vlocode-project - v2.4.3
    Preparing search index...

    Class DatapackRecordMatcher

    Matches datapack records that cannot be identified through a matching key -- typically embedded child records which a deployment deletes and recreates -- against the records in the target org by comparing the record data. Records are located through their resolved parent references and compared field-by-field using OrgRecordComparer.fieldEquals; each org record can only be matched by a single datapack record.

    The matcher is stateful: queried org records and matched record IDs are tracked across calls so subsequent matches (e.g. for records deeper in the datapack tree) do not match the same org record twice. Use one matcher instance per deployment or comparison.

    Index

    Constructors

    Properties

    candidateGroups: Map<string, CandidateGroup> = ...

    Candidate org records grouped by SObject type and lookup scope

    consumedRowIds: Set<string> = ...

    Org record IDs already matched to a datapack record

    logger: Logger
    orgDataStore?: {
        getRows(
            sobjectType: string,
            filter: Record<string, unknown>,
        ): Record<string, unknown>[];
        has(sobjectType: string): boolean;
    }

    Optional store of extracted org records; when set the candidate rows for extracted types are resolved from the store instead of through org queries. Set by the DatapackComparer when bulk extraction is enabled.

    recordComparer: OrgRecordComparer
    salesforceService: SalesforceService

    Methods

    • Index the rows of a candidate group by the canonical form of the values of the specified fields; mirrors the record key built in findMatch so a row and the record it matches produce the same key.

      Parameters

      • group: CandidateGroup
      • shape: string[]

      Returns Map<string, Record<string, any>[]>

    • Find the first unconsumed candidate row in the group that matches the record on all compared fields.

      Candidates are located through an index on the canonical form (OrgRecordComparer.canonicalMatchValue) of the compared values -- the same approach used by the matching key lookups -- and each candidate is verified with OrgRecordComparer.fieldEquals so the exact matching semantics are preserved. Values that OrgRecordComparer.fieldEquals can match fuzzily (date-like strings) or that have no exact canonical form are excluded from the index key and only verified per candidate; records without any indexable value fall back to comparing against every candidate row.

      Parameters

      • record: DatapackDeploymentRecord

        Record to match

      • group: CandidateGroup

        Candidate group with the queried org rows

      • compareFields: string[]

        Fields to compare

      • fields: ReadonlyMap<string, Field>
      • rowIndexes: Map<CandidateGroup, Map<string, Map<string, Record<string, any>[]>>>

        Cache of row indexes per group and field shape shared across the match requests of a single call

      Returns Record<string, any> | undefined

    • Parameters

      • sobjectType: string
      • datapackKey: string
      • scope: Record<string, unknown>
      • scoped: boolean

      Returns CandidateGroup

    • Get the fields of a record that are compared against org data to establish record identity. Unlike the field comparison of an already matched record, create-only fields (e.g. master-detail relationships) are included: they cannot be updated but they are set on insert and often are the only fields that discriminate between sibling records. Fields that do not exist in the target org, that cannot be written at all (formula, auto-number) or that contain binary data are excluded.

      Parameters

      Returns string[]

    • Build a lookup filter from the filterable field values of a record; used as fallback to locate standalone records without matching key and without parent references. Returns undefined when none of the record fields can be filtered on.

      Parameters

      Returns { filter: Record<string, unknown>; scoped: false } | undefined

    • Get the IDs of the org records in the specified scopes that are not matched to a datapack record. Reuses the org records already queried for matching when available; scopes that were not queried yet are queried in a single batched lookup. Used by the deployment to delete only the unmatched org records of a parent while preserving the records that are matched (and thus in sync) with the datapack.

      Parameters

      • sobjectType: string

        SObject type of the scopes

      • scopes: Record<string, unknown>[]

        Scope filters, i.e. { parentField: parentId } per parent

      • OptionalcancelToken: CancellationToken

        An optional cancellation token to abort the org lookups

      Returns Promise<string[][]>

      Per scope (in input order) the org record IDs that are not matched to a datapack record

    • Match datapack records without matching key against org data by querying the org records in the same scope (child records of the same parent) and comparing all comparable fields.

      Records that match consume the matched org record and report an inSync outcome including the matched record ID; records without an org match report a missing outcome with the record data that is missing. The caller decides how to act on the outcomes (e.g. skip the record in a deployment or report it). Records without an outcome were not matched due to a cancellation and should be treated as not matched.

      Parameters

      Returns Promise<Map<string, RecordMatchOutcome>>

      Match outcome per record keyed by record source key

    • Query the org records for candidate groups that have not been queried yet or require additional fields; queried rows are merged into the group by record ID. Rows are assigned to their group(s) through an index on the canonical form of the scope values -- scopes with values that cannot be indexed exactly are compared per row -- and each assignment is verified with OrgRecordComparer.recordMatches to preserve the exact matching semantics.

      Parameters

      Returns Promise<void>

    • Release the record IDs consumed by previous matches while retaining queried candidate rows. A deployment comparison calls this after building its result so the same matcher can subsequently be reused by the deployment's embedded-record purge without querying the org again.

      Returns void