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