@openfairygui/backend 0.2.0-alpha.3 → 0.2.0-alpha.30
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 +48 -2
- package/dist/index.cjs +150 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.mts +34 -2
- package/dist/index.mjs +150 -2
- package/dist/node.cjs +4 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.mjs +4 -1
- package/dist/{runtime-IrXqqmko.d.cts → runtime-BQOEw22M.d.mts} +85 -10
- package/dist/{runtime-jKuQmcqM.cjs → runtime-CcBLI-J7.cjs} +523 -86
- package/dist/{runtime-BG5qOVkJ.mjs → runtime-NiBgr7PF.mjs} +524 -87
- package/dist/{runtime-u1Bq_ysz.d.mts → runtime-Wu6vGZ-j.d.cts} +86 -11
- package/package.json +5 -4
- package/src/contracts.ts +8 -0
- package/src/index.ts +25 -12
- package/src/node.ts +3 -0
- package/src/runtime/capabilities.ts +126 -0
- package/src/runtime/contracts.ts +513 -0
- package/src/runtime.ts +67 -551
- package/src/services/authoring-service.ts +559 -80
- package/src/services/context.ts +14 -8
- package/src/services/runtime-service.ts +122 -12
- package/src/services/session-project-writer.ts +67 -0
- package/src/services/session-utils.ts +5 -1
- package/src/storage.ts +201 -0
|
@@ -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";
|
|
@@ -18,6 +18,14 @@ interface BackendDiagnostic {
|
|
|
18
18
|
code: string;
|
|
19
19
|
message: string;
|
|
20
20
|
severity: 'info' | 'warning' | 'error';
|
|
21
|
+
path?: string;
|
|
22
|
+
nodeKind?: string;
|
|
23
|
+
resourceKind?: string;
|
|
24
|
+
gearKind?: string;
|
|
25
|
+
field?: string;
|
|
26
|
+
operationKind?: string;
|
|
27
|
+
opIndex?: number;
|
|
28
|
+
opId?: string;
|
|
21
29
|
}
|
|
22
30
|
interface BackendResponseMeta {
|
|
23
31
|
requestId: string;
|
|
@@ -40,7 +48,7 @@ interface PathPolicyViolationError {
|
|
|
40
48
|
allowedPath: string;
|
|
41
49
|
}
|
|
42
50
|
//#endregion
|
|
43
|
-
//#region src/runtime.d.ts
|
|
51
|
+
//#region src/runtime/contracts.d.ts
|
|
44
52
|
interface BackendFileHandle {
|
|
45
53
|
writeFile(content: string): Promise<void>;
|
|
46
54
|
close(): Promise<void>;
|
|
@@ -62,6 +70,7 @@ interface BackendFileSystem {
|
|
|
62
70
|
resolvePath(filePath: string): Promise<string>;
|
|
63
71
|
openExclusive(filePath: string): Promise<BackendFileHandle>;
|
|
64
72
|
unlink(filePath: string): Promise<void>;
|
|
73
|
+
rmdir(dirPath: string): Promise<void>;
|
|
65
74
|
join(...paths: string[]): string;
|
|
66
75
|
dirname(filePath: string): string;
|
|
67
76
|
resolve(...paths: string[]): string;
|
|
@@ -87,7 +96,13 @@ interface BackendCapabilityManifest {
|
|
|
87
96
|
adapters: {
|
|
88
97
|
fileSystem: {
|
|
89
98
|
injected: true;
|
|
90
|
-
requiredFor: readonly ['openSession', 'saveSession'];
|
|
99
|
+
requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
|
|
100
|
+
};
|
|
101
|
+
projectStorage: {
|
|
102
|
+
injected: true;
|
|
103
|
+
browserSafe: true;
|
|
104
|
+
requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
|
|
105
|
+
adapterFactory: 'createBackendStorageFileSystem';
|
|
91
106
|
};
|
|
92
107
|
host: {
|
|
93
108
|
injected: true;
|
|
@@ -111,7 +126,7 @@ interface BackendCapabilities {
|
|
|
111
126
|
transactionKernelOwner: '@openfairygui/core';
|
|
112
127
|
appSeamOwner: '@openfairygui/functions';
|
|
113
128
|
runtimeOwner: '@openfairygui/backend';
|
|
114
|
-
methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
|
|
129
|
+
methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
|
|
115
130
|
read: {
|
|
116
131
|
capabilitySnapshot: true;
|
|
117
132
|
sessionSnapshot: true;
|
|
@@ -179,9 +194,19 @@ interface BackendSessionSnapshot {
|
|
|
179
194
|
revision: number;
|
|
180
195
|
lastSavedRevision: number;
|
|
181
196
|
dirty: boolean;
|
|
197
|
+
uamFidelity: 'full' | 'unsupported';
|
|
182
198
|
lockHeld: boolean;
|
|
183
199
|
capabilities: BackendCapabilities;
|
|
184
200
|
}
|
|
201
|
+
interface MaterializeSessionSnapshot extends BackendSessionSnapshot {
|
|
202
|
+
mode: 'fullProject';
|
|
203
|
+
reason?: string;
|
|
204
|
+
materializeRevision: number;
|
|
205
|
+
saveRevision: number;
|
|
206
|
+
writtenPaths: string[];
|
|
207
|
+
skippedPaths: string[];
|
|
208
|
+
diagnostics: BackendDiagnostic[];
|
|
209
|
+
}
|
|
185
210
|
interface BackendSuccess<T> {
|
|
186
211
|
ok: true;
|
|
187
212
|
meta: BackendResponseMeta;
|
|
@@ -234,6 +259,33 @@ interface SavePartialFailureError {
|
|
|
234
259
|
failedPaths: string[];
|
|
235
260
|
diskMayBePartiallyUpdated: true;
|
|
236
261
|
}
|
|
262
|
+
interface UamFidelityUnsupportedError {
|
|
263
|
+
code: 'uam_fidelity_unsupported';
|
|
264
|
+
message: string;
|
|
265
|
+
sessionId: string;
|
|
266
|
+
canonicalPathKey: string;
|
|
267
|
+
}
|
|
268
|
+
interface MaterializeValidationFailedError {
|
|
269
|
+
code: 'materialize_validation_failed';
|
|
270
|
+
message: string;
|
|
271
|
+
sessionId: string;
|
|
272
|
+
canonicalPathKey: string;
|
|
273
|
+
issueCount: number;
|
|
274
|
+
diagnostics: BackendDiagnostic[];
|
|
275
|
+
}
|
|
276
|
+
interface MaterializeWriteFailedError {
|
|
277
|
+
code: 'write_failed';
|
|
278
|
+
message: string;
|
|
279
|
+
sessionId: string;
|
|
280
|
+
canonicalPathKey: string;
|
|
281
|
+
attemptedRevision: number;
|
|
282
|
+
lastSavedRevision: number;
|
|
283
|
+
writtenPaths: string[];
|
|
284
|
+
failedPaths: string[];
|
|
285
|
+
skippedPaths: string[];
|
|
286
|
+
diagnostics: BackendDiagnostic[];
|
|
287
|
+
diskMayBePartiallyUpdated: true;
|
|
288
|
+
}
|
|
237
289
|
type BackendEventKind = 'session.opened' | 'transaction.applied' | 'transaction.rejected' | 'save.started' | 'save.completed' | 'save.failed' | 'session.closeRequested' | 'session.closed' | 'cache.invalidated' | 'cache.updated' | 'job.created' | 'job.started' | 'job.progress' | 'job.cancelRequested' | 'job.cancelled' | 'job.completed' | 'job.failed';
|
|
238
290
|
interface BackendEvent {
|
|
239
291
|
sequence: number;
|
|
@@ -365,7 +417,7 @@ interface RefreshCacheInput {
|
|
|
365
417
|
sessionId: string;
|
|
366
418
|
reason?: 'manual' | 'session_open' | 'after_save';
|
|
367
419
|
}
|
|
368
|
-
type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
|
|
420
|
+
type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
|
|
369
421
|
interface ApplySessionTransactionInput {
|
|
370
422
|
sessionId: string;
|
|
371
423
|
expectedRevision: number;
|
|
@@ -376,11 +428,37 @@ interface OpenProjectSessionInput {
|
|
|
376
428
|
sessionId?: string;
|
|
377
429
|
canonicalProjectPath?: string;
|
|
378
430
|
canonicalPathKey?: string;
|
|
431
|
+
storage?: BackendProjectSessionStorage;
|
|
432
|
+
}
|
|
433
|
+
interface BackendProjectSessionStorage {
|
|
434
|
+
fileSystem: BackendFileSystem;
|
|
435
|
+
fairyPath: string;
|
|
436
|
+
canonicalProjectPath?: string;
|
|
437
|
+
canonicalPathKey?: string;
|
|
438
|
+
}
|
|
439
|
+
interface SaveSessionInput {
|
|
440
|
+
sessionId: string;
|
|
441
|
+
expectedRevision?: number;
|
|
442
|
+
targetPath?: string;
|
|
443
|
+
fileSystem?: BackendFileSystem;
|
|
444
|
+
force?: boolean;
|
|
445
|
+
mode?: 'materializeCleanSession';
|
|
446
|
+
}
|
|
447
|
+
interface MaterializeSessionInput {
|
|
448
|
+
sessionId: string;
|
|
449
|
+
expectedRevision?: number;
|
|
450
|
+
storage?: BackendProjectSessionStorage;
|
|
451
|
+
targetPath?: string;
|
|
452
|
+
fileSystem?: BackendFileSystem;
|
|
453
|
+
mode?: 'fullProject';
|
|
454
|
+
reason?: string;
|
|
379
455
|
}
|
|
380
456
|
interface BackendRuntimeOptions {
|
|
381
457
|
fileSystem?: BackendFileSystem;
|
|
382
458
|
host?: BackendHostAdapter;
|
|
383
459
|
}
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/runtime.d.ts
|
|
384
462
|
declare class BackendRuntime {
|
|
385
463
|
private readonly fileSystem?;
|
|
386
464
|
private readonly capabilities;
|
|
@@ -407,11 +485,8 @@ declare class BackendRuntime {
|
|
|
407
485
|
sessionId: string;
|
|
408
486
|
}): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
|
|
409
487
|
applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
|
|
410
|
-
saveSession(input:
|
|
411
|
-
|
|
412
|
-
expectedRevision?: number;
|
|
413
|
-
targetPath?: string;
|
|
414
|
-
}): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | PathPolicyViolationError | BackendCapabilityUnavailableError>>;
|
|
488
|
+
saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
|
|
489
|
+
materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
|
|
415
490
|
closeSession(input: {
|
|
416
491
|
sessionId: string;
|
|
417
492
|
}): Promise<BackendResult<{
|
|
@@ -426,4 +501,4 @@ declare class BackendRuntime {
|
|
|
426
501
|
refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
|
|
427
502
|
}
|
|
428
503
|
//#endregion
|
|
429
|
-
export {
|
|
504
|
+
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 };
|
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.30",
|
|
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.30",
|
|
56
|
+
"@openfairygui/functions": "0.2.0-alpha.30"
|
|
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",
|
package/src/contracts.ts
CHANGED
|
@@ -17,6 +17,14 @@ export interface BackendDiagnostic {
|
|
|
17
17
|
code: string;
|
|
18
18
|
message: string;
|
|
19
19
|
severity: 'info' | 'warning' | 'error';
|
|
20
|
+
path?: string;
|
|
21
|
+
nodeKind?: string;
|
|
22
|
+
resourceKind?: string;
|
|
23
|
+
gearKind?: string;
|
|
24
|
+
field?: string;
|
|
25
|
+
operationKind?: string;
|
|
26
|
+
opIndex?: number;
|
|
27
|
+
opId?: string;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
export interface BackendResponseMeta {
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
2
|
+
BACKEND_CAPABILITY_SCHEMA_VERSION,
|
|
3
|
+
BACKEND_COMPATIBILITY_POLICY,
|
|
4
|
+
BACKEND_CONTRACT_VERSION,
|
|
5
|
+
type BackendDiagnostic,
|
|
6
|
+
type BackendMessage,
|
|
7
|
+
type BackendResponseMeta,
|
|
8
|
+
type BackendStage,
|
|
9
|
+
} from './contracts.js';
|
|
10
|
+
export {
|
|
3
11
|
type AdvisoryLockConflictError,
|
|
4
12
|
type ApplySessionTransactionInput,
|
|
5
13
|
type BackendArtifactBridgeCapability,
|
|
6
14
|
type BackendCacheEntry,
|
|
7
15
|
type BackendCacheSnapshot,
|
|
16
|
+
type BackendCapabilities,
|
|
8
17
|
type BackendCapabilityManifest,
|
|
9
18
|
type BackendCapabilityUnavailableError,
|
|
10
|
-
type BackendCapabilities,
|
|
11
19
|
type BackendError,
|
|
12
20
|
type BackendEvent,
|
|
13
21
|
type BackendEventKind,
|
|
@@ -16,6 +24,7 @@ export {
|
|
|
16
24
|
type BackendFileStat,
|
|
17
25
|
type BackendFileSystem,
|
|
18
26
|
type BackendHostAdapter,
|
|
27
|
+
type BackendJobErrors,
|
|
19
28
|
type BackendJobKind,
|
|
20
29
|
type BackendJobListSnapshot,
|
|
21
30
|
type BackendJobListStatusFilter,
|
|
@@ -24,11 +33,12 @@ export {
|
|
|
24
33
|
type BackendJobProgress,
|
|
25
34
|
type BackendJobSnapshot,
|
|
26
35
|
type BackendJobStatus,
|
|
27
|
-
type
|
|
36
|
+
type BackendProjectSessionStorage,
|
|
28
37
|
type BackendResult,
|
|
38
|
+
BackendRuntime,
|
|
39
|
+
type BackendRuntimeOptions,
|
|
29
40
|
type BackendSessionSnapshot,
|
|
30
41
|
type BackendSuccess,
|
|
31
|
-
type BackendRuntimeOptions,
|
|
32
42
|
type CacheRefreshFailedError,
|
|
33
43
|
type CancelJobInput,
|
|
34
44
|
type EventCursorInvalidError,
|
|
@@ -38,18 +48,21 @@ export {
|
|
|
38
48
|
type GetJobInput,
|
|
39
49
|
type InProcessLockConflictError,
|
|
40
50
|
type ListJobsInput,
|
|
51
|
+
type MaterializeSessionInput,
|
|
52
|
+
type MaterializeSessionSnapshot,
|
|
53
|
+
type MaterializeValidationFailedError,
|
|
54
|
+
type MaterializeWriteFailedError,
|
|
41
55
|
type OpenProjectSessionInput,
|
|
42
56
|
type RefreshCacheInput,
|
|
43
57
|
type SavePartialFailureError,
|
|
58
|
+
type SaveSessionInput,
|
|
44
59
|
type SessionNotFoundError,
|
|
45
60
|
type SessionStaleWriteError,
|
|
61
|
+
type UamFidelityUnsupportedError,
|
|
46
62
|
} from './runtime.js';
|
|
47
63
|
export {
|
|
48
|
-
type
|
|
49
|
-
type
|
|
50
|
-
type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
BACKEND_COMPATIBILITY_POLICY,
|
|
54
|
-
BACKEND_CONTRACT_VERSION,
|
|
55
|
-
} from './contracts.js';
|
|
64
|
+
type BackendAsyncStorageAdapter,
|
|
65
|
+
type BackendStorageFileSystem,
|
|
66
|
+
type BackendStorageStatLike,
|
|
67
|
+
createBackendStorageFileSystem,
|
|
68
|
+
} from './storage.js';
|
package/src/node.ts
CHANGED
|
@@ -54,6 +54,9 @@ export function createNodeBackendFileSystem(): BackendFileSystem {
|
|
|
54
54
|
unlink(filePath: string): Promise<void> {
|
|
55
55
|
return fs.unlink(filePath);
|
|
56
56
|
},
|
|
57
|
+
rmdir(dirPath: string): Promise<void> {
|
|
58
|
+
return fs.rmdir(dirPath);
|
|
59
|
+
},
|
|
57
60
|
join(...paths: string[]): string {
|
|
58
61
|
return path.join(...paths);
|
|
59
62
|
},
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UAM_SUPPORTED_MATERIALIZATION_SCOPE,
|
|
3
|
+
UAM_SUPPORTED_TRANSACTION_SCOPE,
|
|
4
|
+
} from '@openfairygui/core/uam';
|
|
5
|
+
import {
|
|
6
|
+
BACKEND_CAPABILITY_SCHEMA_VERSION,
|
|
7
|
+
BACKEND_COMPATIBILITY_POLICY,
|
|
8
|
+
BACKEND_CONTRACT_VERSION,
|
|
9
|
+
} from '../contracts.js';
|
|
10
|
+
import { createRuntimePathPolicy } from '../path-policy.js';
|
|
11
|
+
import { createArtifactCapabilities } from '../services/artifact-service.js';
|
|
12
|
+
import type { BackendArtifactBridgeCapability, BackendCapabilities } from './contracts.js';
|
|
13
|
+
|
|
14
|
+
const BACKEND_METHODS = [
|
|
15
|
+
'getCapabilities',
|
|
16
|
+
'openSession',
|
|
17
|
+
'openProjectSession',
|
|
18
|
+
'getSession',
|
|
19
|
+
'applyTransaction',
|
|
20
|
+
'saveSession',
|
|
21
|
+
'materializeSession',
|
|
22
|
+
'closeSession',
|
|
23
|
+
'getEvents',
|
|
24
|
+
'getJob',
|
|
25
|
+
'listJobs',
|
|
26
|
+
'cancelJob',
|
|
27
|
+
'getCacheSnapshot',
|
|
28
|
+
'refreshCache',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
const ARTIFACT_BRIDGE_CAPABILITY = {
|
|
32
|
+
available: false,
|
|
33
|
+
requiredHost: 'node',
|
|
34
|
+
executionBoundary: 'external-bridge',
|
|
35
|
+
bridgeEntrypoint: '@openfairygui/backend/node',
|
|
36
|
+
reason: 'publish/restore require explicit Node-hosted filesystem and artifact execution.',
|
|
37
|
+
} as const satisfies BackendArtifactBridgeCapability;
|
|
38
|
+
|
|
39
|
+
export function createCapabilities(): BackendCapabilities {
|
|
40
|
+
return {
|
|
41
|
+
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
42
|
+
capabilitySchemaVersion: BACKEND_CAPABILITY_SCHEMA_VERSION,
|
|
43
|
+
transactionKernelOwner: '@openfairygui/core',
|
|
44
|
+
appSeamOwner: '@openfairygui/functions',
|
|
45
|
+
runtimeOwner: '@openfairygui/backend',
|
|
46
|
+
methods: BACKEND_METHODS,
|
|
47
|
+
read: {
|
|
48
|
+
capabilitySnapshot: true,
|
|
49
|
+
sessionSnapshot: true,
|
|
50
|
+
},
|
|
51
|
+
authoring: {
|
|
52
|
+
applyTransaction: true,
|
|
53
|
+
saveSession: true,
|
|
54
|
+
resourceKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
|
|
55
|
+
nodeKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.nodeKinds],
|
|
56
|
+
gearKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.gearKinds],
|
|
57
|
+
transactionScope: {
|
|
58
|
+
resourceKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.resourceKinds],
|
|
59
|
+
nodeKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.nodeKinds],
|
|
60
|
+
gearKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.gearKinds],
|
|
61
|
+
},
|
|
62
|
+
unsupported: ['artifact.publish', 'artifact.restore'],
|
|
63
|
+
},
|
|
64
|
+
artifact: createArtifactCapabilities(),
|
|
65
|
+
manifest: {
|
|
66
|
+
browserSafe: true,
|
|
67
|
+
rootEntrypoint: '@openfairygui/backend',
|
|
68
|
+
nodeEntrypoint: '@openfairygui/backend/node',
|
|
69
|
+
adapters: {
|
|
70
|
+
fileSystem: {
|
|
71
|
+
injected: true,
|
|
72
|
+
requiredFor: ['openSession', 'saveSession', 'materializeSession'],
|
|
73
|
+
},
|
|
74
|
+
projectStorage: {
|
|
75
|
+
injected: true,
|
|
76
|
+
browserSafe: true,
|
|
77
|
+
requiredFor: ['openProjectSession.writeback', 'saveSession', 'materializeSession'],
|
|
78
|
+
adapterFactory: 'createBackendStorageFileSystem',
|
|
79
|
+
},
|
|
80
|
+
host: {
|
|
81
|
+
injected: true,
|
|
82
|
+
requiredFor: ['advisoryLockMetadata'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
executionBoundaries: {
|
|
86
|
+
projectSession: 'in-process-browser-safe',
|
|
87
|
+
fileBackedSession: 'adapter-backed',
|
|
88
|
+
artifactPublish: ARTIFACT_BRIDGE_CAPABILITY,
|
|
89
|
+
artifactRestore: ARTIFACT_BRIDGE_CAPABILITY,
|
|
90
|
+
},
|
|
91
|
+
diagnostics: {
|
|
92
|
+
stableCodes: true,
|
|
93
|
+
errorDiagnosticMirror: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
|
|
97
|
+
runtime: {
|
|
98
|
+
sessionRuntime: true,
|
|
99
|
+
advisoryLocking: true,
|
|
100
|
+
coordinatedSave: true,
|
|
101
|
+
atomicSave: false,
|
|
102
|
+
staleRevisionProtection: true,
|
|
103
|
+
pathPolicy: createRuntimePathPolicy(),
|
|
104
|
+
events: {
|
|
105
|
+
polling: true,
|
|
106
|
+
subscriptions: false,
|
|
107
|
+
retentionLimit: 1000,
|
|
108
|
+
sequenceScope: 'runtime',
|
|
109
|
+
},
|
|
110
|
+
jobs: {
|
|
111
|
+
inMemory: true,
|
|
112
|
+
cooperativeCancel: true,
|
|
113
|
+
persistent: false,
|
|
114
|
+
supportedKinds: ['cache.refresh'],
|
|
115
|
+
artifactJobs: false,
|
|
116
|
+
completedRetentionLimit: 100,
|
|
117
|
+
},
|
|
118
|
+
cache: {
|
|
119
|
+
derivedReadOnly: true,
|
|
120
|
+
keyedBy: 'canonicalPathKey',
|
|
121
|
+
sourceOfTruth: false,
|
|
122
|
+
refreshMethod: 'refreshCache',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|