synology_apm_repo.sdk.units.saas.services module

Content inspection for embedded saas_obj objects already located through the object-name index: open_service_db opens a service DB snapshot, sniff/inspect_object classify an object’s bytes. Never used to discover where an object is.

Bytes classify into ServiceKind by a fixed rule: ZSTD-framed SQLite, then a JSON object, then an RFC822 header, else binary.

class synology_apm_repo.sdk.units.saas.services.ServiceKind(*values)

Bases: Enum

What one already-located object’s raw bytes turn out to be (sniff’s classification).

  • SERVICE_DB: ZSTD -> SQLite; the owning app is guessed from its sqlite_master table names (_SERVICE_TABLE_HINTS).

  • INDEX: JSON matching the db_objects/ db_infos_in_snapshot shape (_index_entries) — extracted as IndexEntry tuples.

  • META_JSON: any other JSON object (content-list fragments, Contact/Calendar client metadata, search-index documents).

  • MAIL_SKELETON: an RFC822 header in the first few hundred bytes.

  • BINARY: anything else — the common case for real Drive content.

INDEX = 'index'
SERVICE_DB = 'service_db'
META_JSON = 'meta_json'
MAIL_SKELETON = 'mail_skeleton'
BINARY = 'binary'
class synology_apm_repo.sdk.units.saas.services.IndexEntry(name, object_id)

Bases: object

One entry in a connector’s own index object: a display name paired with the backing object id.

name: str
object_id: str
class synology_apm_repo.sdk.units.saas.services.SniffResult(kind, tables=frozenset({}), service_name=None, index_entries=())

Bases: object

What sniffing a service-DB/index object’s bytes found: its ServiceKind, plus whichever of tables/service_name/ index_entries that kind actually carries.

kind: ServiceKind
tables: frozenset[str]
service_name: str | None
index_entries: tuple[IndexEntry, ...]
async synology_apm_repo.sdk.units.saas.services.open_service_db(data)

Decompress one service-level DB snapshot’s bytes into a temp file and open it as SQLite; the caller closes the returned source. No fixed size cap, since the object was already identified through the index; a frame declaring no size is bounded by the free disk space above the reserve.

Raises:
async synology_apm_repo.sdk.units.saas.services.sniff(data)

Classify one object’s raw bytes into a ServiceKind. Touches no repository; decompression runs off the event loop.

A zstd frame that fails to decompress, or declares a size over _MAX_SNIFF_DECOMPRESS (checked before decompressing, since data is untrusted), is unclassifiable rather than an error, as is {-prefixed data that doesn’t parse as JSON (invalid, or nested too deep for the decoder).

Raises:
async synology_apm_repo.sdk.units.saas.services.inspect_object(dedup_file, offset, length)

sniff an already-located object, reading only its head when it’s over _FULL_READ_CAP and not zstd-framed.

Raises: