@openfairygui/backend 0.6.2 → 0.7.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.
Files changed (48) hide show
  1. package/dist/contracts-Bx8HUr7I.d.cts +756 -0
  2. package/dist/contracts-CMQiPEyz.d.mts +756 -0
  3. package/dist/diagnostics-CIe7S-RW.cjs +670 -0
  4. package/dist/diagnostics-CZ12H1Mx.d.cts +1679 -0
  5. package/dist/diagnostics-CpJ8cAP6.d.mts +1679 -0
  6. package/dist/diagnostics-DTnLXQGs.mjs +641 -0
  7. package/dist/docs.cjs +11506 -5902
  8. package/dist/docs.d.cts +5 -185
  9. package/dist/docs.d.mts +5 -185
  10. package/dist/docs.mjs +11504 -5901
  11. package/dist/index.cjs +16 -2703
  12. package/dist/index.d.cts +5 -2362
  13. package/dist/index.d.mts +5 -2362
  14. package/dist/index.mjs +4 -2691
  15. package/dist/node.cjs +367 -2779
  16. package/dist/node.d.cts +4 -724
  17. package/dist/node.d.mts +4 -724
  18. package/dist/node.mjs +359 -2751
  19. package/dist/rolldown-runtime-BJqNVkSG.cjs +28 -0
  20. package/dist/runtime-DYqG77ak.cjs +2249 -0
  21. package/dist/runtime-gStewf1p.mjs +2189 -0
  22. package/package.json +4 -5
  23. package/src/contracts.ts +0 -58
  24. package/src/diagnostics.ts +0 -188
  25. package/src/docs.ts +0 -109
  26. package/src/generated/contracts.ts +0 -24165
  27. package/src/generated/docs.ts +0 -12
  28. package/src/index.ts +0 -99
  29. package/src/node.ts +0 -317
  30. package/src/path-policy.ts +0 -123
  31. package/src/runtime/capabilities.ts +0 -131
  32. package/src/runtime/contracts.ts +0 -672
  33. package/src/runtime.ts +0 -231
  34. package/src/services/artifact-service.ts +0 -19
  35. package/src/services/authoring-service.ts +0 -229
  36. package/src/services/cache-service.ts +0 -81
  37. package/src/services/capture-project.ts +0 -75
  38. package/src/services/context.ts +0 -150
  39. package/src/services/event-service.ts +0 -86
  40. package/src/services/persistence-service.ts +0 -550
  41. package/src/services/read-service.ts +0 -274
  42. package/src/services/runtime-service.ts +0 -342
  43. package/src/services/session-operation-queue.ts +0 -21
  44. package/src/services/session-project-writer.ts +0 -89
  45. package/src/services/session-registry.ts +0 -70
  46. package/src/services/session-utils.ts +0 -45
  47. package/src/services/transaction-preview.ts +0 -116
  48. package/src/storage.ts +0 -232
package/dist/node.d.mts CHANGED
@@ -1,730 +1,10 @@
1
- import { UamComponentModel, UamComponentResource, UamComponentSelector, UamControllerModel, UamControllerSelector, UamDisplayNode, UamDisplayNodeKind, UamDisplayNodeSelector, UamGenericAssetResource, UamImageResource, UamMovieClipResource, UamPackage, UamPackageSelector, UamPackageSettings, UamProject, UamResource, UamResourceSelector, UamTransactionOperation, UamTransactionSupportIssueCode, UamTransitionModel, UamTransitionSelector } from "@openfairygui/core/uam";
2
- import { ApplyUamTransactionAppError } from "@openfairygui/functions/uam";
3
- import * as _$_openfairygui_core0 from "@openfairygui/core";
4
- import { ProjectDiagnosticCode, ProjectValidationReport } from "@openfairygui/core";
1
+ import { A as BackendFileStat, M as BackendHostAdapter, U as BackendRuntimeOptions, W as BackendSessionLock, d as BackendRuntime, j as BackendFileSystem } from "./contracts-CMQiPEyz.mjs";
5
2
 
