@almadar/core 10.129.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behavior-package.d.ts +49 -11
- package/dist/behavior-package.js +1 -1
- package/dist/{orbital-CkFdDS9f.d.ts → builders-BhnofAik.d.ts} +5966 -7116
- package/dist/builders.d.ts +6 -6
- package/dist/builders.js +7 -6
- package/dist/{bus-CcbB__oo.d.ts → bus-BrRFWDQK.d.ts} +270 -354
- package/dist/chunk-347APWFM.js +286 -0
- package/dist/chunk-347APWFM.js.map +1 -0
- package/dist/chunk-3URQAGD7.js +98 -0
- package/dist/chunk-3URQAGD7.js.map +1 -0
- package/dist/chunk-7GHJU5WI.js +39 -0
- package/dist/chunk-7GHJU5WI.js.map +1 -0
- package/dist/chunk-B4MNHGBP.js +8 -0
- package/dist/chunk-B4MNHGBP.js.map +1 -0
- package/dist/{chunk-KDMV222Q.js → chunk-F6KHUW7T.js} +304 -373
- package/dist/chunk-F6KHUW7T.js.map +1 -0
- package/dist/chunk-FGT5OS2Y.js +918 -0
- package/dist/chunk-FGT5OS2Y.js.map +1 -0
- package/dist/chunk-FQLEAMAB.js +24 -0
- package/dist/chunk-FQLEAMAB.js.map +1 -0
- package/dist/chunk-HEXOGHQ4.js +3264 -0
- package/dist/chunk-HEXOGHQ4.js.map +1 -0
- package/dist/chunk-JCD6GLBX.js +412 -0
- package/dist/chunk-JCD6GLBX.js.map +1 -0
- package/dist/{chunk-QUOTJULD.js → chunk-MGLG2XLD.js} +20 -219
- package/dist/chunk-MGLG2XLD.js.map +1 -0
- package/dist/chunk-MTBEBSNO.js +1293 -0
- package/dist/chunk-MTBEBSNO.js.map +1 -0
- package/dist/{chunk-X4SC7FGF.js → chunk-RGACZEYC.js} +99 -96
- package/dist/chunk-RGACZEYC.js.map +1 -0
- package/dist/{chunk-RYPVOI6H.js → chunk-UZPYYI37.js} +524 -26
- package/dist/{chunk-RYPVOI6H.js.map → chunk-UZPYYI37.js.map} +1 -1
- package/dist/chunk-VG7BRFUD.js +152 -0
- package/dist/chunk-VG7BRFUD.js.map +1 -0
- package/dist/chunk-Y2DYZPP5.js +2329 -0
- package/dist/chunk-Y2DYZPP5.js.map +1 -0
- package/dist/chunk-ZEI7C32D.js +1566 -0
- package/dist/chunk-ZEI7C32D.js.map +1 -0
- package/dist/{domain-Dz3jP-UM.d.ts → domain-CfKPpXCP.d.ts} +51 -51
- package/dist/{effect-result-Bebwu9yT.d.ts → effect-result-DPERsn_v.d.ts} +641 -851
- package/dist/{effect-CiEVLsZz.d.ts → effect-wP-IdRt2.d.ts} +236 -443
- package/dist/{expression-D0Fs0riG.d.ts → expression-DirYKz-f.d.ts} +5 -13
- package/dist/factory/index.d.ts +7 -144
- package/dist/factory/index.js +8 -8
- package/dist/factory-runtime/index.d.ts +7 -6
- package/dist/factory-runtime/index.js +527 -8
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/fixtures.d.ts +9 -11
- package/dist/fixtures.js +12 -8
- package/dist/fixtures.js.map +1 -1
- package/dist/i18n/index.d.ts +15 -19
- package/dist/i18n/index.js +2 -1
- package/dist/{index-BC-Jycqj.d.ts → index-DomgmRBG.d.ts} +29 -729
- package/dist/index.d.ts +69 -247
- package/dist/index.js +322 -986
- package/dist/index.js.map +1 -1
- package/dist/kernel-wire.d.ts +3 -3
- package/dist/kernel-wire.js +3 -79
- package/dist/kernel-wire.js.map +1 -1
- package/dist/language/constructs.json +22 -2
- package/dist/language/program-types.json +203 -22
- package/dist/language/protocols.json +46 -0
- package/dist/language/ui-vocabulary.json +1697 -0
- package/dist/language/validation-codes.json +1205 -1215
- package/dist/language/vocabulary.json +44 -8
- package/dist/language-data.d.ts +7 -4
- package/dist/language-data.js +20 -14
- package/dist/language-data.js.map +1 -1
- package/dist/patterns/component-mapping.json +11 -1
- package/dist/patterns/definitions.d.ts +2 -2
- package/dist/patterns/definitions.js +1 -1
- package/dist/patterns/event-contracts.json +1 -15
- package/dist/patterns/index.d.ts +24 -120
- package/dist/patterns/index.js +3 -3
- package/dist/patterns/patterns-registry.json +522 -24
- package/dist/patterns/registry.json +522 -24
- package/dist/trait-CzG9M89M.d.ts +3519 -0
- package/dist/types/index.d.ts +9 -10
- package/dist/types/index.js +11 -5
- package/dist/{types-DGwrltUF.d.ts → types-BHlTjwWd.d.ts} +3 -3
- package/fixtures/events-wire/client-effects-by-trait/response.json +0 -18
- package/fixtures/events-wire/client-effects-provenance/response.json +0 -18
- package/fixtures/events-wire/effect-results-every-kind/response.json +2 -27
- package/fixtures/events-wire/navigate-1/response.json +8 -5
- package/fixtures/events-wire/navigate-2/response.json +11 -8
- package/fixtures/events-wire/navigate-3/response.json +14 -11
- package/fixtures/events-wire/navigate-back/response.json +7 -4
- package/fixtures/events-wire/render-ui-3/response.json +12 -9
- package/fixtures/events-wire/render-ui-clear/response.json +0 -7
- package/fixtures/events-wire/sse-stream/response.json +0 -20
- package/fixtures/events-wire/sse-stream/stream.json +0 -20
- package/fixtures/events-wire/stateless-traits/response.json +14 -5
- package/fixtures/kernel-wire/golden/basic-entity.json +1687 -0
- package/fixtures/kernel-wire/golden/entity-rerender.json +743 -0
- package/fixtures/kernel-wire/golden/rollback.json +793 -0
- package/fixtures/kernel-wire/golden/tick-counter.json +1538 -0
- package/fixtures/kernel-wire/golden/two-orbital-chore.json +847 -0
- package/fixtures/kernel-wire/golden/two-orbital-task.json +457 -0
- package/fixtures/kernel-wire/played-step.json +136 -0
- package/fixtures/kernel-wire/scripts/basic-entity.json +28 -0
- package/fixtures/kernel-wire/scripts/entity-rerender.json +13 -0
- package/fixtures/kernel-wire/scripts/rollback.json +53 -0
- package/fixtures/kernel-wire/scripts/tick-counter.json +26 -0
- package/fixtures/kernel-wire/scripts/two-orbital-chore.json +9 -0
- package/fixtures/kernel-wire/scripts/two-orbital-task.json +9 -0
- package/package.json +28 -19
- package/dist/builders-DmZE5By0.d.ts +0 -2663
- package/dist/chunk-45I2O4SJ.js +0 -4646
- package/dist/chunk-45I2O4SJ.js.map +0 -1
- package/dist/chunk-6LR43Z5E.js +0 -3061
- package/dist/chunk-6LR43Z5E.js.map +0 -1
- package/dist/chunk-GIUA3NUJ.js +0 -809
- package/dist/chunk-GIUA3NUJ.js.map +0 -1
- package/dist/chunk-GTY53NS5.js +0 -1908
- package/dist/chunk-GTY53NS5.js.map +0 -1
- package/dist/chunk-JOHDVS6J.js +0 -1614
- package/dist/chunk-JOHDVS6J.js.map +0 -1
- package/dist/chunk-KDMV222Q.js.map +0 -1
- package/dist/chunk-QRHJUS3D.js +0 -23
- package/dist/chunk-QRHJUS3D.js.map +0 -1
- package/dist/chunk-QUOTJULD.js.map +0 -1
- package/dist/chunk-V5VNGRVU.js +0 -66
- package/dist/chunk-V5VNGRVU.js.map +0 -1
- package/dist/chunk-X4SC7FGF.js.map +0 -1
- package/dist/entityAccess-BPSz1i2n.d.ts +0 -80
- package/dist/mock/index.d.ts +0 -153
- package/dist/mock/index.js +0 -190
- package/dist/mock/index.js.map +0 -1
- package/dist/schema-T5RT5s6H.d.ts +0 -282
- package/dist/state-machine/index.d.ts +0 -359
- package/dist/state-machine/index.js +0 -3
- package/dist/state-machine/index.js.map +0 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { persistenceModeAllowsOverrides, UI_SLOTS } from './chunk-GTY53NS5.js';
|
|
4
|
-
import { getAllPatternTypes, controlBody } from './chunk-QUOTJULD.js';
|
|
1
|
+
import { NUM_WIDTH_TAGS, persistenceModeAllowsOverrides, UI_SLOTS } from './chunk-FGT5OS2Y.js';
|
|
2
|
+
import { getAllPatternTypes } from './chunk-MGLG2XLD.js';
|
|
5
3
|
|
|
6
4
|
// src/factory/knob-defs.ts
|
|
7
5
|
function rehydrateKnobDefs(catalog) {
|
|
@@ -34,6 +32,304 @@ function rehydrateKnobDefs(catalog) {
|
|
|
34
32
|
return catalog;
|
|
35
33
|
}
|
|
36
34
|
|
|
35
|
+
// src/factory/questions/generate.ts
|
|
36
|
+
function generateQuestions(plan, catalog, ruleOverlay, _userPrompt) {
|
|
37
|
+
const out = [];
|
|
38
|
+
const ruleCapabilities = collectRuleCapabilities(ruleOverlay);
|
|
39
|
+
for (const call of plan) {
|
|
40
|
+
const signature = findSignature(catalog, call.organism, call.orbital);
|
|
41
|
+
if (!signature) continue;
|
|
42
|
+
out.push(...configKeyQuestions(call, signature));
|
|
43
|
+
out.push(...entityFieldQuestions(call, signature));
|
|
44
|
+
out.push(...capabilityQuestions(call, signature, ruleCapabilities));
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
var TIER_D_NAMED_PRIMITIVES = /* @__PURE__ */ new Set([
|
|
49
|
+
"layoutMode",
|
|
50
|
+
"layoutPattern",
|
|
51
|
+
"viewPattern",
|
|
52
|
+
"detailPattern",
|
|
53
|
+
"detailSlot",
|
|
54
|
+
"contentTrait"
|
|
55
|
+
]);
|
|
56
|
+
var TIER_D_TYPES = /* @__PURE__ */ new Set(["trait", "slot", "pattern", "event"]);
|
|
57
|
+
function configKeyQuestions(call, signature) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const trait of signature.traits) {
|
|
60
|
+
for (const param of trait.overridableConfigKeys) {
|
|
61
|
+
if (param.tier === "internal") continue;
|
|
62
|
+
if (TIER_D_TYPES.has(param.type)) continue;
|
|
63
|
+
if (TIER_D_NAMED_PRIMITIVES.has(param.key)) continue;
|
|
64
|
+
out.push(buildConfigKeyQuestion(call, trait, param));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function buildConfigKeyQuestion(call, trait, param) {
|
|
70
|
+
const question = param.label ?? humanizeKey(param.key);
|
|
71
|
+
const callSiteOverride = callSiteOverrideValue(call, trait.name, param.key);
|
|
72
|
+
const effectiveDefault = callSiteOverride !== void 0 ? callSiteOverride : param.default;
|
|
73
|
+
const helpText = param.description;
|
|
74
|
+
const syntheticReason = `Customizes "${param.key}" on the ${trait.name} trait. ` + (effectiveDefault !== void 0 ? `Default: ${stringifyDefault(effectiveDefault)}.` : `No default \u2014 leave blank to inherit the factory's behavior.`);
|
|
75
|
+
const reason = helpText !== void 0 ? void 0 : syntheticReason;
|
|
76
|
+
const isAdvanced = !isPrimaryTier(param.tier);
|
|
77
|
+
const out = {
|
|
78
|
+
id: `${factoryCallPlanOrbitalName(call)}.${trait.name}.${param.key}`,
|
|
79
|
+
orbitalName: factoryCallPlanOrbitalName(call),
|
|
80
|
+
question,
|
|
81
|
+
inputType: deriveInputType(param),
|
|
82
|
+
mutationTemplate: {
|
|
83
|
+
kind: "set-trait-override-config",
|
|
84
|
+
orbitalName: factoryCallPlanOrbitalName(call),
|
|
85
|
+
traitName: trait.name,
|
|
86
|
+
configKey: param.key
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (reason !== void 0) {
|
|
90
|
+
out.reason = reason;
|
|
91
|
+
}
|
|
92
|
+
if (helpText !== void 0) {
|
|
93
|
+
out.helpText = helpText;
|
|
94
|
+
}
|
|
95
|
+
if (effectiveDefault !== void 0) {
|
|
96
|
+
out.defaultValue = effectiveDefault;
|
|
97
|
+
}
|
|
98
|
+
if (param.enumValues && param.enumValues.length > 0) {
|
|
99
|
+
out.suggestedAnswers = param.enumValues;
|
|
100
|
+
}
|
|
101
|
+
if (param.items) {
|
|
102
|
+
out.itemSchema = param.items;
|
|
103
|
+
}
|
|
104
|
+
if (param.properties) {
|
|
105
|
+
out.objectSchema = param.properties;
|
|
106
|
+
}
|
|
107
|
+
if (param.tier) {
|
|
108
|
+
out.tier = param.tier;
|
|
109
|
+
}
|
|
110
|
+
if (isAdvanced) {
|
|
111
|
+
out.advanced = true;
|
|
112
|
+
}
|
|
113
|
+
const weight = tierWeight(param.tier);
|
|
114
|
+
out.weight = weight;
|
|
115
|
+
out.priority = weight;
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
function tierWeight(tier) {
|
|
119
|
+
switch (tier) {
|
|
120
|
+
case "domain":
|
|
121
|
+
case "policy":
|
|
122
|
+
return 3;
|
|
123
|
+
case "infra":
|
|
124
|
+
return 2;
|
|
125
|
+
case "internal":
|
|
126
|
+
return 0;
|
|
127
|
+
case "presentation":
|
|
128
|
+
default:
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function isPrimaryTier(tier) {
|
|
133
|
+
return tier === "domain" || tier === "policy";
|
|
134
|
+
}
|
|
135
|
+
function callSiteOverrideValue(call, traitName, configKey) {
|
|
136
|
+
const override = call.params.traitOverrides?.[traitName];
|
|
137
|
+
if (!override?.config) return void 0;
|
|
138
|
+
if (!Object.prototype.hasOwnProperty.call(override.config, configKey)) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
return override.config[configKey];
|
|
142
|
+
}
|
|
143
|
+
function deriveInputType(param) {
|
|
144
|
+
if (param.type.startsWith("[")) {
|
|
145
|
+
if (param.items?.properties && Object.keys(param.items.properties).length > 0) {
|
|
146
|
+
return "listOfObjects";
|
|
147
|
+
}
|
|
148
|
+
if (param.enumValues && param.enumValues.length > 0) {
|
|
149
|
+
return "multiselect";
|
|
150
|
+
}
|
|
151
|
+
return "tagList";
|
|
152
|
+
}
|
|
153
|
+
if (param.type.startsWith("Map<")) {
|
|
154
|
+
return "objectForm";
|
|
155
|
+
}
|
|
156
|
+
if (param.type === "object") {
|
|
157
|
+
if (param.properties && Object.keys(param.properties).length > 0) {
|
|
158
|
+
return "objectForm";
|
|
159
|
+
}
|
|
160
|
+
return "text";
|
|
161
|
+
}
|
|
162
|
+
switch (param.type) {
|
|
163
|
+
case "number":
|
|
164
|
+
case "integer":
|
|
165
|
+
return "number";
|
|
166
|
+
case "boolean":
|
|
167
|
+
return "boolean";
|
|
168
|
+
case "enum":
|
|
169
|
+
return "enum";
|
|
170
|
+
case "string":
|
|
171
|
+
return param.enumValues && param.enumValues.length > 0 ? "enum" : "text";
|
|
172
|
+
default:
|
|
173
|
+
return "text";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function humanizeKey(key) {
|
|
177
|
+
const parts = key.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ").filter((s) => s.length > 0);
|
|
178
|
+
return parts.map((p) => /^[A-Z]+$/.test(p) ? p : p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
|
|
179
|
+
}
|
|
180
|
+
function stringifyDefault(v) {
|
|
181
|
+
if (typeof v === "string") return JSON.stringify(v);
|
|
182
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
183
|
+
if (Array.isArray(v)) return `${v.length} item${v.length === 1 ? "" : "s"}`;
|
|
184
|
+
return "object";
|
|
185
|
+
}
|
|
186
|
+
function entityFieldQuestions(call, signature) {
|
|
187
|
+
if (signature.entities.length === 0) return [];
|
|
188
|
+
const entity = signature.entities[0];
|
|
189
|
+
const entityName = call.params.entityName ?? entity.name;
|
|
190
|
+
const candidateFields = entity.fields.map(signatureFieldToEntityField);
|
|
191
|
+
const fieldCandidates = {};
|
|
192
|
+
const fieldDescriptions = {};
|
|
193
|
+
const candidateNames = [];
|
|
194
|
+
for (let i = 0; i < entity.fields.length; i++) {
|
|
195
|
+
const sig = entity.fields[i];
|
|
196
|
+
const ef = candidateFields[i];
|
|
197
|
+
const name = sig.name;
|
|
198
|
+
candidateNames.push(name);
|
|
199
|
+
fieldCandidates[name] = ef;
|
|
200
|
+
if (sig.description) {
|
|
201
|
+
fieldDescriptions[name] = sig.description;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const weight = tierWeight("domain");
|
|
205
|
+
const q = {
|
|
206
|
+
id: `${factoryCallPlanOrbitalName(call)}.__entityFields`,
|
|
207
|
+
orbitalName: factoryCallPlanOrbitalName(call),
|
|
208
|
+
question: `Fields for ${entityName}`,
|
|
209
|
+
reason: `Defines the data model for ${entityName}. Pick the fields that matter for your use case.`,
|
|
210
|
+
inputType: "multiselect",
|
|
211
|
+
mutationTemplate: {
|
|
212
|
+
kind: "set-orbital-entity-fields",
|
|
213
|
+
orbitalName: factoryCallPlanOrbitalName(call)
|
|
214
|
+
},
|
|
215
|
+
suggestedAnswers: candidateNames,
|
|
216
|
+
defaultValue: candidateNames,
|
|
217
|
+
fieldCandidates,
|
|
218
|
+
tier: "domain",
|
|
219
|
+
weight,
|
|
220
|
+
priority: weight
|
|
221
|
+
};
|
|
222
|
+
if (Object.keys(fieldDescriptions).length > 0) {
|
|
223
|
+
q.fieldDescriptions = fieldDescriptions;
|
|
224
|
+
}
|
|
225
|
+
return [q];
|
|
226
|
+
}
|
|
227
|
+
function signatureFieldToEntityField(f) {
|
|
228
|
+
const base = {
|
|
229
|
+
name: f.name,
|
|
230
|
+
required: f.required,
|
|
231
|
+
description: f.description,
|
|
232
|
+
synonyms: f.synonyms,
|
|
233
|
+
intrinsic: f.intrinsic
|
|
234
|
+
};
|
|
235
|
+
switch (f.type) {
|
|
236
|
+
case "string":
|
|
237
|
+
case "number":
|
|
238
|
+
case "boolean":
|
|
239
|
+
case "date":
|
|
240
|
+
case "timestamp":
|
|
241
|
+
case "datetime":
|
|
242
|
+
// Semantic string domains carry no dependent payload, so they pass through
|
|
243
|
+
// as-is and the question widget narrows the input accordingly.
|
|
244
|
+
case "email":
|
|
245
|
+
case "url":
|
|
246
|
+
case "phone":
|
|
247
|
+
case "uuid":
|
|
248
|
+
case "image":
|
|
249
|
+
return { ...base, type: f.type };
|
|
250
|
+
case "array":
|
|
251
|
+
return { ...base, type: "array" };
|
|
252
|
+
case "object":
|
|
253
|
+
return { ...base, type: "object" };
|
|
254
|
+
case "enum":
|
|
255
|
+
if (Array.isArray(f.values) && f.values.length > 0) {
|
|
256
|
+
return { ...base, type: "enum", values: f.values };
|
|
257
|
+
}
|
|
258
|
+
return { ...base, type: "string" };
|
|
259
|
+
case "relation":
|
|
260
|
+
if (f.relation !== void 0) {
|
|
261
|
+
return { ...base, type: "relation", relation: f.relation };
|
|
262
|
+
}
|
|
263
|
+
return { ...base, type: "string" };
|
|
264
|
+
case "node":
|
|
265
|
+
return { ...base, type: "node" };
|
|
266
|
+
case "event":
|
|
267
|
+
return { ...base, type: "event" };
|
|
268
|
+
case "money":
|
|
269
|
+
case "instant":
|
|
270
|
+
case "file":
|
|
271
|
+
case "bytes":
|
|
272
|
+
return { ...base, type: f.type };
|
|
273
|
+
default: {
|
|
274
|
+
f.type;
|
|
275
|
+
return { ...base, type: "string" };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function capabilityQuestions(call, signature, ruleCapabilities) {
|
|
280
|
+
const entityName = call.params.entityName ?? signature.entities[0]?.name ?? factoryCallPlanOrbitalName(call);
|
|
281
|
+
const seen = /* @__PURE__ */ new Set();
|
|
282
|
+
const out = [];
|
|
283
|
+
for (const trait of signature.traits) {
|
|
284
|
+
const policyKnobKeys = new Set(
|
|
285
|
+
trait.overridableConfigKeys.filter((p) => p.tier === "policy").map((p) => p.key)
|
|
286
|
+
);
|
|
287
|
+
for (const cap of trait.capabilities) {
|
|
288
|
+
if (seen.has(cap)) continue;
|
|
289
|
+
seen.add(cap);
|
|
290
|
+
if (ruleCapabilities.has(cap)) continue;
|
|
291
|
+
if (policyKnobKeys.has(cap)) continue;
|
|
292
|
+
out.push({
|
|
293
|
+
id: `${factoryCallPlanOrbitalName(call)}.capability.${cap}`,
|
|
294
|
+
orbitalName: factoryCallPlanOrbitalName(call),
|
|
295
|
+
question: capabilityPrompt(cap, entityName),
|
|
296
|
+
helpText: capabilityHelp(cap, trait),
|
|
297
|
+
capability: cap,
|
|
298
|
+
inputType: "boolean",
|
|
299
|
+
mutationTemplate: {
|
|
300
|
+
kind: "set-rule",
|
|
301
|
+
capability: cap,
|
|
302
|
+
appliesTo: [entityName]
|
|
303
|
+
},
|
|
304
|
+
// Capabilities encode governance/policy decisions — high impact.
|
|
305
|
+
weight: 3,
|
|
306
|
+
priority: 3
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
function capabilityPrompt(capability, entity) {
|
|
313
|
+
const label = humanizeKey(capability);
|
|
314
|
+
return `Enable ${label} for ${entity}?`;
|
|
315
|
+
}
|
|
316
|
+
function capabilityHelp(capability, trait) {
|
|
317
|
+
return `Turns on the "${capability}" behavior from the ${trait.name} trait. Say yes to wire a governance rule into the schema.`;
|
|
318
|
+
}
|
|
319
|
+
function findSignature(catalog, organism, orbital) {
|
|
320
|
+
return catalog.find((s) => s.organism === organism && s.orbital === orbital);
|
|
321
|
+
}
|
|
322
|
+
function collectRuleCapabilities(overlay) {
|
|
323
|
+
const out = /* @__PURE__ */ new Set();
|
|
324
|
+
for (const r of overlay?.rules ?? []) {
|
|
325
|
+
if (typeof r.capability === "string") out.add(r.capability);
|
|
326
|
+
}
|
|
327
|
+
return out;
|
|
328
|
+
}
|
|
329
|
+
function factoryCallPlanOrbitalName(call) {
|
|
330
|
+
return call.orbitalName ?? call.orbital;
|
|
331
|
+
}
|
|
332
|
+
|
|
37
333
|
// src/factory/questions/reducer.ts
|
|
38
334
|
var PERSISTENCE_VALUES = [
|
|
39
335
|
"persistent",
|
|
@@ -671,6 +967,7 @@ var SCALAR_FIELD_TYPES = [
|
|
|
671
967
|
"string",
|
|
672
968
|
"number",
|
|
673
969
|
"int",
|
|
970
|
+
...NUM_WIDTH_TAGS,
|
|
674
971
|
"boolean",
|
|
675
972
|
"date",
|
|
676
973
|
"timestamp",
|
|
@@ -822,372 +1119,6 @@ var PAGE_OVERRIDE_SCHEMA = {
|
|
|
822
1119
|
}
|
|
823
1120
|
};
|
|
824
1121
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
for (const [knob, field] of Object.entries(contract.declaredConfig ?? {})) {
|
|
829
|
-
const override = config?.[knob];
|
|
830
|
-
if (typeof override === "string") effective[knob] = override;
|
|
831
|
-
else if (field.default !== void 0) effective[knob] = field.default;
|
|
832
|
-
}
|
|
833
|
-
return (event) => {
|
|
834
|
-
if (configRefEventKnob(event) === void 0) return event;
|
|
835
|
-
const r = resolveConfigRefEventName(event, contract.declaredConfig, effective);
|
|
836
|
-
return r.ok ? r.value : void 0;
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
function followEventName(contract, side, name, fromConfig, toConfig) {
|
|
840
|
-
const before = eventNamer(contract, fromConfig);
|
|
841
|
-
const after = eventNamer(contract, toConfig);
|
|
842
|
-
const sources = contract[side].filter((e) => before(e) === name);
|
|
843
|
-
if (sources.length === 0) return { ok: true, value: name };
|
|
844
|
-
const values = [...new Set(sources.flatMap((e) => after(e) ?? []))];
|
|
845
|
-
if (values.length > 1) return { ok: false, message: `${name} comes from ${sources.join(", ")}, which this block names differently (${values.join(", ")}) \u2014 wire one of those names` };
|
|
846
|
-
return { ok: true, value: values[0] };
|
|
847
|
-
}
|
|
848
|
-
function resolveBlockContract(contract, config) {
|
|
849
|
-
const unresolved = [];
|
|
850
|
-
const named = eventNamer(contract, config);
|
|
851
|
-
const resolve = (event) => {
|
|
852
|
-
const v = named(event);
|
|
853
|
-
if (v === void 0 && !unresolved.includes(event)) unresolved.push(event);
|
|
854
|
-
return v;
|
|
855
|
-
};
|
|
856
|
-
const names = (events) => events.flatMap((e) => {
|
|
857
|
-
const v = resolve(e);
|
|
858
|
-
return v === void 0 ? [] : [v];
|
|
859
|
-
});
|
|
860
|
-
const listens = contract.listens.flatMap((l) => {
|
|
861
|
-
const event = resolve(l.event);
|
|
862
|
-
const triggers = resolve(l.triggers);
|
|
863
|
-
return event === void 0 || triggers === void 0 ? [] : [{ ...l, event, triggers }];
|
|
864
|
-
});
|
|
865
|
-
return { contract: { ...contract, emits: names(contract.emits), triggers: names(contract.triggers), listens }, unresolved };
|
|
866
|
-
}
|
|
867
|
-
function bindsRecord(contract, record) {
|
|
868
|
-
return contract.entityRebindable || contract.linkedEntity === void 0 || contract.linkedEntity === record;
|
|
869
|
-
}
|
|
870
|
-
function placedBlocks(node, out) {
|
|
871
|
-
if (node.kind === "block") out.push(node.block);
|
|
872
|
-
else for (const child of node.children) placedBlocks(child, out);
|
|
873
|
-
}
|
|
874
|
-
function checkComposition(spec, ctx) {
|
|
875
|
-
const issues = [];
|
|
876
|
-
if (spec.entity.kind === "declare" && spec.entity.entity.persistence === "persistent" && !spec.entity.entity.collection) {
|
|
877
|
-
issues.push({ code: "missing-collection", path: "entity.collection", message: `persistent entity ${spec.entity.entity.name} declares no collection` });
|
|
878
|
-
}
|
|
879
|
-
const contracts = /* @__PURE__ */ new Map();
|
|
880
|
-
const names = /* @__PURE__ */ new Set();
|
|
881
|
-
const aliases = /* @__PURE__ */ new Map();
|
|
882
|
-
if (spec.entity.kind === "import") aliases.set(spec.entity.as, spec.entity.from);
|
|
883
|
-
for (const b of spec.blocks) {
|
|
884
|
-
const at = `blocks.${b.name}`;
|
|
885
|
-
if (names.has(b.name)) issues.push({ code: "duplicate-name", path: at, message: `two blocks are named "${b.name}"` });
|
|
886
|
-
names.add(b.name);
|
|
887
|
-
const prior = aliases.get(b.as);
|
|
888
|
-
if (prior !== void 0 && prior !== b.from) {
|
|
889
|
-
issues.push({ code: "alias-conflict", path: `${at}.as`, message: `alias "${b.as}" already names ${prior}` });
|
|
890
|
-
}
|
|
891
|
-
aliases.set(b.as, b.from);
|
|
892
|
-
const contract = ctx.block(b.from, b.trait);
|
|
893
|
-
if (contract === null) {
|
|
894
|
-
issues.push({ code: "unknown-block", path: at, message: `${b.from} declares no trait ${b.trait}` });
|
|
895
|
-
continue;
|
|
896
|
-
}
|
|
897
|
-
contracts.set(b.name, resolveBlockContract(contract, b.config).contract);
|
|
898
|
-
for (const key of Object.keys(b.config ?? {})) {
|
|
899
|
-
if (!contract.configKeys.includes(key)) {
|
|
900
|
-
issues.push({ code: "unknown-config-key", path: `${at}.config.${key}`, message: `${b.trait} declares no knob "${key}" (declares: ${contract.configKeys.join(", ")})` });
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
const recordName = spec.entity.kind === "import" ? spec.entity.entity : spec.entity.entity.name;
|
|
904
|
-
if (!bindsRecord(contract, recordName)) {
|
|
905
|
-
issues.push({
|
|
906
|
-
code: "entity-mismatch",
|
|
907
|
-
path: at,
|
|
908
|
-
message: `${b.trait} is bound to the record "${contract.linkedEntity}" and cannot be rebound \u2014 name this page's record "${contract.linkedEntity}" or use another part`
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
if (b.linkedEntity !== void 0 && !contract.entityRebindable) {
|
|
912
|
-
issues.push({ code: "not-rebindable", path: `${at}.linkedEntity`, message: `${b.trait} has a fixed entity binding` });
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
for (const b of spec.blocks) {
|
|
916
|
-
const declared = ctx.block(b.from, b.trait)?.declaredConfig ?? {};
|
|
917
|
-
for (const [key, value] of Object.entries(b.config ?? {})) {
|
|
918
|
-
if (declared[key]?.type !== "trait" || typeof value !== "string") continue;
|
|
919
|
-
const target = value.startsWith("@trait.") ? value.slice("@trait.".length) : void 0;
|
|
920
|
-
if (target === void 0 || !names.has(target)) {
|
|
921
|
-
issues.push({
|
|
922
|
-
code: "unknown-trait-ref",
|
|
923
|
-
path: `blocks.${b.name}.config.${key}`,
|
|
924
|
-
message: `${key} must be "@trait.<block>" naming a block of this composition (${[...names].join(", ")}), got "${value}"`
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
const keptNames = /* @__PURE__ */ new Set();
|
|
930
|
-
for (const k of spec.kept ?? []) {
|
|
931
|
-
if (names.has(k.name) || keptNames.has(k.name)) issues.push({ code: "duplicate-name", path: `kept.${k.name}`, message: `two parts are named "${k.name}"` });
|
|
932
|
-
keptNames.add(k.name);
|
|
933
|
-
}
|
|
934
|
-
const placed = [];
|
|
935
|
-
placedBlocks(spec.layout, placed);
|
|
936
|
-
for (const p of placed) {
|
|
937
|
-
if (!names.has(p) && !keptNames.has(p)) issues.push({ code: "layout-unknown-block", path: `layout.${p}`, message: `the layout places "${p}", which is not a block` });
|
|
938
|
-
}
|
|
939
|
-
const slotted = /* @__PURE__ */ new Set();
|
|
940
|
-
const collectSlots = (v) => {
|
|
941
|
-
if (typeof v === "string") {
|
|
942
|
-
if (v.startsWith("@trait.")) slotted.add(v.slice("@trait.".length));
|
|
943
|
-
} else if (Array.isArray(v)) {
|
|
944
|
-
for (const x of v) collectSlots(x);
|
|
945
|
-
} else if (typeof v === "object" && v !== null) {
|
|
946
|
-
for (const x of Object.values(v)) collectSlots(x);
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
for (const b of spec.blocks) for (const v of Object.values(b.config ?? {})) collectSlots(v);
|
|
950
|
-
for (const b of spec.blocks) {
|
|
951
|
-
if (!placed.includes(b.name) && !slotted.has(b.name)) issues.push({ code: "unplaced-block", path: `blocks.${b.name}`, message: `"${b.name}" is not placed in the layout` });
|
|
952
|
-
}
|
|
953
|
-
for (const [i, w] of (spec.wiring ?? []).entries()) {
|
|
954
|
-
const at = `wiring.${i}`;
|
|
955
|
-
const src = contracts.get(w.fromBlock);
|
|
956
|
-
const dst = contracts.get(w.toBlock);
|
|
957
|
-
if (!names.has(w.fromBlock) || !names.has(w.toBlock)) {
|
|
958
|
-
issues.push({ code: "unknown-wire-block", path: at, message: `wire ${w.fromBlock} \u2192 ${w.toBlock} names a missing block` });
|
|
959
|
-
continue;
|
|
960
|
-
}
|
|
961
|
-
if (src !== void 0 && !src.emits.includes(w.event)) {
|
|
962
|
-
issues.push({ code: "unknown-event", path: `${at}.event`, message: `${w.fromBlock} does not emit ${w.event} (emits: ${src.emits.join(", ")})` });
|
|
963
|
-
}
|
|
964
|
-
if (dst !== void 0 && !dst.triggers.includes(w.trigger)) {
|
|
965
|
-
issues.push({ code: "unknown-trigger", path: `${at}.trigger`, message: `${w.toBlock} handles no ${w.trigger} (handles: ${dst.triggers.join(", ")})` });
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
return issues;
|
|
969
|
-
}
|
|
970
|
-
function layoutTree(node) {
|
|
971
|
-
if (node.kind === "block") return makeSlot(node.block);
|
|
972
|
-
return {
|
|
973
|
-
type: "stack",
|
|
974
|
-
...node.direction !== void 0 ? { direction: node.direction } : {},
|
|
975
|
-
...node.gap !== void 0 ? { gap: node.gap } : {},
|
|
976
|
-
...node.align !== void 0 ? { align: node.align } : {},
|
|
977
|
-
...node.justify !== void 0 ? { justify: node.justify } : {},
|
|
978
|
-
...node.className !== void 0 ? { className: node.className } : {},
|
|
979
|
-
children: node.children.map(layoutTree)
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
function entityName(e) {
|
|
983
|
-
return e.kind === "import" ? e.entity : e.entity.name;
|
|
984
|
-
}
|
|
985
|
-
function assembleComposition(spec, ctx) {
|
|
986
|
-
const issues = checkComposition(spec, ctx);
|
|
987
|
-
if (issues.length > 0) return { ok: false, issues };
|
|
988
|
-
const entity = entityName(spec.entity);
|
|
989
|
-
const uses = [];
|
|
990
|
-
const seen = /* @__PURE__ */ new Set();
|
|
991
|
-
const addUse = (from, as) => {
|
|
992
|
-
if (seen.has(as)) return;
|
|
993
|
-
seen.add(as);
|
|
994
|
-
uses.push({ from, as });
|
|
995
|
-
};
|
|
996
|
-
if (spec.entity.kind === "import") addUse(spec.entity.from, spec.entity.as);
|
|
997
|
-
for (const b of spec.blocks) addUse(b.from, b.as);
|
|
998
|
-
const root = layoutTree(spec.layout);
|
|
999
|
-
const viewName = `${spec.orbital}View`;
|
|
1000
|
-
const view = makeLayoutTrait({
|
|
1001
|
-
name: viewName,
|
|
1002
|
-
linkedEntity: entity,
|
|
1003
|
-
renderUI: typeof root === "string" ? { type: "stack", children: [root] } : root
|
|
1004
|
-
});
|
|
1005
|
-
const blockTraits = spec.blocks.map((b) => {
|
|
1006
|
-
const declared = ctx.block(b.from, b.trait);
|
|
1007
|
-
const contract = declared !== null ? resolveBlockContract(declared, b.config).contract : null;
|
|
1008
|
-
const wires = (spec.wiring ?? []).filter((w) => w.toBlock === b.name);
|
|
1009
|
-
const listens = wires.length > 0 && contract !== null ? [
|
|
1010
|
-
...contract.listens,
|
|
1011
|
-
...wires.map((w) => ({ event: w.event, triggers: w.trigger, source: { kind: "trait", trait: w.fromBlock } }))
|
|
1012
|
-
] : void 0;
|
|
1013
|
-
const rebind = b.linkedEntity ?? (contract?.entityRebindable === true ? entity : void 0);
|
|
1014
|
-
return makeTraitRef({
|
|
1015
|
-
ref: `${b.as}.traits.${b.trait}`,
|
|
1016
|
-
name: b.name,
|
|
1017
|
-
...rebind !== void 0 ? { linkedEntity: rebind } : {},
|
|
1018
|
-
...b.config !== void 0 ? { config: mergeCallSiteConfigOverrides({}, b.config) } : {},
|
|
1019
|
-
...listens !== void 0 ? { listens } : {}
|
|
1020
|
-
});
|
|
1021
|
-
});
|
|
1022
|
-
if (spec.entity.kind === "import") {
|
|
1023
|
-
const e = spec.entity;
|
|
1024
|
-
const orbital = {
|
|
1025
|
-
...makeOrbitalWithUses({ name: spec.orbital, uses, entity: `${e.as}.orbitals.${e.orbital}.entity`, traits: [view, ...blockTraits, ...spec.kept ?? []] }),
|
|
1026
|
-
reference: {
|
|
1027
|
-
ref: `${e.as}.orbitals.${e.orbital}`,
|
|
1028
|
-
entity: e.entity,
|
|
1029
|
-
...e.only !== void 0 ? { only: [...e.only] } : {},
|
|
1030
|
-
pages: { [e.page]: spec.page.path },
|
|
1031
|
-
mounts: { [e.page]: [viewName] }
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
return { ok: true, orbital };
|
|
1035
|
-
}
|
|
1036
|
-
return {
|
|
1037
|
-
ok: true,
|
|
1038
|
-
orbital: makeOrbitalWithUses({
|
|
1039
|
-
name: spec.orbital,
|
|
1040
|
-
uses,
|
|
1041
|
-
entity: spec.entity.entity,
|
|
1042
|
-
traits: [view, ...blockTraits, ...spec.kept ?? []],
|
|
1043
|
-
pages: [{ name: spec.page.name, path: spec.page.path, traits: [{ ref: viewName }] }]
|
|
1044
|
-
})
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
function blockContractOf(trait, orbitalEntity) {
|
|
1048
|
-
const triggers = [];
|
|
1049
|
-
for (const t of trait.stateMachine?.transitions ?? []) if (!triggers.includes(t.event)) triggers.push(t.event);
|
|
1050
|
-
const sets = /* @__PURE__ */ new Set();
|
|
1051
|
-
const visitEffect = (effect) => {
|
|
1052
|
-
if (!Array.isArray(effect)) return;
|
|
1053
|
-
if (effect[0] === "set" && typeof effect[1] === "string" && effect[1].startsWith("@entity.")) {
|
|
1054
|
-
const field = effect[1].slice("@entity.".length).split(".")[0];
|
|
1055
|
-
if (field !== void 0 && field.length > 0) sets.add(field);
|
|
1056
|
-
}
|
|
1057
|
-
for (const child of controlBody(effect)) visitEffect(child);
|
|
1058
|
-
};
|
|
1059
|
-
for (const t of trait.stateMachine?.transitions ?? []) for (const e of t.effects ?? []) visitEffect(e);
|
|
1060
|
-
const linkedEntity = trait.linkedEntity ?? orbitalEntity;
|
|
1061
|
-
return {
|
|
1062
|
-
configKeys: Object.keys(trait.config ?? {}),
|
|
1063
|
-
...trait.config !== void 0 ? { declaredConfig: trait.config } : {},
|
|
1064
|
-
emits: (trait.emits ?? []).map((e) => e.event),
|
|
1065
|
-
triggers,
|
|
1066
|
-
listens: trait.listens ?? [],
|
|
1067
|
-
entityRebindable: trait.entityRebindable === true,
|
|
1068
|
-
setsFields: [...sets],
|
|
1069
|
-
...linkedEntity !== void 0 ? { linkedEntity } : {}
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
function toParamValue(value) {
|
|
1073
|
-
if (value === void 0 || value === null) return void 0;
|
|
1074
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
1075
|
-
if (Array.isArray(value)) {
|
|
1076
|
-
const out = [];
|
|
1077
|
-
for (const v of value) {
|
|
1078
|
-
const p = toParamValue(v);
|
|
1079
|
-
if (p !== void 0) out.push(p);
|
|
1080
|
-
}
|
|
1081
|
-
return out;
|
|
1082
|
-
}
|
|
1083
|
-
if (typeof value === "object") {
|
|
1084
|
-
const out = {};
|
|
1085
|
-
for (const [k, v] of Object.entries(value)) {
|
|
1086
|
-
const p = toParamValue(v);
|
|
1087
|
-
if (p !== void 0) out[k] = p;
|
|
1088
|
-
}
|
|
1089
|
-
return out;
|
|
1090
|
-
}
|
|
1091
|
-
return void 0;
|
|
1092
|
-
}
|
|
1093
|
-
function decomposeOrbital(orbital) {
|
|
1094
|
-
const fromOf = new Map((orbital.uses ?? []).map((u) => [u.as, u.from]));
|
|
1095
|
-
const blocks = [];
|
|
1096
|
-
for (const t of orbital.traits) {
|
|
1097
|
-
if (typeof t === "string" || isInlineTrait(t)) continue;
|
|
1098
|
-
const m = /^([A-Za-z_]\w*)\.traits\.([A-Za-z_]\w*)$/.exec(t.ref);
|
|
1099
|
-
if (m === null) continue;
|
|
1100
|
-
const from = fromOf.get(m[1]);
|
|
1101
|
-
if (from === void 0) continue;
|
|
1102
|
-
const config = {};
|
|
1103
|
-
for (const [key, entry] of Object.entries(t.config ?? {})) {
|
|
1104
|
-
const value = toParamValue(isCallSiteConfigDeclaration(entry) ? entry.default : entry);
|
|
1105
|
-
if (value !== void 0) config[key] = value;
|
|
1106
|
-
}
|
|
1107
|
-
blocks.push({
|
|
1108
|
-
name: t.name ?? m[2],
|
|
1109
|
-
from,
|
|
1110
|
-
as: m[1],
|
|
1111
|
-
trait: m[2],
|
|
1112
|
-
...t.linkedEntity !== void 0 ? { linkedEntity: t.linkedEntity } : {},
|
|
1113
|
-
...Object.keys(config).length > 0 ? { config } : {}
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
return blocks;
|
|
1117
|
-
}
|
|
1118
|
-
function isTraitRefObject(t) {
|
|
1119
|
-
return typeof t !== "string" && !isInlineTrait(t) && "ref" in t;
|
|
1120
|
-
}
|
|
1121
|
-
function refListens(t) {
|
|
1122
|
-
return t.listens ?? [];
|
|
1123
|
-
}
|
|
1124
|
-
function sameListen(a, b) {
|
|
1125
|
-
const src = (l) => l.source?.kind === "trait" ? `trait:${l.source.trait}` : JSON.stringify(l.source ?? null);
|
|
1126
|
-
return a.event === b.event && a.triggers === b.triggers && src(a) === src(b);
|
|
1127
|
-
}
|
|
1128
|
-
function compositionSpecOf(orbital, ctx, chromeRefs) {
|
|
1129
|
-
const kept = [];
|
|
1130
|
-
for (const t of orbital.traits) {
|
|
1131
|
-
if (typeof t === "string") return { ok: false, reason: `trait "${t}" is a bare name, not a block reference` };
|
|
1132
|
-
if (isInlineTrait(t)) kept.push(t);
|
|
1133
|
-
}
|
|
1134
|
-
const refs = orbital.traits.filter(isTraitRefObject);
|
|
1135
|
-
const chromeNames = new Set(refs.filter((t) => chromeRefs.has(t.ref)).map((t) => t.name ?? t.ref));
|
|
1136
|
-
const blocks = decomposeOrbital(orbital).filter((b) => !chromeRefs.has(`${b.as}.traits.${b.trait}`));
|
|
1137
|
-
if (blocks.length !== refs.length - chromeNames.size) {
|
|
1138
|
-
return { ok: false, reason: "a trait reference names no `uses` alias" };
|
|
1139
|
-
}
|
|
1140
|
-
const names = new Set(blocks.map((b) => b.name));
|
|
1141
|
-
const wiring = [];
|
|
1142
|
-
for (const block of blocks) {
|
|
1143
|
-
const ref = refs.find((t) => (t.name ?? "") === block.name || t.name === void 0 && t.ref.endsWith(`.traits.${block.name}`));
|
|
1144
|
-
const contract = ctx.block(block.from, block.trait);
|
|
1145
|
-
const own = contract !== null ? resolveBlockContract(contract, block.config).contract.listens : [];
|
|
1146
|
-
const listens = ref !== void 0 ? refListens(ref) : [];
|
|
1147
|
-
for (const l of listens) {
|
|
1148
|
-
if (l.source?.kind !== "trait" || !names.has(l.source.trait) || own.some((o) => sameListen(o, l))) continue;
|
|
1149
|
-
wiring.push({ fromBlock: l.source.trait, event: l.event, toBlock: block.name, trigger: l.triggers });
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
let entity;
|
|
1153
|
-
let page;
|
|
1154
|
-
let order;
|
|
1155
|
-
if (typeof orbital.entity === "object" && !("extends" in orbital.entity)) {
|
|
1156
|
-
entity = { kind: "declare", entity: orbital.entity };
|
|
1157
|
-
const first = (orbital.pages ?? []).find((p) => typeof p !== "string" && !("ref" in p) && typeof p.path === "string");
|
|
1158
|
-
if (first === void 0 || typeof first === "string" || "ref" in first) return { ok: false, reason: "the orbital has no inline page" };
|
|
1159
|
-
page = { name: first.name, path: first.path };
|
|
1160
|
-
order = (first.traits ?? []).flatMap((t) => typeof t === "string" ? [t] : "ref" in t && typeof t.ref === "string" ? [t.ref] : []);
|
|
1161
|
-
} else {
|
|
1162
|
-
const reference = orbital.reference;
|
|
1163
|
-
const m = reference !== void 0 ? /^([A-Za-z_]\w*)\.orbitals\.([A-Za-z_]\w*)$/.exec(reference.ref) : null;
|
|
1164
|
-
const from = m !== null ? (orbital.uses ?? []).find((u) => u.as === m[1])?.from : void 0;
|
|
1165
|
-
const mounted = Object.entries(reference?.mounts ?? {})[0];
|
|
1166
|
-
if (reference === void 0 || m === null || from === void 0 || reference.entity === void 0 || mounted === void 0) {
|
|
1167
|
-
return { ok: false, reason: "the orbital neither declares its entity nor imports one with a mounted page" };
|
|
1168
|
-
}
|
|
1169
|
-
const [upstream, traits] = mounted;
|
|
1170
|
-
entity = { kind: "import", from, as: m[1], orbital: m[2], entity: reference.entity, page: upstream, ...reference.only !== void 0 ? { only: [...reference.only] } : {} };
|
|
1171
|
-
page = { name: `${orbital.name}Page`, path: reference.pages?.[upstream] ?? upstream };
|
|
1172
|
-
order = [...traits];
|
|
1173
|
-
}
|
|
1174
|
-
const keptNames = new Set(kept.map((k) => k.name));
|
|
1175
|
-
const placed = order.filter((n) => names.has(n) || keptNames.has(n));
|
|
1176
|
-
for (const b of blocks) if (!placed.includes(b.name)) placed.push(b.name);
|
|
1177
|
-
return {
|
|
1178
|
-
ok: true,
|
|
1179
|
-
spec: {
|
|
1180
|
-
orbital: orbital.name,
|
|
1181
|
-
entity,
|
|
1182
|
-
blocks,
|
|
1183
|
-
layout: { kind: "stack", direction: "vertical", children: placed.map((block) => ({ kind: "block", block })) },
|
|
1184
|
-
wiring,
|
|
1185
|
-
page,
|
|
1186
|
-
...kept.length > 0 ? { kept } : {}
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
export { ENTITY_FIELD_SCHEMA, answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assembleComposition, assertNoUnsatisfiableEnum, bindsRecord, blockContractOf, checkComposition, compositionSpecOf, decomposeOrbital, followEventName, mapEntityFieldType, rehydrateKnobDefs, resolveBlockContract, signatureToParamsSchema };
|
|
1192
|
-
//# sourceMappingURL=chunk-KDMV222Q.js.map
|
|
1193
|
-
//# sourceMappingURL=chunk-KDMV222Q.js.map
|
|
1122
|
+
export { ENTITY_FIELD_SCHEMA, answerToMutations, answersToMutations, applyFactoryCallPlanMutation, assertNoUnsatisfiableEnum, deriveInputType, factoryCallPlanOrbitalName, generateQuestions, humanizeKey, rehydrateKnobDefs, signatureToParamsSchema };
|
|
1123
|
+
//# sourceMappingURL=chunk-F6KHUW7T.js.map
|
|
1124
|
+
//# sourceMappingURL=chunk-F6KHUW7T.js.map
|