@almadar/core 10.55.0 → 10.57.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 +15 -3
- package/dist/builders.js +27 -2
- package/dist/builders.js.map +1 -1
- package/dist/{effect-DxD-XTI8.d.ts → effect-D-_fm4No.d.ts} +35 -6
- package/dist/{entityAccess-JTWGFDja.d.ts → entityAccess-kTNoti84.d.ts} +1 -1
- package/dist/factory/index.d.ts +4 -4
- package/dist/factory-runtime/index.d.ts +68 -15
- package/dist/factory-runtime/index.js +133 -10
- package/dist/factory-runtime/index.js.map +1 -1
- package/dist/index.d.ts +49 -10
- package/dist/index.js +352 -13
- package/dist/index.js.map +1 -1
- package/dist/mock/index.d.ts +4 -4
- package/dist/mock/index.js +1 -0
- 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 +187 -13
- package/dist/patterns/index.js +104 -11
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/integrators-registry.json +22 -1
- package/dist/patterns/patterns-registry.json +75 -8
- package/dist/patterns/registry.json +75 -8
- package/dist/patterns/services-registry.json +21 -0
- package/dist/{schema-0C1bXRFm.d.ts → schema-CrUFqWXN.d.ts} +468 -89
- package/dist/{trait-WnYkvPdZ.d.ts → trait-A4_OlY_l.d.ts} +20 -20
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +26 -3
- package/dist/types/index.js.map +1 -1
- package/dist/{types-C4YztU2N.d.ts → types-AHD31Gn-.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -1117,6 +1117,9 @@ type EntityFieldBase = {
|
|
|
1117
1117
|
name?: string;
|
|
1118
1118
|
/** Whether the field is required */
|
|
1119
1119
|
required?: boolean;
|
|
1120
|
+
/** Primary-key marker. Mirrors Rust's `FieldDefinition.primary_key`
|
|
1121
|
+
* (serde `primaryKey`). */
|
|
1122
|
+
primaryKey?: boolean;
|
|
1120
1123
|
/** Default value — parsed from `.orb`, always JSON-shaped. */
|
|
1121
1124
|
default?: JsonValue;
|
|
1122
1125
|
/** Minimum value (for number) or length (for string) */
|
|
@@ -2427,7 +2430,7 @@ type EntityData = Record<string, EntityRow[]>;
|
|
|
2427
2430
|
*
|
|
2428
2431
|
* DO NOT EDIT MANUALLY — regenerated by almadar-pattern-sync `patterns` command.
|
|
2429
2432
|
*
|
|
2430
|
-
* Generated: 2026-08-
|
|
2433
|
+
* Generated: 2026-08-07T09:57:07.256Z
|
|
2431
2434
|
* Pattern count: 269
|
|
2432
2435
|
*/
|
|
2433
2436
|
|
|
@@ -4035,6 +4038,7 @@ interface PatternPropsMap {
|
|
|
4035
4038
|
className?: string | SExpr;
|
|
4036
4039
|
showLabels?: boolean | string | SExpr;
|
|
4037
4040
|
zoomToFit?: boolean | string | SExpr;
|
|
4041
|
+
layout?: string | SExpr;
|
|
4038
4042
|
};
|
|
4039
4043
|
'grid': {
|
|
4040
4044
|
type: 'grid';
|
|
@@ -5977,12 +5981,35 @@ type CallServiceConfig = {
|
|
|
5977
5981
|
* lets the TS effect type express it.
|
|
5978
5982
|
*/
|
|
5979
5983
|
type RenderBinding = `@${string}`;
|
|
5984
|
+
/**
|
|
5985
|
+
* A binding reference resolving to a {@link UISlot} at inline time — a trait
|
|
5986
|
+
* `config` knob holding the slot name, e.g. `"@config.reviewSlot"`. Mirrors
|
|
5987
|
+
* {@link RenderBinding} for the SLOT position: the compiler's inline phase
|
|
5988
|
+
* substitutes the config value before anything renders, and the Rust
|
|
5989
|
+
* validator accepts the pre-substitution form (worked example:
|
|
5990
|
+
* `std-approval-gate`'s review queue renders into `@config.reviewSlot`).
|
|
5991
|
+
* This variant lets the TS effect type express the template-layer form.
|
|
5992
|
+
*/
|
|
5993
|
+
type SlotBinding = `@config.${string}`;
|
|
5994
|
+
/**
|
|
5995
|
+
* Template-layer pattern node: a render tree whose discriminant and/or props
|
|
5996
|
+
* are still bindings (`type: '@config.viewPattern'`, `title: '@config.title'`)
|
|
5997
|
+
* or loose nested descriptors the compiler's inline phase resolves. The
|
|
5998
|
+
* resolved layer is {@link AnyPatternConfig}; this variant lets generated
|
|
5999
|
+
* behavior descriptors (std-ts) carry the pre-substitution form the Rust
|
|
6000
|
+
* validator accepts (worked example: `std-graphs` renders
|
|
6001
|
+
* `{ type: '@config.viewPattern', chartType: '@config.chartType', … }`).
|
|
6002
|
+
*/
|
|
6003
|
+
type TemplatePatternConfig = {
|
|
6004
|
+
type: PatternType | RenderBinding;
|
|
6005
|
+
} & Record<string, JsonValue>;
|
|
5980
6006
|
/**
|
|
5981
6007
|
* Render UI effect - displays a pattern in a UI slot.
|
|
5982
6008
|
* @example ['render-ui', 'main', { patternType: 'entity-table', columns: ['name'] }]
|
|
5983
6009
|
* @example ['render-ui', 'main', '@config.bodyContent'] // a {@link RenderBinding} target
|
|
6010
|
+
* @example ['render-ui', '@config.reviewSlot', { patternType: 'entity-table' }] // a {@link SlotBinding} slot
|
|
5984
6011
|
*/
|
|
5985
|
-
type RenderUIEffect = ['render-ui', UISlot, AnyPatternConfig] | ['render-ui', UISlot, AnyPatternConfig, ResolvedPatternProps] | ['render-ui', UISlot, RenderBinding] | ['render-ui', UISlot, null];
|
|
6012
|
+
type RenderUIEffect = ['render-ui', UISlot | SlotBinding, AnyPatternConfig] | ['render-ui', UISlot | SlotBinding, AnyPatternConfig, ResolvedPatternProps] | ['render-ui', UISlot | SlotBinding, TemplatePatternConfig] | ['render-ui', UISlot | SlotBinding, RenderBinding] | ['render-ui', UISlot | SlotBinding, null];
|
|
5986
6013
|
/**
|
|
5987
6014
|
* Lambda expression for per-item rendering in data-grid/data-list.
|
|
5988
6015
|
* The compiler generates: {(paramName: Record<string, unknown>) => (<>JSX</>)}
|
|
@@ -6151,10 +6178,12 @@ type FetchOptions = {
|
|
|
6151
6178
|
id?: string;
|
|
6152
6179
|
/** Filter expression (S-expression) */
|
|
6153
6180
|
filter?: SExpr;
|
|
6154
|
-
/** Maximum number of entities to return
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6181
|
+
/** Maximum number of entities to return. The template layer may carry a
|
|
6182
|
+
* binding (`'@config.pageSize'`) or a computed S-expression — the
|
|
6183
|
+
* compiler's inline phase resolves it to a number. */
|
|
6184
|
+
limit?: number | RenderBinding | SExpr[];
|
|
6185
|
+
/** Number of entities to skip — same template-layer forms as `limit`. */
|
|
6186
|
+
offset?: number | RenderBinding | SExpr[];
|
|
6158
6187
|
/** Relations to populate (entity field names) */
|
|
6159
6188
|
include?: string[];
|
|
6160
6189
|
/** Lifecycle events to emit on resolve / reject */
|
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
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-
|
|
3
|
-
import { a as EntityPersistence, E as EntityField } from '../effect-
|
|
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-AHD31Gn-.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-AHD31Gn-.js';
|
|
3
|
+
import { a as EntityPersistence, E as EntityField } from '../effect-D-_fm4No.js';
|
|
4
|
+
import { a as TraitReference } from '../trait-A4_OlY_l.js';
|
|
5
5
|
export { J as JsonValue } from '../expression-Fk8bQWef.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-
|
|
2
|
-
import { h as CallSiteConfig, i as CallSiteConfigEntry, g as Trait } from '../trait-
|
|
3
|
-
import { E as EntityField, a as EntityPersistence } from '../effect-
|
|
1
|
+
import { O as OrbitalSchema, a as OrbitalDefinition } from '../schema-CrUFqWXN.js';
|
|
2
|
+
import { h as CallSiteConfig, i as CallSiteConfigEntry, g as Trait } from '../trait-A4_OlY_l.js';
|
|
3
|
+
import { E as EntityField, a as EntityPersistence } from '../effect-D-_fm4No.js';
|
|
4
4
|
import { MakeTraitRefOpts } from '../builders.js';
|
|
5
5
|
import '../expression-Fk8bQWef.js';
|
|
6
6
|
import 'zod';
|
|
@@ -150,18 +150,39 @@ declare function rewriteEntityInInlineTrait(trait: Trait, oldName: string, newNa
|
|
|
150
150
|
*/
|
|
151
151
|
declare function mergeCallSiteConfigOverrides(base: CallSiteConfig, overrides: CallSiteConfig): Record<string, CallSiteConfigEntry>;
|
|
152
152
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
153
|
+
* Read-only structural view over the JSON lattice the reference-rewrite
|
|
154
|
+
* walker traverses — same trick as `derive-expectations.ts` (`SExpr` and
|
|
155
|
+
* `TraitConfigValue` both assign to it). Exported alongside
|
|
156
|
+
* `rewriteTraitRefsInTree` for the rabit composer's dedupe backstop.
|
|
157
|
+
*/
|
|
158
|
+
type WalkableData = string | number | boolean | null | ReadonlyArray<WalkableData> | {
|
|
159
|
+
readonly [key: string]: WalkableData;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Deep `@trait.<from>` → `@trait.<to>` token rewrite over a JSON tree —
|
|
163
|
+
* config values at any depth, state-machine trees, listen/tick arms. The
|
|
164
|
+
* rename pass (`applyDeclarationTraitRenames`) and the rabit composer's
|
|
165
|
+
* inline-trait dedupe backstop share this one walker so both cover exactly
|
|
166
|
+
* the positions the compiled path's `rewrite_trait_embed_in_sexpr` does.
|
|
167
|
+
*/
|
|
168
|
+
declare function rewriteTraitRefsInTree(node: WalkableData, renames: ReadonlyMap<string, string>): WalkableData;
|
|
169
|
+
/**
|
|
170
|
+
* Apply `traitOverrides.<T>.name` renames to trait DECLARATIONS, AFTER the
|
|
171
|
+
* schema has been stamped (V4-W4 stamp-before-rename).
|
|
155
172
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
173
|
+
* The rename moves the declaration (`traits[].name` for inline traits, the
|
|
174
|
+
* ref object's local `name` for reference traits), the ledger `curName` of
|
|
175
|
+
* each renamed declaration id, AND every name-based reference to the old
|
|
176
|
+
* name: `@trait.<old>` tokens in config values and state-machine/tick effect
|
|
177
|
+
* trees, the `traitEmbedIds` side-map keys that index those tokens, and page
|
|
178
|
+
* trait refs (`pages[].traits[].ref`). The dual-carry ids (`refId`,
|
|
179
|
+
* `traitEmbedIds` values) are untouched, so the compiled path's
|
|
180
|
+
* `identity_normalize` pass observes tokens already equal to the id-resolved
|
|
181
|
+
* current name and no-ops, while the JS runtime — which resolves `@trait.X`
|
|
182
|
+
* config knobs (e.g. `DashboardLayout.config.tile2Trait`) and page refs BY
|
|
183
|
+
* NAME — never sees a dangling reference (FIX-H, dashboard-edit-title-string
|
|
184
|
+
* 2026-08-06: the declaration-only rename left `@trait.DefaultRevenueChart`
|
|
185
|
+
* in a sibling's config and the page ref while validate stayed green).
|
|
165
186
|
*
|
|
166
187
|
* The keys are canonical names because stamping ran while the declaration
|
|
167
188
|
* still carried its canonical name (the factory no longer renames — see
|
|
@@ -210,6 +231,38 @@ declare function applyDeclarationEntityRename(schema: OrbitalSchema, rename: Ent
|
|
|
210
231
|
* declaration disagrees with `curName` → `ORB_ID_NAME_MISMATCH`.
|
|
211
232
|
*/
|
|
212
233
|
at: string): OrbitalSchema;
|
|
234
|
+
/**
|
|
235
|
+
* Ledger/declaration agreement heal for the factory build path: every entity
|
|
236
|
+
* declaration carrying an id must find its ledger row naming the SAME name
|
|
237
|
+
* the declaration carries. A re-instantiate adopts the prior `.orb`'s ledger
|
|
238
|
+
* via `orb stamp --prior` — including rename rows an earlier build recorded —
|
|
239
|
+
* while the factory re-emits the entity at its baked/requested name, so a
|
|
240
|
+
* stale `curName` would survive a corrective rebuild unchanged and
|
|
241
|
+
* manufacture an `ORB_ID_NAME_MISMATCH` no repair pass can edit away
|
|
242
|
+
* (battery 2026-08-06 domain-rule: param-fill renamed MarketplaceUserOrbital's
|
|
243
|
+
* entity to `Product`; the corrective re-instantiate at `entityName:
|
|
244
|
+
* "MarketplaceUser"` applies NO rename — from === to — and the adopted row
|
|
245
|
+
* kept `curName: "Product"` against a `MarketplaceUser` declaration).
|
|
246
|
+
*
|
|
247
|
+
* Sound on this path only: the factory always re-emits the declaration at the
|
|
248
|
+
* requested/baked name, so the declaration is the build's truth and the
|
|
249
|
+
* adopted row carries identity (the id) forward. No-op when they agree.
|
|
250
|
+
*/
|
|
251
|
+
declare function healEntityLedgerRows(schema: OrbitalSchema, at: string): OrbitalSchema;
|
|
252
|
+
/**
|
|
253
|
+
* Trait-declaration sibling of `healEntityLedgerRows`. A re-instantiate with
|
|
254
|
+
* NO trait renames in its params (a corrective rebuild, or the plan-repair
|
|
255
|
+
* reset-to-factory-defaults verb) adopts the prior `.orb`'s ledger — including
|
|
256
|
+
* trait rename rows an earlier build recorded — while the factory re-emits
|
|
257
|
+
* every trait declaration at its baked/requested name, so the stale `curName`
|
|
258
|
+
* would manufacture an `ORB_ID_NAME_MISMATCH` (the entity twin of this is the
|
|
259
|
+
* battery 2026-08-06 `healEntityLedgerRows` case). Same soundness argument:
|
|
260
|
+
* on this path the factory re-emission is the build's truth and the adopted
|
|
261
|
+
* row carries identity (the id) forward. Reference-form declarations resolve
|
|
262
|
+
* their current name as `name ?? <ref last segment>` (mirrors the compiler's
|
|
263
|
+
* `collect_trait_id_names`). No-op when they agree.
|
|
264
|
+
*/
|
|
265
|
+
declare function healTraitLedgerRows(schema: OrbitalSchema, at: string): OrbitalSchema;
|
|
213
266
|
/**
|
|
214
267
|
* The overlay. Resolves the effective entity name + collection, calls
|
|
215
268
|
* `makeOrbitalWithUses` with the rewritten data, then applies the params'
|
|
@@ -233,4 +286,4 @@ declare function applyParamsToOrb(orb: OrbitalSchema, orbitalName: string, _mani
|
|
|
233
286
|
|
|
234
287
|
declare function applyParamsToWholeOrb(orb: OrbitalSchema, manifests: readonly OrbitalParamsManifest[], params: OrbitalFactoryParams): OrbitalSchema;
|
|
235
288
|
|
|
236
|
-
export { type EntityDeclarationRename, type OrbitalFactoryParams, type OrbitalParamsManifest, type OrbitalTraitOverride, type ParamFieldDescriptor, type ParamValidationError, type ParamValidationResult, applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
|
|
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 };
|
|
@@ -148,6 +148,7 @@ var EntityFieldSchema = z.lazy(() => {
|
|
|
148
148
|
const baseFieldShape = {
|
|
149
149
|
name: z.string().min(1, "Field name is required").optional(),
|
|
150
150
|
required: z.boolean().optional(),
|
|
151
|
+
primaryKey: z.boolean().optional(),
|
|
151
152
|
default: JsonValueSchema.optional(),
|
|
152
153
|
min: z.number().optional(),
|
|
153
154
|
max: z.number().optional(),
|
|
@@ -555,7 +556,10 @@ var TraitEntityFieldSchema = z.object({
|
|
|
555
556
|
"url",
|
|
556
557
|
"phone",
|
|
557
558
|
"uuid",
|
|
558
|
-
"image"
|
|
559
|
+
"image",
|
|
560
|
+
"trait",
|
|
561
|
+
"slot",
|
|
562
|
+
"pattern"
|
|
559
563
|
]),
|
|
560
564
|
required: z.boolean().optional(),
|
|
561
565
|
default: TraitConfigValueSchema.optional(),
|
|
@@ -665,7 +669,7 @@ var TraitEventListenerSchema = z.object({
|
|
|
665
669
|
});
|
|
666
670
|
var RequiredFieldSchema = z.object({
|
|
667
671
|
name: z.string().min(1),
|
|
668
|
-
type: z.enum(["string", "number", "boolean", "date", "array", "object", "timestamp", "datetime", "enum", "email", "url", "phone", "uuid", "image"]),
|
|
672
|
+
type: z.enum(["string", "number", "boolean", "date", "array", "object", "timestamp", "datetime", "enum", "email", "url", "phone", "uuid", "image", "trait", "slot", "pattern"]),
|
|
669
673
|
description: z.string().optional()
|
|
670
674
|
});
|
|
671
675
|
var TraitReferenceSchema = z.object({
|
|
@@ -1284,6 +1288,23 @@ var UseDeclarationSchema = z.object({
|
|
|
1284
1288
|
'Alias must be PascalCase (e.g., "Health", "GameCore")'
|
|
1285
1289
|
)
|
|
1286
1290
|
});
|
|
1291
|
+
var ExpectDeclarationSchema = z.discriminatedUnion("kind", [
|
|
1292
|
+
z.object({
|
|
1293
|
+
kind: z.literal("identity"),
|
|
1294
|
+
name: z.string().optional(),
|
|
1295
|
+
shape: z.array(EntityFieldSchema).optional()
|
|
1296
|
+
}),
|
|
1297
|
+
z.object({
|
|
1298
|
+
kind: z.literal("entity"),
|
|
1299
|
+
name: z.string().min(1, "Expected entity name is required"),
|
|
1300
|
+
shape: z.array(EntityFieldSchema).optional()
|
|
1301
|
+
}),
|
|
1302
|
+
z.object({
|
|
1303
|
+
kind: z.literal("event"),
|
|
1304
|
+
traitName: z.string().min(1, "Expected event trait name is required"),
|
|
1305
|
+
event: z.string().min(1, "Expected event name is required")
|
|
1306
|
+
})
|
|
1307
|
+
]);
|
|
1287
1308
|
var EntityRefStringSchema = z.string().regex(
|
|
1288
1309
|
/^[A-Z][a-zA-Z0-9]*\.entity$/,
|
|
1289
1310
|
'Entity reference must be in format "Alias.entity" (e.g., "Goblin.entity")'
|
|
@@ -1373,6 +1394,8 @@ var OrbitalDefinitionSchema = z.object({
|
|
|
1373
1394
|
visual_prompt: z.string().optional(),
|
|
1374
1395
|
// Import system
|
|
1375
1396
|
uses: z.array(UseDeclarationSchema).optional(),
|
|
1397
|
+
// Consumer-side requirement declarations (`.lolo` `expects ...`)
|
|
1398
|
+
expects: z.array(ExpectDeclarationSchema).optional(),
|
|
1376
1399
|
// Theme & Services
|
|
1377
1400
|
theme: ThemeRefSchema.optional(),
|
|
1378
1401
|
services: z.array(ServiceRefSchema).optional(),
|
|
@@ -1571,7 +1594,9 @@ function makeOrbitalWithUses(opts) {
|
|
|
1571
1594
|
const orbital = {
|
|
1572
1595
|
name: opts.name,
|
|
1573
1596
|
uses: opts.uses,
|
|
1597
|
+
...opts.expects !== void 0 ? { expects: opts.expects } : {},
|
|
1574
1598
|
entity: opts.entity,
|
|
1599
|
+
...opts.auxiliaryEntities !== void 0 ? { auxiliaryEntities: opts.auxiliaryEntities } : {},
|
|
1575
1600
|
traits: opts.traits,
|
|
1576
1601
|
pages: opts.pages ?? []
|
|
1577
1602
|
};
|
|
@@ -1864,22 +1889,83 @@ function mergeCallSiteConfigOverrides(base, overrides) {
|
|
|
1864
1889
|
}
|
|
1865
1890
|
return next;
|
|
1866
1891
|
}
|
|
1892
|
+
function rewriteTraitRefToken(value, renames) {
|
|
1893
|
+
const prefix = "@trait.";
|
|
1894
|
+
if (!value.startsWith(prefix)) return value;
|
|
1895
|
+
const rest = value.slice(prefix.length);
|
|
1896
|
+
const splitAt = rest.search(/[.[]/);
|
|
1897
|
+
const name = splitAt === -1 ? rest : rest.slice(0, splitAt);
|
|
1898
|
+
const to = renames.get(name);
|
|
1899
|
+
if (to === void 0) return value;
|
|
1900
|
+
return `${prefix}${to}${splitAt === -1 ? "" : rest.slice(splitAt)}`;
|
|
1901
|
+
}
|
|
1902
|
+
function rewriteTraitRefsInTree(node, renames) {
|
|
1903
|
+
if (typeof node === "string") return rewriteTraitRefToken(node, renames);
|
|
1904
|
+
if (Array.isArray(node)) return node.map((item) => rewriteTraitRefsInTree(item, renames));
|
|
1905
|
+
if (node !== null && typeof node === "object") {
|
|
1906
|
+
const out = {};
|
|
1907
|
+
for (const [key, value] of Object.entries(node)) out[key] = rewriteTraitRefsInTree(value, renames);
|
|
1908
|
+
return out;
|
|
1909
|
+
}
|
|
1910
|
+
return node;
|
|
1911
|
+
}
|
|
1912
|
+
function rekeyTraitEmbedIds(embedIds, renames) {
|
|
1913
|
+
let out;
|
|
1914
|
+
for (const [token, id] of Object.entries(embedIds)) {
|
|
1915
|
+
const to = renames.get(token);
|
|
1916
|
+
if (to === void 0) continue;
|
|
1917
|
+
out = out ?? { ...embedIds };
|
|
1918
|
+
delete out[token];
|
|
1919
|
+
out[to] = id;
|
|
1920
|
+
}
|
|
1921
|
+
return out ?? embedIds;
|
|
1922
|
+
}
|
|
1867
1923
|
function applyDeclarationTraitRenames(schema, renames, at) {
|
|
1868
1924
|
if (renames.size === 0) return schema;
|
|
1869
1925
|
const renamedTraitIds = [];
|
|
1870
1926
|
const renameDeclaration = (t) => {
|
|
1871
1927
|
if (typeof t !== "object" || t === null) return t;
|
|
1928
|
+
let next = t;
|
|
1872
1929
|
const named = t;
|
|
1873
|
-
if (typeof named.name
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1930
|
+
if (typeof named.name === "string") {
|
|
1931
|
+
const renamed = renames.get(named.name);
|
|
1932
|
+
if (renamed !== void 0) {
|
|
1933
|
+
const id = t.id;
|
|
1934
|
+
if (typeof id === "string") renamedTraitIds.push({ id, to: renamed });
|
|
1935
|
+
next = { ...next, name: renamed };
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
const walked = rewriteTraitRefsInTree(next, renames);
|
|
1939
|
+
const embedIds = walked.traitEmbedIds;
|
|
1940
|
+
if (embedIds !== void 0) {
|
|
1941
|
+
const rekeyed = rekeyTraitEmbedIds(embedIds, renames);
|
|
1942
|
+
if (rekeyed !== embedIds) {
|
|
1943
|
+
walked.traitEmbedIds = rekeyed;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return walked;
|
|
1947
|
+
};
|
|
1948
|
+
const renamePageTraitRefs = (p) => {
|
|
1949
|
+
if (typeof p !== "object" || p === null) return p;
|
|
1950
|
+
const walked = rewriteTraitRefsInTree(p, renames);
|
|
1951
|
+
const traits = walked.traits;
|
|
1952
|
+
if (!Array.isArray(traits)) return walked;
|
|
1953
|
+
return {
|
|
1954
|
+
...walked,
|
|
1955
|
+
traits: traits.map((t) => {
|
|
1956
|
+
if (typeof t === "string") return renames.get(t) ?? t;
|
|
1957
|
+
const to = renames.get(t.ref);
|
|
1958
|
+
return to === void 0 ? t : { ...t, ref: to };
|
|
1959
|
+
})
|
|
1960
|
+
};
|
|
1879
1961
|
};
|
|
1880
1962
|
const orbitals = schema.orbitals.map((orbital) => {
|
|
1881
1963
|
if (!("traits" in orbital) || !Array.isArray(orbital.traits)) return orbital;
|
|
1882
|
-
return {
|
|
1964
|
+
return {
|
|
1965
|
+
...orbital,
|
|
1966
|
+
traits: orbital.traits.map(renameDeclaration),
|
|
1967
|
+
...orbital.pages !== void 0 ? { pages: orbital.pages.map(renamePageTraitRefs) } : {}
|
|
1968
|
+
};
|
|
1883
1969
|
});
|
|
1884
1970
|
let ledger = schema.ledger;
|
|
1885
1971
|
if (ledger !== void 0) {
|
|
@@ -1921,6 +2007,39 @@ function applyDeclarationEntityRename(schema, rename, at) {
|
|
|
1921
2007
|
}
|
|
1922
2008
|
return { ...schema, orbitals, ...ledger !== schema.ledger ? { ledger } : {} };
|
|
1923
2009
|
}
|
|
2010
|
+
function healEntityLedgerRows(schema, at) {
|
|
2011
|
+
let ledger = schema.ledger;
|
|
2012
|
+
if (ledger === void 0) return schema;
|
|
2013
|
+
for (const orbital of schema.orbitals) {
|
|
2014
|
+
const entity = orbital.entity;
|
|
2015
|
+
if (typeof entity !== "object" || entity === null) continue;
|
|
2016
|
+
const id = entity.id;
|
|
2017
|
+
const name = entity.name;
|
|
2018
|
+
if (typeof id !== "string" || typeof name !== "string") continue;
|
|
2019
|
+
const entry = ledger.entries[id];
|
|
2020
|
+
if (entry === void 0 || entry.kind !== "entity" || entry.curName === name) continue;
|
|
2021
|
+
ledger = ledgerRename(ledger, id, name, at);
|
|
2022
|
+
}
|
|
2023
|
+
return ledger !== schema.ledger ? { ...schema, ledger } : schema;
|
|
2024
|
+
}
|
|
2025
|
+
function healTraitLedgerRows(schema, at) {
|
|
2026
|
+
let ledger = schema.ledger;
|
|
2027
|
+
if (ledger === void 0) return schema;
|
|
2028
|
+
for (const orbital of schema.orbitals) {
|
|
2029
|
+
for (const trait of orbital.traits ?? []) {
|
|
2030
|
+
if (typeof trait !== "object" || trait === null) continue;
|
|
2031
|
+
const id = trait.id;
|
|
2032
|
+
if (typeof id !== "string") continue;
|
|
2033
|
+
const declared = trait;
|
|
2034
|
+
const name = typeof declared.name === "string" ? declared.name : typeof declared.ref === "string" ? declared.ref.slice(declared.ref.lastIndexOf(".") + 1) : void 0;
|
|
2035
|
+
if (name === void 0) continue;
|
|
2036
|
+
const entry = ledger.entries[id];
|
|
2037
|
+
if (entry === void 0 || entry.kind !== "trait" || entry.curName === name) continue;
|
|
2038
|
+
ledger = ledgerRename(ledger, id, name, at);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
return ledger !== schema.ledger ? { ...schema, ledger } : schema;
|
|
2042
|
+
}
|
|
1924
2043
|
function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
1925
2044
|
const orbital = findOrbitalOrThrow(orb, orbitalName);
|
|
1926
2045
|
const canonicalEntity = assertResolvedEntity(orbital.entity, orbitalName, orb.name);
|
|
@@ -1930,6 +2049,10 @@ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
|
|
|
1930
2049
|
const built = makeOrbitalWithUses({
|
|
1931
2050
|
name: orbital.name,
|
|
1932
2051
|
uses: orbital.uses ?? [],
|
|
2052
|
+
// Derived `expects` declarations ride the overlay untouched — they name
|
|
2053
|
+
// SIBLING entities (never the orbital's own), so the entityName rename
|
|
2054
|
+
// below cannot affect them.
|
|
2055
|
+
...orbital.expects !== void 0 ? { expects: orbital.expects } : {},
|
|
1933
2056
|
entity: buildEntity(ctx, canonicalEntityName, effectiveCollection, params),
|
|
1934
2057
|
traits: rebuildTraits(orbital.traits),
|
|
1935
2058
|
pages: rebuildPages(orbital.pages)
|
|
@@ -1991,6 +2114,6 @@ function applyParamsToWholeOrb(orb, manifests, params) {
|
|
|
1991
2114
|
return { ...orb, orbitals: rebuilt };
|
|
1992
2115
|
}
|
|
1993
2116
|
|
|
1994
|
-
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
|
|
2117
|
+
export { applyDeclarationEntityRename, applyDeclarationTraitRenames, applyParamsToOrb, applyParamsToWholeOrb, extractManifest, healEntityLedgerRows, healTraitLedgerRows, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, rewriteTraitRefsInTree, validateOrbitalFactoryParams };
|
|
1995
2118
|
//# sourceMappingURL=index.js.map
|
|
1996
2119
|
//# sourceMappingURL=index.js.map
|