@agent-teams/engineering-foundation 0.12.0 → 0.13.1
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/dist/cli.js +23 -12
- package/dist/cli.js.map +1 -1
- package/dist/foundation-state-contract.d.ts +7 -0
- package/dist/foundation-state-contract.d.ts.map +1 -0
- package/dist/foundation-state-contract.js +7 -0
- package/dist/foundation-state-contract.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/local-mode/attach-transaction.d.ts.map +1 -1
- package/dist/local-mode/attach-transaction.js +13 -7
- package/dist/local-mode/attach-transaction.js.map +1 -1
- package/dist/local-mode/inspection.d.ts +4 -1
- package/dist/local-mode/inspection.d.ts.map +1 -1
- package/dist/local-mode/inspection.js +20 -0
- package/dist/local-mode/inspection.js.map +1 -1
- package/dist/local-mode/local-state-store.d.ts.map +1 -1
- package/dist/local-mode/local-state-store.js +8 -105
- package/dist/local-mode/local-state-store.js.map +1 -1
- package/dist/local-mode/service.d.ts.map +1 -1
- package/dist/local-mode/service.js +17 -4
- package/dist/local-mode/service.js.map +1 -1
- package/dist/local-mode/types.d.ts +7 -4
- package/dist/local-mode/types.d.ts.map +1 -1
- package/dist/local-mode/types.js +1 -4
- package/dist/local-mode/types.js.map +1 -1
- package/dist/package-version.d.ts +2 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +10 -0
- package/dist/package-version.js.map +1 -0
- package/dist/process-execution/windows-managed-process.d.ts.map +1 -1
- package/dist/process-execution/windows-managed-process.js +1 -0
- package/dist/process-execution/windows-managed-process.js.map +1 -1
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts +31 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.js +272 -0
- package/dist/repository-mutation/adapters/node/node-absent-file-publication.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts +20 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js +123 -0
- package/dist/repository-mutation/adapters/node/node-bounded-regular-file.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts +12 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.js +32 -0
- package/dist/repository-mutation/adapters/node/node-directory-durability.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts +13 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js +67 -0
- package/dist/repository-mutation/adapters/node/node-existing-repository-ancestors.js.map +1 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.d.ts +2 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.d.ts.map +1 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.js +7 -0
- package/dist/repository-mutation/adapters/node/node-repository-path.js.map +1 -0
- package/dist/repository-mutation/application/model/exact-postimage.d.ts +17 -0
- package/dist/repository-mutation/application/model/exact-postimage.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/exact-postimage.js +11 -0
- package/dist/repository-mutation/application/model/exact-postimage.js.map +1 -0
- package/dist/repository-mutation/application/model/path-identity.d.ts +7 -0
- package/dist/repository-mutation/application/model/path-identity.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/path-identity.js +2 -0
- package/dist/repository-mutation/application/model/path-identity.js.map +1 -0
- package/dist/repository-mutation/application/model/repository-path.d.ts +8 -0
- package/dist/repository-mutation/application/model/repository-path.d.ts.map +1 -0
- package/dist/repository-mutation/application/model/repository-path.js +74 -0
- package/dist/repository-mutation/application/model/repository-path.js.map +1 -0
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js +52 -8
- package/dist/scaffolding/adapters/node/filesystem-authority-workspace.js.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts +3 -19
- package/dist/scaffolding/adapters/node/filesystem-file-identity.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-file-identity.js +1 -121
- package/dist/scaffolding/adapters/node/filesystem-file-identity.js.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-journal.d.ts +1 -1
- package/dist/scaffolding/adapters/node/filesystem-journal.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-journal.js +4 -20
- package/dist/scaffolding/adapters/node/filesystem-journal.js.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts +2 -1
- package/dist/scaffolding/adapters/node/filesystem-operation-state.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-operation-state.js +73 -122
- package/dist/scaffolding/adapters/node/filesystem-operation-state.js.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-path-guard.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/filesystem-path-guard.js +27 -68
- package/dist/scaffolding/adapters/node/filesystem-path-guard.js.map +1 -1
- package/dist/scaffolding/adapters/node/installed-foundation-version.d.ts +1 -1
- package/dist/scaffolding/adapters/node/installed-foundation-version.d.ts.map +1 -1
- package/dist/scaffolding/adapters/node/installed-foundation-version.js +1 -9
- package/dist/scaffolding/adapters/node/installed-foundation-version.js.map +1 -1
- package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.d.ts +4 -0
- package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.d.ts.map +1 -0
- package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.js +48 -0
- package/dist/scaffolding/application/policies/legacy-scaffolding-repository-path.js.map +1 -0
- package/dist/scaffolding/kernel/authority-journal-validation.d.ts +4 -0
- package/dist/scaffolding/kernel/authority-journal-validation.d.ts.map +1 -0
- package/dist/scaffolding/kernel/authority-journal-validation.js +24 -0
- package/dist/scaffolding/kernel/authority-journal-validation.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.d.ts +11 -0
- package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.js +130 -0
- package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.d.ts +7 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.js +336 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-operation-lock.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.d.ts +4 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.js +76 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-state-directory.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.d.ts +3 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.js +23 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-coordinator.js.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts +12 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.d.ts.map +1 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js +332 -0
- package/dist/transaction-coordination/adapters/node/node-foundation-transaction-slot.js.map +1 -0
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts +22 -0
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.d.ts.map +1 -0
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js +78 -0
- package/dist/transaction-coordination/application/foundation-transaction-coordinator.js.map +1 -0
- package/dist/transaction-coordination/application/foundation-transaction-error.d.ts +16 -0
- package/dist/transaction-coordination/application/foundation-transaction-error.d.ts.map +1 -0
- package/dist/transaction-coordination/application/foundation-transaction-error.js +19 -0
- package/dist/transaction-coordination/application/foundation-transaction-error.js.map +1 -0
- package/dist/transaction-coordination/application/model/transaction-status.d.ts +47 -0
- package/dist/transaction-coordination/application/model/transaction-status.d.ts.map +1 -0
- package/dist/transaction-coordination/application/model/transaction-status.js +2 -0
- package/dist/transaction-coordination/application/model/transaction-status.js.map +1 -0
- package/dist/transaction-coordination/application/ports/foundation-operation-lock.d.ts +7 -0
- package/dist/transaction-coordination/application/ports/foundation-operation-lock.d.ts.map +1 -0
- package/dist/transaction-coordination/application/ports/foundation-operation-lock.js +2 -0
- package/dist/transaction-coordination/application/ports/foundation-operation-lock.js.map +1 -0
- package/dist/transaction-coordination/application/ports/foundation-transaction-slot.d.ts +5 -0
- package/dist/transaction-coordination/application/ports/foundation-transaction-slot.d.ts.map +1 -0
- package/dist/transaction-coordination/application/ports/foundation-transaction-slot.js +2 -0
- package/dist/transaction-coordination/application/ports/foundation-transaction-slot.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import { lstat, mkdir,
|
|
2
|
-
import {
|
|
1
|
+
import { lstat, mkdir, realpath } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { assertNoPortableNameCollision, assertSafeExistingRepositoryAncestors, ExistingRepositoryAncestorError } from "../../../repository-mutation/adapters/node/node-existing-repository-ancestors.js";
|
|
4
|
+
import { syncDirectoryDurably } from "../../../repository-mutation/adapters/node/node-directory-durability.js";
|
|
5
|
+
import { isLexicallyContainedPath } from "../../../repository-mutation/adapters/node/node-repository-path.js";
|
|
6
|
+
import { legacyScaffoldingRepositoryPathProblem } from "../../application/policies/legacy-scaffolding-repository-path.js";
|
|
3
7
|
import { ScaffoldError } from "../../scaffold-error.js";
|
|
4
8
|
const PROTECTED_ROOTS = new Set([".agent-teams-local", ".git", "node_modules"]);
|
|
5
|
-
const WINDOWS_RESERVED_NAMES = new Set([
|
|
6
|
-
"AUX",
|
|
7
|
-
"CON",
|
|
8
|
-
"NUL",
|
|
9
|
-
"PRN",
|
|
10
|
-
...Array.from({ length: 9 }, (_unused, index) => `COM${index + 1}`),
|
|
11
|
-
...Array.from({ length: 9 }, (_unused, index) => `LPT${index + 1}`)
|
|
12
|
-
]);
|
|
13
9
|
function isMissing(error) {
|
|
14
10
|
return (error instanceof Error &&
|
|
15
11
|
"code" in error &&
|
|
16
12
|
error.code === "ENOENT");
|
|
17
13
|
}
|
|
18
14
|
export function isContainedPath(root, candidate) {
|
|
19
|
-
|
|
20
|
-
return (relation === "" ||
|
|
21
|
-
(!relation.startsWith(`..${sep}`) && relation !== ".." && !isAbsolute(relation)));
|
|
15
|
+
return isLexicallyContainedPath(root, candidate);
|
|
22
16
|
}
|
|
23
17
|
export function assertSafeOperationPaths(plan) {
|
|
24
18
|
const folded = new Map();
|
|
@@ -27,17 +21,7 @@ export function assertSafeOperationPaths(plan) {
|
|
|
27
21
|
for (const operation of plan.operations) {
|
|
28
22
|
const segments = operation.path.split("/");
|
|
29
23
|
if (!operation.path.startsWith(targetPrefix) ||
|
|
30
|
-
operation.path
|
|
31
|
-
operation.path.length > 512 ||
|
|
32
|
-
operation.path.includes("\\") ||
|
|
33
|
-
isAbsolute(operation.path) ||
|
|
34
|
-
segments.some((segment) => segment.length === 0 ||
|
|
35
|
-
segment === "." ||
|
|
36
|
-
segment === ".." ||
|
|
37
|
-
segment.length > 255 ||
|
|
38
|
-
segment.endsWith(".") ||
|
|
39
|
-
Array.from(segment).some((character) => (character.codePointAt(0) ?? 0) < 32) ||
|
|
40
|
-
WINDOWS_RESERVED_NAMES.has((segment.split(".")[0] ?? "").toUpperCase())) ||
|
|
24
|
+
legacyScaffoldingRepositoryPathProblem(operation.path) !== undefined ||
|
|
41
25
|
segments.some((segment) => PROTECTED_ROOTS.has(segment.toLowerCase()))) {
|
|
42
26
|
throw new ScaffoldError("SCAFFOLD_PLAN_INVALID", `Scaffolding operation path is unsafe: ${operation.path}.`);
|
|
43
27
|
}
|
|
@@ -56,35 +40,19 @@ export function assertSafeOperationPaths(plan) {
|
|
|
56
40
|
}
|
|
57
41
|
}
|
|
58
42
|
export async function syncDirectory(path) {
|
|
43
|
+
await syncDirectoryDurably(path);
|
|
44
|
+
}
|
|
45
|
+
async function assertNoCaseCollision(parent, requestedName) {
|
|
59
46
|
try {
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
await handle.sync();
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
await handle.close();
|
|
66
|
-
}
|
|
47
|
+
await assertNoPortableNameCollision(parent, requestedName, (path) => path.toLowerCase(), "filesystem");
|
|
67
48
|
}
|
|
68
49
|
catch (error) {
|
|
69
|
-
if (
|
|
70
|
-
error
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function assertNoCaseCollision(parent, requestedName) {
|
|
79
|
-
const entries = await readdir(parent).catch((error) => {
|
|
80
|
-
if (isMissing(error)) {
|
|
81
|
-
return [];
|
|
50
|
+
if (error instanceof ExistingRepositoryAncestorError &&
|
|
51
|
+
error.problem === "name-collision") {
|
|
52
|
+
const collision = error.existingName ?? "";
|
|
53
|
+
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Path collides under case folding: ${collision}, ${requestedName}.`);
|
|
82
54
|
}
|
|
83
55
|
throw error;
|
|
84
|
-
});
|
|
85
|
-
const collision = entries.find((entry) => entry !== requestedName && entry.toLowerCase() === requestedName.toLowerCase());
|
|
86
|
-
if (collision !== undefined) {
|
|
87
|
-
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Path collides under case folding: ${collision}, ${requestedName}.`);
|
|
88
56
|
}
|
|
89
57
|
}
|
|
90
58
|
export async function ensureSafeParent(root, repositoryPath) {
|
|
@@ -116,29 +84,20 @@ export async function ensureSafeParent(root, repositoryPath) {
|
|
|
116
84
|
return current;
|
|
117
85
|
}
|
|
118
86
|
export async function assertSafeExistingAncestors(root, repositoryPath) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
87
|
+
try {
|
|
88
|
+
await assertSafeExistingRepositoryAncestors(root, repositoryPath, (path) => path.toLowerCase(), "filesystem");
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (error instanceof ExistingRepositoryAncestorError) {
|
|
92
|
+
if (error.problem === "name-collision") {
|
|
93
|
+
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Path collides under case folding: ${error.existingName ?? ""}, ${error.requestedName ?? ""}.`);
|
|
94
|
+
}
|
|
95
|
+
if (error.problem === "not-directory") {
|
|
96
|
+
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Scaffolding parent is not a real directory: ${repositoryPath}.`);
|
|
127
97
|
}
|
|
128
|
-
throw error;
|
|
129
|
-
});
|
|
130
|
-
if (metadata === null) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
134
|
-
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Scaffolding parent is not a real directory: ${repositoryPath}.`);
|
|
135
|
-
}
|
|
136
|
-
const canonical = await realpath(next);
|
|
137
|
-
if (!isContainedPath(root, canonical)) {
|
|
138
98
|
throw new ScaffoldError("SCAFFOLD_APPLY_CONFLICT", `Scaffolding parent escapes the repository: ${repositoryPath}.`);
|
|
139
99
|
}
|
|
140
|
-
|
|
100
|
+
throw error;
|
|
141
101
|
}
|
|
142
|
-
await assertNoCaseCollision(current, segments.at(-1) ?? "");
|
|
143
102
|
}
|
|
144
103
|
//# sourceMappingURL=filesystem-path-guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-path-guard.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-path-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"filesystem-path-guard.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/filesystem-path-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,qCAAqC,EACrC,+BAA+B,EAChC,MAAM,kFAAkF,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yEAAyE,CAAC;AAC/G,OAAO,EAAE,wBAAwB,EAAE,MAAM,oEAAoE,CAAC;AAC9G,OAAO,EAAE,sCAAsC,EAAE,MAAM,kEAAkE,CAAC;AAE1H,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAEhF,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,SAAiB;IAC7D,OAAO,wBAAwB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAkB;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,MAAM,YAAY,G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AC/F,CAAC;YACJ,CAAC;YACD,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;gBACtC,MAAM,IAAI,aAAa,CACrB,yBAAyB,EACzB,+CAA+C,cAAc,GAAG,CACjE,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,aAAa,CACrB,yBAAyB,EACzB,8CAA8C,cAAc,GAAG,CAChE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { installedFoundationVersion } from "../../../package-version.js";
|
|
2
2
|
//# sourceMappingURL=installed-foundation-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed-foundation-version.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/installed-foundation-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"installed-foundation-version.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/installed-foundation-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
export async function installedFoundationVersion() {
|
|
4
|
-
const manifest = JSON.parse(await readFile(fileURLToPath(new URL("../../../../package.json", import.meta.url)), "utf8"));
|
|
5
|
-
if (typeof manifest.version !== "string") {
|
|
6
|
-
throw new Error("Installed Foundation package version is unavailable.");
|
|
7
|
-
}
|
|
8
|
-
return manifest.version;
|
|
9
|
-
}
|
|
1
|
+
export { installedFoundationVersion } from "../../../package-version.js";
|
|
10
2
|
//# sourceMappingURL=installed-foundation-version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed-foundation-version.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/installed-foundation-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"installed-foundation-version.js","sourceRoot":"","sources":["../../../../src/scaffolding/adapters/node/installed-foundation-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PortableRepositoryPathProblem } from "../../../repository-mutation/application/model/repository-path.js";
|
|
2
|
+
/** Preserves the published scaffolding v1 path contract exactly. */
|
|
3
|
+
export declare function legacyScaffoldingRepositoryPathProblem(repositoryPath: string): PortableRepositoryPathProblem | undefined;
|
|
4
|
+
//# sourceMappingURL=legacy-scaffolding-repository-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-scaffolding-repository-path.d.ts","sourceRoot":"","sources":["../../../../src/scaffolding/application/policies/legacy-scaffolding-repository-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mEAAmE,CAAC;AAmBvH,oEAAoE;AACpE,wBAAgB,sCAAsC,CACpD,cAAc,EAAE,MAAM,GACrB,6BAA6B,GAAG,SAAS,CAsC3C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const WINDOWS_RESERVED_NAMES = new Set([
|
|
2
|
+
"AUX",
|
|
3
|
+
"CON",
|
|
4
|
+
"NUL",
|
|
5
|
+
"PRN",
|
|
6
|
+
...Array.from({ length: 9 }, (_unused, index) => `COM${index + 1}`),
|
|
7
|
+
...Array.from({ length: 9 }, (_unused, index) => `LPT${index + 1}`)
|
|
8
|
+
]);
|
|
9
|
+
function isPortableAbsolutePath(repositoryPath) {
|
|
10
|
+
return (repositoryPath.startsWith("/") ||
|
|
11
|
+
repositoryPath.startsWith("\\\\") ||
|
|
12
|
+
/^[A-Za-z]:[\\/]/u.test(repositoryPath));
|
|
13
|
+
}
|
|
14
|
+
/** Preserves the published scaffolding v1 path contract exactly. */
|
|
15
|
+
export function legacyScaffoldingRepositoryPathProblem(repositoryPath) {
|
|
16
|
+
if (repositoryPath.length > 512) {
|
|
17
|
+
return "path-too-long";
|
|
18
|
+
}
|
|
19
|
+
if (isPortableAbsolutePath(repositoryPath)) {
|
|
20
|
+
return "absolute";
|
|
21
|
+
}
|
|
22
|
+
if (repositoryPath.includes("\\")) {
|
|
23
|
+
return "backslash";
|
|
24
|
+
}
|
|
25
|
+
const segments = repositoryPath.split("/");
|
|
26
|
+
for (const segment of segments) {
|
|
27
|
+
if (segment.length === 0) {
|
|
28
|
+
return "empty-segment";
|
|
29
|
+
}
|
|
30
|
+
if (segment === "." || segment === "..") {
|
|
31
|
+
return "invalid-segment";
|
|
32
|
+
}
|
|
33
|
+
if (segment.length > 255) {
|
|
34
|
+
return "segment-too-long";
|
|
35
|
+
}
|
|
36
|
+
if (segment.endsWith(".")) {
|
|
37
|
+
return "trailing-dot";
|
|
38
|
+
}
|
|
39
|
+
if (Array.from(segment).some((character) => (character.codePointAt(0) ?? 0) < 32)) {
|
|
40
|
+
return "control-character";
|
|
41
|
+
}
|
|
42
|
+
if (WINDOWS_RESERVED_NAMES.has((segment.split(".")[0] ?? "").toUpperCase())) {
|
|
43
|
+
return "reserved-name";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=legacy-scaffolding-repository-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-scaffolding-repository-path.js","sourceRoot":"","sources":["../../../../src/scaffolding/application/policies/legacy-scaffolding-repository-path.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,GAAG,CAAC,EAA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,CAAC,OAAO,CAAC,CAAC,IAAI,CACtB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CACpD,EACD,CAAC;YACD,OAAO,mBAAmB,CAAC;QAC7B,CAAC;QACD,IACE,sBAAsB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,EACvE,CAAC;YACD,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AuthorityScaffoldJournal } from "../contract/types.js";
|
|
2
|
+
/** Validates all semantic bindings of a schema-valid v1 recovery journal. */
|
|
3
|
+
export declare function assertAuthorityScaffoldJournal(journal: AuthorityScaffoldJournal): void;
|
|
4
|
+
//# sourceMappingURL=authority-journal-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-journal-validation.d.ts","sourceRoot":"","sources":["../../../src/scaffolding/kernel/authority-journal-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAiCrE,6EAA6E;AAC7E,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAGN"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ScaffoldError } from "../scaffold-error.js";
|
|
2
|
+
import { assertAuthorityScaffoldPlanDigest } from "./plan-validation.js";
|
|
3
|
+
function assertAuthorityJournalOperationBindings(journal) {
|
|
4
|
+
if (journal.operations.length !== journal.plan.operations.length) {
|
|
5
|
+
throw new ScaffoldError("SCAFFOLD_RECOVERY_REQUIRED", "Scaffolding recovery journal operation evidence does not match its Plan.");
|
|
6
|
+
}
|
|
7
|
+
const planOperations = new Map(journal.plan.operations.map((operation) => [operation.id, operation]));
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
for (const operation of journal.operations) {
|
|
10
|
+
const planned = planOperations.get(operation.operationId);
|
|
11
|
+
if (planned === undefined ||
|
|
12
|
+
planned.path !== operation.path ||
|
|
13
|
+
seen.has(operation.operationId)) {
|
|
14
|
+
throw new ScaffoldError("SCAFFOLD_RECOVERY_REQUIRED", "Scaffolding recovery journal operation evidence is invalid.");
|
|
15
|
+
}
|
|
16
|
+
seen.add(operation.operationId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Validates all semantic bindings of a schema-valid v1 recovery journal. */
|
|
20
|
+
export function assertAuthorityScaffoldJournal(journal) {
|
|
21
|
+
assertAuthorityScaffoldPlanDigest(journal.plan);
|
|
22
|
+
assertAuthorityJournalOperationBindings(journal);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=authority-journal-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-journal-validation.js","sourceRoot":"","sources":["../../../src/scaffolding/kernel/authority-journal-validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAEzE,SAAS,uCAAuC,CAC9C,OAAiC;IAEjC,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACjE,MAAM,IAAI,aAAa,CACrB,4BAA4B,EAC5B,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CACtE,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC1D,IACE,OAAO,KAAK,SAAS;YACrB,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI;YAC/B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,EAC/B,CAAC;YACD,MAAM,IAAI,aAAa,CACrB,4BAA4B,EAC5B,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,8BAA8B,CAC5C,OAAiC;IAEjC,iCAAiC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,uCAAuC,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Sha256Digest } from "../../../scaffolding/contract/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Derives an identity from the installed package manifest, executable
|
|
4
|
+
* JavaScript, and every shipped schema/preset contract. Length-prefixed paths and bytes
|
|
5
|
+
* make the digest independent of directory enumeration and installation path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeFoundationBuildIdentity(root: string, limits?: {
|
|
8
|
+
readonly maximumVisitedEntries?: number;
|
|
9
|
+
}): Promise<Sha256Digest>;
|
|
10
|
+
export declare function installedFoundationBuildIdentity(): Promise<Sha256Digest>;
|
|
11
|
+
//# sourceMappingURL=installed-foundation-build-identity.d.ts.map
|
package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installed-foundation-build-identity.d.ts","sourceRoot":"","sources":["../../../../src/transaction-coordination/adapters/node/installed-foundation-build-identity.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AA6H3E;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAAO,GACvD,OAAO,CAAC,YAAY,CAAC,CA2BvB;AAID,wBAAgB,gCAAgC,IAAI,OAAO,CAAC,YAAY,CAAC,CAGxE"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat, opendir } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { readBoundedRegularFile } from "../../../repository-mutation/adapters/node/node-bounded-regular-file.js";
|
|
6
|
+
const maximumBuildFileBytes = 8 * 1024 * 1024;
|
|
7
|
+
const maximumBuildFiles = 4096;
|
|
8
|
+
const maximumBuildBytes = 64 * 1024 * 1024;
|
|
9
|
+
const maximumVisitedBuildEntries = 16_384;
|
|
10
|
+
const maximumBuildTreeDepth = 64;
|
|
11
|
+
const packageRoot = dirname(fileURLToPath(new URL("../../../../package.json", import.meta.url)));
|
|
12
|
+
function comparePortablePaths(left, right) {
|
|
13
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
14
|
+
}
|
|
15
|
+
function portableRelativePath(root, path) {
|
|
16
|
+
return relative(root, path).split(sep).join("/");
|
|
17
|
+
}
|
|
18
|
+
async function collectRegularFiles(root, directory, include, output, budget) {
|
|
19
|
+
if (budget.depth > maximumBuildTreeDepth) {
|
|
20
|
+
throw new Error("Installed Foundation build tree is too deep.");
|
|
21
|
+
}
|
|
22
|
+
const entries = [];
|
|
23
|
+
const handle = await opendir(directory);
|
|
24
|
+
try {
|
|
25
|
+
for await (const entry of handle) {
|
|
26
|
+
budget.visited += 1;
|
|
27
|
+
if (budget.visited > budget.maximumVisited) {
|
|
28
|
+
throw new Error("Installed Foundation build contains too many entries.");
|
|
29
|
+
}
|
|
30
|
+
entries.push(entry);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await handle.close().catch((error) => {
|
|
35
|
+
if (!(error instanceof Error &&
|
|
36
|
+
"code" in error &&
|
|
37
|
+
error.code === "ERR_DIR_CLOSED")) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
entries.sort((left, right) => comparePortablePaths(left.name, right.name));
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
const path = join(directory, entry.name);
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
budget.depth += 1;
|
|
47
|
+
try {
|
|
48
|
+
await collectRegularFiles(root, path, include, output, budget);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
budget.depth -= 1;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!entry.isFile()) {
|
|
56
|
+
throw new Error(`Installed Foundation build contains a non-regular artifact: ${portableRelativePath(root, path)}.`);
|
|
57
|
+
}
|
|
58
|
+
if (include(path)) {
|
|
59
|
+
output.push(path);
|
|
60
|
+
if (output.length > maximumBuildFiles) {
|
|
61
|
+
throw new Error("Installed Foundation build contains too many artifacts.");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function assertRealDirectory(path) {
|
|
67
|
+
const metadata = await lstat(path);
|
|
68
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
69
|
+
throw new Error(`Installed Foundation build directory is unsafe: ${path}.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function buildIdentityFiles(root, maximumVisited) {
|
|
73
|
+
const files = [];
|
|
74
|
+
const budget = { depth: 0, maximumVisited, visited: 0 };
|
|
75
|
+
const distribution = join(root, "dist");
|
|
76
|
+
const schemas = join(root, "schemas");
|
|
77
|
+
const presets = join(root, "presets");
|
|
78
|
+
const manifest = join(root, "package.json");
|
|
79
|
+
await Promise.all([
|
|
80
|
+
assertRealDirectory(distribution),
|
|
81
|
+
assertRealDirectory(schemas),
|
|
82
|
+
assertRealDirectory(presets)
|
|
83
|
+
]);
|
|
84
|
+
await collectRegularFiles(root, distribution, (path) => path.endsWith(".js"), files, budget);
|
|
85
|
+
await collectRegularFiles(root, schemas, () => true, files, budget);
|
|
86
|
+
await collectRegularFiles(root, presets, () => true, files, budget);
|
|
87
|
+
files.push(manifest);
|
|
88
|
+
return files.toSorted((left, right) => comparePortablePaths(portableRelativePath(root, left), portableRelativePath(root, right)));
|
|
89
|
+
}
|
|
90
|
+
function hashLength(hash, length) {
|
|
91
|
+
const encoded = Buffer.allocUnsafe(8);
|
|
92
|
+
encoded.writeBigUInt64BE(BigInt(length));
|
|
93
|
+
hash.update(encoded);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Derives an identity from the installed package manifest, executable
|
|
97
|
+
* JavaScript, and every shipped schema/preset contract. Length-prefixed paths and bytes
|
|
98
|
+
* make the digest independent of directory enumeration and installation path.
|
|
99
|
+
*/
|
|
100
|
+
export async function computeFoundationBuildIdentity(root, limits = {}) {
|
|
101
|
+
const hash = createHash("sha256");
|
|
102
|
+
let totalBytes = 0;
|
|
103
|
+
const maximumVisitedEntries = limits.maximumVisitedEntries ?? maximumVisitedBuildEntries;
|
|
104
|
+
if (!Number.isSafeInteger(maximumVisitedEntries) || maximumVisitedEntries <= 0) {
|
|
105
|
+
throw new TypeError("maximumVisitedEntries must be a positive safe integer.");
|
|
106
|
+
}
|
|
107
|
+
for (const path of await buildIdentityFiles(root, maximumVisitedEntries)) {
|
|
108
|
+
const relativePath = portableRelativePath(root, path);
|
|
109
|
+
const record = await readBoundedRegularFile(path, maximumBuildFileBytes);
|
|
110
|
+
if (record.outcome !== "read") {
|
|
111
|
+
throw new Error(`Installed Foundation build artifact is not a stable bounded regular file: ${relativePath}.`);
|
|
112
|
+
}
|
|
113
|
+
totalBytes += record.bytes.byteLength;
|
|
114
|
+
if (totalBytes > maximumBuildBytes) {
|
|
115
|
+
throw new Error("Installed Foundation build artifacts exceed the byte limit.");
|
|
116
|
+
}
|
|
117
|
+
const pathBytes = Buffer.from(relativePath, "utf8");
|
|
118
|
+
hashLength(hash, pathBytes.byteLength);
|
|
119
|
+
hash.update(pathBytes);
|
|
120
|
+
hashLength(hash, record.bytes.byteLength);
|
|
121
|
+
hash.update(record.bytes);
|
|
122
|
+
}
|
|
123
|
+
return `sha256:${hash.digest("hex")}`;
|
|
124
|
+
}
|
|
125
|
+
let installedBuildIdentity;
|
|
126
|
+
export function installedFoundationBuildIdentity() {
|
|
127
|
+
installedBuildIdentity ??= computeFoundationBuildIdentity(packageRoot);
|
|
128
|
+
return installedBuildIdentity;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=installed-foundation-build-identity.js.map
|
package/dist/transaction-coordination/adapters/node/installed-foundation-build-identity.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installed-foundation-build-identity.js","sourceRoot":"","sources":["../../../../src/transaction-coordination/adapters/node/installed-foundation-build-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yEAAyE,CAAC;AAEjH,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,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AM,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,6EAA6E,YAAY,GAAG,CAC7F,CAAC;QACJ,CAAC;QACD,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QACtC,IAAI,UAAU,GAAG,iBAAiB,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACpD,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACxC,CAAC;AAED,IAAI,sBAAyD,CAAC;AAE9D,MAAM,UAAU,gCAAgC;IAC9C,sBAAsB,KAAK,8BAA8B,CAAC,WAAW,CAAC,CAAC;IACvE,OAAO,sBAAsB,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FoundationOperationLock, FoundationOperationReleaseOptions } from "../../application/ports/foundation-operation-lock.js";
|
|
2
|
+
export declare class NodeFoundationOperationLock implements FoundationOperationLock {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(consumerRoot: string);
|
|
5
|
+
acquire(): Promise<(options?: FoundationOperationReleaseOptions) => Promise<void>>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=node-foundation-operation-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-foundation-operation-lock.d.ts","sourceRoot":"","sources":["../../../../src/transaction-coordination/adapters/node/node-foundation-operation-lock.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,uBAAuB,EACvB,iCAAiC,EAClC,MAAM,sDAAsD,CAAC;AA2X9D,qBAAa,2BAA4B,YAAW,uBAAuB;;IAGzE,YAAY,YAAY,EAAE,MAAM,EAE/B;IAEK,OAAO,IAAI,OAAO,CACtB,CAAC,OAAO,CAAC,EAAE,iCAAiC,KAAK,OAAO,CAAC,IAAI,CAAC,CAC/D,CAqEA;CACF"}
|