@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/index.mjs
CHANGED
|
@@ -3,14 +3,650 @@ import { applyUamTransactionAppAsync } from "@openfairygui/functions/uam";
|
|
|
3
3
|
import { ProjectReader, ProjectWriter } from "@openfairygui/core/project-io";
|
|
4
4
|
import { validateProject } from "@openfairygui/functions";
|
|
5
5
|
//#region src/contracts.ts
|
|
6
|
-
const BACKEND_CONTRACT_VERSION = "
|
|
7
|
-
const BACKEND_CAPABILITY_SCHEMA_VERSION =
|
|
6
|
+
const BACKEND_CONTRACT_VERSION = "2.0.0-p2";
|
|
7
|
+
const BACKEND_CAPABILITY_SCHEMA_VERSION = 11;
|
|
8
8
|
const BACKEND_COMPATIBILITY_POLICY = {
|
|
9
9
|
incompatibleChange: "requires contractVersion bump",
|
|
10
10
|
capabilitySchemaChange: "requires capabilitySchemaVersion bump",
|
|
11
11
|
additiveChange: "allowed without breaking existing consumers"
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
|
+
//#region src/diagnostics.ts
|
|
15
|
+
const selector = {
|
|
16
|
+
kind: "revise-selector",
|
|
17
|
+
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."
|
|
18
|
+
};
|
|
19
|
+
const source = {
|
|
20
|
+
kind: "host-action",
|
|
21
|
+
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."
|
|
22
|
+
};
|
|
23
|
+
const path = {
|
|
24
|
+
kind: "host-action",
|
|
25
|
+
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."
|
|
26
|
+
};
|
|
27
|
+
const unsupported = {
|
|
28
|
+
kind: "revise-operation",
|
|
29
|
+
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."
|
|
30
|
+
};
|
|
31
|
+
const payload = {
|
|
32
|
+
kind: "revise-operation",
|
|
33
|
+
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."
|
|
34
|
+
};
|
|
35
|
+
const unchanged = {
|
|
36
|
+
kind: "refresh-and-replan",
|
|
37
|
+
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."
|
|
38
|
+
};
|
|
39
|
+
const duplicate = {
|
|
40
|
+
kind: "revise-operation",
|
|
41
|
+
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."
|
|
42
|
+
};
|
|
43
|
+
const references = {
|
|
44
|
+
kind: "revise-operation",
|
|
45
|
+
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."
|
|
46
|
+
};
|
|
47
|
+
const project = {
|
|
48
|
+
kind: "host-action",
|
|
49
|
+
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."
|
|
50
|
+
};
|
|
51
|
+
const capability = {
|
|
52
|
+
kind: "host-action",
|
|
53
|
+
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."
|
|
54
|
+
};
|
|
55
|
+
const write = {
|
|
56
|
+
kind: "host-action",
|
|
57
|
+
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."
|
|
58
|
+
};
|
|
59
|
+
const execution = {
|
|
60
|
+
kind: "host-action",
|
|
61
|
+
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."
|
|
62
|
+
};
|
|
63
|
+
const job = {
|
|
64
|
+
kind: "host-action",
|
|
65
|
+
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."
|
|
66
|
+
};
|
|
67
|
+
/** Exhaustiveness and exact ownership are checked against the canonical unions. */
|
|
68
|
+
const BACKEND_DIAGNOSTIC_GUIDES = [
|
|
69
|
+
{
|
|
70
|
+
code: "stale_read",
|
|
71
|
+
owners: ["backend"],
|
|
72
|
+
remediation: {
|
|
73
|
+
kind: "refresh-and-replan",
|
|
74
|
+
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."
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
code: "session_read_failed",
|
|
79
|
+
owners: ["backend"],
|
|
80
|
+
remediation: {
|
|
81
|
+
kind: "host-action",
|
|
82
|
+
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."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
code: "transaction_preview_failed",
|
|
87
|
+
owners: ["backend"],
|
|
88
|
+
remediation: {
|
|
89
|
+
kind: "host-action",
|
|
90
|
+
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."
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
code: "stale_write",
|
|
95
|
+
owners: ["backend"],
|
|
96
|
+
remediation: {
|
|
97
|
+
kind: "refresh-and-replan",
|
|
98
|
+
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."
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
code: "entity_query_failed",
|
|
103
|
+
owners: ["backend"],
|
|
104
|
+
remediation: {
|
|
105
|
+
kind: "host-action",
|
|
106
|
+
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."
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
code: "session_not_found",
|
|
111
|
+
owners: ["backend"],
|
|
112
|
+
remediation: {
|
|
113
|
+
kind: "host-action",
|
|
114
|
+
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."
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
code: "path_policy_violation",
|
|
119
|
+
owners: ["backend"],
|
|
120
|
+
remediation: path
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
code: "project_root_not_allowed",
|
|
124
|
+
owners: ["backend"],
|
|
125
|
+
remediation: path
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
code: "invalid_package_selector",
|
|
129
|
+
owners: ["core.transaction"],
|
|
130
|
+
remediation: selector
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
code: "invalid_component_selector",
|
|
134
|
+
owners: ["core.transaction"],
|
|
135
|
+
remediation: selector
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: "invalid_resource_selector",
|
|
139
|
+
owners: ["core.transaction"],
|
|
140
|
+
remediation: selector
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
code: "invalid_display_node_selector",
|
|
144
|
+
owners: ["core.transaction"],
|
|
145
|
+
remediation: selector
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
code: "invalid_resource_folder_selector",
|
|
149
|
+
owners: ["core.transaction"],
|
|
150
|
+
remediation: selector
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
code: "invalid_branch_selector",
|
|
154
|
+
owners: ["core.transaction"],
|
|
155
|
+
remediation: selector
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
code: "invalid_gear_selector",
|
|
159
|
+
owners: ["core.transaction"],
|
|
160
|
+
remediation: selector
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
code: "invalid_look_gear_selector",
|
|
164
|
+
owners: ["core.transaction"],
|
|
165
|
+
remediation: selector
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
code: "selector_ambiguity",
|
|
169
|
+
owners: ["core.transaction"],
|
|
170
|
+
remediation: selector
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
code: "unavailable_resource_source_bytes",
|
|
174
|
+
owners: ["core.transaction"],
|
|
175
|
+
remediation: source
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
code: "missing_source",
|
|
179
|
+
owners: ["core.validation"],
|
|
180
|
+
remediation: source
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
code: "unreadable_source",
|
|
184
|
+
owners: ["core.validation"],
|
|
185
|
+
remediation: source
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
code: "decode_capability_unavailable",
|
|
189
|
+
owners: ["core.validation"],
|
|
190
|
+
remediation: {
|
|
191
|
+
kind: "host-action",
|
|
192
|
+
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."
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: "session_id_conflict",
|
|
197
|
+
owners: ["backend"],
|
|
198
|
+
remediation: {
|
|
199
|
+
kind: "host-action",
|
|
200
|
+
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."
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
code: "lock_conflict",
|
|
205
|
+
owners: ["backend"],
|
|
206
|
+
remediation: {
|
|
207
|
+
kind: "host-action",
|
|
208
|
+
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."
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
code: "event_cursor_invalid",
|
|
213
|
+
owners: ["backend"],
|
|
214
|
+
remediation: {
|
|
215
|
+
kind: "refresh-and-replan",
|
|
216
|
+
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."
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
code: "corrupt_source",
|
|
221
|
+
owners: ["core.validation"],
|
|
222
|
+
remediation: source
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
code: "unsupported_operation",
|
|
226
|
+
owners: ["core.transaction"],
|
|
227
|
+
remediation: unsupported
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
code: "transaction_unsupported",
|
|
231
|
+
owners: ["core.transaction"],
|
|
232
|
+
remediation: unsupported
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
code: "unsupported_display_node_kind",
|
|
236
|
+
owners: ["core.transaction"],
|
|
237
|
+
remediation: unsupported
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
code: "unsupported_cross_package_image_ref",
|
|
241
|
+
owners: ["core.transaction"],
|
|
242
|
+
remediation: unsupported
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
code: "unsupported_gear_kind",
|
|
246
|
+
owners: ["core.transaction"],
|
|
247
|
+
remediation: unsupported
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
code: "unsupported_resource_mutation",
|
|
251
|
+
owners: ["core.transaction"],
|
|
252
|
+
remediation: unsupported
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
code: "unsupported_display_node_mutation",
|
|
256
|
+
owners: ["core.transaction"],
|
|
257
|
+
remediation: unsupported
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
code: "unsupported_text_field_target",
|
|
261
|
+
owners: ["core.transaction"],
|
|
262
|
+
remediation: unsupported
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
code: "unsupported_display_node_field",
|
|
266
|
+
owners: ["core.transaction"],
|
|
267
|
+
remediation: unsupported
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
code: "unsupported_operation_batch",
|
|
271
|
+
owners: ["core.transaction"],
|
|
272
|
+
remediation: unsupported
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
code: "unsupported_resource_kind",
|
|
276
|
+
owners: ["core.transaction", "core.validation"],
|
|
277
|
+
remediation: unsupported
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
code: "invalid_project_settings",
|
|
281
|
+
owners: ["core.transaction"],
|
|
282
|
+
remediation: payload
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
code: "invalid_package_settings",
|
|
286
|
+
owners: ["core.transaction"],
|
|
287
|
+
remediation: payload
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
code: "invalid_display_node_payload",
|
|
291
|
+
owners: ["core.transaction"],
|
|
292
|
+
remediation: payload
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
code: "invalid_resource_name",
|
|
296
|
+
owners: ["core.transaction"],
|
|
297
|
+
remediation: payload
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
code: "invalid_resource_path",
|
|
301
|
+
owners: ["core.transaction"],
|
|
302
|
+
remediation: payload
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
code: "invalid_resource_folder_path",
|
|
306
|
+
owners: ["core.transaction"],
|
|
307
|
+
remediation: payload
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
code: "invalid_resource_folder_atlas",
|
|
311
|
+
owners: ["core.transaction"],
|
|
312
|
+
remediation: payload
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
code: "invalid_attach_index",
|
|
316
|
+
owners: ["core.transaction"],
|
|
317
|
+
remediation: payload
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
code: "invalid_controller_payload",
|
|
321
|
+
owners: ["core.transaction"],
|
|
322
|
+
remediation: payload
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
code: "invalid_transition_payload",
|
|
326
|
+
owners: ["core.transaction"],
|
|
327
|
+
remediation: payload
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
code: "invalid_look_gear_payload",
|
|
331
|
+
owners: ["core.transaction"],
|
|
332
|
+
remediation: payload
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
code: "invalid_gear_payload",
|
|
336
|
+
owners: ["core.transaction"],
|
|
337
|
+
remediation: payload
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
code: "invalid_resource_payload",
|
|
341
|
+
owners: ["core.transaction"],
|
|
342
|
+
remediation: payload
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
code: "invalid_resource_bytes",
|
|
346
|
+
owners: ["core.transaction"],
|
|
347
|
+
remediation: payload
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
code: "invalid_movie_clip_jta",
|
|
351
|
+
owners: ["core.transaction"],
|
|
352
|
+
remediation: payload
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
code: "invalid_resource_index",
|
|
356
|
+
owners: ["core.transaction"],
|
|
357
|
+
remediation: payload
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
code: "invalid_branch_name",
|
|
361
|
+
owners: ["core.transaction"],
|
|
362
|
+
remediation: payload
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
code: "invalid_package_payload",
|
|
366
|
+
owners: ["core.transaction"],
|
|
367
|
+
remediation: payload
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
code: "invalid_package_index",
|
|
371
|
+
owners: ["core.transaction"],
|
|
372
|
+
remediation: payload
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
code: "invalid_component_payload",
|
|
376
|
+
owners: ["core.transaction"],
|
|
377
|
+
remediation: payload
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
code: "invalid_component_index",
|
|
381
|
+
owners: ["core.transaction"],
|
|
382
|
+
remediation: payload
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
code: "invalid_component_move",
|
|
386
|
+
owners: ["core.transaction"],
|
|
387
|
+
remediation: payload
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
code: "invalid_uam",
|
|
391
|
+
owners: ["core.transaction", "core.validation"],
|
|
392
|
+
remediation: payload
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
code: "project_settings_unchanged",
|
|
396
|
+
owners: ["core.transaction"],
|
|
397
|
+
remediation: unchanged
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
code: "package_settings_unchanged",
|
|
401
|
+
owners: ["core.transaction"],
|
|
402
|
+
remediation: unchanged
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
code: "display_node_props_unchanged",
|
|
406
|
+
owners: ["core.transaction"],
|
|
407
|
+
remediation: unchanged
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
code: "resource_folder_atlas_unchanged",
|
|
411
|
+
owners: ["core.transaction"],
|
|
412
|
+
remediation: unchanged
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
code: "duplicate_look_gear_controller",
|
|
416
|
+
owners: ["core.transaction"],
|
|
417
|
+
remediation: duplicate
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
code: "duplicate_transition_name",
|
|
421
|
+
owners: ["core.transaction"],
|
|
422
|
+
remediation: duplicate
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
code: "duplicate_look_gear_state_page",
|
|
426
|
+
owners: ["core.transaction"],
|
|
427
|
+
remediation: duplicate
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
code: "duplicate_gear_controller",
|
|
431
|
+
owners: ["core.transaction"],
|
|
432
|
+
remediation: duplicate
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
code: "duplicate_gear_state_page",
|
|
436
|
+
owners: ["core.transaction"],
|
|
437
|
+
remediation: duplicate
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
code: "duplicate_branch_name",
|
|
441
|
+
owners: ["core.transaction"],
|
|
442
|
+
remediation: duplicate
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
code: "duplicate_component_id",
|
|
446
|
+
owners: ["core.transaction"],
|
|
447
|
+
remediation: duplicate
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
code: "resource_folder_conflict",
|
|
451
|
+
owners: ["core.transaction"],
|
|
452
|
+
remediation: duplicate
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
code: "duplicate_resource_id",
|
|
456
|
+
owners: ["core.transaction", "core.validation"],
|
|
457
|
+
remediation: duplicate
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
code: "duplicate_package_id",
|
|
461
|
+
owners: ["core.transaction", "core.validation"],
|
|
462
|
+
remediation: duplicate
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
code: "duplicate_package_name",
|
|
466
|
+
owners: ["core.transaction", "core.validation"],
|
|
467
|
+
remediation: duplicate
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
code: "resource_folder_not_empty",
|
|
471
|
+
owners: ["core.transaction"],
|
|
472
|
+
remediation: references
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
code: "branch_not_empty",
|
|
476
|
+
owners: ["core.transaction"],
|
|
477
|
+
remediation: references
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
code: "branch_referenced",
|
|
481
|
+
owners: ["core.transaction"],
|
|
482
|
+
remediation: references
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
code: "invalid_resource_reference",
|
|
486
|
+
owners: ["core.transaction"],
|
|
487
|
+
remediation: references
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
code: "invalid_component_reference",
|
|
491
|
+
owners: ["core.transaction"],
|
|
492
|
+
remediation: references
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
code: "invalid_group_reference",
|
|
496
|
+
owners: ["core.transaction"],
|
|
497
|
+
remediation: references
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
code: "package_referenced",
|
|
501
|
+
owners: ["core.transaction"],
|
|
502
|
+
remediation: references
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
code: "component_referenced",
|
|
506
|
+
owners: ["core.transaction"],
|
|
507
|
+
remediation: references
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
code: "component_has_package_dependencies",
|
|
511
|
+
owners: ["core.transaction"],
|
|
512
|
+
remediation: references
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
code: "dangling_resource_reference",
|
|
516
|
+
owners: ["core.validation"],
|
|
517
|
+
remediation: references
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
code: "invalid_project_xml",
|
|
521
|
+
owners: ["core.validation"],
|
|
522
|
+
remediation: project
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
code: "invalid_package_xml",
|
|
526
|
+
owners: ["core.validation"],
|
|
527
|
+
remediation: project
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
code: "invalid_branch_package_xml",
|
|
531
|
+
owners: ["core.validation"],
|
|
532
|
+
remediation: project
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
code: "invalid_component_xml",
|
|
536
|
+
owners: ["core.validation"],
|
|
537
|
+
remediation: project
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
code: "invalid_project_value",
|
|
541
|
+
owners: ["core.validation"],
|
|
542
|
+
remediation: project
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
code: "desktop_incompatible_geometry",
|
|
546
|
+
owners: ["core.validation"],
|
|
547
|
+
remediation: project
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
code: "invalid_settings_json",
|
|
551
|
+
owners: ["core.validation"],
|
|
552
|
+
remediation: project
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
code: "path_collision",
|
|
556
|
+
owners: ["core.validation"],
|
|
557
|
+
remediation: path
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
code: "unsafe_path",
|
|
561
|
+
owners: ["core.validation"],
|
|
562
|
+
remediation: path
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
code: "capability_unavailable",
|
|
566
|
+
owners: ["backend"],
|
|
567
|
+
remediation: capability
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
code: "uam_fidelity_unsupported",
|
|
571
|
+
owners: ["backend"],
|
|
572
|
+
remediation: capability
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
code: "save_partial_failure",
|
|
576
|
+
owners: ["backend"],
|
|
577
|
+
remediation: write
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
code: "write_failed",
|
|
581
|
+
owners: ["backend"],
|
|
582
|
+
remediation: write
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
code: "project_open_failed",
|
|
586
|
+
owners: ["backend"],
|
|
587
|
+
remediation: project
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
code: "materialize_validation_failed",
|
|
591
|
+
owners: ["backend"],
|
|
592
|
+
remediation: project
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
code: "execution_failure",
|
|
596
|
+
owners: ["core.transaction"],
|
|
597
|
+
remediation: execution
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
code: "cache_refresh_failed",
|
|
601
|
+
owners: ["backend"],
|
|
602
|
+
remediation: execution
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
code: "job_not_found",
|
|
606
|
+
owners: ["backend"],
|
|
607
|
+
remediation: job
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
code: "job_not_cancellable",
|
|
611
|
+
owners: ["backend"],
|
|
612
|
+
remediation: job
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
code: "job_cancelled",
|
|
616
|
+
owners: ["backend"],
|
|
617
|
+
remediation: job
|
|
618
|
+
}
|
|
619
|
+
];
|
|
620
|
+
const BACKEND_DIAGNOSTICS_URI = "openfairygui://docs/diagnostics";
|
|
621
|
+
const BACKEND_DIAGNOSTIC_TEMPLATE = `${BACKEND_DIAGNOSTICS_URI}/{code}`;
|
|
622
|
+
function getBackendDiagnosticCatalog() {
|
|
623
|
+
return BACKEND_DIAGNOSTIC_GUIDES.map((guide) => ({
|
|
624
|
+
...structuredClone(guide),
|
|
625
|
+
docsUri: `${BACKEND_DIAGNOSTICS_URI}/${guide.code}`
|
|
626
|
+
}));
|
|
627
|
+
}
|
|
628
|
+
function getBackendDiagnosticGuide(code) {
|
|
629
|
+
const guide = getBackendDiagnosticCatalog().find((entry) => entry.code === code);
|
|
630
|
+
if (!guide) throw new RangeError(`No recovery guide for diagnostic: ${code}`);
|
|
631
|
+
return guide;
|
|
632
|
+
}
|
|
633
|
+
function enrichBackendDiagnostic(diagnostic, sessionId) {
|
|
634
|
+
const guide = BACKEND_DIAGNOSTIC_GUIDES.find((entry) => entry.code === diagnostic.code);
|
|
635
|
+
if (!guide) return { ...diagnostic };
|
|
636
|
+
return {
|
|
637
|
+
...diagnostic,
|
|
638
|
+
owner: diagnostic.owner ?? guide.owners[0],
|
|
639
|
+
docsUri: `${BACKEND_DIAGNOSTICS_URI}/${guide.code}`,
|
|
640
|
+
remediation: {
|
|
641
|
+
...guide.remediation,
|
|
642
|
+
...sessionId && guide.remediation.kind !== "host-action" ? { read: {
|
|
643
|
+
method: "getProjectOutline",
|
|
644
|
+
input: { sessionId }
|
|
645
|
+
} } : {}
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
14
650
|
//#region src/path-policy.ts
|
|
15
651
|
function normalizeComparablePath(value) {
|
|
16
652
|
const normalized = value.replace(/[/\\]+$/, "").replace(/\\/g, "/");
|
|
@@ -104,10 +740,10 @@ function createMeta(stage, startedAt, options) {
|
|
|
104
740
|
revision: options?.revision,
|
|
105
741
|
durationMs: Math.max(0, Date.now() - startedAt),
|
|
106
742
|
warnings: options?.warnings ?? [],
|
|
107
|
-
diagnostics: options?.diagnostics ?? [],
|
|
743
|
+
diagnostics: (options?.diagnostics ?? []).map((entry) => enrichBackendDiagnostic(entry, options?.sessionId)),
|
|
108
744
|
stage,
|
|
109
745
|
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
110
|
-
capabilitySchemaVersion:
|
|
746
|
+
capabilitySchemaVersion: 11
|
|
111
747
|
};
|
|
112
748
|
}
|
|
113
749
|
function success(stage, startedAt, data, options) {
|
|
@@ -223,6 +859,268 @@ function createStaleWriteError(session, expectedRevision) {
|
|
|
223
859
|
};
|
|
224
860
|
}
|
|
225
861
|
//#endregion
|
|
862
|
+
//#region src/runtime/contracts.ts
|
|
863
|
+
const BACKEND_ENTITY_QUERY_LIMITS = {
|
|
864
|
+
maxBytes: 262144,
|
|
865
|
+
maxDepth: 32,
|
|
866
|
+
maxNodes: 1e5
|
|
867
|
+
};
|
|
868
|
+
const BACKEND_SESSION_READ_LIMITS = {
|
|
869
|
+
model: {
|
|
870
|
+
maxBytes: 4194304,
|
|
871
|
+
maxDepth: 64,
|
|
872
|
+
maxNodes: 5e5
|
|
873
|
+
},
|
|
874
|
+
resourceBytes: 1048576
|
|
875
|
+
};
|
|
876
|
+
const BACKEND_TRANSACTION_PREVIEW_LIMITS = {
|
|
877
|
+
maxBytes: 262144,
|
|
878
|
+
maxEntries: 2e3
|
|
879
|
+
};
|
|
880
|
+
/** Fixed resource projection. Binary content, source bookkeeping and arbitrary metadata are excluded. */
|
|
881
|
+
const BACKEND_RESOURCE_QUERY_FIELDS = [
|
|
882
|
+
"kind",
|
|
883
|
+
"id",
|
|
884
|
+
"name",
|
|
885
|
+
"path",
|
|
886
|
+
"exported",
|
|
887
|
+
"favorite",
|
|
888
|
+
"branch",
|
|
889
|
+
"branchItemIds",
|
|
890
|
+
"fileName",
|
|
891
|
+
"file",
|
|
892
|
+
"dimensions",
|
|
893
|
+
"image",
|
|
894
|
+
"movieClip"
|
|
895
|
+
];
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/services/capture-project.ts
|
|
898
|
+
function createCaptureFileSystem(files, directories) {
|
|
899
|
+
const normalize = (filePath) => filePath.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
900
|
+
return {
|
|
901
|
+
async readFile(filePath) {
|
|
902
|
+
const value = files.get(normalize(filePath));
|
|
903
|
+
if (typeof value !== "string") throw new Error(`Captured text file was not found: ${filePath}`);
|
|
904
|
+
return value;
|
|
905
|
+
},
|
|
906
|
+
async readFileRaw(filePath) {
|
|
907
|
+
const value = files.get(normalize(filePath));
|
|
908
|
+
if (!(value instanceof Uint8Array)) throw new Error(`Captured binary file was not found: ${filePath}`);
|
|
909
|
+
return value.slice();
|
|
910
|
+
},
|
|
911
|
+
async writeFile(filePath, content) {
|
|
912
|
+
files.set(normalize(filePath), content);
|
|
913
|
+
},
|
|
914
|
+
async writeFileRaw(filePath, data) {
|
|
915
|
+
files.set(normalize(filePath), data.slice());
|
|
916
|
+
},
|
|
917
|
+
async mkdir(dirPath) {
|
|
918
|
+
directories.add(normalize(dirPath));
|
|
919
|
+
},
|
|
920
|
+
async readdir() {
|
|
921
|
+
return [];
|
|
922
|
+
},
|
|
923
|
+
async exists(filePath) {
|
|
924
|
+
return files.has(normalize(filePath));
|
|
925
|
+
},
|
|
926
|
+
join(...paths) {
|
|
927
|
+
return normalize(paths.filter(Boolean).join("/"));
|
|
928
|
+
},
|
|
929
|
+
dirname(filePath) {
|
|
930
|
+
const normalized = normalize(filePath);
|
|
931
|
+
const separator = normalized.lastIndexOf("/");
|
|
932
|
+
return separator < 0 ? "" : normalized.slice(0, separator);
|
|
933
|
+
},
|
|
934
|
+
async unlink(filePath) {
|
|
935
|
+
files.delete(normalize(filePath));
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
function capturedFilesEqual(left, right) {
|
|
940
|
+
if (left.size !== right.size) return false;
|
|
941
|
+
for (const [filePath, leftValue] of left) {
|
|
942
|
+
const rightValue = right.get(filePath);
|
|
943
|
+
if (typeof leftValue === "string") {
|
|
944
|
+
if (leftValue !== rightValue) return false;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
if (!(rightValue instanceof Uint8Array) || leftValue.length !== rightValue.length) return false;
|
|
948
|
+
for (let index = 0; index < leftValue.length; index += 1) if (leftValue[index] !== rightValue[index]) return false;
|
|
949
|
+
}
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
function capturedDirectoriesEqual(left, right) {
|
|
953
|
+
return left.size === right.size && [...left].every((directory) => right.has(directory));
|
|
954
|
+
}
|
|
955
|
+
/** Serialize only into memory. This is a model projection, not a disk inventory or write plan. */
|
|
956
|
+
async function captureProject(document, fairyFileName) {
|
|
957
|
+
const files = /* @__PURE__ */ new Map();
|
|
958
|
+
const directories = /* @__PURE__ */ new Set();
|
|
959
|
+
await new ProjectWriter(createCaptureFileSystem(files, directories)).write(document, fairyFileName);
|
|
960
|
+
return {
|
|
961
|
+
files,
|
|
962
|
+
directories
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/services/transaction-preview.ts
|
|
967
|
+
/** Keep child identities/order on their parent, and compare each child's own properties separately. */
|
|
968
|
+
function entities(project) {
|
|
969
|
+
const result = /* @__PURE__ */ new Map();
|
|
970
|
+
function add(target, properties) {
|
|
971
|
+
const key = JSON.stringify(target);
|
|
972
|
+
if (result.has(key)) throw new Error(`Ambiguous preview identity: ${key}`);
|
|
973
|
+
result.set(key, {
|
|
974
|
+
target,
|
|
975
|
+
properties
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
const { packages, ...properties } = project;
|
|
979
|
+
add({ kind: "project" }, {
|
|
980
|
+
...properties,
|
|
981
|
+
packages: packages.map((pkg) => pkg.id)
|
|
982
|
+
});
|
|
983
|
+
for (const { resources, ...pkg } of packages) {
|
|
984
|
+
const packageId = pkg.id;
|
|
985
|
+
add({
|
|
986
|
+
kind: "package",
|
|
987
|
+
selector: { packageId }
|
|
988
|
+
}, {
|
|
989
|
+
...pkg,
|
|
990
|
+
resources: resources.map((resource) => resource.id)
|
|
991
|
+
});
|
|
992
|
+
for (const resource of resources) {
|
|
993
|
+
const resourceTarget = {
|
|
994
|
+
kind: "resource",
|
|
995
|
+
selector: {
|
|
996
|
+
packageId,
|
|
997
|
+
resourceId: resource.id
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
if (resource.kind !== "component") {
|
|
1001
|
+
add(resourceTarget, resource);
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
const { component, ...resourceProperties } = resource;
|
|
1005
|
+
add(resourceTarget, resourceProperties);
|
|
1006
|
+
const { displayList, controllers, transitions, ...componentProperties } = component;
|
|
1007
|
+
const selector = {
|
|
1008
|
+
packageId,
|
|
1009
|
+
componentResourceId: resource.id
|
|
1010
|
+
};
|
|
1011
|
+
add({
|
|
1012
|
+
kind: "component",
|
|
1013
|
+
selector
|
|
1014
|
+
}, {
|
|
1015
|
+
...componentProperties,
|
|
1016
|
+
displayList: displayList.map((node) => node.id),
|
|
1017
|
+
controllers: controllers.map((controller) => controller.name),
|
|
1018
|
+
transitions: transitions.map((transition) => transition.name)
|
|
1019
|
+
});
|
|
1020
|
+
for (const node of displayList) add({
|
|
1021
|
+
kind: "displayNode",
|
|
1022
|
+
selector: {
|
|
1023
|
+
...selector,
|
|
1024
|
+
displayNodeId: node.id
|
|
1025
|
+
}
|
|
1026
|
+
}, node);
|
|
1027
|
+
for (const controller of controllers) add({
|
|
1028
|
+
kind: "controller",
|
|
1029
|
+
selector: {
|
|
1030
|
+
...selector,
|
|
1031
|
+
controllerName: controller.name
|
|
1032
|
+
}
|
|
1033
|
+
}, controller);
|
|
1034
|
+
for (const transition of transitions) add({
|
|
1035
|
+
kind: "transition",
|
|
1036
|
+
selector: {
|
|
1037
|
+
...selector,
|
|
1038
|
+
transitionName: transition.name
|
|
1039
|
+
}
|
|
1040
|
+
}, transition);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
return result;
|
|
1044
|
+
}
|
|
1045
|
+
function equal(left, right, depth = 0) {
|
|
1046
|
+
if (left === right) return true;
|
|
1047
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object") return false;
|
|
1048
|
+
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]);
|
|
1049
|
+
if (depth > 128) throw new Error("Preview property comparison exceeds the supported nesting depth.");
|
|
1050
|
+
if (Array.isArray(left) !== Array.isArray(right)) return false;
|
|
1051
|
+
if (Array.isArray(left) && Array.isArray(right) && left.length !== right.length) return false;
|
|
1052
|
+
const a = left, b = right;
|
|
1053
|
+
const keys = Object.keys(a);
|
|
1054
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && equal(a[key], b[key], depth + 1));
|
|
1055
|
+
}
|
|
1056
|
+
var PreviewBudgetError = class extends Error {};
|
|
1057
|
+
/** No host filesystem, cache, event or session mutation is involved in the projection. */
|
|
1058
|
+
async function previewTransactionImpact(session, project, fileSystemAvailable) {
|
|
1059
|
+
const impact = {
|
|
1060
|
+
entities: [],
|
|
1061
|
+
files: []
|
|
1062
|
+
};
|
|
1063
|
+
const before = entities(session.project), after = entities(project);
|
|
1064
|
+
let entries = 0, bytes = 0;
|
|
1065
|
+
const encoder = new TextEncoder();
|
|
1066
|
+
function count(value) {
|
|
1067
|
+
bytes += encoder.encode(JSON.stringify(value)).byteLength;
|
|
1068
|
+
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.");
|
|
1069
|
+
}
|
|
1070
|
+
for (const key of new Set([...before.keys(), ...after.keys()])) {
|
|
1071
|
+
const previous = before.get(key), next = after.get(key);
|
|
1072
|
+
const fields = [...new Set([...Object.keys(previous?.properties ?? {}), ...Object.keys(next?.properties ?? {})])].filter((field) => !previous || !next || !equal(previous.properties[field], next.properties[field])).sort();
|
|
1073
|
+
if (!fields.length && previous && next) continue;
|
|
1074
|
+
const change = {
|
|
1075
|
+
target: (next ?? previous).target,
|
|
1076
|
+
change: !previous ? "added" : !next ? "removed" : "updated",
|
|
1077
|
+
fields
|
|
1078
|
+
};
|
|
1079
|
+
count(change);
|
|
1080
|
+
impact.entities.push(change);
|
|
1081
|
+
}
|
|
1082
|
+
const fairyFileName = session.fileSystem ? session.fairyPath.replace(/\\/g, "/").split("/").at(-1) : "Project.fairy";
|
|
1083
|
+
const [previousFiles, nextFiles] = await Promise.all([captureProject(materializeUamProject(session.project), fairyFileName), captureProject(materializeUamProject(project), fairyFileName)]);
|
|
1084
|
+
for (const path of new Set([...previousFiles.files.keys(), ...nextFiles.files.keys()])) {
|
|
1085
|
+
const previous = previousFiles.files.get(path), next = nextFiles.files.get(path);
|
|
1086
|
+
if (equal(previous, next)) continue;
|
|
1087
|
+
const change = {
|
|
1088
|
+
path,
|
|
1089
|
+
kind: "file",
|
|
1090
|
+
change: previous === void 0 ? "added" : next === void 0 ? "removed" : "updated"
|
|
1091
|
+
};
|
|
1092
|
+
count(change);
|
|
1093
|
+
impact.files.push(change);
|
|
1094
|
+
}
|
|
1095
|
+
for (const path of new Set([...previousFiles.directories, ...nextFiles.directories])) {
|
|
1096
|
+
if (previousFiles.directories.has(path) === nextFiles.directories.has(path)) continue;
|
|
1097
|
+
const change = {
|
|
1098
|
+
path,
|
|
1099
|
+
kind: "directory",
|
|
1100
|
+
change: nextFiles.directories.has(path) ? "added" : "removed"
|
|
1101
|
+
};
|
|
1102
|
+
count(change);
|
|
1103
|
+
impact.files.push(change);
|
|
1104
|
+
}
|
|
1105
|
+
impact.files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.kind.localeCompare(b.kind));
|
|
1106
|
+
const preview = {
|
|
1107
|
+
sessionId: session.sessionId,
|
|
1108
|
+
baseRevision: session.revision,
|
|
1109
|
+
projectedRevision: session.revision + 1,
|
|
1110
|
+
mode: "execute-and-discard",
|
|
1111
|
+
impact,
|
|
1112
|
+
persistence: {
|
|
1113
|
+
requiredAfterApply: true,
|
|
1114
|
+
fileSystemAvailable,
|
|
1115
|
+
uamFidelity: session.uamFidelity,
|
|
1116
|
+
writeVerified: false,
|
|
1117
|
+
nextAction: session.uamFidelity === "unsupported" || !fileSystemAvailable ? "host-action" : session.fileSystem ? "saveSession" : "materializeSession"
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
if (encoder.encode(JSON.stringify(preview)).byteLength > BACKEND_TRANSACTION_PREVIEW_LIMITS.maxBytes) throw new PreviewBudgetError("The complete transaction preview exceeds the response byte budget.");
|
|
1121
|
+
return preview;
|
|
1122
|
+
}
|
|
1123
|
+
//#endregion
|
|
226
1124
|
//#region src/services/authoring-service.ts
|
|
227
1125
|
function sourceFileKey(source) {
|
|
228
1126
|
return [
|
|
@@ -252,8 +1150,12 @@ function recordStaleProjectFiles(session, previousProject, nextProject) {
|
|
|
252
1150
|
for (const directory of staleBranchDirectories(nextProject, previousProject)) session.pendingStaleBranchDirectories.delete(branchDirectoryKey(directory));
|
|
253
1151
|
}
|
|
254
1152
|
function toBackendDiagnostics(error) {
|
|
255
|
-
return error.diagnostics.length > 0 ? error.diagnostics.map((diagnostic) => ({
|
|
1153
|
+
return error.diagnostics.length > 0 ? error.diagnostics.map((diagnostic) => ({
|
|
1154
|
+
...diagnostic,
|
|
1155
|
+
owner: "core.transaction"
|
|
1156
|
+
})) : [{
|
|
256
1157
|
code: error.code,
|
|
1158
|
+
owner: "core.transaction",
|
|
257
1159
|
message: error.message,
|
|
258
1160
|
severity: "error",
|
|
259
1161
|
operationKind: error.operationKind,
|
|
@@ -341,6 +1243,46 @@ var AuthoringService = class {
|
|
|
341
1243
|
if (this.sessionOperations.get(sessionId) === tail) this.sessionOperations.delete(sessionId);
|
|
342
1244
|
}
|
|
343
1245
|
}
|
|
1246
|
+
async preflightTransaction(input) {
|
|
1247
|
+
const queuedInput = structuredClone(input);
|
|
1248
|
+
detachSharedByteViews(queuedInput);
|
|
1249
|
+
return this.runSessionExclusive(queuedInput.sessionId, async () => {
|
|
1250
|
+
const startedAt = Date.now();
|
|
1251
|
+
const session = this.context.sessions.get(queuedInput.sessionId);
|
|
1252
|
+
if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1253
|
+
const meta = {
|
|
1254
|
+
sessionId: session.sessionId,
|
|
1255
|
+
revision: session.revision
|
|
1256
|
+
};
|
|
1257
|
+
if (queuedInput.expectedRevision !== session.revision) return failure("authoring", startedAt, createStaleWriteError(session, queuedInput.expectedRevision), toSessionSnapshot(session, this.context.capabilities), meta);
|
|
1258
|
+
const project = structuredClone(session.project);
|
|
1259
|
+
detachSharedByteViews(project);
|
|
1260
|
+
const result = await applyUamTransactionAppAsync({
|
|
1261
|
+
project,
|
|
1262
|
+
operations: queuedInput.operations
|
|
1263
|
+
});
|
|
1264
|
+
if (this.context.sessions.get(queuedInput.sessionId) !== session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1265
|
+
if (!result.ok) return failure("authoring", startedAt, result.error, toSessionSnapshot(session, this.context.capabilities), {
|
|
1266
|
+
...meta,
|
|
1267
|
+
diagnostics: toBackendDiagnostics(result.error)
|
|
1268
|
+
});
|
|
1269
|
+
try {
|
|
1270
|
+
const preview = await previewTransactionImpact({
|
|
1271
|
+
...session,
|
|
1272
|
+
project
|
|
1273
|
+
}, result.project, Boolean(session.fileSystem));
|
|
1274
|
+
if (this.context.sessions.get(queuedInput.sessionId) !== session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(queuedInput.sessionId));
|
|
1275
|
+
return success("authoring", startedAt, preview, meta);
|
|
1276
|
+
} catch (error) {
|
|
1277
|
+
return failure("authoring", startedAt, {
|
|
1278
|
+
code: "transaction_preview_failed",
|
|
1279
|
+
sessionId: session.sessionId,
|
|
1280
|
+
reason: error instanceof PreviewBudgetError ? "response_budget_exceeded" : "projection_failed",
|
|
1281
|
+
message: error instanceof Error ? error.message : String(error)
|
|
1282
|
+
}, toSessionSnapshot(session, this.context.capabilities), meta);
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
344
1286
|
async applyTransaction(input) {
|
|
345
1287
|
const queuedInput = structuredClone(input);
|
|
346
1288
|
detachSharedByteViews(queuedInput);
|
|
@@ -420,7 +1362,7 @@ var AuthoringService = class {
|
|
|
420
1362
|
const startedAt = Date.now();
|
|
421
1363
|
const session = this.context.sessions.get(input.sessionId);
|
|
422
1364
|
if (!session || session.closed) return failure("authoring", startedAt, createSessionNotFoundError(input.sessionId));
|
|
423
|
-
const fileSystem = session.fileSystem ?? input.fileSystem
|
|
1365
|
+
const fileSystem = session.fileSystem ?? input.fileSystem;
|
|
424
1366
|
if (!fileSystem) return failure("authoring", startedAt, createCapabilityUnavailableError$1("saveSession requires an injected BackendFileSystem adapter."), toSessionSnapshot(session, this.context.capabilities), {
|
|
425
1367
|
sessionId: session.sessionId,
|
|
426
1368
|
revision: session.revision
|
|
@@ -522,7 +1464,7 @@ var AuthoringService = class {
|
|
|
522
1464
|
revision: session.revision
|
|
523
1465
|
});
|
|
524
1466
|
const storageTarget = input.storage ? storageCanonicalTarget(input.storage) : null;
|
|
525
|
-
const fileSystem = storageTarget?.fileSystem ?? input.fileSystem ?? session.fileSystem
|
|
1467
|
+
const fileSystem = storageTarget?.fileSystem ?? input.fileSystem ?? session.fileSystem;
|
|
526
1468
|
if (!fileSystem) return failure("authoring", startedAt, createCapabilityUnavailableError$1("materializeSession requires an injected BackendFileSystem adapter."), toSessionSnapshot(session, this.context.capabilities), {
|
|
527
1469
|
sessionId: session.sessionId,
|
|
528
1470
|
revision: session.revision
|
|
@@ -748,7 +1690,7 @@ var EventService = class {
|
|
|
748
1690
|
...event,
|
|
749
1691
|
sequence: this.context.nextEventSequence(),
|
|
750
1692
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
751
|
-
diagnostics: event.diagnostics ?? []
|
|
1693
|
+
diagnostics: (event.diagnostics ?? []).map((entry) => enrichBackendDiagnostic(entry, event.sessionId))
|
|
752
1694
|
};
|
|
753
1695
|
const sessionId = event.sessionId;
|
|
754
1696
|
if (!sessionId) return emitted;
|
|
@@ -1076,6 +2018,48 @@ var JobService = class {
|
|
|
1076
2018
|
};
|
|
1077
2019
|
//#endregion
|
|
1078
2020
|
//#region src/services/read-service.ts
|
|
2021
|
+
/** Bound traversal before serialization or cloning, including non-JSON values on a malformed native input. */
|
|
2022
|
+
function queryResponseProblem(value, limits = BACKEND_ENTITY_QUERY_LIMITS) {
|
|
2023
|
+
const pending = [{
|
|
2024
|
+
value,
|
|
2025
|
+
depth: 0
|
|
2026
|
+
}];
|
|
2027
|
+
let nodes = 0;
|
|
2028
|
+
let stringUnits = 0;
|
|
2029
|
+
while (pending.length) {
|
|
2030
|
+
const { value, depth } = pending.pop();
|
|
2031
|
+
if (++nodes > limits.maxNodes || depth > limits.maxDepth) return "response_budget_exceeded";
|
|
2032
|
+
if (typeof value === "string" && (stringUnits += value.length) > limits.maxBytes) return "response_budget_exceeded";
|
|
2033
|
+
if (value === void 0 || value === null || typeof value === "string" || typeof value === "boolean") continue;
|
|
2034
|
+
if (typeof value === "number") {
|
|
2035
|
+
if (!Number.isFinite(value)) return "non_json_value";
|
|
2036
|
+
continue;
|
|
2037
|
+
}
|
|
2038
|
+
if (typeof value !== "object" || !Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return "non_json_value";
|
|
2039
|
+
if (Array.isArray(value) && value.length + pending.length + nodes > limits.maxNodes) return "response_budget_exceeded";
|
|
2040
|
+
const entries = Object.entries(value);
|
|
2041
|
+
if (entries.length + pending.length + nodes > limits.maxNodes) return "response_budget_exceeded";
|
|
2042
|
+
for (const [key, child] of entries) {
|
|
2043
|
+
if (!Array.isArray(value) && (stringUnits += key.length) > limits.maxBytes) return "response_budget_exceeded";
|
|
2044
|
+
pending.push({
|
|
2045
|
+
value: child,
|
|
2046
|
+
depth: depth + 1
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
if (new TextEncoder().encode(JSON.stringify(value)).byteLength > limits.maxBytes) return "response_budget_exceeded";
|
|
2051
|
+
}
|
|
2052
|
+
function readFailure(startedAt, sessionId, reason, revision) {
|
|
2053
|
+
return failure("read", startedAt, {
|
|
2054
|
+
code: "session_read_failed",
|
|
2055
|
+
sessionId,
|
|
2056
|
+
reason,
|
|
2057
|
+
message: `Session read failed: ${reason}.`
|
|
2058
|
+
}, void 0, {
|
|
2059
|
+
sessionId,
|
|
2060
|
+
revision
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
1079
2063
|
function toProjectOutline(session) {
|
|
1080
2064
|
const project = session.project;
|
|
1081
2065
|
return {
|
|
@@ -1143,6 +2127,195 @@ var ReadService = class {
|
|
|
1143
2127
|
revision: session.revision
|
|
1144
2128
|
});
|
|
1145
2129
|
}
|
|
2130
|
+
queryEntity(input) {
|
|
2131
|
+
const startedAt = Date.now();
|
|
2132
|
+
const session = this.context.sessions.get(input.sessionId);
|
|
2133
|
+
if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
|
|
2134
|
+
const meta = {
|
|
2135
|
+
sessionId: session.sessionId,
|
|
2136
|
+
revision: session.revision
|
|
2137
|
+
};
|
|
2138
|
+
const reject = (reason) => failure("read", startedAt, {
|
|
2139
|
+
code: "entity_query_failed",
|
|
2140
|
+
sessionId: session.sessionId,
|
|
2141
|
+
reason,
|
|
2142
|
+
message: `Entity query failed: ${reason}.`
|
|
2143
|
+
}, void 0, meta);
|
|
2144
|
+
const target = input.target;
|
|
2145
|
+
if (!target || typeof target !== "object" || Array.isArray(target) || Object.keys(target).some((key) => key !== "kind" && key !== "selector")) return reject("invalid_query");
|
|
2146
|
+
const respond = (entity) => {
|
|
2147
|
+
const data = {
|
|
2148
|
+
...meta,
|
|
2149
|
+
target,
|
|
2150
|
+
entity
|
|
2151
|
+
};
|
|
2152
|
+
const problem = queryResponseProblem(data);
|
|
2153
|
+
return problem ? reject(problem) : success("read", startedAt, structuredClone(data), meta);
|
|
2154
|
+
};
|
|
2155
|
+
if (target.kind === "project") {
|
|
2156
|
+
if (Object.hasOwn(target, "selector")) return reject("invalid_query");
|
|
2157
|
+
const { projectId, settings } = session.project;
|
|
2158
|
+
return respond({
|
|
2159
|
+
kind: "project",
|
|
2160
|
+
properties: {
|
|
2161
|
+
projectId,
|
|
2162
|
+
settings
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
const keys = target.kind === "package" ? ["packageId"] : target.kind === "resource" ? ["packageId", "resourceId"] : target.kind === "component" ? ["packageId", "componentResourceId"] : target.kind === "displayNode" ? [
|
|
2167
|
+
"packageId",
|
|
2168
|
+
"componentResourceId",
|
|
2169
|
+
"displayNodeId"
|
|
2170
|
+
] : target.kind === "controller" ? [
|
|
2171
|
+
"packageId",
|
|
2172
|
+
"componentResourceId",
|
|
2173
|
+
"controllerName"
|
|
2174
|
+
] : target.kind === "transition" ? [
|
|
2175
|
+
"packageId",
|
|
2176
|
+
"componentResourceId",
|
|
2177
|
+
"transitionName"
|
|
2178
|
+
] : [];
|
|
2179
|
+
const selector = target.selector;
|
|
2180
|
+
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");
|
|
2181
|
+
const packages = session.project.packages.filter((pkg) => pkg.id === selector.packageId);
|
|
2182
|
+
if (packages.length !== 1) return reject(packages.length ? "ambiguous" : "not_found");
|
|
2183
|
+
if (target.kind === "package") {
|
|
2184
|
+
const { id, name, compressPNG, jpegQuality, publish } = packages[0];
|
|
2185
|
+
return respond({
|
|
2186
|
+
kind: "package",
|
|
2187
|
+
properties: {
|
|
2188
|
+
id,
|
|
2189
|
+
name,
|
|
2190
|
+
settings: {
|
|
2191
|
+
compressPNG,
|
|
2192
|
+
jpegQuality,
|
|
2193
|
+
publish
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
const resources = packages[0].resources.filter((resource) => resource.id === (target.kind === "resource" ? selector.resourceId : selector.componentResourceId));
|
|
2199
|
+
if (resources.length !== 1) return reject(resources.length ? "ambiguous" : "not_found");
|
|
2200
|
+
const resource = resources[0];
|
|
2201
|
+
let entity;
|
|
2202
|
+
if (target.kind === "resource") {
|
|
2203
|
+
const record = resource;
|
|
2204
|
+
entity = {
|
|
2205
|
+
kind: "resource",
|
|
2206
|
+
properties: Object.fromEntries(BACKEND_RESOURCE_QUERY_FIELDS.filter((key) => Object.hasOwn(record, key)).map((key) => [key, record[key]]))
|
|
2207
|
+
};
|
|
2208
|
+
} else {
|
|
2209
|
+
if (resource.kind !== "component") return reject("not_found");
|
|
2210
|
+
if (target.kind === "component") {
|
|
2211
|
+
const { size, properties, customData } = resource.component;
|
|
2212
|
+
entity = {
|
|
2213
|
+
kind: "component",
|
|
2214
|
+
properties: {
|
|
2215
|
+
size,
|
|
2216
|
+
properties,
|
|
2217
|
+
customData
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
} else if (target.kind === "controller") {
|
|
2221
|
+
const controllers = resource.component.controllers.filter((controller) => controller.name === selector.controllerName);
|
|
2222
|
+
if (controllers.length !== 1) return reject(controllers.length ? "ambiguous" : "not_found");
|
|
2223
|
+
entity = {
|
|
2224
|
+
kind: "controller",
|
|
2225
|
+
properties: controllers[0]
|
|
2226
|
+
};
|
|
2227
|
+
} else if (target.kind === "transition") {
|
|
2228
|
+
const transitions = resource.component.transitions.filter((transition) => transition.name === selector.transitionName);
|
|
2229
|
+
if (transitions.length !== 1) return reject(transitions.length ? "ambiguous" : "not_found");
|
|
2230
|
+
entity = {
|
|
2231
|
+
kind: "transition",
|
|
2232
|
+
properties: transitions[0]
|
|
2233
|
+
};
|
|
2234
|
+
} else {
|
|
2235
|
+
const nodes = resource.component.displayList.filter((node) => node.id === selector.displayNodeId);
|
|
2236
|
+
if (nodes.length !== 1) return reject(nodes.length ? "ambiguous" : "not_found");
|
|
2237
|
+
entity = {
|
|
2238
|
+
kind: "displayNode",
|
|
2239
|
+
properties: nodes[0]
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return respond(entity);
|
|
2244
|
+
}
|
|
2245
|
+
resolveReadSession(input, startedAt) {
|
|
2246
|
+
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");
|
|
2247
|
+
const session = this.context.sessions.get(input.sessionId);
|
|
2248
|
+
if (!session || session.closed) return failure("read", startedAt, createSessionNotFoundError(input.sessionId));
|
|
2249
|
+
const meta = {
|
|
2250
|
+
sessionId: session.sessionId,
|
|
2251
|
+
revision: session.revision
|
|
2252
|
+
};
|
|
2253
|
+
if (input.expectedRevision !== void 0 && input.expectedRevision !== session.revision) return failure("read", startedAt, {
|
|
2254
|
+
code: "stale_read",
|
|
2255
|
+
sessionId: session.sessionId,
|
|
2256
|
+
expectedRevision: input.expectedRevision,
|
|
2257
|
+
actualRevision: session.revision,
|
|
2258
|
+
message: "The session edit revision changed. Restart the model and resource read."
|
|
2259
|
+
}, void 0, meta);
|
|
2260
|
+
return success("read", startedAt, session, meta);
|
|
2261
|
+
}
|
|
2262
|
+
readSessionState(input) {
|
|
2263
|
+
const startedAt = Date.now();
|
|
2264
|
+
const resolved = this.resolveReadSession(input, startedAt);
|
|
2265
|
+
if (!resolved.ok) return resolved;
|
|
2266
|
+
const session = resolved.data;
|
|
2267
|
+
const meta = {
|
|
2268
|
+
sessionId: session.sessionId,
|
|
2269
|
+
revision: session.revision
|
|
2270
|
+
};
|
|
2271
|
+
const data = {
|
|
2272
|
+
...meta,
|
|
2273
|
+
dirty: session.dirty,
|
|
2274
|
+
lastSavedRevision: session.lastSavedRevision,
|
|
2275
|
+
uamFidelity: session.uamFidelity,
|
|
2276
|
+
readComplete: session.readComplete,
|
|
2277
|
+
readDiagnostics: session.readDiagnostics,
|
|
2278
|
+
project: {
|
|
2279
|
+
...session.project,
|
|
2280
|
+
packages: session.project.packages.map((pkg) => ({
|
|
2281
|
+
...pkg,
|
|
2282
|
+
resources: pkg.resources.map((resource) => {
|
|
2283
|
+
if (resource.kind === "component") return resource;
|
|
2284
|
+
const { sourceBytes: _sourceBytes, ...model } = resource;
|
|
2285
|
+
return model;
|
|
2286
|
+
})
|
|
2287
|
+
}))
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
const problem = queryResponseProblem(data, BACKEND_SESSION_READ_LIMITS.model);
|
|
2291
|
+
return problem ? readFailure(startedAt, session.sessionId, problem, session.revision) : success("read", startedAt, structuredClone(data), meta);
|
|
2292
|
+
}
|
|
2293
|
+
readResourceBytes(input) {
|
|
2294
|
+
const startedAt = Date.now();
|
|
2295
|
+
const resolved = this.resolveReadSession(input, startedAt);
|
|
2296
|
+
if (!resolved.ok) return resolved;
|
|
2297
|
+
const session = resolved.data;
|
|
2298
|
+
const reject = (reason) => readFailure(startedAt, session.sessionId, reason, session.revision);
|
|
2299
|
+
const selector = input.selector;
|
|
2300
|
+
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");
|
|
2301
|
+
const packages = session.project.packages.filter((pkg) => pkg.id === selector.packageId);
|
|
2302
|
+
if (packages.length !== 1) return reject(packages.length ? "ambiguous" : "not_found");
|
|
2303
|
+
const resources = packages[0].resources.filter((resource) => resource.id === selector.resourceId);
|
|
2304
|
+
if (resources.length !== 1) return reject(resources.length ? "ambiguous" : "not_found");
|
|
2305
|
+
const resource = resources[0];
|
|
2306
|
+
if (resource.kind === "component") return reject("unsupported_resource");
|
|
2307
|
+
if (!(resource.sourceBytes instanceof Uint8Array)) return reject("bytes_unavailable");
|
|
2308
|
+
if (resource.sourceBytes.byteLength > BACKEND_SESSION_READ_LIMITS.resourceBytes) return reject("response_budget_exceeded");
|
|
2309
|
+
const meta = {
|
|
2310
|
+
sessionId: session.sessionId,
|
|
2311
|
+
revision: session.revision
|
|
2312
|
+
};
|
|
2313
|
+
return success("read", startedAt, {
|
|
2314
|
+
...meta,
|
|
2315
|
+
selector: { ...selector },
|
|
2316
|
+
sourceBytes: new Uint8Array(resource.sourceBytes)
|
|
2317
|
+
}, meta);
|
|
2318
|
+
}
|
|
1146
2319
|
validateSession(input) {
|
|
1147
2320
|
const startedAt = Date.now();
|
|
1148
2321
|
const session = this.context.sessions.get(input.sessionId);
|
|
@@ -1159,7 +2332,8 @@ var ReadService = class {
|
|
|
1159
2332
|
code,
|
|
1160
2333
|
message,
|
|
1161
2334
|
severity,
|
|
1162
|
-
path
|
|
2335
|
+
path,
|
|
2336
|
+
owner: "core.validation"
|
|
1163
2337
|
}))
|
|
1164
2338
|
});
|
|
1165
2339
|
}
|
|
@@ -1220,63 +2394,6 @@ function createProjectReaderFileSystem(fileSystem, projectRoot) {
|
|
|
1220
2394
|
}
|
|
1221
2395
|
};
|
|
1222
2396
|
}
|
|
1223
|
-
function createCaptureFileSystem(files, directories) {
|
|
1224
|
-
const normalize = (filePath) => filePath.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
1225
|
-
return {
|
|
1226
|
-
async readFile(filePath) {
|
|
1227
|
-
const value = files.get(normalize(filePath));
|
|
1228
|
-
if (typeof value !== "string") throw new Error(`Captured text file was not found: ${filePath}`);
|
|
1229
|
-
return value;
|
|
1230
|
-
},
|
|
1231
|
-
async readFileRaw(filePath) {
|
|
1232
|
-
const value = files.get(normalize(filePath));
|
|
1233
|
-
if (!(value instanceof Uint8Array)) throw new Error(`Captured binary file was not found: ${filePath}`);
|
|
1234
|
-
return value.slice();
|
|
1235
|
-
},
|
|
1236
|
-
async writeFile(filePath, content) {
|
|
1237
|
-
files.set(normalize(filePath), content);
|
|
1238
|
-
},
|
|
1239
|
-
async writeFileRaw(filePath, data) {
|
|
1240
|
-
files.set(normalize(filePath), data.slice());
|
|
1241
|
-
},
|
|
1242
|
-
async mkdir(dirPath) {
|
|
1243
|
-
directories.add(normalize(dirPath));
|
|
1244
|
-
},
|
|
1245
|
-
async readdir() {
|
|
1246
|
-
return [];
|
|
1247
|
-
},
|
|
1248
|
-
async exists(filePath) {
|
|
1249
|
-
return files.has(normalize(filePath));
|
|
1250
|
-
},
|
|
1251
|
-
join(...paths) {
|
|
1252
|
-
return normalize(paths.filter(Boolean).join("/"));
|
|
1253
|
-
},
|
|
1254
|
-
dirname(filePath) {
|
|
1255
|
-
const normalized = normalize(filePath);
|
|
1256
|
-
const separator = normalized.lastIndexOf("/");
|
|
1257
|
-
return separator < 0 ? "" : normalized.slice(0, separator);
|
|
1258
|
-
},
|
|
1259
|
-
async unlink(filePath) {
|
|
1260
|
-
files.delete(normalize(filePath));
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
function capturedFilesEqual(left, right) {
|
|
1265
|
-
if (left.size !== right.size) return false;
|
|
1266
|
-
for (const [filePath, leftValue] of left) {
|
|
1267
|
-
const rightValue = right.get(filePath);
|
|
1268
|
-
if (typeof leftValue === "string") {
|
|
1269
|
-
if (leftValue !== rightValue) return false;
|
|
1270
|
-
continue;
|
|
1271
|
-
}
|
|
1272
|
-
if (!(rightValue instanceof Uint8Array) || leftValue.length !== rightValue.length) return false;
|
|
1273
|
-
for (let index = 0; index < leftValue.length; index += 1) if (leftValue[index] !== rightValue[index]) return false;
|
|
1274
|
-
}
|
|
1275
|
-
return true;
|
|
1276
|
-
}
|
|
1277
|
-
function capturedDirectoriesEqual(left, right) {
|
|
1278
|
-
return left.size === right.size && [...left].every((directory) => right.has(directory));
|
|
1279
|
-
}
|
|
1280
2397
|
async function hasFullUamFidelity(document, project) {
|
|
1281
2398
|
const sourceFiles = /* @__PURE__ */ new Map();
|
|
1282
2399
|
const materializedFiles = /* @__PURE__ */ new Map();
|
|
@@ -1508,7 +2625,11 @@ const BACKEND_METHODS = [
|
|
|
1508
2625
|
"openProjectSession",
|
|
1509
2626
|
"getSession",
|
|
1510
2627
|
"getProjectOutline",
|
|
2628
|
+
"queryEntity",
|
|
2629
|
+
"readSessionState",
|
|
2630
|
+
"readResourceBytes",
|
|
1511
2631
|
"validateSession",
|
|
2632
|
+
"preflightTransaction",
|
|
1512
2633
|
"applyTransaction",
|
|
1513
2634
|
"saveSession",
|
|
1514
2635
|
"materializeSession",
|
|
@@ -1530,7 +2651,7 @@ const ARTIFACT_BRIDGE_CAPABILITY = {
|
|
|
1530
2651
|
function createCapabilities(atomicSave = false) {
|
|
1531
2652
|
return {
|
|
1532
2653
|
contractVersion: BACKEND_CONTRACT_VERSION,
|
|
1533
|
-
capabilitySchemaVersion:
|
|
2654
|
+
capabilitySchemaVersion: 11,
|
|
1534
2655
|
transactionKernelOwner: "@openfairygui/core",
|
|
1535
2656
|
appSeamOwner: "@openfairygui/functions",
|
|
1536
2657
|
runtimeOwner: "@openfairygui/backend",
|
|
@@ -1539,9 +2660,38 @@ function createCapabilities(atomicSave = false) {
|
|
|
1539
2660
|
capabilitySnapshot: true,
|
|
1540
2661
|
sessionSnapshot: true,
|
|
1541
2662
|
projectOutline: true,
|
|
2663
|
+
entityQuery: {
|
|
2664
|
+
kinds: [
|
|
2665
|
+
"project",
|
|
2666
|
+
"package",
|
|
2667
|
+
"resource",
|
|
2668
|
+
"component",
|
|
2669
|
+
"displayNode",
|
|
2670
|
+
"controller",
|
|
2671
|
+
"transition"
|
|
2672
|
+
],
|
|
2673
|
+
projection: "properties",
|
|
2674
|
+
sourceBytes: false,
|
|
2675
|
+
limits: BACKEND_ENTITY_QUERY_LIMITS
|
|
2676
|
+
},
|
|
2677
|
+
sessionState: {
|
|
2678
|
+
sourceBytes: false,
|
|
2679
|
+
limits: BACKEND_SESSION_READ_LIMITS.model
|
|
2680
|
+
},
|
|
2681
|
+
resourceBytes: {
|
|
2682
|
+
expectedRevisionRequired: true,
|
|
2683
|
+
hydration: false,
|
|
2684
|
+
maxBytes: BACKEND_SESSION_READ_LIMITS.resourceBytes
|
|
2685
|
+
},
|
|
1542
2686
|
projectValidation: true
|
|
1543
2687
|
},
|
|
1544
2688
|
authoring: {
|
|
2689
|
+
preflightTransaction: {
|
|
2690
|
+
mode: "execute-and-discard",
|
|
2691
|
+
reservesRevision: false,
|
|
2692
|
+
impact: "model-diff",
|
|
2693
|
+
limits: BACKEND_TRANSACTION_PREVIEW_LIMITS
|
|
2694
|
+
},
|
|
1545
2695
|
applyTransaction: true,
|
|
1546
2696
|
saveSession: true,
|
|
1547
2697
|
resourceKinds: [...UAM_SUPPORTED_MATERIALIZATION_SCOPE.resourceKinds],
|
|
@@ -1591,7 +2741,9 @@ function createCapabilities(atomicSave = false) {
|
|
|
1591
2741
|
},
|
|
1592
2742
|
diagnostics: {
|
|
1593
2743
|
stableCodes: true,
|
|
1594
|
-
errorDiagnosticMirror: true
|
|
2744
|
+
errorDiagnosticMirror: true,
|
|
2745
|
+
recoveryGuides: "all-formal-codes",
|
|
2746
|
+
automaticRepair: false
|
|
1595
2747
|
}
|
|
1596
2748
|
},
|
|
1597
2749
|
compatibilityPolicy: BACKEND_COMPATIBILITY_POLICY,
|
|
@@ -1692,9 +2844,21 @@ var BackendRuntime = class {
|
|
|
1692
2844
|
getProjectOutline(input) {
|
|
1693
2845
|
return this.readService.getProjectOutline(input);
|
|
1694
2846
|
}
|
|
2847
|
+
queryEntity(input) {
|
|
2848
|
+
return this.readService.queryEntity(input);
|
|
2849
|
+
}
|
|
2850
|
+
readSessionState(input) {
|
|
2851
|
+
return this.readService.readSessionState(input);
|
|
2852
|
+
}
|
|
2853
|
+
readResourceBytes(input) {
|
|
2854
|
+
return this.readService.readResourceBytes(input);
|
|
2855
|
+
}
|
|
1695
2856
|
validateSession(input) {
|
|
1696
2857
|
return this.readService.validateSession(input);
|
|
1697
2858
|
}
|
|
2859
|
+
async preflightTransaction(input) {
|
|
2860
|
+
return this.authoringService.preflightTransaction(input);
|
|
2861
|
+
}
|
|
1698
2862
|
async applyTransaction(input) {
|
|
1699
2863
|
return this.authoringService.applyTransaction(input);
|
|
1700
2864
|
}
|
|
@@ -1897,4 +3061,4 @@ function createBackendStorageFileSystem(storage) {
|
|
|
1897
3061
|
return fileSystem;
|
|
1898
3062
|
}
|
|
1899
3063
|
//#endregion
|
|
1900
|
-
export { BACKEND_CAPABILITY_SCHEMA_VERSION, BACKEND_COMPATIBILITY_POLICY, BACKEND_CONTRACT_VERSION, BackendRuntime, createBackendStorageFileSystem };
|
|
3064
|
+
export { BACKEND_CAPABILITY_SCHEMA_VERSION, BACKEND_COMPATIBILITY_POLICY, BACKEND_CONTRACT_VERSION, BACKEND_DIAGNOSTICS_URI, BACKEND_DIAGNOSTIC_TEMPLATE, BACKEND_ENTITY_QUERY_LIMITS, BACKEND_SESSION_READ_LIMITS, BACKEND_TRANSACTION_PREVIEW_LIMITS, BackendRuntime, createBackendStorageFileSystem, getBackendDiagnosticCatalog, getBackendDiagnosticGuide };
|