farseer-cli 1.17.0 → 1.19.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 +3 -3
- package/dist/commands/app.js.map +0 -1
- package/dist/commands/apps.js.map +0 -1
- package/dist/commands/cells.js.map +0 -1
- package/dist/commands/code.js.map +0 -1
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/dashboards.js.map +0 -1
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/dimensions.js.map +0 -1
- package/dist/commands/files.js.map +0 -1
- package/dist/commands/formula.js +16 -7
- package/dist/commands/formula.js.map +1 -2
- package/dist/commands/install.js.map +0 -1
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -2
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/mcp-server.js.map +0 -1
- package/dist/commands/model.js.map +0 -1
- package/dist/commands/pipeline.js.map +0 -1
- package/dist/commands/pull.js +1 -1
- package/dist/commands/pull.js.map +1 -2
- package/dist/commands/push.js +2 -2
- package/dist/commands/push.js.map +1 -2
- package/dist/commands/refresh.js.map +0 -1
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/sheets.js.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/tool.js +120 -0
- package/dist/commands/tool.js.map +6 -0
- package/dist/commands/variables.js.map +0 -1
- package/dist/commands/whoami.js.map +0 -1
- package/dist/index.js +29 -12
- package/dist/index.js.map +1 -2
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/prompts/workflows.js.map +0 -1
- package/dist/mcp/resources/documentation.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/skills.js.map +0 -1
- package/dist/mcp/tools/appTools.js.map +0 -1
- package/dist/mcp/tools/authTools.js +1 -1
- package/dist/mcp/tools/authTools.js.map +1 -2
- package/dist/mcp/tools/cellTools.js.map +0 -1
- package/dist/mcp/tools/dashboardTools.js.map +0 -1
- package/dist/mcp/tools/dataTools.js.map +0 -1
- package/dist/mcp/tools/folderTools.js.map +0 -1
- package/dist/mcp/tools/modelTools.js +65 -23
- package/dist/mcp/tools/modelTools.js.map +2 -3
- package/dist/mcp/tools/pipelineContract.js.map +0 -1
- package/dist/mcp/tools/pipelineTools.js.map +0 -1
- package/dist/mcp/tools/runTools.js +6 -2
- package/dist/mcp/tools/runTools.js.map +1 -2
- package/dist/mcp/tools/sheetTools.js.map +0 -1
- package/dist/mcp/tools/syncTools.js +2 -2
- package/dist/mcp/tools/syncTools.js.map +1 -2
- package/dist/mcp/utils/helpers.js.map +0 -1
- package/dist/mcp/utils/launchPin.js +1 -1
- package/dist/mcp/utils/launchPin.js.map +1 -2
- package/dist/mcp/utils/registerTool.js.map +0 -1
- package/dist/mcp/utils/session.js.map +0 -1
- package/dist/mcp/utils/tenantPin.js.map +0 -1
- package/dist/pipeline/compatibility.js.map +0 -1
- package/dist/pipeline/connect.js.map +0 -1
- package/dist/pipeline/create.js.map +0 -1
- package/dist/pipeline/errors.js.map +0 -1
- package/dist/pipeline/generated-reference.json +22 -10
- package/dist/pipeline/guide.js.map +0 -1
- package/dist/pipeline/init.js.map +0 -1
- package/dist/pipeline/operations.js.map +0 -1
- package/dist/pipeline/query.js.map +0 -1
- package/dist/pipeline/queryDownloads.js.map +0 -1
- package/dist/pipeline/queryWorker.js.map +0 -1
- package/dist/pipeline/readiness.js.map +0 -1
- package/dist/pipeline/reference.js.map +0 -1
- package/dist/pipeline/requests.js.map +0 -1
- package/dist/pipeline/runArguments.js.map +0 -1
- package/dist/pipeline/runtime.js.map +0 -1
- package/dist/pipeline/service.js.map +0 -1
- package/dist/services/agentApprovalFetch.js +7 -3
- package/dist/services/agentApprovalFetch.js.map +1 -2
- package/dist/services/appSyncService.js.map +0 -1
- package/dist/services/apps.js.map +0 -1
- package/dist/services/authErrors.js.map +0 -1
- package/dist/services/codefirst/api.js +38 -5
- package/dist/services/codefirst/api.js.map +1 -2
- package/dist/services/codefirst/binaryDisk.js.map +0 -1
- package/dist/services/codefirst/byteHashes.js +5 -0
- package/dist/services/codefirst/byteHashes.js.map +1 -2
- package/dist/services/codefirst/documents.js +41 -15
- package/dist/services/codefirst/documents.js.map +1 -2
- package/dist/services/codefirst/layoutBinaryProjection.js +24 -13
- package/dist/services/codefirst/layoutBinaryProjection.js.map +1 -2
- package/dist/services/codefirst/layoutCompose.js +44 -38
- package/dist/services/codefirst/layoutCompose.js.map +1 -2
- package/dist/services/codefirst/layoutCore.js +14 -1
- package/dist/services/codefirst/layoutCore.js.map +1 -2
- package/dist/services/codefirst/layoutPaths.js +80 -4
- package/dist/services/codefirst/layoutPaths.js.map +1 -2
- package/dist/services/codefirst/layoutProjection.js +73 -39
- package/dist/services/codefirst/layoutProjection.js.map +1 -2
- package/dist/services/codefirst/layoutReadback.js +357 -130
- package/dist/services/codefirst/layoutReadback.js.map +2 -3
- package/dist/services/codefirst/layoutReadbackPlacement.js +94 -57
- package/dist/services/codefirst/layoutReadbackPlacement.js.map +2 -3
- package/dist/services/codefirst/layoutReceipt.js +283 -243
- package/dist/services/codefirst/layoutReceipt.js.map +2 -3
- package/dist/services/codefirst/layoutScan.js +208 -110
- package/dist/services/codefirst/layoutScan.js.map +1 -2
- package/dist/services/codefirst/output.js +76 -10
- package/dist/services/codefirst/output.js.map +1 -2
- package/dist/services/codefirst/types.js.map +0 -1
- package/dist/services/codefirst/workflow.js +65 -29
- package/dist/services/codefirst/workflow.js.map +2 -3
- package/dist/services/codefirst/workspace.js.map +0 -1
- package/dist/services/codefirst/workspaceLock.js.map +0 -1
- package/dist/services/codefirst/workspaceRoot.js +2 -1
- package/dist/services/codefirst/workspaceRoot.js.map +1 -2
- package/dist/services/configService.js.map +0 -1
- package/dist/services/credentials.js.map +0 -1
- package/dist/services/farseerService.js +3 -1
- package/dist/services/farseerService.js.map +1 -2
- package/dist/services/httpError.js.map +0 -1
- package/dist/services/modelExport.js.map +0 -1
- package/dist/services/organisation.js.map +0 -1
- package/dist/services/preflight.js.map +0 -1
- package/dist/services/realms.js.map +0 -1
- package/dist/services/syncService.js +3 -3
- package/dist/services/syncService.js.map +1 -2
- package/dist/skills/pipeline.js.map +0 -1
- package/dist/utils/agentSandbox.js.map +0 -1
- package/dist/utils/cliOptions.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/entityResolver.js.map +0 -1
- package/dist/utils/errorFormatter.js +59 -11
- package/dist/utils/errorFormatter.js.map +1 -2
- package/dist/utils/fileLogger.js.map +0 -1
- package/dist/utils/fileValidation.js.map +0 -1
- package/dist/utils/folderMatch.js.map +0 -1
- package/dist/utils/formulaFilters.js +48 -0
- package/dist/utils/formulaFilters.js.map +6 -0
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/nameResolver.js.map +0 -1
- package/dist/utils/packageManager.js.map +0 -1
- package/dist/utils/syncReporting.js.map +0 -1
- package/dist/utils/syncScope.js.map +0 -1
- package/dist/utils/updateCheck.js.map +0 -1
- package/dist/utils/variableValues.js.map +0 -1
- package/dist/utils/workspace.js.map +0 -1
- package/docs/cli-guide.md +14 -1
- package/docs/import-workflows.md +14 -14
- package/docs/new-app-template.md +1 -1
- package/docs/pipeline-client-guide.md +1 -1
- package/docs/pipeline-reference.md +292 -3
- package/package.json +2 -2
- package/skills/farseer-analysis/SKILL.md +132 -0
- package/skills/farseer-dashboards/SKILL.md +40 -0
- package/skills/farseer-formulas/SKILL.md +165 -0
- package/skills/farseer-model/SKILL.md +119 -0
- package/skills/pipeline-authoring/SKILL.md +6 -4
- package/skills/pipeline-authoring/practices.md +6 -5
|
@@ -31,6 +31,10 @@ const FLAT_ROOTS = {
|
|
|
31
31
|
dataset: "definitions/datasets",
|
|
32
32
|
export_configuration: "definitions/exports"
|
|
33
33
|
};
|
|
34
|
+
const FIXED_PATHS = {
|
|
35
|
+
settings: "definitions/settings.json",
|
|
36
|
+
global_locks: "definitions/global_locks.json"
|
|
37
|
+
};
|
|
34
38
|
function sameBinarySelector(left, right) {
|
|
35
39
|
if (left.slot !== right.slot) return false;
|
|
36
40
|
if (left.slot === "file-entry" && right.slot === "file-entry") return left.sidecar === right.sidecar;
|
|
@@ -54,14 +58,12 @@ function sourceFor(documentKey, document) {
|
|
|
54
58
|
function semanticPath(document) {
|
|
55
59
|
const value = document;
|
|
56
60
|
if (document.kind === "folder") {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return value.path;
|
|
61
|
+
const path = (0, import_layoutPaths.folderPathSegments)(value.path);
|
|
62
|
+
return path && typeof path.at(-1) === "string" ? path : void 0;
|
|
60
63
|
}
|
|
61
64
|
if (["variable", "dimension_table", "sheet", "dashboard", "remote_job", "file"].includes(document.kind)) {
|
|
62
|
-
const folder =
|
|
63
|
-
if (typeof value.name !== "string" || !value.name || !
|
|
64
|
-
return void 0;
|
|
65
|
+
const folder = (0, import_layoutPaths.itemFolderPath)(value.folder);
|
|
66
|
+
if (typeof value.name !== "string" || !value.name || !folder) return void 0;
|
|
65
67
|
return [...folder, value.name];
|
|
66
68
|
}
|
|
67
69
|
return void 0;
|
|
@@ -97,17 +99,21 @@ function requiresIdentityReallocation(candidate) {
|
|
|
97
99
|
}
|
|
98
100
|
function selectedHeadDamage(input, diagnostics) {
|
|
99
101
|
if (!input.head) return /* @__PURE__ */ new Map();
|
|
102
|
+
const proof = input.headProof;
|
|
100
103
|
try {
|
|
101
104
|
const authoritative = input.headDocuments;
|
|
102
105
|
if (!authoritative) throw new Error("Selected Head was not validated");
|
|
103
|
-
const damage = extractAuthoritativeDamageEvidence(input.head, authoritative);
|
|
106
|
+
const damage = proof?.damage ?? extractAuthoritativeDamageEvidence(input.head, authoritative);
|
|
107
|
+
if (proof) proof.damage = damage;
|
|
104
108
|
if (input.documents.length !== input.documentKeys.length || new Set(input.documentKeys).size !== input.documentKeys.length)
|
|
105
109
|
throw new Error("Selected documents are missing, duplicated or misaligned");
|
|
106
110
|
for (const [index, document] of input.documents.entries()) {
|
|
107
111
|
const documentKey = input.documentKeys[index];
|
|
112
|
+
if (proof?.matched.get(documentKey) === document) continue;
|
|
108
113
|
const expected = authoritative.get(documentKey);
|
|
109
114
|
if (!expected || (0, import_layoutCore.canonicalFragmentHash)({ documentKey, document }) !== (0, import_layoutCore.canonicalFragmentHash)({ documentKey, document: expected }))
|
|
110
115
|
throw new Error(`Selected document does not match Head: ${documentKey}`);
|
|
116
|
+
proof?.matched.set(documentKey, document);
|
|
111
117
|
}
|
|
112
118
|
return damage;
|
|
113
119
|
} catch (error) {
|
|
@@ -145,9 +151,13 @@ function groupOwner(document) {
|
|
|
145
151
|
return { kind: owner.kind, dangling: owner.dangling };
|
|
146
152
|
return void 0;
|
|
147
153
|
}
|
|
154
|
+
function markerId(value) {
|
|
155
|
+
const marker = (0, import_layoutCore.object)(value);
|
|
156
|
+
return typeof marker?.dangling === "string" ? marker.dangling : typeof marker?.hidden === "string" ? marker.hidden : void 0;
|
|
157
|
+
}
|
|
148
158
|
function hasExplicitDamageShape(document) {
|
|
149
159
|
const value = document;
|
|
150
|
-
if (document.kind === "folder") return value.path === null &&
|
|
160
|
+
if (document.kind === "folder") return value.path === null && markerId(value.parent) !== void 0;
|
|
151
161
|
if (document.kind === "share") return typeof (0, import_layoutCore.object)(value.owner)?.dangling === "string";
|
|
152
162
|
return ["variable", "dimension_table", "sheet", "dashboard", "remote_job", "file"].includes(document.kind) && typeof (0, import_layoutCore.object)(value.folder)?.dangling === "string";
|
|
153
163
|
}
|
|
@@ -257,6 +267,24 @@ function planAuthoritativePlacement(input) {
|
|
|
257
267
|
...rawObservationsBySource.keys(),
|
|
258
268
|
...input.currentBinary.attachmentObservations.map((observation) => (0, import_layoutCore.sourceIdentityKey)(observation.source))
|
|
259
269
|
]);
|
|
270
|
+
let insertionEvidence;
|
|
271
|
+
const signatureKey = (document) => JSON.stringify([document.kind, placementSignature(document)]);
|
|
272
|
+
const indexInsertionEvidence = () => {
|
|
273
|
+
const keyedSignatures = /* @__PURE__ */ new Set();
|
|
274
|
+
const keyed = (source, document) => {
|
|
275
|
+
if (document && (source.type === "transient" || source.type === "resource" && "key" in source.resource))
|
|
276
|
+
keyedSignatures.add(signatureKey(document));
|
|
277
|
+
};
|
|
278
|
+
for (const mapping of input.currentGrouped.sources)
|
|
279
|
+
keyed(mapping.source, input.currentGrouped.documents[mapping.documentIndex]);
|
|
280
|
+
for (const mapping of input.currentBinary.rawSources)
|
|
281
|
+
keyed(mapping.source, input.currentBinary.rawDocuments[mapping.documentIndex]);
|
|
282
|
+
return {
|
|
283
|
+
keyedSignatures,
|
|
284
|
+
routeSources: new Set(input.groupedRoutes.map((route) => (0, import_layoutCore.sourceIdentityKey)(route.source))),
|
|
285
|
+
trackedRoutes: new Set(input.scan.tracked.map((tracked) => tracked.route))
|
|
286
|
+
};
|
|
287
|
+
};
|
|
260
288
|
const normalized = [];
|
|
261
289
|
const usedIndexes = /* @__PURE__ */ new Set();
|
|
262
290
|
const usedKeys = /* @__PURE__ */ new Set();
|
|
@@ -352,19 +380,9 @@ function planAuthoritativePlacement(input) {
|
|
|
352
380
|
}
|
|
353
381
|
} else {
|
|
354
382
|
const key = (0, import_layoutCore.sourceIdentityKey)(source);
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
source: mapping.source
|
|
359
|
-
})),
|
|
360
|
-
...input.currentBinary.rawSources.map((mapping) => ({
|
|
361
|
-
document: input.currentBinary.rawDocuments[mapping.documentIndex],
|
|
362
|
-
source: mapping.source
|
|
363
|
-
}))
|
|
364
|
-
].some(
|
|
365
|
-
(current2) => (current2.source.type === "transient" || current2.source.type === "resource" && "key" in current2.source.resource) && current2.document?.kind === document.kind && placementSignature(current2.document) === placementSignature(document)
|
|
366
|
-
);
|
|
367
|
-
const priorAssociation = input.groupedRoutes.some((route) => (0, import_layoutCore.sourceIdentityKey)(route.source) === key) || currentSourceKeys.has(key) || (0, import_layoutCore.own)(input.canonicalBaseline, intent.documentKey) || input.scan.tracked.some((tracked) => tracked.route === intent.documentKey);
|
|
383
|
+
const evidence = insertionEvidence ??= indexInsertionEvidence();
|
|
384
|
+
const semanticAssociation = document.kind !== "share" && evidence.keyedSignatures.has(signatureKey(document));
|
|
385
|
+
const priorAssociation = evidence.routeSources.has(key) || currentSourceKeys.has(key) || (0, import_layoutCore.own)(input.canonicalBaseline, intent.documentKey) || evidence.trackedRoutes.has(intent.documentKey);
|
|
368
386
|
if (semanticAssociation || priorAssociation && !intent.reinsert) {
|
|
369
387
|
diagnostics.push(
|
|
370
388
|
(0, import_layoutCore.diagnostic)("invalid-insertion-authority", intent.documentKey, "A prior source association exists")
|
|
@@ -500,7 +518,7 @@ function planAuthoritativePlacement(input) {
|
|
|
500
518
|
}
|
|
501
519
|
};
|
|
502
520
|
const reserveControl = (path, identity) => {
|
|
503
|
-
const existing = allocator.
|
|
521
|
+
const existing = allocator.claimsAt(path);
|
|
504
522
|
if (existing.length > 0) {
|
|
505
523
|
if (existing.length === 1 && existing[0].kind === "file" && existing[0].role === "control") return true;
|
|
506
524
|
diagnostics.push(
|
|
@@ -511,7 +529,8 @@ function planAuthoritativePlacement(input) {
|
|
|
511
529
|
return claimFixed({ path, kind: "file", role: "control", identity });
|
|
512
530
|
};
|
|
513
531
|
const resolveParent = (path, childKey) => {
|
|
514
|
-
if (path.length === 0
|
|
532
|
+
if (path.length === 0 || path.length === 1 && (0, import_layoutPaths.anchorId)(path[0]) !== void 0)
|
|
533
|
+
return { type: "normal", directory: (0, import_layoutPaths.folderRootDirectory)(path) };
|
|
515
534
|
const key = (0, import_layoutCore.canonicalFragmentHash)([...path]);
|
|
516
535
|
const planned = plannedFolders.get(key);
|
|
517
536
|
if (planned) return planned;
|
|
@@ -579,7 +598,7 @@ function planAuthoritativePlacement(input) {
|
|
|
579
598
|
);
|
|
580
599
|
return void 0;
|
|
581
600
|
}
|
|
582
|
-
const before = allocator.
|
|
601
|
+
const before = allocator.size;
|
|
583
602
|
try {
|
|
584
603
|
const allocated = allocator.allocate(request);
|
|
585
604
|
if (forbidden(allocated.path)) {
|
|
@@ -612,7 +631,7 @@ function planAuthoritativePlacement(input) {
|
|
|
612
631
|
reason: "representation-fallback",
|
|
613
632
|
sourceKey: (0, import_layoutCore.sourceIdentityKey)(candidate.source),
|
|
614
633
|
request,
|
|
615
|
-
existingClaims: before
|
|
634
|
+
existingClaims: allocator.snapshot(before)
|
|
616
635
|
};
|
|
617
636
|
return { file: path, slot };
|
|
618
637
|
}
|
|
@@ -696,7 +715,7 @@ function planAuthoritativePlacement(input) {
|
|
|
696
715
|
} else if (parent?.type === "normal") {
|
|
697
716
|
const request = {
|
|
698
717
|
directory: parent.directory,
|
|
699
|
-
name:
|
|
718
|
+
name: (0, import_layoutPaths.lastPathName)(path),
|
|
700
719
|
role: "directory",
|
|
701
720
|
identity: identityValue(candidate.source),
|
|
702
721
|
requiredChildren: ["_folder.json"]
|
|
@@ -771,7 +790,7 @@ function planAuthoritativePlacement(input) {
|
|
|
771
790
|
try {
|
|
772
791
|
allocated = allocator.allocate({
|
|
773
792
|
directory: bucket.path,
|
|
774
|
-
name:
|
|
793
|
+
name: (0, import_layoutPaths.lastPathName)(path),
|
|
775
794
|
role: "raw",
|
|
776
795
|
identity: identityValue(candidate.source)
|
|
777
796
|
});
|
|
@@ -886,11 +905,11 @@ function planAuthoritativePlacement(input) {
|
|
|
886
905
|
}
|
|
887
906
|
const request = {
|
|
888
907
|
directory: parent.directory,
|
|
889
|
-
name:
|
|
908
|
+
name: (0, import_layoutPaths.lastPathName)(path),
|
|
890
909
|
role: "raw",
|
|
891
910
|
identity: identityValue(candidate.source)
|
|
892
911
|
};
|
|
893
|
-
const before = allocator.
|
|
912
|
+
const before = allocator.size;
|
|
894
913
|
try {
|
|
895
914
|
const allocated = allocator.allocate(request);
|
|
896
915
|
allocations.push({ source: candidate.source, path: allocated });
|
|
@@ -904,7 +923,10 @@ function planAuthoritativePlacement(input) {
|
|
|
904
923
|
};
|
|
905
924
|
} catch (error) {
|
|
906
925
|
if (error instanceof import_layoutPaths.LayoutPathAllocationError && error.reason === "unrepresentable")
|
|
907
|
-
destination = allocateDetachedRaw(candidate, void 0, {
|
|
926
|
+
destination = allocateDetachedRaw(candidate, void 0, {
|
|
927
|
+
request,
|
|
928
|
+
claims: allocator.snapshot(before)
|
|
929
|
+
});
|
|
908
930
|
else
|
|
909
931
|
diagnostics.push(
|
|
910
932
|
(0, import_layoutCore.diagnostic)("invalid-layout-request", candidate.documentKey, error.message)
|
|
@@ -950,15 +972,15 @@ function planAuthoritativePlacement(input) {
|
|
|
950
972
|
candidate,
|
|
951
973
|
request: {
|
|
952
974
|
directory: parent.directory,
|
|
953
|
-
name:
|
|
975
|
+
name: (0, import_layoutPaths.lastPathName)(path),
|
|
954
976
|
extension: ".json",
|
|
955
977
|
role: "document",
|
|
956
978
|
identity: identityValue(candidate.source)
|
|
957
979
|
},
|
|
958
980
|
slot: document.kind === "dimension_table" ? "table-definition" : "document"
|
|
959
981
|
});
|
|
960
|
-
} else if (document.kind
|
|
961
|
-
const path =
|
|
982
|
+
} else if (FIXED_PATHS[document.kind]) {
|
|
983
|
+
const path = FIXED_PATHS[document.kind];
|
|
962
984
|
if (claimFixed({
|
|
963
985
|
path,
|
|
964
986
|
kind: "file",
|
|
@@ -1037,8 +1059,8 @@ function planAuthoritativePlacement(input) {
|
|
|
1037
1059
|
let destination = tableDestinations.get(id);
|
|
1038
1060
|
if (!destination) {
|
|
1039
1061
|
const tableSource = `resource/dimension_table/id/${id}`;
|
|
1040
|
-
const table =
|
|
1041
|
-
(mapping) =>
|
|
1062
|
+
const table = (groupedBySource.get(tableSource) ?? []).filter(
|
|
1063
|
+
(mapping) => mapping.selector.slot === "table-definition"
|
|
1042
1064
|
);
|
|
1043
1065
|
const file = table.length === 1 ? table[0].selector.file : candidate.current?.codec === "grouped" ? candidate.current.mapping.selector.file : void 0;
|
|
1044
1066
|
if (file) destination = { file, slot: "member-set" };
|
|
@@ -1107,7 +1129,11 @@ function planAuthoritativePlacement(input) {
|
|
|
1107
1129
|
...candidate.current.mapping.selector,
|
|
1108
1130
|
identity: { id: identityValue(candidate.source) }
|
|
1109
1131
|
});
|
|
1110
|
-
} else
|
|
1132
|
+
} else {
|
|
1133
|
+
const pending = pendingShareGroups.get(key);
|
|
1134
|
+
if (pending) pending.push(candidate);
|
|
1135
|
+
else pendingShareGroups.set(key, [candidate]);
|
|
1136
|
+
}
|
|
1111
1137
|
}
|
|
1112
1138
|
for (const [key, candidates] of [...pendingShareGroups].sort(([left], [right]) => left.localeCompare(right))) {
|
|
1113
1139
|
const owner = groupOwner(candidates[0].document);
|
|
@@ -1284,7 +1310,9 @@ function planAuthoritativePlacement(input) {
|
|
|
1284
1310
|
);
|
|
1285
1311
|
groupedTargetKeys.add(key);
|
|
1286
1312
|
const fileKey = (0, import_layoutPaths.layoutCollisionKey)(selector.file);
|
|
1287
|
-
|
|
1313
|
+
const fileOwners = groupedFileOwners.get(fileKey);
|
|
1314
|
+
if (fileOwners) fileOwners.push(correspondence);
|
|
1315
|
+
else groupedFileOwners.set(fileKey, [correspondence]);
|
|
1288
1316
|
}
|
|
1289
1317
|
for (const owners of groupedFileOwners.values()) {
|
|
1290
1318
|
if (owners.length < 2) continue;
|
|
@@ -1410,43 +1438,51 @@ function validateRenderedIdentity(document, source) {
|
|
|
1410
1438
|
if (resourceId(document.id) !== source.resource.id)
|
|
1411
1439
|
throw new Error(`Head document identity does not match its key: ${source.resource.kind}/${source.resource.id}`);
|
|
1412
1440
|
}
|
|
1413
|
-
function
|
|
1441
|
+
function exactMarker(value) {
|
|
1414
1442
|
const marker = (0, import_layoutCore.object)(value);
|
|
1415
1443
|
if (!marker || Object.keys(marker).length !== 1) return void 0;
|
|
1416
|
-
return resourceId(marker.dangling);
|
|
1444
|
+
return resourceId(marker.dangling) ?? resourceId(marker.hidden);
|
|
1417
1445
|
}
|
|
1418
|
-
function
|
|
1419
|
-
|
|
1446
|
+
function diagnosticsByResource(diagnostics) {
|
|
1447
|
+
const byResource = /* @__PURE__ */ new Map();
|
|
1448
|
+
for (const diagnostic2 of diagnostics) {
|
|
1449
|
+
if (typeof diagnostic2.kind !== "string" || typeof diagnostic2.id !== "string") continue;
|
|
1450
|
+
const key = JSON.stringify([diagnostic2.kind, diagnostic2.id]);
|
|
1451
|
+
const list = byResource.get(key);
|
|
1452
|
+
if (list) list.push(diagnostic2);
|
|
1453
|
+
else byResource.set(key, [diagnostic2]);
|
|
1454
|
+
}
|
|
1455
|
+
return (kind, id) => byResource.get(JSON.stringify([kind, id])) ?? [];
|
|
1420
1456
|
}
|
|
1421
|
-
function nullLocationCode(
|
|
1457
|
+
function nullLocationCode(diagnosticsOf, kind, id) {
|
|
1422
1458
|
const codes = [
|
|
1423
1459
|
...new Set(
|
|
1424
|
-
|
|
1460
|
+
diagnosticsOf(kind, id).map((diagnostic2) => diagnostic2.code).filter((code) => NULL_LOCATION_CODES.has(code))
|
|
1425
1461
|
)
|
|
1426
1462
|
];
|
|
1427
1463
|
if (codes.length > 1) throw new Error(`Head has conflicting placement diagnostics for ${kind}/${id}`);
|
|
1428
1464
|
return codes[0];
|
|
1429
1465
|
}
|
|
1430
|
-
function groupedCause(document, source,
|
|
1466
|
+
function groupedCause(document, source, diagnosticsOf) {
|
|
1431
1467
|
const value = document;
|
|
1432
1468
|
const folder = value.folder;
|
|
1433
1469
|
if (folder === null) {
|
|
1434
|
-
const code = nullLocationCode(
|
|
1470
|
+
const code = nullLocationCode(diagnosticsOf, source.resource.kind, source.resource.id);
|
|
1435
1471
|
return code ? { type: "null-location", code } : void 0;
|
|
1436
1472
|
}
|
|
1437
|
-
if (
|
|
1438
|
-
const folderId =
|
|
1473
|
+
if ((0, import_layoutPaths.itemFolderPath)(folder)) return void 0;
|
|
1474
|
+
const folderId = exactMarker(folder);
|
|
1439
1475
|
if (folderId) return { type: "dangling-folder", folderId };
|
|
1440
1476
|
throw new Error(`Head has an invalid folder location for ${source.resource.kind}/${source.resource.id}`);
|
|
1441
1477
|
}
|
|
1442
1478
|
function folderCause(document, source) {
|
|
1443
1479
|
const value = document;
|
|
1444
|
-
if (
|
|
1480
|
+
if ((0, import_layoutPaths.folderPathSegments)(value.path)) return void 0;
|
|
1445
1481
|
if (value.path !== null)
|
|
1446
1482
|
throw new Error(`Head has an invalid folder path for ${source.resource.kind}/${source.resource.id}`);
|
|
1447
1483
|
if (typeof value.name !== "string")
|
|
1448
1484
|
throw new Error(`Head has an invalid damaged folder name for ${source.resource.kind}/${source.resource.id}`);
|
|
1449
|
-
const parentId =
|
|
1485
|
+
const parentId = exactMarker(value.parent);
|
|
1450
1486
|
if (!parentId)
|
|
1451
1487
|
throw new Error(`Head has an invalid damaged folder parent for ${source.resource.kind}/${source.resource.id}`);
|
|
1452
1488
|
return { type: "dangling-folder-parent", parentId };
|
|
@@ -1460,19 +1496,19 @@ function shareOwner(value) {
|
|
|
1460
1496
|
if (id === void 0 === (dangling === void 0)) throw new Error("Head has an invalid share owner");
|
|
1461
1497
|
return id ? { kind: owner.kind, id } : { kind: owner.kind, dangling };
|
|
1462
1498
|
}
|
|
1463
|
-
function shareCause(document, source,
|
|
1499
|
+
function shareCause(document, source, diagnosticsOf) {
|
|
1464
1500
|
const owner = shareOwner(document.owner);
|
|
1465
|
-
if (
|
|
1466
|
-
const damaged =
|
|
1467
|
-
(diagnostic2) => diagnostic2.
|
|
1501
|
+
if ((0, import_layoutProjection.isMarkerOwner)(owner)) return { type: "damaged-share-owner", owner };
|
|
1502
|
+
const damaged = diagnosticsOf(source.resource.kind, source.resource.id).some(
|
|
1503
|
+
(diagnostic2) => diagnostic2.code === "share-owner-damaged"
|
|
1468
1504
|
);
|
|
1469
1505
|
return damaged ? { type: "damaged-share-owner", owner, code: "share-owner-damaged" } : void 0;
|
|
1470
1506
|
}
|
|
1471
|
-
function causeFor(document, source,
|
|
1507
|
+
function causeFor(document, source, diagnosticsOf) {
|
|
1472
1508
|
if (document.kind === "folder") return folderCause(document, source);
|
|
1473
|
-
if (document.kind === "share") return shareCause(document, source,
|
|
1509
|
+
if (document.kind === "share") return shareCause(document, source, diagnosticsOf);
|
|
1474
1510
|
if (document.kind === "file" || import_layoutCore.TREE_DOCUMENT_KINDS.has(document.kind))
|
|
1475
|
-
return groupedCause(document, source,
|
|
1511
|
+
return groupedCause(document, source, diagnosticsOf);
|
|
1476
1512
|
return void 0;
|
|
1477
1513
|
}
|
|
1478
1514
|
function locationHash(document) {
|
|
@@ -1493,10 +1529,11 @@ function extractAuthoritativeDamageEvidence(head, documents) {
|
|
|
1493
1529
|
for (const hash of Object.values(head.manifest))
|
|
1494
1530
|
if (typeof hash !== "string" || !import_layoutCore.SHA256.test(hash)) throw new Error("Head manifest has an invalid hash");
|
|
1495
1531
|
const evidence = /* @__PURE__ */ new Map();
|
|
1532
|
+
const diagnosticsOf = diagnosticsByResource(head.diagnostics);
|
|
1496
1533
|
for (const [documentKey, document] of documents) {
|
|
1497
1534
|
const source = resourceFromKey(documentKey);
|
|
1498
1535
|
validateRenderedIdentity(document, source);
|
|
1499
|
-
const cause = causeFor(document, source,
|
|
1536
|
+
const cause = causeFor(document, source, diagnosticsOf);
|
|
1500
1537
|
if (!cause) continue;
|
|
1501
1538
|
evidence.set(documentKey, {
|
|
1502
1539
|
documentKey,
|