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