@almadar/core 10.86.0 → 10.88.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.d.ts +5 -4
- package/dist/builders.js +70 -29
- package/dist/builders.js.map +1 -1
- package/dist/{effect-BgDiw_bG.d.ts → effect-DMA97JxX.d.ts} +22 -6
- package/dist/{entityAccess-DK5S_2cT.d.ts → entityAccess-B5_Y9zF5.d.ts} +2 -2
- package/dist/{expression-Fk8bQWef.d.ts → expression-WfTp2arD.d.ts} +2 -65
- package/dist/factory/index.d.ts +6 -5
- package/dist/factory/index.js +1194 -401
- package/dist/factory/index.js.map +1 -1
- package/dist/factory-runtime/index.d.ts +35 -5
- package/dist/factory-runtime/index.js +129 -52
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/i18n/index.d.ts +124 -2
- package/dist/i18n/index.js +680 -382
- package/dist/i18n/index.js.map +1 -1
- package/dist/{index-ChYsqVJj.d.ts → index-CYE40P_7.d.ts} +18 -5
- package/dist/index.d.ts +82 -14
- package/dist/index.js +2058 -696
- package/dist/index.js.map +1 -1
- package/dist/json-D8gmyK3l.d.ts +65 -0
- package/dist/mock/index.d.ts +129 -12
- package/dist/mock/index.js +192 -61
- package/dist/mock/index.js.map +1 -1
- package/dist/patterns/component-mapping.json +1 -1
- package/dist/patterns/event-contracts.json +1 -1
- package/dist/patterns/index.d.ts +2525 -609
- package/dist/patterns/index.js +1238 -384
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/integrators-registry.json +107 -23
- package/dist/patterns/patterns-registry.json +1170 -400
- package/dist/patterns/registry.json +1170 -400
- package/dist/patterns/services-registry.json +170 -35
- package/dist/{schema-BhfQb1oe.d.ts → schema-ex9koAoK.d.ts} +46845 -21335
- package/dist/state-machine/index.d.ts +2 -1
- package/dist/trait-BJAX5TJK.d.ts +10683 -0
- package/dist/types/index.d.ts +7 -6
- package/dist/types/index.js +134 -43
- package/dist/types/index.js.map +1 -1
- package/dist/{types-CCAmdxcH.d.ts → types-kHQhEEXQ.d.ts} +19 -3
- package/package.json +4 -3
- package/dist/trait-pavNlGqm.d.ts +0 -5385
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-
|
|
2
|
-
import { i as CallSiteConfig, j as CallSiteConfigEntry, h as Trait } from '../trait-
|
|
3
|
-
import { E as EntityField, a as EntityPersistence } from '../effect-
|
|
1
|
+
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-ex9koAoK.js';
|
|
2
|
+
import { g as TraitConfigValue, i as CallSiteConfig, j as CallSiteConfigEntry, h as Trait } from '../trait-BJAX5TJK.js';
|
|
3
|
+
import { E as EntityField, a as EntityPersistence } from '../effect-DMA97JxX.js';
|
|
4
4
|
import { MakeTraitRefOpts } from '../builders.js';
|
|
5
|
-
import '../
|
|
5
|
+
import '../json-D8gmyK3l.js';
|
|
6
|
+
import '../expression-WfTp2arD.js';
|
|
6
7
|
import 'zod';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -25,6 +26,14 @@ interface OrbitalParamsManifest {
|
|
|
25
26
|
paramFields: readonly ParamFieldDescriptor[];
|
|
26
27
|
traitNames: readonly string[];
|
|
27
28
|
inlineTraitNames: readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* The orbital's own declared config knob names (`Orbital.config`), the
|
|
31
|
+
* `config` param's allow-list. Present only when the orbital declares at
|
|
32
|
+
* least one knob of its own — mirrors `paramFields`' persistence-style
|
|
33
|
+
* gate (see `extractManifest`). Absent means `config` is not a valid
|
|
34
|
+
* top-level param for this orbital at all.
|
|
35
|
+
*/
|
|
36
|
+
configKeys?: readonly string[];
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
/**
|
|
@@ -36,6 +45,13 @@ interface OrbitalParamsManifest {
|
|
|
36
45
|
* @packageDocumentation
|
|
37
46
|
*/
|
|
38
47
|
|
|
48
|
+
/**
|
|
49
|
+
* The param descriptors this orbital actually accepts — the closed L1 delta
|
|
50
|
+
* allow-list, gated per orbital exactly like `persistence`/`collection`
|
|
51
|
+
* (dropped when the entity's persistence mode disallows overrides): `config`
|
|
52
|
+
* is dropped when the orbital declares no config knobs of its own.
|
|
53
|
+
*/
|
|
54
|
+
declare function paramFieldsFor(_orb: OrbitalSchema, orbital: OrbitalSchema['orbitals'][number]): readonly ParamFieldDescriptor[];
|
|
39
55
|
declare function extractManifest(orb: OrbitalSchema): readonly OrbitalParamsManifest[];
|
|
40
56
|
|
|
41
57
|
/**
|
|
@@ -80,6 +96,13 @@ interface OrbitalFactoryParams {
|
|
|
80
96
|
readonly collection?: string;
|
|
81
97
|
/** Per-imported-trait overrides, keyed on the trait's canonical `name`. */
|
|
82
98
|
readonly traitOverrides?: Readonly<Record<string, OrbitalTraitOverride | undefined>>;
|
|
99
|
+
/**
|
|
100
|
+
* Override this orbital's OWN declared config knobs (`Orbital.config`) by
|
|
101
|
+
* key. Only present when the manifest carries `configKeys` (the orbital
|
|
102
|
+
* declares at least one knob of its own); every key must be a member of
|
|
103
|
+
* `configKeys` or validation rejects it.
|
|
104
|
+
*/
|
|
105
|
+
readonly config?: Readonly<Record<string, TraitConfigValue>>;
|
|
83
106
|
}
|
|
84
107
|
/**
|
|
85
108
|
* Discriminated failure shape for params validation against a manifest. Each
|
|
@@ -99,6 +122,13 @@ type ParamValidationError = {
|
|
|
99
122
|
} | {
|
|
100
123
|
readonly kind: 'trait-overrides-not-object';
|
|
101
124
|
readonly received: string;
|
|
125
|
+
} | {
|
|
126
|
+
readonly kind: 'config-not-object';
|
|
127
|
+
readonly received: string;
|
|
128
|
+
} | {
|
|
129
|
+
readonly kind: 'unknown-config-key';
|
|
130
|
+
readonly key: string;
|
|
131
|
+
readonly allowed: readonly string[];
|
|
102
132
|
};
|
|
103
133
|
/** Discriminated result type for validation. Caller never widens. */
|
|
104
134
|
type ParamValidationResult = {
|
|
@@ -286,4 +316,4 @@ declare function applyParamsToOrb(orb: OrbitalSchema, orbitalName: string, _mani
|
|
|
286
316
|
|
|
287
317
|
declare function applyParamsToWholeOrb(orb: OrbitalSchema, manifests: readonly OrbitalParamsManifest[], params: OrbitalFactoryParams): OrbitalSchema;
|
|
288
318
|
|
|
289
|
-
export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, type WalkableData, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, healTraitLedgerRows, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, rewriteTraitRefsInTree, validateOrbitalFactoryParams };
|
|
319
|
+
export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, type WalkableData, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, healTraitLedgerRows, mergeCallSiteConfigOverrides, paramFieldsFor, rebindInlineTraitEntity, rewriteEntityInInlineTrait, rewriteTraitRefsInTree, validateOrbitalFactoryParams };
|
|
@@ -429,6 +429,9 @@ var EntityPersistenceSchema = z.enum([
|
|
|
429
429
|
]);
|
|
430
430
|
var OrbitalEntitySchema = z.object({
|
|
431
431
|
name: z.string().min(1, "Entity name is required"),
|
|
432
|
+
// V4 arena id (`EntityDefinition.id`); declared so the strip-mode zod gate
|
|
433
|
+
// carries an imported entity's id through instead of erasing it.
|
|
434
|
+
id: EntityIdSchema.optional(),
|
|
432
435
|
persistence: EntityPersistenceSchema.default("persistent"),
|
|
433
436
|
shared: z.boolean().optional(),
|
|
434
437
|
// Must stay in step with the Rust serde field (`EntityDefinition.identity`,
|
|
@@ -520,7 +523,8 @@ var PayloadFieldSchema = z.object({
|
|
|
520
523
|
type: z.string().min(1),
|
|
521
524
|
required: z.boolean().optional(),
|
|
522
525
|
properties: z.lazy(() => z.array(PayloadFieldSchema)).optional(),
|
|
523
|
-
typeWhen: z.array(PayloadTypeWhenSchema).optional()
|
|
526
|
+
typeWhen: z.array(PayloadTypeWhenSchema).optional(),
|
|
527
|
+
entity: z.string().min(1).optional()
|
|
524
528
|
});
|
|
525
529
|
var EventSchema = z.object({
|
|
526
530
|
key: z.string().min(1, "Event key is required"),
|
|
@@ -530,6 +534,7 @@ var EventSchema = z.object({
|
|
|
530
534
|
synonyms: z.string().optional(),
|
|
531
535
|
tier: z.string().optional(),
|
|
532
536
|
payloadSchema: z.array(PayloadFieldSchema).optional(),
|
|
537
|
+
payloadEntity: z.string().optional(),
|
|
533
538
|
classification: z.enum(["domain", "system"]).optional(),
|
|
534
539
|
semanticRole: z.string().optional()
|
|
535
540
|
});
|
|
@@ -569,6 +574,19 @@ var TraitConfigSchema = z.record(TraitConfigValueSchema);
|
|
|
569
574
|
function isCallSiteConfigDeclaration(entry) {
|
|
570
575
|
return typeof entry === "object" && entry !== null && !Array.isArray(entry) && "type" in entry && typeof entry.type === "string" && "default" in entry;
|
|
571
576
|
}
|
|
577
|
+
function overrideDeclaredKnobs(declared, overrides) {
|
|
578
|
+
const out = { ...declared };
|
|
579
|
+
for (const key of Object.keys(overrides)) {
|
|
580
|
+
const field = declared[key];
|
|
581
|
+
if (field === void 0) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
`overrideDeclaredKnobs: config override "${key}" is not a declared knob (ORB_O_CONFIG_UNKNOWN_KEY). Declared: ${Object.keys(declared).join(", ") || "(none)"}`
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
out[key] = { ...field, default: overrides[key] };
|
|
587
|
+
}
|
|
588
|
+
return out;
|
|
589
|
+
}
|
|
572
590
|
var ConfigFieldItemsDeclarationSchema = z.lazy(
|
|
573
591
|
() => z.object({
|
|
574
592
|
type: z.string().optional(),
|
|
@@ -588,7 +606,8 @@ var ConfigFieldDeclarationSchema = z.object({
|
|
|
588
606
|
values: z.array(z.string()).optional(),
|
|
589
607
|
synonyms: z.string().optional(),
|
|
590
608
|
items: ConfigFieldItemsDeclarationSchema.optional(),
|
|
591
|
-
properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional()
|
|
609
|
+
properties: z.lazy(() => z.record(TraitEntityFieldSchema)).optional(),
|
|
610
|
+
forwardedFrom: z.string().optional()
|
|
592
611
|
});
|
|
593
612
|
var DeclaredTraitConfigSchema = z.record(
|
|
594
613
|
ConfigFieldDeclarationSchema
|
|
@@ -610,31 +629,32 @@ var TraitCategorySchema = z.enum([
|
|
|
610
629
|
"game-board",
|
|
611
630
|
"game-puzzle"
|
|
612
631
|
]);
|
|
632
|
+
var TRAIT_FIELD_TYPES = [
|
|
633
|
+
"string",
|
|
634
|
+
"number",
|
|
635
|
+
"boolean",
|
|
636
|
+
"date",
|
|
637
|
+
"array",
|
|
638
|
+
"object",
|
|
639
|
+
"timestamp",
|
|
640
|
+
"datetime",
|
|
641
|
+
"enum",
|
|
642
|
+
"email",
|
|
643
|
+
"url",
|
|
644
|
+
"phone",
|
|
645
|
+
"uuid",
|
|
646
|
+
"image",
|
|
647
|
+
"trait",
|
|
648
|
+
"slot",
|
|
649
|
+
"pattern",
|
|
650
|
+
"node",
|
|
651
|
+
"event",
|
|
652
|
+
"scalar",
|
|
653
|
+
"union"
|
|
654
|
+
];
|
|
613
655
|
var TraitEntityFieldSchema = z.object({
|
|
614
656
|
name: z.string().min(1),
|
|
615
|
-
type: z.enum(
|
|
616
|
-
"string",
|
|
617
|
-
"number",
|
|
618
|
-
"boolean",
|
|
619
|
-
"date",
|
|
620
|
-
"array",
|
|
621
|
-
"object",
|
|
622
|
-
"timestamp",
|
|
623
|
-
"datetime",
|
|
624
|
-
"enum",
|
|
625
|
-
"email",
|
|
626
|
-
"url",
|
|
627
|
-
"phone",
|
|
628
|
-
"uuid",
|
|
629
|
-
"image",
|
|
630
|
-
"trait",
|
|
631
|
-
"slot",
|
|
632
|
-
"pattern",
|
|
633
|
-
// `node` was missing here while being a real `TraitFieldType` member
|
|
634
|
-
// — the same latent-drift trap `event` would otherwise repeat.
|
|
635
|
-
"node",
|
|
636
|
-
"event"
|
|
637
|
-
]),
|
|
657
|
+
type: z.enum(TRAIT_FIELD_TYPES),
|
|
638
658
|
required: z.boolean().optional(),
|
|
639
659
|
default: TraitConfigValueSchema.optional(),
|
|
640
660
|
values: z.array(z.string()).optional(),
|
|
@@ -689,7 +709,7 @@ var EventPayloadFieldSchema = z.object({
|
|
|
689
709
|
type: z.string().min(1),
|
|
690
710
|
required: z.boolean().optional(),
|
|
691
711
|
description: z.string().optional(),
|
|
692
|
-
|
|
712
|
+
entity: z.string().optional(),
|
|
693
713
|
properties: z.lazy(() => z.array(EventPayloadFieldSchema)).optional(),
|
|
694
714
|
typeWhen: z.array(PayloadTypeWhenSchema).optional()
|
|
695
715
|
});
|
|
@@ -714,6 +734,7 @@ var TraitEventContractSchema = z.object({
|
|
|
714
734
|
definerKnob: z.string().optional(),
|
|
715
735
|
scopeOverridden: z.boolean().optional(),
|
|
716
736
|
payloadSchema: z.array(EventPayloadFieldSchema).optional(),
|
|
737
|
+
payloadEntity: z.string().optional(),
|
|
717
738
|
scope: EventScopeSchema.optional()
|
|
718
739
|
});
|
|
719
740
|
var ListenSourceSchema = z.union([
|
|
@@ -746,8 +767,7 @@ var TraitEventListenerSchema = z.object({
|
|
|
746
767
|
});
|
|
747
768
|
var RequiredFieldSchema = z.object({
|
|
748
769
|
name: z.string().min(1),
|
|
749
|
-
|
|
750
|
-
type: z.enum(["string", "number", "boolean", "date", "array", "object", "timestamp", "datetime", "enum", "email", "url", "phone", "uuid", "image", "trait", "slot", "pattern", "node", "event"]),
|
|
770
|
+
type: z.enum(TRAIT_FIELD_TYPES),
|
|
751
771
|
description: z.string().optional()
|
|
752
772
|
});
|
|
753
773
|
var TraitReferenceSchema = z.object({
|
|
@@ -766,6 +786,7 @@ var TraitReferenceSchema = z.object({
|
|
|
766
786
|
z.string().min(1, "events value (caller event name) must be non-empty")
|
|
767
787
|
).optional(),
|
|
768
788
|
eventIds: z.record(z.string().min(1), EventIdSchema).optional(),
|
|
789
|
+
_resolved: z.lazy(() => TraitSchema).optional(),
|
|
769
790
|
// 3-II type-parameter arguments (see `TraitReference.typeArgs`).
|
|
770
791
|
typeArgs: z.record(
|
|
771
792
|
z.string().min(1, "typeArgs key (declared param name) must be non-empty"),
|
|
@@ -1384,7 +1405,8 @@ var UseDeclarationSchema = z.object({
|
|
|
1384
1405
|
as: z.string().min(1, "Alias is required").regex(
|
|
1385
1406
|
/^[A-Z][a-zA-Z0-9]*$/,
|
|
1386
1407
|
'Alias must be PascalCase (e.g., "Health", "GameCore")'
|
|
1387
|
-
)
|
|
1408
|
+
),
|
|
1409
|
+
config: DeclaredTraitConfigSchema.optional()
|
|
1388
1410
|
});
|
|
1389
1411
|
var ExpectDeclarationSchema = z.discriminatedUnion("kind", [
|
|
1390
1412
|
z.object({
|
|
@@ -1461,6 +1483,25 @@ var PageRefSchema = z.union([
|
|
|
1461
1483
|
PageRefStringSchema,
|
|
1462
1484
|
PageRefObjectSchema
|
|
1463
1485
|
]);
|
|
1486
|
+
var OrbitalRefStringSchema = z.string().regex(
|
|
1487
|
+
/^[A-Z][a-zA-Z0-9]*\.orbitals\.[A-Z][a-zA-Z0-9]*$/,
|
|
1488
|
+
'Orbital reference must be "Alias.orbitals.OrbitalName"'
|
|
1489
|
+
);
|
|
1490
|
+
var OrbitalRefObjectSchema = z.object({
|
|
1491
|
+
ref: OrbitalRefStringSchema,
|
|
1492
|
+
refId: OrbitalIdSchema.optional(),
|
|
1493
|
+
entity: z.string().optional(),
|
|
1494
|
+
fields: z.record(z.string()).optional(),
|
|
1495
|
+
pages: z.record(z.string()).optional(),
|
|
1496
|
+
omit: z.array(z.string()).optional(),
|
|
1497
|
+
only: z.array(z.string()).optional(),
|
|
1498
|
+
config: DeclaredTraitConfigSchema.optional(),
|
|
1499
|
+
events: z.record(z.string()).optional(),
|
|
1500
|
+
roles: z.record(z.string(), z.array(z.string())).optional(),
|
|
1501
|
+
entities: z.record(z.string(), z.string()).optional(),
|
|
1502
|
+
mounts: z.record(z.string(), z.array(z.string())).optional(),
|
|
1503
|
+
extend: z.array(EntityFieldSchema).optional()
|
|
1504
|
+
});
|
|
1464
1505
|
z.string().regex(
|
|
1465
1506
|
/^([A-Z][a-zA-Z0-9]*\.traits\.)?[A-Z][a-zA-Z0-9]*$/,
|
|
1466
1507
|
'Trait reference must be "TraitName" or "Alias.traits.TraitName"'
|
|
@@ -1503,6 +1544,15 @@ var OrbitalDefinitionSchema = z.object({
|
|
|
1503
1544
|
services: z.array(ServiceRefSchema).optional(),
|
|
1504
1545
|
// Components (inline or reference)
|
|
1505
1546
|
entity: EntityRefSchema,
|
|
1547
|
+
// Mirrors the `OrbitalDefinition.auxiliaryEntities` type field — WAS
|
|
1548
|
+
// undeclared here, so `OrbitalSchemaSchema.safeParse` (every load through
|
|
1549
|
+
// `external-loader.ts`) silently stripped it on every externally-loaded
|
|
1550
|
+
// orbital (zod drops unrecognized keys by default), while a schema parsed
|
|
1551
|
+
// directly via `JSON.parse` kept it. Found via the entity-field auto-merge
|
|
1552
|
+
// rebind-target fallback landing on the wrong entity for any RECURSIVELY
|
|
1553
|
+
// loaded `uses` file (`packages/almadar-runtime/src/resolver/
|
|
1554
|
+
// reference-resolver.ts`'s `mergeImportedEntityFieldsIntoOrbital`).
|
|
1555
|
+
auxiliaryEntities: z.array(EntityRefSchema).optional(),
|
|
1506
1556
|
traits: z.array(TraitRefSchema),
|
|
1507
1557
|
pages: z.array(PageRefSchema),
|
|
1508
1558
|
// Event interface (trait-centric model) - computed by resolver
|
|
@@ -1510,6 +1560,10 @@ var OrbitalDefinitionSchema = z.object({
|
|
|
1510
1560
|
listens: z.array(ComputedEventListenerSchema).optional(),
|
|
1511
1561
|
// Filter for exposed events (trait-centric model)
|
|
1512
1562
|
exposes: z.array(z.string()).optional(),
|
|
1563
|
+
// This orbital's own declared knobs (§4.5)
|
|
1564
|
+
config: DeclaredTraitConfigSchema.optional(),
|
|
1565
|
+
// Transient — set by lowering, cleared by inline/resolve
|
|
1566
|
+
reference: OrbitalRefObjectSchema.optional(),
|
|
1513
1567
|
// Context fields - persisted throughout orbital lifecycle
|
|
1514
1568
|
domainContext: DomainContextSchema.optional(),
|
|
1515
1569
|
design: DesignPreferencesSchema.optional(),
|
|
@@ -1517,18 +1571,6 @@ var OrbitalDefinitionSchema = z.object({
|
|
|
1517
1571
|
types: z.record(z.string(), z.array(EventPayloadFieldSchema)).optional()
|
|
1518
1572
|
});
|
|
1519
1573
|
var OrbitalSchema = OrbitalDefinitionSchema;
|
|
1520
|
-
var OrbitalConfigSchema = z.object({
|
|
1521
|
-
theme: z.object({
|
|
1522
|
-
primary: z.string().optional(),
|
|
1523
|
-
secondary: z.string().optional(),
|
|
1524
|
-
mode: z.enum(["light", "dark", "system"]).optional()
|
|
1525
|
-
}).optional(),
|
|
1526
|
-
features: z.record(z.boolean()).optional(),
|
|
1527
|
-
api: z.object({
|
|
1528
|
-
baseUrl: z.string().optional(),
|
|
1529
|
-
timeout: z.number().optional()
|
|
1530
|
-
}).optional()
|
|
1531
|
-
});
|
|
1532
1574
|
var ConfigProvenanceRecordSchema = z.object({
|
|
1533
1575
|
trait: z.string(),
|
|
1534
1576
|
patternPath: z.string().optional(),
|
|
@@ -1554,7 +1596,7 @@ z.object({
|
|
|
1554
1596
|
customPatterns: CustomPatternMapSchema,
|
|
1555
1597
|
orbitals: z.array(OrbitalSchema).min(1, "At least one orbital is required"),
|
|
1556
1598
|
services: z.array(ServiceDefinitionSchema).optional(),
|
|
1557
|
-
config:
|
|
1599
|
+
config: DeclaredTraitConfigSchema.optional(),
|
|
1558
1600
|
_metadata: SchemaMetadataSchema.optional(),
|
|
1559
1601
|
// V4 identity — optional/dual-carry until the Phase-7 flip. Present on
|
|
1560
1602
|
// id-carrying `.orb` files so `parseOrbitalSchema` preserves them instead
|
|
@@ -1628,6 +1670,11 @@ var STATIC_PARAM_FIELDS = [
|
|
|
1628
1670
|
name: "traitOverrides",
|
|
1629
1671
|
type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
|
|
1630
1672
|
description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
name: "config",
|
|
1676
|
+
type: "Readonly<Record<string, TraitConfigValue>>",
|
|
1677
|
+
description: "Override this orbital's own declared config knobs (Orbital.config) by key."
|
|
1631
1678
|
}
|
|
1632
1679
|
];
|
|
1633
1680
|
function entityPersistence(entity) {
|
|
@@ -1636,11 +1683,21 @@ function entityPersistence(entity) {
|
|
|
1636
1683
|
}
|
|
1637
1684
|
return void 0;
|
|
1638
1685
|
}
|
|
1639
|
-
function
|
|
1640
|
-
if (
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1686
|
+
function declaredConfigKeys(config) {
|
|
1687
|
+
if (config === void 0) return void 0;
|
|
1688
|
+
const keys = Object.keys(config).sort();
|
|
1689
|
+
return keys.length > 0 ? keys : void 0;
|
|
1690
|
+
}
|
|
1691
|
+
function paramFieldsFor(_orb, orbital) {
|
|
1692
|
+
const allowPersistenceOverride = persistenceModeAllowsOverrides(entityPersistence(orbital.entity));
|
|
1693
|
+
const hasConfig = declaredConfigKeys(orbital.config) !== void 0;
|
|
1694
|
+
return STATIC_PARAM_FIELDS.filter((f) => {
|
|
1695
|
+
if ((f.name === "persistence" || f.name === "collection") && !allowPersistenceOverride) {
|
|
1696
|
+
return false;
|
|
1697
|
+
}
|
|
1698
|
+
if (f.name === "config" && !hasConfig) return false;
|
|
1699
|
+
return true;
|
|
1700
|
+
});
|
|
1644
1701
|
}
|
|
1645
1702
|
function splitTraits(traits) {
|
|
1646
1703
|
const refTraitNames = [];
|
|
@@ -1661,12 +1718,14 @@ function extractManifest(orb) {
|
|
|
1661
1718
|
const behaviorName = orb.name;
|
|
1662
1719
|
return orb.orbitals.map((orbital) => {
|
|
1663
1720
|
const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
|
|
1721
|
+
const configKeys = declaredConfigKeys(orbital.config);
|
|
1664
1722
|
return {
|
|
1665
1723
|
organism: behaviorName,
|
|
1666
1724
|
orbitalName: orbital.name,
|
|
1667
|
-
paramFields:
|
|
1725
|
+
paramFields: paramFieldsFor(orb, orbital),
|
|
1668
1726
|
traitNames: refTraitNames,
|
|
1669
|
-
inlineTraitNames
|
|
1727
|
+
inlineTraitNames,
|
|
1728
|
+
...configKeys !== void 0 ? { configKeys } : {}
|
|
1670
1729
|
};
|
|
1671
1730
|
});
|
|
1672
1731
|
}
|
|
@@ -1748,6 +1807,21 @@ function validateOrbitalFactoryParams(manifest, raw) {
|
|
|
1748
1807
|
}
|
|
1749
1808
|
}
|
|
1750
1809
|
}
|
|
1810
|
+
if (candidate.config !== void 0) {
|
|
1811
|
+
const cfg = candidate.config;
|
|
1812
|
+
if (cfg === null || typeof cfg !== "object" || Array.isArray(cfg)) {
|
|
1813
|
+
return {
|
|
1814
|
+
ok: false,
|
|
1815
|
+
error: { kind: "config-not-object", received: Array.isArray(cfg) ? "array" : typeof cfg }
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
const allowedKeys = manifest.configKeys ?? [];
|
|
1819
|
+
for (const key of Object.keys(cfg)) {
|
|
1820
|
+
if (!allowedKeys.includes(key)) {
|
|
1821
|
+
return { ok: false, error: { kind: "unknown-config-key", key, allowed: allowedKeys } };
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1751
1825
|
return { ok: true, params: candidate };
|
|
1752
1826
|
}
|
|
1753
1827
|
function assertResolvedEntity(entity, orbitalName, orbName) {
|
|
@@ -1901,8 +1975,8 @@ function rewriteEventContract(contract, oldName, newName) {
|
|
|
1901
1975
|
...contract,
|
|
1902
1976
|
payloadSchema: contract.payloadSchema.map((f) => {
|
|
1903
1977
|
const next = { ...f, type: rewritePayloadFieldType(f.type, oldName, newName) };
|
|
1904
|
-
if (typeof f.
|
|
1905
|
-
next.
|
|
1978
|
+
if (typeof f.entity === "string" && f.entity === oldName) {
|
|
1979
|
+
next.entity = newName;
|
|
1906
1980
|
}
|
|
1907
1981
|
return next;
|
|
1908
1982
|
})
|
|
@@ -2162,6 +2236,9 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
2162
2236
|
traits: rebuildTraits(orbital.traits),
|
|
2163
2237
|
pages: rebuildPages(orbital.pages)
|
|
2164
2238
|
});
|
|
2239
|
+
if (orbital.config !== void 0) {
|
|
2240
|
+
built.config = params.config !== void 0 ? overrideDeclaredKnobs(orbital.config, params.config) : orbital.config;
|
|
2241
|
+
}
|
|
2165
2242
|
if (built.traits && params.traitOverrides !== void 0) {
|
|
2166
2243
|
built.traits = built.traits.map((t) => {
|
|
2167
2244
|
if (!isTraitReferenceObject(t) || typeof t.name !== "string") return t;
|
|
@@ -2219,6 +2296,6 @@ function applyParamsToWholeOrb(orb, manifests, params) {
|
|
|
2219
2296
|
return { ...orb, orbitals: rebuilt };
|
|
2220
2297
|
}
|
|
2221
2298
|
|
|
2222
|
-
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, healTraitLedgerRows, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, rewriteTraitRefsInTree, validateOrbitalFactoryParams };
|
|
2299
|
+
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, healTraitLedgerRows, mergeCallSiteConfigOverrides, paramFieldsFor, rebindInlineTraitEntity, rewriteEntityInInlineTrait, rewriteTraitRefsInTree, validateOrbitalFactoryParams };
|
|
2223
2300
|
//# sourceMappingURL=index.js.map
|
|
2224
2301
|
//# sourceMappingURL=index.js.map
|