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

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.
@@ -0,0 +1,1217 @@
1
+ require("./node.cjs");
2
+ let _openfairygui_core_uam = require("@openfairygui/core/uam");
3
+ let _openfairygui_core_project_io = require("@openfairygui/core/project-io");
4
+ let _openfairygui_functions_uam = require("@openfairygui/functions/uam");
5
+ //#region src/contracts.ts
6
+ const BACKEND_CONTRACT_VERSION = "1.1.0-p2";
7
+ const BACKEND_CAPABILITY_SCHEMA_VERSION = 2;
8
+ const BACKEND_COMPATIBILITY_POLICY = {
9
+ incompatibleChange: "requires contractVersion bump",
10
+ capabilitySchemaChange: "requires capabilitySchemaVersion bump",
11
+ additiveChange: "allowed without breaking existing consumers"
12
+ };
13
+ //#endregion
14
+ //#region src/path-policy.ts
15
+ function normalizeComparablePath(value) {
16
+ const normalized = value.replace(/[/\\]+$/, "").replace(/\\/g, "/");
17
+ const driveMatch = normalized.match(/^([a-z]:)(?:\/(.*))?$/i);
18
+ const drivePrefix = driveMatch?.[1].toLowerCase() ?? "";
19
+ const remainder = driveMatch ? driveMatch[2] ?? "" : normalized;
20
+ const hasRoot = driveMatch ? true : remainder.startsWith("/");
21
+ const rawSegments = remainder.split("/").filter((segment) => segment.length > 0);
22
+ const segments = [];
23
+ for (const segment of rawSegments) {
24
+ if (segment === ".") continue;
25
+ if (segment === "..") {
26
+ if (segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
27
+ else if (!hasRoot) segments.push("..");
28
+ continue;
29
+ }
30
+ segments.push(segment);
31
+ }
32
+ const joined = segments.join("/");
33
+ return (drivePrefix ? `${drivePrefix}/${joined}`.replace(/\/$/, "") : hasRoot ? `/${joined}`.replace(/\/$/, "") : joined || ".").toLowerCase();
34
+ }
35
+ function createRuntimePathPolicy() {
36
+ return {
37
+ canonicalization: "realpath+normalized-casefold",
38
+ sessionIdentity: "project-root",
39
+ saveTarget: "opened-project-only",
40
+ outputTargets: "deferred",
41
+ workspaceBoundary: "project-root-only"
42
+ };
43
+ }
44
+ async function resolveFairyPath(fileSystem, input) {
45
+ const resolvedInput = fileSystem.resolve(input);
46
+ const stat = await fileSystem.stat(resolvedInput);
47
+ if (stat.isFile() && resolvedInput.endsWith(".fairy")) return await fileSystem.resolvePath(resolvedInput);
48
+ if (stat.isDirectory()) {
49
+ const fairyFiles = (await fileSystem.readdir(resolvedInput)).filter((entry) => entry.endsWith(".fairy"));
50
+ if (fairyFiles.length === 1) return await fileSystem.resolvePath(fileSystem.join(resolvedInput, fairyFiles[0]));
51
+ if (fairyFiles.length > 1) throw new Error(`Multiple .fairy files found in ${resolvedInput}: ${fairyFiles.join(", ")}`);
52
+ throw new Error(`No .fairy file found in ${resolvedInput}`);
53
+ }
54
+ throw new Error(`Input is not a .fairy file or directory: ${resolvedInput}`);
55
+ }
56
+ async function resolveCanonicalProjectRoot(fileSystem, input) {
57
+ const fairyPath = await resolveFairyPath(fileSystem, input);
58
+ const canonicalProjectPath = await fileSystem.resolvePath(fileSystem.dirname(fairyPath));
59
+ return {
60
+ fairyPath,
61
+ canonicalProjectPath,
62
+ canonicalPathKey: normalizeComparablePath(canonicalProjectPath)
63
+ };
64
+ }
65
+ async function validateSaveTarget(fileSystem, openedFairyPath, targetPath) {
66
+ if (!targetPath) return null;
67
+ const attemptedPath = await fileSystem.resolvePath(fileSystem.resolve(targetPath));
68
+ const allowedPath = await fileSystem.resolvePath(openedFairyPath);
69
+ if (normalizeComparablePath(attemptedPath) === normalizeComparablePath(allowedPath)) return null;
70
+ return {
71
+ code: "path_policy_violation",
72
+ message: `Save target is restricted to the originally opened project file: ${allowedPath}`,
73
+ policy: "save_target",
74
+ attemptedPath,
75
+ allowedPath
76
+ };
77
+ }
78
+ //#endregion
79
+ //#region src/services/artifact-service.ts
80
+ function createArtifactCapabilities() {
81
+ const bridge = {
82
+ available: false,
83
+ requiredHost: "node",
84
+ executionBoundary: "external-bridge",
85
+ bridgeEntrypoint: "@openfairygui/backend/node",
86
+ reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
87
+ };
88
+ return {
89
+ publish: false,
90
+ restore: false,
91
+ status: "bridge-required",
92
+ publishBridge: bridge,
93
+ restoreBridge: bridge
94
+ };
95
+ }
96
+ //#endregion
97
+ //#region src/services/context.ts
98
+ function diagnosticFromError(error) {
99
+ return {
100
+ code: error.code,
101
+ message: error.message,
102
+ severity: "error"
103
+ };
104
+ }
105
+ function randomId$1() {
106
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
107
+ }
108
+ function createMeta(stage, startedAt, options) {
109
+ return {
110
+ requestId: options?.requestId ?? randomId$1(),
111
+ sessionId: options?.sessionId,
112
+ revision: options?.revision,
113
+ durationMs: Math.max(0, Date.now() - startedAt),
114
+ warnings: options?.warnings ?? [],
115
+ diagnostics: options?.diagnostics ?? [],
116
+ stage,
117
+ contractVersion: BACKEND_CONTRACT_VERSION,
118
+ capabilitySchemaVersion: 2
119
+ };
120
+ }
121
+ function success(stage, startedAt, data, options) {
122
+ return {
123
+ ok: true,
124
+ meta: createMeta(stage, startedAt, options),
125
+ data
126
+ };
127
+ }
128
+ function failure(stage, startedAt, error, session, options) {
129
+ const diagnostics = options?.diagnostics ?? [diagnosticFromError(error)];
130
+ return {
131
+ ok: false,
132
+ meta: createMeta(stage, startedAt, {
133
+ ...options,
134
+ diagnostics
135
+ }),
136
+ error,
137
+ session
138
+ };
139
+ }
140
+ //#endregion
141
+ //#region src/services/snapshot-utils.ts
142
+ function cloneJsonValue(value) {
143
+ if (value === void 0 || value === null) return value;
144
+ return JSON.parse(JSON.stringify(value));
145
+ }
146
+ function cloneEventSnapshot(event) {
147
+ return {
148
+ ...event,
149
+ diagnostics: event.diagnostics.map((diagnostic) => ({ ...diagnostic })),
150
+ payload: cloneJsonValue(event.payload)
151
+ };
152
+ }
153
+ function cloneJobSnapshot(job) {
154
+ return {
155
+ ...job,
156
+ diagnostics: job.diagnostics.map((diagnostic) => ({ ...diagnostic })),
157
+ progress: job.progress ? { ...job.progress } : void 0,
158
+ result: cloneJsonValue(job.result),
159
+ error: cloneJsonValue(job.error)
160
+ };
161
+ }
162
+ function cloneCacheEntrySnapshot(entry) {
163
+ return {
164
+ ...entry,
165
+ summary: {
166
+ ...entry.summary,
167
+ diagnostics: entry.summary.diagnostics.map((diagnostic) => ({ ...diagnostic }))
168
+ }
169
+ };
170
+ }
171
+ function cloneCapabilitiesSnapshot(capabilities) {
172
+ return cloneJsonValue(capabilities);
173
+ }
174
+ //#endregion
175
+ //#region src/services/session-utils.ts
176
+ function toSessionSnapshot(session, capabilities) {
177
+ return {
178
+ sessionId: session.sessionId,
179
+ canonicalProjectPath: session.canonicalProjectPath,
180
+ revision: session.revision,
181
+ lastSavedRevision: session.lastSavedRevision,
182
+ dirty: session.dirty,
183
+ lockHeld: session.lockHeld,
184
+ capabilities: cloneCapabilitiesSnapshot(capabilities)
185
+ };
186
+ }
187
+ function createSessionNotFoundError(sessionId) {
188
+ return {
189
+ code: "session_not_found",
190
+ message: `Session was not found: ${sessionId}`,
191
+ sessionId
192
+ };
193
+ }
194
+ function createStaleWriteError(session, expectedRevision) {
195
+ return {
196
+ code: "stale_write",
197
+ message: `Expected revision ${expectedRevision} does not match current revision ${session.revision}.`,
198
+ sessionId: session.sessionId,
199
+ canonicalPathKey: session.canonicalPathKey,
200
+ expectedRevision,
201
+ actualRevision: session.revision
202
+ };
203
+ }
204
+ //#endregion
205
+ //#region src/services/authoring-service.ts
206
+ function createWriterFileSystem(fileSystem, committedPaths, failedPaths) {
207
+ async function trackWrite(targetPath, fn) {
208
+ try {
209
+ const result = await fn();
210
+ committedPaths.push(targetPath);
211
+ return result;
212
+ } catch (error) {
213
+ failedPaths.push(targetPath);
214
+ throw error;
215
+ }
216
+ }
217
+ return {
218
+ async readFile(filePath) {
219
+ return fileSystem.readFile(filePath);
220
+ },
221
+ async readFileRaw(filePath) {
222
+ return fileSystem.readFileRaw(filePath);
223
+ },
224
+ async writeFile(filePath, content) {
225
+ await trackWrite(filePath, async () => {
226
+ await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
227
+ await fileSystem.writeFile(filePath, content);
228
+ });
229
+ },
230
+ async writeFileRaw(filePath, data) {
231
+ await trackWrite(filePath, async () => {
232
+ await fileSystem.mkdir(fileSystem.dirname(filePath), { recursive: true });
233
+ await fileSystem.writeFileRaw(filePath, data);
234
+ });
235
+ },
236
+ async mkdir(dirPath) {
237
+ await fileSystem.mkdir(dirPath, { recursive: true });
238
+ },
239
+ async readdir(dirPath) {
240
+ return fileSystem.readdir(dirPath);
241
+ },
242
+ async exists(filePath) {
243
+ try {
244
+ await fileSystem.stat(filePath);
245
+ return true;
246
+ } catch {
247
+ return false;
248
+ }
249
+ },
250
+ join(...paths) {
251
+ return fileSystem.join(...paths);
252
+ },
253
+ dirname(filePath) {
254
+ return fileSystem.dirname(filePath);
255
+ }
256
+ };
257
+ }
258
+ var AuthoringService = class {
259
+ constructor(context, cacheService, eventService) {
260
+ this.context = context;
261
+ this.cacheService = cacheService;
262
+ this.eventService = eventService;
263
+ }
264
+ async applyTransaction(input) {
265
+ const startedAt = Date.now();
266
+ const session = this.context.sessions.get(input.sessionId);
267
+ if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(input.sessionId));
268
+ if (input.expectedRevision !== session.revision) {
269
+ this.eventService.emit({
270
+ kind: "transaction.rejected",
271
+ sessionId: session.sessionId,
272
+ canonicalPathKey: session.canonicalPathKey,
273
+ revision: session.revision
274
+ });
275
+ return failure("authoring", startedAt, createStaleWriteError(session, input.expectedRevision), toSessionSnapshot(session, this.context.capabilities), {
276
+ sessionId: session.sessionId,
277
+ revision: session.revision
278
+ });
279
+ }
280
+ const result = (0, _openfairygui_functions_uam.applyUamTransactionApp)({
281
+ project: session.project,
282
+ operations: input.operations
283
+ });
284
+ if (result.ok === false) {
285
+ this.eventService.emit({
286
+ kind: "transaction.rejected",
287
+ sessionId: session.sessionId,
288
+ canonicalPathKey: session.canonicalPathKey,
289
+ revision: session.revision,
290
+ diagnostics: result.error.issues?.map((issue) => ({
291
+ code: result.error.code,
292
+ message: issue.message,
293
+ severity: "error"
294
+ })) ?? []
295
+ });
296
+ return failure("authoring", startedAt, result.error, toSessionSnapshot(session, this.context.capabilities), {
297
+ sessionId: session.sessionId,
298
+ revision: session.revision
299
+ });
300
+ }
301
+ session.project = result.project;
302
+ session.revision += 1;
303
+ session.dirty = true;
304
+ const cacheEntry = this.cacheService.invalidateSession(session);
305
+ this.eventService.emit({
306
+ kind: "transaction.applied",
307
+ sessionId: session.sessionId,
308
+ canonicalPathKey: session.canonicalPathKey,
309
+ revision: session.revision
310
+ });
311
+ this.eventService.emit({
312
+ kind: "cache.invalidated",
313
+ sessionId: session.sessionId,
314
+ canonicalPathKey: session.canonicalPathKey,
315
+ revision: session.revision,
316
+ cacheRevision: cacheEntry.revision
317
+ });
318
+ return success("authoring", startedAt, toSessionSnapshot(session, this.context.capabilities), {
319
+ sessionId: session.sessionId,
320
+ revision: session.revision
321
+ });
322
+ }
323
+ async saveSession(input) {
324
+ const startedAt = Date.now();
325
+ const session = this.context.sessions.get(input.sessionId);
326
+ if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(input.sessionId));
327
+ if (!this.context.fileSystem) return failure("authoring", startedAt, {
328
+ code: "capability_unavailable",
329
+ message: "saveSession requires an injected BackendFileSystem adapter.",
330
+ capability: "fileSystem",
331
+ requiredAdapter: "BackendFileSystem"
332
+ }, toSessionSnapshot(session, this.context.capabilities), {
333
+ sessionId: session.sessionId,
334
+ revision: session.revision
335
+ });
336
+ if (input.expectedRevision !== void 0 && input.expectedRevision !== session.revision) return failure("authoring", startedAt, createStaleWriteError(session, input.expectedRevision), toSessionSnapshot(session, this.context.capabilities), {
337
+ sessionId: session.sessionId,
338
+ revision: session.revision
339
+ });
340
+ const fileSystem = this.context.fileSystem;
341
+ const targetViolation = await validateSaveTarget(fileSystem, session.fairyPath, input.targetPath);
342
+ if (targetViolation) return failure("authoring", startedAt, targetViolation, toSessionSnapshot(session, this.context.capabilities), {
343
+ sessionId: session.sessionId,
344
+ revision: session.revision
345
+ });
346
+ if (!session.dirty) return success("authoring", startedAt, toSessionSnapshot(session, this.context.capabilities), {
347
+ sessionId: session.sessionId,
348
+ revision: session.revision
349
+ });
350
+ const committedPaths = [];
351
+ const failedPaths = [];
352
+ this.eventService.emit({
353
+ kind: "save.started",
354
+ sessionId: session.sessionId,
355
+ canonicalPathKey: session.canonicalPathKey,
356
+ revision: session.revision
357
+ });
358
+ try {
359
+ await new _openfairygui_core_project_io.ProjectWriter(createWriterFileSystem(fileSystem, committedPaths, failedPaths)).write((0, _openfairygui_core_uam.materializeUamProject)(session.project), session.fairyPath);
360
+ session.lastSavedRevision = session.revision;
361
+ session.dirty = false;
362
+ const cacheEntry = this.cacheService.refreshSession(session);
363
+ this.eventService.emit({
364
+ kind: "save.completed",
365
+ sessionId: session.sessionId,
366
+ canonicalPathKey: session.canonicalPathKey,
367
+ revision: session.revision
368
+ });
369
+ this.eventService.emit({
370
+ kind: "cache.updated",
371
+ sessionId: session.sessionId,
372
+ canonicalPathKey: session.canonicalPathKey,
373
+ revision: session.revision,
374
+ cacheRevision: cacheEntry.revision
375
+ });
376
+ return success("authoring", startedAt, toSessionSnapshot(session, this.context.capabilities), {
377
+ sessionId: session.sessionId,
378
+ revision: session.revision
379
+ });
380
+ } catch (error) {
381
+ this.cacheService.invalidateSession(session);
382
+ this.eventService.emit({
383
+ kind: "save.failed",
384
+ sessionId: session.sessionId,
385
+ canonicalPathKey: session.canonicalPathKey,
386
+ revision: session.revision
387
+ });
388
+ return failure("authoring", startedAt, {
389
+ code: "save_partial_failure",
390
+ message: error instanceof Error ? error.message : String(error),
391
+ sessionId: session.sessionId,
392
+ canonicalPathKey: session.canonicalPathKey,
393
+ attemptedRevision: session.revision,
394
+ lastSavedRevision: session.lastSavedRevision,
395
+ committedPaths,
396
+ failedPaths,
397
+ diskMayBePartiallyUpdated: true
398
+ }, toSessionSnapshot(session, this.context.capabilities), {
399
+ sessionId: session.sessionId,
400
+ revision: session.revision
401
+ });
402
+ }
403
+ }
404
+ };
405
+ //#endregion
406
+ //#region src/services/cache-service.ts
407
+ function createCacheEntry(session, valid) {
408
+ return {
409
+ canonicalPathKey: session.canonicalPathKey,
410
+ sessionId: session.sessionId,
411
+ revision: session.revision,
412
+ lastSavedRevision: session.lastSavedRevision,
413
+ dirty: session.dirty,
414
+ valid,
415
+ indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
416
+ summary: {
417
+ packageCount: session.project.packages.length,
418
+ resourceCount: session.project.packages.reduce((total, pkg) => total + pkg.resources.length, 0),
419
+ diagnostics: []
420
+ }
421
+ };
422
+ }
423
+ var CacheService = class {
424
+ constructor(context) {
425
+ this.context = context;
426
+ }
427
+ getCacheSnapshot(input) {
428
+ const startedAt = Date.now();
429
+ const session = this.context.sessions.get(input.sessionId);
430
+ if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
431
+ const entry = this.context.cacheBySession.get(input.sessionId);
432
+ return success("read", startedAt, {
433
+ cacheRevision: entry?.revision ?? session.revision,
434
+ entries: entry ? [cloneCacheEntrySnapshot(entry)] : []
435
+ }, {
436
+ sessionId: session.sessionId,
437
+ revision: session.revision
438
+ });
439
+ }
440
+ refreshSession(session) {
441
+ const entry = createCacheEntry(session, true);
442
+ this.context.cacheBySession.set(session.sessionId, entry);
443
+ return entry;
444
+ }
445
+ invalidateSession(session) {
446
+ const entry = createCacheEntry(session, false);
447
+ this.context.cacheBySession.set(session.sessionId, entry);
448
+ return entry;
449
+ }
450
+ removeSession(sessionId) {
451
+ this.context.cacheBySession.delete(sessionId);
452
+ }
453
+ };
454
+ //#endregion
455
+ //#region src/services/event-service.ts
456
+ const DEFAULT_EVENT_RETENTION_LIMIT = 1e3;
457
+ var EventService = class {
458
+ constructor(context) {
459
+ this.context = context;
460
+ }
461
+ emit(event) {
462
+ const emitted = {
463
+ ...event,
464
+ sequence: this.context.nextEventSequence(),
465
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
466
+ diagnostics: event.diagnostics ?? []
467
+ };
468
+ const sessionId = event.sessionId;
469
+ if (!sessionId) return emitted;
470
+ const events = this.context.eventsBySession.get(sessionId) ?? [];
471
+ events.push(emitted);
472
+ while (events.length > DEFAULT_EVENT_RETENTION_LIMIT) events.shift();
473
+ this.context.eventsBySession.set(sessionId, events);
474
+ return emitted;
475
+ }
476
+ getEvents(input) {
477
+ const startedAt = Date.now();
478
+ const session = this.context.sessions.get(input.sessionId);
479
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
480
+ const events = this.context.eventsBySession.get(input.sessionId) ?? [];
481
+ const oldestSequence = events[0]?.sequence ?? (events.length === 0 ? 1 : 0);
482
+ const currentSequence = events.at(-1)?.sequence ?? 0;
483
+ const after = input.after === void 0 ? 0 : Number(input.after);
484
+ if (!Number.isInteger(after) || after < 0) return failure("runtime", startedAt, {
485
+ code: "event_cursor_invalid",
486
+ message: `Invalid event cursor: ${input.after}`,
487
+ sessionId: input.sessionId,
488
+ after: String(input.after)
489
+ });
490
+ if (events.length > 0 && after !== 0 && after < oldestSequence - 1) return failure("runtime", startedAt, {
491
+ code: "event_cursor_invalid",
492
+ message: `Event cursor has expired: ${after}`,
493
+ sessionId: input.sessionId,
494
+ after: String(input.after)
495
+ });
496
+ if (after > currentSequence) return failure("runtime", startedAt, {
497
+ code: "event_cursor_invalid",
498
+ message: `Unknown event cursor: ${after}`,
499
+ sessionId: input.sessionId,
500
+ after: String(input.after)
501
+ });
502
+ const filtered = events.filter((event) => event.sequence > after);
503
+ const limit = input.limit === void 0 ? filtered.length : Math.max(0, input.limit);
504
+ return success("runtime", startedAt, {
505
+ events: filtered.slice(0, limit).map(cloneEventSnapshot),
506
+ oldestSequence,
507
+ currentSequence,
508
+ cursorExpired: false
509
+ }, {
510
+ sessionId: session.sessionId,
511
+ revision: session.revision
512
+ });
513
+ }
514
+ removeSession(sessionId) {
515
+ this.context.eventsBySession.delete(sessionId);
516
+ }
517
+ };
518
+ //#endregion
519
+ //#region src/services/job-service.ts
520
+ const COMPLETED_JOB_RETENTION_LIMIT = 100;
521
+ const REFRESH_START_DELAY_MS = 0;
522
+ const REFRESH_COMPLETE_DELAY_MS = 50;
523
+ function isTerminal(status) {
524
+ return status === "completed" || status === "failed" || status === "cancelled";
525
+ }
526
+ var JobService = class {
527
+ constructor(context, cacheService, eventService) {
528
+ this.context = context;
529
+ this.cacheService = cacheService;
530
+ this.eventService = eventService;
531
+ }
532
+ cancellationRequests = /* @__PURE__ */ new Set();
533
+ getJobs(sessionId) {
534
+ return this.context.jobsBySession.get(sessionId) ?? [];
535
+ }
536
+ setJobs(sessionId, jobs) {
537
+ const retained = [];
538
+ let terminalCount = 0;
539
+ for (let index = jobs.length - 1; index >= 0; index -= 1) {
540
+ const job = jobs[index];
541
+ if (isTerminal(job.status)) {
542
+ if (terminalCount >= COMPLETED_JOB_RETENTION_LIMIT) continue;
543
+ terminalCount += 1;
544
+ }
545
+ retained.push(job);
546
+ }
547
+ this.context.jobsBySession.set(sessionId, retained.reverse());
548
+ }
549
+ refreshCache(input) {
550
+ const startedAt = Date.now();
551
+ const session = this.context.sessions.get(input.sessionId);
552
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
553
+ const jobId = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
554
+ const job = {
555
+ jobId,
556
+ kind: "cache.refresh",
557
+ status: "queued",
558
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
559
+ sessionId: session.sessionId,
560
+ canonicalPathKey: session.canonicalPathKey,
561
+ revision: session.revision,
562
+ diagnostics: [],
563
+ progress: {
564
+ completed: 0,
565
+ total: 1,
566
+ message: input.reason ?? "manual"
567
+ }
568
+ };
569
+ const jobs = this.getJobs(session.sessionId);
570
+ jobs.push(job);
571
+ this.setJobs(session.sessionId, jobs);
572
+ this.eventService.emit({
573
+ kind: "job.created",
574
+ sessionId: session.sessionId,
575
+ canonicalPathKey: session.canonicalPathKey,
576
+ revision: session.revision,
577
+ jobId
578
+ });
579
+ this.scheduleRefreshJob(session.sessionId, jobId);
580
+ return success("runtime", startedAt, cloneJobSnapshot(job), {
581
+ sessionId: session.sessionId,
582
+ revision: session.revision
583
+ });
584
+ }
585
+ getJob(input) {
586
+ const startedAt = Date.now();
587
+ const session = this.context.sessions.get(input.sessionId);
588
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
589
+ const job = this.getJobs(input.sessionId).find((item) => item.jobId === input.jobId);
590
+ if (!job) return failure("runtime", startedAt, {
591
+ code: "job_not_found",
592
+ message: `Job was not found: ${input.jobId}`,
593
+ sessionId: input.sessionId,
594
+ jobId: input.jobId
595
+ }, void 0, {
596
+ sessionId: session.sessionId,
597
+ revision: session.revision
598
+ });
599
+ return success("runtime", startedAt, cloneJobSnapshot(job), {
600
+ sessionId: session.sessionId,
601
+ revision: session.revision
602
+ });
603
+ }
604
+ listJobs(input) {
605
+ const startedAt = Date.now();
606
+ const session = this.context.sessions.get(input.sessionId);
607
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
608
+ let jobs = [...this.getJobs(input.sessionId)];
609
+ if (input.kind) jobs = jobs.filter((job) => job.kind === input.kind);
610
+ if (input.status) if (input.status === "active") jobs = jobs.filter((job) => !isTerminal(job.status));
611
+ else if (input.status === "terminal") jobs = jobs.filter((job) => isTerminal(job.status));
612
+ else jobs = jobs.filter((job) => job.status === input.status);
613
+ if (input.limit !== void 0) jobs = jobs.slice(0, Math.max(0, input.limit));
614
+ return success("runtime", startedAt, { jobs: jobs.map(cloneJobSnapshot) }, {
615
+ sessionId: session.sessionId,
616
+ revision: session.revision
617
+ });
618
+ }
619
+ cancelJob(input) {
620
+ const startedAt = Date.now();
621
+ const session = this.context.sessions.get(input.sessionId);
622
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
623
+ const job = this.getJobs(input.sessionId).find((item) => item.jobId === input.jobId);
624
+ if (!job) return failure("runtime", startedAt, {
625
+ code: "job_not_found",
626
+ message: `Job was not found: ${input.jobId}`,
627
+ sessionId: input.sessionId,
628
+ jobId: input.jobId
629
+ }, void 0, {
630
+ sessionId: session.sessionId,
631
+ revision: session.revision
632
+ });
633
+ if (isTerminal(job.status)) return failure("runtime", startedAt, {
634
+ code: "job_not_cancellable",
635
+ message: `Job is already terminal: ${input.jobId}`,
636
+ sessionId: input.sessionId,
637
+ jobId: input.jobId,
638
+ status: job.status
639
+ }, void 0, {
640
+ sessionId: session.sessionId,
641
+ revision: session.revision
642
+ });
643
+ this.cancellationRequests.add(job.jobId);
644
+ this.eventService.emit({
645
+ kind: "job.cancelRequested",
646
+ sessionId: input.sessionId,
647
+ canonicalPathKey: session.canonicalPathKey,
648
+ revision: session.revision,
649
+ jobId: job.jobId
650
+ });
651
+ return success("runtime", startedAt, cloneJobSnapshot(this.cancelRefreshJob(session.sessionId, job)), {
652
+ sessionId: session.sessionId,
653
+ revision: session.revision
654
+ });
655
+ }
656
+ removeSession(sessionId) {
657
+ for (const job of this.getJobs(sessionId)) this.cancellationRequests.delete(job.jobId);
658
+ this.context.jobsBySession.delete(sessionId);
659
+ }
660
+ replaceJob(sessionId, nextJob) {
661
+ const jobs = this.getJobs(sessionId).map((job) => job.jobId === nextJob.jobId ? nextJob : job);
662
+ this.setJobs(sessionId, jobs);
663
+ }
664
+ scheduleRefreshJob(sessionId, jobId) {
665
+ setTimeout(() => this.startRefreshJob(sessionId, jobId), REFRESH_START_DELAY_MS);
666
+ }
667
+ startRefreshJob(sessionId, jobId) {
668
+ const session = this.context.sessions.get(sessionId);
669
+ if (!session || session.closed) return;
670
+ const job = this.getJobs(sessionId).find((item) => item.jobId === jobId);
671
+ if (!job || isTerminal(job.status)) return;
672
+ if (this.cancellationRequests.has(jobId)) {
673
+ this.cancelRefreshJob(sessionId, job);
674
+ return;
675
+ }
676
+ const running = {
677
+ ...job,
678
+ status: "running",
679
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
680
+ progress: {
681
+ completed: 0,
682
+ total: 1,
683
+ message: "refreshing cache"
684
+ }
685
+ };
686
+ this.replaceJob(sessionId, running);
687
+ this.eventService.emit({
688
+ kind: "job.started",
689
+ sessionId,
690
+ canonicalPathKey: session.canonicalPathKey,
691
+ revision: session.revision,
692
+ jobId
693
+ });
694
+ this.eventService.emit({
695
+ kind: "job.progress",
696
+ sessionId,
697
+ canonicalPathKey: session.canonicalPathKey,
698
+ revision: session.revision,
699
+ jobId,
700
+ payload: running.progress
701
+ });
702
+ setTimeout(() => this.completeRefreshJob(sessionId, jobId), REFRESH_COMPLETE_DELAY_MS);
703
+ }
704
+ completeRefreshJob(sessionId, jobId) {
705
+ const session = this.context.sessions.get(sessionId);
706
+ if (!session || session.closed) return;
707
+ const job = this.getJobs(sessionId).find((item) => item.jobId === jobId);
708
+ if (!job || isTerminal(job.status)) return;
709
+ if (this.cancellationRequests.has(jobId)) {
710
+ this.cancelRefreshJob(sessionId, job);
711
+ return;
712
+ }
713
+ try {
714
+ const entry = this.cacheService.refreshSession(session);
715
+ const completed = {
716
+ ...job,
717
+ status: "completed",
718
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
719
+ cacheRevision: entry.revision,
720
+ progress: {
721
+ completed: 1,
722
+ total: 1,
723
+ message: "cache refreshed"
724
+ },
725
+ result: { cacheRevision: entry.revision }
726
+ };
727
+ this.replaceJob(sessionId, completed);
728
+ this.eventService.emit({
729
+ kind: "job.completed",
730
+ sessionId,
731
+ canonicalPathKey: session.canonicalPathKey,
732
+ revision: session.revision,
733
+ cacheRevision: entry.revision,
734
+ jobId
735
+ });
736
+ this.eventService.emit({
737
+ kind: "cache.updated",
738
+ sessionId,
739
+ canonicalPathKey: session.canonicalPathKey,
740
+ revision: session.revision,
741
+ cacheRevision: entry.revision
742
+ });
743
+ } catch (error) {
744
+ const failed = {
745
+ ...job,
746
+ status: "failed",
747
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
748
+ error: {
749
+ code: "cache_refresh_failed",
750
+ message: error instanceof Error ? error.message : "Cache refresh failed",
751
+ sessionId,
752
+ jobId
753
+ }
754
+ };
755
+ this.replaceJob(sessionId, failed);
756
+ this.eventService.emit({
757
+ kind: "job.failed",
758
+ sessionId,
759
+ canonicalPathKey: session.canonicalPathKey,
760
+ revision: session.revision,
761
+ jobId,
762
+ diagnostics: failed.diagnostics
763
+ });
764
+ }
765
+ }
766
+ cancelRefreshJob(sessionId, job) {
767
+ const session = this.context.sessions.get(sessionId);
768
+ const cancelled = {
769
+ ...job,
770
+ status: "cancelled",
771
+ finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
772
+ error: {
773
+ code: "job_cancelled",
774
+ message: `Job was cancelled: ${job.jobId}`,
775
+ sessionId,
776
+ jobId: job.jobId
777
+ }
778
+ };
779
+ this.replaceJob(sessionId, cancelled);
780
+ this.cancellationRequests.delete(job.jobId);
781
+ this.eventService.emit({
782
+ kind: "job.cancelled",
783
+ sessionId,
784
+ canonicalPathKey: session?.canonicalPathKey ?? job.canonicalPathKey,
785
+ revision: session?.revision ?? job.revision,
786
+ jobId: job.jobId
787
+ });
788
+ return cancelled;
789
+ }
790
+ };
791
+ //#endregion
792
+ //#region src/services/read-service.ts
793
+ var ReadService = class {
794
+ constructor(context) {
795
+ this.context = context;
796
+ }
797
+ getCapabilities() {
798
+ return success("read", Date.now(), cloneCapabilitiesSnapshot(this.context.capabilities));
799
+ }
800
+ getSession(input) {
801
+ const startedAt = Date.now();
802
+ const session = this.context.sessions.get(input.sessionId);
803
+ if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
804
+ return success("read", startedAt, toSessionSnapshot(session, this.context.capabilities), {
805
+ sessionId: session.sessionId,
806
+ revision: session.revision
807
+ });
808
+ }
809
+ };
810
+ //#endregion
811
+ //#region src/services/runtime-service.ts
812
+ function randomId() {
813
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
814
+ }
815
+ function createCapabilityUnavailableError(capability) {
816
+ const artifactCapability = capability === "artifact.publish" || capability === "artifact.restore";
817
+ return {
818
+ code: "capability_unavailable",
819
+ message: artifactCapability ? `${capability} requires the Node bridge boundary exposed by @openfairygui/backend/node.` : `${capability} requires an injected BackendFileSystem adapter.`,
820
+ capability,
821
+ requiredAdapter: capability === "fileSystem" ? "BackendFileSystem" : void 0,
822
+ requiredHost: artifactCapability ? "node" : void 0,
823
+ bridgeBoundary: artifactCapability ? "external-bridge" : void 0
824
+ };
825
+ }
826
+ function createProjectReaderFileSystem(fileSystem) {
827
+ return {
828
+ readFile(filePath) {
829
+ return fileSystem.readFile(filePath);
830
+ },
831
+ readFileRaw(filePath) {
832
+ return fileSystem.readFileRaw(filePath);
833
+ },
834
+ writeFile(filePath, content) {
835
+ return fileSystem.writeFile(filePath, content);
836
+ },
837
+ writeFileRaw(filePath, data) {
838
+ return fileSystem.writeFileRaw(filePath, data);
839
+ },
840
+ async mkdir(dirPath) {
841
+ await fileSystem.mkdir(dirPath, { recursive: true });
842
+ },
843
+ readdir(dirPath) {
844
+ return fileSystem.readdir(dirPath);
845
+ },
846
+ async exists(filePath) {
847
+ try {
848
+ await fileSystem.stat(filePath);
849
+ return true;
850
+ } catch {
851
+ return false;
852
+ }
853
+ },
854
+ join(...paths) {
855
+ return fileSystem.join(...paths);
856
+ },
857
+ dirname(filePath) {
858
+ return fileSystem.dirname(filePath);
859
+ }
860
+ };
861
+ }
862
+ var RuntimeService = class {
863
+ constructor(context, cacheService, eventService, jobService) {
864
+ this.context = context;
865
+ this.cacheService = cacheService;
866
+ this.eventService = eventService;
867
+ this.jobService = jobService;
868
+ }
869
+ async openSession(input) {
870
+ const startedAt = Date.now();
871
+ if (!this.context.fileSystem) return failure("runtime", startedAt, createCapabilityUnavailableError("fileSystem"));
872
+ const fileSystem = this.context.fileSystem;
873
+ const { fairyPath, canonicalProjectPath, canonicalPathKey } = await resolveCanonicalProjectRoot(fileSystem, input.projectPath);
874
+ const existingSessionId = this.context.sessionsByPath.get(canonicalPathKey);
875
+ const lockFilePath = fileSystem.join(canonicalProjectPath, ".openfairygui.backend.lock");
876
+ if (existingSessionId) return failure("runtime", startedAt, {
877
+ code: "lock_conflict",
878
+ kind: "in_process_session_exists",
879
+ message: `Project is already open in this backend runtime: ${canonicalProjectPath}`,
880
+ canonicalPathKey,
881
+ holderSessionId: existingSessionId,
882
+ lockFilePath
883
+ });
884
+ let advisoryLock = null;
885
+ try {
886
+ advisoryLock = await fileSystem.openExclusive(lockFilePath);
887
+ await advisoryLock.writeFile(JSON.stringify(this.context.host?.lockMetadata?.({
888
+ canonicalPathKey,
889
+ canonicalProjectPath,
890
+ lockFilePath
891
+ }) ?? {
892
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
893
+ canonicalPathKey
894
+ }));
895
+ await advisoryLock.close();
896
+ const project = (0, _openfairygui_core_uam.liftDocumentToUamProject)(await new _openfairygui_core_project_io.ProjectReader(createProjectReaderFileSystem(fileSystem)).read(fairyPath));
897
+ const sessionId = randomId();
898
+ const session = {
899
+ sessionId,
900
+ fairyPath,
901
+ canonicalProjectPath,
902
+ canonicalPathKey,
903
+ lockFilePath,
904
+ project,
905
+ revision: 0,
906
+ lastSavedRevision: 0,
907
+ dirty: false,
908
+ lockHeld: true,
909
+ closed: false
910
+ };
911
+ this.context.sessions.set(sessionId, session);
912
+ this.context.sessionsByPath.set(canonicalPathKey, sessionId);
913
+ this.cacheService.refreshSession(session);
914
+ this.eventService.emit({
915
+ kind: "session.opened",
916
+ sessionId,
917
+ canonicalPathKey,
918
+ revision: session.revision
919
+ });
920
+ return success("runtime", startedAt, toSessionSnapshot(session, this.context.capabilities), {
921
+ sessionId: session.sessionId,
922
+ revision: session.revision
923
+ });
924
+ } catch (error) {
925
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST") return failure("runtime", startedAt, {
926
+ code: "lock_conflict",
927
+ kind: "advisory_lock_conflict",
928
+ message: `Advisory lock already exists for project: ${canonicalProjectPath}`,
929
+ canonicalPathKey,
930
+ lockFilePath
931
+ });
932
+ if (advisoryLock) {
933
+ await advisoryLock.close().catch(() => void 0);
934
+ await fileSystem.unlink(lockFilePath).catch(() => void 0);
935
+ }
936
+ throw error;
937
+ }
938
+ }
939
+ openProjectSession(input) {
940
+ const startedAt = Date.now();
941
+ const sessionId = input.sessionId ?? randomId();
942
+ const canonicalProjectPath = input.canonicalProjectPath ?? `memory://${sessionId}`;
943
+ const canonicalPathKey = input.canonicalPathKey ?? canonicalProjectPath.toLowerCase();
944
+ const existingSessionId = this.context.sessionsByPath.get(canonicalPathKey);
945
+ if (existingSessionId) return failure("runtime", startedAt, {
946
+ code: "lock_conflict",
947
+ kind: "in_process_session_exists",
948
+ message: `Project is already open in this backend runtime: ${canonicalProjectPath}`,
949
+ canonicalPathKey,
950
+ holderSessionId: existingSessionId
951
+ });
952
+ const session = {
953
+ sessionId,
954
+ fairyPath: canonicalProjectPath,
955
+ canonicalProjectPath,
956
+ canonicalPathKey,
957
+ lockFilePath: "",
958
+ project: (0, _openfairygui_core_uam.normalizeUamProject)(input.project),
959
+ revision: 0,
960
+ lastSavedRevision: 0,
961
+ dirty: false,
962
+ lockHeld: false,
963
+ closed: false
964
+ };
965
+ this.context.sessions.set(sessionId, session);
966
+ this.context.sessionsByPath.set(canonicalPathKey, sessionId);
967
+ this.cacheService.refreshSession(session);
968
+ this.eventService.emit({
969
+ kind: "session.opened",
970
+ sessionId,
971
+ canonicalPathKey,
972
+ revision: session.revision
973
+ });
974
+ return success("runtime", startedAt, toSessionSnapshot(session, this.context.capabilities), {
975
+ sessionId: session.sessionId,
976
+ revision: session.revision
977
+ });
978
+ }
979
+ async closeSession(input) {
980
+ const startedAt = Date.now();
981
+ const session = this.context.sessions.get(input.sessionId);
982
+ if (!session || session.closed) return failure("runtime", startedAt, createSessionNotFoundError(input.sessionId));
983
+ this.eventService.emit({
984
+ kind: "session.closeRequested",
985
+ sessionId: session.sessionId,
986
+ canonicalPathKey: session.canonicalPathKey,
987
+ revision: session.revision
988
+ });
989
+ if (this.context.fileSystem && session.lockFilePath) await this.context.fileSystem.unlink(session.lockFilePath).catch(() => void 0);
990
+ session.lockHeld = false;
991
+ session.closed = true;
992
+ this.context.sessions.delete(session.sessionId);
993
+ this.context.sessionsByPath.delete(session.canonicalPathKey);
994
+ this.cacheService.removeSession(session.sessionId);
995
+ this.jobService.removeSession(session.sessionId);
996
+ this.eventService.emit({
997
+ kind: "session.closed",
998
+ sessionId: session.sessionId,
999
+ canonicalPathKey: session.canonicalPathKey,
1000
+ revision: session.revision
1001
+ });
1002
+ this.eventService.removeSession(session.sessionId);
1003
+ return success("runtime", startedAt, {
1004
+ sessionId: session.sessionId,
1005
+ closed: true
1006
+ }, {
1007
+ sessionId: session.sessionId,
1008
+ revision: session.revision
1009
+ });
1010
+ }
1011
+ };
1012
+ //#endregion
1013
+ //#region src/runtime.ts
1014
+ const BACKEND_METHODS = [
1015
+ "getCapabilities",
1016
+ "openSession",
1017
+ "openProjectSession",
1018
+ "getSession",
1019
+ "applyTransaction",
1020
+ "saveSession",
1021
+ "closeSession",
1022
+ "getEvents",
1023
+ "getJob",
1024
+ "listJobs",
1025
+ "cancelJob",
1026
+ "getCacheSnapshot",
1027
+ "refreshCache"
1028
+ ];
1029
+ const ARTIFACT_BRIDGE_CAPABILITY = {
1030
+ available: false,
1031
+ requiredHost: "node",
1032
+ executionBoundary: "external-bridge",
1033
+ bridgeEntrypoint: "@openfairygui/backend/node",
1034
+ reason: "publish/restore require explicit Node-hosted filesystem and artifact execution."
1035
+ };
1036
+ function createCapabilities() {
1037
+ return {
1038
+ contractVersion: BACKEND_CONTRACT_VERSION,
1039
+ capabilitySchemaVersion: 2,
1040
+ transactionKernelOwner: "@openfairygui/core",
1041
+ appSeamOwner: "@openfairygui/functions",
1042
+ runtimeOwner: "@openfairygui/backend",
1043
+ methods: BACKEND_METHODS,
1044
+ read: {
1045
+ capabilitySnapshot: true,
1046
+ sessionSnapshot: true
1047
+ },
1048
+ authoring: {
1049
+ applyTransaction: true,
1050
+ saveSession: true,
1051
+ resourceKinds: [..._openfairygui_core_uam.UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
1052
+ nodeKinds: [..._openfairygui_core_uam.UAM_SUPPORTED_MATERIALIZATION_SCOPE.nodeKinds],
1053
+ gearKinds: [..._openfairygui_core_uam.UAM_SUPPORTED_MATERIALIZATION_SCOPE.gearKinds],
1054
+ unsupported: ["artifact.publish", "artifact.restore"]
1055
+ },
1056
+ artifact: createArtifactCapabilities(),
1057
+ manifest: {
1058
+ browserSafe: true,
1059
+ rootEntrypoint: "@openfairygui/backend",
1060
+ nodeEntrypoint: "@openfairygui/backend/node",
1061
+ adapters: {
1062
+ fileSystem: {
1063
+ injected: true,
1064
+ requiredFor: ["openSession", "saveSession"]
1065
+ },
1066
+ host: {
1067
+ injected: true,
1068
+ requiredFor: ["advisoryLockMetadata"]
1069
+ }
1070
+ },
1071
+ executionBoundaries: {
1072
+ projectSession: "in-process-browser-safe",
1073
+ fileBackedSession: "adapter-backed",
1074
+ artifactPublish: ARTIFACT_BRIDGE_CAPABILITY,
1075
+ artifactRestore: ARTIFACT_BRIDGE_CAPABILITY
1076
+ },
1077
+ diagnostics: {
1078
+ stableCodes: true,
1079
+ errorDiagnosticMirror: true
1080
+ }
1081
+ },
1082
+ compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
1083
+ runtime: {
1084
+ sessionRuntime: true,
1085
+ advisoryLocking: true,
1086
+ coordinatedSave: true,
1087
+ atomicSave: false,
1088
+ staleRevisionProtection: true,
1089
+ pathPolicy: createRuntimePathPolicy(),
1090
+ events: {
1091
+ polling: true,
1092
+ subscriptions: false,
1093
+ retentionLimit: 1e3,
1094
+ sequenceScope: "runtime"
1095
+ },
1096
+ jobs: {
1097
+ inMemory: true,
1098
+ cooperativeCancel: true,
1099
+ persistent: false,
1100
+ supportedKinds: ["cache.refresh"],
1101
+ artifactJobs: false,
1102
+ completedRetentionLimit: 100
1103
+ },
1104
+ cache: {
1105
+ derivedReadOnly: true,
1106
+ keyedBy: "canonicalPathKey",
1107
+ sourceOfTruth: false,
1108
+ refreshMethod: "refreshCache"
1109
+ }
1110
+ }
1111
+ };
1112
+ }
1113
+ var BackendRuntime = class {
1114
+ fileSystem;
1115
+ capabilities;
1116
+ sessions = /* @__PURE__ */ new Map();
1117
+ sessionsByPath = /* @__PURE__ */ new Map();
1118
+ eventsBySession = /* @__PURE__ */ new Map();
1119
+ jobsBySession = /* @__PURE__ */ new Map();
1120
+ cacheBySession = /* @__PURE__ */ new Map();
1121
+ eventSequence = 0;
1122
+ context;
1123
+ readService;
1124
+ runtimeService;
1125
+ authoringService;
1126
+ cacheService;
1127
+ eventService;
1128
+ jobService;
1129
+ constructor(options = {}) {
1130
+ this.fileSystem = options.fileSystem;
1131
+ this.capabilities = createCapabilities();
1132
+ this.context = {
1133
+ fileSystem: this.fileSystem,
1134
+ host: options.host,
1135
+ capabilities: this.capabilities,
1136
+ sessions: this.sessions,
1137
+ sessionsByPath: this.sessionsByPath,
1138
+ eventsBySession: this.eventsBySession,
1139
+ jobsBySession: this.jobsBySession,
1140
+ cacheBySession: this.cacheBySession,
1141
+ nextEventSequence: () => {
1142
+ this.eventSequence += 1;
1143
+ return this.eventSequence;
1144
+ }
1145
+ };
1146
+ this.readService = new ReadService(this.context);
1147
+ this.eventService = new EventService(this.context);
1148
+ this.cacheService = new CacheService(this.context);
1149
+ this.jobService = new JobService(this.context, this.cacheService, this.eventService);
1150
+ this.runtimeService = new RuntimeService(this.context, this.cacheService, this.eventService, this.jobService);
1151
+ this.authoringService = new AuthoringService(this.context, this.cacheService, this.eventService);
1152
+ }
1153
+ getCapabilities() {
1154
+ return this.readService.getCapabilities();
1155
+ }
1156
+ async openSession(input) {
1157
+ return this.runtimeService.openSession(input);
1158
+ }
1159
+ openProjectSession(input) {
1160
+ return this.runtimeService.openProjectSession(input);
1161
+ }
1162
+ getSession(input) {
1163
+ return this.readService.getSession(input);
1164
+ }
1165
+ async applyTransaction(input) {
1166
+ return this.authoringService.applyTransaction(input);
1167
+ }
1168
+ async saveSession(input) {
1169
+ return this.authoringService.saveSession(input);
1170
+ }
1171
+ async closeSession(input) {
1172
+ return this.runtimeService.closeSession(input);
1173
+ }
1174
+ getEvents(input) {
1175
+ return this.eventService.getEvents(input);
1176
+ }
1177
+ getJob(input) {
1178
+ return this.jobService.getJob(input);
1179
+ }
1180
+ listJobs(input) {
1181
+ return this.jobService.listJobs(input);
1182
+ }
1183
+ cancelJob(input) {
1184
+ return this.jobService.cancelJob(input);
1185
+ }
1186
+ getCacheSnapshot(input) {
1187
+ return this.cacheService.getCacheSnapshot(input);
1188
+ }
1189
+ refreshCache(input) {
1190
+ return this.jobService.refreshCache(input);
1191
+ }
1192
+ };
1193
+ //#endregion
1194
+ Object.defineProperty(exports, "BACKEND_CAPABILITY_SCHEMA_VERSION", {
1195
+ enumerable: true,
1196
+ get: function() {
1197
+ return BACKEND_CAPABILITY_SCHEMA_VERSION;
1198
+ }
1199
+ });
1200
+ Object.defineProperty(exports, "BACKEND_COMPATIBILITY_POLICY", {
1201
+ enumerable: true,
1202
+ get: function() {
1203
+ return BACKEND_COMPATIBILITY_POLICY;
1204
+ }
1205
+ });
1206
+ Object.defineProperty(exports, "BACKEND_CONTRACT_VERSION", {
1207
+ enumerable: true,
1208
+ get: function() {
1209
+ return BACKEND_CONTRACT_VERSION;
1210
+ }
1211
+ });
1212
+ Object.defineProperty(exports, "BackendRuntime", {
1213
+ enumerable: true,
1214
+ get: function() {
1215
+ return BackendRuntime;
1216
+ }
1217
+ });