@openfairygui/backend 0.2.0-alpha.19 → 0.2.0-alpha.20
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/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.mjs +1 -1
- package/dist/{runtime-B6UjcyIt.d.cts → runtime-B4SwHTRC.d.mts} +4 -2
- package/dist/{runtime-BihiQW-H.d.mts → runtime-BB_3Ws5y.d.cts} +5 -3
- package/dist/{runtime-B017UgBl.mjs → runtime-CqGK_D9A.mjs} +80 -78
- package/dist/{runtime-P0Nhxk2f.cjs → runtime-D3bShb1X.cjs} +80 -78
- package/package.json +5 -4
- package/src/runtime/capabilities.ts +126 -0
- package/src/runtime/contracts.ts +512 -0
- package/src/runtime.ts +41 -630
- package/src/services/authoring-service.ts +14 -66
- package/src/services/session-project-writer.ts +64 -0
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("./runtime-
|
|
2
|
+
const require_runtime = require("./runtime-D3bShb1X.cjs");
|
|
3
3
|
//#region src/storage.ts
|
|
4
4
|
var StorageFileStat = class {
|
|
5
5
|
constructor(kind) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as BACKEND_COMPATIBILITY_POLICY, A as BackendSessionSnapshot, B as ListJobsInput, C as
|
|
1
|
+
import { $ as BACKEND_COMPATIBILITY_POLICY, A as BackendSessionSnapshot, B as ListJobsInput, C as BackendJobNotFoundError, D as BackendProjectSessionStorage, E as BackendJobStatus, F as GetCacheSnapshotInput, G as OpenProjectSessionInput, H as MaterializeSessionSnapshot, I as GetEventsInput, J as SaveSessionInput, K as RefreshCacheInput, L as GetEventsSnapshot, M as CacheRefreshFailedError, N as CancelJobInput, O as BackendResult, P as EventCursorInvalidError, Q as BACKEND_CAPABILITY_SCHEMA_VERSION, R as GetJobInput, S as BackendJobNotCancellableError, T as BackendJobSnapshot, U as MaterializeValidationFailedError, V as MaterializeSessionInput, W as MaterializeWriteFailedError, X as SessionStaleWriteError, Y as SessionNotFoundError, Z as UamFidelityUnsupportedError, _ as BackendHostAdapter, a as BackendCacheEntry, b as BackendJobListSnapshot, c as BackendCapabilityManifest, d as BackendEvent, et as BACKEND_CONTRACT_VERSION, f as BackendEventKind, g as BackendFileSystem, h as BackendFileStat, i as BackendArtifactBridgeCapability, it as BackendStage, j as BackendSuccess, k as BackendRuntimeOptions, l as BackendCapabilityUnavailableError, m as BackendFileHandle, n as AdvisoryLockConflictError, nt as BackendMessage, o as BackendCacheSnapshot, p as BackendFailure, q as SavePartialFailureError, r as ApplySessionTransactionInput, rt as BackendResponseMeta, s as BackendCapabilities, t as BackendRuntime, tt as BackendDiagnostic, u as BackendError, v as BackendJobErrors, w as BackendJobProgress, x as BackendJobListStatusFilter, y as BackendJobKind, z as InProcessLockConflictError } from "./runtime-BB_3Ws5y.cjs";
|
|
2
2
|
import { FileSystem } from "@openfairygui/core/project-io";
|
|
3
3
|
|
|
4
4
|
//#region src/storage.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as BACKEND_COMPATIBILITY_POLICY, A as BackendSessionSnapshot, B as ListJobsInput, C as
|
|
1
|
+
import { $ as BACKEND_COMPATIBILITY_POLICY, A as BackendSessionSnapshot, B as ListJobsInput, C as BackendJobNotFoundError, D as BackendProjectSessionStorage, E as BackendJobStatus, F as GetCacheSnapshotInput, G as OpenProjectSessionInput, H as MaterializeSessionSnapshot, I as GetEventsInput, J as SaveSessionInput, K as RefreshCacheInput, L as GetEventsSnapshot, M as CacheRefreshFailedError, N as CancelJobInput, O as BackendResult, P as EventCursorInvalidError, Q as BACKEND_CAPABILITY_SCHEMA_VERSION, R as GetJobInput, S as BackendJobNotCancellableError, T as BackendJobSnapshot, U as MaterializeValidationFailedError, V as MaterializeSessionInput, W as MaterializeWriteFailedError, X as SessionStaleWriteError, Y as SessionNotFoundError, Z as UamFidelityUnsupportedError, _ as BackendHostAdapter, a as BackendCacheEntry, b as BackendJobListSnapshot, c as BackendCapabilityManifest, d as BackendEvent, et as BACKEND_CONTRACT_VERSION, f as BackendEventKind, g as BackendFileSystem, h as BackendFileStat, i as BackendArtifactBridgeCapability, it as BackendStage, j as BackendSuccess, k as BackendRuntimeOptions, l as BackendCapabilityUnavailableError, m as BackendFileHandle, n as AdvisoryLockConflictError, nt as BackendMessage, o as BackendCacheSnapshot, p as BackendFailure, q as SavePartialFailureError, r as ApplySessionTransactionInput, rt as BackendResponseMeta, s as BackendCapabilities, t as BackendRuntime, tt as BackendDiagnostic, u as BackendError, v as BackendJobErrors, w as BackendJobProgress, x as BackendJobListStatusFilter, y as BackendJobKind, z as InProcessLockConflictError } from "./runtime-B4SwHTRC.mjs";
|
|
2
2
|
import { FileSystem } from "@openfairygui/core/project-io";
|
|
3
3
|
|
|
4
4
|
//#region src/storage.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as BACKEND_CONTRACT_VERSION, n as BACKEND_CAPABILITY_SCHEMA_VERSION, r as BACKEND_COMPATIBILITY_POLICY, t as BackendRuntime } from "./runtime-
|
|
1
|
+
import { i as BACKEND_CONTRACT_VERSION, n as BACKEND_CAPABILITY_SCHEMA_VERSION, r as BACKEND_COMPATIBILITY_POLICY, t as BackendRuntime } from "./runtime-CqGK_D9A.mjs";
|
|
2
2
|
//#region src/storage.ts
|
|
3
3
|
var StorageFileStat = class {
|
|
4
4
|
constructor(kind) {
|
package/dist/node.cjs
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_runtime = require("./runtime-
|
|
24
|
+
const require_runtime = require("./runtime-D3bShb1X.cjs");
|
|
25
25
|
let node_fs_promises = require("node:fs/promises");
|
|
26
26
|
node_fs_promises = __toESM(node_fs_promises);
|
|
27
27
|
let node_path = require("node:path");
|
package/dist/node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as BackendHostAdapter, g as BackendFileSystem, h as BackendFileStat, k as BackendRuntimeOptions, m as BackendFileHandle, t as BackendRuntime } from "./runtime-BB_3Ws5y.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/node.d.ts
|
|
4
4
|
declare function createNodeBackendFileSystem(): BackendFileSystem;
|
package/dist/node.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as BackendHostAdapter, g as BackendFileSystem, h as BackendFileStat, k as BackendRuntimeOptions, m as BackendFileHandle, t as BackendRuntime } from "./runtime-B4SwHTRC.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/node.d.ts
|
|
4
4
|
declare function createNodeBackendFileSystem(): BackendFileSystem;
|
package/dist/node.mjs
CHANGED
|
@@ -48,7 +48,7 @@ interface PathPolicyViolationError {
|
|
|
48
48
|
allowedPath: string;
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region src/runtime.d.ts
|
|
51
|
+
//#region src/runtime/contracts.d.ts
|
|
52
52
|
interface BackendFileHandle {
|
|
53
53
|
writeFile(content: string): Promise<void>;
|
|
54
54
|
close(): Promise<void>;
|
|
@@ -456,6 +456,8 @@ interface BackendRuntimeOptions {
|
|
|
456
456
|
fileSystem?: BackendFileSystem;
|
|
457
457
|
host?: BackendHostAdapter;
|
|
458
458
|
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/runtime.d.ts
|
|
459
461
|
declare class BackendRuntime {
|
|
460
462
|
private readonly fileSystem?;
|
|
461
463
|
private readonly capabilities;
|
|
@@ -498,4 +500,4 @@ declare class BackendRuntime {
|
|
|
498
500
|
refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
|
|
499
501
|
}
|
|
500
502
|
//#endregion
|
|
501
|
-
export { BACKEND_COMPATIBILITY_POLICY as $, BackendSessionSnapshot as A, ListJobsInput as B,
|
|
503
|
+
export { BACKEND_COMPATIBILITY_POLICY as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobNotFoundError as C, BackendProjectSessionStorage as D, BackendJobStatus as E, GetCacheSnapshotInput as F, OpenProjectSessionInput as G, MaterializeSessionSnapshot as H, GetEventsInput as I, SaveSessionInput as J, RefreshCacheInput as K, GetEventsSnapshot as L, CacheRefreshFailedError as M, CancelJobInput as N, BackendResult as O, EventCursorInvalidError as P, BACKEND_CAPABILITY_SCHEMA_VERSION as Q, GetJobInput as R, BackendJobNotCancellableError as S, BackendJobSnapshot as T, MaterializeValidationFailedError as U, MaterializeSessionInput as V, MaterializeWriteFailedError as W, SessionStaleWriteError as X, SessionNotFoundError as Y, UamFidelityUnsupportedError as Z, BackendHostAdapter as _, BackendCacheEntry as a, BackendJobListSnapshot as b, BackendCapabilityManifest as c, BackendEvent as d, BACKEND_CONTRACT_VERSION as et, BackendEventKind as f, BackendFileSystem as g, BackendFileStat as h, BackendArtifactBridgeCapability as i, BackendStage as it, BackendSuccess as j, BackendRuntimeOptions as k, BackendCapabilityUnavailableError as l, BackendFileHandle as m, AdvisoryLockConflictError as n, BackendMessage as nt, BackendCacheSnapshot as o, BackendFailure as p, SavePartialFailureError as q, ApplySessionTransactionInput as r, BackendResponseMeta as rt, BackendCapabilities as s, BackendRuntime as t, BackendDiagnostic as tt, BackendError as u, BackendJobErrors as v, BackendJobProgress as w, BackendJobListStatusFilter as x, BackendJobKind as y, InProcessLockConflictError as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UamProject, UamTransactionOperation } from "@openfairygui/core/uam";
|
|
2
1
|
import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
|
|
2
|
+
import { UamProject, UamTransactionOperation } from "@openfairygui/core/uam";
|
|
3
3
|
|
|
4
4
|
//#region src/contracts.d.ts
|
|
5
5
|
declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
|
|
@@ -48,7 +48,7 @@ interface PathPolicyViolationError {
|
|
|
48
48
|
allowedPath: string;
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region src/runtime.d.ts
|
|
51
|
+
//#region src/runtime/contracts.d.ts
|
|
52
52
|
interface BackendFileHandle {
|
|
53
53
|
writeFile(content: string): Promise<void>;
|
|
54
54
|
close(): Promise<void>;
|
|
@@ -456,6 +456,8 @@ interface BackendRuntimeOptions {
|
|
|
456
456
|
fileSystem?: BackendFileSystem;
|
|
457
457
|
host?: BackendHostAdapter;
|
|
458
458
|
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/runtime.d.ts
|
|
459
461
|
declare class BackendRuntime {
|
|
460
462
|
private readonly fileSystem?;
|
|
461
463
|
private readonly capabilities;
|
|
@@ -498,4 +500,4 @@ declare class BackendRuntime {
|
|
|
498
500
|
refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
|
|
499
501
|
}
|
|
500
502
|
//#endregion
|
|
501
|
-
export { BACKEND_COMPATIBILITY_POLICY as $, BackendSessionSnapshot as A, ListJobsInput as B,
|
|
503
|
+
export { BACKEND_COMPATIBILITY_POLICY as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobNotFoundError as C, BackendProjectSessionStorage as D, BackendJobStatus as E, GetCacheSnapshotInput as F, OpenProjectSessionInput as G, MaterializeSessionSnapshot as H, GetEventsInput as I, SaveSessionInput as J, RefreshCacheInput as K, GetEventsSnapshot as L, CacheRefreshFailedError as M, CancelJobInput as N, BackendResult as O, EventCursorInvalidError as P, BACKEND_CAPABILITY_SCHEMA_VERSION as Q, GetJobInput as R, BackendJobNotCancellableError as S, BackendJobSnapshot as T, MaterializeValidationFailedError as U, MaterializeSessionInput as V, MaterializeWriteFailedError as W, SessionStaleWriteError as X, SessionNotFoundError as Y, UamFidelityUnsupportedError as Z, BackendHostAdapter as _, BackendCacheEntry as a, BackendJobListSnapshot as b, BackendCapabilityManifest as c, BackendEvent as d, BACKEND_CONTRACT_VERSION as et, BackendEventKind as f, BackendFileSystem as g, BackendFileStat as h, BackendArtifactBridgeCapability as i, BackendStage as it, BackendSuccess as j, BackendRuntimeOptions as k, BackendCapabilityUnavailableError as l, BackendFileHandle as m, AdvisoryLockConflictError as n, BackendMessage as nt, BackendCacheSnapshot as o, BackendFailure as p, SavePartialFailureError as q, ApplySessionTransactionInput as r, BackendResponseMeta as rt, BackendCapabilities as s, BackendRuntime as t, BackendDiagnostic as tt, BackendError as u, BackendJobErrors as v, BackendJobProgress as w, BackendJobListStatusFilter as x, BackendJobKind as y, InProcessLockConflictError as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UAM_SUPPORTED_MATERIALIZATION_SCOPE, UAM_SUPPORTED_TRANSACTION_SCOPE, commitUamProjectSourcePaths, liftDocumentToUamProject, materializeUamProject, normalizeUamProject, validateUamProject } from "@openfairygui/core/uam";
|
|
2
|
-
import { ProjectReader, ProjectWriter } from "@openfairygui/core/project-io";
|
|
3
2
|
import { applyUamTransactionApp } from "@openfairygui/functions/uam";
|
|
3
|
+
import { ProjectReader, ProjectWriter } from "@openfairygui/core/project-io";
|
|
4
4
|
//#region src/contracts.ts
|
|
5
5
|
const BACKEND_CONTRACT_VERSION = "1.1.0-p2";
|
|
6
6
|
const BACKEND_CAPABILITY_SCHEMA_VERSION = 2;
|
|
@@ -75,24 +75,6 @@ async function validateSaveTarget(fileSystem, openedFairyPath, targetPath) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region src/services/artifact-service.ts
|
|
79
|
-
function createArtifactCapabilities() {
|
|
80
|
-
const bridge = {
|
|
81
|
-
available: false,
|
|
82
|
-
requiredHost: "node",
|
|
83
|
-
executionBoundary: "external-bridge",
|
|
84
|
-
bridgeEntrypoint: "@openfairygui/backend/node",
|
|
85
|
-
reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
|
|
86
|
-
};
|
|
87
|
-
return {
|
|
88
|
-
publish: false,
|
|
89
|
-
restore: false,
|
|
90
|
-
status: "bridge-required",
|
|
91
|
-
publishBridge: bridge,
|
|
92
|
-
restoreBridge: bridge
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
78
|
//#region src/services/context.ts
|
|
97
79
|
function diagnosticFromError(error) {
|
|
98
80
|
return {
|
|
@@ -137,6 +119,48 @@ function failure(stage, startedAt, error, session, options) {
|
|
|
137
119
|
};
|
|
138
120
|
}
|
|
139
121
|
//#endregion
|
|
122
|
+
//#region src/services/session-project-writer.ts
|
|
123
|
+
function createWriterFileSystem(fileSystem, writtenPaths, failedPaths) {
|
|
124
|
+
async function trackWrite(targetPath, write) {
|
|
125
|
+
try {
|
|
126
|
+
const result = await write();
|
|
127
|
+
writtenPaths.push(targetPath);
|
|
128
|
+
return result;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
failedPaths.push(targetPath);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
readFile: (path) => fileSystem.readFile(path),
|
|
136
|
+
readFileRaw: (path) => fileSystem.readFileRaw(path),
|
|
137
|
+
writeFile: (path, content) => trackWrite(path, async () => {
|
|
138
|
+
await fileSystem.mkdir(fileSystem.dirname(path), { recursive: true });
|
|
139
|
+
await fileSystem.writeFile(path, content);
|
|
140
|
+
}),
|
|
141
|
+
writeFileRaw: (path, data) => trackWrite(path, async () => {
|
|
142
|
+
await fileSystem.mkdir(fileSystem.dirname(path), { recursive: true });
|
|
143
|
+
await fileSystem.writeFileRaw(path, data);
|
|
144
|
+
}),
|
|
145
|
+
mkdir: (path) => fileSystem.mkdir(path, { recursive: true }),
|
|
146
|
+
readdir: (path) => fileSystem.readdir(path),
|
|
147
|
+
async exists(path) {
|
|
148
|
+
try {
|
|
149
|
+
await fileSystem.stat(path);
|
|
150
|
+
return true;
|
|
151
|
+
} catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
join: (...paths) => fileSystem.join(...paths),
|
|
156
|
+
dirname: (path) => fileSystem.dirname(path),
|
|
157
|
+
unlink: (path) => trackWrite(path, () => fileSystem.unlink(path))
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function writeSessionProject(input) {
|
|
161
|
+
await new ProjectWriter(createWriterFileSystem(input.fileSystem, input.writtenPaths, input.failedPaths)).write(input.document, input.fairyPath, { staleSourceFiles: input.staleSourceFiles });
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
140
164
|
//#region src/services/snapshot-utils.ts
|
|
141
165
|
function cloneJsonValue(value) {
|
|
142
166
|
if (value === void 0 || value === null) return value;
|
|
@@ -203,61 +227,6 @@ function createStaleWriteError(session, expectedRevision) {
|
|
|
203
227
|
}
|
|
204
228
|
//#endregion
|
|
205
229
|
//#region src/services/authoring-service.ts
|
|
206
|
-
function createWriterFileSystem(fileSystem, committedPaths, failedPaths) {
|
|
207
|
-
async function trackWrite(targetPath, fn) {
|
|
208
|
-
try {
|
|
209
|
-
const result = await fn();
|
|
210
|
-
committedPaths.push(targetPath);
|
|
211
|
-
return result;
|
|
212
|
-
} catch (error) {
|
|
213
|
-
failedPaths.push(targetPath);
|
|
214
|
-
throw error;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
async readFile(filePath) {
|
|
219
|
-
return fileSystem.readFile(filePath);
|
|
220
|
-
},
|
|
221
|
-
async readFileRaw(filePath) {
|
|
222
|
-
return fileSystem.readFileRaw(filePath);
|
|
223
|
-
},
|
|
224
|
-
async writeFile(filePath, content) {
|
|
225
|
-
await trackWrite(filePath, async () => {
|
|
226
|
-
await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
|
|
227
|
-
await fileSystem.writeFile(filePath, content);
|
|
228
|
-
});
|
|
229
|
-
},
|
|
230
|
-
async writeFileRaw(filePath, data) {
|
|
231
|
-
await trackWrite(filePath, async () => {
|
|
232
|
-
await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
|
|
233
|
-
await fileSystem.writeFileRaw(filePath, data);
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
async mkdir(dirPath) {
|
|
237
|
-
await fileSystem.mkdir(dirPath, { recursive: true });
|
|
238
|
-
},
|
|
239
|
-
async readdir(dirPath) {
|
|
240
|
-
return fileSystem.readdir(dirPath);
|
|
241
|
-
},
|
|
242
|
-
async exists(filePath) {
|
|
243
|
-
try {
|
|
244
|
-
await fileSystem.stat(filePath);
|
|
245
|
-
return true;
|
|
246
|
-
} catch {
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
join(...paths) {
|
|
251
|
-
return fileSystem.join(...paths);
|
|
252
|
-
},
|
|
253
|
-
dirname(filePath) {
|
|
254
|
-
return fileSystem.dirname(filePath);
|
|
255
|
-
},
|
|
256
|
-
async unlink(filePath) {
|
|
257
|
-
await trackWrite(filePath, () => fileSystem.unlink(filePath));
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
230
|
function projectSourceFiles(project) {
|
|
262
231
|
const result = /* @__PURE__ */ new Map();
|
|
263
232
|
for (const pkg of project.packages) {
|
|
@@ -492,7 +461,14 @@ var AuthoringService = class {
|
|
|
492
461
|
revision: session.revision
|
|
493
462
|
});
|
|
494
463
|
try {
|
|
495
|
-
await
|
|
464
|
+
await writeSessionProject({
|
|
465
|
+
fileSystem,
|
|
466
|
+
document: materializeUamProject(session.project),
|
|
467
|
+
fairyPath: session.fairyPath,
|
|
468
|
+
staleSourceFiles: [...session.pendingStaleSourceFiles.values()],
|
|
469
|
+
writtenPaths: committedPaths,
|
|
470
|
+
failedPaths
|
|
471
|
+
});
|
|
496
472
|
session.fileSystem ??= fileSystem;
|
|
497
473
|
session.pendingStaleSourceFiles.clear();
|
|
498
474
|
commitUamProjectSourcePaths(session.project);
|
|
@@ -626,9 +602,15 @@ var AuthoringService = class {
|
|
|
626
602
|
revision: session.revision
|
|
627
603
|
});
|
|
628
604
|
try {
|
|
629
|
-
const writer = new ProjectWriter(createWriterFileSystem(fileSystem, writtenPaths, failedPaths));
|
|
630
605
|
const isSessionStorageTarget = fileSystem === session.fileSystem && fairyPath === session.fairyPath;
|
|
631
|
-
await
|
|
606
|
+
await writeSessionProject({
|
|
607
|
+
fileSystem,
|
|
608
|
+
document,
|
|
609
|
+
fairyPath,
|
|
610
|
+
staleSourceFiles: isSessionStorageTarget ? [...session.pendingStaleSourceFiles.values()] : [],
|
|
611
|
+
writtenPaths,
|
|
612
|
+
failedPaths
|
|
613
|
+
});
|
|
632
614
|
if (isSessionStorageTarget) session.pendingStaleSourceFiles.clear();
|
|
633
615
|
if (storageTarget && !isSessionStorageTarget) session.pendingStaleSourceFiles.clear();
|
|
634
616
|
if (isSessionStorageTarget || storageTarget) commitUamProjectSourcePaths(session.project);
|
|
@@ -1380,7 +1362,25 @@ var RuntimeService = class {
|
|
|
1380
1362
|
}
|
|
1381
1363
|
};
|
|
1382
1364
|
//#endregion
|
|
1383
|
-
//#region src/
|
|
1365
|
+
//#region src/services/artifact-service.ts
|
|
1366
|
+
function createArtifactCapabilities() {
|
|
1367
|
+
const bridge = {
|
|
1368
|
+
available: false,
|
|
1369
|
+
requiredHost: "node",
|
|
1370
|
+
executionBoundary: "external-bridge",
|
|
1371
|
+
bridgeEntrypoint: "@openfairygui/backend/node",
|
|
1372
|
+
reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
|
|
1373
|
+
};
|
|
1374
|
+
return {
|
|
1375
|
+
publish: false,
|
|
1376
|
+
restore: false,
|
|
1377
|
+
status: "bridge-required",
|
|
1378
|
+
publishBridge: bridge,
|
|
1379
|
+
restoreBridge: bridge
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
//#endregion
|
|
1383
|
+
//#region src/runtime/capabilities.ts
|
|
1384
1384
|
const BACKEND_METHODS = [
|
|
1385
1385
|
"getCapabilities",
|
|
1386
1386
|
"openSession",
|
|
@@ -1500,6 +1500,8 @@ function createCapabilities() {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
};
|
|
1502
1502
|
}
|
|
1503
|
+
//#endregion
|
|
1504
|
+
//#region src/runtime.ts
|
|
1503
1505
|
var BackendRuntime = class {
|
|
1504
1506
|
fileSystem;
|
|
1505
1507
|
capabilities;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./node.cjs");
|
|
2
2
|
let _openfairygui_core_uam = require("@openfairygui/core/uam");
|
|
3
|
-
let _openfairygui_core_project_io = require("@openfairygui/core/project-io");
|
|
4
3
|
let _openfairygui_functions_uam = require("@openfairygui/functions/uam");
|
|
4
|
+
let _openfairygui_core_project_io = require("@openfairygui/core/project-io");
|
|
5
5
|
//#region src/contracts.ts
|
|
6
6
|
const BACKEND_CONTRACT_VERSION = "1.1.0-p2";
|
|
7
7
|
const BACKEND_CAPABILITY_SCHEMA_VERSION = 2;
|
|
@@ -76,24 +76,6 @@ async function validateSaveTarget(fileSystem, openedFairyPath, targetPath) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
|
-
//#region src/services/artifact-service.ts
|
|
80
|
-
function createArtifactCapabilities() {
|
|
81
|
-
const bridge = {
|
|
82
|
-
available: false,
|
|
83
|
-
requiredHost: "node",
|
|
84
|
-
executionBoundary: "external-bridge",
|
|
85
|
-
bridgeEntrypoint: "@openfairygui/backend/node",
|
|
86
|
-
reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
publish: false,
|
|
90
|
-
restore: false,
|
|
91
|
-
status: "bridge-required",
|
|
92
|
-
publishBridge: bridge,
|
|
93
|
-
restoreBridge: bridge
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
97
79
|
//#region src/services/context.ts
|
|
98
80
|
function diagnosticFromError(error) {
|
|
99
81
|
return {
|
|
@@ -138,6 +120,48 @@ function failure(stage, startedAt, error, session, options) {
|
|
|
138
120
|
};
|
|
139
121
|
}
|
|
140
122
|
//#endregion
|
|
123
|
+
//#region src/services/session-project-writer.ts
|
|
124
|
+
function createWriterFileSystem(fileSystem, writtenPaths, failedPaths) {
|
|
125
|
+
async function trackWrite(targetPath, write) {
|
|
126
|
+
try {
|
|
127
|
+
const result = await write();
|
|
128
|
+
writtenPaths.push(targetPath);
|
|
129
|
+
return result;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
failedPaths.push(targetPath);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
readFile: (path) => fileSystem.readFile(path),
|
|
137
|
+
readFileRaw: (path) => fileSystem.readFileRaw(path),
|
|
138
|
+
writeFile: (path, content) => trackWrite(path, async () => {
|
|
139
|
+
await fileSystem.mkdir(fileSystem.dirname(path), { recursive: true });
|
|
140
|
+
await fileSystem.writeFile(path, content);
|
|
141
|
+
}),
|
|
142
|
+
writeFileRaw: (path, data) => trackWrite(path, async () => {
|
|
143
|
+
await fileSystem.mkdir(fileSystem.dirname(path), { recursive: true });
|
|
144
|
+
await fileSystem.writeFileRaw(path, data);
|
|
145
|
+
}),
|
|
146
|
+
mkdir: (path) => fileSystem.mkdir(path, { recursive: true }),
|
|
147
|
+
readdir: (path) => fileSystem.readdir(path),
|
|
148
|
+
async exists(path) {
|
|
149
|
+
try {
|
|
150
|
+
await fileSystem.stat(path);
|
|
151
|
+
return true;
|
|
152
|
+
} catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
join: (...paths) => fileSystem.join(...paths),
|
|
157
|
+
dirname: (path) => fileSystem.dirname(path),
|
|
158
|
+
unlink: (path) => trackWrite(path, () => fileSystem.unlink(path))
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
async function writeSessionProject(input) {
|
|
162
|
+
await new _openfairygui_core_project_io.ProjectWriter(createWriterFileSystem(input.fileSystem, input.writtenPaths, input.failedPaths)).write(input.document, input.fairyPath, { staleSourceFiles: input.staleSourceFiles });
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
141
165
|
//#region src/services/snapshot-utils.ts
|
|
142
166
|
function cloneJsonValue(value) {
|
|
143
167
|
if (value === void 0 || value === null) return value;
|
|
@@ -204,61 +228,6 @@ function createStaleWriteError(session, expectedRevision) {
|
|
|
204
228
|
}
|
|
205
229
|
//#endregion
|
|
206
230
|
//#region src/services/authoring-service.ts
|
|
207
|
-
function createWriterFileSystem(fileSystem, committedPaths, failedPaths) {
|
|
208
|
-
async function trackWrite(targetPath, fn) {
|
|
209
|
-
try {
|
|
210
|
-
const result = await fn();
|
|
211
|
-
committedPaths.push(targetPath);
|
|
212
|
-
return result;
|
|
213
|
-
} catch (error) {
|
|
214
|
-
failedPaths.push(targetPath);
|
|
215
|
-
throw error;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return {
|
|
219
|
-
async readFile(filePath) {
|
|
220
|
-
return fileSystem.readFile(filePath);
|
|
221
|
-
},
|
|
222
|
-
async readFileRaw(filePath) {
|
|
223
|
-
return fileSystem.readFileRaw(filePath);
|
|
224
|
-
},
|
|
225
|
-
async writeFile(filePath, content) {
|
|
226
|
-
await trackWrite(filePath, async () => {
|
|
227
|
-
await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
|
|
228
|
-
await fileSystem.writeFile(filePath, content);
|
|
229
|
-
});
|
|
230
|
-
},
|
|
231
|
-
async writeFileRaw(filePath, data) {
|
|
232
|
-
await trackWrite(filePath, async () => {
|
|
233
|
-
await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
|
|
234
|
-
await fileSystem.writeFileRaw(filePath, data);
|
|
235
|
-
});
|
|
236
|
-
},
|
|
237
|
-
async mkdir(dirPath) {
|
|
238
|
-
await fileSystem.mkdir(dirPath, { recursive: true });
|
|
239
|
-
},
|
|
240
|
-
async readdir(dirPath) {
|
|
241
|
-
return fileSystem.readdir(dirPath);
|
|
242
|
-
},
|
|
243
|
-
async exists(filePath) {
|
|
244
|
-
try {
|
|
245
|
-
await fileSystem.stat(filePath);
|
|
246
|
-
return true;
|
|
247
|
-
} catch {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
join(...paths) {
|
|
252
|
-
return fileSystem.join(...paths);
|
|
253
|
-
},
|
|
254
|
-
dirname(filePath) {
|
|
255
|
-
return fileSystem.dirname(filePath);
|
|
256
|
-
},
|
|
257
|
-
async unlink(filePath) {
|
|
258
|
-
await trackWrite(filePath, () => fileSystem.unlink(filePath));
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
231
|
function projectSourceFiles(project) {
|
|
263
232
|
const result = /* @__PURE__ */ new Map();
|
|
264
233
|
for (const pkg of project.packages) {
|
|
@@ -493,7 +462,14 @@ var AuthoringService = class {
|
|
|
493
462
|
revision: session.revision
|
|
494
463
|
});
|
|
495
464
|
try {
|
|
496
|
-
await
|
|
465
|
+
await writeSessionProject({
|
|
466
|
+
fileSystem,
|
|
467
|
+
document: (0, _openfairygui_core_uam.materializeUamProject)(session.project),
|
|
468
|
+
fairyPath: session.fairyPath,
|
|
469
|
+
staleSourceFiles: [...session.pendingStaleSourceFiles.values()],
|
|
470
|
+
writtenPaths: committedPaths,
|
|
471
|
+
failedPaths
|
|
472
|
+
});
|
|
497
473
|
session.fileSystem ??= fileSystem;
|
|
498
474
|
session.pendingStaleSourceFiles.clear();
|
|
499
475
|
(0, _openfairygui_core_uam.commitUamProjectSourcePaths)(session.project);
|
|
@@ -627,9 +603,15 @@ var AuthoringService = class {
|
|
|
627
603
|
revision: session.revision
|
|
628
604
|
});
|
|
629
605
|
try {
|
|
630
|
-
const writer = new _openfairygui_core_project_io.ProjectWriter(createWriterFileSystem(fileSystem, writtenPaths, failedPaths));
|
|
631
606
|
const isSessionStorageTarget = fileSystem === session.fileSystem && fairyPath === session.fairyPath;
|
|
632
|
-
await
|
|
607
|
+
await writeSessionProject({
|
|
608
|
+
fileSystem,
|
|
609
|
+
document,
|
|
610
|
+
fairyPath,
|
|
611
|
+
staleSourceFiles: isSessionStorageTarget ? [...session.pendingStaleSourceFiles.values()] : [],
|
|
612
|
+
writtenPaths,
|
|
613
|
+
failedPaths
|
|
614
|
+
});
|
|
633
615
|
if (isSessionStorageTarget) session.pendingStaleSourceFiles.clear();
|
|
634
616
|
if (storageTarget && !isSessionStorageTarget) session.pendingStaleSourceFiles.clear();
|
|
635
617
|
if (isSessionStorageTarget || storageTarget) (0, _openfairygui_core_uam.commitUamProjectSourcePaths)(session.project);
|
|
@@ -1381,7 +1363,25 @@ var RuntimeService = class {
|
|
|
1381
1363
|
}
|
|
1382
1364
|
};
|
|
1383
1365
|
//#endregion
|
|
1384
|
-
//#region src/
|
|
1366
|
+
//#region src/services/artifact-service.ts
|
|
1367
|
+
function createArtifactCapabilities() {
|
|
1368
|
+
const bridge = {
|
|
1369
|
+
available: false,
|
|
1370
|
+
requiredHost: "node",
|
|
1371
|
+
executionBoundary: "external-bridge",
|
|
1372
|
+
bridgeEntrypoint: "@openfairygui/backend/node",
|
|
1373
|
+
reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
|
|
1374
|
+
};
|
|
1375
|
+
return {
|
|
1376
|
+
publish: false,
|
|
1377
|
+
restore: false,
|
|
1378
|
+
status: "bridge-required",
|
|
1379
|
+
publishBridge: bridge,
|
|
1380
|
+
restoreBridge: bridge
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
//#endregion
|
|
1384
|
+
//#region src/runtime/capabilities.ts
|
|
1385
1385
|
const BACKEND_METHODS = [
|
|
1386
1386
|
"getCapabilities",
|
|
1387
1387
|
"openSession",
|
|
@@ -1501,6 +1501,8 @@ function createCapabilities() {
|
|
|
1501
1501
|
}
|
|
1502
1502
|
};
|
|
1503
1503
|
}
|
|
1504
|
+
//#endregion
|
|
1505
|
+
//#region src/runtime.ts
|
|
1504
1506
|
var BackendRuntime = class {
|
|
1505
1507
|
fileSystem;
|
|
1506
1508
|
capabilities;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfairygui/backend",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.20",
|
|
4
4
|
"description": "FairyGUI Headless Authoring SDK — stateful backend runtime and session services.",
|
|
5
5
|
"author": "OpenFairyGUI Contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,12 +52,13 @@
|
|
|
52
52
|
"runtime"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@openfairygui/core": "0.2.0-alpha.
|
|
56
|
-
"@openfairygui/functions": "0.2.0-alpha.
|
|
55
|
+
"@openfairygui/core": "0.2.0-alpha.20",
|
|
56
|
+
"@openfairygui/functions": "0.2.0-alpha.20"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"ava": "^7.0.0",
|
|
60
|
-
"tsx": "^4.0.0"
|
|
60
|
+
"tsx": "^4.0.0",
|
|
61
|
+
"@openfairygui/test-utils": "0.2.0-alpha.10"
|
|
61
62
|
},
|
|
62
63
|
"scripts": {
|
|
63
64
|
"build": "tsdown src/index.ts src/node.ts --format esm,cjs --platform node --external node:fs --external node:fs/promises --external node:path --env.PACKAGE_VERSION=$npm_package_version",
|