@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
|
@@ -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 };
|