@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.
@@ -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
- sessionId: string;
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 { BackendSuccess as A, OpenProjectSessionInput as B, BackendJobProgress as C, BackendRuntime as D, BackendResult as E, GetEventsInput as F, BACKEND_CAPABILITY_SCHEMA_VERSION as G, SavePartialFailureError as H, GetEventsSnapshot as I, BackendDiagnostic as J, BACKEND_COMPATIBILITY_POLICY as K, GetJobInput as L, CancelJobInput as M, EventCursorInvalidError as N, BackendRuntimeOptions as O, GetCacheSnapshotInput as P, InProcessLockConflictError as R, BackendJobNotFoundError as S, BackendJobStatus as T, SessionNotFoundError as U, RefreshCacheInput as V, SessionStaleWriteError as W, BackendResponseMeta as X, BackendMessage as Y, BackendStage 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, CacheRefreshFailedError as j, BackendSessionSnapshot as k, BackendError as l, BackendFileStat as m, ApplySessionTransactionInput as n, BackendCapabilities as o, BackendFileHandle as p, BACKEND_CONTRACT_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, ListJobsInput as z };
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 };