6
- //#region src/path-policy.d.ts
7
- interface PathPolicyViolationError {
8
- code: 'path_policy_violation';
9
- message: string;
10
- policy: 'save_target';
11
- attemptedPath: string;
12
- allowedPath: string;
13
- }
14
- //#endregion
15
- //#region src/contracts.d.ts
16
- declare const BACKEND_CONTRACT_VERSION: "3.0.0";
17
- declare const BACKEND_CAPABILITY_SCHEMA_VERSION: 12;
18
- declare const BACKEND_COMPATIBILITY_POLICY: {
19
- readonly incompatibleChange: "requires contractVersion bump";
20
- readonly capabilitySchemaChange: "requires capabilitySchemaVersion bump";
21
- readonly additiveChange: "allowed without breaking existing consumers";
22
- };
23
- type BackendStage = 'read' | 'authoring' | 'runtime';
24
- interface BackendMessage {
25
- code: string;
26
- message: string;
27
- }
28
- type BackendDiagnosticCode = BackendError['code'] | UamTransactionSupportIssueCode | ProjectDiagnosticCode;
29
- type BackendDiagnosticOwner = 'backend' | 'core.transaction' | 'core.validation';
30
- interface BackendDiagnostic {
31
- code: BackendDiagnosticCode;
32
- message: string;
33
- severity: 'info' | 'warning' | 'error';
34
- path?: string;
35
- nodeKind?: string;
36
- resourceKind?: string;
37
- gearKind?: string;
38
- field?: string;
39
- operationKind?: string;
40
- opIndex?: number;
41
- opId?: string;
42
- /** Present for catalogued diagnostics only; original codes and classification are preserved. */
43
- owner?: BackendDiagnosticOwner;
44
- docsUri?: string;
45
- remediation?: BackendDiagnosticRemediation;
46
- }
47
- interface BackendDiagnosticRemediation {
48
- kind: 'refresh-and-replan' | 'revise-selector' | 'revise-operation' | 'host-action';
49
- message: string;
50
- /** A read-only starting point, never permission to retry or mutate. */
51
- read?: {
52
- method: 'getProjectOutline';
53
- input: {
54
- sessionId: string;
55
- };
56
- };
57
- }
58
- interface BackendResponseMeta {
59
- requestId: string;
60
- sessionId?: string;
61
- revision?: number;
62
- durationMs: number;
63
- warnings: BackendMessage[];
64
- diagnostics: BackendDiagnostic[];
65
- stage: BackendStage;
66
- contractVersion: typeof BACKEND_CONTRACT_VERSION;
67
- capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
68
- }
69
- //#endregion
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", "getCacheSnapshot", "refreshCache"];
72
- //#endregion
73
- //#region src/runtime/contracts.d.ts
74
- declare const BACKEND_ENTITY_QUERY_LIMITS: {
75
- readonly maxBytes: 262144;
76
- readonly maxDepth: 32;
77
- readonly maxNodes: 100000;
78
- };
79
- declare const BACKEND_SESSION_READ_LIMITS: {
80
- readonly model: {
81
- readonly maxBytes: 4194304;
82
- readonly maxDepth: 64;
83
- readonly maxNodes: 500000;
84
- };
85
- readonly resourceBytes: 1048576;
86
- };
87
- /** The public UAM model, excluding only each asset resource's primary sourceBytes. */
88
- type BackendSessionResourceModel = UamComponentResource | Omit<UamImageResource, 'sourceBytes'> | Omit<UamMovieClipResource, 'sourceBytes'> | Omit<UamGenericAssetResource, 'sourceBytes'>;
89
- interface BackendSessionPackageModel extends Omit<UamPackage, 'resources'> {
90
- resources: BackendSessionResourceModel[];
91
- }
92
- interface BackendSessionProjectModel extends Omit<UamProject, 'packages'> {
93
- packages: BackendSessionPackageModel[];
94
- }
95
- interface ReadSessionStateInput {
96
- sessionId: string;
97
- expectedRevision?: number;
98
- }
99
- interface ReadResourceBytesInput {
100
- sessionId: string;
101
- expectedRevision: number;
102
- selector: UamResourceSelector;
103
- }
104
- interface BackendSessionStateSnapshot extends Pick<BackendSessionSnapshot, 'sessionId' | 'revision' | 'lastSavedRevision' | 'dirty' | 'uamFidelity'> {
105
- project: BackendSessionProjectModel;
106
- readDiagnostics: _$_openfairygui_core0.ProjectDiagnostic[];
107
- /** Source-read completeness, not a guarantee of resource bytes or downstream usability. */
108
- readComplete: boolean;
109
- }
110
- interface BackendResourceBytesSnapshot {
111
- sessionId: string;
112
- revision: number;
113
- selector: UamResourceSelector;
114
- /** Only primary bytes already held in this session; no filesystem hydration. */
115
- sourceBytes: Uint8Array;
116
- }
117
- interface SessionReadError {
118
- code: 'session_read_failed';
119
- message: string;
120
- sessionId: string;
121
- reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'unsupported_resource' | 'bytes_unavailable' | 'response_budget_exceeded' | 'non_json_value';
122
- }
123
- interface SessionStaleReadError {
124
- code: 'stale_read';
125
- message: string;
126
- sessionId: string;
127
- expectedRevision: number;
128
- actualRevision: number;
129
- }
130
- declare const BACKEND_TRANSACTION_PREVIEW_LIMITS: {
131
- readonly maxBytes: 262144;
132
- readonly maxEntries: 2000;
133
- };
134
- /** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
135
- declare const BACKEND_RESOURCE_QUERY_FIELDS: readonly ["kind", "id", "name", "path", "exported", "favorite", "branch", "branchItemIds", "fileName", "file", "dimensions", "image", "movieClip"];
136
- type ResourceQueryFields<T> = Pick<T, Extract<keyof T, typeof BACKEND_RESOURCE_QUERY_FIELDS[number]>>;
137
- type BackendResourceSnapshot = ResourceQueryFields<UamImageResource> | ResourceQueryFields<UamMovieClipResource> | ResourceQueryFields<UamGenericAssetResource> | ResourceQueryFields<UamComponentResource>;
138
- type BackendComponentSnapshot = Pick<UamComponentModel, 'size' | 'properties' | 'customData'>;
139
- type BackendProjectSnapshot = Pick<UamProject, 'projectId' | 'settings'>;
140
- interface BackendPackageSnapshot {
141
- id: string;
142
- name: string;
143
- settings: UamPackageSettings;
144
- }
145
- type BackendEntityTarget = {
146
- kind: 'project';
147
- } | {
148
- kind: 'package';
149
- selector: UamPackageSelector;
150
- } | {
151
- kind: 'resource';
152
- selector: UamResourceSelector;
153
- } | {
154
- kind: 'component';
155
- selector: UamComponentSelector;
156
- } | {
157
- kind: 'displayNode';
158
- selector: UamDisplayNodeSelector;
159
- } | {
160
- kind: 'controller';
161
- selector: UamControllerSelector;
162
- } | {
163
- kind: 'transition';
164
- selector: UamTransitionSelector;
165
- };
166
- interface QueryEntityInput {
167
- sessionId: string;
168
- target: BackendEntityTarget;
169
- }
170
- interface BackendEntitySnapshot {
171
- sessionId: string;
172
- revision: number;
173
- target: BackendEntityTarget;
174
- entity: {
175
- kind: 'project';
176
- properties: BackendProjectSnapshot;
177
- } | {
178
- kind: 'package';
179
- properties: BackendPackageSnapshot;
180
- } | {
181
- kind: 'resource';
182
- properties: BackendResourceSnapshot;
183
- } | {
184
- kind: 'component';
185
- properties: BackendComponentSnapshot;
186
- } | {
187
- kind: 'displayNode';
188
- properties: UamDisplayNode;
189
- } | {
190
- kind: 'controller';
191
- properties: UamControllerModel;
192
- } | {
193
- kind: 'transition';
194
- properties: UamTransitionModel;
195
- };
196
- }
197
- interface EntityQueryError {
198
- code: 'entity_query_failed';
199
- message: string;
200
- sessionId: string;
201
- reason: 'invalid_query' | 'not_found' | 'ambiguous' | 'response_budget_exceeded' | 'non_json_value';
202
- }
203
- /** An exclusive lock owned for the lifetime of one backend session. */
204
- interface BackendSessionLock {
205
- /** Persist optional host metadata without changing lock ownership. */
206
- writeMetadata(content: string): Promise<void>;
207
- /** Release ownership. Browser implementations must also release when their document terminates. */
208
- release(): Promise<void>;
209
- }
210
- interface BackendFileStat {
211
- isFile(): boolean;
212
- isDirectory(): boolean;
213
- }
214
- interface BackendFileSystem {
215
- stat(filePath: string): Promise<BackendFileStat>;
216
- readdir(dirPath: string): Promise<string[]>;
217
- readFile(filePath: string): Promise<string>;
218
- readFileRaw(filePath: string): Promise<Uint8Array>;
219
- writeFile(filePath: string, content: string): Promise<void>;
220
- writeFileRaw(filePath: string, data: Uint8Array): Promise<void>;
221
- mkdir(dirPath: string, options?: {
222
- recursive?: boolean;
223
- }): Promise<void>;
224
- resolvePath(filePath: string): Promise<string>;
225
- /** Optional host validation before a project is read. Node rejects links anywhere in the project tree. */
226
- validateProjectRoot?(projectRoot: string): Promise<void>;
227
- /** Optional host-specific lock location. Node keeps it beside the project so directory swaps do not move it. */
228
- getSessionLockPath?(canonicalProjectPath: string): string;
229
- /** Stages project writes. On failure, throw ProjectWriteTransactionError to report rollback and recovery paths. */
230
- runProjectWriteTransaction?(projectRoot: string, write: (stagedFileSystem: BackendFileSystem) => Promise<void>): Promise<void>;
231
- acquireSessionLock(lockPath: string): Promise<BackendSessionLock>;
232
- unlink(filePath: string): Promise<void>;
233
- rmdir(dirPath: string): Promise<void>;
234
- join(...paths: string[]): string;
235
- dirname(filePath: string): string;
236
- resolve(...paths: string[]): string;
237
- }
238
- interface BackendHostAdapter {
239
- lockMetadata?(input: {
240
- canonicalPathKey: string;
241
- canonicalProjectPath: string;
242
- lockFilePath: string;
243
- }): unknown;
244
- }
245
- interface BackendArtifactBridgeCapability {
246
- available: false;
247
- requiredHost: 'node';
248
- executionBoundary: 'external-bridge';
249
- bridgeEntrypoint: '@openfairygui/backend/node';
250
- reason: string;
251
- }
252
- interface BackendCapabilityManifest {
253
- browserSafe: true;
254
- rootEntrypoint: '@openfairygui/backend';
255
- nodeEntrypoint: '@openfairygui/backend/node';
256
- adapters: {
257
- fileSystem: {
258
- injected: true;
259
- requiredFor: readonly ['openSession', 'saveSession', 'materializeSession'];
260
- };
261
- projectStorage: {
262
- injected: true;
263
- browserSafe: true;
264
- requiredFor: readonly ['openProjectSession.writeback', 'saveSession', 'materializeSession'];
265
- adapterFactory: 'createBackendStorageFileSystem';
266
- };
267
- host: {
268
- injected: true;
269
- requiredFor: readonly ['advisoryLockMetadata'];
270
- };
271
- };
272
- executionBoundaries: {
273
- projectSession: 'in-process-browser-safe';
274
- fileBackedSession: 'adapter-backed';
275
- artifactPublish: BackendArtifactBridgeCapability;
276
- artifactRestore: BackendArtifactBridgeCapability;
277
- };
278
- diagnostics: {
279
- stableCodes: true;
280
- errorDiagnosticMirror: true;
281
- recoveryGuides: 'all-formal-codes';
282
- automaticRepair: false;
283
- };
284
- }
285
- interface BackendCapabilities {
286
- contractVersion: typeof BACKEND_CONTRACT_VERSION;
287
- capabilitySchemaVersion: typeof BACKEND_CAPABILITY_SCHEMA_VERSION;
288
- transactionKernelOwner: '@openfairygui/core';
289
- appSeamOwner: '@openfairygui/functions';
290
- runtimeOwner: '@openfairygui/backend';
291
- methods: typeof BACKEND_METHODS;
292
- read: {
293
- capabilitySnapshot: true;
294
- sessionSnapshot: true;
295
- projectOutline: true;
296
- entityQuery: {
297
- kinds: readonly BackendEntityTarget['kind'][];
298
- projection: 'properties';
299
- sourceBytes: false;
300
- limits: typeof BACKEND_ENTITY_QUERY_LIMITS;
301
- };
302
- sessionState: {
303
- sourceBytes: false;
304
- limits: typeof BACKEND_SESSION_READ_LIMITS.model;
305
- };
306
- resourceBytes: {
307
- expectedRevisionRequired: true;
308
- hydration: false;
309
- maxBytes: typeof BACKEND_SESSION_READ_LIMITS.resourceBytes;
310
- };
311
- projectValidation: true;
312
- };
313
- authoring: {
314
- preflightTransaction: {
315
- mode: 'execute-and-discard';
316
- reservesRevision: false;
317
- impact: 'model-diff';
318
- limits: typeof BACKEND_TRANSACTION_PREVIEW_LIMITS;
319
- };
320
- applyTransaction: true;
321
- saveSession: true;
322
- resourceKinds: readonly string[];
323
- nodeKinds: readonly string[];
324
- gearKinds: readonly string[];
325
- transactionScope: {
326
- resourceKinds: readonly string[];
327
- nodeKinds: readonly string[];
328
- gearKinds: readonly string[];
329
- };
330
- unsupported: readonly ['artifact.publish', 'artifact.restore'];
331
- };
332
- artifact: {
333
- publish: false;
334
- restore: false;
335
- status: 'bridge-required';
336
- publishBridge: BackendArtifactBridgeCapability;
337
- restoreBridge: BackendArtifactBridgeCapability;
338
- };
339
- manifest: BackendCapabilityManifest;
340
- compatibilityPolicy: typeof BACKEND_COMPATIBILITY_POLICY;
341
- runtime: {
342
- sessionRuntime: true;
343
- advisoryLocking: true;
344
- coordinatedSave: true;
345
- atomicSave: boolean;
346
- staleRevisionProtection: true;
347
- pathPolicy: {
348
- canonicalization: 'realpath+normalized-casefold';
349
- sessionIdentity: 'project-root';
350
- saveTarget: 'opened-project-only';
351
- outputTargets: 'deferred';
352
- workspaceBoundary: 'project-root-only';
353
- };
354
- events: {
355
- polling: true;
356
- subscriptions: false;
357
- retentionLimit: 1000;
358
- sequenceScope: 'runtime';
359
- };
360
- cache: {
361
- derivedReadOnly: true;
362
- keyedBy: 'sessionId';
363
- refreshMode: 'synchronous';
364
- sourceOfTruth: false;
365
- refreshMethod: 'refreshCache';
366
- };
367
- };
368
- }
369
- interface BackendSessionSnapshot {
370
- sessionId: string;
371
- canonicalProjectPath: string;
372
- revision: number;
373
- lastSavedRevision: number;
374
- dirty: boolean;
375
- uamFidelity: 'full' | 'unsupported';
376
- lockHeld: boolean;
377
- capabilities: BackendCapabilities;
378
- }
379
- interface BackendProjectOutline {
380
- sessionId: string;
381
- revision: number;
382
- projectId: string;
383
- projectType: number;
384
- version: string;
385
- branches: string[];
386
- packages: BackendProjectOutlinePackage[];
387
- }
388
- interface BackendProjectOutlinePackage {
389
- id: string;
390
- name: string;
391
- branchNames: string[];
392
- folders: Array<{
393
- branch: string;
394
- path: string;
395
- }>;
396
- resources: BackendProjectOutlineResource[];
397
- }
398
- interface BackendProjectOutlineResource {
399
- id: string;
400
- name: string;
401
- path: string;
402
- kind: UamResource['kind'];
403
- branch: string;
404
- component?: {
405
- displayList: Array<{
406
- id: string;
407
- name: string;
408
- kind: UamDisplayNodeKind;
409
- }>;
410
- controllers: Array<{
411
- name: string;
412
- pages: Array<{
413
- id: string;
414
- name: string;
415
- }>;
416
- }>;
417
- transitions: Array<{
418
- name: string;
419
- }>;
420
- };
421
- }
422
- interface MaterializeSessionSnapshot extends BackendSessionSnapshot {
423
- mode: 'fullProject';
424
- reason?: string;
425
- materializeRevision: number;
426
- saveRevision: number;
427
- writtenPaths: string[];
428
- skippedPaths: string[];
429
- diagnostics: BackendDiagnostic[];
430
- }
431
- interface BackendSuccess<T> {
432
- ok: true;
433
- meta: BackendResponseMeta;
434
- data: T;
435
- }
436
- interface BackendFailure<E extends BackendError = BackendError> {
437
- ok: false;
438
- meta: BackendResponseMeta;
439
- error: E;
440
- session?: BackendSessionSnapshot;
441
- }
442
- type BackendResult<T, E extends BackendError = BackendError> = BackendSuccess<T> | BackendFailure<E>;
443
- interface SessionNotFoundError {
444
- code: 'session_not_found';
445
- message: string;
446
- sessionId: string;
447
- }
448
- interface SessionCloseFailedError {
449
- code: 'session_close_failed';
450
- message: string;
451
- sessionId: string;
452
- lockFilePath: string;
453
- }
454
- interface SessionStaleWriteError {
455
- code: 'stale_write';
456
- message: string;
457
- sessionId: string;
458
- canonicalPathKey: string;
459
- expectedRevision: number;
460
- actualRevision: number;
461
- }
462
- interface InProcessLockConflictError {
463
- code: 'lock_conflict';
464
- kind: 'in_process_session_exists';
465
- message: string;
466
- canonicalPathKey: string;
467
- holderSessionId: string;
468
- lockFilePath?: string;
469
- }
470
- interface AdvisoryLockConflictError {
471
- code: 'lock_conflict';
472
- kind: 'advisory_lock_conflict';
473
- message: string;
474
- canonicalPathKey: string;
475
- holderSessionId?: string;
476
- lockFilePath: string;
477
- }
478
- interface SessionIdConflictError {
479
- code: 'session_id_conflict';
480
- message: string;
481
- sessionId: string;
482
- }
483
- interface SavePartialFailureError {
484
- code: 'save_partial_failure';
485
- message: string;
486
- sessionId: string;
487
- canonicalPathKey: string;
488
- attemptedRevision: number;
489
- lastSavedRevision: number;
490
- committedPaths: string[];
491
- failedPaths: string[];
492
- diskMayBePartiallyUpdated: boolean;
493
- recoveryPaths?: string[];
494
- }
495
- interface UamFidelityUnsupportedError {
496
- code: 'uam_fidelity_unsupported';
497
- message: string;
498
- sessionId: string;
499
- canonicalPathKey: string;
500
- }
501
- interface MaterializeValidationFailedError {
502
- code: 'materialize_validation_failed';
503
- message: string;
504
- sessionId: string;
505
- canonicalPathKey: string;
506
- issueCount: number;
507
- diagnostics: BackendDiagnostic[];
508
- }
509
- interface MaterializeWriteFailedError {
510
- code: 'write_failed';
511
- message: string;
512
- sessionId: string;
513
- canonicalPathKey: string;
514
- attemptedRevision: number;
515
- lastSavedRevision: number;
516
- writtenPaths: string[];
517
- failedPaths: string[];
518
- skippedPaths: string[];
519
- diagnostics: BackendDiagnostic[];
520
- diskMayBePartiallyUpdated: boolean;
521
- recoveryPaths?: string[];
522
- }
523
- type BackendEventKind = 'session.opened' | 'transaction.applied' | 'transaction.rejected' | 'save.started' | 'save.completed' | 'save.failed' | 'session.closeRequested' | 'session.closed' | 'cache.invalidated' | 'cache.updated';
524
- interface BackendEvent {
525
- sequence: number;
526
- kind: BackendEventKind;
527
- timestamp: string;
528
- sessionId?: string;
529
- canonicalPathKey?: string;
530
- revision?: number;
531
- cacheRevision?: number;
532
- diagnostics: BackendDiagnostic[];
533
- payload?: unknown;
534
- }
535
- interface GetEventsInput {
536
- sessionId: string;
537
- after?: string;
538
- limit?: number;
539
- }
540
- interface GetEventsSnapshot {
541
- events: BackendEvent[];
542
- oldestSequence: number;
543
- currentSequence: number;
544
- cursorExpired: boolean;
545
- }
546
- interface EventCursorInvalidError {
547
- code: 'event_cursor_invalid';
548
- message: string;
549
- sessionId: string;
550
- after: string;
551
- }
552
- interface BackendCapabilityUnavailableError {
553
- code: 'capability_unavailable';
554
- message: string;
555
- capability: 'fileSystem' | 'artifact.publish' | 'artifact.restore';
556
- requiredAdapter?: 'BackendFileSystem';
557
- requiredHost?: 'node';
558
- bridgeBoundary?: 'external-bridge';
559
- }
560
- interface BackendCacheSnapshot {
561
- cacheRevision: number;
562
- entries: BackendCacheEntry[];
563
- }
564
- interface BackendCacheEntry {
565
- canonicalPathKey: string;
566
- sessionId?: string;
567
- revision: number;
568
- lastSavedRevision: number;
569
- dirty: boolean;
570
- valid: boolean;
571
- indexedAt: string;
572
- summary: {
573
- resourceCount: number;
574
- packageCount?: number;
575
- diagnostics: BackendDiagnostic[];
576
- };
577
- }
578
- interface GetCacheSnapshotInput {
579
- sessionId: string;
580
- }
581
- interface RefreshCacheInput {
582
- sessionId: string;
583
- reason?: 'manual' | 'session_open' | 'after_save';
584
- }
585
- type BackendError = SessionNotFoundError | SessionCloseFailedError | TransactionPreviewError | EntityQueryError | SessionReadError | SessionStaleReadError | SessionIdConflictError | SessionStaleWriteError | InProcessLockConflictError | AdvisoryLockConflictError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | EventCursorInvalidError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError | ApplyUamTransactionAppError;
586
- interface ProjectRootNotAllowedError {
587
- code: 'project_root_not_allowed';
588
- message: string;
589
- projectPath: string;
590
- }
591
- interface ProjectOpenFailedError {
592
- code: 'project_open_failed';
593
- message: string;
594
- projectPath: string;
595
- }
596
- interface ApplySessionTransactionInput {
597
- sessionId: string;
598
- expectedRevision: number;
599
- operations: UamTransactionOperation[];
600
- }
601
- interface BackendTransactionPreview {
602
- sessionId: string;
603
- baseRevision: number;
604
- /** Revision after applying this batch at baseRevision, including an empty batch. Not reserved. */
605
- projectedRevision: number;
606
- mode: 'execute-and-discard';
607
- /** Complete, bounded comparison of current and projected UAM, not unsaved changes since last save. */
608
- impact: {
609
- entities: BackendTransactionEntityChange[]; /** Project-relative paths from the actual ProjectWriter, including empty directories. Not a disk write plan. */
610
- files: Array<{
611
- path: string;
612
- kind: 'file' | 'directory';
613
- change: 'added' | 'removed' | 'updated';
614
- }>;
615
- };
616
- persistence: {
617
- requiredAfterApply: true;
618
- nextAction: 'saveSession' | 'materializeSession' | 'host-action';
619
- fileSystemAvailable: boolean;
620
- uamFidelity: BackendSessionSnapshot['uamFidelity']; /** Preflight never verifies filesystem permissions, materialize destinations or actual disk state. */
621
- writeVerified: false;
622
- };
623
- }
624
- interface BackendTransactionEntityChange {
625
- target: BackendEntityTarget;
626
- change: 'added' | 'removed' | 'updated';
627
- /** Changed top-level property names; child collections contain identities and preserve their order. */
628
- fields: string[];
629
- }
630
- interface TransactionPreviewError {
631
- code: 'transaction_preview_failed';
632
- message: string;
633
- sessionId: string;
634
- reason: 'response_budget_exceeded' | 'projection_failed';
635
- }
636
- interface GetProjectOutlineInput {
637
- sessionId: string;
638
- }
639
- interface ValidateSessionInput {
640
- sessionId: string;
641
- }
642
- interface OpenProjectSessionInput {
643
- /** Authoritative UAM project. Use BackendRuntime.openSession() when importing an existing project from storage. */
644
- project: UamProject;
645
- sessionId?: string;
646
- /** Session identity only; without explicit storage or a per-call filesystem this grants no filesystem access. */
647
- canonicalProjectPath?: string;
648
- /** Host-defined session identity; not a filesystem authorization or an allowed-root override. */
649
- canonicalPathKey?: string;
650
- /** Optional writeback target for the authoritative UAM project; this is not an import source. */
651
- storage?: BackendProjectSessionStorage;
652
- }
653
- interface BackendProjectSessionStorage {
654
- fileSystem: BackendFileSystem;
655
- fairyPath: string;
656
- canonicalProjectPath?: string;
657
- canonicalPathKey?: string;
658
- }
659
- interface SaveSessionInput {
660
- sessionId: string;
661
- expectedRevision?: number;
662
- targetPath?: string;
663
- fileSystem?: BackendFileSystem;
664
- force?: boolean;
665
- mode?: 'materializeCleanSession';
666
- }
667
- interface MaterializeSessionInput {
668
- sessionId: string;
669
- expectedRevision?: number;
670
- storage?: BackendProjectSessionStorage;
671
- targetPath?: string;
672
- fileSystem?: BackendFileSystem;
673
- mode?: 'fullProject';
674
- reason?: string;
675
- }
676
- interface BackendRuntimeOptions {
677
- fileSystem?: BackendFileSystem;
678
- host?: BackendHostAdapter;
679
- /** Canonical filesystem roots available to file-backed sessions. Omit for unrestricted library use. */
680
- allowedProjectRoots?: readonly string[];
681
- }
682
- //#endregion
683
- //#region src/runtime.d.ts
684
- declare class BackendRuntime {
685
- private readonly fileSystem?;
686
- private readonly capabilities;
687
- private readonly sessions;
688
- private readonly sessionOperations;
689
- private readonly context;
690
- private readonly readService;
691
- private readonly runtimeService;
692
- private readonly authoringService;
693
- private readonly persistenceService;
694
- private readonly cacheService;
695
- private readonly eventService;
696
- constructor(options?: BackendRuntimeOptions);
697
- getCapabilities(): BackendSuccess<BackendCapabilities>;
698
- openSession(input: {
699
- projectPath: string;
700
- }): Promise<BackendResult<BackendSessionSnapshot, InProcessLockConflictError | AdvisoryLockConflictError | BackendCapabilityUnavailableError | ProjectRootNotAllowedError | ProjectOpenFailedError>>;
701
- openProjectSession(input: OpenProjectSessionInput): BackendResult<BackendSessionSnapshot, InProcessLockConflictError | SessionIdConflictError>;
702
- getSession(input: {
703
- sessionId: string;
704
- }): BackendResult<BackendSessionSnapshot, SessionNotFoundError>;
705
- getProjectOutline(input: GetProjectOutlineInput): BackendResult<BackendProjectOutline, SessionNotFoundError>;
706
- queryEntity(input: QueryEntityInput): BackendResult<BackendEntitySnapshot, SessionNotFoundError | EntityQueryError>;
707
- readSessionState(input: ReadSessionStateInput): BackendResult<BackendSessionStateSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
708
- readResourceBytes(input: ReadResourceBytesInput): BackendResult<BackendResourceBytesSnapshot, SessionNotFoundError | SessionReadError | SessionStaleReadError>;
709
- validateSession(input: ValidateSessionInput): BackendResult<ProjectValidationReport, SessionNotFoundError>;
710
- preflightTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendTransactionPreview, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError | TransactionPreviewError>>;
711
- applyTransaction(input: ApplySessionTransactionInput): Promise<BackendResult<BackendSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | ApplyUamTransactionAppError>>;
712
- saveSession(input: SaveSessionInput): Promise<BackendResult<BackendSessionSnapshot | MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | SavePartialFailureError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
713
- materializeSession(input: MaterializeSessionInput): Promise<BackendResult<MaterializeSessionSnapshot, SessionNotFoundError | SessionStaleWriteError | UamFidelityUnsupportedError | MaterializeValidationFailedError | MaterializeWriteFailedError | PathPolicyViolationError | InProcessLockConflictError | BackendCapabilityUnavailableError>>;
714
- closeSession(input: {
715
- sessionId: string;
716
- }): Promise<BackendResult<{
717
- sessionId: string;
718
- closed: true;
719
- }, SessionNotFoundError | SessionCloseFailedError>>;
720
- getEvents(input: GetEventsInput): BackendResult<GetEventsSnapshot, SessionNotFoundError | EventCursorInvalidError>;
721
- getCacheSnapshot(input: GetCacheSnapshotInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
722
- refreshCache(input: RefreshCacheInput): BackendResult<BackendCacheSnapshot, SessionNotFoundError>;
723
- }
724
- //#endregion
725
3
  //#region src/node.d.ts
726
4
  declare function createNodeBackendFileSystem(): BackendFileSystem;
727
5
  declare function createNodeBackendHostAdapter(): BackendHostAdapter;
728
6
  declare function createNodeBackendRuntime(options?: BackendRuntimeOptions): BackendRuntime;
7
+ /** Resolve a CLI/SDK project input using the same rules as Node sessions. */
8
+ declare function resolveNodeFairyPath(input: string): Promise<string>;
729
9
  //#endregion
730
- export { type BackendFileStat, type BackendFileSystem, type BackendHostAdapter, BackendRuntime, type BackendRuntimeOptions, type BackendSessionLock, createNodeBackendFileSystem, createNodeBackendHostAdapter, createNodeBackendRuntime };
10
+ export { type BackendFileStat, type BackendFileSystem, type BackendHostAdapter, BackendRuntime, type BackendRuntimeOptions, type BackendSessionLock, createNodeBackendFileSystem, createNodeBackendHostAdapter, createNodeBackendRuntime, resolveNodeFairyPath };