@openfairygui/backend 0.5.0 → 0.6.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/dist/node.d.cts CHANGED
@@ -13,8 +13,8 @@ interface PathPolicyViolationError {
13
13
  }
14
14
  //#endregion
15
15
  //#region src/contracts.d.ts
16
- declare const BACKEND_CONTRACT_VERSION: "2.0.0-p3";
17
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 11;
16
+ declare const BACKEND_CONTRACT_VERSION: "3.0.0";
17
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 12;
18
18
  declare const BACKEND_COMPATIBILITY_POLICY: {
19
19
  readonly incompatibleChange: "requires contractVersion bump";
20
20
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -68,7 +68,7 @@ interface BackendResponseMeta {
68
68
  }
69
69
  //#endregion
70
70
  //#region src/runtime/capabilities.d.ts
71
- declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getCacheSnapshot", "refreshCache"];
72
72
  //#endregion
73
73
  //#region src/runtime/contracts.d.ts
74
74
  declare const BACKEND_ENTITY_QUERY_LIMITS: {
@@ -226,7 +226,7 @@ interface BackendFileSystem {
226
226
  validateProjectRoot?(projectRoot: string): Promise<void>;
227
227
  /** Optional host-specific lock location. Node keeps it beside the project so directory swaps do not move it. */
228
228
  getSessionLockPath?(canonicalProjectPath: string): string;
229
- /** Runs project writes against a staged copy and commits them as one directory swap. */
229
+ /** Stages project writes. On failure, throw ProjectWriteTransactionError to report rollback and recovery paths. */
230
230
  runProjectWriteTransaction?(projectRoot: string, write: (stagedFileSystem: BackendFileSystem) => Promise<void>): Promise<void>;
231
231
  acquireSessionLock(lockPath: string): Promise<BackendSessionLock>;
232
232
  unlink(filePath: string): Promise<void>;
@@ -357,17 +357,10 @@ interface BackendCapabilities {
357
357
  retentionLimit: 1000;
358
358
  sequenceScope: 'runtime';
359
359
  };
360
- jobs: {
361
- inMemory: true;
362
- cooperativeCancel: true;
363
- persistent: false;
364
- supportedKinds: readonly ['cache.refresh'];
365
- artifactJobs: false;
366
- completedRetentionLimit: 100;
367
- };
368
360
  cache: {
369
361
  derivedReadOnly: true;
370
- keyedBy: 'canonicalPathKey';
362
+ keyedBy: 'sessionId';
363
+ refreshMode: 'synchronous';
371
364
  sourceOfTruth: false;
372
365
  refreshMethod: 'refreshCache';
373
366
  };
@@ -452,6 +445,12 @@ interface SessionNotFoundError {
452
445
  message: string;
453
446
  sessionId: string;
454
447
  }
448
+ interface SessionCloseFailedError {
449
+ code: 'session_close_failed';
450
+ message: string;
451
+ sessionId: string;
452
+ lockFilePath: string;
453
+ }
455
454
  interface SessionStaleWriteError {
456
455
  code: 'stale_write';
457
456
  message: string;
@@ -491,6 +490,7 @@ interface SavePartialFailureError {
491
490
  committedPaths: string[];
492
491
  failedPaths: string[];
493
492
  diskMayBePartiallyUpdated: boolean;
493
+ recoveryPaths?: string[];
494
494
  }
495
495
  interface UamFidelityUnsupportedError {
496
496
  code: 'uam_fidelity_unsupported';
@@ -518,8 +518,9 @@ interface MaterializeWriteFailedError {
518
518
  skippedPaths: string[];
519
519
  diagnostics: BackendDiagnostic[];
520
520
  diskMayBePartiallyUpdated: boolean;
521
+ recoveryPaths?: string[];
521
522
  }
522
- 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';
523
+ type BackendEventKind = 'session.opened' | 'transaction.applied' | 'transaction.rejected' | 'save.started' | 'save.completed' | 'save.failed' | 'session.closeRequested' | 'session.closed' | 'cache.invalidated' | 'cache.updated';
523
524
  interface BackendEvent {
524
525
  sequence: number;
525
526
  kind: BackendEventKind;
@@ -528,7 +529,6 @@ interface BackendEvent {
528
529
  canonicalPathKey?: string;
529
530
  revision?: number;
530
531
  cacheRevision?: number;
531
- jobId?: string;
532
532
  diagnostics: BackendDiagnostic[];
533
533
  payload?: unknown;
534
534
  }
@@ -549,73 +549,6 @@ interface EventCursorInvalidError {
549
549
  sessionId: string;
550
550
  after: string;
551
551
  }
552
- type BackendJobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
553
- type BackendJobKind = 'cache.refresh';
554
- type BackendJobListStatusFilter = BackendJobStatus | 'active' | 'terminal';
555
- interface BackendJobProgress {
556
- completed: number;
557
- total?: number;
558
- message?: string;
559
- }
560
- interface BackendJobSnapshot {
561
- jobId: string;
562
- kind: BackendJobKind;
563
- status: BackendJobStatus;
564
- createdAt: string;
565
- startedAt?: string;
566
- finishedAt?: string;
567
- sessionId?: string;
568
- canonicalPathKey?: string;
569
- revision?: number;
570
- cacheRevision?: number;
571
- diagnostics: BackendDiagnostic[];
572
- progress?: BackendJobProgress;
573
- result?: unknown;
574
- error?: BackendError;
575
- }
576
- interface BackendJobListSnapshot {
577
- jobs: BackendJobSnapshot[];
578
- }
579
- interface GetJobInput {
580
- sessionId: string;
581
- jobId: string;
582
- }
583
- interface ListJobsInput {
584
- sessionId: string;
585
- status?: BackendJobListStatusFilter;
586
- kind?: BackendJobKind;
587
- limit?: number;
588
- }
589
- interface CancelJobInput {
590
- sessionId: string;
591
- jobId: string;
592
- }
593
- interface BackendJobNotFoundError {
594
- code: 'job_not_found';
595
- message: string;
596
- sessionId: string;
597
- jobId: string;
598
- }
599
- interface BackendJobNotCancellableError {
600
- code: 'job_not_cancellable';
601
- message: string;
602
- sessionId: string;
603
- jobId: string;
604
- status: 'completed' | 'failed' | 'cancelled';
605
- }
606
- interface BackendJobCancelledError {
607
- code: 'job_cancelled';
608
- message: string;
609
- sessionId: string;
610
- jobId: string;
611
- }
612
- interface CacheRefreshFailedError {
613
- code: 'cache_refresh_failed';
614
- message: string;
615
- sessionId: string;
616
- jobId: string;
617
- causeCode?: string;
618
- }
619
552
  interface BackendCapabilityUnavailableError {
620
553
  code: 'capability_unavailable';
621
554
  message: string;
@@ -649,7 +582,7 @@ interface RefreshCacheInput {
649
582
  sessionId: string;
650
583
  reason?: 'manual' | 'session_open' | 'after_save';
651
584
  }
652
- type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
585
+ type BackendError = SessionNotFoundError | SessionCloseFailedError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
653
586
  interface ProjectRootNotAllowedError {
654
587
  code: 'project_root_not_allowed';
655
588
  message: string;
@@ -752,18 +685,14 @@ declare class BackendRuntime {
752
685
  private readonly fileSystem?;
753
686
  private readonly capabilities;
754
687
  private readonly sessions;
755
- private readonly sessionsByPath;
756
- private readonly eventsBySession;
757
- private readonly jobsBySession;
758
- private readonly cacheBySession;
759
- private eventSequence;
688
+ private readonly sessionOperations;
760
689
  private readonly context;
761
690
  private readonly readService;
762
691
  private readonly runtimeService;
763
692
  private readonly authoringService;
693
+ private readonly persistenceService;
764
694
  private readonly cacheService;
765
695
  private readonly eventService;
766
- private readonly jobService;
767
696
  constructor(options?: BackendRuntimeOptions);
768
697
  getCapabilities(): BackendSuccess<BackendCapabilities>;
769
698
  openSession(input: {
@@ -787,13 +716,10 @@ declare class BackendRuntime {
787
716
  }): Promise<BackendResult<{
788
717
  sessionId: string;
789
718
  closed: true;
790
- }, SessionNotFoundError>>;
719
+ }, SessionNotFoundError | SessionCloseFailedError>>;
791
720
  getEvents(input: GetEventsInput): BackendResult<GetEventsSnapshot, SessionNotFoundError | EventCursorInvalidError>;
792
- getJob(input: GetJobInput): BackendResult<BackendJobSnapshot, SessionNotFoundError | BackendJobNotFoundError>;
793
- listJobs(input: ListJobsInput): BackendResult<BackendJobListSnapshot, SessionNotFoundError>;
794
- cancelJob(input: CancelJobInput): BackendResult<BackendJobSnapshot, SessionNotFoundError | BackendJobNotFoundError | BackendJobNotCancellableError>;
795
721
  getCacheSnapshot(input: GetCacheSnapshotInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
796
- refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
722
+ refreshCache(input: RefreshCacheInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
797
723
  }
798
724
  //#endregion
799
725
  //#region src/node.d.ts
package/dist/node.d.mts CHANGED
@@ -13,8 +13,8 @@ interface PathPolicyViolationError {
13
13
  }
14
14
  //#endregion
15
15
  //#region src/contracts.d.ts
16
- declare const BACKEND_CONTRACT_VERSION: "2.0.0-p3";
17
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 11;
16
+ declare const BACKEND_CONTRACT_VERSION: "3.0.0";
17
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 12;
18
18
  declare const BACKEND_COMPATIBILITY_POLICY: {
19
19
  readonly incompatibleChange: "requires contractVersion bump";
20
20
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -68,7 +68,7 @@ interface BackendResponseMeta {
68
68
  }
69
69
  //#endregion
70
70
  //#region src/runtime/capabilities.d.ts
71
- declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "readSessionState", "readResourceBytes", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getCacheSnapshot", "refreshCache"];
72
72
  //#endregion
73
73
  //#region src/runtime/contracts.d.ts
74
74
  declare const BACKEND_ENTITY_QUERY_LIMITS: {
@@ -226,7 +226,7 @@ interface BackendFileSystem {
226
226
  validateProjectRoot?(projectRoot: string): Promise<void>;
227
227
  /** Optional host-specific lock location. Node keeps it beside the project so directory swaps do not move it. */
228
228
  getSessionLockPath?(canonicalProjectPath: string): string;
229
- /** Runs project writes against a staged copy and commits them as one directory swap. */
229
+ /** Stages project writes. On failure, throw ProjectWriteTransactionError to report rollback and recovery paths. */
230
230
  runProjectWriteTransaction?(projectRoot: string, write: (stagedFileSystem: BackendFileSystem) => Promise<void>): Promise<void>;
231
231
  acquireSessionLock(lockPath: string): Promise<BackendSessionLock>;
232
232
  unlink(filePath: string): Promise<void>;
@@ -357,17 +357,10 @@ interface BackendCapabilities {
357
357
  retentionLimit: 1000;
358
358
  sequenceScope: 'runtime';
359
359
  };
360
- jobs: {
361
- inMemory: true;
362
- cooperativeCancel: true;
363
- persistent: false;
364
- supportedKinds: readonly ['cache.refresh'];
365
- artifactJobs: false;
366
- completedRetentionLimit: 100;
367
- };
368
360
  cache: {
369
361
  derivedReadOnly: true;
370
- keyedBy: 'canonicalPathKey';
362
+ keyedBy: 'sessionId';
363
+ refreshMode: 'synchronous';
371
364
  sourceOfTruth: false;
372
365
  refreshMethod: 'refreshCache';
373
366
  };
@@ -452,6 +445,12 @@ interface SessionNotFoundError {
452
445
  message: string;
453
446
  sessionId: string;
454
447
  }
448
+ interface SessionCloseFailedError {
449
+ code: 'session_close_failed';
450
+ message: string;
451
+ sessionId: string;
452
+ lockFilePath: string;
453
+ }
455
454
  interface SessionStaleWriteError {
456
455
  code: 'stale_write';
457
456
  message: string;
@@ -491,6 +490,7 @@ interface SavePartialFailureError {
491
490
  committedPaths: string[];
492
491
  failedPaths: string[];
493
492
  diskMayBePartiallyUpdated: boolean;
493
+ recoveryPaths?: string[];
494
494
  }
495
495
  interface UamFidelityUnsupportedError {
496
496
  code: 'uam_fidelity_unsupported';
@@ -518,8 +518,9 @@ interface MaterializeWriteFailedError {
518
518
  skippedPaths: string[];
519
519
  diagnostics: BackendDiagnostic[];
520
520
  diskMayBePartiallyUpdated: boolean;
521
+ recoveryPaths?: string[];
521
522
  }
522
- 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';
523
+ type BackendEventKind = 'session.opened' | 'transaction.applied' | 'transaction.rejected' | 'save.started' | 'save.completed' | 'save.failed' | 'session.closeRequested' | 'session.closed' | 'cache.invalidated' | 'cache.updated';
523
524
  interface BackendEvent {
524
525
  sequence: number;
525
526
  kind: BackendEventKind;
@@ -528,7 +529,6 @@ interface BackendEvent {
528
529
  canonicalPathKey?: string;
529
530
  revision?: number;
530
531
  cacheRevision?: number;
531
- jobId?: string;
532
532
  diagnostics: BackendDiagnostic[];
533
533
  payload?: unknown;
534
534
  }
@@ -549,73 +549,6 @@ interface EventCursorInvalidError {
549
549
  sessionId: string;
550
550
  after: string;
551
551
  }
552
- type BackendJobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
553
- type BackendJobKind = 'cache.refresh';
554
- type BackendJobListStatusFilter = BackendJobStatus | 'active' | 'terminal';
555
- interface BackendJobProgress {
556
- completed: number;
557
- total?: number;
558
- message?: string;
559
- }
560
- interface BackendJobSnapshot {
561
- jobId: string;
562
- kind: BackendJobKind;
563
- status: BackendJobStatus;
564
- createdAt: string;
565
- startedAt?: string;
566
- finishedAt?: string;
567
- sessionId?: string;
568
- canonicalPathKey?: string;
569
- revision?: number;
570
- cacheRevision?: number;
571
- diagnostics: BackendDiagnostic[];
572
- progress?: BackendJobProgress;
573
- result?: unknown;
574
- error?: BackendError;
575
- }
576
- interface BackendJobListSnapshot {
577
- jobs: BackendJobSnapshot[];
578
- }
579
- interface GetJobInput {
580
- sessionId: string;
581
- jobId: string;
582
- }
583
- interface ListJobsInput {
584
- sessionId: string;
585
- status?: BackendJobListStatusFilter;
586
- kind?: BackendJobKind;
587
- limit?: number;
588
- }
589
- interface CancelJobInput {
590
- sessionId: string;
591
- jobId: string;
592
- }
593
- interface BackendJobNotFoundError {
594
- code: 'job_not_found';
595
- message: string;
596
- sessionId: string;
597
- jobId: string;
598
- }
599
- interface BackendJobNotCancellableError {
600
- code: 'job_not_cancellable';
601
- message: string;
602
- sessionId: string;
603
- jobId: string;
604
- status: 'completed' | 'failed' | 'cancelled';
605
- }
606
- interface BackendJobCancelledError {
607
- code: 'job_cancelled';
608
- message: string;
609
- sessionId: string;
610
- jobId: string;
611
- }
612
- interface CacheRefreshFailedError {
613
- code: 'cache_refresh_failed';
614
- message: string;
615
- sessionId: string;
616
- jobId: string;
617
- causeCode?: string;
618
- }
619
552
  interface BackendCapabilityUnavailableError {
620
553
  code: 'capability_unavailable';
621
554
  message: string;
@@ -649,7 +582,7 @@ interface RefreshCacheInput {
649
582
  sessionId: string;
650
583
  reason?: 'manual' | 'session_open' | 'after_save';
651
584
  }
652
- type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
585
+ type BackendError = SessionNotFoundError | SessionCloseFailedError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
653
586
  interface ProjectRootNotAllowedError {
654
587
  code: 'project_root_not_allowed';
655
588
  message: string;
@@ -752,18 +685,14 @@ declare class BackendRuntime {
752
685
  private readonly fileSystem?;
753
686
  private readonly capabilities;
754
687
  private readonly sessions;
755
- private readonly sessionsByPath;
756
- private readonly eventsBySession;
757
- private readonly jobsBySession;
758
- private readonly cacheBySession;
759
- private eventSequence;
688
+ private readonly sessionOperations;
760
689
  private readonly context;
761
690
  private readonly readService;
762
691
  private readonly runtimeService;
763
692
  private readonly authoringService;
693
+ private readonly persistenceService;
764
694
  private readonly cacheService;
765
695
  private readonly eventService;
766
- private readonly jobService;
767
696
  constructor(options?: BackendRuntimeOptions);
768
697
  getCapabilities(): BackendSuccess<BackendCapabilities>;
769
698
  openSession(input: {
@@ -787,13 +716,10 @@ declare class BackendRuntime {
787
716
  }): Promise<BackendResult<{
788
717
  sessionId: string;
789
718
  closed: true;
790
- }, SessionNotFoundError>>;
719
+ }, SessionNotFoundError | SessionCloseFailedError>>;
791
720
  getEvents(input: GetEventsInput): BackendResult<GetEventsSnapshot, SessionNotFoundError | EventCursorInvalidError>;
792
- getJob(input: GetJobInput): BackendResult<BackendJobSnapshot, SessionNotFoundError | BackendJobNotFoundError>;
793
- listJobs(input: ListJobsInput): BackendResult<BackendJobListSnapshot, SessionNotFoundError>;
794
- cancelJob(input: CancelJobInput): BackendResult<BackendJobSnapshot, SessionNotFoundError | BackendJobNotFoundError | BackendJobNotCancellableError>;
795
721
  getCacheSnapshot(input: GetCacheSnapshotInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
796
- refreshCache(input: RefreshCacheInput): BackendResult<BackendJobSnapshot, SessionNotFoundError>;
722
+ refreshCache(input: RefreshCacheInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
797
723
  }
798
724
  //#endregion
799
725
  //#region src/node.d.ts