synology_apm_repo.sdk.units.saas.object_name_index module

The per-version object-name index the connector records in copy_target_version’s additional_meta: which object holds each named service DB, and the ObjectDB location (<stream_uuid>_<offset>_<length>) that maps them. Plus the shared lookup helpers SaaS providers’ secondary-table reads build on.

Every function here returns None rather than raising when the index isn’t recorded or a lookup can’t be completed; a store failure still raises.

synology_apm_repo.sdk.units.saas.object_name_index.DEGRADABLE_OPEN_ERRORS: tuple[type[Exception], ...] = (<class 'sqlite3.DatabaseError'>, <class 'synology_apm_repo.sdk.errors.DataCorruptError'>, <class 'synology_apm_repo.sdk.errors.ResourceLimitExceededError'>)

The errors meaning “this candidate isn’t a safely-openable service DB/ObjectDB”, caught wherever a SaaS provider reads and opens one speculatively: corruption, or a size over a safety ceiling or over the free disk space above the reserve.

class synology_apm_repo.sdk.units.saas.object_name_index.ObjectNameIndex(stream_uuid, offset, length, object_ids)

Bases: object

One version’s object-name index: indexed db name -> object_id (object_ids), resolved through the ObjectDB at offset/length in stream stream_uuid.

stream_uuid: str
offset: int
length: int
object_ids: Mapping[str, str]
async synology_apm_repo.sdk.units.saas.object_name_index.resolve_object_name_index(repo, version)

version’s object-name index, or None when none is recorded (no copy_target_version row, an unreadable version_spec, or a missing/malformed additional_meta, e.g. an older connector; a field of the wrong JSON type counts as missing). Doesn’t validate the ObjectDB it points at.

class synology_apm_repo.sdk.units.saas.object_name_index.ResolvedServiceDb(object_id, source)

Bases: NamedTuple

A service DB resolve_service_db opened: the index object_id it came from, and its open source (the caller closes it).

object_id: str

Alias for field number 0

source: SqliteSource

Alias for field number 1

async synology_apm_repo.sdk.units.saas.object_name_index.resolve_service_db(dedup_file, object_db, object_name_index, object_names, table_name)

Open the service DB defining table_name: tries each object_names alias in order against object_db (the index’s loaded ObjectDB), returning the first that exists, opens, and defines table_name; one whose DB can’t be opened or whose schema can’t be read (DEGRADABLE_OPEN_ERRORS) is skipped. None when no alias resolves.

async synology_apm_repo.sdk.units.saas.object_name_index.read_indexed_table(dedup_file, object_name_index, object_names, table_name, reader, *, object_db=None)

Best-effort one-shot read of a secondary table (folder, label and group name tables): opens it via resolve_service_db, hands its connection to reader, and closes it.

None when there’s no index, no alias resolves, or the read hits corruption or schema drift — callers treat the result as optional enrichment and show less without it.

object_db is the index’s ObjectDB if the caller already holds it; otherwise one is loaded and closed here.

async synology_apm_repo.sdk.units.saas.object_name_index.read_id_to_name_map(dedup_file, object_name_index, object_names, table_name, *, id_column, name_column, object_db=None)

read_indexed_table for a folder/label/group definitions table: {str(id_column): str(name_column)}, or None.

async synology_apm_repo.sdk.units.saas.object_name_index.read_grouped_names(dedup_file, object_name_index, *, definition_names, definition_table, id_column, name_column, membership_names, membership_table, item_column, group_column, object_db=None, membership_connection=None)

Best-effort item_id -> [group/label names] map joining a definitions table (id_column -> name_column) with a membership table (item_column, group_column) — GWS’s mail labels and contact groups. None if either half is unavailable; a group id with no definition shows as the raw id.

membership_connection, the membership_names DB when the caller already holds it open, is queried in place of opening it again, if it defines membership_table.