@openfairygui/backend 0.2.0-alpha.9 → 0.3.0-alpha.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/README.md +33 -8
- package/dist/index.cjs +1689 -27
- package/dist/index.d.cts +564 -4
- package/dist/index.d.mts +564 -4
- package/dist/index.mjs +1685 -23
- package/dist/node.cjs +1659 -9
- package/dist/node.d.cts +555 -2
- package/dist/node.d.mts +555 -2
- package/dist/node.mjs +1657 -6
- package/package.json +7 -6
- package/src/index.ts +22 -17
- package/src/node.ts +24 -8
- package/src/runtime/capabilities.ts +128 -0
- package/src/runtime/contracts.ts +560 -0
- package/src/runtime.ts +57 -623
- package/src/services/authoring-service.ts +242 -99
- package/src/services/cache-service.ts +1 -2
- package/src/services/context.ts +17 -8
- package/src/services/event-service.ts +1 -2
- package/src/services/job-service.ts +4 -5
- package/src/services/read-service.ts +64 -4
- package/src/services/runtime-service.ts +133 -27
- package/src/services/session-project-writer.ts +69 -0
- package/src/services/session-utils.ts +6 -3
- package/src/storage.ts +67 -27
- package/dist/runtime-DFatY9W0.mjs +0 -1417
- package/dist/runtime-GKzsXJdO.cjs +0 -1441
- package/dist/runtime-GyNVxAQ0.d.mts +0 -494
- package/dist/runtime-Jec6FcF5.d.cts +0 -494
- package/src/services/snapshot-utils.ts +0 -43
package/src/runtime.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UAM_SUPPORTED_MATERIALIZATION_SCOPE,
|
|
3
|
-
UAM_SUPPORTED_TRANSACTION_SCOPE,
|
|
4
|
-
type UamProject,
|
|
5
|
-
type UamTransactionOperation,
|
|
6
|
-
} from '@openfairygui/core/uam';
|
|
7
1
|
import type { ApplyUamTransactionAppError } from '@openfairygui/functions/uam';
|
|
8
|
-
import {
|
|
9
|
-
BACKEND_CAPABILITY_SCHEMA_VERSION,
|
|
10
|
-
BACKEND_COMPATIBILITY_POLICY,
|
|
11
|
-
BACKEND_CONTRACT_VERSION,
|
|
12
|
-
type BackendResponseMeta,
|
|
13
|
-
} from './contracts.js';
|
|
14
|
-
import { createRuntimePathPolicy, type PathPolicyViolationError } from './path-policy.js';
|
|
15
|
-
import { createArtifactCapabilities } from './services/artifact-service.js';
|
|
2
|
+
import type { PathPolicyViolationError } from './path-policy.js';
|
|
16
3
|
import { AuthoringService } from './services/authoring-service.js';
|
|
17
4
|
import { CacheService } from './services/cache-service.js';
|
|
18
5
|
import type { BackendContext, BackendSessionState } from './services/context.js';
|
|
@@ -20,613 +7,48 @@ import { EventService } from './services/event-service.js';
|
|
|
20
7
|
import { JobService } from './services/job-service.js';
|
|
21
8
|
import { ReadService } from './services/read-service.js';
|
|
22
9
|
import { RuntimeService } from './services/runtime-service.js';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
nodeEntrypoint: '@openfairygui/backend/node';
|
|
66
|
-
adapters: {
|
|
67
|
-
fileSystem: {
|
|
68
|
-
injected: true;
|
|
69
|
-
requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
|
|
70
|
-
};
|
|
71
|
-
projectStorage: {
|
|
72
|
-
injected: true;
|
|
73
|
-
browserSafe: true;
|
|
74
|
-
requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
|
|
75
|
-
adapterFactory: 'createBackendStorageFileSystem';
|
|
76
|
-
};
|
|
77
|
-
host: {
|
|
78
|
-
injected: true;
|
|
79
|
-
requiredFor: readonly ['advisoryLockMetadata'];
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
executionBoundaries: {
|
|
83
|
-
projectSession: 'in-process-browser-safe';
|
|
84
|
-
fileBackedSession: 'adapter-backed';
|
|
85
|
-
artifactPublish: BackendArtifactBridgeCapability;
|
|
86
|
-
artifactRestore: BackendArtifactBridgeCapability;
|
|
87
|
-
};
|
|
88
|
-
diagnostics: {
|
|
89
|
-
stableCodes: true;
|
|
90
|
-
errorDiagnosticMirror: true;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface BackendCapabilities {
|
|
95
|
-
contractVersion: typeof BACKEND_CONTRACT_VERSION;
|
|
96
|
-
capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
|
|
97
|
-
transactionKernelOwner: '@openfairygui/core';
|
|
98
|
-
appSeamOwner: '@openfairygui/functions';
|
|
99
|
-
runtimeOwner: '@openfairygui/backend';
|
|
100
|
-
methods: readonly [
|
|
101
|
-
'getCapabilities',
|
|
102
|
-
'openSession',
|
|
103
|
-
'openProjectSession',
|
|
104
|
-
'getSession',
|
|
105
|
-
'applyTransaction',
|
|
106
|
-
'saveSession',
|
|
107
|
-
'materializeSession',
|
|
108
|
-
'closeSession',
|
|
109
|
-
'getEvents',
|
|
110
|
-
'getJob',
|
|
111
|
-
'listJobs',
|
|
112
|
-
'cancelJob',
|
|
113
|
-
'getCacheSnapshot',
|
|
114
|
-
'refreshCache',
|
|
115
|
-
];
|
|
116
|
-
read: {
|
|
117
|
-
capabilitySnapshot: true;
|
|
118
|
-
sessionSnapshot: true;
|
|
119
|
-
};
|
|
120
|
-
authoring: {
|
|
121
|
-
applyTransaction: true;
|
|
122
|
-
saveSession: true;
|
|
123
|
-
resourceKinds: readonly string[];
|
|
124
|
-
nodeKinds: readonly string[];
|
|
125
|
-
gearKinds: readonly string[];
|
|
126
|
-
transactionScope: {
|
|
127
|
-
resourceKinds: readonly string[];
|
|
128
|
-
nodeKinds: readonly string[];
|
|
129
|
-
gearKinds: readonly string[];
|
|
130
|
-
};
|
|
131
|
-
unsupported: readonly ['artifact.publish', 'artifact.restore'];
|
|
132
|
-
};
|
|
133
|
-
artifact: {
|
|
134
|
-
publish: false;
|
|
135
|
-
restore: false;
|
|
136
|
-
status: 'bridge-required';
|
|
137
|
-
publishBridge: BackendArtifactBridgeCapability;
|
|
138
|
-
restoreBridge: BackendArtifactBridgeCapability;
|
|
139
|
-
};
|
|
140
|
-
manifest: BackendCapabilityManifest;
|
|
141
|
-
compatibilityPolicy: typeof BACKEND_COMPATIBILITY_POLICY;
|
|
142
|
-
runtime: {
|
|
143
|
-
sessionRuntime: true;
|
|
144
|
-
advisoryLocking: true;
|
|
145
|
-
coordinatedSave: true;
|
|
146
|
-
atomicSave: false;
|
|
147
|
-
staleRevisionProtection: true;
|
|
148
|
-
pathPolicy: {
|
|
149
|
-
canonicalization: 'realpath+normalized-casefold';
|
|
150
|
-
sessionIdentity: 'project-root';
|
|
151
|
-
saveTarget: 'opened-project-only';
|
|
152
|
-
outputTargets: 'deferred';
|
|
153
|
-
workspaceBoundary: 'project-root-only';
|
|
154
|
-
};
|
|
155
|
-
events: {
|
|
156
|
-
polling: true;
|
|
157
|
-
subscriptions: false;
|
|
158
|
-
retentionLimit: 1000;
|
|
159
|
-
sequenceScope: 'runtime';
|
|
160
|
-
};
|
|
161
|
-
jobs: {
|
|
162
|
-
inMemory: true;
|
|
163
|
-
cooperativeCancel: true;
|
|
164
|
-
persistent: false;
|
|
165
|
-
supportedKinds: readonly ['cache.refresh'];
|
|
166
|
-
artifactJobs: false;
|
|
167
|
-
completedRetentionLimit: 100;
|
|
168
|
-
};
|
|
169
|
-
cache: {
|
|
170
|
-
derivedReadOnly: true;
|
|
171
|
-
keyedBy: 'canonicalPathKey';
|
|
172
|
-
sourceOfTruth: false;
|
|
173
|
-
refreshMethod: 'refreshCache';
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface BackendSessionSnapshot {
|
|
179
|
-
sessionId: string;
|
|
180
|
-
canonicalProjectPath: string;
|
|
181
|
-
revision: number;
|
|
182
|
-
lastSavedRevision: number;
|
|
183
|
-
dirty: boolean;
|
|
184
|
-
lockHeld: boolean;
|
|
185
|
-
capabilities: BackendCapabilities;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface MaterializeSessionSnapshot extends BackendSessionSnapshot {
|
|
189
|
-
mode: 'fullProject';
|
|
190
|
-
reason?: string;
|
|
191
|
-
materializeRevision: number;
|
|
192
|
-
saveRevision: number;
|
|
193
|
-
writtenPaths: string[];
|
|
194
|
-
skippedPaths: string[];
|
|
195
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export interface BackendSuccess<T> {
|
|
199
|
-
ok: true;
|
|
200
|
-
meta: BackendResponseMeta;
|
|
201
|
-
data: T;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export interface BackendFailure<E extends BackendError = BackendError> {
|
|
205
|
-
ok: false;
|
|
206
|
-
meta: BackendResponseMeta;
|
|
207
|
-
error: E;
|
|
208
|
-
session?: BackendSessionSnapshot;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export type BackendResult<T, E extends BackendError = BackendError> = BackendSuccess<T> | BackendFailure<E>;
|
|
212
|
-
|
|
213
|
-
export interface SessionNotFoundError {
|
|
214
|
-
code: 'session_not_found';
|
|
215
|
-
message: string;
|
|
216
|
-
sessionId: string;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export interface SessionStaleWriteError {
|
|
220
|
-
code: 'stale_write';
|
|
221
|
-
message: string;
|
|
222
|
-
sessionId: string;
|
|
223
|
-
canonicalPathKey: string;
|
|
224
|
-
expectedRevision: number;
|
|
225
|
-
actualRevision: number;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export interface InProcessLockConflictError {
|
|
229
|
-
code: 'lock_conflict';
|
|
230
|
-
kind: 'in_process_session_exists';
|
|
231
|
-
message: string;
|
|
232
|
-
canonicalPathKey: string;
|
|
233
|
-
holderSessionId: string;
|
|
234
|
-
lockFilePath?: string;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export interface AdvisoryLockConflictError {
|
|
238
|
-
code: 'lock_conflict';
|
|
239
|
-
kind: 'advisory_lock_conflict';
|
|
240
|
-
message: string;
|
|
241
|
-
canonicalPathKey: string;
|
|
242
|
-
holderSessionId?: string;
|
|
243
|
-
lockFilePath: string;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export interface SavePartialFailureError {
|
|
247
|
-
code: 'save_partial_failure';
|
|
248
|
-
message: string;
|
|
249
|
-
sessionId: string;
|
|
250
|
-
canonicalPathKey: string;
|
|
251
|
-
attemptedRevision: number;
|
|
252
|
-
lastSavedRevision: number;
|
|
253
|
-
committedPaths: string[];
|
|
254
|
-
failedPaths: string[];
|
|
255
|
-
diskMayBePartiallyUpdated: true;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export interface MaterializeValidationFailedError {
|
|
259
|
-
code: 'materialize_validation_failed';
|
|
260
|
-
message: string;
|
|
261
|
-
sessionId: string;
|
|
262
|
-
canonicalPathKey: string;
|
|
263
|
-
issueCount: number;
|
|
264
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export interface MaterializeWriteFailedError {
|
|
268
|
-
code: 'write_failed';
|
|
269
|
-
message: string;
|
|
270
|
-
sessionId: string;
|
|
271
|
-
canonicalPathKey: string;
|
|
272
|
-
attemptedRevision: number;
|
|
273
|
-
lastSavedRevision: number;
|
|
274
|
-
writtenPaths: string[];
|
|
275
|
-
failedPaths: string[];
|
|
276
|
-
skippedPaths: string[];
|
|
277
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
278
|
-
diskMayBePartiallyUpdated: true;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export type BackendEventKind =
|
|
282
|
-
| 'session.opened'
|
|
283
|
-
| 'transaction.applied'
|
|
284
|
-
| 'transaction.rejected'
|
|
285
|
-
| 'save.started'
|
|
286
|
-
| 'save.completed'
|
|
287
|
-
| 'save.failed'
|
|
288
|
-
| 'session.closeRequested'
|
|
289
|
-
| 'session.closed'
|
|
290
|
-
| 'cache.invalidated'
|
|
291
|
-
| 'cache.updated'
|
|
292
|
-
| 'job.created'
|
|
293
|
-
| 'job.started'
|
|
294
|
-
| 'job.progress'
|
|
295
|
-
| 'job.cancelRequested'
|
|
296
|
-
| 'job.cancelled'
|
|
297
|
-
| 'job.completed'
|
|
298
|
-
| 'job.failed';
|
|
299
|
-
|
|
300
|
-
export interface BackendEvent {
|
|
301
|
-
sequence: number;
|
|
302
|
-
kind: BackendEventKind;
|
|
303
|
-
timestamp: string;
|
|
304
|
-
sessionId?: string;
|
|
305
|
-
canonicalPathKey?: string;
|
|
306
|
-
revision?: number;
|
|
307
|
-
cacheRevision?: number;
|
|
308
|
-
jobId?: string;
|
|
309
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
310
|
-
payload?: unknown;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export interface GetEventsInput {
|
|
314
|
-
sessionId: string;
|
|
315
|
-
after?: string;
|
|
316
|
-
limit?: number;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export interface GetEventsSnapshot {
|
|
320
|
-
events: BackendEvent[];
|
|
321
|
-
oldestSequence: number;
|
|
322
|
-
currentSequence: number;
|
|
323
|
-
cursorExpired: boolean;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export interface EventCursorInvalidError {
|
|
327
|
-
code: 'event_cursor_invalid';
|
|
328
|
-
message: string;
|
|
329
|
-
sessionId: string;
|
|
330
|
-
after: string;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export type BackendJobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
334
|
-
export type BackendJobKind = 'cache.refresh';
|
|
335
|
-
export type BackendJobListStatusFilter = BackendJobStatus | 'active' | 'terminal';
|
|
336
|
-
|
|
337
|
-
export interface BackendJobProgress {
|
|
338
|
-
completed: number;
|
|
339
|
-
total?: number;
|
|
340
|
-
message?: string;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export interface BackendJobSnapshot {
|
|
344
|
-
jobId: string;
|
|
345
|
-
kind: BackendJobKind;
|
|
346
|
-
status: BackendJobStatus;
|
|
347
|
-
createdAt: string;
|
|
348
|
-
startedAt?: string;
|
|
349
|
-
finishedAt?: string;
|
|
350
|
-
sessionId?: string;
|
|
351
|
-
canonicalPathKey?: string;
|
|
352
|
-
revision?: number;
|
|
353
|
-
cacheRevision?: number;
|
|
354
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
355
|
-
progress?: BackendJobProgress;
|
|
356
|
-
result?: unknown;
|
|
357
|
-
error?: BackendError;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export interface BackendJobListSnapshot {
|
|
361
|
-
jobs: BackendJobSnapshot[];
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export interface GetJobInput {
|
|
365
|
-
sessionId: string;
|
|
366
|
-
jobId: string;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export interface ListJobsInput {
|
|
370
|
-
sessionId: string;
|
|
371
|
-
status?: BackendJobListStatusFilter;
|
|
372
|
-
kind?: BackendJobKind;
|
|
373
|
-
limit?: number;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export interface CancelJobInput {
|
|
377
|
-
sessionId: string;
|
|
378
|
-
jobId: string;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export interface BackendJobNotFoundError {
|
|
382
|
-
code: 'job_not_found';
|
|
383
|
-
message: string;
|
|
384
|
-
sessionId: string;
|
|
385
|
-
jobId: string;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
export interface BackendJobNotCancellableError {
|
|
389
|
-
code: 'job_not_cancellable';
|
|
390
|
-
message: string;
|
|
391
|
-
sessionId: string;
|
|
392
|
-
jobId: string;
|
|
393
|
-
status: 'completed' | 'failed' | 'cancelled';
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export interface BackendJobCancelledError {
|
|
397
|
-
code: 'job_cancelled';
|
|
398
|
-
message: string;
|
|
399
|
-
sessionId: string;
|
|
400
|
-
jobId: string;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export interface CacheRefreshFailedError {
|
|
404
|
-
code: 'cache_refresh_failed';
|
|
405
|
-
message: string;
|
|
406
|
-
sessionId: string;
|
|
407
|
-
jobId: string;
|
|
408
|
-
causeCode?: string;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export interface BackendCapabilityUnavailableError {
|
|
412
|
-
code: 'capability_unavailable';
|
|
413
|
-
message: string;
|
|
414
|
-
capability: 'fileSystem' | 'artifact.publish' | 'artifact.restore';
|
|
415
|
-
requiredAdapter?: 'BackendFileSystem';
|
|
416
|
-
requiredHost?: 'node';
|
|
417
|
-
bridgeBoundary?: 'external-bridge';
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export type BackendJobErrors =
|
|
421
|
-
| BackendJobNotFoundError
|
|
422
|
-
| BackendJobNotCancellableError
|
|
423
|
-
| BackendJobCancelledError
|
|
424
|
-
| CacheRefreshFailedError;
|
|
425
|
-
|
|
426
|
-
export interface BackendCacheSnapshot {
|
|
427
|
-
cacheRevision: number;
|
|
428
|
-
entries: BackendCacheEntry[];
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
export interface BackendCacheEntry {
|
|
432
|
-
canonicalPathKey: string;
|
|
433
|
-
sessionId?: string;
|
|
434
|
-
revision: number;
|
|
435
|
-
lastSavedRevision: number;
|
|
436
|
-
dirty: boolean;
|
|
437
|
-
valid: boolean;
|
|
438
|
-
indexedAt: string;
|
|
439
|
-
summary: {
|
|
440
|
-
resourceCount: number;
|
|
441
|
-
packageCount?: number;
|
|
442
|
-
diagnostics: import('./contracts.js').BackendDiagnostic[];
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export interface GetCacheSnapshotInput {
|
|
447
|
-
sessionId: string;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
export interface RefreshCacheInput {
|
|
451
|
-
sessionId: string;
|
|
452
|
-
reason?: 'manual' | 'session_open' | 'after_save';
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export type BackendError =
|
|
456
|
-
| SessionNotFoundError
|
|
457
|
-
| SessionStaleWriteError
|
|
458
|
-
| InProcessLockConflictError
|
|
459
|
-
| AdvisoryLockConflictError
|
|
460
|
-
| SavePartialFailureError
|
|
461
|
-
| MaterializeValidationFailedError
|
|
462
|
-
| MaterializeWriteFailedError
|
|
463
|
-
| PathPolicyViolationError
|
|
464
|
-
| EventCursorInvalidError
|
|
465
|
-
| BackendJobNotFoundError
|
|
466
|
-
| BackendJobNotCancellableError
|
|
467
|
-
| BackendJobCancelledError
|
|
468
|
-
| CacheRefreshFailedError
|
|
469
|
-
| BackendCapabilityUnavailableError
|
|
470
|
-
| ApplyUamTransactionAppError;
|
|
471
|
-
|
|
472
|
-
export interface ApplySessionTransactionInput {
|
|
473
|
-
sessionId: string;
|
|
474
|
-
expectedRevision: number;
|
|
475
|
-
operations: UamTransactionOperation[];
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
export interface OpenProjectSessionInput {
|
|
479
|
-
project: UamProject;
|
|
480
|
-
sessionId?: string;
|
|
481
|
-
canonicalProjectPath?: string;
|
|
482
|
-
canonicalPathKey?: string;
|
|
483
|
-
storage?: BackendProjectSessionStorage;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export interface BackendProjectSessionStorage {
|
|
487
|
-
fileSystem: BackendFileSystem;
|
|
488
|
-
fairyPath: string;
|
|
489
|
-
canonicalProjectPath?: string;
|
|
490
|
-
canonicalPathKey?: string;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
export interface SaveSessionInput {
|
|
494
|
-
sessionId: string;
|
|
495
|
-
expectedRevision?: number;
|
|
496
|
-
targetPath?: string;
|
|
497
|
-
fileSystem?: BackendFileSystem;
|
|
498
|
-
force?: boolean;
|
|
499
|
-
mode?: 'materializeCleanSession';
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
export interface MaterializeSessionInput {
|
|
503
|
-
sessionId: string;
|
|
504
|
-
expectedRevision?: number;
|
|
505
|
-
storage?: BackendProjectSessionStorage;
|
|
506
|
-
targetPath?: string;
|
|
507
|
-
fileSystem?: BackendFileSystem;
|
|
508
|
-
mode?: 'fullProject';
|
|
509
|
-
reason?: string;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
export interface BackendRuntimeOptions {
|
|
513
|
-
fileSystem?: BackendFileSystem;
|
|
514
|
-
host?: BackendHostAdapter;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
const BACKEND_METHODS = [
|
|
518
|
-
'getCapabilities',
|
|
519
|
-
'openSession',
|
|
520
|
-
'openProjectSession',
|
|
521
|
-
'getSession',
|
|
522
|
-
'applyTransaction',
|
|
523
|
-
'saveSession',
|
|
524
|
-
'materializeSession',
|
|
525
|
-
'closeSession',
|
|
526
|
-
'getEvents',
|
|
527
|
-
'getJob',
|
|
528
|
-
'listJobs',
|
|
529
|
-
'cancelJob',
|
|
530
|
-
'getCacheSnapshot',
|
|
531
|
-
'refreshCache',
|
|
532
|
-
] as const;
|
|
533
|
-
|
|
534
|
-
const ARTIFACT_BRIDGE_CAPABILITY = {
|
|
535
|
-
available: false,
|
|
536
|
-
requiredHost: 'node',
|
|
537
|
-
executionBoundary: 'external-bridge',
|
|
538
|
-
bridgeEntrypoint: '@openfairygui/backend/node',
|
|
539
|
-
reason: 'publish/restore require explicit Node-hosted filesystem and artifact execution.',
|
|
540
|
-
} as const satisfies BackendArtifactBridgeCapability;
|
|
541
|
-
|
|
542
|
-
function createCapabilities(): BackendCapabilities {
|
|
543
|
-
return {
|
|
544
|
-
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
545
|
-
capabilitySchemaVersion: BACKEND_CAPABILITY_SCHEMA_VERSION,
|
|
546
|
-
transactionKernelOwner: '@openfairygui/core',
|
|
547
|
-
appSeamOwner: '@openfairygui/functions',
|
|
548
|
-
runtimeOwner: '@openfairygui/backend',
|
|
549
|
-
methods: BACKEND_METHODS,
|
|
550
|
-
read: {
|
|
551
|
-
capabilitySnapshot: true,
|
|
552
|
-
sessionSnapshot: true,
|
|
553
|
-
},
|
|
554
|
-
authoring: {
|
|
555
|
-
applyTransaction: true,
|
|
556
|
-
saveSession: true,
|
|
557
|
-
resourceKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
|
|
558
|
-
nodeKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.nodeKinds],
|
|
559
|
-
gearKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.gearKinds],
|
|
560
|
-
transactionScope: {
|
|
561
|
-
resourceKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.resourceKinds],
|
|
562
|
-
nodeKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.nodeKinds],
|
|
563
|
-
gearKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.gearKinds],
|
|
564
|
-
},
|
|
565
|
-
unsupported: ['artifact.publish', 'artifact.restore'],
|
|
566
|
-
},
|
|
567
|
-
artifact: createArtifactCapabilities(),
|
|
568
|
-
manifest: {
|
|
569
|
-
browserSafe: true,
|
|
570
|
-
rootEntrypoint: '@openfairygui/backend',
|
|
571
|
-
nodeEntrypoint: '@openfairygui/backend/node',
|
|
572
|
-
adapters: {
|
|
573
|
-
fileSystem: {
|
|
574
|
-
injected: true,
|
|
575
|
-
requiredFor: ['openSession', 'saveSession', 'materializeSession'],
|
|
576
|
-
},
|
|
577
|
-
projectStorage: {
|
|
578
|
-
injected: true,
|
|
579
|
-
browserSafe: true,
|
|
580
|
-
requiredFor: ['openProjectSession.writeback', 'saveSession', 'materializeSession'],
|
|
581
|
-
adapterFactory: 'createBackendStorageFileSystem',
|
|
582
|
-
},
|
|
583
|
-
host: {
|
|
584
|
-
injected: true,
|
|
585
|
-
requiredFor: ['advisoryLockMetadata'],
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
executionBoundaries: {
|
|
589
|
-
projectSession: 'in-process-browser-safe',
|
|
590
|
-
fileBackedSession: 'adapter-backed',
|
|
591
|
-
artifactPublish: ARTIFACT_BRIDGE_CAPABILITY,
|
|
592
|
-
artifactRestore: ARTIFACT_BRIDGE_CAPABILITY,
|
|
593
|
-
},
|
|
594
|
-
diagnostics: {
|
|
595
|
-
stableCodes: true,
|
|
596
|
-
errorDiagnosticMirror: true,
|
|
597
|
-
},
|
|
598
|
-
},
|
|
599
|
-
compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
|
|
600
|
-
runtime: {
|
|
601
|
-
sessionRuntime: true,
|
|
602
|
-
advisoryLocking: true,
|
|
603
|
-
coordinatedSave: true,
|
|
604
|
-
atomicSave: false,
|
|
605
|
-
staleRevisionProtection: true,
|
|
606
|
-
pathPolicy: createRuntimePathPolicy(),
|
|
607
|
-
events: {
|
|
608
|
-
polling: true,
|
|
609
|
-
subscriptions: false,
|
|
610
|
-
retentionLimit: 1000,
|
|
611
|
-
sequenceScope: 'runtime',
|
|
612
|
-
},
|
|
613
|
-
jobs: {
|
|
614
|
-
inMemory: true,
|
|
615
|
-
cooperativeCancel: true,
|
|
616
|
-
persistent: false,
|
|
617
|
-
supportedKinds: ['cache.refresh'],
|
|
618
|
-
artifactJobs: false,
|
|
619
|
-
completedRetentionLimit: 100,
|
|
620
|
-
},
|
|
621
|
-
cache: {
|
|
622
|
-
derivedReadOnly: true,
|
|
623
|
-
keyedBy: 'canonicalPathKey',
|
|
624
|
-
sourceOfTruth: false,
|
|
625
|
-
refreshMethod: 'refreshCache',
|
|
626
|
-
},
|
|
627
|
-
},
|
|
628
|
-
};
|
|
629
|
-
}
|
|
10
|
+
import { createCapabilities } from './runtime/capabilities.js';
|
|
11
|
+
import type {
|
|
12
|
+
AdvisoryLockConflictError,
|
|
13
|
+
ApplySessionTransactionInput,
|
|
14
|
+
BackendCacheEntry,
|
|
15
|
+
BackendCacheSnapshot,
|
|
16
|
+
BackendCapabilities,
|
|
17
|
+
BackendCapabilityUnavailableError,
|
|
18
|
+
BackendEvent,
|
|
19
|
+
BackendFileSystem,
|
|
20
|
+
BackendJobListSnapshot,
|
|
21
|
+
BackendJobNotCancellableError,
|
|
22
|
+
BackendJobNotFoundError,
|
|
23
|
+
BackendJobSnapshot,
|
|
24
|
+
BackendProjectOutline,
|
|
25
|
+
BackendResult,
|
|
26
|
+
BackendRuntimeOptions,
|
|
27
|
+
BackendSessionSnapshot,
|
|
28
|
+
BackendSuccess,
|
|
29
|
+
CancelJobInput,
|
|
30
|
+
EventCursorInvalidError,
|
|
31
|
+
GetCacheSnapshotInput,
|
|
32
|
+
GetEventsInput,
|
|
33
|
+
GetEventsSnapshot,
|
|
34
|
+
GetJobInput,
|
|
35
|
+
GetProjectOutlineInput,
|
|
36
|
+
InProcessLockConflictError,
|
|
37
|
+
ListJobsInput,
|
|
38
|
+
MaterializeSessionInput,
|
|
39
|
+
MaterializeSessionSnapshot,
|
|
40
|
+
MaterializeValidationFailedError,
|
|
41
|
+
MaterializeWriteFailedError,
|
|
42
|
+
OpenProjectSessionInput,
|
|
43
|
+
RefreshCacheInput,
|
|
44
|
+
SavePartialFailureError,
|
|
45
|
+
SaveSessionInput,
|
|
46
|
+
SessionNotFoundError,
|
|
47
|
+
SessionStaleWriteError,
|
|
48
|
+
UamFidelityUnsupportedError,
|
|
49
|
+
} from './runtime/contracts.js';
|
|
50
|
+
|
|
51
|
+
export * from './runtime/contracts.js';
|
|
630
52
|
|
|
631
53
|
export class BackendRuntime {
|
|
632
54
|
private readonly fileSystem?: BackendFileSystem;
|
|
@@ -693,6 +115,12 @@ export class BackendRuntime {
|
|
|
693
115
|
return this.readService.getSession(input);
|
|
694
116
|
}
|
|
695
117
|
|
|
118
|
+
public getProjectOutline(
|
|
119
|
+
input: GetProjectOutlineInput,
|
|
120
|
+
): BackendResult<BackendProjectOutline, SessionNotFoundError> {
|
|
121
|
+
return this.readService.getProjectOutline(input);
|
|
122
|
+
}
|
|
123
|
+
|
|
696
124
|
public async applyTransaction(
|
|
697
125
|
input: ApplySessionTransactionInput,
|
|
698
126
|
): Promise<
|
|
@@ -704,12 +132,15 @@ export class BackendRuntime {
|
|
|
704
132
|
return this.authoringService.applyTransaction(input);
|
|
705
133
|
}
|
|
706
134
|
|
|
707
|
-
public async saveSession(
|
|
135
|
+
public async saveSession(
|
|
136
|
+
input: SaveSessionInput,
|
|
137
|
+
): Promise<
|
|
708
138
|
BackendResult<
|
|
709
139
|
BackendSessionSnapshot | MaterializeSessionSnapshot,
|
|
710
140
|
| SessionNotFoundError
|
|
711
141
|
| SessionStaleWriteError
|
|
712
142
|
| SavePartialFailureError
|
|
143
|
+
| UamFidelityUnsupportedError
|
|
713
144
|
| MaterializeValidationFailedError
|
|
714
145
|
| MaterializeWriteFailedError
|
|
715
146
|
| PathPolicyViolationError
|
|
@@ -720,11 +151,14 @@ export class BackendRuntime {
|
|
|
720
151
|
return this.authoringService.saveSession(input);
|
|
721
152
|
}
|
|
722
153
|
|
|
723
|
-
public async materializeSession(
|
|
154
|
+
public async materializeSession(
|
|
155
|
+
input: MaterializeSessionInput,
|
|
156
|
+
): Promise<
|
|
724
157
|
BackendResult<
|
|
725
158
|
MaterializeSessionSnapshot,
|
|
726
159
|
| SessionNotFoundError
|
|
727
160
|
| SessionStaleWriteError
|
|
161
|
+
| UamFidelityUnsupportedError
|
|
728
162
|
| MaterializeValidationFailedError
|
|
729
163
|
| MaterializeWriteFailedError
|
|
730
164
|
| PathPolicyViolationError
|