@almadar/core 10.29.0 → 10.30.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-C458pIMW.d.ts} +1882 -221
- package/dist/builders.d.ts +3 -3
- package/dist/builders.js +151 -11
- 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 +192 -88
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +428 -57
- package/dist/index.js.map +1 -1
- package/dist/json-DOTchoRS.d.ts +57 -0
- package/dist/{pattern-types-JZordBZv.d.ts → pattern-types-CLcOXOmW.d.ts} +273 -13
- package/dist/patterns/component-mapping.json +1 -1
- package/dist/patterns/event-contracts.json +1 -1
- package/dist/patterns/index.d.ts +327 -48
- package/dist/patterns/index.js +188 -34
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/patterns-registry.json +146 -29
- package/dist/patterns/registry.json +146 -29
- package/dist/{trait-B_CzfDSi.d.ts → trait-CwWjkU-1.d.ts} +423 -45
- package/dist/types/index.d.ts +49 -19
- package/dist/types/index.js +212 -18
- package/dist/types/index.js.map +1 -1
- package/dist/{types-CGC5A1-T.d.ts → types-yW22YNNt.d.ts} +4 -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
|
-
import { a as TraitReference } from '../trait-
|
|
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-yW22YNNt.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-yW22YNNt.js';
|
|
3
|
+
import { a as EntityPersistence, E as EntityField } from '../pattern-types-CLcOXOmW.js';
|
|
4
|
+
import { a as TraitReference } from '../trait-CwWjkU-1.js';
|
|
5
|
+
export { J as JsonValue } from '../json-DOTchoRS.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-C458pIMW.js';
|
|
2
|
+
import { C as CallSiteConfig, b as CallSiteConfigEntry, c as Trait } from '../trait-CwWjkU-1.js';
|
|
3
|
+
import { E as EntityField, a as EntityPersistence } from '../pattern-types-CLcOXOmW.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,90 @@
|
|
|
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
|
+
});
|
|
4
88
|
z.enum([
|
|
5
89
|
"string",
|
|
6
90
|
"number",
|
|
@@ -25,6 +109,7 @@ var RelationCardinalitySchema = z.enum([
|
|
|
25
109
|
]);
|
|
26
110
|
var RelationConfigSchema = z.object({
|
|
27
111
|
entity: z.string().min(1, "Target entity is required"),
|
|
112
|
+
entityId: EntityIdSchema.optional(),
|
|
28
113
|
field: z.string().optional(),
|
|
29
114
|
cardinality: RelationCardinalitySchema.optional(),
|
|
30
115
|
onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
|
|
@@ -35,6 +120,7 @@ var RelationConfigSchema = z.object({
|
|
|
35
120
|
}).transform((data) => {
|
|
36
121
|
const normalized = {
|
|
37
122
|
entity: data.entity || data.target || "",
|
|
123
|
+
entityId: data.entityId,
|
|
38
124
|
cardinality: data.cardinality || data.type,
|
|
39
125
|
field: data.field,
|
|
40
126
|
onDelete: data.onDelete
|
|
@@ -329,6 +415,7 @@ var PayloadFieldSchema = z.object({
|
|
|
329
415
|
});
|
|
330
416
|
var EventSchema = z.object({
|
|
331
417
|
key: z.string().min(1, "Event key is required"),
|
|
418
|
+
id: EventIdSchema.optional(),
|
|
332
419
|
name: z.string().min(1, "Event name is required"),
|
|
333
420
|
description: z.string().optional(),
|
|
334
421
|
synonyms: z.string().optional(),
|
|
@@ -346,6 +433,7 @@ var TransitionSchema = z.object({
|
|
|
346
433
|
from: z.string().min(1, "Transition source state is required"),
|
|
347
434
|
to: z.string().min(1, "Transition target state is required"),
|
|
348
435
|
event: z.string().min(1, "Transition event is required"),
|
|
436
|
+
eventId: EventIdSchema.optional(),
|
|
349
437
|
guard: ExpressionSchema.nullish(),
|
|
350
438
|
effects: z.array(EffectSchema).optional(),
|
|
351
439
|
description: z.string().nullish()
|
|
@@ -382,6 +470,7 @@ var ConfigFieldItemsDeclarationSchema = z.lazy(
|
|
|
382
470
|
var ConfigFieldDeclarationSchema = z.object({
|
|
383
471
|
type: z.string(),
|
|
384
472
|
default: TraitConfigValueSchema.optional(),
|
|
473
|
+
refId: z.string().optional(),
|
|
385
474
|
required: z.boolean().optional(),
|
|
386
475
|
label: z.string().optional(),
|
|
387
476
|
description: z.string().optional(),
|
|
@@ -447,9 +536,11 @@ var TraitTickSchema = z.object({
|
|
|
447
536
|
interval: z.union([z.literal("frame"), z.number().positive()]),
|
|
448
537
|
appliesTo: z.array(z.string()).optional(),
|
|
449
538
|
pages: z.array(z.string()).optional(),
|
|
539
|
+
pageIds: z.array(PageIdSchema).optional(),
|
|
450
540
|
guard: ExpressionSchema.optional(),
|
|
451
541
|
effects: z.array(EffectSchema).min(1),
|
|
452
|
-
emits: z.array(z.string()).optional()
|
|
542
|
+
emits: z.array(z.string()).optional(),
|
|
543
|
+
emitIds: z.array(EventIdSchema).optional()
|
|
453
544
|
});
|
|
454
545
|
var EventScopeSchema = z.enum(["internal", "external"]);
|
|
455
546
|
var EventPayloadFieldSchema = z.object({
|
|
@@ -484,6 +575,7 @@ var TraitEventContractSchema = z.object({
|
|
|
484
575
|
/^([A-Za-z][A-Za-z0-9_]*|@config\.[A-Za-z_][A-Za-z0-9_]*)$/,
|
|
485
576
|
"Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference"
|
|
486
577
|
),
|
|
578
|
+
eventId: EventIdSchema.optional(),
|
|
487
579
|
description: z.string().optional(),
|
|
488
580
|
synonyms: z.string().optional(),
|
|
489
581
|
tier: z.string().optional(),
|
|
@@ -492,16 +584,24 @@ var TraitEventContractSchema = z.object({
|
|
|
492
584
|
});
|
|
493
585
|
var ListenSourceSchema = z.union([
|
|
494
586
|
z.object({ kind: z.literal("any") }),
|
|
495
|
-
z.object({
|
|
587
|
+
z.object({
|
|
588
|
+
kind: z.literal("trait"),
|
|
589
|
+
trait: z.string().min(1),
|
|
590
|
+
traitId: TraitIdSchema.optional()
|
|
591
|
+
}),
|
|
496
592
|
z.object({
|
|
497
593
|
kind: z.literal("orbital"),
|
|
498
594
|
orbital: z.string().min(1),
|
|
499
|
-
trait: z.string().min(1)
|
|
595
|
+
trait: z.string().min(1),
|
|
596
|
+
orbitalId: OrbitalIdSchema.optional(),
|
|
597
|
+
traitId: TraitIdSchema.optional()
|
|
500
598
|
})
|
|
501
599
|
]);
|
|
502
600
|
var TraitEventListenerSchema = z.object({
|
|
503
601
|
event: z.string().min(1),
|
|
602
|
+
eventId: EventIdSchema.optional(),
|
|
504
603
|
triggers: z.string().min(1),
|
|
604
|
+
triggersId: EventIdSchema.optional(),
|
|
505
605
|
description: z.string().optional(),
|
|
506
606
|
synonyms: z.string().optional(),
|
|
507
607
|
tier: z.string().optional(),
|
|
@@ -517,14 +617,20 @@ var RequiredFieldSchema = z.object({
|
|
|
517
617
|
});
|
|
518
618
|
z.object({
|
|
519
619
|
ref: z.string().min(1),
|
|
620
|
+
refId: TraitIdSchema.optional(),
|
|
621
|
+
// V4 local declaration id (see the interface doc) — declared so the
|
|
622
|
+
// strip-mode zod gate carries it through instead of dropping it.
|
|
623
|
+
id: TraitIdSchema.optional(),
|
|
520
624
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
521
625
|
from: z.string().optional(),
|
|
522
626
|
linkedEntity: z.string().optional(),
|
|
627
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
523
628
|
name: z.string().optional(),
|
|
524
629
|
events: z.record(
|
|
525
630
|
z.string().min(1, "events key (atom event name) must be non-empty"),
|
|
526
631
|
z.string().min(1, "events value (caller event name) must be non-empty")
|
|
527
632
|
).optional(),
|
|
633
|
+
eventIds: z.record(z.string().min(1), EventIdSchema).optional(),
|
|
528
634
|
fields: z.record(
|
|
529
635
|
z.string().min(1, "fields key (canonical field name) must be non-empty"),
|
|
530
636
|
z.string().min(1, "fields value (consumer field name) must be non-empty")
|
|
@@ -574,6 +680,7 @@ var SourceBehaviorMetadataSchema = z.object({
|
|
|
574
680
|
originalName: z.string().min(1)
|
|
575
681
|
});
|
|
576
682
|
var TraitSchema = z.object({
|
|
683
|
+
id: TraitIdSchema.optional(),
|
|
577
684
|
name: z.string().min(1),
|
|
578
685
|
description: z.string().optional(),
|
|
579
686
|
description_visual_prompt: z.string().optional(),
|
|
@@ -585,6 +692,9 @@ var TraitSchema = z.object({
|
|
|
585
692
|
capabilities: z.array(z.string()).optional(),
|
|
586
693
|
scope: TraitScopeSchema,
|
|
587
694
|
linkedEntity: z.string().optional(),
|
|
695
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
696
|
+
entityRefIds: z.record(z.string().min(1), EntityIdSchema).optional(),
|
|
697
|
+
traitEmbedIds: z.record(z.string().min(1), TraitIdSchema).optional(),
|
|
588
698
|
requiredFields: z.array(RequiredFieldSchema).optional(),
|
|
589
699
|
dataEntities: z.array(TraitDataEntitySchema).optional(),
|
|
590
700
|
stateMachine: StateMachineSchema.optional(),
|
|
@@ -627,10 +737,13 @@ var ViewTypeSchema = z.enum([
|
|
|
627
737
|
]);
|
|
628
738
|
var PageTraitRefSchema = z.object({
|
|
629
739
|
ref: z.string().min(1, "Trait ref is required"),
|
|
740
|
+
refId: TraitIdSchema.optional(),
|
|
630
741
|
linkedEntity: z.string().optional(),
|
|
742
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
631
743
|
config: TraitConfigSchema.optional()
|
|
632
744
|
});
|
|
633
745
|
z.object({
|
|
746
|
+
id: PageIdSchema.optional(),
|
|
634
747
|
name: z.string().min(1, "Page name is required"),
|
|
635
748
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
636
749
|
primaryEntity: z.string().min(1, "Primary entity is required"),
|
|
@@ -638,6 +751,7 @@ z.object({
|
|
|
638
751
|
title: z.string().optional()
|
|
639
752
|
}).strict();
|
|
640
753
|
var OrbitalPageSchema = z.object({
|
|
754
|
+
id: PageIdSchema.optional(),
|
|
641
755
|
name: z.string().min(1, "Page name is required"),
|
|
642
756
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
643
757
|
viewType: ViewTypeSchema.optional(),
|
|
@@ -1153,11 +1267,14 @@ var PageRefStringSchema = z.string().regex(
|
|
|
1153
1267
|
);
|
|
1154
1268
|
var PageRefObjectSchema = z.object({
|
|
1155
1269
|
ref: PageRefStringSchema,
|
|
1270
|
+
refId: PageIdSchema.optional(),
|
|
1156
1271
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
1157
1272
|
from: z.string().optional(),
|
|
1158
1273
|
path: z.string().startsWith("/").optional(),
|
|
1159
1274
|
linkedEntity: z.string().optional(),
|
|
1160
|
-
|
|
1275
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
1276
|
+
traits: z.array(TraitRefSchema).optional(),
|
|
1277
|
+
traitRefIds: z.array(TraitIdSchema).optional()
|
|
1161
1278
|
});
|
|
1162
1279
|
var PageRefSchema = z.union([
|
|
1163
1280
|
PageSchema,
|
|
@@ -1193,6 +1310,7 @@ var ComputedEventListenerSchema = z.object({
|
|
|
1193
1310
|
payloadMapping: z.record(z.string()).optional()
|
|
1194
1311
|
});
|
|
1195
1312
|
var OrbitalDefinitionSchema = z.object({
|
|
1313
|
+
id: OrbitalIdSchema.optional(),
|
|
1196
1314
|
name: z.string().min(1, "Orbital name is required"),
|
|
1197
1315
|
description: z.string().optional(),
|
|
1198
1316
|
visual_prompt: z.string().optional(),
|
|
@@ -1253,7 +1371,12 @@ z.object({
|
|
|
1253
1371
|
orbitals: z.array(OrbitalSchema).min(1, "At least one orbital is required"),
|
|
1254
1372
|
services: z.array(ServiceDefinitionSchema).optional(),
|
|
1255
1373
|
config: OrbitalConfigSchema.optional(),
|
|
1256
|
-
_metadata: SchemaMetadataSchema.optional()
|
|
1374
|
+
_metadata: SchemaMetadataSchema.optional(),
|
|
1375
|
+
// V4 identity — optional/dual-carry until the Phase-7 flip. Present on
|
|
1376
|
+
// id-carrying `.orb` files so `parseOrbitalSchema` preserves them instead
|
|
1377
|
+
// of stripping unknown keys.
|
|
1378
|
+
schemaVersion: z.number().optional(),
|
|
1379
|
+
ledger: IdentityLedgerSchema.optional()
|
|
1257
1380
|
});
|
|
1258
1381
|
z.string().refine(
|
|
1259
1382
|
(val) => {
|
|
@@ -1370,6 +1493,7 @@ function makeTraitRef(opts) {
|
|
|
1370
1493
|
if (opts.from !== void 0) ref2.from = opts.from;
|
|
1371
1494
|
if (opts.name !== void 0) ref2.name = opts.name;
|
|
1372
1495
|
if (opts.linkedEntity !== void 0) ref2.linkedEntity = opts.linkedEntity;
|
|
1496
|
+
if (opts.linkedEntityId !== void 0) ref2.linkedEntityId = opts.linkedEntityId;
|
|
1373
1497
|
if (opts.events !== void 0) ref2.events = opts.events;
|
|
1374
1498
|
if (opts.fields !== void 0) ref2.fields = opts.fields;
|
|
1375
1499
|
if (opts.effects !== void 0) ref2.effects = opts.effects;
|
|
@@ -1656,32 +1780,17 @@ function rewriteEntityInInlineTrait(trait, oldName, newName) {
|
|
|
1656
1780
|
}
|
|
1657
1781
|
return next;
|
|
1658
1782
|
}
|
|
1659
|
-
function rebuildTraits(
|
|
1783
|
+
function rebuildTraits(traits) {
|
|
1660
1784
|
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);
|
|
1785
|
+
if (!isTraitReferenceObject(t)) return t;
|
|
1786
|
+
return makeTraitRef({ ...t });
|
|
1671
1787
|
});
|
|
1672
1788
|
}
|
|
1673
|
-
function rebuildPages(
|
|
1789
|
+
function rebuildPages(pages) {
|
|
1674
1790
|
if (!pages) return [];
|
|
1675
1791
|
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);
|
|
1792
|
+
if (!isPageRefObject(p)) return p;
|
|
1793
|
+
return makePageRef({ ...p });
|
|
1685
1794
|
});
|
|
1686
1795
|
}
|
|
1687
1796
|
function mergeCallSiteConfigOverrides(base, overrides) {
|
|
@@ -1699,85 +1808,81 @@ function mergeCallSiteConfigOverrides(base, overrides) {
|
|
|
1699
1808
|
}
|
|
1700
1809
|
return next;
|
|
1701
1810
|
}
|
|
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;
|
|
1811
|
+
function applyDeclarationTraitRenames(schema, renames, at) {
|
|
1812
|
+
if (renames.size === 0) return schema;
|
|
1813
|
+
const renamedTraitIds = [];
|
|
1814
|
+
const renameDeclaration = (t) => {
|
|
1815
|
+
if (typeof t !== "object" || t === null) return t;
|
|
1816
|
+
const named = t;
|
|
1817
|
+
if (typeof named.name !== "string") return t;
|
|
1818
|
+
const renamed = renames.get(named.name);
|
|
1819
|
+
if (renamed === void 0) return t;
|
|
1820
|
+
const id = t.id;
|
|
1821
|
+
if (typeof id === "string") renamedTraitIds.push({ id, to: renamed });
|
|
1822
|
+
return { ...t, name: renamed };
|
|
1719
1823
|
};
|
|
1720
|
-
const
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1824
|
+
const orbitals = schema.orbitals.map((orbital) => {
|
|
1825
|
+
if (!("traits" in orbital) || !Array.isArray(orbital.traits)) return orbital;
|
|
1826
|
+
return { ...orbital, traits: orbital.traits.map(renameDeclaration) };
|
|
1827
|
+
});
|
|
1828
|
+
let ledger = schema.ledger;
|
|
1829
|
+
if (ledger !== void 0) {
|
|
1830
|
+
for (const { id, to } of renamedTraitIds) {
|
|
1831
|
+
ledger = ledgerRename(ledger, id, to, at);
|
|
1723
1832
|
}
|
|
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;
|
|
1833
|
+
}
|
|
1834
|
+
return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
|
|
1835
|
+
}
|
|
1836
|
+
function applyDeclarationEntityRename(schema, rename, at) {
|
|
1837
|
+
if (rename.from === rename.to) return schema;
|
|
1838
|
+
const linkedEntityIsFrom = (shape) => shape.linkedEntity === rename.from;
|
|
1839
|
+
const renamedEntityIds = [];
|
|
1840
|
+
const orbitals = schema.orbitals.map((orbital) => {
|
|
1841
|
+
const entity = orbital.entity;
|
|
1842
|
+
if (typeof entity !== "object" || entity === null || entity.name !== rename.from) {
|
|
1843
|
+
return orbital;
|
|
1739
1844
|
}
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1845
|
+
const entityId = entity.id;
|
|
1846
|
+
if (typeof entityId === "string") renamedEntityIds.push(entityId);
|
|
1847
|
+
const traits = orbital.traits.map(
|
|
1848
|
+
(t) => typeof t === "object" && t !== null && linkedEntityIsFrom(t) ? { ...t, linkedEntity: rename.to } : t
|
|
1849
|
+
);
|
|
1850
|
+
const pages = orbital.pages?.map(
|
|
1851
|
+
(p) => typeof p === "object" && p !== null && linkedEntityIsFrom(p) ? { ...p, linkedEntity: rename.to } : p
|
|
1852
|
+
);
|
|
1853
|
+
return {
|
|
1854
|
+
...orbital,
|
|
1855
|
+
entity: { ...entity, name: rename.to },
|
|
1856
|
+
traits,
|
|
1857
|
+
...pages !== void 0 ? { pages } : {}
|
|
1858
|
+
};
|
|
1742
1859
|
});
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
return renamed !== void 0 ? { ...entry, ref: renamed } : entry;
|
|
1860
|
+
let ledger = schema.ledger;
|
|
1861
|
+
if (ledger !== void 0) {
|
|
1862
|
+
for (const id of renamedEntityIds) {
|
|
1863
|
+
ledger = ledgerRename(ledger, id, rename.to, at);
|
|
1748
1864
|
}
|
|
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 };
|
|
1865
|
+
}
|
|
1866
|
+
return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
|
|
1757
1867
|
}
|
|
1758
1868
|
function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
1759
1869
|
const orbital = findOrbitalOrThrow(orb, orbitalName);
|
|
1760
1870
|
const canonicalEntity = assertResolvedEntity(orbital.entity, orbitalName, orb.name);
|
|
1761
1871
|
const canonicalEntityName = canonicalEntity.name;
|
|
1762
|
-
const effectiveEntityName = params.entityName ?? canonicalEntityName;
|
|
1763
1872
|
const effectiveCollection = typeof canonicalEntity.collection === "string" ? params.collection ?? (params.entityName ? `${params.entityName.toLowerCase()}s` : canonicalEntity.collection) : params.collection;
|
|
1764
|
-
const ctx = {
|
|
1873
|
+
const ctx = { canonicalEntity };
|
|
1765
1874
|
const built = makeOrbitalWithUses({
|
|
1766
1875
|
name: orbital.name,
|
|
1767
1876
|
uses: orbital.uses ?? [],
|
|
1768
|
-
entity: buildEntity(ctx,
|
|
1769
|
-
traits: rebuildTraits(
|
|
1770
|
-
pages: rebuildPages(
|
|
1877
|
+
entity: buildEntity(ctx, canonicalEntityName, effectiveCollection, params),
|
|
1878
|
+
traits: rebuildTraits(orbital.traits),
|
|
1879
|
+
pages: rebuildPages(orbital.pages)
|
|
1771
1880
|
});
|
|
1772
|
-
const traitRenames = /* @__PURE__ */ new Map();
|
|
1773
1881
|
if (built.traits && params.traitOverrides !== void 0) {
|
|
1774
1882
|
built.traits = built.traits.map((t) => {
|
|
1775
1883
|
if (!isTraitReferenceObject(t) || typeof t.name !== "string") return t;
|
|
1776
1884
|
const override = params.traitOverrides?.[t.name];
|
|
1777
1885
|
if (!override) return t;
|
|
1778
|
-
if (override.name !== void 0 && override.name !== t.name) {
|
|
1779
|
-
traitRenames.set(t.name, override.name);
|
|
1780
|
-
}
|
|
1781
1886
|
const merged = { ...t };
|
|
1782
1887
|
if (override.config !== void 0) {
|
|
1783
1888
|
merged.config = mergeCallSiteConfigOverrides(t.config ?? {}, override.config);
|
|
@@ -1798,7 +1903,6 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
1798
1903
|
}
|
|
1799
1904
|
merged.events = { ...t.events ?? {}, ...override.events };
|
|
1800
1905
|
}
|
|
1801
|
-
if (override.name !== void 0) merged.name = override.name;
|
|
1802
1906
|
if (override.emitsScope !== void 0) merged.emitsScope = override.emitsScope;
|
|
1803
1907
|
if (override.listens !== void 0) merged.listens = override.listens;
|
|
1804
1908
|
return merged;
|
|
@@ -1810,7 +1914,7 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
1810
1914
|
return { ...p, path: params.pagePath };
|
|
1811
1915
|
});
|
|
1812
1916
|
}
|
|
1813
|
-
return
|
|
1917
|
+
return built;
|
|
1814
1918
|
}
|
|
1815
1919
|
|
|
1816
1920
|
// src/factory-runtime/apply-params-to-whole-orb.ts
|
|
@@ -1831,6 +1935,6 @@ function applyParamsToWholeOrb(orb, manifests, params) {
|
|
|
1831
1935
|
return { ...orb, orbitals: rebuilt };
|
|
1832
1936
|
}
|
|
1833
1937
|
|
|
1834
|
-
export { applyParamsToOrb, applyParamsToWholeOrb,
|
|
1938
|
+
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
|
|
1835
1939
|
//# sourceMappingURL=index.js.map
|
|
1836
1940
|
//# sourceMappingURL=index.js.map
|