farseer-cli 1.15.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.
Files changed (55) hide show
  1. package/README.md +328 -0
  2. package/dist/commands/code.js +104 -0
  3. package/dist/commands/code.js.map +7 -0
  4. package/dist/commands/model.js +14 -4
  5. package/dist/commands/model.js.map +2 -2
  6. package/dist/index.js +16 -0
  7. package/dist/index.js.map +2 -2
  8. package/dist/pipeline/generated-reference.json +30 -30
  9. package/dist/pipeline/service.js +2 -2
  10. package/dist/pipeline/service.js.map +2 -2
  11. package/dist/services/codefirst/api.js +269 -0
  12. package/dist/services/codefirst/api.js.map +7 -0
  13. package/dist/services/codefirst/binaryDisk.js +67 -0
  14. package/dist/services/codefirst/binaryDisk.js.map +7 -0
  15. package/dist/services/codefirst/byteHashes.js +129 -0
  16. package/dist/services/codefirst/byteHashes.js.map +7 -0
  17. package/dist/services/codefirst/documents.js +563 -0
  18. package/dist/services/codefirst/documents.js.map +7 -0
  19. package/dist/services/codefirst/layoutBinaryProjection.js +974 -0
  20. package/dist/services/codefirst/layoutBinaryProjection.js.map +7 -0
  21. package/dist/services/codefirst/layoutCompose.js +593 -0
  22. package/dist/services/codefirst/layoutCompose.js.map +7 -0
  23. package/dist/services/codefirst/layoutCore.js +260 -0
  24. package/dist/services/codefirst/layoutCore.js.map +7 -0
  25. package/dist/services/codefirst/layoutPaths.js +492 -0
  26. package/dist/services/codefirst/layoutPaths.js.map +7 -0
  27. package/dist/services/codefirst/layoutProjection.js +995 -0
  28. package/dist/services/codefirst/layoutProjection.js.map +7 -0
  29. package/dist/services/codefirst/layoutReadback.js +2552 -0
  30. package/dist/services/codefirst/layoutReadback.js.map +7 -0
  31. package/dist/services/codefirst/layoutReadbackPlacement.js +1517 -0
  32. package/dist/services/codefirst/layoutReadbackPlacement.js.map +7 -0
  33. package/dist/services/codefirst/layoutReceipt.js +1592 -0
  34. package/dist/services/codefirst/layoutReceipt.js.map +7 -0
  35. package/dist/services/codefirst/layoutScan.js +882 -0
  36. package/dist/services/codefirst/layoutScan.js.map +7 -0
  37. package/dist/services/codefirst/output.js +179 -0
  38. package/dist/services/codefirst/output.js.map +7 -0
  39. package/dist/services/codefirst/types.js +17 -0
  40. package/dist/services/codefirst/types.js.map +7 -0
  41. package/dist/services/codefirst/workflow.js +581 -0
  42. package/dist/services/codefirst/workflow.js.map +7 -0
  43. package/dist/services/codefirst/workspace.js +310 -0
  44. package/dist/services/codefirst/workspace.js.map +7 -0
  45. package/dist/services/codefirst/workspaceLock.js +148 -0
  46. package/dist/services/codefirst/workspaceLock.js.map +7 -0
  47. package/dist/services/codefirst/workspaceRoot.js +147 -0
  48. package/dist/services/codefirst/workspaceRoot.js.map +7 -0
  49. package/dist/utils/logger.js +9 -3
  50. package/dist/utils/logger.js.map +2 -2
  51. package/docs/pipeline-client-guide.md +2 -2
  52. package/docs/pipeline-reference.md +156 -99
  53. package/package.json +3 -2
  54. package/skills/pipeline-authoring/SKILL.md +10 -8
  55. package/skills/pipeline-authoring/practices.md +39 -25
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/codefirst/layoutScan.ts"],
4
+ "sourcesContent": ["/**\n * Everything this workspace reads from disk: the read-only managed scan, one symlink-refusing path\n * walk, the byte evidence a composition needs and the capture a writer revalidates against.\n * Nothing here interprets a document; layoutCompose does that.\n *\n * One raw uploaded file is two artifacts: its bytes, and the `<name>.meta` sidecar beside them that\n * carries its row. The sidecar claims that sibling, so a raw `.json` is never read as a document.\n */\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { hashWorkspaceFile } from './byteHashes';\nimport { peekState } from './documents';\nimport type { LayoutByteFact, OwnerFieldProjection } from './layoutBinaryProjection';\nimport type { LayoutSubmissionEvidence } from './layoutCompose';\nimport {\n attachmentPointer as pointer,\n cloneOptional as clone,\n compareText,\n diagnostic as pathDiagnostic,\n isObject,\n ITEM_KINDS,\n object,\n attachmentField as ownerField,\n sourceFromValue,\n sourceIdentityKey,\n TREE_DOCUMENT_KINDS,\n} from './layoutCore';\nimport {\n decodeLayoutName,\n folderDirectory,\n isIgnoredLayoutName,\n isPortableWorkspacePointer,\n collisionAncestors,\n isRawSidecarPath,\n layoutCollisionKey,\n LayoutPathAllocator,\n LayoutPathKind,\n LayoutPathRole,\n parseWorkspacePointer,\n RAW_SIDECAR_SUFFIX,\n rawBytesPath,\n type LayoutPathClaim,\n} from './layoutPaths';\nimport type { ProjectionDiagnostic } from './layoutProjection';\nimport type { LayoutWorkspaceSnapshot, LayoutWorkspaceSnapshotSeed } from './layoutReceipt';\nimport type { State } from './types';\nimport { STATE_FILE, workspacePath } from './workspace';\nexport type TrackedLayoutRole = 'folder-control' | 'raw-metadata' | 'document' | 'raw' | 'attachment';\nexport type LayoutArtifactRole =\n | TrackedLayoutRole\n | 'share-group'\n | 'user-group'\n | 'user-grant'\n | 'label'\n | 'settings'\n | 'dataset'\n | 'export'\n | 'detached-document';\n\nexport interface TrackedLayoutPath {\n route: string;\n path: string;\n kind: LayoutPathKind;\n role: TrackedLayoutRole;\n}\n\nexport interface LayoutScanInput {\n root: string;\n tracked: readonly TrackedLayoutPath[];\n}\n\nexport interface LayoutPointer {\n kind: 'share' | 'attachment';\n field: string;\n path: string;\n present: boolean;\n}\n\nexport interface LayoutArtifact {\n path: string;\n kind: 'file';\n role: LayoutArtifactRole;\n present: boolean;\n json?: unknown;\n decodedName?: string;\n /** A `name` field the filename outranks, because it spells another name (a warning, not an error). */\n ignoredNameOverride?: string;\n /** The sidecar that carries a raw file's row, or the owner document of an attachment. */\n source?: string;\n pointers?: LayoutPointer[];\n}\n\nexport interface LayoutTrackedPresence {\n route: string;\n path: string;\n status: 'present' | 'missing-leaf' | 'missing-subtree';\n missingAncestor?: string;\n}\n\nexport interface LayoutScanDiagnostic {\n code: string;\n path: string;\n message: string;\n relatedPath?: string;\n}\n\nexport interface LayoutScanResult {\n artifacts: LayoutArtifact[];\n tracked: LayoutTrackedPresence[];\n opaqueDirectories: string[];\n localOnlyFiles: string[];\n /** Marked directories whose own name no managed path can carry; they stay opaque and are named. */\n unmanageableDirectories?: string[];\n diagnostics: LayoutScanDiagnostic[];\n}\n\nexport type LayoutPhysicalPathFact =\n | { path: string; state: 'file' | 'directory' | 'symlink' }\n | { path: string; state: 'absent'; missingAncestor: string };\n\ninterface Occupant {\n path: string;\n kind: LayoutPathKind | 'symlink';\n}\n\ninterface PendingAttachment {\n owner: LayoutArtifact;\n field: string;\n path: string;\n}\n\nconst FOLDER_CONTROL = '_folder.json';\n/** The manifest this layout retired. A workspace that still holds one is refused by name. */\nconst RETIRED_MANIFEST = '_files.json';\n\ntype AddDiagnostic = (code: string, path: string, message: string, relatedPath?: string) => void;\n\nfunction pointerTarget(value: unknown, artifact: LayoutArtifact, addDiagnostic: AddDiagnostic): string | undefined {\n const target = isObject(value) && typeof value.file === 'string' ? value.file : undefined;\n if (target === undefined) return undefined;\n try {\n return parseWorkspacePointer(target);\n } catch (error) {\n addDiagnostic('unsafe-pointer', artifact.path, (error as Error).message);\n return undefined;\n }\n}\n\nfunction addSharePointerToArtifact(\n artifact: LayoutArtifact,\n value: unknown,\n field: string,\n present: (path: string) => boolean,\n addDiagnostic: AddDiagnostic,\n): void {\n const target = pointerTarget(value, artifact, addDiagnostic);\n if (target === undefined) return;\n if (!/^access\\/shares\\/[^/]+\\.json$/.test(target)) {\n addDiagnostic('invalid-share-pointer', artifact.path, `Share pointer is outside access/shares`, target);\n return;\n }\n (artifact.pointers ??= []).push({ kind: 'share', field, path: target, present: present(target) });\n}\n\nfunction decodeArtifactName(\n artifact: LayoutArtifact,\n component: string,\n role: 'directory' | 'raw' | 'document',\n extension: string,\n value: unknown,\n addDiagnostic: AddDiagnostic,\n): void {\n const override = isObject(value) && typeof value.name === 'string' ? value.name : undefined;\n try {\n artifact.decodedName = decodeLayoutName(component, role, extension, override);\n if (override !== undefined && artifact.decodedName !== override) artifact.ignoredNameOverride = override;\n } catch (error) {\n addDiagnostic('invalid-layout-name', artifact.path, (error as Error).message);\n }\n}\n\nfunction buildRawArtifact(\n sidecar: string,\n value: unknown,\n present: boolean,\n sharePresent: (path: string) => boolean,\n addDiagnostic: AddDiagnostic,\n): LayoutArtifact {\n const bytes = rawBytesPath(sidecar);\n const artifact: LayoutArtifact = {\n path: bytes,\n kind: 'file',\n role: 'raw',\n present,\n source: sidecar,\n json: value,\n };\n decodeArtifactName(artifact, bytes.slice(bytes.lastIndexOf('/') + 1), 'raw', '', value, addDiagnostic);\n if (isObject(value)) addSharePointerToArtifact(artifact, value.shares, 'shares', sharePresent, addDiagnostic);\n return artifact;\n}\n\nfunction finalizeScanResult(\n artifacts: LayoutArtifact[],\n tracked: LayoutTrackedPresence[],\n opaqueDirectories: Iterable<string>,\n localOnlyFiles: Iterable<string>,\n diagnostics: LayoutScanDiagnostic[],\n unmanageableDirectories: Iterable<string> = [],\n): LayoutScanResult {\n const uniqueDiagnostics = new Map<string, LayoutScanDiagnostic>();\n for (const diagnostic of diagnostics)\n uniqueDiagnostics.set(`${diagnostic.code}\\0${diagnostic.path}\\0${diagnostic.relatedPath ?? ''}`, diagnostic);\n artifacts.sort((left, right) => compareText(left.path, right.path) || compareText(left.role, right.role));\n tracked.sort((left, right) => compareText(left.route, right.route));\n const unmanageable = [...unmanageableDirectories].sort(compareText);\n return {\n artifacts,\n tracked,\n opaqueDirectories: [...opaqueDirectories].sort(compareText),\n localOnlyFiles: [...localOnlyFiles].sort(compareText),\n ...(unmanageable.length > 0 ? { unmanageableDirectories: unmanageable } : {}),\n diagnostics: [...uniqueDiagnostics.values()].sort(\n (left, right) => compareText(left.path, right.path) || compareText(left.code, right.code),\n ),\n };\n}\n\nfunction physicalLayoutClaims(scan: LayoutScanResult): LayoutPathClaim[] {\n const claims = new Map<string, LayoutPathClaim>();\n const add = (claim: LayoutPathClaim) => claims.set(`${claim.kind}\\0${claim.path}`, claim);\n const addDirectories = (relative: string, includeLeaf: boolean) => {\n const parts = relative.split('/');\n const length = includeLeaf ? parts.length : parts.length - 1;\n for (let index = 1; index <= length; index++) {\n const directory = parts.slice(0, index).join('/');\n add({ path: directory, kind: 'directory', role: 'directory', identity: `physical:${directory}` });\n }\n };\n const addFile = (relative: string, role: LayoutPathRole) => {\n addDirectories(relative, false);\n add({ path: relative, kind: 'file', role, identity: `physical:${relative}` });\n };\n\n for (const artifact of scan.artifacts) {\n if (!artifact.present) continue;\n const role: LayoutPathRole =\n artifact.role === 'raw'\n ? 'raw'\n : artifact.role === 'attachment'\n ? 'attachment'\n : ['folder-control', 'raw-metadata'].includes(artifact.role)\n ? 'control'\n : 'document';\n addFile(artifact.path, role);\n }\n for (const relative of scan.localOnlyFiles) addFile(relative, 'document');\n for (const directory of scan.opaqueDirectories) {\n addDirectories(directory, true);\n }\n return [...claims.values()];\n}\n\nexport function scanLayout(input: LayoutScanInput): LayoutScanResult {\n const root = path.resolve(input.root);\n const artifacts: LayoutArtifact[] = [];\n const diagnostics: LayoutScanDiagnostic[] = [];\n const opaqueDirectories = new Set<string>();\n const unmanageableDirectories = new Set<string>();\n const localOnlyFiles = new Set<string>();\n const occupants = new Map<string, Occupant[]>();\n /** Per collision key, the earliest occupied key strictly beneath it, in `occupants` order. */\n const firstOccupiedBeneath = new Map<string, string>();\n const occupiedOrder = new Map<string, number>();\n const claims = new Map<string, { path: string; role: string; source: string }>();\n const allocator = new LayoutPathAllocator();\n const pendingAttachments: PendingAttachment[] = [];\n const trackedMarkerDirectories = new Set<string>();\n /** Every tracked path and its ancestors: an ignored name on one of them was written by the workspace. */\n const trackedPaths = new Set(\n input.tracked.flatMap((item) =>\n item.path.split('/').map((_, index, parts) => parts.slice(0, index + 1).join('/')),\n ),\n );\n\n const addDiagnostic = (code: string, relative: string, message: string, relatedPath?: string) => {\n diagnostics.push({ code, path: relative, message, ...(relatedPath ? { relatedPath } : {}) });\n };\n const rootFailure = (): LayoutScanResult => ({\n artifacts: [],\n tracked: input.tracked\n .map((tracked) => ({\n route: tracked.route,\n path: tracked.path,\n status: 'missing-subtree' as const,\n }))\n .sort((left, right) => compareText(left.route, right.route)),\n opaqueDirectories: [],\n localOnlyFiles: [],\n diagnostics,\n });\n let rootStat: fs.Stats;\n try {\n rootStat = fs.lstatSync(root);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return rootFailure();\n addDiagnostic('filesystem-error', '.', `Cannot inspect workspace root`);\n return rootFailure();\n }\n if (rootStat.isSymbolicLink()) {\n addDiagnostic('symlink', '.', `Workspace root is a symlink`);\n return rootFailure();\n }\n if (!rootStat.isDirectory()) {\n addDiagnostic('path-role-overlap', '.', `Workspace root is not a directory`);\n return rootFailure();\n }\n const absolute = (relative: string) => {\n const resolved = path.resolve(root, ...relative.split('/'));\n const fromRoot = path.relative(root, resolved);\n if (fromRoot === '..' || fromRoot.startsWith(`..${path.sep}`) || path.isAbsolute(fromRoot))\n throw new Error(`Path escapes workspace root: ${relative}`);\n return resolved;\n };\n const lstat = (relative: string): fs.Stats | undefined => {\n try {\n return fs.lstatSync(absolute(relative));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;\n addDiagnostic('filesystem-error', relative, `Cannot inspect ${relative}`);\n return undefined;\n }\n };\n const recordOccupant = (occupant: Occupant) => {\n const key = layoutCollisionKey(occupant.path);\n const group = occupants.get(key);\n if (group) {\n group.push(occupant);\n return;\n }\n occupants.set(key, [occupant]);\n occupiedOrder.set(key, occupiedOrder.size);\n for (const ancestor of collisionAncestors(key))\n if (!firstOccupiedBeneath.has(ancestor)) firstOccupiedBeneath.set(ancestor, key);\n };\n const physicalEntries = (directory: string): fs.Dirent[] | undefined => {\n const stat = lstat(directory);\n if (!stat) return undefined;\n if (stat.isSymbolicLink()) {\n addDiagnostic('symlink', directory, `Managed path is a symlink: ${directory}`);\n return undefined;\n }\n if (!stat.isDirectory()) {\n addDiagnostic('path-role-overlap', directory, `Expected a directory: ${directory}`);\n return undefined;\n }\n claim(directory, 'directory', 'directory', `directory:${directory}`);\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(absolute(directory), { withFileTypes: true });\n } catch {\n addDiagnostic('filesystem-error', directory, `Cannot read directory ${directory}`);\n return undefined;\n }\n // OS and tool files are not part of the workspace, unless an earlier version of it wrote one.\n entries = entries.filter(\n (entry) => !isIgnoredLayoutName(entry.name) || trackedPaths.has(`${directory}/${entry.name}`),\n );\n entries.sort((left, right) => compareText(left.name, right.name));\n for (const entry of entries) {\n const relative = `${directory}/${entry.name}`;\n recordOccupant({\n path: relative,\n kind: entry.isSymbolicLink() ? 'symlink' : entry.isDirectory() ? 'directory' : 'file',\n });\n }\n return entries;\n };\n const claim = (relative: string, kind: LayoutPathKind, role: LayoutPathRole, source: string): boolean => {\n let normalized: string;\n try {\n normalized = parseWorkspacePointer(relative);\n } catch (error) {\n addDiagnostic('unsafe-managed-path', relative, (error as Error).message);\n return false;\n }\n const key = layoutCollisionKey(normalized);\n const previous = claims.get(key);\n if (previous) {\n if (previous.path === normalized && previous.role === role && role === 'directory') return true;\n addDiagnostic(\n 'duplicate-claim',\n normalized,\n `Path is claimed as both ${previous.role} and ${role}`,\n previous.source,\n );\n return false;\n }\n const beneath = kind === 'file' ? firstOccupiedBeneath.get(key) : undefined;\n // The first local occupant that aliases the claim: the same key spelled or typed differently,\n // a file above it, or, for a file claim, anything below it.\n const aliases = [\n {\n key,\n occupant: occupants\n .get(key)\n ?.find((item) => item.path !== normalized || (item.kind !== kind && item.kind !== 'symlink')),\n },\n ...collisionAncestors(key).map((ancestor) => ({\n key: ancestor,\n occupant: occupants.get(ancestor)?.find((item) => item.kind === 'file' || item.kind === 'symlink'),\n })),\n ...(beneath ? [{ key: beneath, occupant: occupants.get(beneath)![0] }] : []),\n ].filter((alias): alias is { key: string; occupant: Occupant } => alias.occupant !== undefined);\n if (aliases.length > 0) {\n const { occupant } = aliases.reduce((first, alias) =>\n occupiedOrder.get(alias.key)! < occupiedOrder.get(first.key)! ? alias : first,\n );\n addDiagnostic(\n 'path-alias',\n normalized,\n `Managed claim conflicts with local ${occupant.kind}`,\n occupant.path,\n );\n return false;\n }\n try {\n allocator.claim({ path: normalized, kind, role, identity: source });\n } catch (error) {\n addDiagnostic('path-role-overlap', normalized, (error as Error).message);\n return false;\n }\n claims.set(key, { path: normalized, role, source });\n return true;\n };\n const parseJson = (relative: string): unknown | undefined => {\n try {\n return JSON.parse(fs.readFileSync(absolute(relative), 'utf8')) as unknown;\n } catch {\n addDiagnostic('malformed-json', relative, `Invalid JSON in ${relative}`);\n return undefined;\n }\n };\n const probe = (\n relative: string,\n ): { present: boolean; symlink: boolean; symlinkPath?: string; missingAncestor?: string } => {\n let current = '';\n const parts = relative.split('/');\n for (let index = 0; index < parts.length; index++) {\n current = current ? `${current}/${parts[index]}` : parts[index];\n const stat = lstat(current);\n if (!stat) return { present: false, symlink: false, missingAncestor: current };\n if (stat.isSymbolicLink()) return { present: true, symlink: true, symlinkPath: current };\n if (index < parts.length - 1 && !stat.isDirectory())\n return { present: false, symlink: false, missingAncestor: current };\n }\n return { present: true, symlink: false };\n };\n const addSharePointer = (artifact: LayoutArtifact, value: unknown, field: string) => {\n addSharePointerToArtifact(artifact, value, field, (target) => probe(target).present, addDiagnostic);\n };\n const addAttachmentPointer = (artifact: LayoutArtifact, value: unknown, field: string) => {\n const target = pointerTarget(value, artifact, addDiagnostic);\n if (target !== undefined) pendingAttachments.push({ owner: artifact, field, path: target });\n };\n const decodeSuppliedName = (\n artifact: LayoutArtifact,\n component: string,\n role: 'directory' | 'raw' | 'document',\n extension: string,\n value: unknown,\n ) => {\n decodeArtifactName(artifact, component, role, extension, value, addDiagnostic);\n };\n const readArtifact = (relative: string, role: LayoutArtifactRole): LayoutArtifact => {\n claim(\n relative,\n 'file',\n role === 'folder-control' || role === 'raw-metadata' ? 'control' : 'document',\n relative,\n );\n const json = parseJson(relative);\n const artifact: LayoutArtifact = { path: relative, kind: 'file', role, present: true, json };\n artifacts.push(artifact);\n return artifact;\n };\n const inspectSymlink = (relative: string) => {\n addDiagnostic('symlink', relative, `Managed path is a symlink: ${relative}`);\n };\n /** Refuse the retired per-folder manifest by name wherever a managed scan can reach it. */\n const retiredManifest = (name: string, relative: string): boolean => {\n if (layoutCollisionKey(name) !== layoutCollisionKey(RETIRED_MANIFEST)) return false;\n addDiagnostic('retired-file-manifest', relative, `delete it and run farseer code pull --force`);\n return true;\n };\n /** Read one `<name>.meta` sidecar and the raw bytes it claims. The bytes may be absent. */\n const scanSidecar = (sidecarPath: string) => {\n const artifact = readArtifact(sidecarPath, 'raw-metadata');\n const value = artifact.json;\n if (!isObject(value)) {\n addDiagnostic('malformed-control', sidecarPath, `Invalid raw sidecar in ${sidecarPath}`);\n return;\n }\n const bytes = rawBytesPath(sidecarPath);\n const state = probe(bytes);\n if (state.symlink) inspectSymlink(bytes);\n const isFile = state.present && !state.symlink && !!lstat(bytes)?.isFile();\n if (state.present && !state.symlink && !isFile)\n addDiagnostic('path-role-overlap', bytes, `Raw sidecar target is not a file`);\n claim(bytes, 'file', 'raw', sidecarPath);\n artifacts.push(buildRawArtifact(sidecarPath, value, isFile, (target) => probe(target).present, addDiagnostic));\n localOnlyFiles.delete(bytes);\n };\n /** The sidecars of one directory, keyed by the exact name of the bytes each one claims. */\n const sidecarNames = (entries: readonly fs.Dirent[]): Map<string, string> => {\n const claimed = new Map<string, string>();\n for (const entry of entries)\n if (entry.isFile() && isRawSidecarPath(entry.name))\n claimed.set(entry.name.slice(0, -RAW_SIDECAR_SUFFIX.length), entry.name);\n return claimed;\n };\n const scanManagedDirectory = (directory: string) => {\n const entries = physicalEntries(directory);\n if (!entries) return;\n const names = new Map(entries.map((entry) => [entry.name, entry]));\n for (const entry of entries) if (entry.isSymbolicLink()) inspectSymlink(`${directory}/${entry.name}`);\n\n const markerPath = `${directory}/${FOLDER_CONTROL}`;\n const marker = names.get(FOLDER_CONTROL);\n if (marker && !marker.isFile()) addDiagnostic('path-role-overlap', markerPath, `Folder control is not a file`);\n if (marker?.isFile()) {\n const markerArtifact = readArtifact(markerPath, 'folder-control');\n if (!isObject(markerArtifact.json))\n addDiagnostic('malformed-control', markerPath, `Invalid folder control in ${markerPath}`);\n decodeSuppliedName(markerArtifact, directory.split('/').at(-1)!, 'directory', '', markerArtifact.json);\n if (isObject(markerArtifact.json)) addSharePointer(markerArtifact, markerArtifact.json.shares, 'shares');\n }\n\n const sidecars = sidecarNames(entries);\n for (const [, sidecar] of [...sidecars].sort(([left], [right]) => compareText(left, right)))\n scanSidecar(`${directory}/${sidecar}`);\n\n for (const entry of entries) {\n const relative = `${directory}/${entry.name}`;\n if (entry.isSymbolicLink() || entry.name === FOLDER_CONTROL) continue;\n if (retiredManifest(entry.name, relative)) continue;\n if (entry.isFile() && (isRawSidecarPath(entry.name) || sidecars.has(entry.name))) continue;\n if (entry.isDirectory()) {\n const nestedMarker = lstat(`${relative}/_folder.json`);\n // A name no managed path can carry stays an opaque local subtree, marker or not.\n if (!isPortableWorkspacePointer(relative)) {\n if (nestedMarker) unmanageableDirectories.add(relative);\n opaqueDirectories.add(relative);\n } else if (nestedMarker || trackedMarkerDirectories.has(relative)) scanManagedDirectory(relative);\n else opaqueDirectories.add(relative);\n continue;\n }\n if (!entry.isFile()) continue;\n if (!entry.name.endsWith('.json')) {\n localOnlyFiles.add(relative);\n continue;\n }\n const artifact = readArtifact(relative, 'document');\n if (\n !isObject(artifact.json) ||\n typeof artifact.json.kind !== 'string' ||\n !TREE_DOCUMENT_KINDS.has(artifact.json.kind)\n )\n addDiagnostic('unknown-json', relative, `Unknown item JSON in ${relative}`);\n decodeSuppliedName(artifact, entry.name, 'document', '.json', artifact.json);\n if (isObject(artifact.json)) {\n addSharePointer(artifact, artifact.json.shares, 'shares');\n if (artifact.json.kind === 'remote_job') addAttachmentPointer(artifact, artifact.json.icon, 'icon');\n }\n }\n };\n const scanFlatJsonDirectory = (\n directory: string,\n role: LayoutArtifactRole,\n options: { namesSupplySemanticName?: boolean; attachmentField?: string } = {},\n ) => {\n const entries = physicalEntries(directory);\n if (!entries) return;\n for (const entry of entries) {\n const relative = `${directory}/${entry.name}`;\n if (entry.isSymbolicLink()) {\n inspectSymlink(relative);\n continue;\n }\n if (entry.isDirectory()) {\n opaqueDirectories.add(relative);\n continue;\n }\n if (!entry.isFile()) continue;\n if (retiredManifest(entry.name, relative)) continue;\n if (!entry.name.endsWith('.json')) {\n localOnlyFiles.add(relative);\n continue;\n }\n const artifact = readArtifact(relative, role);\n if (options.namesSupplySemanticName)\n decodeSuppliedName(artifact, entry.name, 'document', '.json', artifact.json);\n if (isObject(artifact.json)) {\n addSharePointer(artifact, artifact.json.shares, 'shares');\n if (options.attachmentField)\n addAttachmentPointer(artifact, artifact.json[options.attachmentField], options.attachmentField);\n if (role === 'detached-document' && artifact.json.kind === 'remote_job')\n addAttachmentPointer(artifact, artifact.json.icon, 'icon');\n }\n }\n };\n const scanDeclaredRoot = (\n rootDirectory: string,\n declared: Record<string, () => void>,\n exactFiles: Record<string, LayoutArtifactRole> = {},\n ) => {\n const entries = physicalEntries(rootDirectory);\n if (!entries) return;\n for (const entry of entries) {\n const relative = `${rootDirectory}/${entry.name}`;\n if (entry.isSymbolicLink()) {\n inspectSymlink(relative);\n continue;\n }\n if (entry.isDirectory()) {\n if (Object.prototype.hasOwnProperty.call(declared, entry.name)) declared[entry.name]();\n else opaqueDirectories.add(relative);\n continue;\n }\n if (!entry.isFile()) continue;\n if (retiredManifest(entry.name, relative)) continue;\n const role = Object.prototype.hasOwnProperty.call(exactFiles, entry.name)\n ? exactFiles[entry.name]\n : undefined;\n if (role) readArtifact(relative, role);\n else if (entry.name.endsWith('.json'))\n addDiagnostic('unknown-json', relative, `JSON is not valid in ${rootDirectory}`);\n else localOnlyFiles.add(relative);\n }\n };\n\n const tracked: LayoutTrackedPresence[] = input.tracked.map((item) => {\n try {\n parseWorkspacePointer(item.path);\n } catch (error) {\n addDiagnostic('unsafe-tracked-path', item.path, (error as Error).message);\n return { route: item.route, path: item.path, status: 'missing-leaf' };\n }\n if (item.role === 'folder-control' && item.path.endsWith('/_folder.json'))\n trackedMarkerDirectories.add(folderDirectory(item.path));\n const state = probe(item.path);\n if (state.symlink) inspectSymlink(state.symlinkPath ?? item.path);\n if (state.present) {\n const stat = state.symlink ? undefined : lstat(item.path);\n if (\n stat &&\n ((item.kind === 'file' && !stat.isFile()) || (item.kind === 'directory' && !stat.isDirectory()))\n )\n addDiagnostic('path-role-overlap', item.path, `Tracked path has the wrong physical kind`);\n return { route: item.route, path: item.path, status: 'present' };\n }\n const final = state.missingAncestor === item.path;\n return {\n route: item.route,\n path: item.path,\n status: final ? 'missing-leaf' : 'missing-subtree',\n ...(final || state.missingAncestor === undefined ? {} : { missingAncestor: state.missingAncestor }),\n };\n });\n\n // The workspace root carries no managed artifacts, so the retired manifest is all it is read for.\n let rootEntries: fs.Dirent[] = [];\n try {\n rootEntries = fs.readdirSync(root, { withFileTypes: true });\n } catch {\n rootEntries = [];\n }\n for (const entry of rootEntries.sort((left, right) => compareText(left.name, right.name)))\n if (entry.isFile()) retiredManifest(entry.name, entry.name);\n\n const treeEntries = physicalEntries('tree');\n for (const entry of treeEntries ?? []) {\n const relative = `tree/${entry.name}`;\n if (entry.isSymbolicLink()) {\n inspectSymlink(relative);\n continue;\n }\n if (entry.isDirectory()) {\n const marker = lstat(`${relative}/_folder.json`);\n // A name no managed path can carry stays an opaque local subtree, marker or not.\n if (!isPortableWorkspacePointer(relative)) {\n if (marker) unmanageableDirectories.add(relative);\n opaqueDirectories.add(relative);\n } else if (marker || trackedMarkerDirectories.has(relative)) scanManagedDirectory(relative);\n else opaqueDirectories.add(relative);\n } else if (entry.isFile() && retiredManifest(entry.name, relative)) continue;\n else if (entry.isFile() && entry.name.endsWith('.json'))\n addDiagnostic('unknown-json', relative, `Only managed folder directories are valid under tree`);\n else if (entry.isFile()) localOnlyFiles.add(relative);\n }\n\n scanDeclaredRoot('access', {\n shares: () => scanFlatJsonDirectory('access/shares', 'share-group'),\n groups: () => scanFlatJsonDirectory('access/groups', 'user-group', { namesSupplySemanticName: true }),\n labels: () => scanFlatJsonDirectory('access/labels', 'label', { namesSupplySemanticName: true }),\n grants: () => {\n const entries = physicalEntries('access/grants');\n for (const entry of entries ?? []) {\n const relative = `access/grants/${entry.name}`;\n if (entry.isSymbolicLink()) inspectSymlink(relative);\n else if (entry.isDirectory()) scanFlatJsonDirectory(relative, 'user-grant');\n else if (entry.isFile() && retiredManifest(entry.name, relative)) continue;\n else if (entry.isFile() && entry.name.endsWith('.json'))\n addDiagnostic('unknown-json', relative, `Grant JSON requires a principal-kind directory`);\n else if (entry.isFile()) localOnlyFiles.add(relative);\n }\n },\n });\n scanDeclaredRoot(\n 'definitions',\n {\n datasets: () => scanFlatJsonDirectory('definitions/datasets', 'dataset', { namesSupplySemanticName: true }),\n exports: () =>\n scanFlatJsonDirectory('definitions/exports', 'export', {\n namesSupplySemanticName: true,\n attachmentField: 'template',\n }),\n },\n { 'settings.json': 'settings' },\n );\n scanDeclaredRoot('detached', {\n ...Object.fromEntries(\n [...ITEM_KINDS].map((kind) => [kind, () => scanFlatJsonDirectory(`detached/${kind}`, 'detached-document')]),\n ),\n files: () => {\n const entries = physicalEntries('detached/files');\n for (const entry of entries ?? []) {\n const bucket = `detached/files/${entry.name}`;\n if (entry.isSymbolicLink()) inspectSymlink(bucket);\n else if (!entry.isDirectory())\n addDiagnostic('path-role-overlap', bucket, `Detached file entry must be an identity directory`);\n else {\n const bucketEntries = physicalEntries(bucket) ?? [];\n const sidecars = sidecarNames(bucketEntries);\n if (sidecars.size === 0)\n addDiagnostic('missing-raw-sidecar', bucket, `Detached file bucket has no raw sidecar`);\n else if (sidecars.size > 1)\n addDiagnostic('detached-file-count', bucket, `Detached file bucket must hold one raw file`);\n for (const [, sidecar] of [...sidecars].sort(([left], [right]) => compareText(left, right)))\n scanSidecar(`${bucket}/${sidecar}`);\n for (const candidate of bucketEntries) {\n const relative = `${bucket}/${candidate.name}`;\n if (candidate.isSymbolicLink()) inspectSymlink(relative);\n else if (retiredManifest(candidate.name, relative)) continue;\n else if (\n candidate.isFile() &&\n (isRawSidecarPath(candidate.name) || sidecars.has(candidate.name))\n )\n continue;\n else if (candidate.isDirectory()) opaqueDirectories.add(relative);\n else if (candidate.isFile() && candidate.name.endsWith('.json'))\n addDiagnostic('unknown-json', relative, `Unclaimed JSON in detached file bucket`);\n else if (candidate.isFile()) localOnlyFiles.add(relative);\n }\n }\n }\n },\n });\n\n for (const pending of pendingAttachments.sort((left, right) => compareText(left.path, right.path))) {\n if (!attachmentTargetValid(pending.owner, pending.path, opaqueDirectories, addDiagnostic)) continue;\n const state = probe(pending.path);\n if (state.symlink) inspectSymlink(state.symlinkPath ?? pending.path);\n const stat = state.present && !state.symlink ? lstat(pending.path) : undefined;\n if (stat && !stat.isFile()) addDiagnostic('path-role-overlap', pending.path, `Attachment target is not a file`);\n claim(pending.path, 'file', 'attachment', `${pending.owner.path}:${pending.field}`);\n const present = !!stat?.isFile();\n (pending.owner.pointers ??= []).push({\n kind: 'attachment',\n field: pending.field,\n path: pending.path,\n present,\n });\n artifacts.push({\n path: pending.path,\n kind: 'file',\n role: 'attachment',\n present,\n source: pending.owner.path,\n });\n localOnlyFiles.delete(pending.path);\n }\n\n for (const markerDirectory of trackedMarkerDirectories) {\n const markerPath = `${markerDirectory}/_folder.json`;\n if (probe(markerPath).present || !probe(markerDirectory).present) continue;\n const retained =\n artifacts.some(\n (artifact) =>\n artifact.present &&\n artifact.path.startsWith(`${markerDirectory}/`) &&\n !['raw-metadata', 'attachment'].includes(artifact.role),\n ) ||\n tracked.some(\n (item) =>\n item.status === 'present' &&\n item.path !== markerPath &&\n !['raw-metadata', 'attachment'].includes(\n input.tracked.find((trackedPath) => trackedPath.route === item.route)?.role ?? '',\n ) &&\n item.path.startsWith(`${markerDirectory}/`),\n );\n if (\n retained &&\n !diagnostics.some(\n (diagnostic) => diagnostic.code === 'missing-folder-marker' && diagnostic.path === markerPath,\n )\n )\n addDiagnostic('missing-folder-marker', markerPath, `Folder marker is missing with managed descendants`);\n }\n\n return finalizeScanResult(\n artifacts,\n tracked,\n opaqueDirectories,\n localOnlyFiles,\n diagnostics,\n unmanageableDirectories,\n );\n}\n\nfunction sourceMatchesOwner(source: OwnerFieldProjection['ownerSource'], value: unknown): boolean {\n if (source.type !== 'resource' || !isObject(value) || value.kind !== source.resource.kind) return false;\n if ('id' in source.resource) return value.id === source.resource.id;\n return value.key === source.resource.key;\n}\n\nfunction attachmentTargetValid(\n owner: LayoutArtifact,\n target: string,\n opaqueDirectories: Iterable<string>,\n addDiagnostic: AddDiagnostic,\n): boolean {\n if (!/^(tree|access|definitions|detached)\\//.test(target)) {\n addDiagnostic('attachment-out-of-scope', owner.path, `Attachment is outside the adapter roots`, target);\n return false;\n }\n if (target.endsWith('.json')) {\n addDiagnostic('attachment-json', owner.path, `Attachment must not claim JSON`, target);\n return false;\n }\n for (const opaque of opaqueDirectories) {\n if (target === opaque || target.startsWith(`${opaque}/`)) {\n addDiagnostic('attachment-opaque', owner.path, `Attachment is inside an opaque directory`, opaque);\n return false;\n }\n }\n return true;\n}\n\nexport interface LoadedLayoutByteEvidence {\n facts: readonly LayoutByteFact[];\n diagnostics: readonly ProjectionDiagnostic[];\n}\n\nexport interface LoadLayoutByteEvidenceInput {\n root: string;\n scan: LayoutScanResult;\n evidence: LayoutSubmissionEvidence;\n}\n\n/**\n * One symlink-refusing walk of a workspace-relative path. It stops at the first missing component;\n * `resolveLayoutPath` turns a refusal into a throw and `probeLayoutPath` returns it as a fact.\n */\nfunction walkLayoutPath(root: string, relative: string): { fact: LayoutPhysicalPathFact; rootSymlink: boolean } {\n const parsed = parseWorkspacePointer(relative);\n const absoluteRoot = path.resolve(root);\n try {\n if (fs.lstatSync(absoluteRoot).isSymbolicLink())\n return { fact: { path: parsed, state: 'symlink' }, rootSymlink: true };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n }\n let current = absoluteRoot;\n const components = parsed.split('/');\n for (const [index, component] of components.entries()) {\n current = path.join(current, component);\n const prefix = components.slice(0, index + 1).join('/');\n let stat: fs.Stats;\n try {\n stat = fs.lstatSync(current);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT')\n return { fact: { path: parsed, state: 'absent', missingAncestor: prefix }, rootSymlink: false };\n throw error;\n }\n if (stat.isSymbolicLink()) return { fact: { path: parsed, state: 'symlink' }, rootSymlink: false };\n if (index === components.length - 1)\n return { fact: { path: parsed, state: stat.isDirectory() ? 'directory' : 'file' }, rootSymlink: false };\n if (!stat.isDirectory())\n return { fact: { path: parsed, state: 'absent', missingAncestor: prefix }, rootSymlink: false };\n }\n throw new Error(`Unable to inspect layout path: ${relative}`);\n}\n\nexport function resolveLayoutPath(root: string, relative: string): string {\n const parsed = parseWorkspacePointer(relative);\n const absoluteRoot = path.resolve(root);\n const resolved = path.resolve(absoluteRoot, ...parsed.split('/'));\n const fromRoot = path.relative(absoluteRoot, resolved);\n if (fromRoot === '..' || fromRoot.startsWith(`..${path.sep}`) || path.isAbsolute(fromRoot))\n throw new Error(`Path escapes workspace root: ${relative}`);\n const walk = walkLayoutPath(root, relative);\n if (walk.fact.state === 'symlink')\n throw new Error(walk.rootSymlink ? `Refusing symlink root: ${absoluteRoot}` : `Refusing symlink: ${relative}`);\n return resolved;\n}\n\nexport function probeLayoutPath(root: string, relative: string): LayoutPhysicalPathFact {\n return walkLayoutPath(root, relative).fact;\n}\n\nexport function hashLayoutPath(root: string, relative: string): LayoutByteFact {\n try {\n const content = hashWorkspaceFile(root, relative, resolveLayoutPath(root, relative));\n return content ? { path: relative, state: 'present', content } : { path: relative, state: 'absent' };\n } catch (error) {\n return { path: relative, state: 'unreadable', message: (error as Error).message };\n }\n}\n\nfunction rawStableSources(scan: LayoutScanResult): Map<string, LayoutArtifact> {\n const sources = new Map<string, LayoutArtifact>();\n for (const artifact of scan.artifacts) {\n if (artifact.role !== 'raw') continue;\n const value = object(artifact.json);\n const source = value && sourceFromValue({ ...value, kind: 'file' });\n if (source) sources.set(sourceIdentityKey(source), artifact);\n }\n return sources;\n}\n\nfunction currentOwnerArtifacts(scan: LayoutScanResult): Map<string, LayoutArtifact> {\n const owners = new Map<string, LayoutArtifact>();\n for (const artifact of scan.artifacts) {\n const value = object(artifact.json);\n if (!value || !ownerField(value)) continue;\n const source = sourceFromValue(value);\n if (source) owners.set(sourceIdentityKey(source), artifact);\n }\n return owners;\n}\n\nexport function loadLayoutByteEvidence(input: LoadLayoutByteEvidenceInput): LoadedLayoutByteEvidence {\n const diagnostics: ProjectionDiagnostic[] = [];\n const facts = new Map<string, LayoutByteFact>();\n const probe = (relative: string) => {\n if (facts.has(relative)) return facts.get(relative)!;\n const fact = hashLayoutPath(input.root, relative);\n facts.set(relative, fact);\n if (fact.state === 'unreadable')\n diagnostics.push(pathDiagnostic('unreadable-byte-path', relative, fact.message));\n return fact;\n };\n\n for (const artifact of input.scan.artifacts)\n if (artifact.role === 'raw' || artifact.role === 'attachment') probe(artifact.path);\n\n const currentRaw = rawStableSources(input.scan);\n for (const route of input.evidence.binaryRoutes) {\n if (route.selector.slot !== 'file-entry' || !route.bytes) continue;\n const selector = route.selector;\n // The identity is still here, so its old bytes matter only when the sidecar's new bytes are absent.\n const current = route.source.type === 'resource' ? currentRaw.get(sourceIdentityKey(route.source)) : undefined;\n if (current && (current.path === route.bytes || facts.get(current.path)?.state !== 'absent')) continue;\n const currentExact = input.scan.artifacts.some(\n (artifact) => artifact.role === 'raw' && artifact.source === selector.sidecar,\n );\n if (route.source.type === 'transient' && currentExact) continue;\n probe(route.bytes);\n }\n\n const currentOwners = currentOwnerArtifacts(input.scan);\n for (const route of input.evidence.binaryRoutes) {\n if (\n route.selector.slot !== 'owner-attachment' ||\n route.source.type !== 'resource' ||\n !route.contributor ||\n !route.bytes\n )\n continue;\n const owner = currentOwners.get(sourceIdentityKey(route.source));\n if (!owner) continue;\n const value = object(owner.json);\n const field = route.selector.field;\n const authored = value?.[field];\n const currentPointer = pointer(authored);\n if (authored === null) continue;\n if (typeof currentPointer === 'string') {\n const replacement = probe(currentPointer);\n if (replacement.state === 'present') continue;\n }\n probe(route.bytes);\n }\n\n return {\n facts: [...facts.values()].sort((left, right) => compareText(left.path, right.path)),\n diagnostics,\n };\n}\n\nexport interface CapturedLayoutWorkspaceSeed {\n snapshot: LayoutWorkspaceSnapshotSeed;\n}\n\nexport interface CapturedLayoutWorkspace {\n snapshot: LayoutWorkspaceSnapshot;\n}\n\nfunction readExactText(file: string): string {\n const descriptor = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);\n try {\n if (!fs.fstatSync(descriptor).isFile()) throw new Error(`Expected regular file: ${file}`);\n return fs.readFileSync(descriptor, 'utf8');\n } finally {\n fs.closeSync(descriptor);\n }\n}\n\nexport function stateText(root: string): string {\n return readExactText(workspacePath(root, STATE_FILE));\n}\n\nfunction evidence(state: State): LayoutSubmissionEvidence {\n if (!state.layout) throw new Error('Layout state is missing');\n return {\n groupedRoutes: state.layout.evidence.groupedRoutes,\n binaryRoutes: state.layout.evidence.binaryRoutes,\n groupedSubmissionProofs: [],\n binarySubmissionProofs: [],\n derivedSourceProofs: state.layout.evidence.derivedSourceProofs,\n rawNavigationRoutes: state.layout.evidence.rawNavigationRoutes,\n canonicalBaseline: state.baseline,\n detachedFileProofs: state.layout.evidence.detachedFileProofs,\n detachedDocumentProofs: state.layout.evidence.detachedDocumentProofs,\n };\n}\n\nfunction managedJsonText(root: string, scan: ReturnType<typeof scanLayout>): Record<string, string> {\n const result: Record<string, string> = {};\n for (const artifact of scan.artifacts) {\n if (!artifact.present || ['raw', 'attachment'].includes(artifact.role) || artifact.json === undefined) continue;\n if (Object.prototype.hasOwnProperty.call(result, artifact.path))\n throw new Error(`Duplicate managed JSON artifact: ${artifact.path}`);\n const text = readExactText(resolveLayoutPath(root, artifact.path));\n let parsed: unknown;\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n throw new Error(`Managed JSON changed after scanning: ${artifact.path}`);\n }\n if (JSON.stringify(parsed) !== JSON.stringify(artifact.json))\n throw new Error(`Managed JSON changed after scanning: ${artifact.path}`);\n result[artifact.path] = text;\n }\n return result;\n}\n\nfunction completeByteFacts(\n root: string,\n scan: ReturnType<typeof scanLayout>,\n inputEvidence: LayoutSubmissionEvidence,\n): LayoutWorkspaceSnapshotSeed['byteFacts'] {\n const loaded = loadLayoutByteEvidence({ root, scan, evidence: inputEvidence });\n const facts = new Map(loaded.facts.map((fact) => [fact.path, fact]));\n const paths = new Set(\n scan.artifacts\n .filter((artifact) => artifact.role === 'raw' || artifact.role === 'attachment')\n .map((artifact) => artifact.path),\n );\n for (const route of inputEvidence.binaryRoutes) if (route.bytes) paths.add(route.bytes);\n for (const relative of paths) if (!facts.has(relative)) facts.set(relative, hashLayoutPath(root, relative));\n return [...paths].sort(compareText).map((relative) => facts.get(relative)!);\n}\n\nfunction normalizedRequiredPaths(paths: readonly string[]): string[] {\n const result = new Set<string>();\n for (const relative of paths) result.add(parseWorkspacePointer(relative));\n return [...result].sort(compareText);\n}\n\nexport function sameValue(left: unknown, right: unknown): boolean {\n return JSON.stringify(left) === JSON.stringify(right);\n}\n\nfunction capture(\n root: string,\n requiredPaths?: readonly string[],\n): CapturedLayoutWorkspaceSeed | CapturedLayoutWorkspace {\n const beforeStateText = stateText(root);\n // Read-only: the capture keeps only the text; every consumer parses its own copy from it.\n const state = peekState(beforeStateText);\n if (!state.layout) throw new Error('Layout state is missing');\n const tracked = state.layout.tracked;\n const firstScan = scanLayout({ root, tracked });\n const inputEvidence = evidence(state);\n const jsonText = managedJsonText(root, firstScan);\n const byteFacts = completeByteFacts(root, firstScan, inputEvidence);\n const pathFacts =\n requiredPaths === undefined\n ? undefined\n : normalizedRequiredPaths(requiredPaths).map((relative) => probeLayoutPath(root, relative));\n const secondScan = scanLayout({ root, tracked });\n if (!sameValue(firstScan, secondScan)) throw new Error('Layout changed while capturing the workspace');\n const afterStateText = stateText(root);\n if (beforeStateText !== afterStateText) throw new Error('Layout state changed while capturing the workspace');\n const seed: LayoutWorkspaceSnapshotSeed = {\n scan: firstScan,\n jsonText,\n byteFacts,\n stateText: beforeStateText,\n };\n return pathFacts === undefined ? { snapshot: seed } : { snapshot: { ...seed, pathFacts } };\n}\n\nexport function captureLayoutWorkspaceSeed(root: string): CapturedLayoutWorkspaceSeed {\n return capture(root) as CapturedLayoutWorkspaceSeed;\n}\n\nexport function captureLayoutWorkspace(root: string, requiredPaths: readonly string[]): CapturedLayoutWorkspace {\n return capture(root, requiredPaths) as CapturedLayoutWorkspace;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,SAAoB;AACpB,WAAsB;AACtB,wBAAkC;AAClC,uBAA0B;AAG1B,wBAYO;AACP,yBAeO;AAIP,uBAA0C;AAqF1C,MAAM,iBAAiB;AAEvB,MAAM,mBAAmB;AAIzB,SAAS,cAAc,OAAgB,UAA0B,eAAkD;AAC/G,QAAM,aAAS,4BAAS,KAAK,KAAK,OAAO,MAAM,SAAS,WAAW,MAAM,OAAO;AAChF,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI;AACA,eAAO,0CAAsB,MAAM;AAAA,EACvC,SAAS,OAAO;AACZ,kBAAc,kBAAkB,SAAS,MAAO,MAAgB,OAAO;AACvE,WAAO;AAAA,EACX;AACJ;AAEA,SAAS,0BACL,UACA,OACA,OACA,SACA,eACI;AACJ,QAAM,SAAS,cAAc,OAAO,UAAU,aAAa;AAC3D,MAAI,WAAW,OAAW;AAC1B,MAAI,CAAC,gCAAgC,KAAK,MAAM,GAAG;AAC/C,kBAAc,yBAAyB,SAAS,MAAM,0CAA0C,MAAM;AACtG;AAAA,EACJ;AACA,GAAC,SAAS,aAAa,CAAC,GAAG,KAAK,EAAE,MAAM,SAAS,OAAO,MAAM,QAAQ,SAAS,QAAQ,MAAM,EAAE,CAAC;AACpG;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6
+ "names": ["tracked", "ownerField", "pathDiagnostic", "pointer"]
7
+ }
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var output_exports = {};
20
+ __export(output_exports, {
21
+ layoutExitCode: () => layoutExitCode,
22
+ renderNotices: () => renderNotices,
23
+ renderPlan: () => renderPlan,
24
+ renderReceipt: () => renderReceipt
25
+ });
26
+ module.exports = __toCommonJS(output_exports);
27
+ var import_farseer_client = require("farseer-client");
28
+ const quoted = (value) => JSON.stringify(value);
29
+ function renderPlan(plan, options = {}) {
30
+ const lines = [];
31
+ for (const op of plan.operations) {
32
+ const label = `${op.kind} ${quoted(op.name)}`;
33
+ if (op.action === import_farseer_client.PlanOperationActionEnum.Create) lines.push(`+ ${label}`);
34
+ if (op.action === import_farseer_client.PlanOperationActionEnum.Delete)
35
+ lines.push(`- ${label}${op.inducedBy ? ` (with ${op.inducedBy.kind}/${op.inducedBy.id})` : ""}`);
36
+ if (op.action === import_farseer_client.PlanOperationActionEnum.Update)
37
+ lines.push(
38
+ `~ ${label}: ${op.fieldDiff.map((d) => `${d.path.join("/")} ${quoted(d.before)} -> ${quoted(d.after)}`).join(", ")}`
39
+ );
40
+ if (op.action === import_farseer_client.PlanOperationActionEnum.Conflict)
41
+ lines.push(`! conflict ${label} (${op.reason ?? "someone else changed this resource"})`);
42
+ if (op.action === import_farseer_client.PlanOperationActionEnum.Blocked) {
43
+ const by = (op.by ?? []).map((k) => `${k.kind}/${k.id}`).join(", ");
44
+ lines.push(`# blocked ${label} ${by ? `by ${by}` : op.reason ? `(${op.reason})` : "by dependencies"}`);
45
+ }
46
+ }
47
+ lines.push(`${plan.summary.create} to add, ${plan.summary.update} to change, ${plan.summary.delete} to destroy.`);
48
+ const touched = new Set(
49
+ plan.operations.filter((op) => op.action !== import_farseer_client.PlanOperationActionEnum.Noop).flatMap((op) => {
50
+ const key = op.key ?? `${op.kind}/${op.handle}`;
51
+ const id = key.slice(key.indexOf("/") + 1);
52
+ return op.kind === "dimension_table" || op.kind === "dimension_members" ? [`dimension_table/${id}`, `dimension_members/${id}`] : [key];
53
+ })
54
+ );
55
+ let hidden = 0;
56
+ for (const diagnostic of plan.diagnostics) {
57
+ const shown = options.verbose || !diagnostic.preexisting || diagnostic.severity === "error" || !diagnostic.key || touched.has(diagnostic.key);
58
+ if (!shown) {
59
+ hidden += 1;
60
+ continue;
61
+ }
62
+ const path = diagnostic.path?.length ? diagnostic.path.join(".") : "";
63
+ const resource = diagnostic.key ? `${diagnostic.key}${path ? `.${path}` : ""}` : path;
64
+ const file = diagnostic.documentIndex === void 0 ? void 0 : options.files?.get(diagnostic.documentIndex);
65
+ const where = [file, resource].filter(Boolean).join(": ");
66
+ lines.push(
67
+ `${diagnostic.severity ?? "warning"}: ${diagnostic.code}${where ? `: ${where}` : ""}: ${diagnostic.message}`
68
+ );
69
+ }
70
+ if (hidden > 0)
71
+ lines.push(
72
+ `${hidden} pre-existing tenant ${hidden === 1 ? "warning" : "warnings"} hidden (farseer code plan --verbose shows them)`
73
+ );
74
+ return lines;
75
+ }
76
+ function renderReceipt(receipt, operations = []) {
77
+ const byKey = /* @__PURE__ */ new Map();
78
+ for (const op of operations) {
79
+ const key = op.key ?? `${op.kind}/${op.handle}`;
80
+ if (!byKey.has(key)) byKey.set(key, op);
81
+ }
82
+ const label = (key) => {
83
+ const op = byKey.get(key);
84
+ return op ? `${op.kind} ${quoted(op.name)}` : key;
85
+ };
86
+ const entries = [];
87
+ const rejected = /* @__PURE__ */ new Map();
88
+ for (const [key, value] of Object.entries(receipt.outcomes)) {
89
+ if (value.outcome === import_farseer_client.OperationOutcomeOutcomeEnum.Unchanged) continue;
90
+ if (value.outcome === import_farseer_client.OperationOutcomeOutcomeEnum.Failed && value.error?.code === "command-rejected") {
91
+ const group = rejected.get(value.error.message);
92
+ if (group) group.keys.push(key);
93
+ else {
94
+ const created = { message: value.error.message, keys: [key] };
95
+ rejected.set(value.error.message, created);
96
+ entries.push(created);
97
+ }
98
+ } else if (value.outcome === import_farseer_client.OperationOutcomeOutcomeEnum.Skipped) {
99
+ const after = (value.blockedBy ?? []).map((k) => label(`${k.kind}/${k.id}`)).join(", ");
100
+ entries.push(`skipped: ${label(key)}${after ? ` after ${after}` : ""}`);
101
+ } else
102
+ entries.push(
103
+ `${value.outcome}: ${label(key)}${value.error ? ` \u2014 ${value.error.message}` : value.reason ? ` \u2014 ${value.reason}` : ""}${value.blockedBy?.length ? ` by ${value.blockedBy.map((k) => `${k.kind}/${k.id}`).join(", ")}` : ""}`
104
+ );
105
+ }
106
+ return entries.flatMap(
107
+ (entry) => typeof entry === "string" ? [entry] : [
108
+ `engine rejected a command, nothing in it was applied: ${entry.message}`,
109
+ ...entry.keys.map((key) => ` failed: ${label(key)}`)
110
+ ]
111
+ ).concat(
112
+ (receipt.warnings ?? []).map((warning) => `warning: ${warning.code}: ${warning.key} \u2014 ${warning.message}`)
113
+ );
114
+ }
115
+ const NEEDS_ATTENTION = /* @__PURE__ */ new Set([
116
+ "unmaterialized",
117
+ "unpatched-create",
118
+ "ambiguous-patch",
119
+ "conflict",
120
+ "kept-in-place"
121
+ ]);
122
+ function layoutExitCode(notices, receiptStatus) {
123
+ if (receiptStatus !== void 0 && receiptStatus !== import_farseer_client.ReceiptStatusEnum.Complete) return 1;
124
+ return notices.some((notice) => NEEDS_ATTENTION.has(notice.status)) ? 1 : 0;
125
+ }
126
+ const GROUPED_NOTICES = /* @__PURE__ */ new Set([
127
+ "new",
128
+ "updated",
129
+ "deleted",
130
+ "kept local",
131
+ "conflict",
132
+ "kept local edits",
133
+ "ambiguous-patch",
134
+ "unmaterialized",
135
+ "pull needed"
136
+ ]);
137
+ const renderNotices = (notices) => {
138
+ const shared = /* @__PURE__ */ new Map();
139
+ for (const notice of notices) shared.set(notice.path, (shared.get(notice.path) ?? 0) + 1);
140
+ const groups = /* @__PURE__ */ new Map();
141
+ const lines = [];
142
+ for (const notice of notices) {
143
+ if (notice.status === "stale-temporary") lines.push(`stale temporary file: ${notice.path}; delete it`);
144
+ else if (notice.status === "kept-in-place")
145
+ lines.push(`kept in place: ${notice.path}; resolve ${(notice.paths ?? []).join(", ")} and pull again`);
146
+ else if (notice.status === "unmanageable-path")
147
+ lines.push(`unmanageable path: ${notice.path}; the workspace cannot manage this name, rename it`);
148
+ else if (notice.status === "unpatched-create")
149
+ lines.push(
150
+ `unpatched-create: ${notice.path}; add "id": "${(notice.key ?? "").split("/").pop() ?? ""}" by hand or delete the file, then run farseer code pull`
151
+ );
152
+ else if (GROUPED_NOTICES.has(notice.status)) {
153
+ const id = `${notice.status}\0${notice.path}`;
154
+ const group = groups.get(id);
155
+ if (group) {
156
+ if (notice.key && !group.keys.includes(notice.key)) group.keys.push(notice.key);
157
+ continue;
158
+ }
159
+ const created = { notice, keys: notice.key ? [notice.key] : [] };
160
+ groups.set(id, created);
161
+ lines.push(created);
162
+ } else lines.push(`${notice.status}: ${notice.path}`);
163
+ }
164
+ return lines.map((line) => {
165
+ if (typeof line === "string") return line;
166
+ const { notice, keys } = line;
167
+ const named = keys.join(", ");
168
+ const suffix = notice.status === "ambiguous-patch" ? ` (${named}; put the id in by hand or delete it, then run farseer code pull)` : notice.status === "unmaterialized" ? ` (${named}; the workspace kept its current content, run farseer code pull again)` : named && (shared.get(notice.path) ?? 0) > 1 ? ` (${named})` : "";
169
+ return `${notice.status}: ${notice.path}${suffix}`;
170
+ });
171
+ };
172
+ // Annotate the CommonJS export names for ESM import in node:
173
+ 0 && (module.exports = {
174
+ layoutExitCode,
175
+ renderNotices,
176
+ renderPlan,
177
+ renderReceipt
178
+ });
179
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/codefirst/output.ts"],
4
+ "sourcesContent": ["import { OperationOutcomeOutcomeEnum, PlanOperationActionEnum, ReceiptStatusEnum } from 'farseer-client';\nimport { Notice, Plan, PlanOperation, Receipt } from './types';\nconst quoted = (value: unknown) => JSON.stringify(value);\n/**\n * Plan output. A diagnostic is shown unless it is a pre-existing tenant warning on a resource the\n * plan leaves alone: those are counted in one summary line, and `verbose` shows them all. `files`\n * names the file each submitted document came from, by position, so a binding error that carries\n * `documentIndex` names its file before its key and path.\n */\nexport function renderPlan(\n plan: Plan,\n options: { verbose?: boolean; files?: ReadonlyMap<number, string> } = {},\n): string[] {\n const lines: string[] = [];\n for (const op of plan.operations) {\n const label = `${op.kind} ${quoted(op.name)}`;\n if (op.action === PlanOperationActionEnum.Create) lines.push(`+ ${label}`);\n if (op.action === PlanOperationActionEnum.Delete)\n lines.push(`- ${label}${op.inducedBy ? ` (with ${op.inducedBy.kind}/${op.inducedBy.id})` : ''}`);\n // A field-diff path names children by id, so it prints as one, `members/412/name`.\n if (op.action === PlanOperationActionEnum.Update)\n lines.push(\n `~ ${label}: ${op.fieldDiff.map((d) => `${d.path.join('/')} ${quoted(d.before)} -> ${quoted(d.after)}`).join(', ')}`,\n );\n if (op.action === PlanOperationActionEnum.Conflict)\n lines.push(`! conflict ${label} (${op.reason ?? 'someone else changed this resource'})`);\n if (op.action === PlanOperationActionEnum.Blocked) {\n const by = (op.by ?? []).map((k) => `${k.kind}/${k.id}`).join(', ');\n lines.push(`# blocked ${label} ${by ? `by ${by}` : op.reason ? `(${op.reason})` : 'by dependencies'}`);\n }\n }\n lines.push(`${plan.summary.create} to add, ${plan.summary.update} to change, ${plan.summary.delete} to destroy.`);\n // A dimension table and its member set share one file, so touching one touches the other.\n const touched = new Set(\n plan.operations\n .filter((op) => op.action !== PlanOperationActionEnum.Noop)\n .flatMap((op) => {\n const key = op.key ?? `${op.kind}/${op.handle}`;\n const id = key.slice(key.indexOf('/') + 1);\n return op.kind === 'dimension_table' || op.kind === 'dimension_members'\n ? [`dimension_table/${id}`, `dimension_members/${id}`]\n : [key];\n }),\n );\n let hidden = 0;\n for (const diagnostic of plan.diagnostics) {\n const shown =\n options.verbose ||\n !diagnostic.preexisting ||\n diagnostic.severity === 'error' ||\n !diagnostic.key ||\n touched.has(diagnostic.key);\n if (!shown) {\n hidden += 1;\n continue;\n }\n const path = diagnostic.path?.length ? diagnostic.path.join('.') : '';\n const resource = diagnostic.key ? `${diagnostic.key}${path ? `.${path}` : ''}` : path;\n const file = diagnostic.documentIndex === undefined ? undefined : options.files?.get(diagnostic.documentIndex);\n const where = [file, resource].filter(Boolean).join(': ');\n lines.push(\n `${diagnostic.severity ?? 'warning'}: ${diagnostic.code}${where ? `: ${where}` : ''}: ${diagnostic.message}`,\n );\n }\n if (hidden > 0)\n lines.push(\n `${hidden} pre-existing tenant ${hidden === 1 ? 'warning' : 'warnings'} hidden (farseer code plan --verbose shows them)`,\n );\n return lines;\n}\n/**\n * One line per resource that did not end applied or unchanged, then the warnings. The resources of one\n * rejected engine command share its message, so they print once under it; the message is the\n * engine's own and is never interpreted. A skipped resource names the failure the apply stopped at.\n */\nexport function renderReceipt(receipt: Receipt, operations: PlanOperation[] = []): string[] {\n const byKey = new Map<string, PlanOperation>();\n // The first operation of a key wins, as a search from the start would find it.\n for (const op of operations) {\n const key = op.key ?? `${op.kind}/${op.handle}`;\n if (!byKey.has(key)) byKey.set(key, op);\n }\n const label = (key: string) => {\n const op = byKey.get(key);\n return op ? `${op.kind} ${quoted(op.name)}` : key;\n };\n // Each entry is a printed line, or the resources of one rejected command printed under its message.\n const entries: (string | { message: string; keys: string[] })[] = [];\n const rejected = new Map<string, { message: string; keys: string[] }>();\n for (const [key, value] of Object.entries(receipt.outcomes)) {\n if (value.outcome === OperationOutcomeOutcomeEnum.Unchanged) continue;\n if (value.outcome === OperationOutcomeOutcomeEnum.Failed && value.error?.code === 'command-rejected') {\n const group = rejected.get(value.error.message);\n if (group) group.keys.push(key);\n else {\n const created = { message: value.error.message, keys: [key] };\n rejected.set(value.error.message, created);\n entries.push(created);\n }\n } else if (value.outcome === OperationOutcomeOutcomeEnum.Skipped) {\n const after = (value.blockedBy ?? []).map((k) => label(`${k.kind}/${k.id}`)).join(', ');\n entries.push(`skipped: ${label(key)}${after ? ` after ${after}` : ''}`);\n } else\n entries.push(\n `${value.outcome}: ${label(key)}${value.error ? ` \u2014 ${value.error.message}` : value.reason ? ` \u2014 ${value.reason}` : ''}${value.blockedBy?.length ? ` by ${value.blockedBy.map((k) => `${k.kind}/${k.id}`).join(', ')}` : ''}`,\n );\n }\n return entries\n .flatMap((entry) =>\n typeof entry === 'string'\n ? [entry]\n : [\n `engine rejected a command, nothing in it was applied: ${entry.message}`,\n ...entry.keys.map((key) => ` failed: ${label(key)}`),\n ],\n )\n .concat(\n (receipt.warnings ?? []).map((warning) => `warning: ${warning.code}: ${warning.key} \u2014 ${warning.message}`),\n );\n}\n/** A notice that says the workspace did not take the model's value, so the author has to act. */\nconst NEEDS_ATTENTION = new Set<Notice['status']>([\n 'unmaterialized',\n 'unpatched-create',\n 'ambiguous-patch',\n 'conflict',\n 'kept-in-place',\n]);\n\n/**\n * The exit code every layout command reports. It is 1 when the revision did not complete, and 1\n * when one resource needs the author: a notice whose status is in NEEDS_ATTENTION. A plain\n * `warning:` line \u2014 a composition warning, `lost-source-correspondence`, `unlinked-generated-share`\n * \u2014 never changes the code by itself, because the command did what it was asked to do. `plan` has\n * no notices: its code comes from the server's own applicability instead.\n */\nexport function layoutExitCode(notices: readonly Notice[], receiptStatus?: ReceiptStatusEnum): 0 | 1 {\n if (receiptStatus !== undefined && receiptStatus !== ReceiptStatusEnum.Complete) return 1;\n return notices.some((notice) => NEEDS_ATTENTION.has(notice.status)) ? 1 : 0;\n}\n\n/** Notices printed once per path and status, naming every resource of that path they cover. */\nconst GROUPED_NOTICES = new Set<Notice['status']>([\n 'new',\n 'updated',\n 'deleted',\n 'kept local',\n 'conflict',\n 'kept local edits',\n 'ambiguous-patch',\n 'unmaterialized',\n 'pull needed',\n]);\n\nexport const renderNotices = (notices: Notice[]): string[] => {\n // A shared container carries several resources, so its line names the ones it covers.\n const shared = new Map<string, number>();\n for (const notice of notices) shared.set(notice.path, (shared.get(notice.path) ?? 0) + 1);\n const groups = new Map<string, { notice: Notice; keys: string[] }>();\n const lines: ({ notice: Notice; keys: string[] } | string)[] = [];\n for (const notice of notices) {\n if (notice.status === 'stale-temporary') lines.push(`stale temporary file: ${notice.path}; delete it`);\n else if (notice.status === 'kept-in-place')\n lines.push(`kept in place: ${notice.path}; resolve ${(notice.paths ?? []).join(', ')} and pull again`);\n else if (notice.status === 'unmanageable-path')\n lines.push(`unmanageable path: ${notice.path}; the workspace cannot manage this name, rename it`);\n else if (notice.status === 'unpatched-create')\n lines.push(\n `unpatched-create: ${notice.path}; add \"id\": \"${(notice.key ?? '').split('/').pop() ?? ''}\" by hand or delete the file, then run farseer code pull`,\n );\n else if (GROUPED_NOTICES.has(notice.status)) {\n const id = `${notice.status}\\0${notice.path}`;\n const group = groups.get(id);\n if (group) {\n if (notice.key && !group.keys.includes(notice.key)) group.keys.push(notice.key);\n continue;\n }\n const created = { notice, keys: notice.key ? [notice.key] : [] };\n groups.set(id, created);\n lines.push(created);\n } else lines.push(`${notice.status}: ${notice.path}`);\n }\n return lines.map((line) => {\n if (typeof line === 'string') return line;\n const { notice, keys } = line;\n const named = keys.join(', ');\n const suffix =\n notice.status === 'ambiguous-patch'\n ? ` (${named}; put the id in by hand or delete it, then run farseer code pull)`\n : notice.status === 'unmaterialized'\n ? ` (${named}; the workspace kept its current content, run farseer code pull again)`\n : named && (shared.get(notice.path) ?? 0) > 1\n ? ` (${named})`\n : '';\n return `${notice.status}: ${notice.path}${suffix}`;\n });\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAwF;AAExF,MAAM,SAAS,CAAC,UAAmB,KAAK,UAAU,KAAK;AAOhD,SAAS,WACZ,MACA,UAAsE,CAAC,GAC/D;AACR,QAAM,QAAkB,CAAC;AACzB,aAAW,MAAM,KAAK,YAAY;AAC9B,UAAM,QAAQ,GAAG,GAAG,IAAI,IAAI,OAAO,GAAG,IAAI,CAAC;AAC3C,QAAI,GAAG,WAAW,8CAAwB,OAAQ,OAAM,KAAK,KAAK,KAAK,EAAE;AACzE,QAAI,GAAG,WAAW,8CAAwB;AACtC,YAAM,KAAK,KAAK,KAAK,GAAG,GAAG,YAAY,UAAU,GAAG,UAAU,IAAI,IAAI,GAAG,UAAU,EAAE,MAAM,EAAE,EAAE;AAEnG,QAAI,GAAG,WAAW,8CAAwB;AACtC,YAAM;AAAA,QACF,KAAK,KAAK,KAAK,GAAG,UAAU,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,KAAK,GAAG,CAAC,IAAI,OAAO,EAAE,MAAM,CAAC,OAAO,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC;AAAA,MACtH;AACJ,QAAI,GAAG,WAAW,8CAAwB;AACtC,YAAM,KAAK,cAAc,KAAK,KAAK,GAAG,UAAU,oCAAoC,GAAG;AAC3F,QAAI,GAAG,WAAW,8CAAwB,SAAS;AAC/C,YAAM,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,KAAK,IAAI;AAClE,YAAM,KAAK,aAAa,KAAK,IAAI,KAAK,MAAM,EAAE,K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Z,KAAK,KAAK,sEACV,OAAO,WAAW,mBAChB,KAAK,KAAK,2EACV,UAAU,OAAO,IAAI,OAAO,IAAI,KAAK,KAAK,IACxC,KAAK,KAAK,MACV;AACd,WAAO,GAAG,OAAO,MAAM,KAAK,OAAO,IAAI,GAAG,MAAM;AAAA,EACpD,CAAC;AACL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/codefirst/types.ts"],
4
+ "sourcesContent": ["import type { LayoutReceiptSubmission } from './layoutReadback';\nimport type { TrackedLayoutPath } from './layoutScan';\nimport type { LayoutSubmissionEvidence } from './layoutCompose';\nimport type { DocumentKindEnum, Receipt } from 'farseer-client';\n\n// The server's bodies are the generated SDK models (`api.ts` parses each through its `FromJSON`).\nexport type {\n AdmissionConflict,\n ApplyingHead,\n BlobContent,\n ExpiredPlan,\n Handle,\n Head,\n HeadDiagnostic,\n Pending,\n Plan,\n PlanOperation,\n Receipt,\n ResourceKey,\n} from 'farseer-client';\nexport type Json = null | boolean | number | string | Json[] | { [key: string]: Json };\n/**\n * A workspace document as composed from its files: plain JSON with the spec's `kind`. The plan\n * request sends it as the generated `Document`, whose other fields are untyped.\n */\nexport type Document = { [key: string]: Json } & { kind: `${DocumentKindEnum}` };\n/** The routes, proofs and provenance the workspace keeps between commands. */\nexport type PersistedLayoutEvidence = Pick<\n LayoutSubmissionEvidence,\n | 'groupedRoutes'\n | 'binaryRoutes'\n | 'derivedSourceProofs'\n | 'rawNavigationRoutes'\n | 'detachedFileProofs'\n | 'detachedDocumentProofs'\n>;\nexport interface LayoutReceiptDraft {\n submission: LayoutReceiptSubmission;\n applying?: boolean;\n /**\n * An apply request of this draft has had no answer from the server yet (set before the first\n * POST, cleared by any answer). While it is set, a 404 from `GET \u2026/attempt` does not prove the\n * plan was never admitted, because that request may still be admitting it.\n */\n unanswered?: boolean;\n revisionId?: string;\n receipt?: Receipt;\n}\nexport interface LayoutWorkspaceState {\n evidence: PersistedLayoutEvidence;\n /** Opaque physical-claim IDs. Materialization preserves caller IDs and allocates deterministic IDs for new claims. */\n tracked: readonly TrackedLayoutPath[];\n receipts: Record<string, LayoutReceiptDraft>;\n /**\n * Drafts the state reader could not validate, kept verbatim under their plan id. They are never\n * used again, and they keep one damaged receipt from making the whole workspace unreadable.\n */\n unreadableReceipts?: Record<string, Json>;\n /**\n * Content hashes of raw byte files by workspace path, with the size, mtime, ctime (ns) and inode they\n * were hashed at. A cache only: a missing or damaged map means every file is hashed again.\n */\n byteHashes?: Record<string, ByteHashEntry>;\n}\n/** One cached file hash; `mtimeNs`, `ctimeNs` and `ino` are decimal strings, as the filesystem reports them. */\nexport interface ByteHashEntry {\n sha256: string;\n size: number;\n mtimeNs: string;\n ctimeNs: string;\n ino: string;\n}\n/** The target one code workspace was checked out from. Every command re-resolves auth from it. */\nexport interface WorkspaceIdentity {\n tenant: string;\n organisation: string;\n /**\n * The server the checkout resolved (`CodeFirstApi.baseUrl`). Plan ids and baseline versions\n * belong to one server, so every command refuses to talk to another.\n */\n baseUrl: string;\n}\nexport interface State extends WorkspaceIdentity {\n revisionId: string | null;\n baseline: Record<string, string>;\n layout: LayoutWorkspaceState;\n}\nexport interface Notice {\n status:\n | 'new'\n | 'updated'\n | 'deleted'\n | 'kept local'\n | 'conflict'\n | 'kept local edits'\n | 'ambiguous-patch'\n | 'unmaterialized'\n | 'unpatched-create'\n | 'stale-temporary'\n | 'unmanageable-path'\n | 'kept-in-place'\n | 'pull needed';\n path: string;\n key?: string;\n /** The paths one notice names beside its own: what keeps a folder where the workspace has it. */\n paths?: readonly string[];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }