@almadar/core 10.28.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-BN3WLFYM.d.ts → builders-C458pIMW.d.ts} +2188 -2525
- package/dist/builders.d.ts +4 -4
- package/dist/builders.js +174 -18
- package/dist/builders.js.map +1 -1
- package/dist/{expression-C6X4A8L7.d.ts → expression-CB9R3KWk.d.ts} +4 -1
- package/dist/factory/index.d.ts +6 -5
- package/dist/factory-runtime/index.d.ts +66 -5
- package/dist/factory-runtime/index.js +220 -40
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/index.d.ts +52 -11
- package/dist/index.js +1054 -76
- package/dist/index.js.map +1 -1
- package/dist/json-DOTchoRS.d.ts +57 -0
- package/dist/pattern-types-CLcOXOmW.d.ts +4895 -0
- package/dist/patterns/component-mapping.json +1 -1
- package/dist/patterns/event-contracts.json +1 -1
- package/dist/patterns/index.d.ts +1324 -66
- package/dist/patterns/index.js +644 -43
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/patterns-registry.json +602 -38
- package/dist/patterns/registry.json +602 -38
- package/dist/state-machine/index.d.ts +1 -1
- package/dist/{trait-DZkS625T.d.ts → trait-CwWjkU-1.d.ts} +608 -686
- package/dist/types/index.d.ts +58 -23
- package/dist/types/index.js +280 -29
- package/dist/types/index.js.map +1 -1
- package/dist/{types-DFn3sWpV.d.ts → types-yW22YNNt.d.ts} +47 -59
- package/package.json +1 -1
- package/src/types/bindings.ts +8 -2
- package/dist/pattern-types-BeQXwgpZ.d.ts +0 -4584
package/dist/builders.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './pattern-types-
|
|
2
|
-
export { i as ComposeBehaviorsInput, j as ComposeBehaviorsResult, c7 as ComposeConnection, c8 as ComposePage, a6 as EventWiringEntry, aq as LayoutStrategy, c9 as MakeAtomOrbitalOpts, ca as MakeAtomOrbitalTraitOverrides, cb as MakeEntityOpts, cc as MakeLayoutTraitOpts, cd as MakeOrbitalWithUsesOpts, ce as MakePageOpts, cf as MakePageRefOpts, cg as MakePageRefOptsTyped, M as MakeTraitRefOpts, ch as MakeTraitRefOptsTyped, bS as applyEventWiring, ci as applyTraitConfigOverrides, cj as compose, bT as composeBehaviors, ck as connect, bU as detectLayoutStrategy, cl as ensureIdField, cm as extractTrait, cn as makeAtomOrbital, co as makeEntity, cp as makeLayoutTrait, cq as makeOrbital, cr as makeOrbitalWithUses, cs as makePage, ct as makePageRef, cu as makeRenderUI, cv as makeSchema, cw as makeSlot, cx as makeTraitRef, cy as
|
|
3
|
-
import './trait-
|
|
4
|
-
import './expression-
|
|
1
|
+
import './pattern-types-CLcOXOmW.js';
|
|
2
|
+
export { i as ComposeBehaviorsInput, j as ComposeBehaviorsResult, c7 as ComposeConnection, c8 as ComposePage, a6 as EventWiringEntry, aq as LayoutStrategy, c9 as MakeAtomOrbitalOpts, ca as MakeAtomOrbitalTraitOverrides, cb as MakeEntityOpts, cc as MakeLayoutTraitOpts, cd as MakeOrbitalWithUsesOpts, ce as MakePageOpts, cf as MakePageRefOpts, cg as MakePageRefOptsTyped, M as MakeTraitRefOpts, ch as MakeTraitRefOptsTyped, bS as applyEventWiring, ci as applyTraitConfigOverrides, cj as compose, bT as composeBehaviors, ck as connect, bU as detectLayoutStrategy, cl as ensureIdField, cm as extractTrait, cn as makeAtomOrbital, co as makeEntity, cp as makeLayoutTrait, cq as makeOrbital, cr as makeOrbitalWithUses, cs as makePage, ct as makePageRef, cu as makeRenderUI, cv as makeSchema, cw as makeSlot, cx as makeTraitRef, cy as mergeLedgers, cz as mergeOrbitals, cA as pipe, cB as plural, cC as wire } from './builders-C458pIMW.js';
|
|
3
|
+
import './trait-CwWjkU-1.js';
|
|
4
|
+
import './expression-CB9R3KWk.js';
|
|
5
5
|
import 'zod';
|
package/dist/builders.js
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
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
|
+
var OrbitalIdSchema = z.string().refine(isOrbitalId, { message: `Expected an orbital id (prefix "${ID_PREFIXES.orbital}")` });
|
|
47
|
+
var EntityIdSchema = z.string().refine(isEntityId, { message: `Expected an entity id (prefix "${ID_PREFIXES.entity}")` });
|
|
48
|
+
var TraitIdSchema = z.string().refine(isTraitId, { message: `Expected a trait id (prefix "${ID_PREFIXES.trait}")` });
|
|
49
|
+
var EventIdSchema = z.string().refine(isEventId, { message: `Expected an event id (prefix "${ID_PREFIXES.event}")` });
|
|
50
|
+
var PageIdSchema = z.string().refine(isPageId, { message: `Expected a page id (prefix "${ID_PREFIXES.page}")` });
|
|
51
|
+
z.string().refine(isServiceId, { message: `Expected a service id (prefix "${ID_PREFIXES.service}")` });
|
|
52
|
+
z.string().refine(isThemeId, { message: `Expected a theme id (prefix "${ID_PREFIXES.theme}")` });
|
|
53
|
+
z.string().refine(isPaletteEntryId, { message: `Expected a palette-entry id (prefix "${ID_PREFIXES.palette}")` });
|
|
54
|
+
var LedgerKindSchema = z.enum([
|
|
55
|
+
"orbital",
|
|
56
|
+
"entity",
|
|
57
|
+
"trait",
|
|
58
|
+
"event",
|
|
59
|
+
"page",
|
|
60
|
+
"service",
|
|
61
|
+
"theme"
|
|
62
|
+
]);
|
|
63
|
+
var LedgerEntrySchema = z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
kind: LedgerKindSchema,
|
|
66
|
+
bakedName: z.string(),
|
|
67
|
+
curName: z.string(),
|
|
68
|
+
renames: z.array(
|
|
69
|
+
z.object({ from: z.string(), to: z.string(), at: z.string() })
|
|
70
|
+
),
|
|
71
|
+
owner: z.enum(["std", "io", "workspace"]),
|
|
72
|
+
parent: TraitIdSchema.optional()
|
|
73
|
+
});
|
|
74
|
+
z.object({
|
|
75
|
+
schemaVersion: z.literal(1),
|
|
76
|
+
entries: z.record(LedgerEntrySchema)
|
|
77
|
+
});
|
|
4
78
|
z.enum([
|
|
5
79
|
"string",
|
|
6
80
|
"number",
|
|
@@ -25,6 +99,7 @@ var RelationCardinalitySchema = z.enum([
|
|
|
25
99
|
]);
|
|
26
100
|
var RelationConfigSchema = z.object({
|
|
27
101
|
entity: z.string().min(1, "Target entity is required"),
|
|
102
|
+
entityId: EntityIdSchema.optional(),
|
|
28
103
|
field: z.string().optional(),
|
|
29
104
|
cardinality: RelationCardinalitySchema.optional(),
|
|
30
105
|
onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
|
|
@@ -35,6 +110,7 @@ var RelationConfigSchema = z.object({
|
|
|
35
110
|
}).transform((data) => {
|
|
36
111
|
const normalized = {
|
|
37
112
|
entity: data.entity || data.target || "",
|
|
113
|
+
entityId: data.entityId,
|
|
38
114
|
cardinality: data.cardinality || data.type,
|
|
39
115
|
field: data.field,
|
|
40
116
|
onDelete: data.onDelete
|
|
@@ -321,10 +397,12 @@ var StateSchema = z.object({
|
|
|
321
397
|
var PayloadFieldSchema = z.object({
|
|
322
398
|
name: z.string().min(1),
|
|
323
399
|
type: z.string().min(1),
|
|
324
|
-
required: z.boolean().optional()
|
|
400
|
+
required: z.boolean().optional(),
|
|
401
|
+
properties: z.lazy(() => z.array(PayloadFieldSchema)).optional()
|
|
325
402
|
});
|
|
326
403
|
var EventSchema = z.object({
|
|
327
404
|
key: z.string().min(1, "Event key is required"),
|
|
405
|
+
id: EventIdSchema.optional(),
|
|
328
406
|
name: z.string().min(1, "Event name is required"),
|
|
329
407
|
description: z.string().optional(),
|
|
330
408
|
synonyms: z.string().optional(),
|
|
@@ -342,6 +420,7 @@ var TransitionSchema = z.object({
|
|
|
342
420
|
from: z.string().min(1, "Transition source state is required"),
|
|
343
421
|
to: z.string().min(1, "Transition target state is required"),
|
|
344
422
|
event: z.string().min(1, "Transition event is required"),
|
|
423
|
+
eventId: EventIdSchema.optional(),
|
|
345
424
|
guard: ExpressionSchema.nullish(),
|
|
346
425
|
effects: z.array(EffectSchema).optional(),
|
|
347
426
|
description: z.string().nullish()
|
|
@@ -368,14 +447,25 @@ var TraitConfigSchema = z.record(TraitConfigValueSchema);
|
|
|
368
447
|
function isCallSiteConfigDeclaration(entry) {
|
|
369
448
|
return typeof entry === "object" && entry !== null && !Array.isArray(entry) && "type" in entry && typeof entry.type === "string" && "default" in entry;
|
|
370
449
|
}
|
|
450
|
+
var ConfigFieldItemsDeclarationSchema = z.lazy(
|
|
451
|
+
() => z.object({
|
|
452
|
+
type: z.string().optional(),
|
|
453
|
+
properties: z.record(TraitEntityFieldSchema).optional(),
|
|
454
|
+
items: ConfigFieldItemsDeclarationSchema.optional()
|
|
455
|
+
})
|
|
456
|
+
);
|
|
371
457
|
var ConfigFieldDeclarationSchema = z.object({
|
|
372
458
|
type: z.string(),
|
|
373
459
|
default: TraitConfigValueSchema.optional(),
|
|
460
|
+
refId: z.string().optional(),
|
|
461
|
+
required: z.boolean().optional(),
|
|
374
462
|
label: z.string().optional(),
|
|
375
463
|
description: z.string().optional(),
|
|
376
464
|
tier: z.string().optional(),
|
|
377
465
|
values: z.array(z.string()).optional(),
|
|
378
|
-
synonyms: z.string().optional()
|
|
466
|
+
synonyms: z.string().optional(),
|
|
467
|
+
items: ConfigFieldItemsDeclarationSchema.optional(),
|
|
468
|
+
properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
|
|
379
469
|
});
|
|
380
470
|
var DeclaredTraitConfigSchema = z.record(
|
|
381
471
|
ConfigFieldDeclarationSchema
|
|
@@ -412,7 +502,9 @@ var TraitEntityFieldSchema = z.object({
|
|
|
412
502
|
]),
|
|
413
503
|
required: z.boolean().optional(),
|
|
414
504
|
default: z.unknown().optional(),
|
|
415
|
-
values: z.array(z.string()).optional()
|
|
505
|
+
values: z.array(z.string()).optional(),
|
|
506
|
+
items: ConfigFieldItemsDeclarationSchema.optional(),
|
|
507
|
+
properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
|
|
416
508
|
});
|
|
417
509
|
var TraitDataEntitySchema = z.object({
|
|
418
510
|
name: z.string().min(1),
|
|
@@ -431,9 +523,11 @@ var TraitTickSchema = z.object({
|
|
|
431
523
|
interval: z.union([z.literal("frame"), z.number().positive()]),
|
|
432
524
|
appliesTo: z.array(z.string()).optional(),
|
|
433
525
|
pages: z.array(z.string()).optional(),
|
|
526
|
+
pageIds: z.array(PageIdSchema).optional(),
|
|
434
527
|
guard: ExpressionSchema.optional(),
|
|
435
528
|
effects: z.array(EffectSchema).min(1),
|
|
436
|
-
emits: z.array(z.string()).optional()
|
|
529
|
+
emits: z.array(z.string()).optional(),
|
|
530
|
+
emitIds: z.array(EventIdSchema).optional()
|
|
437
531
|
});
|
|
438
532
|
var EventScopeSchema = z.enum(["internal", "external"]);
|
|
439
533
|
var EventPayloadFieldSchema = z.object({
|
|
@@ -451,7 +545,8 @@ var EventPayloadFieldSchema = z.object({
|
|
|
451
545
|
type: z.string().min(1),
|
|
452
546
|
required: z.boolean().optional(),
|
|
453
547
|
description: z.string().optional(),
|
|
454
|
-
entityType: z.string().optional()
|
|
548
|
+
entityType: z.string().optional(),
|
|
549
|
+
properties: z.lazy(() => z.array(EventPayloadFieldSchema)).optional()
|
|
455
550
|
});
|
|
456
551
|
var TraitEventContractSchema = z.object({
|
|
457
552
|
/**
|
|
@@ -459,12 +554,15 @@ var TraitEventContractSchema = z.object({
|
|
|
459
554
|
* starts with a letter, then any letters / digits / underscores. Both
|
|
460
555
|
* UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the
|
|
461
556
|
* post-Phase 2.5 nominal-event type system (events declared via
|
|
462
|
-
* `type X = Event<T>`).
|
|
557
|
+
* `type X = Event<T>`). A pre-resolution `@config.<knob>` reference
|
|
558
|
+
* (Option B) is also legal — inline/resolve substitutes it with the
|
|
559
|
+
* knob's effective literal before codegen/runtime consume it.
|
|
463
560
|
*/
|
|
464
561
|
event: z.string().min(1).regex(
|
|
465
|
-
/^[A-Za-z][A-Za-z0-9_]
|
|
466
|
-
"Event name must start with a letter and contain only letters, digits, and underscores"
|
|
562
|
+
/^([A-Za-z][A-Za-z0-9_]*|@config\.[A-Za-z_][A-Za-z0-9_]*)$/,
|
|
563
|
+
"Event name must start with a letter and contain only letters, digits, and underscores, or be a `@config.<knob>` reference"
|
|
467
564
|
),
|
|
565
|
+
eventId: EventIdSchema.optional(),
|
|
468
566
|
description: z.string().optional(),
|
|
469
567
|
synonyms: z.string().optional(),
|
|
470
568
|
tier: z.string().optional(),
|
|
@@ -473,16 +571,24 @@ var TraitEventContractSchema = z.object({
|
|
|
473
571
|
});
|
|
474
572
|
var ListenSourceSchema = z.union([
|
|
475
573
|
z.object({ kind: z.literal("any") }),
|
|
476
|
-
z.object({
|
|
574
|
+
z.object({
|
|
575
|
+
kind: z.literal("trait"),
|
|
576
|
+
trait: z.string().min(1),
|
|
577
|
+
traitId: TraitIdSchema.optional()
|
|
578
|
+
}),
|
|
477
579
|
z.object({
|
|
478
580
|
kind: z.literal("orbital"),
|
|
479
581
|
orbital: z.string().min(1),
|
|
480
|
-
trait: z.string().min(1)
|
|
582
|
+
trait: z.string().min(1),
|
|
583
|
+
orbitalId: OrbitalIdSchema.optional(),
|
|
584
|
+
traitId: TraitIdSchema.optional()
|
|
481
585
|
})
|
|
482
586
|
]);
|
|
483
587
|
var TraitEventListenerSchema = z.object({
|
|
484
588
|
event: z.string().min(1),
|
|
589
|
+
eventId: EventIdSchema.optional(),
|
|
485
590
|
triggers: z.string().min(1),
|
|
591
|
+
triggersId: EventIdSchema.optional(),
|
|
486
592
|
description: z.string().optional(),
|
|
487
593
|
synonyms: z.string().optional(),
|
|
488
594
|
tier: z.string().optional(),
|
|
@@ -498,14 +604,20 @@ var RequiredFieldSchema = z.object({
|
|
|
498
604
|
});
|
|
499
605
|
z.object({
|
|
500
606
|
ref: z.string().min(1),
|
|
607
|
+
refId: TraitIdSchema.optional(),
|
|
608
|
+
// V4 local declaration id (see the interface doc) — declared so the
|
|
609
|
+
// strip-mode zod gate carries it through instead of dropping it.
|
|
610
|
+
id: TraitIdSchema.optional(),
|
|
501
611
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
502
612
|
from: z.string().optional(),
|
|
503
613
|
linkedEntity: z.string().optional(),
|
|
614
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
504
615
|
name: z.string().optional(),
|
|
505
616
|
events: z.record(
|
|
506
617
|
z.string().min(1, "events key (atom event name) must be non-empty"),
|
|
507
618
|
z.string().min(1, "events value (caller event name) must be non-empty")
|
|
508
619
|
).optional(),
|
|
620
|
+
eventIds: z.record(z.string().min(1), EventIdSchema).optional(),
|
|
509
621
|
fields: z.record(
|
|
510
622
|
z.string().min(1, "fields key (canonical field name) must be non-empty"),
|
|
511
623
|
z.string().min(1, "fields value (consumer field name) must be non-empty")
|
|
@@ -555,6 +667,7 @@ var SourceBehaviorMetadataSchema = z.object({
|
|
|
555
667
|
originalName: z.string().min(1)
|
|
556
668
|
});
|
|
557
669
|
var TraitSchema = z.object({
|
|
670
|
+
id: TraitIdSchema.optional(),
|
|
558
671
|
name: z.string().min(1),
|
|
559
672
|
description: z.string().optional(),
|
|
560
673
|
description_visual_prompt: z.string().optional(),
|
|
@@ -566,6 +679,9 @@ var TraitSchema = z.object({
|
|
|
566
679
|
capabilities: z.array(z.string()).optional(),
|
|
567
680
|
scope: TraitScopeSchema,
|
|
568
681
|
linkedEntity: z.string().optional(),
|
|
682
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
683
|
+
entityRefIds: z.record(z.string().min(1), EntityIdSchema).optional(),
|
|
684
|
+
traitEmbedIds: z.record(z.string().min(1), TraitIdSchema).optional(),
|
|
569
685
|
requiredFields: z.array(RequiredFieldSchema).optional(),
|
|
570
686
|
dataEntities: z.array(TraitDataEntitySchema).optional(),
|
|
571
687
|
stateMachine: StateMachineSchema.optional(),
|
|
@@ -611,10 +727,13 @@ var ViewTypeSchema = z.enum([
|
|
|
611
727
|
]);
|
|
612
728
|
var PageTraitRefSchema = z.object({
|
|
613
729
|
ref: z.string().min(1, "Trait ref is required"),
|
|
730
|
+
refId: TraitIdSchema.optional(),
|
|
614
731
|
linkedEntity: z.string().optional(),
|
|
732
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
615
733
|
config: TraitConfigSchema.optional()
|
|
616
734
|
});
|
|
617
735
|
z.object({
|
|
736
|
+
id: PageIdSchema.optional(),
|
|
618
737
|
name: z.string().min(1, "Page name is required"),
|
|
619
738
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
620
739
|
primaryEntity: z.string().min(1, "Primary entity is required"),
|
|
@@ -622,6 +741,7 @@ z.object({
|
|
|
622
741
|
title: z.string().optional()
|
|
623
742
|
}).strict();
|
|
624
743
|
var OrbitalPageSchema = z.object({
|
|
744
|
+
id: PageIdSchema.optional(),
|
|
625
745
|
name: z.string().min(1, "Page name is required"),
|
|
626
746
|
path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
|
|
627
747
|
viewType: ViewTypeSchema.optional(),
|
|
@@ -1143,11 +1263,14 @@ var PageRefStringSchema = z.string().regex(
|
|
|
1143
1263
|
);
|
|
1144
1264
|
var PageRefObjectSchema = z.object({
|
|
1145
1265
|
ref: PageRefStringSchema,
|
|
1266
|
+
refId: PageIdSchema.optional(),
|
|
1146
1267
|
// Phase 1.2: optional registry path disambiguator, pairs with `ref`.
|
|
1147
1268
|
from: z.string().optional(),
|
|
1148
1269
|
path: z.string().startsWith("/").optional(),
|
|
1149
1270
|
linkedEntity: z.string().optional(),
|
|
1150
|
-
|
|
1271
|
+
linkedEntityId: EntityIdSchema.optional(),
|
|
1272
|
+
traits: z.array(TraitRefSchema).optional(),
|
|
1273
|
+
traitRefIds: z.array(TraitIdSchema).optional()
|
|
1151
1274
|
});
|
|
1152
1275
|
var PageRefSchema = z.union([
|
|
1153
1276
|
PageSchema,
|
|
@@ -1188,6 +1311,7 @@ var ComputedEventListenerSchema = z.object({
|
|
|
1188
1311
|
payloadMapping: z.record(z.string()).optional()
|
|
1189
1312
|
});
|
|
1190
1313
|
z.object({
|
|
1314
|
+
id: OrbitalIdSchema.optional(),
|
|
1191
1315
|
name: z.string().min(1, "Orbital name is required"),
|
|
1192
1316
|
description: z.string().optional(),
|
|
1193
1317
|
visual_prompt: z.string().optional(),
|
|
@@ -1370,13 +1494,40 @@ function applyEventWiring(orbitals, wiring) {
|
|
|
1370
1494
|
}
|
|
1371
1495
|
|
|
1372
1496
|
// src/builders/compose-behaviors.ts
|
|
1497
|
+
function isSchema(input) {
|
|
1498
|
+
return "orbitals" in input && Array.isArray(input.orbitals);
|
|
1499
|
+
}
|
|
1373
1500
|
function asDefinitions(inputs) {
|
|
1374
|
-
return inputs.flatMap(
|
|
1375
|
-
|
|
1376
|
-
|
|
1501
|
+
return inputs.flatMap(
|
|
1502
|
+
(input) => isSchema(input) ? input.orbitals : [input]
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
function mergeLedgers(inputs) {
|
|
1506
|
+
const merged = /* @__PURE__ */ new Map();
|
|
1507
|
+
let sawLedger = false;
|
|
1508
|
+
for (const input of inputs) {
|
|
1509
|
+
if (!isSchema(input) || input.ledger === void 0) continue;
|
|
1510
|
+
sawLedger = true;
|
|
1511
|
+
for (const [id, entry] of Object.entries(input.ledger.entries)) {
|
|
1512
|
+
if (!merged.has(id)) merged.set(id, entry);
|
|
1377
1513
|
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1514
|
+
}
|
|
1515
|
+
if (!sawLedger) return void 0;
|
|
1516
|
+
const entries = {};
|
|
1517
|
+
for (const [id, entry] of [...merged.entries()].sort(
|
|
1518
|
+
([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
1519
|
+
)) {
|
|
1520
|
+
entries[id] = entry;
|
|
1521
|
+
}
|
|
1522
|
+
return { schemaVersion: 1, entries };
|
|
1523
|
+
}
|
|
1524
|
+
function mergeSchemaVersions(inputs) {
|
|
1525
|
+
let max;
|
|
1526
|
+
for (const input of inputs) {
|
|
1527
|
+
if (!isSchema(input) || input.schemaVersion === void 0) continue;
|
|
1528
|
+
max = max === void 0 ? input.schemaVersion : Math.max(max, input.schemaVersion);
|
|
1529
|
+
}
|
|
1530
|
+
return max;
|
|
1380
1531
|
}
|
|
1381
1532
|
function toKebabCase(name) {
|
|
1382
1533
|
return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
@@ -1446,10 +1597,14 @@ function composeBehaviors(input) {
|
|
|
1446
1597
|
pages: page ? [page] : []
|
|
1447
1598
|
};
|
|
1448
1599
|
});
|
|
1600
|
+
const ledger = mergeLedgers(rawInputs);
|
|
1601
|
+
const schemaVersion = mergeSchemaVersions(rawInputs);
|
|
1449
1602
|
const schema = {
|
|
1450
1603
|
name: appName,
|
|
1451
1604
|
version: "1.0.0",
|
|
1452
|
-
orbitals: orbitalsWithPages
|
|
1605
|
+
orbitals: orbitalsWithPages,
|
|
1606
|
+
...schemaVersion !== void 0 ? { schemaVersion } : {},
|
|
1607
|
+
...ledger !== void 0 ? { ledger } : {}
|
|
1453
1608
|
};
|
|
1454
1609
|
return {
|
|
1455
1610
|
schema,
|
|
@@ -1588,6 +1743,7 @@ function makeTraitRef(opts) {
|
|
|
1588
1743
|
if (opts.from !== void 0) ref.from = opts.from;
|
|
1589
1744
|
if (opts.name !== void 0) ref.name = opts.name;
|
|
1590
1745
|
if (opts.linkedEntity !== void 0) ref.linkedEntity = opts.linkedEntity;
|
|
1746
|
+
if (opts.linkedEntityId !== void 0) ref.linkedEntityId = opts.linkedEntityId;
|
|
1591
1747
|
if (opts.events !== void 0) ref.events = opts.events;
|
|
1592
1748
|
if (opts.fields !== void 0) ref.fields = opts.fields;
|
|
1593
1749
|
if (opts.effects !== void 0) ref.effects = opts.effects;
|
|
@@ -1789,6 +1945,6 @@ function pipe(orbitals, events, appName) {
|
|
|
1789
1945
|
};
|
|
1790
1946
|
}
|
|
1791
1947
|
|
|
1792
|
-
export { applyEventWiring, applyTraitConfigOverrides, compose, composeBehaviors, connect, detectLayoutStrategy, ensureIdField, extractTrait, makeAtomOrbital, makeEntity, makeLayoutTrait, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeRenderUI, makeSchema, makeSlot, makeTraitRef, mergeOrbitals, pipe, plural, wire };
|
|
1948
|
+
export { applyEventWiring, applyTraitConfigOverrides, compose, composeBehaviors, connect, detectLayoutStrategy, ensureIdField, extractTrait, makeAtomOrbital, makeEntity, makeLayoutTrait, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeRenderUI, makeSchema, makeSlot, makeTraitRef, mergeLedgers, mergeOrbitals, pipe, plural, wire };
|
|
1793
1949
|
//# sourceMappingURL=builders.js.map
|
|
1794
1950
|
//# sourceMappingURL=builders.js.map
|