@almadar/core 10.29.0 → 10.31.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/{builders-DcBjE_Uw.d.ts → builders-DDcCVboe.d.ts} +2567 -906
- package/dist/builders.d.ts +3 -3
- package/dist/builders.js +161 -17
- package/dist/builders.js.map +1 -1
- package/dist/factory/index.d.ts +5 -4
- package/dist/factory-runtime/index.d.ts +63 -18
- package/dist/factory-runtime/index.js +202 -94
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/index.d.ts +8 -9
- package/dist/index.js +1308 -592
- package/dist/index.js.map +1 -1
- package/dist/{pattern-types-JZordBZv.d.ts → pattern-types-VDIr2TkX.d.ts} +375 -48
- package/dist/patterns/component-mapping.json +13 -3
- package/dist/patterns/event-contracts.json +10 -3
- package/dist/patterns/index.d.ts +2167 -787
- package/dist/patterns/index.js +1063 -563
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/patterns-registry.json +995 -554
- package/dist/patterns/registry.json +995 -554
- package/dist/{trait-B_CzfDSi.d.ts → trait-DE6VU4Cd.d.ts} +507 -128
- package/dist/types/index.d.ts +47 -19
- package/dist/types/index.js +222 -24
- package/dist/types/index.js.map +1 -1
- package/dist/{types-CGC5A1-T.d.ts → types-DSfz2mr5.d.ts} +3 -59
- package/package.json +1 -1
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { h as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, j as FactorySignature, R as RuleOverlay,
|
|
2
|
-
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryExposure, g as FactoryPageSignature, i as FactoryProvenance, k as FactorySignatureCatalog, l as FactorySignatureEntityField, m as FactoryTraitSignature,
|
|
3
|
-
import { a as EntityPersistence, E as EntityField } from '../pattern-types-
|
|
4
|
-
|
|
1
|
+
import { h as FactoryParamValue, c as FactoryConfigTier, b as FactoryConfigParam, F as FactoryCallSite, j as FactorySignature, R as RuleOverlay, p as RuleOverlayEntry, o as PresentationOverlay, T as TraitOverlay } from '../types-DSfz2mr5.js';
|
|
2
|
+
export { a as FactoryCallSiteParams, d as FactoryEntitySignature, e as FactoryEventSignature, f as FactoryExposure, g as FactoryPageSignature, i as FactoryProvenance, k as FactorySignatureCatalog, l as FactorySignatureEntityField, m as FactoryTraitSignature, J as JsonSchema, n as JsonSchemaType, O as OwnershipOverlayEntry, P as PresentationNavItem, S as SchemaFieldType, q as TraitOverlayEntry, r as TraitOverlayListener } from '../types-DSfz2mr5.js';
|
|
3
|
+
import { a as EntityPersistence, E as EntityField } from '../pattern-types-VDIr2TkX.js';
|
|
4
|
+
export { J as JsonValue } from '../pattern-types-VDIr2TkX.js';
|
|
5
|
+
import { a as TraitReference } from '../trait-DE6VU4Cd.js';
|
|
5
6
|
import 'zod';
|
|
6
7
|
import '../expression-CB9R3KWk.js';
|
|
7
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as OrbitalSchema, M as MakeTraitRefOpts, a as OrbitalDefinition } from '../builders-
|
|
2
|
-
import { C as CallSiteConfig, b as CallSiteConfigEntry, c as Trait } from '../trait-
|
|
3
|
-
import { E as EntityField, a as EntityPersistence } from '../pattern-types-
|
|
1
|
+
import { O as OrbitalSchema, M as MakeTraitRefOpts, a as OrbitalDefinition } from '../builders-DDcCVboe.js';
|
|
2
|
+
import { C as CallSiteConfig, b as CallSiteConfigEntry, c as Trait } from '../trait-DE6VU4Cd.js';
|
|
3
|
+
import { E as EntityField, a as EntityPersistence } from '../pattern-types-VDIr2TkX.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../expression-CB9R3KWk.js';
|
|
6
6
|
|
|
@@ -149,21 +149,66 @@ declare function rewriteEntityInInlineTrait(trait: Trait, oldName: string, newNa
|
|
|
149
149
|
*/
|
|
150
150
|
declare function mergeCallSiteConfigOverrides(base: CallSiteConfig, overrides: CallSiteConfig): Record<string, CallSiteConfigEntry>;
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
152
|
+
* Apply `traitOverrides.<T>.name` renames to trait DECLARATIONS only,
|
|
153
|
+
* AFTER the schema has been stamped (V4-W4 stamp-before-rename).
|
|
154
|
+
*
|
|
155
|
+
* A trait rename is a pure display-name change: it renames the declaration
|
|
156
|
+
* (`traits[].name` for inline traits, the ref object's local `name` for
|
|
157
|
+
* reference traits) and nothing else. Every REFERENCE to the trait —
|
|
158
|
+
* `pages[].traits[].ref`, `@trait.<canonical>` tokens in sibling config /
|
|
159
|
+
* stateMachine effect trees — is left carrying its canonical name AND its
|
|
160
|
+
* stamped id (page ref `refId`, the referring trait's `traitEmbedIds`
|
|
161
|
+
* side-map). Readers resolve those references by stable id onto the renamed
|
|
162
|
+
* declaration, so no token/page-ref rewrite is needed (this replaced the
|
|
163
|
+
* deleted `applyTraitRenames`).
|
|
164
|
+
*
|
|
165
|
+
* The keys are canonical names because stamping ran while the declaration
|
|
166
|
+
* still carried its canonical name (the factory no longer renames — see
|
|
167
|
+
* `applyParamsToOrb`), so `trait.name === canonicalKey` at this point.
|
|
168
|
+
*
|
|
169
|
+
* Pure — returns a new schema. Applied per orbital; the same override key
|
|
170
|
+
* renames the matching declaration in every orbital that owns it (matches
|
|
171
|
+
* the former per-orbital `applyParamsToOrb` semantics).
|
|
172
|
+
*/
|
|
173
|
+
declare function applyDeclarationTraitRenames(schema: OrbitalSchema, renames: ReadonlyMap<string, string>,
|
|
174
|
+
/**
|
|
175
|
+
* Rename timestamp (ISO string) for the ledger `renames[]` audit row. Threaded
|
|
176
|
+
* from the persistence layer (which owns the clock). The stamp keyed each inline
|
|
177
|
+
* trait's ledger `curName` to its canonical name; without this update the renamed
|
|
178
|
+
* declaration disagrees with `curName` → `ORB_ID_NAME_MISMATCH` on the page ref.
|
|
179
|
+
*/
|
|
180
|
+
at: string): OrbitalSchema;
|
|
181
|
+
/** A single entity display rename: `from` (canonical name at stamp) → `to`. */
|
|
182
|
+
interface EntityDeclarationRename {
|
|
183
|
+
readonly from: string;
|
|
184
|
+
readonly to: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Apply an entity rename to DECLARATIONS only, AFTER the schema has been
|
|
188
|
+
* stamped (V4-W4 stamp-before-rename). The entity, its `@entity.<from>` body
|
|
189
|
+
* tokens, and every trait/page `linkedEntity` were all emitted CANONICAL by
|
|
190
|
+
* the factory, so stamping keyed `entityRefIds`/`linkedEntityId` by `from`.
|
|
191
|
+
*
|
|
192
|
+
* This renames only the visible declaration surface — `entity.name` and every
|
|
193
|
+
* trait/page `linkedEntity` whose value is `from` — leaving the `@entity.<from>`
|
|
194
|
+
* body tokens and every stamped id untouched. Readers resolve those tokens by
|
|
195
|
+
* `entityRefIds` id and resolve `linkedEntity` by `linkedEntityId`, so the
|
|
196
|
+
* rename lands on the right declaration without any body rewrite (this is what
|
|
197
|
+
* lets the factory stop calling `rebindInlineTraitEntity`). Collection is not
|
|
198
|
+
* renamed here — its effective value was already baked at build time.
|
|
199
|
+
*
|
|
200
|
+
* Pure — returns a new schema. Applied to every orbital whose primary entity
|
|
201
|
+
* is named `from` (mirrors the former per-orbital `applyParamsToOrb` scope for
|
|
202
|
+
* a single-orbital write).
|
|
203
|
+
*/
|
|
204
|
+
declare function applyDeclarationEntityRename(schema: OrbitalSchema, rename: EntityDeclarationRename,
|
|
205
|
+
/**
|
|
206
|
+
* Rename timestamp (ISO string) for the ledger `renames[]` audit row. Threaded
|
|
207
|
+
* from the persistence layer (which owns the clock). The stamp keyed the ledger
|
|
208
|
+
* `curName` to the canonical entity name; without this update the renamed
|
|
209
|
+
* declaration disagrees with `curName` → `ORB_ID_NAME_MISMATCH`.
|
|
165
210
|
*/
|
|
166
|
-
|
|
211
|
+
at: string): OrbitalSchema;
|
|
167
212
|
/**
|
|
168
213
|
* The overlay. Resolves the effective entity name + collection, calls
|
|
169
214
|
* `makeOrbitalWithUses` with the rewritten data, then applies the params'
|
|
@@ -187,4 +232,4 @@ declare function applyParamsToOrb(orb: OrbitalSchema, orbitalName: string, _mani
|
|
|
187
232
|
|
|
188
233
|
declare function applyParamsToWholeOrb(orb: OrbitalSchema, manifests: readonly OrbitalParamsManifest[], params: OrbitalFactoryParams): OrbitalSchema;
|
|
189
234
|
|
|
190
|
-
export { type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, applyParamsToOrb, applyParamsToWholeOrb,
|
|
235
|
+
export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
|
|
@@ -1,6 +1,95 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
// src/types/orbital.ts
|
|
4
|
+
var ID_PREFIXES = {
|
|
5
|
+
orbital: "orb_",
|
|
6
|
+
entity: "ent_",
|
|
7
|
+
trait: "trt_",
|
|
8
|
+
event: "evt_",
|
|
9
|
+
page: "pag_",
|
|
10
|
+
service: "svc_",
|
|
11
|
+
theme: "thm_",
|
|
12
|
+
palette: "pal_"
|
|
13
|
+
};
|
|
14
|
+
function brand(value) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function makeIdKind(kind) {
|
|
18
|
+
const prefix = ID_PREFIXES[kind];
|
|
19
|
+
const is = (value) => value.startsWith(prefix) && value.length > prefix.length;
|
|
20
|
+
const as = (value) => {
|
|
21
|
+
if (!is(value)) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Expected ${kind} id (prefix "${prefix}"), got: ${JSON.stringify(value)}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return brand(value);
|
|
27
|
+
};
|
|
28
|
+
return { prefix, is, as };
|
|
29
|
+
}
|
|
30
|
+
var orbitalKind = makeIdKind("orbital");
|
|
31
|
+
var entityKind = makeIdKind("entity");
|
|
32
|
+
var traitKind = makeIdKind("trait");
|
|
33
|
+
var eventKind = makeIdKind("event");
|
|
34
|
+
var pageKind = makeIdKind("page");
|
|
35
|
+
var serviceKind = makeIdKind("service");
|
|
36
|
+
var themeKind = makeIdKind("theme");
|
|
37
|
+
var paletteKind = makeIdKind("palette");
|
|
38
|
+
var isOrbitalId = orbitalKind.is;
|
|
39
|
+
var isEntityId = entityKind.is;
|
|
40
|
+
var isTraitId = traitKind.is;
|
|
41
|
+
var isEventId = eventKind.is;
|
|
42
|
+
var isPageId = pageKind.is;
|
|
43
|
+
var isServiceId = serviceKind.is;
|
|
44
|
+
var isThemeId = themeKind.is;
|
|
45
|
+
var isPaletteEntryId = paletteKind.is;
|
|
46
|
+
function ledgerRename(ledger, id, to, at) {
|
|
47
|
+
const entry = ledger.entries[id];
|
|
48
|
+
if (entry === void 0) return ledger;
|
|
49
|
+
const updated = {
|
|
50
|
+
...entry,
|
|
51
|
+
curName: to,
|
|
52
|
+
renames: [...entry.renames, { from: entry.curName, to, at }]
|
|
53
|
+
};
|
|
54
|
+
return { ...ledger, entries: { ...ledger.entries, [id]: updated } };
|
|
55
|
+
}
|
|
56
|
+
var OrbitalIdSchema = z.string().refine(isOrbitalId, { message: `Expected an orbital id (prefix "${ID_PREFIXES.orbital}")` });
|
|
57
|
+
var EntityIdSchema = z.string().refine(isEntityId, { message: `Expected an entity id (prefix "${ID_PREFIXES.entity}")` });
|
|
58
|
+
var TraitIdSchema = z.string().refine(isTraitId, { message: `Expected a trait id (prefix "${ID_PREFIXES.trait}")` });
|
|
59
|
+
var EventIdSchema = z.string().refine(isEventId, { message: `Expected an event id (prefix "${ID_PREFIXES.event}")` });
|
|
60
|
+
var PageIdSchema = z.string().refine(isPageId, { message: `Expected a page id (prefix "${ID_PREFIXES.page}")` });
|
|
61
|
+
z.string().refine(isServiceId, { message: `Expected a service id (prefix "${ID_PREFIXES.service}")` });
|
|
62
|
+
z.string().refine(isThemeId, { message: `Expected a theme id (prefix "${ID_PREFIXES.theme}")` });
|
|
63
|
+
z.string().refine(isPaletteEntryId, { message: `Expected a palette-entry id (prefix "${ID_PREFIXES.palette}")` });
|
|
64
|
+
var LedgerKindSchema = z.enum([
|
|
65
|
+
"orbital",
|
|
66
|
+
"entity",
|
|
67
|
+
"trait",
|
|
68
|
+
"event",
|
|
69
|
+
"page",
|
|
70
|
+
"service",
|
|
71
|
+
"theme"
|
|
72
|
+
]);
|
|
73
|
+
var LedgerEntrySchema = z.object({
|
|
74
|
+
id: z.string(),
|
|
75
|
+
kind: LedgerKindSchema,
|
|
76
|
+
bakedName: z.string(),
|
|
77
|
+
curName: z.string(),
|
|
78
|
+
renames: z.array(
|
|
79
|
+
z.object({ from: z.string(), to: z.string(), at: z.string() })
|
|
80
|
+
),
|
|
81
|
+
owner: z.enum(["std", "io", "workspace"]),
|
|
82
|
+
parent: TraitIdSchema.optional()
|
|
83
|
+
});
|
|
84
|
+
var IdentityLedgerSchema = z.object({
|
|
85
|
+
schemaVersion: z.literal(1),
|
|
86
|
+
entries: z.record(LedgerEntrySchema)
|
|
87
|
+
});
|
|
88
|
+
var JsonValueSchema = z.lazy(
|
|
89
|
+
() => z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(JsonValueSchema), z.record(JsonValueSchema)])
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// src/types/field.ts
|
|
4
93
|
z.enum([
|
|
5
94
|
"string",
|
|
6
95
|
"number",
|
|
@@ -25,6 +114,7 @@ var RelationCardinalitySchema = z.enum([
|
|
|
25
114
|
]);
|
|
26
115
|
var RelationConfigSchema = z.object({
|
|
27
116
|
entity: z.string().min(1, "Target entity is required"),
|
|
117
|
+
entityId: EntityIdSchema.optional(),
|
|
28
118
|
field: z.string().optional(),
|
|
29
119
|
cardinality: RelationCardinalitySchema.optional(),
|
|
30
120
|
onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
|
|
@@ -35,6 +125,7 @@ var RelationConfigSchema = z.object({
|
|
|
35
125
|
}).transform((data) => {
|
|
36
126
|
const normalized = {
|
|
37
127
|
entity: data.entity || data.target || "",
|
|
128
|
+
entityId: data.entityId,
|
|
38
129
|
cardinality: data.cardinality || data.type,
|
|
39
130
|
field: data.field,
|
|
40
131
|
onDelete: data.onDelete
|
|
@@ -62,7 +153,7 @@ var EntityFieldSchema = z.lazy(() => {
|
|
|
62
153
|
const baseFieldShape = {
|
|
63
154
|
name: z.string().min(1, "Field name is required").optional(),
|
|
64
155
|
required: z.boolean().optional(),
|
|
65
|
-
default:
|
|
156
|
+
default: JsonValueSchema.optional(),
|
|
66
157
|
format: FieldFormatSchema.optional(),
|
|
67
158
|
min: z.number().optional(),
|
|
68
159
|
max: z.number().optional(),
|
|
@@ -329,6 +420,7 @@ var PayloadFieldSchema = z.object({
|
|
|
329
420
|
});
|
|
330
421
|
var EventSchema = z.object({
|
|
331
422
|
key: z.string().min(1, "Event key is required"),
|
|
423
|
+
id: EventIdSchema.optional(),
|
|
332
424
|
name: z.string().min(1, "Event name is required"),
|
|
333
425
|
description: z.string().optional(),
|
|
334
426
|
synonyms: z.string().optional(),
|
|
@@ -346,6 +438,7 @@ var TransitionSchema = z.object({
|
|
|
346
438
|
from: z.string().min(1, "Transition source state is required"),
|
|
347
439
|
to: z.string().min(1, "Transition target state is required"),
|
|
348
440
|
event: z.string().min(1, "Transition event is required"),
|
|
441
|
+
eventId: EventIdSchema.optional(),
|
|
349
442
|
guard: ExpressionSchema.nullish(),
|
|
350
443
|
effects: z.array(EffectSchema).optional(),
|
|
351
444
|
description: z.string().nullish()
|
|
@@ -382,6 +475,7 @@ var ConfigFieldItemsDeclarationSchema = z.lazy(
|
|
|
382
475
|
var ConfigFieldDeclarationSchema = z.object({
|
|
383
476
|
type: z.string(),
|
|
384
477
|
default: TraitConfigValueSchema.optional(),
|
|
478
|
+
refId: z.string().optional(),
|
|
385
479
|
required: z.boolean().optional(),
|
|
386
480
|
label: z.string().optional(),
|
|
387
481
|
description: z.string().optional(),
|
|
@@ -425,7 +519,7 @@ var TraitEntityFieldSchema = z.object({
|
|
|
425
519
|
"enum"
|
|
426
520
|
]),
|
|
427
521
|
required: z.boolean().optional(),
|
|
428
|
-
default:
|
|
522
|
+
default: TraitConfigValueSchema.optional(),
|
|
429
523
|
values: z.array(z.string()).optional(),
|
|
430
524
|
items: ConfigFieldItemsDeclarationSchema.optional(),
|
|
431
525
|
properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
|
|
@@ -447,9 +541,11 @@ var TraitTickSchema = z.object({
|
|
|
447
541
|
interval: z.union([z.literal("frame"), z.number().positive()]),
|
|
448
542
|
appliesTo: z.array(z.string()).optional(),
|
|
449
543
|
pages: z.array(z.string()).optional(),
|
|
544
|
+
pageIds: z.array(PageIdSchema).optional(),
|
|
450
545
|
guard: ExpressionSchema.optional(),
|
|
451
546
|
effects: z.array(EffectSchema).min(1),
|
|
452
|
-
emits: z.array(z.string()).optional()
|
|
547
|
+
emits: z.array(z.string()).optional(),
|
|
548
|
+
emitIds: z.array(EventIdSchema).optional()
|
|
453
549
|
});
|
|
454
550
|
var EventScopeSchema = z.enum(["internal", "external"]);
|
|
455
551
|
var EventPayloadFieldSchema = z.object({
|
|
@@ -484,6 +580,7 @@ var TraitEventContractSchema = z.object({
|
|
|
484
580
|
/^([A-Za-z][A-Za-z0-9_]*|@config\.[A-Za-z_][A-Za-z0-9_]*)$/,
|
|
485
581
|
"Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference"
|
|
486
582
|
),
|
|
583
|
+
eventId: EventIdSchema.optional(),
|
|
487
584
|
description: z.string().optional(),
|
|
488
585
|
synonyms: z.string().optional(),
|
|
489
586
|
tier: z.string().optional(),
|
|
@@ -492,16 +589,24 @@ var TraitEventContractSchema = z.object({
|
|
|
492
589
|
});
|
|
493
590
|
var ListenSourceSchema = z.union([
|
|
494
591
|
z.object({ kind: z.literal("any") }),
|
|
495
|
-
z.object({
|
|
592
|
+
z.object({
|
|
593
|
+
kind: z.literal("trait"),
|
|
594
|
+
trait: z.string().min(1),
|
|
595
|
+
traitId: TraitIdSchema.optional()
|
|
596
|
+
}),
|
|
496
597
|
z.object({
|
|
497
598
|
kind: z.literal("orbital"),
|
|
498
599
|
orbital: z.string().min(1),
|
|
499
|
-
trait: z.string().min(1)
|
|
600
|
+
trait: z.string().min(1),
|
|
601
|
+
orbitalId: OrbitalIdSchema.optional(),
|
|
602
|
+
traitId: TraitIdSchema.optional()
|
|
500
603
|
})
|
|
501
604
|
]);
|
|
502
605
|
var TraitEventListenerSchema = z.object({
|
|
503
606
|
event: z.string().min(1),
|
|
607
|
+
eventId: EventIdSchema.optional(),
|
|
504
608
|
triggers: z.string().min(1),
|
|
609
|
+
triggersId: EventIdSchema.optional(),
|
|
505
610
|
description: z.string().optional(),
|
|
506
611
|
synonyms: z.string().optional(),
|
|
507
612
|
tier: z.string().optional(),
|
|
@@ -517,14 +622,20 @@ var RequiredFieldSchema = z.object({
|
|
|
517
622
|
});
|
|
518
623
|
z.object({
|
|
519
624
|
ref: z.string().min(1),
|
|
625
|
+
refId: TraitIdSchema.optional(),
|
|
626
|
+
// V4 local declaration id (see the interface doc) — declared so the
|
|
627
|
+
// strip-mode zod gate carries it through instead of dropping it.
|
|
628
|
+
id: TraitIdSchema.optional(),
|
|
520
629
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
521
630
|
from: z.string().optional(),
|
|
522
631
|
linkedEntity: z.string().optional(),
|
|
632
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
523
633
|
name: z.string().optional(),
|
|
524
634
|
events: z.record(
|
|
525
635
|
z.string().min(1, "events key (atom event name) must be non-empty"),
|
|
526
636
|
z.string().min(1, "events value (caller event name) must be non-empty")
|
|
527
637
|
).optional(),
|
|
638
|
+
eventIds: z.record(z.string().min(1), EventIdSchema).optional(),
|
|
528
639
|
fields: z.record(
|
|
529
640
|
z.string().min(1, "fields key (canonical field name) must be non-empty"),
|
|
530
641
|
z.string().min(1, "fields value (consumer field name) must be non-empty")
|
|
@@ -543,12 +654,11 @@ z.object({
|
|
|
543
654
|
listens: z.array(z.unknown()).optional(),
|
|
544
655
|
emitsScope: z.enum(["internal", "external"]).optional(),
|
|
545
656
|
// Phase F.8: per-transition effects override. The keys are event
|
|
546
|
-
// names (the transition triggers AFTER renames)
|
|
547
|
-
//
|
|
548
|
-
// shape during application, so the schema accepts loose `unknown[]`.
|
|
657
|
+
// names (the transition triggers AFTER renames); values are SExpr
|
|
658
|
+
// effect tuples.
|
|
549
659
|
effects: z.record(
|
|
550
660
|
z.string().min(1, "effects override key (event name) must be non-empty"),
|
|
551
|
-
z.array(
|
|
661
|
+
z.array(SExprSchema)
|
|
552
662
|
).optional()
|
|
553
663
|
}).refine(
|
|
554
664
|
(ref2) => {
|
|
@@ -574,6 +684,7 @@ var SourceBehaviorMetadataSchema = z.object({
|
|
|
574
684
|
originalName: z.string().min(1)
|
|
575
685
|
});
|
|
576
686
|
var TraitSchema = z.object({
|
|
687
|
+
id: TraitIdSchema.optional(),
|
|
577
688
|
name: z.string().min(1),
|
|
578
689
|
description: z.string().optional(),
|
|
579
690
|
description_visual_prompt: z.string().optional(),
|
|
@@ -585,6 +696,9 @@ var TraitSchema = z.object({
|
|
|
585
696
|
capabilities: z.array(z.string()).optional(),
|
|
586
697
|
scope: TraitScopeSchema,
|
|
587
698
|
linkedEntity: z.string().optional(),
|
|
699
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
700
|
+
entityRefIds: z.record(z.string().min(1), EntityIdSchema).optional(),
|
|
701
|
+
traitEmbedIds: z.record(z.string().min(1), TraitIdSchema).optional(),
|
|
588
702
|
requiredFields: z.array(RequiredFieldSchema).optional(),
|
|
589
703
|
dataEntities: z.array(TraitDataEntitySchema).optional(),
|
|
590
704
|
stateMachine: StateMachineSchema.optional(),
|
|
@@ -627,10 +741,13 @@ var ViewTypeSchema = z.enum([
|
|
|
627
741
|
]);
|
|
628
742
|
var PageTraitRefSchema = z.object({
|
|
629
743
|
ref: z.string().min(1, "Trait ref is required"),
|
|
744
|
+
refId: TraitIdSchema.optional(),
|
|
630
745
|
linkedEntity: z.string().optional(),
|
|
746
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
631
747
|
config: TraitConfigSchema.optional()
|
|
632
748
|
});
|
|
633
749
|
z.object({
|
|
750
|
+
id: PageIdSchema.optional(),
|
|
634
751
|
name: z.string().min(1, "Page name is required"),
|
|
635
752
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
636
753
|
primaryEntity: z.string().min(1, "Primary entity is required"),
|
|
@@ -638,6 +755,7 @@ z.object({
|
|
|
638
755
|
title: z.string().optional()
|
|
639
756
|
}).strict();
|
|
640
757
|
var OrbitalPageSchema = z.object({
|
|
758
|
+
id: PageIdSchema.optional(),
|
|
641
759
|
name: z.string().min(1, "Page name is required"),
|
|
642
760
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
643
761
|
viewType: ViewTypeSchema.optional(),
|
|
@@ -1153,11 +1271,14 @@ var PageRefStringSchema = z.string().regex(
|
|
|
1153
1271
|
);
|
|
1154
1272
|
var PageRefObjectSchema = z.object({
|
|
1155
1273
|
ref: PageRefStringSchema,
|
|
1274
|
+
refId: PageIdSchema.optional(),
|
|
1156
1275
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
1157
1276
|
from: z.string().optional(),
|
|
1158
1277
|
path: z.string().startsWith("/").optional(),
|
|
1159
1278
|
linkedEntity: z.string().optional(),
|
|
1160
|
-
|
|
1279
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
1280
|
+
traits: z.array(TraitRefSchema).optional(),
|
|
1281
|
+
traitRefIds: z.array(TraitIdSchema).optional()
|
|
1161
1282
|
});
|
|
1162
1283
|
var PageRefSchema = z.union([
|
|
1163
1284
|
PageSchema,
|
|
@@ -1193,6 +1314,7 @@ var ComputedEventListenerSchema = z.object({
|
|
|
1193
1314
|
payloadMapping: z.record(z.string()).optional()
|
|
1194
1315
|
});
|
|
1195
1316
|
var OrbitalDefinitionSchema = z.object({
|
|
1317
|
+
id: OrbitalIdSchema.optional(),
|
|
1196
1318
|
name: z.string().min(1, "Orbital name is required"),
|
|
1197
1319
|
description: z.string().optional(),
|
|
1198
1320
|
visual_prompt: z.string().optional(),
|
|
@@ -1253,7 +1375,12 @@ z.object({
|
|
|
1253
1375
|
orbitals: z.array(OrbitalSchema).min(1, "At least one orbital is required"),
|
|
1254
1376
|
services: z.array(ServiceDefinitionSchema).optional(),
|
|
1255
1377
|
config: OrbitalConfigSchema.optional(),
|
|
1256
|
-
_metadata: SchemaMetadataSchema.optional()
|
|
1378
|
+
_metadata: SchemaMetadataSchema.optional(),
|
|
1379
|
+
// V4 identity — optional/dual-carry until the Phase-7 flip. Present on
|
|
1380
|
+
// id-carrying `.orb` files so `parseOrbitalSchema` preserves them instead
|
|
1381
|
+
// of stripping unknown keys.
|
|
1382
|
+
schemaVersion: z.number().optional(),
|
|
1383
|
+
ledger: IdentityLedgerSchema.optional()
|
|
1257
1384
|
});
|
|
1258
1385
|
z.string().refine(
|
|
1259
1386
|
(val) => {
|
|
@@ -1370,6 +1497,7 @@ function makeTraitRef(opts) {
|
|
|
1370
1497
|
if (opts.from !== void 0) ref2.from = opts.from;
|
|
1371
1498
|
if (opts.name !== void 0) ref2.name = opts.name;
|
|
1372
1499
|
if (opts.linkedEntity !== void 0) ref2.linkedEntity = opts.linkedEntity;
|
|
1500
|
+
if (opts.linkedEntityId !== void 0) ref2.linkedEntityId = opts.linkedEntityId;
|
|
1373
1501
|
if (opts.events !== void 0) ref2.events = opts.events;
|
|
1374
1502
|
if (opts.fields !== void 0) ref2.fields = opts.fields;
|
|
1375
1503
|
if (opts.effects !== void 0) ref2.effects = opts.effects;
|
|
@@ -1656,32 +1784,17 @@ function rewriteEntityInInlineTrait(trait, oldName, newName) {
|
|
|
1656
1784
|
}
|
|
1657
1785
|
return next;
|
|
1658
1786
|
}
|
|
1659
|
-
function rebuildTraits(
|
|
1787
|
+
function rebuildTraits(traits) {
|
|
1660
1788
|
return traits.map((t) => {
|
|
1661
|
-
if (!isTraitReferenceObject(t))
|
|
1662
|
-
|
|
1663
|
-
return rebindInlineTraitEntity(t, ctx.canonicalEntityName, effectiveEntityName);
|
|
1664
|
-
}
|
|
1665
|
-
const rewrittenLinkedEntity = t.linkedEntity === ctx.canonicalEntityName ? effectiveEntityName : t.linkedEntity;
|
|
1666
|
-
const opts = {
|
|
1667
|
-
...t,
|
|
1668
|
-
linkedEntity: rewrittenLinkedEntity
|
|
1669
|
-
};
|
|
1670
|
-
return makeTraitRef(opts);
|
|
1789
|
+
if (!isTraitReferenceObject(t)) return t;
|
|
1790
|
+
return makeTraitRef({ ...t });
|
|
1671
1791
|
});
|
|
1672
1792
|
}
|
|
1673
|
-
function rebuildPages(
|
|
1793
|
+
function rebuildPages(pages) {
|
|
1674
1794
|
if (!pages) return [];
|
|
1675
1795
|
return pages.map((p) => {
|
|
1676
|
-
if (!isPageRefObject(p))
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
const rewrittenLinkedEntity = p.linkedEntity === ctx.canonicalEntityName ? effectiveEntityName : p.linkedEntity;
|
|
1680
|
-
const opts = {
|
|
1681
|
-
...p,
|
|
1682
|
-
linkedEntity: rewrittenLinkedEntity
|
|
1683
|
-
};
|
|
1684
|
-
return makePageRef(opts);
|
|
1796
|
+
if (!isPageRefObject(p)) return p;
|
|
1797
|
+
return makePageRef({ ...p });
|
|
1685
1798
|
});
|
|
1686
1799
|
}
|
|
1687
1800
|
function mergeCallSiteConfigOverrides(base, overrides) {
|
|
@@ -1699,85 +1812,81 @@ function mergeCallSiteConfigOverrides(base, overrides) {
|
|
|
1699
1812
|
}
|
|
1700
1813
|
return next;
|
|
1701
1814
|
}
|
|
1702
|
-
function
|
|
1703
|
-
if (renames.size === 0) return
|
|
1704
|
-
const
|
|
1705
|
-
const
|
|
1706
|
-
if (
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
if (
|
|
1713
|
-
|
|
1714
|
-
const out = {};
|
|
1715
|
-
for (const [k, x] of Object.entries(v)) out[k] = rewriteValue(x);
|
|
1716
|
-
return out;
|
|
1717
|
-
}
|
|
1718
|
-
return v;
|
|
1815
|
+
function applyDeclarationTraitRenames(schema, renames, at) {
|
|
1816
|
+
if (renames.size === 0) return schema;
|
|
1817
|
+
const renamedTraitIds = [];
|
|
1818
|
+
const renameDeclaration = (t) => {
|
|
1819
|
+
if (typeof t !== "object" || t === null) return t;
|
|
1820
|
+
const named = t;
|
|
1821
|
+
if (typeof named.name !== "string") return t;
|
|
1822
|
+
const renamed = renames.get(named.name);
|
|
1823
|
+
if (renamed === void 0) return t;
|
|
1824
|
+
const id = t.id;
|
|
1825
|
+
if (typeof id === "string") renamedTraitIds.push({ id, to: renamed });
|
|
1826
|
+
return { ...t, name: renamed };
|
|
1719
1827
|
};
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1828
|
+
const orbitals = schema.orbitals.map((orbital) => {
|
|
1829
|
+
if (!("traits" in orbital) || !Array.isArray(orbital.traits)) return orbital;
|
|
1830
|
+
return { ...orbital, traits: orbital.traits.map(renameDeclaration) };
|
|
1831
|
+
});
|
|
1832
|
+
let ledger = schema.ledger;
|
|
1833
|
+
if (ledger !== void 0) {
|
|
1834
|
+
for (const { id, to } of renamedTraitIds) {
|
|
1835
|
+
ledger = ledgerRename(ledger, id, to, at);
|
|
1723
1836
|
}
|
|
1724
|
-
|
|
1725
|
-
};
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1733
|
-
(
|
|
1734
|
-
|
|
1735
|
-
const traits = (orbital.traits ?? []).map((t) => {
|
|
1736
|
-
if (typeof t !== "object" || t === null) return t;
|
|
1737
|
-
if ("ref" in t) {
|
|
1738
|
-
return t.config !== void 0 ? { ...t, config: rewriteConfig(t.config) } : t;
|
|
1837
|
+
}
|
|
1838
|
+
return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
|
|
1839
|
+
}
|
|
1840
|
+
function applyDeclarationEntityRename(schema, rename, at) {
|
|
1841
|
+
if (rename.from === rename.to) return schema;
|
|
1842
|
+
const linkedEntityIsFrom = (shape) => shape.linkedEntity === rename.from;
|
|
1843
|
+
const renamedEntityIds = [];
|
|
1844
|
+
const orbitals = schema.orbitals.map((orbital) => {
|
|
1845
|
+
const entity = orbital.entity;
|
|
1846
|
+
if (typeof entity !== "object" || entity === null || entity.name !== rename.from) {
|
|
1847
|
+
return orbital;
|
|
1739
1848
|
}
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1849
|
+
const entityId = entity.id;
|
|
1850
|
+
if (typeof entityId === "string") renamedEntityIds.push(entityId);
|
|
1851
|
+
const traits = orbital.traits.map(
|
|
1852
|
+
(t) => typeof t === "object" && t !== null && linkedEntityIsFrom(t) ? { ...t, linkedEntity: rename.to } : t
|
|
1853
|
+
);
|
|
1854
|
+
const pages = orbital.pages?.map(
|
|
1855
|
+
(p) => typeof p === "object" && p !== null && linkedEntityIsFrom(p) ? { ...p, linkedEntity: rename.to } : p
|
|
1856
|
+
);
|
|
1857
|
+
return {
|
|
1858
|
+
...orbital,
|
|
1859
|
+
entity: { ...entity, name: rename.to },
|
|
1860
|
+
traits,
|
|
1861
|
+
...pages !== void 0 ? { pages } : {}
|
|
1862
|
+
};
|
|
1742
1863
|
});
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
return renamed !== void 0 ? { ...entry, ref: renamed } : entry;
|
|
1864
|
+
let ledger = schema.ledger;
|
|
1865
|
+
if (ledger !== void 0) {
|
|
1866
|
+
for (const id of renamedEntityIds) {
|
|
1867
|
+
ledger = ledgerRename(ledger, id, rename.to, at);
|
|
1748
1868
|
}
|
|
1749
|
-
|
|
1750
|
-
};
|
|
1751
|
-
const pages = (orbital.pages ?? []).map((p) => {
|
|
1752
|
-
if (typeof p !== "object" || p === null) return p;
|
|
1753
|
-
if (!Array.isArray(p.traits)) return p;
|
|
1754
|
-
return { ...p, traits: p.traits.map(renamePageTrait) };
|
|
1755
|
-
});
|
|
1756
|
-
return { ...orbital, traits, pages };
|
|
1869
|
+
}
|
|
1870
|
+
return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
|
|
1757
1871
|
}
|
|
1758
1872
|
function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
1759
1873
|
const orbital = findOrbitalOrThrow(orb, orbitalName);
|
|
1760
1874
|
const canonicalEntity = assertResolvedEntity(orbital.entity, orbitalName, orb.name);
|
|
1761
1875
|
const canonicalEntityName = canonicalEntity.name;
|
|
1762
|
-
const effectiveEntityName = params.entityName ?? canonicalEntityName;
|
|
1763
1876
|
const effectiveCollection = typeof canonicalEntity.collection === "string" ? params.collection ?? (params.entityName ? `${params.entityName.toLowerCase()}s` : canonicalEntity.collection) : params.collection;
|
|
1764
|
-
const ctx = {
|
|
1877
|
+
const ctx = { canonicalEntity };
|
|
1765
1878
|
const built = makeOrbitalWithUses({
|
|
1766
1879
|
name: orbital.name,
|
|
1767
1880
|
uses: orbital.uses ?? [],
|
|
1768
|
-
entity: buildEntity(ctx,
|
|
1769
|
-
traits: rebuildTraits(
|
|
1770
|
-
pages: rebuildPages(
|
|
1881
|
+
entity: buildEntity(ctx, canonicalEntityName, effectiveCollection, params),
|
|
1882
|
+
traits: rebuildTraits(orbital.traits),
|
|
1883
|
+
pages: rebuildPages(orbital.pages)
|
|
1771
1884
|
});
|
|
1772
|
-
const traitRenames = /* @__PURE__ */ new Map();
|
|
1773
1885
|
if (built.traits && params.traitOverrides !== void 0) {
|
|
1774
1886
|
built.traits = built.traits.map((t) => {
|
|
1775
1887
|
if (!isTraitReferenceObject(t) || typeof t.name !== "string") return t;
|
|
1776
1888
|
const override = params.traitOverrides?.[t.name];
|
|
1777
1889
|
if (!override) return t;
|
|
1778
|
-
if (override.name !== void 0 && override.name !== t.name) {
|
|
1779
|
-
traitRenames.set(t.name, override.name);
|
|
1780
|
-
}
|
|
1781
1890
|
const merged = { ...t };
|
|
1782
1891
|
if (override.config !== void 0) {
|
|
1783
1892
|
merged.config = mergeCallSiteConfigOverrides(t.config ?? {}, override.config);
|
|
@@ -1798,7 +1907,6 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
1798
1907
|
}
|
|
1799
1908
|
merged.events = { ...t.events ?? {}, ...override.events };
|
|
1800
1909
|
}
|
|
1801
|
-
if (override.name !== void 0) merged.name = override.name;
|
|
1802
1910
|
if (override.emitsScope !== void 0) merged.emitsScope = override.emitsScope;
|
|
1803
1911
|
if (override.listens !== void 0) merged.listens = override.listens;
|
|
1804
1912
|
return merged;
|
|
@@ -1810,7 +1918,7 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
1810
1918
|
return { ...p, path: params.pagePath };
|
|
1811
1919
|
});
|
|
1812
1920
|
}
|
|
1813
|
-
return
|
|
1921
|
+
return built;
|
|
1814
1922
|
}
|
|
1815
1923
|
|
|
1816
1924
|
// src/factory-runtime/apply-params-to-whole-orb.ts
|
|
@@ -1831,6 +1939,6 @@ function applyParamsToWholeOrb(orb, manifests, params) {
|
|
|
1831
1939
|
return { ...orb, orbitals: rebuilt };
|
|
1832
1940
|
}
|
|
1833
1941
|
|
|
1834
|
-
export { applyParamsToOrb, applyParamsToWholeOrb,
|
|
1942
|
+
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
|
|
1835
1943
|
//# sourceMappingURL=index.js.map
|
|
1836
1944
|
//# sourceMappingURL=index.js.map
|