@openfairygui/backend 0.2.0-alpha.7 → 0.2.0-alpha.9

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.
@@ -95,12 +95,12 @@ interface BackendCapabilityManifest {
95
95
  adapters: {
96
96
  fileSystem: {
97
97
  injected: true;
98
- requiredFor: readonly ['openSession', 'saveSession'];
98
+ requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
99
99
  };
100
100
  projectStorage: {
101
101
  injected: true;
102
102
  browserSafe: true;
103
- requiredFor: readonly ['openProjectSession.writeback', 'saveSession'];
103
+ requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
104
104
  adapterFactory: 'createBackendStorageFileSystem';
105
105
  };
106
106
  host: {
@@ -125,7 +125,7 @@ interface BackendCapabilities {
125
125
  transactionKernelOwner: '@openfairygui/core';
126
126
  appSeamOwner: '@openfairygui/functions';
127
127
  runtimeOwner: '@openfairygui/backend';
128
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
128
+ methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
129
129
  read: {
130
130
  capabilitySnapshot: true;
131
131
  sessionSnapshot: true;
@@ -196,6 +196,15 @@ interface BackendSessionSnapshot {
196
196
  lockHeld: boolean;
197
197
  capabilities: BackendCapabilities;
198
198
  }
199
+ interface MaterializeSessionSnapshot extends BackendSessionSnapshot {
200
+ mode: 'fullProject';
201
+ reason?: string;
202
+ materializeRevision: number;
203
+ saveRevision: number;
204
+ writtenPaths: string[];
205
+ skippedPaths: string[];
206
+ diagnostics: BackendDiagnostic[];
207
+ }
199
208
  interface BackendSuccess<T> {
200
209
  ok: true;
201
210
  meta: BackendResponseMeta;
@@ -248,6 +257,27 @@ interface SavePartialFailureError {
248
257
  failedPaths: string[];
249
258
  diskMayBePartiallyUpdated: true;
250
259
  }
260
+ interface MaterializeValidationFailedError {
261
+ code: 'materialize_validation_failed';
262
+ message: string;
263
+ sessionId: string;
264
+ canonicalPathKey: string;
265
+ issueCount: number;
266
+ diagnostics: BackendDiagnostic[];
267
+ }
268
+ interface MaterializeWriteFailedError {
269
+ code: 'write_failed';
270
+ message: string;
271
+ sessionId: string;
272
+ canonicalPathKey: string;
273
+ attemptedRevision: number;
274
+ lastSavedRevision: number;
275
+ writtenPaths: string[];
276
+ failedPaths: string[];
277
+ skippedPaths: string[];
278
+ diagnostics: BackendDiagnostic[];
279
+ diskMayBePartiallyUpdated: true;
280
+ }
251
281
  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';
252
282
  interface BackendEvent {
253
283
  sequence: number;
@@ -379,7 +409,7 @@ interface RefreshCacheInput {
379
409
  sessionId: string;
380
410
  reason?: 'manual' | 'session_open' | 'after_save';
381
411
  }
382
- type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
412
+ type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
383
413
  interface ApplySessionTransactionInput {
384
414
  sessionId: string;
385
415
  expectedRevision: number;
@@ -403,6 +433,17 @@ interface SaveSessionInput {
403
433
  expectedRevision?: number;
404
434
  targetPath?: string;
405
435
  fileSystem?: BackendFileSystem;
436
+ force?: boolean;
437
+ mode?: 'materializeCleanSession';
438
+ }
439
+ interface MaterializeSessionInput {
440
+ sessionId: string;
441
+ expectedRevision?: number;
442
+ storage?: BackendProjectSessionStorage;
443
+ targetPath?: string;
444
+ fileSystem?: BackendFileSystem;
445
+ mode?: 'fullProject';
446
+ reason?: string;
406
447
  }
407
448
  interface BackendRuntimeOptions {
408
449
  fileSystem?: BackendFileSystem;
@@ -434,7 +475,8 @@ declare class BackendRuntime {
434
475
  sessionId: string;
435
476
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
436
477
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
437
- saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | PathPolicyViolationError | BackendCapabilityUnavailableError>>;
478
+ saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
479
+ materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
438
480
  closeSession(input: {
439
481
  sessionId: string;
440
482
  }): Promise<BackendResult<{
@@ -449,4 +491,4 @@ declare class BackendRuntime {
449
491
  refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
450
492
  }
451
493
  //#endregion
452
- export { BackendStage as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobProgress as C, BackendResult as D, BackendProjectSessionStorage as E, GetCacheSnapshotInput as F, SessionNotFoundError as G, RefreshCacheInput as H, GetEventsInput as I, BACKEND_COMPATIBILITY_POLICY as J, SessionStaleWriteError as K, GetEventsSnapshot as L, CacheRefreshFailedError as M, CancelJobInput as N, BackendRuntime as O, EventCursorInvalidError as P, BackendResponseMeta as Q, GetJobInput as R, BackendJobNotFoundError as S, BackendJobStatus as T, SavePartialFailureError as U, OpenProjectSessionInput as V, SaveSessionInput as W, BackendDiagnostic as X, BACKEND_CONTRACT_VERSION as Y, BackendMessage as Z, BackendJobErrors as _, BackendCacheSnapshot as a, BackendJobListStatusFilter as b, BackendCapabilityUnavailableError as c, BackendEventKind as d, BackendFailure as f, BackendHostAdapter as g, BackendFileSystem as h, BackendCacheEntry as i, BackendSuccess as j, BackendRuntimeOptions as k, BackendError as l, BackendFileStat as m, ApplySessionTransactionInput as n, BackendCapabilities as o, BackendFileHandle as p, BACKEND_CAPABILITY_SCHEMA_VERSION as q, BackendArtifactBridgeCapability as r, BackendCapabilityManifest as s, AdvisoryLockConflictError as t, BackendEvent as u, BackendJobKind as v, BackendJobSnapshot as w, BackendJobNotCancellableError as x, BackendJobListSnapshot as y, InProcessLockConflictError as z };
494
+ export { BACKEND_CONTRACT_VERSION as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobProgress as C, BackendResult as D, BackendProjectSessionStorage 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, BackendRuntime as O, EventCursorInvalidError as P, BACKEND_COMPATIBILITY_POLICY as Q, GetJobInput as R, BackendJobNotFoundError as S, BackendJobStatus as T, MaterializeValidationFailedError as U, MaterializeSessionInput as V, MaterializeWriteFailedError as W, SessionStaleWriteError as X, SessionNotFoundError as Y, BACKEND_CAPABILITY_SCHEMA_VERSION as Z, BackendJobErrors as _, BackendCacheSnapshot as a, BackendJobListStatusFilter as b, BackendCapabilityUnavailableError as c, BackendEventKind as d, BackendDiagnostic as et, BackendFailure as f, BackendHostAdapter as g, BackendFileSystem as h, BackendCacheEntry as i, BackendSuccess as j, BackendRuntimeOptions as k, BackendError as l, BackendFileStat as m, ApplySessionTransactionInput as n, BackendResponseMeta as nt, BackendCapabilities as o, BackendFileHandle as p, SavePartialFailureError as q, BackendArtifactBridgeCapability as r, BackendStage as rt, BackendCapabilityManifest as s, AdvisoryLockConflictError as t, BackendMessage as tt, BackendEvent as u, BackendJobKind as v, BackendJobSnapshot as w, BackendJobNotCancellableError as x, BackendJobListSnapshot as y, InProcessLockConflictError as z };
@@ -95,12 +95,12 @@ interface BackendCapabilityManifest {
95
95
  adapters: {
96
96
  fileSystem: {
97
97
  injected: true;
98
- requiredFor: readonly ['openSession', 'saveSession'];
98
+ requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
99
99
  };
100
100
  projectStorage: {
101
101
  injected: true;
102
102
  browserSafe: true;
103
- requiredFor: readonly ['openProjectSession.writeback', 'saveSession'];
103
+ requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
104
104
  adapterFactory: 'createBackendStorageFileSystem';
105
105
  };
106
106
  host: {
@@ -125,7 +125,7 @@ interface BackendCapabilities {
125
125
  transactionKernelOwner: '@openfairygui/core';
126
126
  appSeamOwner: '@openfairygui/functions';
127
127
  runtimeOwner: '@openfairygui/backend';
128
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
128
+ methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
129
129
  read: {
130
130
  capabilitySnapshot: true;
131
131
  sessionSnapshot: true;
@@ -196,6 +196,15 @@ interface BackendSessionSnapshot {
196
196
  lockHeld: boolean;
197
197
  capabilities: BackendCapabilities;
198
198
  }
199
+ interface MaterializeSessionSnapshot extends BackendSessionSnapshot {
200
+ mode: 'fullProject';
201
+ reason?: string;
202
+ materializeRevision: number;
203
+ saveRevision: number;
204
+ writtenPaths: string[];
205
+ skippedPaths: string[];
206
+ diagnostics: BackendDiagnostic[];
207
+ }
199
208
  interface BackendSuccess<T> {
200
209
  ok: true;
201
210
  meta: BackendResponseMeta;
@@ -248,6 +257,27 @@ interface SavePartialFailureError {
248
257
  failedPaths: string[];
249
258
  diskMayBePartiallyUpdated: true;
250
259
  }
260
+ interface MaterializeValidationFailedError {
261
+ code: 'materialize_validation_failed';
262
+ message: string;
263
+ sessionId: string;
264
+ canonicalPathKey: string;
265
+ issueCount: number;
266
+ diagnostics: BackendDiagnostic[];
267
+ }
268
+ interface MaterializeWriteFailedError {
269
+ code: 'write_failed';
270
+ message: string;
271
+ sessionId: string;
272
+ canonicalPathKey: string;
273
+ attemptedRevision: number;
274
+ lastSavedRevision: number;
275
+ writtenPaths: string[];
276
+ failedPaths: string[];
277
+ skippedPaths: string[];
278
+ diagnostics: BackendDiagnostic[];
279
+ diskMayBePartiallyUpdated: true;
280
+ }
251
281
  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';
252
282
  interface BackendEvent {
253
283
  sequence: number;
@@ -379,7 +409,7 @@ interface RefreshCacheInput {
379
409
  sessionId: string;
380
410
  reason?: 'manual' | 'session_open' | 'after_save';
381
411
  }
382
- type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
412
+ type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
383
413
  interface ApplySessionTransactionInput {
384
414
  sessionId: string;
385
415
  expectedRevision: number;
@@ -403,6 +433,17 @@ interface SaveSessionInput {
403
433
  expectedRevision?: number;
404
434
  targetPath?: string;
405
435
  fileSystem?: BackendFileSystem;
436
+ force?: boolean;
437
+ mode?: 'materializeCleanSession';
438
+ }
439
+ interface MaterializeSessionInput {
440
+ sessionId: string;
441
+ expectedRevision?: number;
442
+ storage?: BackendProjectSessionStorage;
443
+ targetPath?: string;
444
+ fileSystem?: BackendFileSystem;
445
+ mode?: 'fullProject';
446
+ reason?: string;
406
447
  }
407
448
  interface BackendRuntimeOptions {
408
449
  fileSystem?: BackendFileSystem;
@@ -434,7 +475,8 @@ declare class BackendRuntime {
434
475
  sessionId: string;
435
476
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
436
477
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
437
- saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | PathPolicyViolationError | BackendCapabilityUnavailableError>>;
478
+ saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
479
+ materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
438
480
  closeSession(input: {
439
481
  sessionId: string;
440
482
  }): Promise<BackendResult<{
@@ -449,4 +491,4 @@ declare class BackendRuntime {
449
491
  refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
450
492
  }
451
493
  //#endregion
452
- export { BackendStage as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobProgress as C, BackendResult as D, BackendProjectSessionStorage as E, GetCacheSnapshotInput as F, SessionNotFoundError as G, RefreshCacheInput as H, GetEventsInput as I, BACKEND_COMPATIBILITY_POLICY as J, SessionStaleWriteError as K, GetEventsSnapshot as L, CacheRefreshFailedError as M, CancelJobInput as N, BackendRuntime as O, EventCursorInvalidError as P, BackendResponseMeta as Q, GetJobInput as R, BackendJobNotFoundError as S, BackendJobStatus as T, SavePartialFailureError as U, OpenProjectSessionInput as V, SaveSessionInput as W, BackendDiagnostic as X, BACKEND_CONTRACT_VERSION as Y, BackendMessage as Z, BackendJobErrors as _, BackendCacheSnapshot as a, BackendJobListStatusFilter as b, BackendCapabilityUnavailableError as c, BackendEventKind as d, BackendFailure as f, BackendHostAdapter as g, BackendFileSystem as h, BackendCacheEntry as i, BackendSuccess as j, BackendRuntimeOptions as k, BackendError as l, BackendFileStat as m, ApplySessionTransactionInput as n, BackendCapabilities as o, BackendFileHandle as p, BACKEND_CAPABILITY_SCHEMA_VERSION as q, BackendArtifactBridgeCapability as r, BackendCapabilityManifest as s, AdvisoryLockConflictError as t, BackendEvent as u, BackendJobKind as v, BackendJobSnapshot as w, BackendJobNotCancellableError as x, BackendJobListSnapshot as y, InProcessLockConflictError as z };
494
+ export { BACKEND_CONTRACT_VERSION as $, BackendSessionSnapshot as A, ListJobsInput as B, BackendJobProgress as C, BackendResult as D, BackendProjectSessionStorage 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, BackendRuntime as O, EventCursorInvalidError as P, BACKEND_COMPATIBILITY_POLICY as Q, GetJobInput as R, BackendJobNotFoundError as S, BackendJobStatus as T, MaterializeValidationFailedError as U, MaterializeSessionInput as V, MaterializeWriteFailedError as W, SessionStaleWriteError as X, SessionNotFoundError as Y, BACKEND_CAPABILITY_SCHEMA_VERSION as Z, BackendJobErrors as _, BackendCacheSnapshot as a, BackendJobListStatusFilter as b, BackendCapabilityUnavailableError as c, BackendEventKind as d, BackendDiagnostic as et, BackendFailure as f, BackendHostAdapter as g, BackendFileSystem as h, BackendCacheEntry as i, BackendSuccess as j, BackendRuntimeOptions as k, BackendError as l, BackendFileStat as m, ApplySessionTransactionInput as n, BackendResponseMeta as nt, BackendCapabilities as o, BackendFileHandle as p, SavePartialFailureError as q, BackendArtifactBridgeCapability as r, BackendStage as rt, BackendCapabilityManifest as s, AdvisoryLockConflictError as t, BackendMessage as tt, BackendEvent as u, BackendJobKind as v, BackendJobSnapshot as w, BackendJobNotCancellableError as x, BackendJobListSnapshot 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.7",
3
+ "version": "0.2.0-alpha.9",
4
4
  "description": "FairyGUI Headless Authoring SDK — stateful backend runtime and session services.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -52,8 +52,8 @@
52
52
  "runtime"
53
53
  ],
54
54
  "dependencies": {
55
- "@openfairygui/core": "0.2.0-alpha.7",
56
- "@openfairygui/functions": "0.2.0-alpha.7"
55
+ "@openfairygui/core": "0.2.0-alpha.9",
56
+ "@openfairygui/functions": "0.2.0-alpha.8"
57
57
  },
58
58
  "devDependencies": {
59
59
  "ava": "^7.0.0",
package/src/index.ts CHANGED
@@ -38,6 +38,10 @@ export {
38
38
  type GetJobInput,
39
39
  type InProcessLockConflictError,
40
40
  type ListJobsInput,
41
+ type MaterializeSessionInput,
42
+ type MaterializeSessionSnapshot,
43
+ type MaterializeValidationFailedError,
44
+ type MaterializeWriteFailedError,
41
45
  type OpenProjectSessionInput,
42
46
  type BackendProjectSessionStorage,
43
47
  type RefreshCacheInput,
package/src/runtime.ts CHANGED
@@ -66,12 +66,12 @@ export interface BackendCapabilityManifest {
66
66
  adapters: {
67
67
  fileSystem: {
68
68
  injected: true;
69
- requiredFor: readonly ['openSession', 'saveSession'];
69
+ requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
70
70
  };
71
71
  projectStorage: {
72
72
  injected: true;
73
73
  browserSafe: true;
74
- requiredFor: readonly ['openProjectSession.writeback', 'saveSession'];
74
+ requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
75
75
  adapterFactory: 'createBackendStorageFileSystem';
76
76
  };
77
77
  host: {
@@ -104,6 +104,7 @@ export interface BackendCapabilities {
104
104
  'getSession',
105
105
  'applyTransaction',
106
106
  'saveSession',
107
+ 'materializeSession',
107
108
  'closeSession',
108
109
  'getEvents',
109
110
  'getJob',
@@ -184,6 +185,16 @@ export interface BackendSessionSnapshot {
184
185
  capabilities: BackendCapabilities;
185
186
  }
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
+
187
198
  export interface BackendSuccess<T> {
188
199
  ok: true;
189
200
  meta: BackendResponseMeta;
@@ -244,6 +255,29 @@ export interface SavePartialFailureError {
244
255
  diskMayBePartiallyUpdated: true;
245
256
  }
246
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
+
247
281
  export type BackendEventKind =
248
282
  | 'session.opened'
249
283
  | 'transaction.applied'
@@ -424,6 +458,8 @@ export type BackendError =
424
458
  | InProcessLockConflictError
425
459
  | AdvisoryLockConflictError
426
460
  | SavePartialFailureError
461
+ | MaterializeValidationFailedError
462
+ | MaterializeWriteFailedError
427
463
  | PathPolicyViolationError
428
464
  | EventCursorInvalidError
429
465
  | BackendJobNotFoundError
@@ -459,6 +495,18 @@ export interface SaveSessionInput {
459
495
  expectedRevision?: number;
460
496
  targetPath?: string;
461
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;
462
510
  }
463
511
 
464
512
  export interface BackendRuntimeOptions {
@@ -473,6 +521,7 @@ const BACKEND_METHODS = [
473
521
  'getSession',
474
522
  'applyTransaction',
475
523
  'saveSession',
524
+ 'materializeSession',
476
525
  'closeSession',
477
526
  'getEvents',
478
527
  'getJob',
@@ -523,12 +572,12 @@ function createCapabilities(): BackendCapabilities {
523
572
  adapters: {
524
573
  fileSystem: {
525
574
  injected: true,
526
- requiredFor: ['openSession', 'saveSession'],
575
+ requiredFor: ['openSession', 'saveSession', 'materializeSession'],
527
576
  },
528
577
  projectStorage: {
529
578
  injected: true,
530
579
  browserSafe: true,
531
- requiredFor: ['openProjectSession.writeback', 'saveSession'],
580
+ requiredFor: ['openProjectSession.writeback', 'saveSession', 'materializeSession'],
532
581
  adapterFactory: 'createBackendStorageFileSystem',
533
582
  },
534
583
  host: {
@@ -657,17 +706,35 @@ export class BackendRuntime {
657
706
 
658
707
  public async saveSession(input: SaveSessionInput): Promise<
659
708
  BackendResult<
660
- BackendSessionSnapshot,
709
+ BackendSessionSnapshot | MaterializeSessionSnapshot,
661
710
  | SessionNotFoundError
662
711
  | SessionStaleWriteError
663
712
  | SavePartialFailureError
713
+ | MaterializeValidationFailedError
714
+ | MaterializeWriteFailedError
664
715
  | PathPolicyViolationError
716
+ | InProcessLockConflictError
665
717
  | BackendCapabilityUnavailableError
666
718
  >
667
719
  > {
668
720
  return this.authoringService.saveSession(input);
669
721
  }
670
722
 
723
+ public async materializeSession(input: MaterializeSessionInput): Promise<
724
+ BackendResult<
725
+ MaterializeSessionSnapshot,
726
+ | SessionNotFoundError
727
+ | SessionStaleWriteError
728
+ | MaterializeValidationFailedError
729
+ | MaterializeWriteFailedError
730
+ | PathPolicyViolationError
731
+ | InProcessLockConflictError
732
+ | BackendCapabilityUnavailableError
733
+ >
734
+ > {
735
+ return this.authoringService.materializeSession(input);
736
+ }
737
+
671
738
  public async closeSession(input: {
672
739
  sessionId: string;
673
740
  }): Promise<BackendResult<{ sessionId: string; closed: true }, SessionNotFoundError>> {