@openfairygui/backend 0.2.0-alpha.2 → 0.2.0-alpha.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/backend",
3
- "version": "0.2.0-alpha.2",
3
+ "version": "0.2.0-alpha.21",
4
4
  "description": "FairyGUI Headless Authoring SDK — stateful backend runtime and session services.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -52,12 +52,13 @@
52
52
  "runtime"
53
53
  ],
54
54
  "dependencies": {
55
- "@openfairygui/core": "0.2.0-alpha.2",
56
- "@openfairygui/functions": "0.2.0-alpha.2"
55
+ "@openfairygui/functions": "0.2.0-alpha.21",
56
+ "@openfairygui/core": "0.2.0-alpha.21"
57
57
  },
58
58
  "devDependencies": {
59
59
  "ava": "^7.0.0",
60
- "tsx": "^4.0.0"
60
+ "tsx": "^4.0.0",
61
+ "@openfairygui/test-utils": "0.2.0-alpha.10"
61
62
  },
62
63
  "scripts": {
63
64
  "build": "tsdown src/index.ts src/node.ts --format esm,cjs --platform node --external node:fs --external node:fs/promises --external node:path --env.PACKAGE_VERSION=$npm_package_version",
package/src/contracts.ts CHANGED
@@ -17,6 +17,14 @@ export interface BackendDiagnostic {
17
17
  code: string;
18
18
  message: string;
19
19
  severity: 'info' | 'warning' | 'error';
20
+ path?: string;
21
+ nodeKind?: string;
22
+ resourceKind?: string;
23
+ gearKind?: string;
24
+ field?: string;
25
+ operationKind?: string;
26
+ opIndex?: number;
27
+ opId?: string;
20
28
  }
21
29
 
22
30
  export interface BackendResponseMeta {
package/src/index.ts CHANGED
@@ -1,13 +1,21 @@
1
1
  export {
2
- BackendRuntime,
2
+ BACKEND_CAPABILITY_SCHEMA_VERSION,
3
+ BACKEND_COMPATIBILITY_POLICY,
4
+ BACKEND_CONTRACT_VERSION,
5
+ type BackendDiagnostic,
6
+ type BackendMessage,
7
+ type BackendResponseMeta,
8
+ type BackendStage,
9
+ } from './contracts.js';
10
+ export {
3
11
  type AdvisoryLockConflictError,
4
12
  type ApplySessionTransactionInput,
5
13
  type BackendArtifactBridgeCapability,
6
14
  type BackendCacheEntry,
7
15
  type BackendCacheSnapshot,
16
+ type BackendCapabilities,
8
17
  type BackendCapabilityManifest,
9
18
  type BackendCapabilityUnavailableError,
10
- type BackendCapabilities,
11
19
  type BackendError,
12
20
  type BackendEvent,
13
21
  type BackendEventKind,
@@ -16,6 +24,7 @@ export {
16
24
  type BackendFileStat,
17
25
  type BackendFileSystem,
18
26
  type BackendHostAdapter,
27
+ type BackendJobErrors,
19
28
  type BackendJobKind,
20
29
  type BackendJobListSnapshot,
21
30
  type BackendJobListStatusFilter,
@@ -24,11 +33,12 @@ export {
24
33
  type BackendJobProgress,
25
34
  type BackendJobSnapshot,
26
35
  type BackendJobStatus,
27
- type BackendJobErrors,
36
+ type BackendProjectSessionStorage,
28
37
  type BackendResult,
38
+ BackendRuntime,
39
+ type BackendRuntimeOptions,
29
40
  type BackendSessionSnapshot,
30
41
  type BackendSuccess,
31
- type BackendRuntimeOptions,
32
42
  type CacheRefreshFailedError,
33
43
  type CancelJobInput,
34
44
  type EventCursorInvalidError,
@@ -38,18 +48,21 @@ export {
38
48
  type GetJobInput,
39
49
  type InProcessLockConflictError,
40
50
  type ListJobsInput,
51
+ type MaterializeSessionInput,
52
+ type MaterializeSessionSnapshot,
53
+ type MaterializeValidationFailedError,
54
+ type MaterializeWriteFailedError,
41
55
  type OpenProjectSessionInput,
42
56
  type RefreshCacheInput,
43
57
  type SavePartialFailureError,
58
+ type SaveSessionInput,
44
59
  type SessionNotFoundError,
45
60
  type SessionStaleWriteError,
61
+ type UamFidelityUnsupportedError,
46
62
  } from './runtime.js';
47
63
  export {
48
- type BackendDiagnostic,
49
- type BackendMessage,
50
- type BackendResponseMeta,
51
- type BackendStage,
52
- BACKEND_CAPABILITY_SCHEMA_VERSION,
53
- BACKEND_COMPATIBILITY_POLICY,
54
- BACKEND_CONTRACT_VERSION,
55
- } from './contracts.js';
64
+ type BackendAsyncStorageAdapter,
65
+ type BackendStorageFileSystem,
66
+ type BackendStorageStatLike,
67
+ createBackendStorageFileSystem,
68
+ } from './storage.js';
@@ -0,0 +1,126 @@
1
+ import {
2
+ UAM_SUPPORTED_MATERIALIZATION_SCOPE,
3
+ UAM_SUPPORTED_TRANSACTION_SCOPE,
4
+ } from '@openfairygui/core/uam';
5
+ import {
6
+ BACKEND_CAPABILITY_SCHEMA_VERSION,
7
+ BACKEND_COMPATIBILITY_POLICY,
8
+ BACKEND_CONTRACT_VERSION,
9
+ } from '../contracts.js';
10
+ import { createRuntimePathPolicy } from '../path-policy.js';
11
+ import { createArtifactCapabilities } from '../services/artifact-service.js';
12
+ import type { BackendArtifactBridgeCapability, BackendCapabilities } from './contracts.js';
13
+
14
+ const BACKEND_METHODS = [
15
+ 'getCapabilities',
16
+ 'openSession',
17
+ 'openProjectSession',
18
+ 'getSession',
19
+ 'applyTransaction',
20
+ 'saveSession',
21
+ 'materializeSession',
22
+ 'closeSession',
23
+ 'getEvents',
24
+ 'getJob',
25
+ 'listJobs',
26
+ 'cancelJob',
27
+ 'getCacheSnapshot',
28
+ 'refreshCache',
29
+ ] as const;
30
+
31
+ const ARTIFACT_BRIDGE_CAPABILITY = {
32
+ available: false,
33
+ requiredHost: 'node',
34
+ executionBoundary: 'external-bridge',
35
+ bridgeEntrypoint: '@openfairygui/backend/node',
36
+ reason: 'publish/restore require explicit Node-hosted filesystem and artifact execution.',
37
+ } as const satisfies BackendArtifactBridgeCapability;
38
+
39
+ export function createCapabilities(): BackendCapabilities {
40
+ return {
41
+ contractVersion: BACKEND_CONTRACT_VERSION,
42
+ capabilitySchemaVersion: BACKEND_CAPABILITY_SCHEMA_VERSION,
43
+ transactionKernelOwner: '@openfairygui/core',
44
+ appSeamOwner: '@openfairygui/functions',
45
+ runtimeOwner: '@openfairygui/backend',
46
+ methods: BACKEND_METHODS,
47
+ read: {
48
+ capabilitySnapshot: true,
49
+ sessionSnapshot: true,
50
+ },
51
+ authoring: {
52
+ applyTransaction: true,
53
+ saveSession: true,
54
+ resourceKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
55
+ nodeKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.nodeKinds],
56
+ gearKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.gearKinds],
57
+ transactionScope: {
58
+ resourceKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.resourceKinds],
59
+ nodeKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.nodeKinds],
60
+ gearKinds: [...UAM_SUPPORTED_TRANSACTION_SCOPE.gearKinds],
61
+ },
62
+ unsupported: ['artifact.publish', 'artifact.restore'],
63
+ },
64
+ artifact: createArtifactCapabilities(),
65
+ manifest: {
66
+ browserSafe: true,
67
+ rootEntrypoint: '@openfairygui/backend',
68
+ nodeEntrypoint: '@openfairygui/backend/node',
69
+ adapters: {
70
+ fileSystem: {
71
+ injected: true,
72
+ requiredFor: ['openSession', 'saveSession', 'materializeSession'],
73
+ },
74
+ projectStorage: {
75
+ injected: true,
76
+ browserSafe: true,
77
+ requiredFor: ['openProjectSession.writeback', 'saveSession', 'materializeSession'],
78
+ adapterFactory: 'createBackendStorageFileSystem',
79
+ },
80
+ host: {
81
+ injected: true,
82
+ requiredFor: ['advisoryLockMetadata'],
83
+ },
84
+ },
85
+ executionBoundaries: {
86
+ projectSession: 'in-process-browser-safe',
87
+ fileBackedSession: 'adapter-backed',
88
+ artifactPublish: ARTIFACT_BRIDGE_CAPABILITY,
89
+ artifactRestore: ARTIFACT_BRIDGE_CAPABILITY,
90
+ },
91
+ diagnostics: {
92
+ stableCodes: true,
93
+ errorDiagnosticMirror: true,
94
+ },
95
+ },
96
+ compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
97
+ runtime: {
98
+ sessionRuntime: true,
99
+ advisoryLocking: true,
100
+ coordinatedSave: true,
101
+ atomicSave: false,
102
+ staleRevisionProtection: true,
103
+ pathPolicy: createRuntimePathPolicy(),
104
+ events: {
105
+ polling: true,
106
+ subscriptions: false,
107
+ retentionLimit: 1000,
108
+ sequenceScope: 'runtime',
109
+ },
110
+ jobs: {
111
+ inMemory: true,
112
+ cooperativeCancel: true,
113
+ persistent: false,
114
+ supportedKinds: ['cache.refresh'],
115
+ artifactJobs: false,
116
+ completedRetentionLimit: 100,
117
+ },
118
+ cache: {
119
+ derivedReadOnly: true,
120
+ keyedBy: 'canonicalPathKey',
121
+ sourceOfTruth: false,
122
+ refreshMethod: 'refreshCache',
123
+ },
124
+ },
125
+ };
126
+ }