@openfairygui/backend 0.3.0 → 0.4.0

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
@@ -1,6 +1,6 @@
1
1
  import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
2
- import { ProjectValidationReport } from "@openfairygui/core";
3
- import { UamDisplayNodeKind, UamProject, UamResource, UamTransactionOperation } from "@openfairygui/core/uam";
2
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
3
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
4
4
 
5
5
  //#region src/path-policy.d.ts
6
6
  interface PathPolicyViolationError {
@@ -12,8 +12,8 @@ interface PathPolicyViolationError {
12
12
  }
13
13
  //#endregion
14
14
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
15
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
16
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 10;
17
17
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
18
  readonly incompatibleChange: "requires contractVersion bump";
19
19
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +24,10 @@ interface BackendMessage {
24
24
  code: string;
25
25
  message: string;
26
26
  }
27
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
28
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
29
  interface BackendDiagnostic {
28
- code: string;
30
+ code: BackendDiagnosticCode;
29
31
  message: string;
30
32
  severity: 'info' | 'warning' | 'error';
31
33
  path?: string;
@@ -36,6 +38,21 @@ interface BackendDiagnostic {
36
38
  operationKind?: string;
37
39
  opIndex?: number;
38
40
  opId?: string;
41
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
42
+ owner?: BackendDiagnosticOwner;
43
+ docsUri?: string;
44
+ remediation?: BackendDiagnosticRemediation;
45
+ }
46
+ interface BackendDiagnosticRemediation {
47
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
48
+ message: string;
49
+ /** A read-only starting point, never permission to retry or mutate. */
50
+ read?: {
51
+ method: 'getProjectOutline';
52
+ input: {
53
+ sessionId: string;
54
+ };
55
+ };
39
56
  }
40
57
  interface BackendResponseMeta {
41
58
  requestId: string;
@@ -49,7 +66,88 @@ interface BackendResponseMeta {
49
66
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
67
  }
51
68
  //#endregion
69
+ //#region src/runtime/capabilities.d.ts
70
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ //#endregion
52
72
  //#region src/runtime/contracts.d.ts
73
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
74
+ readonly maxBytes: 262144;
75
+ readonly maxDepth: 32;
76
+ readonly maxNodes: 100000;
77
+ };
78
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
79
+ readonly maxBytes: 262144;
80
+ readonly maxEntries: 2000;
81
+ };
82
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
83
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
84
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
85
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
86
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
87
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
88
+ interface BackendPackageSnapshot {
89
+ id: string;
90
+ name: string;
91
+ settings: UamPackageSettings;
92
+ }
93
+ type BackendEntityTarget = {
94
+ kind: 'project';
95
+ } | {
96
+ kind: 'package';
97
+ selector: UamPackageSelector;
98
+ } | {
99
+ kind: 'resource';
100
+ selector: UamResourceSelector;
101
+ } | {
102
+ kind: 'component';
103
+ selector: UamComponentSelector;
104
+ } | {
105
+ kind: 'displayNode';
106
+ selector: UamDisplayNodeSelector;
107
+ } | {
108
+ kind: 'controller';
109
+ selector: UamControllerSelector;
110
+ } | {
111
+ kind: 'transition';
112
+ selector: UamTransitionSelector;
113
+ };
114
+ interface QueryEntityInput {
115
+ sessionId: string;
116
+ target: BackendEntityTarget;
117
+ }
118
+ interface BackendEntitySnapshot {
119
+ sessionId: string;
120
+ revision: number;
121
+ target: BackendEntityTarget;
122
+ entity: {
123
+ kind: 'project';
124
+ properties: BackendProjectSnapshot;
125
+ } | {
126
+ kind: 'package';
127
+ properties: BackendPackageSnapshot;
128
+ } | {
129
+ kind: 'resource';
130
+ properties: BackendResourceSnapshot;
131
+ } | {
132
+ kind: 'component';
133
+ properties: BackendComponentSnapshot;
134
+ } | {
135
+ kind: 'displayNode';
136
+ properties: UamDisplayNode;
137
+ } | {
138
+ kind: 'controller';
139
+ properties: UamControllerModel;
140
+ } | {
141
+ kind: 'transition';
142
+ properties: UamTransitionModel;
143
+ };
144
+ }
145
+ interface EntityQueryError {
146
+ code: 'entity_query_failed';
147
+ message: string;
148
+ sessionId: string;
149
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
150
+ }
53
151
  /** An exclusive lock owned for the lifetime of one backend session. */
54
152
  interface BackendSessionLock {
55
153
  /** Persist optional host metadata without changing lock ownership. */
@@ -72,6 +170,12 @@ interface BackendFileSystem {
72
170
  recursive?: boolean;
73
171
  }): Promise<void>;
74
172
  resolvePath(filePath: string): Promise<string>;
173
+ /** Optional host validation before a project is read. Node rejects links anywhere in the project tree. */
174
+ validateProjectRoot?(projectRoot: string): Promise<void>;
175
+ /** Optional host-specific lock location. Node keeps it beside the project so directory swaps do not move it. */
176
+ getSessionLockPath?(canonicalProjectPath: string): string;
177
+ /** Runs project writes against a staged copy and commits them as one directory swap. */
178
+ runProjectWriteTransaction?(projectRoot: string, write: (stagedFileSystem: BackendFileSystem) => Promise<void>): Promise<void>;
75
179
  acquireSessionLock(lockPath: string): Promise<BackendSessionLock>;
76
180
  unlink(filePath: string): Promise<void>;
77
181
  rmdir(dirPath: string): Promise<void>;
@@ -122,6 +226,8 @@ interface BackendCapabilityManifest {
122
226
  diagnostics: {
123
227
  stableCodes: true;
124
228
  errorDiagnosticMirror: true;
229
+ recoveryGuides: 'all-formal-codes';
230
+ automaticRepair: false;
125
231
  };
126
232
  }
127
233
  interface BackendCapabilities {
@@ -130,14 +236,26 @@ interface BackendCapabilities {
130
236
  transactionKernelOwner: '@openfairygui/core';
131
237
  appSeamOwner: '@openfairygui/functions';
132
238
  runtimeOwner: '@openfairygui/backend';
133
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
239
+ methods: typeof BACKEND_METHODS;
134
240
  read: {
135
241
  capabilitySnapshot: true;
136
242
  sessionSnapshot: true;
137
243
  projectOutline: true;
244
+ entityQuery: {
245
+ kinds: readonly BackendEntityTarget['kind'][];
246
+ projection: 'properties';
247
+ sourceBytes: false;
248
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
249
+ };
138
250
  projectValidation: true;
139
251
  };
140
252
  authoring: {
253
+ preflightTransaction: {
254
+ mode: 'execute-and-discard';
255
+ reservesRevision: false;
256
+ impact: 'model-diff';
257
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
258
+ };
141
259
  applyTransaction: true;
142
260
  saveSession: true;
143
261
  resourceKinds: readonly string[];
@@ -163,7 +281,7 @@ interface BackendCapabilities {
163
281
  sessionRuntime: true;
164
282
  advisoryLocking: true;
165
283
  coordinatedSave: true;
166
- atomicSave: false;
284
+ atomicSave: boolean;
167
285
  staleRevisionProtection: true;
168
286
  pathPolicy: {
169
287
  canonicalization: 'realpath+normalized-casefold';
@@ -297,6 +415,11 @@ interface AdvisoryLockConflictError {
297
415
  holderSessionId?: string;
298
416
  lockFilePath: string;
299
417
  }
418
+ interface SessionIdConflictError {
419
+ code: 'session_id_conflict';
420
+ message: string;
421
+ sessionId: string;
422
+ }
300
423
  interface SavePartialFailureError {
301
424
  code: 'save_partial_failure';
302
425
  message: string;
@@ -306,7 +429,7 @@ interface SavePartialFailureError {
306
429
  lastSavedRevision: number;
307
430
  committedPaths: string[];
308
431
  failedPaths: string[];
309
- diskMayBePartiallyUpdated: true;
432
+ diskMayBePartiallyUpdated: boolean;
310
433
  }
311
434
  interface UamFidelityUnsupportedError {
312
435
  code: 'uam_fidelity_unsupported';
@@ -333,7 +456,7 @@ interface MaterializeWriteFailedError {
333
456
  failedPaths: string[];
334
457
  skippedPaths: string[];
335
458
  diagnostics: BackendDiagnostic[];
336
- diskMayBePartiallyUpdated: true;
459
+ diskMayBePartiallyUpdated: boolean;
337
460
  }
338
461
  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';
339
462
  interface BackendEvent {
@@ -465,12 +588,57 @@ interface RefreshCacheInput {
465
588
  sessionId: string;
466
589
  reason?: 'manual' | 'session_open' | 'after_save';
467
590
  }
468
- type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
591
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
592
+ interface ProjectRootNotAllowedError {
593
+ code: 'project_root_not_allowed';
594
+ message: string;
595
+ projectPath: string;
596
+ }
597
+ interface ProjectOpenFailedError {
598
+ code: 'project_open_failed';
599
+ message: string;
600
+ projectPath: string;
601
+ }
469
602
  interface ApplySessionTransactionInput {
470
603
  sessionId: string;
471
604
  expectedRevision: number;
472
605
  operations: UamTransactionOperation[];
473
606
  }
607
+ interface BackendTransactionPreview {
608
+ sessionId: string;
609
+ baseRevision: number;
610
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
611
+ projectedRevision: number;
612
+ mode: 'execute-and-discard';
613
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
614
+ impact: {
615
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
616
+ files: Array<{
617
+ path: string;
618
+ kind: 'file' | 'directory';
619
+ change: 'added' | 'removed' | 'updated';
620
+ }>;
621
+ };
622
+ persistence: {
623
+ requiredAfterApply: true;
624
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
625
+ fileSystemAvailable: boolean;
626
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
627
+ writeVerified: false;
628
+ };
629
+ }
630
+ interface BackendTransactionEntityChange {
631
+ target: BackendEntityTarget;
632
+ change: 'added' | 'removed' | 'updated';
633
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
634
+ fields: string[];
635
+ }
636
+ interface TransactionPreviewError {
637
+ code: 'transaction_preview_failed';
638
+ message: string;
639
+ sessionId: string;
640
+ reason: 'response_budget_exceeded' | 'projection_failed';
641
+ }
474
642
  interface GetProjectOutlineInput {
475
643
  sessionId: string;
476
644
  }
@@ -481,7 +649,9 @@ interface OpenProjectSessionInput {
481
649
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
482
650
  project: UamProject;
483
651
  sessionId?: string;
652
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
484
653
  canonicalProjectPath?: string;
654
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
485
655
  canonicalPathKey?: string;
486
656
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
487
657
  storage?: BackendProjectSessionStorage;
@@ -512,6 +682,8 @@ interface MaterializeSessionInput {
512
682
  interface BackendRuntimeOptions {
513
683
  fileSystem?: BackendFileSystem;
514
684
  host?: BackendHostAdapter;
685
+ /** Canonical filesystem roots available to file-backed sessions. Omit for unrestricted library use. */
686
+ allowedProjectRoots?: readonly string[];
515
687
  }
516
688
  //#endregion
517
689
  //#region src/runtime.d.ts
@@ -535,13 +707,15 @@ declare class BackendRuntime {
535
707
  getCapabilities(): BackendSuccess<BackendCapabilities>;
536
708
  openSession(input: {
537
709
  projectPath: string;
538
- }): Promise<BackendResult<BackendSessionSnapshot, InProcessLockConflictError | AdvisoryLockConflictError | BackendCapabilityUnavailableError>>;
539
- openProjectSession(input: OpenProjectSessionInput): BackendResult<BackendSessionSnapshot>;
710
+ }): Promise<BackendResult<BackendSessionSnapshot, InProcessLockConflictError | AdvisoryLockConflictError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError>>;
711
+ openProjectSession(input: OpenProjectSessionInput): BackendResult<BackendSessionSnapshot, InProcessLockConflictError | SessionIdConflictError>;
540
712
  getSession(input: {
541
713
  sessionId: string;
542
714
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
543
715
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
716
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
544
717
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
718
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
545
719
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
546
720
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
547
721
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
package/dist/node.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { UamDisplayNodeKind, UamProject, UamResource, UamTransactionOperation } from "@openfairygui/core/uam";
1
+ import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
2
2
  import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
3
- import { ProjectValidationReport } from "@openfairygui/core";
3
+ import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
4
4
 
5
5
  //#region src/path-policy.d.ts
6
6
  interface PathPolicyViolationError {
@@ -12,8 +12,8 @@ interface PathPolicyViolationError {
12
12
  }
13
13
  //#endregion
14
14
  //#region src/contracts.d.ts
15
- declare const BACKEND_CONTRACT_VERSION: "1.1.0-p2";
16
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 3;
15
+ declare const BACKEND_CONTRACT_VERSION: "2.0.0-p2";
16
+ declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 10;
17
17
  declare const BACKEND_COMPATIBILITY_POLICY: {
18
18
  readonly incompatibleChange: "requires contractVersion bump";
19
19
  readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
@@ -24,8 +24,10 @@ interface BackendMessage {
24
24
  code: string;
25
25
  message: string;
26
26
  }
27
+ type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
28
+ type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
27
29
  interface BackendDiagnostic {
28
- code: string;
30
+ code: BackendDiagnosticCode;
29
31
  message: string;
30
32
  severity: 'info' | 'warning' | 'error';
31
33
  path?: string;
@@ -36,6 +38,21 @@ interface BackendDiagnostic {
36
38
  operationKind?: string;
37
39
  opIndex?: number;
38
40
  opId?: string;
41
+ /** Present for catalogued diagnostics only; original codes and classification are preserved. */
42
+ owner?: BackendDiagnosticOwner;
43
+ docsUri?: string;
44
+ remediation?: BackendDiagnosticRemediation;
45
+ }
46
+ interface BackendDiagnosticRemediation {
47
+ kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
48
+ message: string;
49
+ /** A read-only starting point, never permission to retry or mutate. */
50
+ read?: {
51
+ method: 'getProjectOutline';
52
+ input: {
53
+ sessionId: string;
54
+ };
55
+ };
39
56
  }
40
57
  interface BackendResponseMeta {
41
58
  requestId: string;
@@ -49,7 +66,88 @@ interface BackendResponseMeta {
49
66
  capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
50
67
  }
51
68
  //#endregion
69
+ //#region src/runtime/capabilities.d.ts
70
+ declare const BACKEND_METHODS: readonly ["getCapabilities", "openSession", "openProjectSession", "getSession", "getProjectOutline", "queryEntity", "validateSession", "preflightTransaction", "applyTransaction", "saveSession", "materializeSession", "closeSession", "getEvents", "getJob", "listJobs", "cancelJob", "getCacheSnapshot", "refreshCache"];
71
+ //#endregion
52
72
  //#region src/runtime/contracts.d.ts
73
+ declare const BACKEND_ENTITY_QUERY_LIMITS: {
74
+ readonly maxBytes: 262144;
75
+ readonly maxDepth: 32;
76
+ readonly maxNodes: 100000;
77
+ };
78
+ declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
79
+ readonly maxBytes: 262144;
80
+ readonly maxEntries: 2000;
81
+ };
82
+ /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
83
+ declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
84
+ type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
85
+ type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
86
+ type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
87
+ type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
88
+ interface BackendPackageSnapshot {
89
+ id: string;
90
+ name: string;
91
+ settings: UamPackageSettings;
92
+ }
93
+ type BackendEntityTarget = {
94
+ kind: 'project';
95
+ } | {
96
+ kind: 'package';
97
+ selector: UamPackageSelector;
98
+ } | {
99
+ kind: 'resource';
100
+ selector: UamResourceSelector;
101
+ } | {
102
+ kind: 'component';
103
+ selector: UamComponentSelector;
104
+ } | {
105
+ kind: 'displayNode';
106
+ selector: UamDisplayNodeSelector;
107
+ } | {
108
+ kind: 'controller';
109
+ selector: UamControllerSelector;
110
+ } | {
111
+ kind: 'transition';
112
+ selector: UamTransitionSelector;
113
+ };
114
+ interface QueryEntityInput {
115
+ sessionId: string;
116
+ target: BackendEntityTarget;
117
+ }
118
+ interface BackendEntitySnapshot {
119
+ sessionId: string;
120
+ revision: number;
121
+ target: BackendEntityTarget;
122
+ entity: {
123
+ kind: 'project';
124
+ properties: BackendProjectSnapshot;
125
+ } | {
126
+ kind: 'package';
127
+ properties: BackendPackageSnapshot;
128
+ } | {
129
+ kind: 'resource';
130
+ properties: BackendResourceSnapshot;
131
+ } | {
132
+ kind: 'component';
133
+ properties: BackendComponentSnapshot;
134
+ } | {
135
+ kind: 'displayNode';
136
+ properties: UamDisplayNode;
137
+ } | {
138
+ kind: 'controller';
139
+ properties: UamControllerModel;
140
+ } | {
141
+ kind: 'transition';
142
+ properties: UamTransitionModel;
143
+ };
144
+ }
145
+ interface EntityQueryError {
146
+ code: 'entity_query_failed';
147
+ message: string;
148
+ sessionId: string;
149
+ reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
150
+ }
53
151
  /** An exclusive lock owned for the lifetime of one backend session. */
54
152
  interface BackendSessionLock {
55
153
  /** Persist optional host metadata without changing lock ownership. */
@@ -72,6 +170,12 @@ interface BackendFileSystem {
72
170
  recursive?: boolean;
73
171
  }): Promise<void>;
74
172
  resolvePath(filePath: string): Promise<string>;
173
+ /** Optional host validation before a project is read. Node rejects links anywhere in the project tree. */
174
+ validateProjectRoot?(projectRoot: string): Promise<void>;
175
+ /** Optional host-specific lock location. Node keeps it beside the project so directory swaps do not move it. */
176
+ getSessionLockPath?(canonicalProjectPath: string): string;
177
+ /** Runs project writes against a staged copy and commits them as one directory swap. */
178
+ runProjectWriteTransaction?(projectRoot: string, write: (stagedFileSystem: BackendFileSystem) => Promise<void>): Promise<void>;
75
179
  acquireSessionLock(lockPath: string): Promise<BackendSessionLock>;
76
180
  unlink(filePath: string): Promise<void>;
77
181
  rmdir(dirPath: string): Promise<void>;
@@ -122,6 +226,8 @@ interface BackendCapabilityManifest {
122
226
  diagnostics: {
123
227
  stableCodes: true;
124
228
  errorDiagnosticMirror: true;
229
+ recoveryGuides: 'all-formal-codes';
230
+ automaticRepair: false;
125
231
  };
126
232
  }
127
233
  interface BackendCapabilities {
@@ -130,14 +236,26 @@ interface BackendCapabilities {
130
236
  transactionKernelOwner: '@openfairygui/core';
131
237
  appSeamOwner: '@openfairygui/functions';
132
238
  runtimeOwner: '@openfairygui/backend';
133
- methods: readonly ['getCapabilities', 'openSession', 'openProjectSession', 'getSession', 'getProjectOutline', 'validateSession', 'applyTransaction', 'saveSession', 'materializeSession', 'closeSession', 'getEvents', 'getJob', 'listJobs', 'cancelJob', 'getCacheSnapshot', 'refreshCache'];
239
+ methods: typeof BACKEND_METHODS;
134
240
  read: {
135
241
  capabilitySnapshot: true;
136
242
  sessionSnapshot: true;
137
243
  projectOutline: true;
244
+ entityQuery: {
245
+ kinds: readonly BackendEntityTarget['kind'][];
246
+ projection: 'properties';
247
+ sourceBytes: false;
248
+ limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
249
+ };
138
250
  projectValidation: true;
139
251
  };
140
252
  authoring: {
253
+ preflightTransaction: {
254
+ mode: 'execute-and-discard';
255
+ reservesRevision: false;
256
+ impact: 'model-diff';
257
+ limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
258
+ };
141
259
  applyTransaction: true;
142
260
  saveSession: true;
143
261
  resourceKinds: readonly string[];
@@ -163,7 +281,7 @@ interface BackendCapabilities {
163
281
  sessionRuntime: true;
164
282
  advisoryLocking: true;
165
283
  coordinatedSave: true;
166
- atomicSave: false;
284
+ atomicSave: boolean;
167
285
  staleRevisionProtection: true;
168
286
  pathPolicy: {
169
287
  canonicalization: 'realpath+normalized-casefold';
@@ -297,6 +415,11 @@ interface AdvisoryLockConflictError {
297
415
  holderSessionId?: string;
298
416
  lockFilePath: string;
299
417
  }
418
+ interface SessionIdConflictError {
419
+ code: 'session_id_conflict';
420
+ message: string;
421
+ sessionId: string;
422
+ }
300
423
  interface SavePartialFailureError {
301
424
  code: 'save_partial_failure';
302
425
  message: string;
@@ -306,7 +429,7 @@ interface SavePartialFailureError {
306
429
  lastSavedRevision: number;
307
430
  committedPaths: string[];
308
431
  failedPaths: string[];
309
- diskMayBePartiallyUpdated: true;
432
+ diskMayBePartiallyUpdated: boolean;
310
433
  }
311
434
  interface UamFidelityUnsupportedError {
312
435
  code: 'uam_fidelity_unsupported';
@@ -333,7 +456,7 @@ interface MaterializeWriteFailedError {
333
456
  failedPaths: string[];
334
457
  skippedPaths: string[];
335
458
  diagnostics: BackendDiagnostic[];
336
- diskMayBePartiallyUpdated: true;
459
+ diskMayBePartiallyUpdated: boolean;
337
460
  }
338
461
  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';
339
462
  interface BackendEvent {
@@ -465,12 +588,57 @@ interface RefreshCacheInput {
465
588
  sessionId: string;
466
589
  reason?: 'manual' | 'session_open' | 'after_save';
467
590
  }
468
- type BackendError = SessionNotFoundError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ApplyUamTransactionAppError;
591
+ type BackendError = SessionNotFoundError | TransactionPreviewError | EntityQueryError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendJobNotFoundError | BackendJobNotCancellableError | BackendJobCancelledError | CacheRefreshFailedError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
592
+ interface ProjectRootNotAllowedError {
593
+ code: 'project_root_not_allowed';
594
+ message: string;
595
+ projectPath: string;
596
+ }
597
+ interface ProjectOpenFailedError {
598
+ code: 'project_open_failed';
599
+ message: string;
600
+ projectPath: string;
601
+ }
469
602
  interface ApplySessionTransactionInput {
470
603
  sessionId: string;
471
604
  expectedRevision: number;
472
605
  operations: UamTransactionOperation[];
473
606
  }
607
+ interface BackendTransactionPreview {
608
+ sessionId: string;
609
+ baseRevision: number;
610
+ /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
611
+ projectedRevision: number;
612
+ mode: 'execute-and-discard';
613
+ /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
614
+ impact: {
615
+ entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
616
+ files: Array<{
617
+ path: string;
618
+ kind: 'file' | 'directory';
619
+ change: 'added' | 'removed' | 'updated';
620
+ }>;
621
+ };
622
+ persistence: {
623
+ requiredAfterApply: true;
624
+ nextAction: 'saveSession' | 'materializeSession' | 'host-action';
625
+ fileSystemAvailable: boolean;
626
+ uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
627
+ writeVerified: false;
628
+ };
629
+ }
630
+ interface BackendTransactionEntityChange {
631
+ target: BackendEntityTarget;
632
+ change: 'added' | 'removed' | 'updated';
633
+ /** Changed top-level property names; child collections contain identities and preserve their order. */
634
+ fields: string[];
635
+ }
636
+ interface TransactionPreviewError {
637
+ code: 'transaction_preview_failed';
638
+ message: string;
639
+ sessionId: string;
640
+ reason: 'response_budget_exceeded' | 'projection_failed';
641
+ }
474
642
  interface GetProjectOutlineInput {
475
643
  sessionId: string;
476
644
  }
@@ -481,7 +649,9 @@ interface OpenProjectSessionInput {
481
649
  /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
482
650
  project: UamProject;
483
651
  sessionId?: string;
652
+ /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
484
653
  canonicalProjectPath?: string;
654
+ /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
485
655
  canonicalPathKey?: string;
486
656
  /** Optional writeback target for the authoritative UAM project; this is not an import source. */
487
657
  storage?: BackendProjectSessionStorage;
@@ -512,6 +682,8 @@ interface MaterializeSessionInput {
512
682
  interface BackendRuntimeOptions {
513
683
  fileSystem?: BackendFileSystem;
514
684
  host?: BackendHostAdapter;
685
+ /** Canonical filesystem roots available to file-backed sessions. Omit for unrestricted library use. */
686
+ allowedProjectRoots?: readonly string[];
515
687
  }
516
688
  //#endregion
517
689
  //#region src/runtime.d.ts
@@ -535,13 +707,15 @@ declare class BackendRuntime {
535
707
  getCapabilities(): BackendSuccess<BackendCapabilities>;
536
708
  openSession(input: {
537
709
  projectPath: string;
538
- }): Promise<BackendResult<BackendSessionSnapshot, InProcessLockConflictError | AdvisoryLockConflictError | BackendCapabilityUnavailableError>>;
539
- openProjectSession(input: OpenProjectSessionInput): BackendResult<BackendSessionSnapshot>;
710
+ }): Promise<BackendResult<BackendSessionSnapshot, InProcessLockConflictError | AdvisoryLockConflictError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError>>;
711
+ openProjectSession(input: OpenProjectSessionInput): BackendResult<BackendSessionSnapshot, InProcessLockConflictError | SessionIdConflictError>;
540
712
  getSession(input: {
541
713
  sessionId: string;
542
714
  }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
543
715
  getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
716
+ queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
544
717
  validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
718
+ preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
545
719
  applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
546
720
  saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
547
721
  materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;