@openfairygui/backend 0.3.1 → 0.5.0-alpha.1
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/README.md +1 -0
- package/dist/docs.cjs +16687 -0
- package/dist/docs.d.cts +297 -0
- package/dist/docs.d.mts +297 -0
- package/dist/docs.mjs +16677 -0
- package/dist/index.cjs +1239 -68
- package/dist/index.d.cts +1934 -43
- package/dist/index.d.mts +1934 -43
- package/dist/index.mjs +1233 -69
- package/dist/node.cjs +1220 -67
- package/dist/node.d.cts +221 -7
- package/dist/node.d.mts +221 -7
- package/dist/node.mjs +1220 -67
- package/docs/skills/openfairygui/SKILL.md +16 -0
- package/docs/workflow.md +60 -0
- package/package.json +15 -4
- package/src/contracts.ts +21 -3
- package/src/diagnostics.ts +189 -0
- package/src/docs.ts +109 -0
- package/src/generated/contracts.ts +24782 -0
- package/src/generated/docs.ts +12 -0
- package/src/index.ts +34 -0
- package/src/runtime/capabilities.ts +14 -3
- package/src/runtime/contracts.ts +166 -18
- package/src/runtime.ts +29 -0
- package/src/services/authoring-service.ts +48 -3
- package/src/services/capture-project.ts +75 -0
- package/src/services/context.ts +2 -1
- package/src/services/event-service.ts +2 -1
- package/src/services/read-service.ts +169 -1
- package/src/services/runtime-service.ts +1 -65
- package/src/services/transaction-preview.ts +114 -0
package/dist/node.cjs
CHANGED
|
@@ -108,13 +108,638 @@ async function validateSaveTarget(fileSystem, openedFairyPath, targetPath) {
|
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region src/contracts.ts
|
|
111
|
-
const BACKEND_CONTRACT_VERSION = "
|
|
111
|
+
const BACKEND_CONTRACT_VERSION = "2.0.0-p2";
|
|
112
112
|
const BACKEND_COMPATIBILITY_POLICY = {
|
|
113
113
|
incompatibleChange: "requires contractVersion bump",
|
|
114
114
|
capabilitySchemaChange: "requires capabilitySchemaVersion bump",
|
|
115
115
|
additiveChange: "allowed without breaking existing consumers"
|
|
116
116
|
};
|
|
117
117
|
//#endregion
|
|
118
|
+
//#region src/diagnostics.ts
|
|
119
|
+
const selector = {
|
|
120
|
+
kind: "revise-selector",
|
|
121
|
+
message: "Read the current outline and query the relevant entity. Use its exact identifiers, inspect the reported selector path, then rebuild and preflight the transaction. Do not guess identifiers or retry the unchanged transaction."
|
|
122
|
+
};
|
|
123
|
+
const source = {
|
|
124
|
+
kind: "host-action",
|
|
125
|
+
message: "Ask the host to inspect the reported source and hydrate its bytes through project I/O or import. Preserve unsaved work; reopening disk state can discard it. No session hydration/repair API is exposed. Revalidate and replan after the host has supplied a complete project."
|
|
126
|
+
};
|
|
127
|
+
const path$1 = {
|
|
128
|
+
kind: "host-action",
|
|
129
|
+
message: "Ask the host to review the attempted path and authorized project root. saveSession only writes the original project; it is not Save As. Do not widen allowed roots or bypass path checks. A separately authorized export may use materializeSession."
|
|
130
|
+
};
|
|
131
|
+
const unsupported = {
|
|
132
|
+
kind: "revise-operation",
|
|
133
|
+
message: "Read the operation schema, capabilities and reported target kind/field. Stop unsupported work or replan using supported operations with equivalent intended semantics. Never silently drop fields or objects to make a transaction pass."
|
|
134
|
+
};
|
|
135
|
+
const payload = {
|
|
136
|
+
kind: "revise-operation",
|
|
137
|
+
message: "Inspect the diagnostic path and current operation schema or UAM issues. Correct values, required fields and indices against exact queried entities, then preflight. Do not invent defaults or coerce away invalid data."
|
|
138
|
+
};
|
|
139
|
+
const unchanged = {
|
|
140
|
+
kind: "refresh-and-replan",
|
|
141
|
+
message: "Query current settings/entity and compare with the request. If already satisfied, report no change; otherwise replan from the current revision. Do not manufacture a mutation or resubmit the same no-op."
|
|
142
|
+
};
|
|
143
|
+
const duplicate = {
|
|
144
|
+
kind: "revise-operation",
|
|
145
|
+
message: "Query current entities and resolve the conflicting ID, name or page explicitly. Choose an unused value only when authorized by the intended edit, then preflight. Never overwrite or delete an existing entity to clear the conflict."
|
|
146
|
+
};
|
|
147
|
+
const references = {
|
|
148
|
+
kind: "revise-operation",
|
|
149
|
+
message: "Query affected entities and references before editing, moving or removing anything. Replan intended dependent changes together and preflight. Do not delete dependent objects or strip references without authorization."
|
|
150
|
+
};
|
|
151
|
+
const project = {
|
|
152
|
+
kind: "host-action",
|
|
153
|
+
message: "Inspect the project path and validation diagnostics with the host. Correct source XML/settings or unsupported geometry using authoritative project data; preserve originals and unsaved work before reopening or validating. Do not guess missing structure or discard rejected content."
|
|
154
|
+
};
|
|
155
|
+
const capability = {
|
|
156
|
+
kind: "host-action",
|
|
157
|
+
message: "Read capability/error details. Ask the host to provide the required filesystem, decoder or complete UAM adapter. Preserve the session and unsaved work; do not substitute a lossy path or bypass checks."
|
|
158
|
+
};
|
|
159
|
+
const write = {
|
|
160
|
+
kind: "host-action",
|
|
161
|
+
message: "Preserve the dirty session and inspect the error, actual target files and permissions with the host. Partial writes may have changed files: verify or recover them before a newly authorized save. Do not clear dirty state, discard memory or blindly retry."
|
|
162
|
+
};
|
|
163
|
+
const execution = {
|
|
164
|
+
kind: "host-action",
|
|
165
|
+
message: "Inspect the execution/cache failure and current session/revision. Preserve sources and unsaved work and report the cause to the host. Replan after resolution; failed execution or cache work is not a completed edit."
|
|
166
|
+
};
|
|
167
|
+
const job = {
|
|
168
|
+
kind: "host-action",
|
|
169
|
+
message: "Inspect the job ID and status with getJob/listJobs. Do not fabricate, restart or force-cancel a missing, terminal or non-cancellable job. Ask the host before scheduling new work; cancellation is not success."
|
|
170
|
+
};
|
|
171
|
+
/** Exhaustiveness and exact ownership are checked against the canonical unions. */
|
|
172
|
+
const BACKEND_DIAGNOSTIC_GUIDES = [
|
|
173
|
+
{
|
|
174
|
+
code: "stale_read",
|
|
175
|
+
owners: ["backend"],
|
|
176
|
+
remediation: {
|
|
177
|
+
kind: "refresh-and-replan",
|
|
178
|
+
message: "Discard the incomplete model/bytes read and restart with readSessionState. Use its revision for every readResourceBytes call. No historical state is retained or reserved; do not combine resources from different edit revisions."
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
code: "session_read_failed",
|
|
183
|
+
owners: ["backend"],
|
|
184
|
+
remediation: {
|
|
185
|
+
kind: "host-action",
|
|
186
|
+
message: "Inspect error.reason: invalid_query requires valid inputs; not_found/ambiguous requires exact current resource identifiers; unsupported_resource/bytes_unavailable means primary bytes cannot be read from this session. Budget or non-JSON failures require host inspection. Preserve unsaved work; do not save, reopen, repair or mutate the model merely to obtain a read."
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
code: "transaction_preview_failed",
|
|
191
|
+
owners: ["backend"],
|
|
192
|
+
remediation: {
|
|
193
|
+
kind: "host-action",
|
|
194
|
+
message: "No complete preview is available. Inspect error.reason with the host: response_budget_exceeded requires a smaller independently meaningful authorized batch; projection_failed requires inspecting the project serialization failure. Preserve the session and never treat a missing or truncated impact as approval to apply or save."
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
code: "stale_write",
|
|
199
|
+
owners: ["backend"],
|
|
200
|
+
remediation: {
|
|
201
|
+
kind: "refresh-and-replan",
|
|
202
|
+
message: "Refresh the outline and affected entities, then replan from their current revision and preflight again. A preview reserves no revision. Never replace expectedRevision and blindly retry the original transaction or save."
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
code: "entity_query_failed",
|
|
207
|
+
owners: ["backend"],
|
|
208
|
+
remediation: {
|
|
209
|
+
kind: "host-action",
|
|
210
|
+
message: "Inspect error.reason: invalid_query requires correcting the target; not_found/ambiguous requires current exact identifiers; response_budget_exceeded/non_json_value requires host inspection of the entity. Do not broaden queries or mutate data to evade the response limits."
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
code: "session_not_found",
|
|
215
|
+
owners: ["backend"],
|
|
216
|
+
remediation: {
|
|
217
|
+
kind: "host-action",
|
|
218
|
+
message: "Ask the host to confirm the runtime and project, recover any unsaved state, then explicitly open a new session if appropriate. Session IDs are runtime-local. Read its new revision and replan; never reuse an expired session or assume disk contains unsaved changes."
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
code: "path_policy_violation",
|
|
223
|
+
owners: ["backend"],
|
|
224
|
+
remediation: path$1
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
code: "project_root_not_allowed",
|
|
228
|
+
owners: ["backend"],
|
|
229
|
+
remediation: path$1
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
code: "invalid_package_selector",
|
|
233
|
+
owners: ["core.transaction"],
|
|
234
|
+
remediation: selector
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
code: "invalid_component_selector",
|
|
238
|
+
owners: ["core.transaction"],
|
|
239
|
+
remediation: selector
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
code: "invalid_resource_selector",
|
|
243
|
+
owners: ["core.transaction"],
|
|
244
|
+
remediation: selector
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
code: "invalid_display_node_selector",
|
|
248
|
+
owners: ["core.transaction"],
|
|
249
|
+
remediation: selector
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
code: "invalid_resource_folder_selector",
|
|
253
|
+
owners: ["core.transaction"],
|
|
254
|
+
remediation: selector
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
code: "invalid_branch_selector",
|
|
258
|
+
owners: ["core.transaction"],
|
|
259
|
+
remediation: selector
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
code: "invalid_gear_selector",
|
|
263
|
+
owners: ["core.transaction"],
|
|
264
|
+
remediation: selector
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
code: "invalid_look_gear_selector",
|
|
268
|
+
owners: ["core.transaction"],
|
|
269
|
+
remediation: selector
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
code: "selector_ambiguity",
|
|
273
|
+
owners: ["core.transaction"],
|
|
274
|
+
remediation: selector
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
code: "unavailable_resource_source_bytes",
|
|
278
|
+
owners: ["core.transaction"],
|
|
279
|
+
remediation: source
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
code: "missing_source",
|
|
283
|
+
owners: ["core.validation"],
|
|
284
|
+
remediation: source
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
code: "unreadable_source",
|
|
288
|
+
owners: ["core.validation"],
|
|
289
|
+
remediation: source
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
code: "decode_capability_unavailable",
|
|
293
|
+
owners: ["core.validation"],
|
|
294
|
+
remediation: {
|
|
295
|
+
kind: "host-action",
|
|
296
|
+
message: "Validation is incomplete, not passed. Inspect whether source bytes are unloaded or a decoder is unavailable. Ask the host to hydrate sources or provide the required decoder (Node image validation uses optional Sharp), then validate again. Do not install dependencies or change the project automatically."
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
code: "session_id_conflict",
|
|
301
|
+
owners: ["backend"],
|
|
302
|
+
remediation: {
|
|
303
|
+
kind: "host-action",
|
|
304
|
+
message: "Use getSession to inspect the existing session. Reuse it only for the intended project, or choose a new session ID; do not close another owner\\u0027s session to make room."
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
code: "lock_conflict",
|
|
309
|
+
owners: ["backend"],
|
|
310
|
+
remediation: {
|
|
311
|
+
kind: "host-action",
|
|
312
|
+
message: "Another owner holds the project lock. Preserve unsaved work and ask that owner to close its session, then explicitly reopen. Never remove a live lock, force-close a peer, or bypass locking."
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
code: "event_cursor_invalid",
|
|
317
|
+
owners: ["backend"],
|
|
318
|
+
remediation: {
|
|
319
|
+
kind: "refresh-and-replan",
|
|
320
|
+
message: "Read the error and getEvents cursor bounds. Request a fresh bounded event page without the invalid cursor and refresh the current outline before replanning; missing retained history is not evidence that nothing changed."
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
code: "corrupt_source",
|
|
325
|
+
owners: ["core.validation"],
|
|
326
|
+
remediation: source
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
code: "unsupported_operation",
|
|
330
|
+
owners: ["core.transaction"],
|
|
331
|
+
remediation: unsupported
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
code: "transaction_unsupported",
|
|
335
|
+
owners: ["core.transaction"],
|
|
336
|
+
remediation: unsupported
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
code: "unsupported_display_node_kind",
|
|
340
|
+
owners: ["core.transaction"],
|
|
341
|
+
remediation: unsupported
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
code: "unsupported_cross_package_image_ref",
|
|
345
|
+
owners: ["core.transaction"],
|
|
346
|
+
remediation: unsupported
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
code: "unsupported_gear_kind",
|
|
350
|
+
owners: ["core.transaction"],
|
|
351
|
+
remediation: unsupported
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
code: "unsupported_resource_mutation",
|
|
355
|
+
owners: ["core.transaction"],
|
|
356
|
+
remediation: unsupported
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
code: "unsupported_display_node_mutation",
|
|
360
|
+
owners: ["core.transaction"],
|
|
361
|
+
remediation: unsupported
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
code: "unsupported_text_field_target",
|
|
365
|
+
owners: ["core.transaction"],
|
|
366
|
+
remediation: unsupported
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
code: "unsupported_display_node_field",
|
|
370
|
+
owners: ["core.transaction"],
|
|
371
|
+
remediation: unsupported
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
code: "unsupported_operation_batch",
|
|
375
|
+
owners: ["core.transaction"],
|
|
376
|
+
remediation: unsupported
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
code: "unsupported_resource_kind",
|
|
380
|
+
owners: ["core.transaction", "core.validation"],
|
|
381
|
+
remediation: unsupported
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
code: "invalid_project_settings",
|
|
385
|
+
owners: ["core.transaction"],
|
|
386
|
+
remediation: payload
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
code: "invalid_package_settings",
|
|
390
|
+
owners: ["core.transaction"],
|
|
391
|
+
remediation: payload
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
code: "invalid_display_node_payload",
|
|
395
|
+
owners: ["core.transaction"],
|
|
396
|
+
remediation: payload
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
code: "invalid_resource_name",
|
|
400
|
+
owners: ["core.transaction"],
|
|
401
|
+
remediation: payload
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
code: "invalid_resource_path",
|
|
405
|
+
owners: ["core.transaction"],
|
|
406
|
+
remediation: payload
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
code: "invalid_resource_folder_path",
|
|
410
|
+
owners: ["core.transaction"],
|
|
411
|
+
remediation: payload
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
code: "invalid_resource_folder_atlas",
|
|
415
|
+
owners: ["core.transaction"],
|
|
416
|
+
remediation: payload
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
code: "invalid_attach_index",
|
|
420
|
+
owners: ["core.transaction"],
|
|
421
|
+
remediation: payload
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
code: "invalid_controller_payload",
|
|
425
|
+
owners: ["core.transaction"],
|
|
426
|
+
remediation: payload
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
code: "invalid_transition_payload",
|
|
430
|
+
owners: ["core.transaction"],
|
|
431
|
+
remediation: payload
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
code: "invalid_look_gear_payload",
|
|
435
|
+
owners: ["core.transaction"],
|
|
436
|
+
remediation: payload
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
code: "invalid_gear_payload",
|
|
440
|
+
owners: ["core.transaction"],
|
|
441
|
+
remediation: payload
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
code: "invalid_resource_payload",
|
|
445
|
+
owners: ["core.transaction"],
|
|
446
|
+
remediation: payload
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
code: "invalid_resource_bytes",
|
|
450
|
+
owners: ["core.transaction"],
|
|
451
|
+
remediation: payload
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
code: "invalid_movie_clip_jta",
|
|
455
|
+
owners: ["core.transaction"],
|
|
456
|
+
remediation: payload
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
code: "invalid_resource_index",
|
|
460
|
+
owners: ["core.transaction"],
|
|
461
|
+
remediation: payload
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
code: "invalid_branch_name",
|
|
465
|
+
owners: ["core.transaction"],
|
|
466
|
+
remediation: payload
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
code: "invalid_package_payload",
|
|
470
|
+
owners: ["core.transaction"],
|
|
471
|
+
remediation: payload
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
code: "invalid_package_index",
|
|
475
|
+
owners: ["core.transaction"],
|
|
476
|
+
remediation: payload
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
code: "invalid_component_payload",
|
|
480
|
+
owners: ["core.transaction"],
|
|
481
|
+
remediation: payload
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
code: "invalid_component_index",
|
|
485
|
+
owners: ["core.transaction"],
|
|
486
|
+
remediation: payload
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
code: "invalid_component_move",
|
|
490
|
+
owners: ["core.transaction"],
|
|
491
|
+
remediation: payload
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
code: "invalid_uam",
|
|
495
|
+
owners: ["core.transaction", "core.validation"],
|
|
496
|
+
remediation: payload
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
code: "project_settings_unchanged",
|
|
500
|
+
owners: ["core.transaction"],
|
|
501
|
+
remediation: unchanged
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
code: "package_settings_unchanged",
|
|
505
|
+
owners: ["core.transaction"],
|
|
506
|
+
remediation: unchanged
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
code: "display_node_props_unchanged",
|
|
510
|
+
owners: ["core.transaction"],
|
|
511
|
+
remediation: unchanged
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
code: "resource_folder_atlas_unchanged",
|
|
515
|
+
owners: ["core.transaction"],
|
|
516
|
+
remediation: unchanged
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
code: "duplicate_look_gear_controller",
|
|
520
|
+
owners: ["core.transaction"],
|
|
521
|
+
remediation: duplicate
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
code: "duplicate_transition_name",
|
|
525
|
+
owners: ["core.transaction"],
|
|
526
|
+
remediation: duplicate
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
code: "duplicate_look_gear_state_page",
|
|
530
|
+
owners: ["core.transaction"],
|
|
531
|
+
remediation: duplicate
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
code: "duplicate_gear_controller",
|
|
535
|
+
owners: ["core.transaction"],
|
|
536
|
+
remediation: duplicate
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
code: "duplicate_gear_state_page",
|
|
540
|
+
owners: ["core.transaction"],
|
|
541
|
+
remediation: duplicate
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
code: "duplicate_branch_name",
|
|
545
|
+
owners: ["core.transaction"],
|
|
546
|
+
remediation: duplicate
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
code: "duplicate_component_id",
|
|
550
|
+
owners: ["core.transaction"],
|
|
551
|
+
remediation: duplicate
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
code: "resource_folder_conflict",
|
|
555
|
+
owners: ["core.transaction"],
|
|
556
|
+
remediation: duplicate
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
code: "duplicate_resource_id",
|
|
560
|
+
owners: ["core.transaction", "core.validation"],
|
|
561
|
+
remediation: duplicate
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
code: "duplicate_package_id",
|
|
565
|
+
owners: ["core.transaction", "core.validation"],
|
|
566
|
+
remediation: duplicate
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
code: "duplicate_package_name",
|
|
570
|
+
owners: ["core.transaction", "core.validation"],
|
|
571
|
+
remediation: duplicate
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
code: "resource_folder_not_empty",
|
|
575
|
+
owners: ["core.transaction"],
|
|
576
|
+
remediation: references
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
code: "branch_not_empty",
|
|
580
|
+
owners: ["core.transaction"],
|
|
581
|
+
remediation: references
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
code: "branch_referenced",
|
|
585
|
+
owners: ["core.transaction"],
|
|
586
|
+
remediation: references
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
code: "invalid_resource_reference",
|
|
590
|
+
owners: ["core.transaction"],
|
|
591
|
+
remediation: references
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
code: "invalid_component_reference",
|
|
595
|
+
owners: ["core.transaction"],
|
|
596
|
+
remediation: references
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
code: "invalid_group_reference",
|
|
600
|
+
owners: ["core.transaction"],
|
|
601
|
+
remediation: references
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
code: "package_referenced",
|
|
605
|
+
owners: ["core.transaction"],
|
|
606
|
+
remediation: references
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
code: "component_referenced",
|
|
610
|
+
owners: ["core.transaction"],
|
|
611
|
+
remediation: references
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
code: "component_has_package_dependencies",
|
|
615
|
+
owners: ["core.transaction"],
|
|
616
|
+
remediation: references
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
code: "dangling_resource_reference",
|
|
620
|
+
owners: ["core.validation"],
|
|
621
|
+
remediation: references
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
code: "invalid_project_xml",
|
|
625
|
+
owners: ["core.validation"],
|
|
626
|
+
remediation: project
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
code: "invalid_package_xml",
|
|
630
|
+
owners: ["core.validation"],
|
|
631
|
+
remediation: project
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
code: "invalid_branch_package_xml",
|
|
635
|
+
owners: ["core.validation"],
|
|
636
|
+
remediation: project
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
code: "invalid_component_xml",
|
|
640
|
+
owners: ["core.validation"],
|
|
641
|
+
remediation: project
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
code: "invalid_project_value",
|
|
645
|
+
owners: ["core.validation"],
|
|
646
|
+
remediation: project
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
code: "desktop_incompatible_geometry",
|
|
650
|
+
owners: ["core.validation"],
|
|
651
|
+
remediation: project
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
code: "invalid_settings_json",
|
|
655
|
+
owners: ["core.validation"],
|
|
656
|
+
remediation: project
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
code: "path_collision",
|
|
660
|
+
owners: ["core.validation"],
|
|
661
|
+
remediation: path$1
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
code: "unsafe_path",
|
|
665
|
+
owners: ["core.validation"],
|
|
666
|
+
remediation: path$1
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
code: "capability_unavailable",
|
|
670
|
+
owners: ["backend"],
|
|
671
|
+
remediation: capability
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
code: "uam_fidelity_unsupported",
|
|
675
|
+
owners: ["backend"],
|
|
676
|
+
remediation: capability
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
code: "save_partial_failure",
|
|
680
|
+
owners: ["backend"],
|
|
681
|
+
remediation: write
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
code: "write_failed",
|
|
685
|
+
owners: ["backend"],
|
|
686
|
+
remediation: write
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
code: "project_open_failed",
|
|
690
|
+
owners: ["backend"],
|
|
691
|
+
remediation: project
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
code: "materialize_validation_failed",
|
|
695
|
+
owners: ["backend"],
|
|
696
|
+
remediation: project
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
code: "execution_failure",
|
|
700
|
+
owners: ["core.transaction"],
|
|
701
|
+
remediation: execution
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
code: "cache_refresh_failed",
|
|
705
|
+
owners: ["backend"],
|
|
706
|
+
remediation: execution
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
code: "job_not_found",
|
|
710
|
+
owners: ["backend"],
|
|
711
|
+
remediation: job
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
code: "job_not_cancellable",
|
|
715
|
+
owners: ["backend"],
|
|
716
|
+
remediation: job
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
code: "job_cancelled",
|
|
720
|
+
owners: ["backend"],
|
|
721
|
+
remediation: job
|
|
722
|
+
}
|
|
723
|
+
];
|
|
724
|
+
const BACKEND_DIAGNOSTICS_URI = "openfairygui://docs/diagnostics";
|
|
725
|
+
`${BACKEND_DIAGNOSTICS_URI}`;
|
|
726
|
+
function enrichBackendDiagnostic(diagnostic, sessionId) {
|
|
727
|
+
const guide = BACKEND_DIAGNOSTIC_GUIDES.find((entry) => entry.code === diagnostic.code);
|
|
728
|
+
if (!guide) return { ...diagnostic };
|
|
729
|
+
return {
|
|
730
|
+
...diagnostic,
|
|
731
|
+
owner: diagnostic.owner ?? guide.owners[0],
|
|
732
|
+
docsUri: `${BACKEND_DIAGNOSTICS_URI}/${guide.code}`,
|
|
733
|
+
remediation: {
|
|
734
|
+
...guide.remediation,
|
|
735
|
+
...sessionId && guide.remediation.kind !== "host-action" ? { read: {
|
|
736
|
+
method: "getProjectOutline",
|
|
737
|
+
input: { sessionId }
|
|
738
|
+
} } : {}
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
//#endregion
|
|
118
743
|
//#region src/services/context.ts
|
|
119
744
|
function diagnosticFromError(error) {
|
|
120
745
|
return {
|
|
@@ -133,10 +758,10 @@ function createMeta(stage, startedAt, options) {
|
|
|
133
758
|
revision: options?.revision,
|
|
134
759
|
durationMs: Math.max(0, Date.now() - startedAt),
|
|
135
760
|
warnings: options?.warnings ?? [],
|
|
136
|
-
diagnostics: options?.diagnostics ?? [],
|
|
761
|
+
diagnostics: (options?.diagnostics ?? []).map((entry) => enrichBackendDiagnostic(entry, options?.sessionId)),
|
|
137
762
|
stage,
|
|
138
763
|
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
139
|
-
capabilitySchemaVersion:
|
|
764
|
+
capabilitySchemaVersion: 11
|
|
140
765
|
};
|
|
141
766
|
}
|
|
142
767
|
function success(stage, startedAt, data, options) {
|
|
@@ -252,6 +877,268 @@ function createStaleWriteError(session, expectedRevision) {
|
|
|
252
877
|
};
|
|
253
878
|
}
|
|
254
879
|
//#endregion
|
|
880
|
+
//#region src/runtime/contracts.ts
|
|
881
|
+
const BACKEND_ENTITY_QUERY_LIMITS = {
|
|
882
|
+
maxBytes: 262144,
|
|
883
|
+
maxDepth: 32,
|
|
884
|
+
maxNodes: 1e5
|
|
885
|
+
};
|
|
886
|
+
const BACKEND_SESSION_READ_LIMITS = {
|
|
887
|
+
model: {
|
|
888
|
+
maxBytes: 4194304,
|
|
889
|
+
maxDepth: 64,
|
|
890
|
+
maxNodes: 5e5
|
|
891
|
+
},
|
|
892
|
+
resourceBytes: 1048576
|
|
893
|
+
};
|
|
894
|
+
const BACKEND_TRANSACTION_PREVIEW_LIMITS = {
|
|
895
|
+
maxBytes: 262144,
|
|
896
|
+
maxEntries: 2e3
|
|
897
|
+
};
|
|
898
|
+
/** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
|
|
899
|
+
const BACKEND_RESOURCE_QUERY_FIELDS = [
|
|
900
|
+
"kind",
|
|
901
|
+
"id",
|
|
902
|
+
"name",
|
|
903
|
+
"path",
|
|
904
|
+
"exported",
|
|
905
|
+
"favorite",
|
|
906
|
+
"branch",
|
|
907
|
+
"branchItemIds",
|
|
908
|
+
"fileName",
|
|
909
|
+
"file",
|
|
910
|
+
"dimensions",
|
|
911
|
+
"image",
|
|
912
|
+
"movieClip"
|
|
913
|
+
];
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/services/capture-project.ts
|
|
916
|
+
function createCaptureFileSystem(files, directories) {
|
|
917
|
+
const normalize = (filePath) => filePath.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
918
|
+
return {
|
|
919
|
+
async readFile(filePath) {
|
|
920
|
+
const value = files.get(normalize(filePath));
|
|
921
|
+
if (typeof value !== "string") throw new Error(`Captured text file was not found: ${filePath}`);
|
|
922
|
+
return value;
|
|
923
|
+
},
|
|
924
|
+
async readFileRaw(filePath) {
|
|
925
|
+
const value = files.get(normalize(filePath));
|
|
926
|
+
if (!(value instanceof Uint8Array)) throw new Error(`Captured binary file was not found: ${filePath}`);
|
|
927
|
+
return value.slice();
|
|
928
|
+
},
|
|
929
|
+
async writeFile(filePath, content) {
|
|
930
|
+
files.set(normalize(filePath), content);
|
|
931
|
+
},
|
|
932
|
+
async writeFileRaw(filePath, data) {
|
|
933
|
+
files.set(normalize(filePath), data.slice());
|
|
934
|
+
},
|
|
935
|
+
async mkdir(dirPath) {
|
|
936
|
+
directories.add(normalize(dirPath));
|
|
937
|
+
},
|
|
938
|
+
async readdir() {
|
|
939
|
+
return [];
|
|
940
|
+
},
|
|
941
|
+
async exists(filePath) {
|
|
942
|
+
return files.has(normalize(filePath));
|
|
943
|
+
},
|
|
944
|
+
join(...paths) {
|
|
945
|
+
return normalize(paths.filter(Boolean).join("/"));
|
|
946
|
+
},
|
|
947
|
+
dirname(filePath) {
|
|
948
|
+
const normalized = normalize(filePath);
|
|
949
|
+
const separator = normalized.lastIndexOf("/");
|
|
950
|
+
return separator < 0 ? "" : normalized.slice(0, separator);
|
|
951
|
+
},
|
|
952
|
+
async unlink(filePath) {
|
|
953
|
+
files.delete(normalize(filePath));
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function capturedFilesEqual(left, right) {
|
|
958
|
+
if (left.size !== right.size) return false;
|
|
959
|
+
for (const [filePath, leftValue] of left) {
|
|
960
|
+
const rightValue = right.get(filePath);
|
|
961
|
+
if (typeof leftValue === "string") {
|
|
962
|
+
if (leftValue !== rightValue) return false;
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (!(rightValue instanceof Uint8Array) || leftValue.length !== rightValue.length) return false;
|
|
966
|
+
for (let index = 0; index < leftValue.length; index += 1) if (leftValue[index] !== rightValue[index]) return false;
|
|
967
|
+
}
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
function capturedDirectoriesEqual(left, right) {
|
|
971
|
+
return left.size === right.size && [...left].every((directory) => right.has(directory));
|
|
972
|
+
}
|
|
973
|
+
/** Serialize only into memory. This is a model projection, not a disk inventory or write plan. */
|
|
974
|
+
async function captureProject(document, fairyFileName) {
|
|
975
|
+
const files = /* @__PURE__ */ new Map();
|
|
976
|
+
const directories = /* @__PURE__ */ new Set();
|
|
977
|
+
await new _openfairygui_core_project_io.ProjectWriter(createCaptureFileSystem(files, directories)).write(document, fairyFileName);
|
|
978
|
+
return {
|
|
979
|
+
files,
|
|
980
|
+
directories
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/services/transaction-preview.ts
|
|
985
|
+
/** Keep child identities/order on their parent, and compare each child's own properties separately. */
|
|
986
|
+
function entities(project) {
|
|
987
|
+
const result = /* @__PURE__ */ new Map();
|
|
988
|
+
function add(target, properties) {
|
|
989
|
+
const key = JSON.stringify(target);
|
|
990
|
+
if (result.has(key)) throw new Error(`Ambiguous preview identity: ${key}`);
|
|
991
|
+
result.set(key, {
|
|
992
|
+
target,
|
|
993
|
+
properties
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
const { packages, ...properties } = project;
|
|
997
|
+
add({ kind: "project" }, {
|
|
998
|
+
...properties,
|
|
999
|
+
packages: packages.map((pkg) => pkg.id)
|
|
1000
|
+
});
|
|
1001
|
+
for (const { resources, ...pkg } of packages) {
|
|
1002
|
+
const packageId = pkg.id;
|
|
1003
|
+
add({
|
|
1004
|
+
kind: "package",
|
|
1005
|
+
selector: { packageId }
|
|
1006
|
+
}, {
|
|
1007
|
+
...pkg,
|
|
1008
|
+
resources: resources.map((resource) => resource.id)
|
|
1009
|
+
});
|
|
1010
|
+
for (const resource of resources) {
|
|
1011
|
+
const resourceTarget = {
|
|
1012
|
+
kind: "resource",
|
|
1013
|
+
selector: {
|
|
1014
|
+
packageId,
|
|
1015
|
+
resourceId: resource.id
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
if (resource.kind !== "component") {
|
|
1019
|
+
add(resourceTarget, resource);
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
const { component, ...resourceProperties } = resource;
|
|
1023
|
+
add(resourceTarget, resourceProperties);
|
|
1024
|
+
const { displayList, controllers, transitions, ...componentProperties } = component;
|
|
1025
|
+
const selector = {
|
|
1026
|
+
packageId,
|
|
1027
|
+
componentResourceId: resource.id
|
|
1028
|
+
};
|
|
1029
|
+
add({
|
|
1030
|
+
kind: "component",
|
|
1031
|
+
selector
|
|
1032
|
+
}, {
|
|
1033
|
+
...componentProperties,
|
|
1034
|
+
displayList: displayList.map((node) => node.id),
|
|
1035
|
+
controllers: controllers.map((controller) => controller.name),
|
|
1036
|
+
transitions: transitions.map((transition) => transition.name)
|
|
1037
|
+
});
|
|
1038
|
+
for (const node of displayList) add({
|
|
1039
|
+
kind: "displayNode",
|
|
1040
|
+
selector: {
|
|
1041
|
+
...selector,
|
|
1042
|
+
displayNodeId: node.id
|
|
1043
|
+
}
|
|
1044
|
+
}, node);
|
|
1045
|
+
for (const controller of controllers) add({
|
|
1046
|
+
kind: "controller",
|
|
1047
|
+
selector: {
|
|
1048
|
+
...selector,
|
|
1049
|
+
controllerName: controller.name
|
|
1050
|
+
}
|
|
1051
|
+
}, controller);
|
|
1052
|
+
for (const transition of transitions) add({
|
|
1053
|
+
kind: "transition",
|
|
1054
|
+
selector: {
|
|
1055
|
+
...selector,
|
|
1056
|
+
transitionName: transition.name
|
|
1057
|
+
}
|
|
1058
|
+
}, transition);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return result;
|
|
1062
|
+
}
|
|
1063
|
+
function equal(left, right, depth = 0) {
|
|
1064
|
+
if (left === right) return true;
|
|
1065
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object") return false;
|
|
1066
|
+
if (left instanceof Uint8Array || right instanceof Uint8Array) return left instanceof Uint8Array && right instanceof Uint8Array && left.length === right.length && left.every((value, index) => value === right[index]);
|
|
1067
|
+
if (depth > 128) throw new Error("Preview property comparison exceeds the supported nesting depth.");
|
|
1068
|
+
if (Array.isArray(left) !== Array.isArray(right)) return false;
|
|
1069
|
+
if (Array.isArray(left) && Array.isArray(right) && left.length !== right.length) return false;
|
|
1070
|
+
const a = left, b = right;
|
|
1071
|
+
const keys = Object.keys(a);
|
|
1072
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && equal(a[key], b[key], depth + 1));
|
|
1073
|
+
}
|
|
1074
|
+
var PreviewBudgetError = class extends Error {};
|
|
1075
|
+
/** No host filesystem, cache, event or session mutation is involved in the projection. */
|
|
1076
|
+
async function previewTransactionImpact(session, project, fileSystemAvailable) {
|
|
1077
|
+
const impact = {
|
|
1078
|
+
entities: [],
|
|
1079
|
+
files: []
|
|
1080
|
+
};
|
|
1081
|
+
const before = entities(session.project), after = entities(project);
|
|
1082
|
+
let entries = 0, bytes = 0;
|
|
1083
|
+
const encoder = new TextEncoder();
|
|
1084
|
+
function count(value) {
|
|
1085
|
+
bytes += encoder.encode(JSON.stringify(value)).byteLength;
|
|
1086
|
+
if (++entries > BACKEND_TRANSACTION_PREVIEW_LIMITS.maxEntries || bytes > BACKEND_TRANSACTION_PREVIEW_LIMITS.maxBytes) throw new PreviewBudgetError("The complete transaction impact exceeds the preview response budget.");
|
|
1087
|
+
}
|
|
1088
|
+
for (const key of new Set([...before.keys(), ...after.keys()])) {
|
|
1089
|
+
const previous = before.get(key), next = after.get(key);
|
|
1090
|
+
const fields = [...new Set([...Object.keys(previous?.properties ?? {}), ...Object.keys(next?.properties ?? {})])].filter((field) => !previous || !next || !equal(previous.properties[field], next.properties[field])).sort();
|
|
1091
|
+
if (!fields.length && previous && next) continue;
|
|
1092
|
+
const change = {
|
|
1093
|
+
target: (next ?? previous).target,
|
|
1094
|
+
change: !previous ? "added" : !next ? "removed" : "updated",
|
|
1095
|
+
fields
|
|
1096
|
+
};
|
|
1097
|
+
count(change);
|
|
1098
|
+
impact.entities.push(change);
|
|
1099
|
+
}
|
|
1100
|
+
const fairyFileName = session.fileSystem ? session.fairyPath.replace(/\\/g, "/").split("/").at(-1) : "Project.fairy";
|
|
1101
|
+
const [previousFiles, nextFiles] = await Promise.all([captureProject((0, _openfairygui_core_uam.materializeUamProject)(session.project), fairyFileName), captureProject((0, _openfairygui_core_uam.materializeUamProject)(project), fairyFileName)]);
|
|
1102
|
+
for (const path of new Set([...previousFiles.files.keys(), ...nextFiles.files.keys()])) {
|
|
1103
|
+
const previous = previousFiles.files.get(path), next = nextFiles.files.get(path);
|
|
1104
|
+
if (equal(previous, next)) continue;
|
|
1105
|
+
const change = {
|
|
1106
|
+
path,
|
|
1107
|
+
kind: "file",
|
|
1108
|
+
change: previous === void 0 ? "added" : next === void 0 ? "removed" : "updated"
|
|
1109
|
+
};
|
|
1110
|
+
count(change);
|
|
1111
|
+
impact.files.push(change);
|
|
1112
|
+
}
|
|
1113
|
+
for (const path of new Set([...previousFiles.directories, ...nextFiles.directories])) {
|
|
1114
|
+
if (previousFiles.directories.has(path) === nextFiles.directories.has(path)) continue;
|
|
1115
|
+
const change = {
|
|
1116
|
+
path,
|
|
1117
|
+
kind: "directory",
|
|
1118
|
+
change: nextFiles.directories.has(path) ? "added" : "removed"
|
|
1119
|
+
};
|
|
1120
|
+
count(change);
|
|
1121
|
+
impact.files.push(change);
|
|
1122
|
+
}
|
|
1123
|
+
impact.files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.kind.localeCompare(b.kind));
|
|
1124
|
+
const preview = {
|
|
1125
|
+
sessionId: session.sessionId,
|
|
1126
|
+
baseRevision: session.revision,
|
|
1127
|
+
projectedRevision: session.revision + 1,
|
|
1128
|
+
mode: "execute-and-discard",
|
|
1129
|
+
impact,
|
|
1130
|
+
persistence: {
|
|
1131
|
+
requiredAfterApply: true,
|
|
1132
|
+
fileSystemAvailable,
|
|
1133
|
+
uamFidelity: session.uamFidelity,
|
|
1134
|
+
writeVerified: false,
|
|
1135
|
+
nextAction: session.uamFidelity === "unsupported" || !fileSystemAvailable ? "host-action" : session.fileSystem ? "saveSession" : "materializeSession"
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
if (encoder.encode(JSON.stringify(preview)).byteLength > BACKEND_TRANSACTION_PREVIEW_LIMITS.maxBytes) throw new PreviewBudgetError("The complete transaction preview exceeds the response byte budget.");
|
|
1139
|
+
return preview;
|
|
1140
|
+
}
|
|
1141
|
+
//#endregion
|
|
255
1142
|
//#region src/services/authoring-service.ts
|
|
256
1143
|
function sourceFileKey(source) {
|
|
257
1144
|
return [
|
|
@@ -281,8 +1168,12 @@ function recordStaleProjectFiles(session, previousProject, nextProject) {
|
|
|
281
1168
|
for (const directory of (0, _openfairygui_core_uam.staleBranchDirectories)(nextProject, previousProject)) session.pendingStaleBranchDirectories.delete(branchDirectoryKey(directory));
|
|
282
1169
|
}
|
|
283
1170
|
function toBackendDiagnostics(error) {
|
|
284
|
-
return error.diagnostics.length > 0 ? error.diagnostics.map((diagnostic) => ({
|
|
1171
|
+
return error.diagnostics.length > 0 ? error.diagnostics.map((diagnostic) => ({
|
|
1172
|
+
...diagnostic,
|
|
1173
|
+
owner: "core.transaction"
|
|
1174
|
+
})) : [{
|
|
285
1175
|
code: error.code,
|
|
1176
|
+
owner: "core.transaction",
|
|
286
1177
|
message: error.message,
|
|
287
1178
|
severity: "error",
|
|
288
1179
|
operationKind: error.operationKind,
|
|
@@ -370,6 +1261,46 @@ var AuthoringService = class {
|
|
|
370
1261
|
if (this.sessionOperations.get(sessionId) === tail) this.sessionOperations.delete(sessionId);
|
|
371
1262
|
}
|
|
372
1263
|
}
|
|
1264
|
+
async preflightTransaction(input) {
|
|
1265
|
+
const queuedInput = structuredClone(input);
|
|
1266
|
+
detachSharedByteViews(queuedInput);
|
|
1267
|
+
return this.runSessionExclusive(queuedInput.sessionId, async () => {
|
|
1268
|
+
const startedAt = Date.now();
|
|
1269
|
+
const session = this.context.sessions.get(queuedInput.sessionId);
|
|
1270
|
+
if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1271
|
+
const meta = {
|
|
1272
|
+
sessionId: session.sessionId,
|
|
1273
|
+
revision: session.revision
|
|
1274
|
+
};
|
|
1275
|
+
if (queuedInput.expectedRevision !== session.revision) return failure("authoring", startedAt, createStaleWriteError(session, queuedInput.expectedRevision), toSessionSnapshot(session, this.context.capabilities), meta);
|
|
1276
|
+
const project = structuredClone(session.project);
|
|
1277
|
+
detachSharedByteViews(project);
|
|
1278
|
+
const result = await (0, _openfairygui_functions_uam.applyUamTransactionAppAsync)({
|
|
1279
|
+
project,
|
|
1280
|
+
operations: queuedInput.operations
|
|
1281
|
+
});
|
|
1282
|
+
if (this.context.sessions.get(queuedInput.sessionId) !== session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1283
|
+
if (!result.ok) return failure("authoring", startedAt, result.error, toSessionSnapshot(session, this.context.capabilities), {
|
|
1284
|
+
...meta,
|
|
1285
|
+
diagnostics: toBackendDiagnostics(result.error)
|
|
1286
|
+
});
|
|
1287
|
+
try {
|
|
1288
|
+
const preview = await previewTransactionImpact({
|
|
1289
|
+
...session,
|
|
1290
|
+
project
|
|
1291
|
+
}, result.project, Boolean(session.fileSystem));
|
|
1292
|
+
if (this.context.sessions.get(queuedInput.sessionId) !== session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1293
|
+
return success("authoring", startedAt, preview, meta);
|
|
1294
|
+
} catch (error) {
|
|
1295
|
+
return failure("authoring", startedAt, {
|
|
1296
|
+
code: "transaction_preview_failed",
|
|
1297
|
+
sessionId: session.sessionId,
|
|
1298
|
+
reason: error instanceof PreviewBudgetError ? "response_budget_exceeded" : "projection_failed",
|
|
1299
|
+
message: error instanceof Error ? error.message : String(error)
|
|
1300
|
+
}, toSessionSnapshot(session, this.context.capabilities), meta);
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
373
1304
|
async applyTransaction(input) {
|
|
374
1305
|
const queuedInput = structuredClone(input);
|
|
375
1306
|
detachSharedByteViews(queuedInput);
|
|
@@ -449,7 +1380,7 @@ var AuthoringService = class {
|
|
|
449
1380
|
const startedAt = Date.now();
|
|
450
1381
|
const session = this.context.sessions.get(input.sessionId);
|
|
451
1382
|
if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(input.sessionId));
|
|
452
|
-
const fileSystem = session.fileSystem ?? input.fileSystem
|
|
1383
|
+
const fileSystem = session.fileSystem ?? input.fileSystem;
|
|
453
1384
|
if (!fileSystem) return failure("authoring", startedAt, createCapabilityUnavailableError$1("saveSession requires an injected BackendFileSystem adapter."), toSessionSnapshot(session, this.context.capabilities), {
|
|
454
1385
|
sessionId: session.sessionId,
|
|
455
1386
|
revision: session.revision
|
|
@@ -551,7 +1482,7 @@ var AuthoringService = class {
|
|
|
551
1482
|
revision: session.revision
|
|
552
1483
|
});
|
|
553
1484
|
const storageTarget = input.storage ? storageCanonicalTarget(input.storage) : null;
|
|
554
|
-
const fileSystem = storageTarget?.fileSystem ?? input.fileSystem ?? session.fileSystem
|
|
1485
|
+
const fileSystem = storageTarget?.fileSystem ?? input.fileSystem ?? session.fileSystem;
|
|
555
1486
|
if (!fileSystem) return failure("authoring", startedAt, createCapabilityUnavailableError$1("materializeSession requires an injected BackendFileSystem adapter."), toSessionSnapshot(session, this.context.capabilities), {
|
|
556
1487
|
sessionId: session.sessionId,
|
|
557
1488
|
revision: session.revision
|
|
@@ -777,7 +1708,7 @@ var EventService = class {
|
|
|
777
1708
|
...event,
|
|
778
1709
|
sequence: this.context.nextEventSequence(),
|
|
779
1710
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
780
|
-
diagnostics: event.diagnostics ?? []
|
|
1711
|
+
diagnostics: (event.diagnostics ?? []).map((entry) => enrichBackendDiagnostic(entry, event.sessionId))
|
|
781
1712
|
};
|
|
782
1713
|
const sessionId = event.sessionId;
|
|
783
1714
|
if (!sessionId) return emitted;
|
|
@@ -1105,6 +2036,48 @@ var JobService = class {
|
|
|
1105
2036
|
};
|
|
1106
2037
|
//#endregion
|
|
1107
2038
|
//#region src/services/read-service.ts
|
|
2039
|
+
/** Bound traversal before serialization or cloning, including non-JSON values on a malformed native input. */
|
|
2040
|
+
function queryResponseProblem(value, limits = BACKEND_ENTITY_QUERY_LIMITS) {
|
|
2041
|
+
const pending = [{
|
|
2042
|
+
value,
|
|
2043
|
+
depth: 0
|
|
2044
|
+
}];
|
|
2045
|
+
let nodes = 0;
|
|
2046
|
+
let stringUnits = 0;
|
|
2047
|
+
while (pending.length) {
|
|
2048
|
+
const { value, depth } = pending.pop();
|
|
2049
|
+
if (++nodes > limits.maxNodes || depth > limits.maxDepth) return "response_budget_exceeded";
|
|
2050
|
+
if (typeof value === "string" && (stringUnits += value.length) > limits.maxBytes) return "response_budget_exceeded";
|
|
2051
|
+
if (value === void 0 || value === null || typeof value === "string" || typeof value === "boolean") continue;
|
|
2052
|
+
if (typeof value === "number") {
|
|
2053
|
+
if (!Number.isFinite(value)) return "non_json_value";
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
if (typeof value !== "object" || !Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return "non_json_value";
|
|
2057
|
+
if (Array.isArray(value) && value.length + pending.length + nodes > limits.maxNodes) return "response_budget_exceeded";
|
|
2058
|
+
const entries = Object.entries(value);
|
|
2059
|
+
if (entries.length + pending.length + nodes > limits.maxNodes) return "response_budget_exceeded";
|
|
2060
|
+
for (const [key, child] of entries) {
|
|
2061
|
+
if (!Array.isArray(value) && (stringUnits += key.length) > limits.maxBytes) return "response_budget_exceeded";
|
|
2062
|
+
pending.push({
|
|
2063
|
+
value: child,
|
|
2064
|
+
depth: depth + 1
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
if (new TextEncoder().encode(JSON.stringify(value)).byteLength > limits.maxBytes) return "response_budget_exceeded";
|
|
2069
|
+
}
|
|
2070
|
+
function readFailure(startedAt, sessionId, reason, revision) {
|
|
2071
|
+
return failure("read", startedAt, {
|
|
2072
|
+
code: "session_read_failed",
|
|
2073
|
+
sessionId,
|
|
2074
|
+
reason,
|
|
2075
|
+
message: `Session read failed: ${reason}.`
|
|
2076
|
+
}, void 0, {
|
|
2077
|
+
sessionId,
|
|
2078
|
+
revision
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
1108
2081
|
function toProjectOutline(session) {
|
|
1109
2082
|
const project = session.project;
|
|
1110
2083
|
return {
|
|
@@ -1172,6 +2145,195 @@ var ReadService = class {
|
|
|
1172
2145
|
revision: session.revision
|
|
1173
2146
|
});
|
|
1174
2147
|
}
|
|
2148
|
+
queryEntity(input) {
|
|
2149
|
+
const startedAt = Date.now();
|
|
2150
|
+
const session = this.context.sessions.get(input.sessionId);
|
|
2151
|
+
if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
|
|
2152
|
+
const meta = {
|
|
2153
|
+
sessionId: session.sessionId,
|
|
2154
|
+
revision: session.revision
|
|
2155
|
+
};
|
|
2156
|
+
const reject = (reason) => failure("read", startedAt, {
|
|
2157
|
+
code: "entity_query_failed",
|
|
2158
|
+
sessionId: session.sessionId,
|
|
2159
|
+
reason,
|
|
2160
|
+
message: `Entity query failed: ${reason}.`
|
|
2161
|
+
}, void 0, meta);
|
|
2162
|
+
const target = input.target;
|
|
2163
|
+
if (!target || typeof target !== "object" || Array.isArray(target) || Object.keys(target).some((key) => key !== "kind" && key !== "selector")) return reject("invalid_query");
|
|
2164
|
+
const respond = (entity) => {
|
|
2165
|
+
const data = {
|
|
2166
|
+
...meta,
|
|
2167
|
+
target,
|
|
2168
|
+
entity
|
|
2169
|
+
};
|
|
2170
|
+
const problem = queryResponseProblem(data);
|
|
2171
|
+
return problem ? reject(problem) : success("read", startedAt, structuredClone(data), meta);
|
|
2172
|
+
};
|
|
2173
|
+
if (target.kind === "project") {
|
|
2174
|
+
if (Object.hasOwn(target, "selector")) return reject("invalid_query");
|
|
2175
|
+
const { projectId, settings } = session.project;
|
|
2176
|
+
return respond({
|
|
2177
|
+
kind: "project",
|
|
2178
|
+
properties: {
|
|
2179
|
+
projectId,
|
|
2180
|
+
settings
|
|
2181
|
+
}
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
const keys = target.kind === "package" ? ["packageId"] : target.kind === "resource" ? ["packageId", "resourceId"] : target.kind === "component" ? ["packageId", "componentResourceId"] : target.kind === "displayNode" ? [
|
|
2185
|
+
"packageId",
|
|
2186
|
+
"componentResourceId",
|
|
2187
|
+
"displayNodeId"
|
|
2188
|
+
] : target.kind === "controller" ? [
|
|
2189
|
+
"packageId",
|
|
2190
|
+
"componentResourceId",
|
|
2191
|
+
"controllerName"
|
|
2192
|
+
] : target.kind === "transition" ? [
|
|
2193
|
+
"packageId",
|
|
2194
|
+
"componentResourceId",
|
|
2195
|
+
"transitionName"
|
|
2196
|
+
] : [];
|
|
2197
|
+
const selector = target.selector;
|
|
2198
|
+
if (!keys.length || !selector || typeof selector !== "object" || Array.isArray(selector) || Object.keys(selector).length !== keys.length || keys.some((key) => !Object.hasOwn(selector, key) || typeof selector[key] !== "string" || !selector[key].length || selector[key].length > 256)) return reject("invalid_query");
|
|
2199
|
+
const packages = session.project.packages.filter((pkg) => pkg.id === selector.packageId);
|
|
2200
|
+
if (packages.length !== 1) return reject(packages.length ? "ambiguous" : "not_found");
|
|
2201
|
+
if (target.kind === "package") {
|
|
2202
|
+
const { id, name, compressPNG, jpegQuality, publish } = packages[0];
|
|
2203
|
+
return respond({
|
|
2204
|
+
kind: "package",
|
|
2205
|
+
properties: {
|
|
2206
|
+
id,
|
|
2207
|
+
name,
|
|
2208
|
+
settings: {
|
|
2209
|
+
compressPNG,
|
|
2210
|
+
jpegQuality,
|
|
2211
|
+
publish
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
const resources = packages[0].resources.filter((resource) => resource.id === (target.kind === "resource" ? selector.resourceId : selector.componentResourceId));
|
|
2217
|
+
if (resources.length !== 1) return reject(resources.length ? "ambiguous" : "not_found");
|
|
2218
|
+
const resource = resources[0];
|
|
2219
|
+
let entity;
|
|
2220
|
+
if (target.kind === "resource") {
|
|
2221
|
+
const record = resource;
|
|
2222
|
+
entity = {
|
|
2223
|
+
kind: "resource",
|
|
2224
|
+
properties: Object.fromEntries(BACKEND_RESOURCE_QUERY_FIELDS.filter((key) => Object.hasOwn(record, key)).map((key) => [key, record[key]]))
|
|
2225
|
+
};
|
|
2226
|
+
} else {
|
|
2227
|
+
if (resource.kind !== "component") return reject("not_found");
|
|
2228
|
+
if (target.kind === "component") {
|
|
2229
|
+
const { size, properties, customData } = resource.component;
|
|
2230
|
+
entity = {
|
|
2231
|
+
kind: "component",
|
|
2232
|
+
properties: {
|
|
2233
|
+
size,
|
|
2234
|
+
properties,
|
|
2235
|
+
customData
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
} else if (target.kind === "controller") {
|
|
2239
|
+
const controllers = resource.component.controllers.filter((controller) => controller.name === selector.controllerName);
|
|
2240
|
+
if (controllers.length !== 1) return reject(controllers.length ? "ambiguous" : "not_found");
|
|
2241
|
+
entity = {
|
|
2242
|
+
kind: "controller",
|
|
2243
|
+
properties: controllers[0]
|
|
2244
|
+
};
|
|
2245
|
+
} else if (target.kind === "transition") {
|
|
2246
|
+
const transitions = resource.component.transitions.filter((transition) => transition.name === selector.transitionName);
|
|
2247
|
+
if (transitions.length !== 1) return reject(transitions.length ? "ambiguous" : "not_found");
|
|
2248
|
+
entity = {
|
|
2249
|
+
kind: "transition",
|
|
2250
|
+
properties: transitions[0]
|
|
2251
|
+
};
|
|
2252
|
+
} else {
|
|
2253
|
+
const nodes = resource.component.displayList.filter((node) => node.id === selector.displayNodeId);
|
|
2254
|
+
if (nodes.length !== 1) return reject(nodes.length ? "ambiguous" : "not_found");
|
|
2255
|
+
entity = {
|
|
2256
|
+
kind: "displayNode",
|
|
2257
|
+
properties: nodes[0]
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
return respond(entity);
|
|
2262
|
+
}
|
|
2263
|
+
resolveReadSession(input, startedAt) {
|
|
2264
|
+
if (!input || typeof input.sessionId !== "string" || !input.sessionId.length || input.sessionId.length > 256 || input.expectedRevision !== void 0 && (!Number.isSafeInteger(input.expectedRevision) || input.expectedRevision < 0)) return readFailure(startedAt, typeof input?.sessionId === "string" ? input.sessionId : "", "invalid_query");
|
|
2265
|
+
const session = this.context.sessions.get(input.sessionId);
|
|
2266
|
+
if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
|
|
2267
|
+
const meta = {
|
|
2268
|
+
sessionId: session.sessionId,
|
|
2269
|
+
revision: session.revision
|
|
2270
|
+
};
|
|
2271
|
+
if (input.expectedRevision !== void 0 && input.expectedRevision !== session.revision) return failure("read", startedAt, {
|
|
2272
|
+
code: "stale_read",
|
|
2273
|
+
sessionId: session.sessionId,
|
|
2274
|
+
expectedRevision: input.expectedRevision,
|
|
2275
|
+
actualRevision: session.revision,
|
|
2276
|
+
message: "The session edit revision changed. Restart the model and resource read."
|
|
2277
|
+
}, void 0, meta);
|
|
2278
|
+
return success("read", startedAt, session, meta);
|
|
2279
|
+
}
|
|
2280
|
+
readSessionState(input) {
|
|
2281
|
+
const startedAt = Date.now();
|
|
2282
|
+
const resolved = this.resolveReadSession(input, startedAt);
|
|
2283
|
+
if (!resolved.ok) return resolved;
|
|
2284
|
+
const session = resolved.data;
|
|
2285
|
+
const meta = {
|
|
2286
|
+
sessionId: session.sessionId,
|
|
2287
|
+
revision: session.revision
|
|
2288
|
+
};
|
|
2289
|
+
const data = {
|
|
2290
|
+
...meta,
|
|
2291
|
+
dirty: session.dirty,
|
|
2292
|
+
lastSavedRevision: session.lastSavedRevision,
|
|
2293
|
+
uamFidelity: session.uamFidelity,
|
|
2294
|
+
readComplete: session.readComplete,
|
|
2295
|
+
readDiagnostics: session.readDiagnostics,
|
|
2296
|
+
project: {
|
|
2297
|
+
...session.project,
|
|
2298
|
+
packages: session.project.packages.map((pkg) => ({
|
|
2299
|
+
...pkg,
|
|
2300
|
+
resources: pkg.resources.map((resource) => {
|
|
2301
|
+
if (resource.kind === "component") return resource;
|
|
2302
|
+
const { sourceBytes: _sourceBytes, ...model } = resource;
|
|
2303
|
+
return model;
|
|
2304
|
+
})
|
|
2305
|
+
}))
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
const problem = queryResponseProblem(data, BACKEND_SESSION_READ_LIMITS.model);
|
|
2309
|
+
return problem ? readFailure(startedAt, session.sessionId, problem, session.revision) : success("read", startedAt, structuredClone(data), meta);
|
|
2310
|
+
}
|
|
2311
|
+
readResourceBytes(input) {
|
|
2312
|
+
const startedAt = Date.now();
|
|
2313
|
+
const resolved = this.resolveReadSession(input, startedAt);
|
|
2314
|
+
if (!resolved.ok) return resolved;
|
|
2315
|
+
const session = resolved.data;
|
|
2316
|
+
const reject = (reason) => readFailure(startedAt, session.sessionId, reason, session.revision);
|
|
2317
|
+
const selector = input.selector;
|
|
2318
|
+
if (input.expectedRevision === void 0 || !selector || typeof selector !== "object" || Array.isArray(selector) || Object.keys(selector).length !== 2 || ["packageId", "resourceId"].some((key) => !Object.hasOwn(selector, key)) || [selector.packageId, selector.resourceId].some((value) => typeof value !== "string" || !value.length || value.length > 256)) return reject("invalid_query");
|
|
2319
|
+
const packages = session.project.packages.filter((pkg) => pkg.id === selector.packageId);
|
|
2320
|
+
if (packages.length !== 1) return reject(packages.length ? "ambiguous" : "not_found");
|
|
2321
|
+
const resources = packages[0].resources.filter((resource) => resource.id === selector.resourceId);
|
|
2322
|
+
if (resources.length !== 1) return reject(resources.length ? "ambiguous" : "not_found");
|
|
2323
|
+
const resource = resources[0];
|
|
2324
|
+
if (resource.kind === "component") return reject("unsupported_resource");
|
|
2325
|
+
if (!(resource.sourceBytes instanceof Uint8Array)) return reject("bytes_unavailable");
|
|
2326
|
+
if (resource.sourceBytes.byteLength > BACKEND_SESSION_READ_LIMITS.resourceBytes) return reject("response_budget_exceeded");
|
|
2327
|
+
const meta = {
|
|
2328
|
+
sessionId: session.sessionId,
|
|
2329
|
+
revision: session.revision
|
|
2330
|
+
};
|
|
2331
|
+
return success("read", startedAt, {
|
|
2332
|
+
...meta,
|
|
2333
|
+
selector: { ...selector },
|
|
2334
|
+
sourceBytes: new Uint8Array(resource.sourceBytes)
|
|
2335
|
+
}, meta);
|
|
2336
|
+
}
|
|
1175
2337
|
validateSession(input) {
|
|
1176
2338
|
const startedAt = Date.now();
|
|
1177
2339
|
const session = this.context.sessions.get(input.sessionId);
|
|
@@ -1188,7 +2350,8 @@ var ReadService = class {
|
|
|
1188
2350
|
code,
|
|
1189
2351
|
message,
|
|
1190
2352
|
severity,
|
|
1191
|
-
path
|
|
2353
|
+
path,
|
|
2354
|
+
owner: "core.validation"
|
|
1192
2355
|
}))
|
|
1193
2356
|
});
|
|
1194
2357
|
}
|
|
@@ -1249,63 +2412,6 @@ function createProjectReaderFileSystem(fileSystem, projectRoot) {
|
|
|
1249
2412
|
}
|
|
1250
2413
|
};
|
|
1251
2414
|
}
|
|
1252
|
-
function createCaptureFileSystem(files, directories) {
|
|
1253
|
-
const normalize = (filePath) => filePath.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
1254
|
-
return {
|
|
1255
|
-
async readFile(filePath) {
|
|
1256
|
-
const value = files.get(normalize(filePath));
|
|
1257
|
-
if (typeof value !== "string") throw new Error(`Captured text file was not found: ${filePath}`);
|
|
1258
|
-
return value;
|
|
1259
|
-
},
|
|
1260
|
-
async readFileRaw(filePath) {
|
|
1261
|
-
const value = files.get(normalize(filePath));
|
|
1262
|
-
if (!(value instanceof Uint8Array)) throw new Error(`Captured binary file was not found: ${filePath}`);
|
|
1263
|
-
return value.slice();
|
|
1264
|
-
},
|
|
1265
|
-
async writeFile(filePath, content) {
|
|
1266
|
-
files.set(normalize(filePath), content);
|
|
1267
|
-
},
|
|
1268
|
-
async writeFileRaw(filePath, data) {
|
|
1269
|
-
files.set(normalize(filePath), data.slice());
|
|
1270
|
-
},
|
|
1271
|
-
async mkdir(dirPath) {
|
|
1272
|
-
directories.add(normalize(dirPath));
|
|
1273
|
-
},
|
|
1274
|
-
async readdir() {
|
|
1275
|
-
return [];
|
|
1276
|
-
},
|
|
1277
|
-
async exists(filePath) {
|
|
1278
|
-
return files.has(normalize(filePath));
|
|
1279
|
-
},
|
|
1280
|
-
join(...paths) {
|
|
1281
|
-
return normalize(paths.filter(Boolean).join("/"));
|
|
1282
|
-
},
|
|
1283
|
-
dirname(filePath) {
|
|
1284
|
-
const normalized = normalize(filePath);
|
|
1285
|
-
const separator = normalized.lastIndexOf("/");
|
|
1286
|
-
return separator < 0 ? "" : normalized.slice(0, separator);
|
|
1287
|
-
},
|
|
1288
|
-
async unlink(filePath) {
|
|
1289
|
-
files.delete(normalize(filePath));
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
|
-
function capturedFilesEqual(left, right) {
|
|
1294
|
-
if (left.size !== right.size) return false;
|
|
1295
|
-
for (const [filePath, leftValue] of left) {
|
|
1296
|
-
const rightValue = right.get(filePath);
|
|
1297
|
-
if (typeof leftValue === "string") {
|
|
1298
|
-
if (leftValue !== rightValue) return false;
|
|
1299
|
-
continue;
|
|
1300
|
-
}
|
|
1301
|
-
if (!(rightValue instanceof Uint8Array) || leftValue.length !== rightValue.length) return false;
|
|
1302
|
-
for (let index = 0; index < leftValue.length; index += 1) if (leftValue[index] !== rightValue[index]) return false;
|
|
1303
|
-
}
|
|
1304
|
-
return true;
|
|
1305
|
-
}
|
|
1306
|
-
function capturedDirectoriesEqual(left, right) {
|
|
1307
|
-
return left.size === right.size && [...left].every((directory) => right.has(directory));
|
|
1308
|
-
}
|
|
1309
2415
|
async function hasFullUamFidelity(document, project) {
|
|
1310
2416
|
const sourceFiles = /* @__PURE__ */ new Map();
|
|
1311
2417
|
const materializedFiles = /* @__PURE__ */ new Map();
|
|
@@ -1537,7 +2643,11 @@ const BACKEND_METHODS = [
|
|
|
1537
2643
|
"openProjectSession",
|
|
1538
2644
|
"getSession",
|
|
1539
2645
|
"getProjectOutline",
|
|
2646
|
+
"queryEntity",
|
|
2647
|
+
"readSessionState",
|
|
2648
|
+
"readResourceBytes",
|
|
1540
2649
|
"validateSession",
|
|
2650
|
+
"preflightTransaction",
|
|
1541
2651
|
"applyTransaction",
|
|
1542
2652
|
"saveSession",
|
|
1543
2653
|
"materializeSession",
|
|
@@ -1559,7 +2669,7 @@ const ARTIFACT_BRIDGE_CAPABILITY = {
|
|
|
1559
2669
|
function createCapabilities(atomicSave = false) {
|
|
1560
2670
|
return {
|
|
1561
2671
|
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
1562
|
-
capabilitySchemaVersion:
|
|
2672
|
+
capabilitySchemaVersion: 11,
|
|
1563
2673
|
transactionKernelOwner: "@openfairygui/core",
|
|
1564
2674
|
appSeamOwner: "@openfairygui/functions",
|
|
1565
2675
|
runtimeOwner: "@openfairygui/backend",
|
|
@@ -1568,9 +2678,38 @@ function createCapabilities(atomicSave = false) {
|
|
|
1568
2678
|
capabilitySnapshot: true,
|
|
1569
2679
|
sessionSnapshot: true,
|
|
1570
2680
|
projectOutline: true,
|
|
2681
|
+
entityQuery: {
|
|
2682
|
+
kinds: [
|
|
2683
|
+
"project",
|
|
2684
|
+
"package",
|
|
2685
|
+
"resource",
|
|
2686
|
+
"component",
|
|
2687
|
+
"displayNode",
|
|
2688
|
+
"controller",
|
|
2689
|
+
"transition"
|
|
2690
|
+
],
|
|
2691
|
+
projection: "properties",
|
|
2692
|
+
sourceBytes: false,
|
|
2693
|
+
limits: BACKEND_ENTITY_QUERY_LIMITS
|
|
2694
|
+
},
|
|
2695
|
+
sessionState: {
|
|
2696
|
+
sourceBytes: false,
|
|
2697
|
+
limits: BACKEND_SESSION_READ_LIMITS.model
|
|
2698
|
+
},
|
|
2699
|
+
resourceBytes: {
|
|
2700
|
+
expectedRevisionRequired: true,
|
|
2701
|
+
hydration: false,
|
|
2702
|
+
maxBytes: BACKEND_SESSION_READ_LIMITS.resourceBytes
|
|
2703
|
+
},
|
|
1571
2704
|
projectValidation: true
|
|
1572
2705
|
},
|
|
1573
2706
|
authoring: {
|
|
2707
|
+
preflightTransaction: {
|
|
2708
|
+
mode: "execute-and-discard",
|
|
2709
|
+
reservesRevision: false,
|
|
2710
|
+
impact: "model-diff",
|
|
2711
|
+
limits: BACKEND_TRANSACTION_PREVIEW_LIMITS
|
|
2712
|
+
},
|
|
1574
2713
|
applyTransaction: true,
|
|
1575
2714
|
saveSession: true,
|
|
1576
2715
|
resourceKinds: [..._openfairygui_core_uam.UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
|
|
@@ -1620,7 +2759,9 @@ function createCapabilities(atomicSave = false) {
|
|
|
1620
2759
|
},
|
|
1621
2760
|
diagnostics: {
|
|
1622
2761
|
stableCodes: true,
|
|
1623
|
-
errorDiagnosticMirror: true
|
|
2762
|
+
errorDiagnosticMirror: true,
|
|
2763
|
+
recoveryGuides: "all-formal-codes",
|
|
2764
|
+
automaticRepair: false
|
|
1624
2765
|
}
|
|
1625
2766
|
},
|
|
1626
2767
|
compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
|
|
@@ -1721,9 +2862,21 @@ var BackendRuntime = class {
|
|
|
1721
2862
|
getProjectOutline(input) {
|
|
1722
2863
|
return this.readService.getProjectOutline(input);
|
|
1723
2864
|
}
|
|
2865
|
+
queryEntity(input) {
|
|
2866
|
+
return this.readService.queryEntity(input);
|
|
2867
|
+
}
|
|
2868
|
+
readSessionState(input) {
|
|
2869
|
+
return this.readService.readSessionState(input);
|
|
2870
|
+
}
|
|
2871
|
+
readResourceBytes(input) {
|
|
2872
|
+
return this.readService.readResourceBytes(input);
|
|
2873
|
+
}
|
|
1724
2874
|
validateSession(input) {
|
|
1725
2875
|
return this.readService.validateSession(input);
|
|
1726
2876
|
}
|
|
2877
|
+
async preflightTransaction(input) {
|
|
2878
|
+
return this.authoringService.preflightTransaction(input);
|
|
2879
|
+
}
|
|
1727
2880
|
async applyTransaction(input) {
|
|
1728
2881
|
return this.authoringService.applyTransaction(input);
|
|
1729
2882
|
}
|