farseer-cli 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +328 -0
- package/dist/commands/code.js +104 -0
- package/dist/commands/code.js.map +7 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +2 -2
- package/dist/pipeline/service.js +1 -1
- package/dist/pipeline/service.js.map +2 -2
- package/dist/services/codefirst/api.js +269 -0
- package/dist/services/codefirst/api.js.map +7 -0
- package/dist/services/codefirst/binaryDisk.js +67 -0
- package/dist/services/codefirst/binaryDisk.js.map +7 -0
- package/dist/services/codefirst/byteHashes.js +129 -0
- package/dist/services/codefirst/byteHashes.js.map +7 -0
- package/dist/services/codefirst/documents.js +563 -0
- package/dist/services/codefirst/documents.js.map +7 -0
- package/dist/services/codefirst/layoutBinaryProjection.js +974 -0
- package/dist/services/codefirst/layoutBinaryProjection.js.map +7 -0
- package/dist/services/codefirst/layoutCompose.js +593 -0
- package/dist/services/codefirst/layoutCompose.js.map +7 -0
- package/dist/services/codefirst/layoutCore.js +260 -0
- package/dist/services/codefirst/layoutCore.js.map +7 -0
- package/dist/services/codefirst/layoutPaths.js +492 -0
- package/dist/services/codefirst/layoutPaths.js.map +7 -0
- package/dist/services/codefirst/layoutProjection.js +995 -0
- package/dist/services/codefirst/layoutProjection.js.map +7 -0
- package/dist/services/codefirst/layoutReadback.js +2552 -0
- package/dist/services/codefirst/layoutReadback.js.map +7 -0
- package/dist/services/codefirst/layoutReadbackPlacement.js +1517 -0
- package/dist/services/codefirst/layoutReadbackPlacement.js.map +7 -0
- package/dist/services/codefirst/layoutReceipt.js +1592 -0
- package/dist/services/codefirst/layoutReceipt.js.map +7 -0
- package/dist/services/codefirst/layoutScan.js +882 -0
- package/dist/services/codefirst/layoutScan.js.map +7 -0
- package/dist/services/codefirst/output.js +179 -0
- package/dist/services/codefirst/output.js.map +7 -0
- package/dist/services/codefirst/types.js +17 -0
- package/dist/services/codefirst/types.js.map +7 -0
- package/dist/services/codefirst/workflow.js +581 -0
- package/dist/services/codefirst/workflow.js.map +7 -0
- package/dist/services/codefirst/workspace.js +310 -0
- package/dist/services/codefirst/workspace.js.map +7 -0
- package/dist/services/codefirst/workspaceLock.js +148 -0
- package/dist/services/codefirst/workspaceLock.js.map +7 -0
- package/dist/services/codefirst/workspaceRoot.js +147 -0
- package/dist/services/codefirst/workspaceRoot.js.map +7 -0
- package/dist/utils/logger.js +9 -3
- package/dist/utils/logger.js.map +2 -2
- package/package.json +3 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/services/codefirst/layoutProjection.ts"],
|
|
4
|
+
"sourcesContent": ["import { canonicalText } from './documents';\nimport { parseWorkspacePointer } from './layoutPaths';\nimport {\n allocateSubmissionToken,\n canonicalFragmentHash as fragmentHash,\n hashCanonicalText,\n groupBySource,\n matchExactSubmissionProof,\n object,\n own,\n ownerKey,\n RESOURCE_ID,\n SHA256,\n sourceIdentityKey as sourceKey,\n without,\n type JsonObject,\n} from './layoutCore';\nimport { Document, Json } from './types';\n\nexport type ResourceIdentity = { kind: string; id: string } | { kind: string; key: string };\nexport type GroupOwnerSelector =\n | { kind: string; id: string }\n | { kind: string; key: string }\n | { kind: string; dangling: string };\nexport type SourceIdentity =\n | { type: 'resource'; resource: ResourceIdentity }\n | { type: 'group'; owner: GroupOwnerSelector }\n | { type: 'transient'; token: string };\nexport type ShareEntryIdentity = { id: string } | { key: string } | { transient: string };\n\nexport type FragmentSelector =\n | { file: string; slot: 'document' | 'table-definition' | 'member-set' | 'owner-navigation' }\n | { file: string; slot: 'share-group-owner' }\n | { file: string; slot: 'share-entry'; identity: ShareEntryIdentity };\n\nexport interface GroupedDocumentArtifact {\n role: 'document';\n path: string;\n value: JsonObject;\n}\n\nexport interface CombinedTableArtifact {\n role: 'combined-table';\n path: string;\n value: JsonObject;\n}\n\nexport interface ShareGroupArtifact {\n role: 'share-group';\n path: string;\n value: JsonObject;\n}\n\nexport type GroupedLayoutArtifact = GroupedDocumentArtifact | CombinedTableArtifact | ShareGroupArtifact;\n\nexport interface ProvenFragmentRoute {\n source: SourceIdentity;\n selector: FragmentSelector;\n sourcePath: (string | number)[];\n priorCleanHash: string;\n derivedSelectorHash?: string;\n contributor: boolean;\n}\n\nexport interface SubmissionCorrespondence {\n source: { type: 'transient'; token: string };\n selector: FragmentSelector;\n sourcePath: (string | number)[];\n fragmentHash: string;\n containerHash: string;\n}\n\nexport interface DerivedSourceProof {\n source: { type: 'resource'; resource: { kind: 'user_permissions'; id: string } };\n selectorHash: string;\n}\n\nexport interface FragmentObservation {\n source: SourceIdentity;\n selector: FragmentSelector;\n sourcePath: (string | number)[];\n currentHash?: string;\n priorCleanHash?: string;\n derivedSelectorHash?: string;\n state: 'clean' | 'dirty' | 'absent' | 'new' | 'present-unclassified';\n contributor: boolean;\n}\n\nexport interface WireSourceMapping {\n documentIndex: number;\n sourcePath: (string | number)[];\n source: SourceIdentity;\n selector: FragmentSelector;\n derivedSelectorHash?: string;\n groupOwner?: GroupOwnerSelector;\n ownerDocument?: { file: string; kind: string; folderLength?: number };\n externalOwnerLocation?: ArtifactSourceLocation;\n wireOwner?: JsonObject;\n}\n\nexport interface ArtifactSourceLocation {\n file: string;\n path: (string | number)[];\n}\n\nexport interface ExternalGroupedOwner {\n source: Extract<SourceIdentity, { type: 'resource' }>;\n owner: { kind: 'file'; id: string } | { kind: 'file'; key: string };\n value: { [key: string]: Json };\n location: ArtifactSourceLocation;\n currentGroupFile?: string;\n priorGroupFile?: string;\n}\n\nexport interface OwnerNavigationRoute {\n source: SourceIdentity;\n selector: { file: string; slot: 'owner-navigation' };\n sourcePath: (string | number)[];\n groupFile: string;\n owner: Exclude<GroupOwnerSelector, { dangling: string }>;\n}\n\nexport interface ProjectionDiagnostic {\n code: string;\n path: string;\n message: string;\n sourcePath?: (string | number)[];\n relatedPath?: string;\n}\n\nexport interface ComposeGroupedLayoutInput {\n artifacts: readonly GroupedLayoutArtifact[];\n externalOwners?: readonly ExternalGroupedOwner[];\n priorRoutes?: readonly ProvenFragmentRoute[];\n submissionProofs?: readonly SubmissionCorrespondence[];\n /** Tokens a saved submission already used; a fragment without proof never receives one of them. */\n reservedTransientTokens?: readonly string[];\n derivedSourceProofs?: readonly DerivedSourceProof[];\n}\n\nexport interface ComposeGroupedLayoutResult {\n documents: Document[];\n sources: WireSourceMapping[];\n observations: FragmentObservation[];\n submissions: SubmissionCorrespondence[];\n navigation: OwnerNavigationRoute[];\n diagnostics: ProjectionDiagnostic[];\n}\n\nexport interface ArtifactPatch {\n source: SourceIdentity;\n selector: FragmentSelector;\n expectedCurrentHash?: string;\n action: 'set' | 'remove';\n value?: Json;\n}\n\nexport interface DecomposeGroupedLayoutInput {\n documents: readonly Document[];\n documentKeys: readonly string[];\n sources: readonly WireSourceMapping[];\n /** Seed for delete materialization. No caller supplies it yet. */\n navigation?: readonly OwnerNavigationRoute[];\n /** Seed for delete materialization. No caller supplies it yet. */\n removals?: readonly Pick<ProvenFragmentRoute, 'source' | 'selector'>[];\n currentArtifacts: readonly GroupedLayoutArtifact[];\n /** The caller's already composed current layout. This function never composes it again. */\n current: ComposeGroupedLayoutResult;\n submissionProofs?: readonly SubmissionCorrespondence[];\n /** The sources this plan writes at another destination or removes: their files are free. */\n vacating?: readonly SourceIdentity[];\n}\n\nexport interface DecomposeGroupedLayoutResult {\n patches: ArtifactPatch[];\n diagnostics: ProjectionDiagnostic[];\n}\n\ninterface CurrentFragment {\n source: SourceIdentity;\n selector: FragmentSelector;\n sourcePath: (string | number)[];\n hash: string;\n containerHash?: string;\n derivedSelectorHash?: string;\n contributor: boolean;\n}\n\ninterface OwnerArtifact {\n path: string;\n value: JsonObject;\n source: SourceIdentity;\n selector: Exclude<GroupOwnerSelector, { dangling: string }> | undefined;\n pointer?: string;\n priorPointer?: string;\n external?: boolean;\n locationPath?: (string | number)[];\n}\n\nconst OWNER_KINDS = new Set(['folder', 'variable', 'dimension_table', 'sheet', 'dashboard', 'file', 'remote_job']);\nconst GLOBAL_OWNER_KINDS = new Set(['variable', 'dimension_table']);\nconst DOCUMENT_KINDS = new Set<Document['kind']>([\n 'folder',\n 'variable',\n 'dimension_table',\n 'dimension_members',\n 'sheet',\n 'dashboard',\n 'share',\n 'user_group',\n 'user_permissions',\n 'label',\n 'settings',\n 'file',\n 'export_configuration',\n 'remote_job',\n 'dataset',\n]);\n\nexport function derivedSourceSelectorHash(document: Document): string | undefined {\n return document.kind === 'user_permissions' && own(document, 'user')\n ? fragmentHash(document.user as Json)\n : undefined;\n}\n\nfunction identityFrom(value: JsonObject, kind: string): ResourceIdentity | undefined {\n if (typeof value.id === 'string') return { kind, id: value.id };\n if (typeof value.key === 'string') return { kind, key: value.key };\n return undefined;\n}\n\nfunction semanticSource(source: SourceIdentity, kind: string): SourceIdentity {\n if (source.type !== 'resource') return source;\n return 'id' in source.resource\n ? { type: 'resource', resource: { kind, id: source.resource.id } }\n : { type: 'resource', resource: { kind, key: source.resource.key } };\n}\n\nfunction selectorSlot(selector: FragmentSelector): FragmentSelector['slot'] {\n return selector.slot;\n}\n\nfunction submissionScopeKey(file: string, slot: FragmentSelector['slot']): string {\n return JSON.stringify([file, slot]);\n}\n\nfunction submissionEvidenceHash(fragment: unknown, container: unknown): string | undefined {\n return typeof fragment === 'string' && fragment.length > 0 && typeof container === 'string' && container.length > 0\n ? fragmentHash({ fragmentHash: fragment, containerHash: container })\n : undefined;\n}\n\nfunction sameSelectorLocation(left: FragmentSelector, right: FragmentSelector): boolean {\n if (left.slot !== right.slot || left.file !== right.file) return false;\n if (left.slot !== 'share-entry' || right.slot !== 'share-entry') return true;\n const a = left.identity;\n const b = right.identity;\n if ('id' in a && 'id' in b) return a.id === b.id;\n if ('key' in a && 'key' in b) return a.key === b.key;\n return 'transient' in a && 'transient' in b && a.transient === b.transient;\n}\n\nexport function composeGroupedLayout(input: ComposeGroupedLayoutInput): ComposeGroupedLayoutResult {\n const priorRoutes = input.priorRoutes ?? [];\n /** The prior routes of each source, in their original order, so a lookup never scans them all. */\n const priorBySource = new Map<string, { route: ProvenFragmentRoute; index: number }[]>();\n priorRoutes.forEach((route, index) => {\n const key = sourceKey(route.source);\n const list = priorBySource.get(key);\n if (list) list.push({ route, index });\n else priorBySource.set(key, [{ route, index }]);\n });\n const priorRoutesOf = (source: SourceIdentity) => priorBySource.get(sourceKey(source)) ?? [];\n const submissionProofs = input.submissionProofs ?? [];\n const documents: Document[] = [];\n const sources: WireSourceMapping[] = [];\n const navigation: OwnerNavigationRoute[] = [];\n const diagnostics: ProjectionDiagnostic[] = [];\n const fragments: CurrentFragment[] = [];\n const owners = new Map<string, OwnerArtifact[]>();\n const groups = new Map<string, { path: string; owner: GroupOwnerSelector }>();\n const artifactPaths = new Set<string>();\n const stableResources = new Map<string, string>();\n const unclassifiedFiles = new Set<string>();\n const usedTransientTokens = new Set([\n ...submissionProofs.map((proof) => proof.source.token),\n ...(input.reservedTransientTokens ?? []),\n ]);\n const normalizedSubmissionProofs = submissionProofs.map((proof) => ({\n token: proof.source.token,\n scopeKey: submissionScopeKey(proof.selector.file, proof.selector.slot),\n sourcePath: proof.sourcePath,\n evidenceHash: submissionEvidenceHash(proof.fragmentHash, proof.containerHash),\n }));\n let transientSequence = 0;\n\n const diagnostic = (\n code: string,\n path: string,\n message: string,\n sourcePath?: (string | number)[],\n relatedPath?: string,\n ) =>\n diagnostics.push({\n code,\n path,\n message,\n ...(sourcePath ? { sourcePath } : {}),\n ...(relatedPath ? { relatedPath } : {}),\n });\n const newTransient = (): SourceIdentity => {\n const allocated = allocateSubmissionToken(usedTransientTokens, transientSequence);\n transientSequence = allocated.sequence;\n return { type: 'transient', token: allocated.token };\n };\n const transientFor = (\n path: string,\n candidates: readonly { slot: FragmentSelector['slot']; sourcePath: (string | number)[]; hash: string }[],\n containerHash: string,\n ): SourceIdentity => {\n const match = matchExactSubmissionProof(\n normalizedSubmissionProofs,\n candidates.map((candidate) => ({\n scopeKey: submissionScopeKey(path, candidate.slot),\n sourcePath: candidate.sourcePath,\n evidenceHash: submissionEvidenceHash(candidate.hash, containerHash)!,\n })),\n );\n if (match.status === 'matched') return { type: 'transient', token: match.token };\n if (match.status === 'ambiguous')\n diagnostic('ambiguous-source-correspondence', path, 'Multiple transient routes match this fragment');\n else if (match.status === 'lost')\n diagnostic('lost-source-correspondence', path, 'The unchanged transient source can no longer be located');\n return newTransient();\n };\n const canonicalTexts = new Map<GroupedLayoutArtifact, string>();\n const validatePath = (artifact: GroupedLayoutArtifact): boolean => {\n // The scan validated every artifact path before composition; a bad path here is a caller error.\n parseWorkspacePointer(artifact.path);\n if (artifactPaths.has(artifact.path)) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('duplicate-artifact-path', artifact.path, 'Multiple artifacts use the same path');\n return false;\n }\n artifactPaths.add(artifact.path);\n try {\n canonicalTexts.set(artifact, canonicalText(artifact.value));\n return true;\n } catch (error) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-json-value', artifact.path, (error as Error).message);\n return false;\n }\n };\n const validateIdentity = (value: JsonObject, path: string): boolean => {\n if (own(value, 'id') && own(value, 'key')) {\n diagnostic('duplicate-local-identity', path, 'An artifact cannot contain both id and key');\n return false;\n }\n if (own(value, 'id') && (typeof value.id !== 'string' || !RESOURCE_ID.test(value.id))) {\n diagnostic('invalid-resource-id', path, 'Resource id must be a canonical non-negative integer string');\n return false;\n }\n if (own(value, 'key') && (typeof value.key !== 'string' || value.key.length === 0)) {\n diagnostic('invalid-local-key', path, 'Local key must be a nonempty string');\n return false;\n }\n return true;\n };\n const addOwner = (owner: OwnerArtifact) => {\n if (!owner.selector) return;\n const key = ownerKey(owner.selector);\n owners.set(key, [...(owners.get(key) ?? []), owner]);\n };\n const claimResource = (identity: ResourceIdentity, path: string, sourcePath?: (string | number)[]): boolean => {\n const key = sourceKey({ type: 'resource', resource: identity });\n const previous = stableResources.get(key);\n if (!previous) {\n stableResources.set(key, path);\n return true;\n }\n unclassifiedFiles.add(path);\n unclassifiedFiles.add(previous);\n diagnostic(\n identity.kind === 'share' ? 'duplicate-share-identity' : 'duplicate-resource-identity',\n path,\n `A semantic resource identity occurs in both ${previous} and ${path}`,\n sourcePath,\n previous,\n );\n return false;\n };\n const addNavigation = (owner: OwnerArtifact) => {\n if (!own(owner.value, 'shares')) return;\n if (!OWNER_KINDS.has(String(owner.value.kind))) {\n unclassifiedFiles.add(owner.path);\n diagnostic('unsupported-share-pointer', owner.path, 'This resource kind cannot own a share group', [\n 'shares',\n ]);\n return;\n }\n if (!owner.selector) {\n unclassifiedFiles.add(owner.path);\n diagnostic('missing-owner-key', owner.path, 'A new owner with a share pointer requires a local key', [\n 'shares',\n ]);\n return;\n }\n const pointer = object(owner.value.shares);\n if (!pointer || Object.keys(pointer).length !== 1 || typeof pointer.file !== 'string') {\n unclassifiedFiles.add(owner.path);\n diagnostic('invalid-share-pointer', owner.path, 'The shares pointer must contain only a file string', [\n 'shares',\n ]);\n return;\n }\n let file: string;\n try {\n file = parseWorkspacePointer(pointer.file);\n } catch (error) {\n unclassifiedFiles.add(owner.path);\n diagnostic('invalid-share-pointer', owner.path, (error as Error).message, ['shares']);\n return;\n }\n owner.pointer = file;\n const selector = { file: owner.path, slot: 'owner-navigation' as const };\n fragments.push({\n source: owner.source,\n selector,\n sourcePath: ['shares'],\n hash: fragmentHash({ file }),\n containerHash: fragmentHash(owner.value),\n contributor: false,\n });\n navigation.push({\n source: owner.source,\n selector,\n sourcePath: ['shares'],\n groupFile: file,\n owner: owner.selector,\n });\n };\n const addWireDocument = (\n document: Document,\n source: SourceIdentity,\n selector: FragmentSelector,\n sourcePath: (string | number)[],\n /** The fragment hash its caller already computed for the transient correspondence. */\n hash: string,\n metadata: {\n containerHash?: string;\n derivedSelectorHash?: string;\n groupOwner?: GroupOwnerSelector;\n ownerDocument?: { file: string; kind: string; folderLength?: number };\n externalOwnerLocation?: ArtifactSourceLocation;\n wireOwner?: JsonObject;\n } = {},\n ) => {\n const documentIndex = documents.length;\n documents.push(document);\n sources.push({ documentIndex, sourcePath, source, selector, ...metadata });\n fragments.push({\n source,\n selector,\n sourcePath,\n hash,\n ...(metadata.containerHash ? { containerHash: metadata.containerHash } : {}),\n ...(metadata.derivedSelectorHash ? { derivedSelectorHash: metadata.derivedSelectorHash } : {}),\n contributor: true,\n });\n };\n const priorProvesNavigation = (owner: OwnerArtifact, groupFile: string): boolean =>\n owner.external\n ? owner.priorPointer === groupFile\n : priorRoutesOf(owner.source).some(\n ({ route }) => route.selector.file === owner.path && route.selector.slot === 'owner-navigation',\n );\n const priorProvesGroup = (path: string, owner: Exclude<GroupOwnerSelector, { dangling: string }>): boolean => {\n const source: SourceIdentity = { type: 'group', owner };\n return priorRoutesOf(source).some(\n ({ route }) => route.selector.file === path && route.selector.slot === 'share-group-owner',\n );\n };\n\n const validArtifacts = input.artifacts.filter(validatePath);\n /** The container hash of a valid artifact, from the canonical text its validation built. */\n const containerHashOf = (artifact: GroupedLayoutArtifact): string =>\n hashCanonicalText(canonicalTexts.get(artifact)!);\n const derivedProofs: DerivedSourceProof[] = [];\n const seenDerivedProofs = new Set<string>();\n const addDerivedProof = (\n source: SourceIdentity,\n selectorHash: string | undefined,\n path: string,\n validSelector: boolean,\n ) => {\n if (selectorHash === undefined) return;\n if (\n source.type !== 'resource' ||\n source.resource.kind !== 'user_permissions' ||\n !('id' in source.resource) ||\n !validSelector ||\n typeof source.resource.id !== 'string' ||\n typeof selectorHash !== 'string' ||\n !RESOURCE_ID.test(source.resource.id) ||\n !SHA256.test(selectorHash)\n ) {\n diagnostic(\n 'invalid-derived-source-proof',\n path,\n 'A derived source proof must pair a canonical user-permissions ID with a selector hash',\n );\n return;\n }\n const proof: DerivedSourceProof = {\n source: {\n type: 'resource',\n resource: { kind: 'user_permissions', id: source.resource.id },\n },\n selectorHash,\n };\n const key = `${sourceKey(proof.source)}/${selectorHash}`;\n if (!seenDerivedProofs.has(key)) {\n seenDerivedProofs.add(key);\n derivedProofs.push(proof);\n }\n };\n for (const route of priorRoutes)\n addDerivedProof(\n route.source,\n route.derivedSelectorHash,\n route.selector.file,\n route.selector.slot === 'document',\n );\n for (const proof of input.derivedSourceProofs ?? [])\n addDerivedProof(proof.source, proof.selectorHash, 'source-provenance', true);\n const derivedArtifactCounts = new Map<string, number>();\n for (const artifact of validArtifacts) {\n if (artifact.role === 'share-group' || artifact.value.kind !== 'user_permissions') continue;\n const selectorHash = derivedSourceSelectorHash(artifact.value as Document);\n if (selectorHash) derivedArtifactCounts.set(selectorHash, (derivedArtifactCounts.get(selectorHash) ?? 0) + 1);\n }\n let unprovenDerivedArtifacts = 0;\n for (const artifact of validArtifacts) {\n if (artifact.role === 'share-group') continue;\n const value = artifact.value;\n const containerHash = containerHashOf(artifact);\n if (typeof value.kind !== 'string' || !DOCUMENT_KINDS.has(value.kind as Document['kind'])) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-document-kind', artifact.path, 'Grouped document has an unsupported kind');\n continue;\n }\n if (value.kind === 'share' || value.kind === 'dimension_members') {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-grouped-role', artifact.path, `${value.kind} must use its grouped representation`);\n continue;\n }\n if (artifact.role === 'combined-table' && value.kind !== 'dimension_table') {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-grouped-role', artifact.path, 'A combined table must have kind dimension_table');\n continue;\n }\n if (artifact.role === 'document' && value.kind === 'dimension_table') {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-grouped-role', artifact.path, 'A dimension table must use the combined-table role');\n continue;\n }\n if (!validateIdentity(value, artifact.path)) {\n unclassifiedFiles.add(artifact.path);\n continue;\n }\n if (value.kind === 'user_permissions' && (own(value, 'id') || own(value, 'key'))) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'unsupported-derived-identity',\n artifact.path,\n 'User-permissions identity comes only from authoritative selector provenance',\n );\n continue;\n }\n const authoredIdentity = identityFrom(value, value.kind);\n if (\n value.kind === 'settings' &&\n (authoredIdentity === undefined || !('id' in authoredIdentity) || authoredIdentity.id !== '1') &&\n (own(value, 'id') || own(value, 'key'))\n ) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-settings-identity', artifact.path, 'Settings has the fixed identity settings/1');\n continue;\n }\n const derivedSelectorHash = derivedSourceSelectorHash(value as Document);\n let identity = authoredIdentity;\n if (value.kind === 'settings') identity = { kind: 'settings', id: '1' };\n else if (value.kind === 'user_permissions' && identity === undefined) {\n const matches = derivedSelectorHash\n ? derivedProofs.filter((proof) => proof.selectorHash === derivedSelectorHash)\n : [];\n const currentSelectorCount = derivedSelectorHash\n ? (derivedArtifactCounts.get(derivedSelectorHash) ?? 0)\n : 0;\n const unique = matches.length === 1 && currentSelectorCount === 1;\n if (unique) identity = matches[0].source.resource;\n else {\n unprovenDerivedArtifacts += 1;\n if (matches.length > 1 || currentSelectorCount > 1)\n diagnostic(\n 'ambiguous-derived-source',\n artifact.path,\n 'A user-permissions selector does not have one unique source proof',\n );\n }\n }\n if (identity && !claimResource(identity, artifact.path)) continue;\n const definition = without(value, [\n 'key',\n 'shares',\n ...(artifact.role === 'combined-table' ? ['members'] : []),\n ]);\n if (artifact.role === 'combined-table' && !Array.isArray(value.members)) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('missing-table-members', artifact.path, 'A combined dimension table requires members');\n continue;\n }\n if (artifact.role === 'combined-table' && typeof value.name !== 'string') {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-table-name', artifact.path, 'A combined dimension table requires a name');\n continue;\n }\n const definitionHash = fragmentHash(definition);\n const memberHash =\n artifact.role === 'combined-table' ? fragmentHash({ members: value.members as Json[] }) : undefined;\n const baseSource = identity\n ? ({ type: 'resource', resource: identity } as const)\n : transientFor(\n artifact.path,\n [\n {\n slot: artifact.role === 'combined-table' ? 'table-definition' : 'document',\n sourcePath: [],\n hash: definitionHash,\n },\n ...(memberHash === undefined\n ? []\n : [{ slot: 'member-set' as const, sourcePath: ['members'], hash: memberHash }]),\n ],\n containerHash,\n );\n const selector: FragmentSelector = {\n file: artifact.path,\n slot: artifact.role === 'combined-table' ? 'table-definition' : 'document',\n };\n addWireDocument(definition as Document, baseSource, selector, [], definitionHash, {\n containerHash,\n ...(derivedSelectorHash ? { derivedSelectorHash } : {}),\n });\n const ownerSelector = identity\n ? 'id' in identity\n ? ({ kind: value.kind, id: identity.id } as const)\n : ({ kind: value.kind, key: identity.key } as const)\n : undefined;\n const owner: OwnerArtifact = {\n path: artifact.path,\n value,\n source: baseSource,\n selector: OWNER_KINDS.has(value.kind) ? ownerSelector : undefined,\n };\n addOwner(owner);\n addNavigation(owner);\n if (artifact.role === 'combined-table') {\n const memberSource = semanticSource(baseSource, 'dimension_members');\n const memberDocument: Document = {\n kind: 'dimension_members',\n table: identity && 'id' in identity ? { id: identity.id } : value.name,\n members: value.members as Json[],\n };\n addWireDocument(\n memberDocument,\n memberSource,\n { file: artifact.path, slot: 'member-set' },\n ['members'],\n memberHash!,\n { containerHash },\n );\n }\n }\n\n for (const external of input.externalOwners ?? []) {\n const locationPath = [...external.location.path];\n const expectedResource = external.source.resource;\n const selectorMatches =\n expectedResource.kind === 'file' &&\n external.owner.kind === 'file' &&\n (('id' in expectedResource && 'id' in external.owner && expectedResource.id === external.owner.id) ||\n ('key' in expectedResource && 'key' in external.owner && expectedResource.key === external.owner.key));\n if (!selectorMatches || external.value.kind !== 'file') {\n diagnostic(\n 'invalid-external-owner',\n external.location.file,\n 'External owner source, selector, and value must identify the same file',\n locationPath,\n );\n continue;\n }\n if (!claimResource(expectedResource, external.location.file, locationPath)) continue;\n addOwner({\n path: external.location.file,\n value: external.value,\n source: external.source,\n selector: external.owner,\n ...(external.currentGroupFile ? { pointer: external.currentGroupFile } : {}),\n ...(external.priorGroupFile ? { priorPointer: external.priorGroupFile } : {}),\n external: true,\n locationPath,\n });\n }\n\n const groupArtifacts = validArtifacts.filter(\n (artifact): artifact is ShareGroupArtifact => artifact.role === 'share-group',\n );\n for (const artifact of groupArtifacts) {\n const value = artifact.value;\n const containerHash = containerHashOf(artifact);\n if (Object.keys(value).some((field) => field !== 'owner' && field !== 'shares')) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('unknown-group-field', artifact.path, 'A share group can contain only owner and shares');\n continue;\n }\n const ownerValue = object(value.owner);\n if (!ownerValue || typeof ownerValue.kind !== 'string' || !OWNER_KINDS.has(ownerValue.kind)) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-group-owner', artifact.path, 'A share group requires a supported owner');\n continue;\n }\n const variants = ['id', 'key', 'dangling'].filter((field) => own(ownerValue, field));\n if (Object.keys(ownerValue).length !== 2 || variants.length !== 1) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'invalid-group-owner',\n artifact.path,\n 'A share group owner requires exactly one tagged selector',\n );\n continue;\n }\n const variant = variants[0] as 'id' | 'key' | 'dangling';\n const selected = ownerValue[variant];\n if (\n typeof selected !== 'string' ||\n selected.length === 0 ||\n ((variant === 'id' || variant === 'dangling') && !RESOURCE_ID.test(selected))\n ) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-group-owner', artifact.path, `Invalid share group owner ${variant}`);\n continue;\n }\n const owner = { kind: ownerValue.kind, [variant]: selected } as GroupOwnerSelector;\n const ownerIdentity = ownerKey(owner);\n const previousGroup = groups.get(ownerIdentity);\n if (previousGroup) {\n unclassifiedFiles.add(artifact.path);\n unclassifiedFiles.add(previousGroup.path);\n diagnostic(\n 'duplicate-owner-group',\n artifact.path,\n 'More than one share group has the same owner selector',\n ['owner'],\n previousGroup.path,\n );\n continue;\n }\n if (!Array.isArray(value.shares)) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-share-list', artifact.path, 'A share group requires a shares array', ['shares']);\n continue;\n }\n let wireOwner: JsonObject;\n let ownerDocument: WireSourceMapping['ownerDocument'];\n let externalOwnerLocation: ArtifactSourceLocation | undefined;\n if ('key' in owner) {\n const matches = owners.get(ownerIdentity) ?? [];\n if (matches.length !== 1) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'unbound-owner-key',\n artifact.path,\n matches.length ? 'A local owner key is ambiguous' : 'A local owner key has no matching artifact',\n ['owner'],\n );\n continue;\n }\n const target = matches[0];\n if (\n target.pointer !== artifact.path &&\n !(target.pointer === undefined && priorProvesNavigation(target, artifact.path))\n ) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'unlinked-owner-group',\n artifact.path,\n 'A keyed owner must point to its share group',\n ['owner'],\n target.path,\n );\n continue;\n }\n const targetKind = String(target.value.kind);\n if (!target.external)\n ownerDocument = {\n file: target.path,\n kind: targetKind,\n ...(Array.isArray(target.value.folder) ? { folderLength: target.value.folder.length } : {}),\n };\n else externalOwnerLocation = { file: target.path, path: [...(target.locationPath ?? [])] };\n if (targetKind === 'folder' && Array.isArray(target.value.path))\n wireOwner = { kind: targetKind, path: target.value.path };\n else if (GLOBAL_OWNER_KINDS.has(targetKind) && typeof target.value.name === 'string')\n wireOwner = { kind: targetKind, name: target.value.name };\n else if (\n ['sheet', 'dashboard', 'file', 'remote_job'].includes(targetKind) &&\n Array.isArray(target.value.folder) &&\n typeof target.value.name === 'string'\n )\n wireOwner = { kind: targetKind, path: [...target.value.folder, target.value.name] };\n else {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'unreadable-owner-key',\n artifact.path,\n 'A new keyed owner needs a readable backend owner reference',\n ['owner'],\n target.path,\n );\n continue;\n }\n } else wireOwner = { ...owner };\n\n groups.set(ownerIdentity, { path: artifact.path, owner });\n const headerHash = fragmentHash(owner);\n const headerSource: SourceIdentity = { type: 'group', owner };\n fragments.push({\n source: headerSource,\n selector: { file: artifact.path, slot: 'share-group-owner' },\n sourcePath: ['owner'],\n hash: headerHash,\n containerHash,\n contributor: false,\n });\n for (const [index, entryValue] of value.shares.entries()) {\n const entry = object(entryValue);\n const sourcePath = ['shares', index] as (string | number)[];\n if (!entry) {\n unclassifiedFiles.add(artifact.path);\n diagnostic('invalid-share-entry', artifact.path, 'A share entry must be an object', sourcePath);\n continue;\n }\n if (own(entry, 'kind') || own(entry, 'owner')) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'reserved-share-field',\n artifact.path,\n 'A grouped share entry cannot contain kind or owner',\n sourcePath,\n );\n continue;\n }\n if (!validateIdentity(entry, artifact.path)) {\n unclassifiedFiles.add(artifact.path);\n continue;\n }\n const identity = identityFrom(entry, 'share');\n if (identity && !claimResource(identity, artifact.path, sourcePath)) continue;\n const semanticEntry = without(entry, ['key']);\n const hashValue: JsonObject = { ...semanticEntry, kind: 'share', owner: { ...owner } };\n const entryHash = fragmentHash(hashValue);\n if ('dangling' in owner && (!identity || !('id' in identity))) {\n unclassifiedFiles.add(artifact.path);\n diagnostic(\n 'missing-share-id',\n artifact.path,\n 'A dangling-owner group can contain only existing share IDs',\n sourcePath,\n );\n continue;\n }\n const source = identity\n ? ({ type: 'resource', resource: identity } as const)\n : transientFor(artifact.path, [{ slot: 'share-entry', sourcePath, hash: entryHash }], containerHash);\n const entryIdentity: ShareEntryIdentity = identity\n ? 'id' in identity\n ? { id: identity.id }\n : { key: identity.key }\n : { transient: (source as { type: 'transient'; token: string }).token };\n const document = { ...semanticEntry, kind: 'share', owner: wireOwner } as Document;\n addWireDocument(\n document,\n source,\n { file: artifact.path, slot: 'share-entry', identity: entryIdentity },\n sourcePath,\n entryHash,\n { containerHash, groupOwner: owner, ownerDocument, externalOwnerLocation, wireOwner },\n );\n }\n }\n\n for (const matches of owners.values()) {\n if (matches.length > 1)\n for (const match of matches)\n diagnostic(\n 'duplicate-owner-identity',\n match.path,\n 'More than one local artifact has this owner identity',\n );\n }\n for (const owner of [...owners.values()].flat()) {\n if (!owner.pointer) continue;\n const group = groups.get(owner.selector ? ownerKey(owner.selector) : '');\n const trackedMissingGroup =\n !group && owner.selector !== undefined && priorProvesGroup(owner.pointer, owner.selector);\n if ((!group && !trackedMissingGroup) || (group && group.path !== owner.pointer))\n diagnostic(\n 'mismatched-share-pointer',\n owner.path,\n 'The owner pointer and share group selector do not agree',\n owner.locationPath ? [...owner.locationPath, 'shares'] : ['shares'],\n owner.pointer,\n );\n }\n for (const group of groups.values()) {\n if ('dangling' in group.owner) continue;\n const matches = owners.get(ownerKey(group.owner)) ?? [];\n const owner = matches[0];\n const trackedMissingNavigation =\n matches.length === 1 && owner.pointer === undefined && priorProvesNavigation(owner, group.path);\n if (matches.length === 1 && owner.pointer !== group.path && !trackedMissingNavigation)\n diagnostic(\n 'unlinked-owner-group',\n group.path,\n 'The local owner does not point to this share group',\n ['owner'],\n owner.path,\n );\n }\n\n const observations: FragmentObservation[] = [];\n const matchedPrior = new Set<number>();\n for (const fragment of fragments) {\n const candidates =\n fragment.source.type === 'transient'\n ? []\n : priorRoutesOf(fragment.source).filter(\n ({ route }) =>\n route.source.type !== 'transient' &&\n selectorSlot(route.selector) === selectorSlot(fragment.selector),\n );\n const prior = candidates.length === 1 ? candidates[0] : undefined;\n if (candidates.length > 1)\n diagnostic('ambiguous-fragment-route', fragment.selector.file, 'Multiple prior routes match this fragment');\n if (prior) matchedPrior.add(prior.index);\n observations.push({\n source: fragment.source,\n selector: fragment.selector,\n sourcePath: fragment.sourcePath,\n currentHash: fragment.hash,\n ...(prior ? { priorCleanHash: prior.route.priorCleanHash } : {}),\n ...(fragment.derivedSelectorHash ? { derivedSelectorHash: fragment.derivedSelectorHash } : {}),\n state: prior ? (prior.route.priorCleanHash === fragment.hash ? 'clean' : 'dirty') : 'new',\n contributor: fragment.contributor,\n });\n }\n priorRoutes.forEach((route, index) => {\n if (matchedPrior.has(index)) return;\n observations.push({\n source: route.source,\n selector: route.selector,\n sourcePath: route.sourcePath,\n priorCleanHash: route.priorCleanHash,\n ...(route.derivedSelectorHash ? { derivedSelectorHash: route.derivedSelectorHash } : {}),\n state:\n unclassifiedFiles.has(route.selector.file) ||\n (unprovenDerivedArtifacts > 0 &&\n route.source.type === 'resource' &&\n route.source.resource.kind === 'user_permissions')\n ? 'present-unclassified'\n : 'absent',\n contributor: route.contributor,\n });\n });\n const submissions = fragments.flatMap((fragment): SubmissionCorrespondence[] =>\n fragment.source.type === 'transient' && fragment.containerHash\n ? [\n {\n source: fragment.source,\n selector: fragment.selector,\n sourcePath: fragment.sourcePath,\n fragmentHash: fragment.hash,\n containerHash: fragment.containerHash,\n },\n ]\n : [],\n );\n return { documents, sources, observations, submissions, navigation, diagnostics };\n}\n\n/** One index of the current composition. Every current lookup below reads it instead of rescanning. */\ninterface CurrentGroupedIndex {\n observedBySource: ReadonlyMap<string, FragmentObservation[]>;\n observedByFile: ReadonlyMap<string, FragmentObservation[]>;\n artifactPaths: ReadonlySet<string>;\n}\n\nfunction currentGroupedIndex(\n current: ComposeGroupedLayoutResult,\n artifacts: readonly GroupedLayoutArtifact[],\n): CurrentGroupedIndex {\n const observed = current.observations.filter((observation) => observation.currentHash !== undefined);\n return {\n observedBySource: groupBySource(observed, (observation) => sourceKey(observation.source)),\n observedByFile: groupBySource(observed, (observation) => observation.selector.file),\n artifactPaths: new Set(artifacts.map((artifact) => artifact.path)),\n };\n}\n\nfunction currentHash(index: CurrentGroupedIndex, selector: FragmentSelector): string | undefined {\n const matches = (index.observedByFile.get(selector.file) ?? []).filter((observation) =>\n sameSelectorLocation(observation.selector, selector),\n );\n return matches.length === 1 ? matches[0].currentHash : undefined;\n}\n\nexport function decomposeGroupedLayout(input: DecomposeGroupedLayoutInput): DecomposeGroupedLayoutResult {\n const current = input.current;\n const index = currentGroupedIndex(current, input.currentArtifacts);\n const diagnostics = [...current.diagnostics];\n const patches: ArtifactPatch[] = [];\n const usedDocuments = new Set<number>();\n const patchedSelectors = new Set<string>();\n const groupOwners = new Map<string, GroupOwnerSelector>();\n const vacating = new Set((input.vacating ?? []).map(sourceKey));\n const diagnostic = (code: string, path: string, message: string) => diagnostics.push({ code, path, message });\n /**\n * A file every current occupant leaves: each one is written at another destination or removed,\n * and the insert's own write overwrites what they leave, so the path is free to take.\n */\n const vacatedFile = (file: string): boolean => {\n const occupants = index.observedByFile.get(file) ?? [];\n return occupants.length > 0 && occupants.every((observation) => vacating.has(sourceKey(observation.source)));\n };\n // A selector names where a resource is now, not where it goes, so one file can carry the patch\n // of the source that leaves it and the patch of the source that takes it: the key holds both.\n const patchKey = (selector: FragmentSelector, source: SourceIdentity) =>\n `${selector.file}/${selector.slot}/${selector.slot === 'share-entry' ? JSON.stringify(selector.identity) : ''}/${sourceKey(source)}`;\n const pushPatch = (patch: ArtifactPatch) => {\n const key = patchKey(patch.selector, patch.source);\n if (patchedSelectors.has(key)) {\n diagnostic(\n 'duplicate-patch-target',\n patch.selector.file,\n `More than one patch targets ${patch.selector.slot}`,\n );\n return;\n }\n patchedSelectors.add(key);\n const expected = currentHash(index, patch.selector);\n patches.push({ ...patch, ...(expected ? { expectedCurrentHash: expected } : {}) });\n };\n const transientMatchesCurrent = (mapping: WireSourceMapping): boolean => {\n const source = mapping.source;\n if (source.type !== 'transient') return false;\n const proofs = (input.submissionProofs ?? []).filter(\n (proof) =>\n proof.source.token === source.token &&\n sameSelectorLocation(proof.selector, mapping.selector) &&\n JSON.stringify(proof.sourcePath) === JSON.stringify(mapping.sourcePath),\n );\n if (proofs.length !== 1) return false;\n const proof = proofs[0];\n const match = matchExactSubmissionProof(\n [\n {\n token: proof.source.token,\n scopeKey: 'mapping',\n sourcePath: proof.sourcePath,\n evidenceHash: submissionEvidenceHash(proof.fragmentHash, proof.containerHash),\n },\n ],\n current.submissions\n .filter(\n (candidate) =>\n candidate.source.token === proof.source.token &&\n sameSelectorLocation(candidate.selector, proof.selector),\n )\n .map((candidate) => ({\n scopeKey: 'mapping',\n sourcePath: candidate.sourcePath,\n evidenceHash: submissionEvidenceHash(candidate.fragmentHash, candidate.containerHash)!,\n })),\n );\n return match.status === 'matched' && match.token === source.token && match.exactMatchCount === 1;\n };\n const currentGroupMatches = (mapping: WireSourceMapping): boolean => {\n const expectedOwner = mapping.groupOwner;\n return (\n expectedOwner !== undefined &&\n (index.observedByFile.get(mapping.selector.file) ?? []).some(\n (observation) =>\n observation.selector.slot === 'share-group-owner' &&\n observation.source.type === 'group' &&\n ownerKey(observation.source.owner) === ownerKey(expectedOwner),\n )\n );\n };\n const currentStableDerivedMatch = (mapping: WireSourceMapping): FragmentObservation | undefined => {\n const source = mapping.source;\n if (source.type !== 'resource' || source.resource.kind !== 'user_permissions' || !('id' in source.resource))\n return undefined;\n const matches = (index.observedBySource.get(sourceKey(source)) ?? []).filter(\n (observation) => observation.selector.slot === 'document',\n );\n return matches.length === 1 ? matches[0] : undefined;\n };\n const currentPromotedDerivedMatch = (mapping: WireSourceMapping): FragmentObservation | undefined => {\n if (mapping.derivedSelectorHash === undefined) return undefined;\n const key = input.documentKeys[mapping.documentIndex];\n const separator = key?.indexOf('/') ?? -1;\n if (separator < 0 || key?.slice(0, separator) !== 'user_permissions') return undefined;\n const id = key.slice(separator + 1);\n if (!RESOURCE_ID.test(id)) return undefined;\n const source: SourceIdentity = { type: 'resource', resource: { kind: 'user_permissions', id } };\n const matches = (index.observedBySource.get(sourceKey(source)) ?? []).filter(\n (observation) =>\n observation.selector.slot === 'document' &&\n observation.derivedSelectorHash === mapping.derivedSelectorHash,\n );\n return matches.length === 1 ? matches[0] : undefined;\n };\n const sourceMatchesCurrent = (mapping: WireSourceMapping): boolean => {\n if (mapping.source.type === 'transient')\n return transientMatchesCurrent(mapping) || currentPromotedDerivedMatch(mapping) !== undefined;\n if (\n mapping.source.type === 'resource' &&\n mapping.source.resource.kind === 'user_permissions' &&\n 'id' in mapping.source.resource\n ) {\n if (currentStableDerivedMatch(mapping)) return true;\n if (\n [...index.observedBySource.values()].some((observations) =>\n observations.some(\n (observation) =>\n observation.selector.slot === 'document' &&\n observation.derivedSelectorHash !== undefined &&\n observation.source.type === 'transient',\n ),\n )\n )\n return false;\n return !index.artifactPaths.has(mapping.selector.file);\n }\n if (!index.artifactPaths.has(mapping.selector.file) || vacatedFile(mapping.selector.file)) return true;\n const observed = index.observedBySource.get(sourceKey(mapping.source)) ?? [];\n const matchingLocation = observed.some((observation) =>\n sameSelectorLocation(observation.selector, mapping.selector),\n );\n if (mapping.selector.slot !== 'share-entry') return matchingLocation;\n if (!currentGroupMatches(mapping)) return false;\n if (matchingLocation) return true;\n const conflictingLocation = observed.some((observation) => observation.selector.slot === 'share-entry');\n return (\n !conflictingLocation &&\n mapping.source.type === 'resource' &&\n mapping.source.resource.kind === 'share' &&\n 'id' in mapping.source.resource\n );\n };\n const sourceMatchesDocument = (mapping: WireSourceMapping, document: Document): boolean => {\n const key = input.documentKeys[mapping.documentIndex];\n if (!key) return false;\n const separator = key.indexOf('/');\n if (separator <= 0 || separator === key.length - 1) return false;\n const kind = key.slice(0, separator);\n const id = key.slice(separator + 1);\n if (kind !== document.kind) return false;\n if (mapping.source.type === 'resource') {\n if (mapping.source.resource.kind !== kind) return false;\n if ('id' in mapping.source.resource && mapping.source.resource.id !== id) return false;\n }\n if (typeof document.id === 'string' && RESOURCE_ID.test(document.id) && document.id !== id) return false;\n if (\n document.kind === 'user_permissions' &&\n (mapping.derivedSelectorHash === undefined ||\n derivedSourceSelectorHash(document) !== mapping.derivedSelectorHash)\n )\n return false;\n if (document.kind === 'dimension_members') {\n const selector = object(document.table);\n if (selector && (Object.keys(selector).length !== 1 || (selector.id !== id && selector.dangling !== id)))\n return false;\n }\n return true;\n };\n const assignedKeys = new Map<string, string>();\n for (const mapping of input.sources) {\n const document = input.documents[mapping.documentIndex];\n const documentKey = input.documentKeys[mapping.documentIndex];\n const separator = documentKey?.indexOf('/') ?? -1;\n const assignedId = separator < 0 ? undefined : documentKey.slice(separator + 1);\n if (\n mapping.source.type !== 'resource' ||\n !('key' in mapping.source.resource) ||\n !document ||\n document.kind !== mapping.source.resource.kind ||\n documentKey?.slice(0, separator) !== document.kind ||\n assignedId === undefined ||\n !RESOURCE_ID.test(assignedId)\n )\n continue;\n const key = sourceKey(mapping.source);\n const prior = assignedKeys.get(key);\n if (prior !== undefined && prior !== assignedId)\n diagnostic('ambiguous-key-assignment', mapping.selector.file, 'A local key has conflicting assigned IDs');\n else assignedKeys.set(key, assignedId);\n }\n\n for (const mapping of input.sources) {\n const document = input.documents[mapping.documentIndex];\n if (!document) throw new Error(`Source mapping ${mapping.documentIndex} has no wire document`);\n if (!input.documentKeys[mapping.documentIndex])\n throw new Error(`Source mapping ${mapping.documentIndex} has no wire document key`);\n if (usedDocuments.has(mapping.documentIndex))\n throw new Error(`Wire document ${mapping.documentIndex} has more than one source mapping`);\n usedDocuments.add(mapping.documentIndex);\n if (!sourceMatchesCurrent(mapping) || !sourceMatchesDocument(mapping, document)) {\n diagnostic(\n 'stale-wire-source',\n mapping.selector.file,\n 'The wire document does not match its current source identity',\n );\n continue;\n }\n if (mapping.selector.slot === 'table-definition') {\n if (document.kind !== 'dimension_table') {\n diagnostic('wire-kind-mismatch', mapping.selector.file, 'A table patch requires dimension_table');\n continue;\n }\n const value =\n mapping.source.type === 'resource' &&\n 'key' in mapping.source.resource &&\n !assignedKeys.has(sourceKey(mapping.source))\n ? { ...document, key: mapping.source.resource.key }\n : document;\n pushPatch({ source: mapping.source, selector: mapping.selector, action: 'set', value });\n } else if (mapping.selector.slot === 'member-set') {\n if (document.kind !== 'dimension_members' || !Array.isArray(document.members)) {\n diagnostic('wire-kind-mismatch', mapping.selector.file, 'A member patch requires dimension_members');\n continue;\n }\n pushPatch({\n source: mapping.source,\n selector: mapping.selector,\n action: 'set',\n value: document.members,\n });\n } else if (mapping.selector.slot === 'document') {\n if (document.kind === 'dimension_members' || document.kind === 'share') {\n diagnostic(\n 'wire-kind-mismatch',\n mapping.selector.file,\n 'This wire document requires a grouped selector',\n );\n continue;\n }\n const value =\n mapping.source.type === 'resource' &&\n 'key' in mapping.source.resource &&\n !assignedKeys.has(sourceKey(mapping.source))\n ? { ...document, key: mapping.source.resource.key }\n : document;\n const derivedMatch = currentStableDerivedMatch(mapping) ?? currentPromotedDerivedMatch(mapping);\n pushPatch({\n source: derivedMatch?.source ?? mapping.source,\n selector: derivedMatch?.selector ?? mapping.selector,\n action: 'set',\n value,\n });\n } else if (mapping.selector.slot === 'share-entry') {\n if (document.kind !== 'share' || !mapping.groupOwner) {\n diagnostic('wire-kind-mismatch', mapping.selector.file, 'A share entry patch requires a group owner');\n continue;\n }\n const assignedOwner =\n 'key' in mapping.groupOwner\n ? assignedKeys.get(\n sourceKey({\n type: 'resource',\n resource: { kind: mapping.groupOwner.kind, key: mapping.groupOwner.key },\n }),\n )\n : undefined;\n const resolvedOwner: GroupOwnerSelector = assignedOwner\n ? { kind: mapping.groupOwner.kind, id: assignedOwner }\n : mapping.groupOwner;\n const expectedOwner = assignedOwner\n ? resolvedOwner\n : (mapping.wireOwner ?? ('key' in mapping.groupOwner ? undefined : mapping.groupOwner));\n const documentOwner = object(document.owner);\n if (!expectedOwner || !documentOwner || canonicalText(documentOwner) !== canonicalText(expectedOwner)) {\n diagnostic(\n 'group-owner-mismatch',\n mapping.selector.file,\n 'The share document owner does not match its group header',\n );\n continue;\n }\n const groupKey = `${mapping.selector.file}/share-group-owner`;\n const priorOwner = groupOwners.get(groupKey);\n if (priorOwner && ownerKey(priorOwner) !== ownerKey(resolvedOwner)) {\n diagnostic(\n 'group-owner-mismatch',\n mapping.selector.file,\n 'Share documents disagree on their group owner',\n );\n continue;\n }\n if (!priorOwner) {\n groupOwners.set(groupKey, resolvedOwner);\n const headerSelector = { file: mapping.selector.file, slot: 'share-group-owner' as const };\n const headerSource = (index.observedByFile.get(headerSelector.file) ?? []).find(\n (observation) => observation.selector.slot === headerSelector.slot,\n )?.source;\n pushPatch({\n source: headerSource ?? mapping.source,\n selector: headerSelector,\n action: 'set',\n value: resolvedOwner,\n });\n }\n const entry = without(document, ['kind', 'owner']);\n if ('key' in mapping.selector.identity && !assignedKeys.has(sourceKey(mapping.source)))\n entry.key = mapping.selector.identity.key;\n pushPatch({\n source: mapping.source,\n selector: mapping.selector,\n action: 'set',\n value: entry,\n });\n } else throw new Error(`Slot ${mapping.selector.slot} is not a wire document selector`);\n }\n input.documents.forEach((_document, index) => {\n if (!usedDocuments.has(index)) throw new Error(`Wire document ${index} has no source mapping`);\n });\n for (const route of input.navigation ?? [])\n pushPatch({\n source: route.source,\n selector: route.selector,\n action: 'set',\n value: { file: route.groupFile },\n });\n for (const removal of input.removals ?? [])\n pushPatch({ source: removal.source, selector: removal.selector, action: 'remove' });\n return { patches, diagnostics };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA8B;AAC9B,yBAAsC;AACtC,wBAcO;AAuLP,MAAM,cAAc,oBAAI,IAAI,CAAC,UAAU,YAAY,mBAAmB,SAAS,aAAa,QAAQ,YAAY,CAAC;AACjH,MAAM,qBAAqB,oBAAI,IAAI,CAAC,YAAY,iBAAiB,CAAC;AAClE,MAAM,iBAAiB,oBAAI,IAAsB;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,SAAS,0BAA0B,UAAwC;AAC9E,SAAO,SAAS,SAAS,0BAAsB,uBAAI,UAAU,MAAM,QAC7D,kBAAAA,uBAAa,SAAS,IAAY,IAClC;AACV;AAEA,SAAS,aAAa,OAAmB,MAA4C;AACjF,MAAI,OAAO,MAAM,OAAO,SAAU,QAAO,EAAE,MAAM,IAAI,MAAM,GAAG;AAC9D,MAAI,OAAO,MAAM,QAAQ,SAAU,QAAO,EAAE,MAAM,KAAK,MAAM,IAAI;AACjE,SAAO;AACX;AAEA,SAAS,eAAe,QAAwB,MAA8B;AAC1E,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,SAAO,QAAQ,OAAO,WAChB,EAAE,MAAM,YAAY,UAAU,EAAE,MAAM,IAAI,OAAO,SAAS,GAAG,EAAE,IAC/D,EAAE,MAAM,YAAY,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