@almadar/core 7.19.1 → 7.20.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/domain-language/index.d.ts +251 -2
- package/dist/domain-language/index.js +381 -16
- package/dist/domain-language/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +381 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a6 as EntityField, a9 as EntityPersistence, cX as TraitReference, c$ as TraitScope, a2 as Entity, br as Page, bh as OrbitalSchema, cE as Trait } from '../schema-WX5fN1Ra.js';
|
|
2
2
|
import { S as SExpr } from '../expression-BVRFm0sV.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@almadar/patterns';
|
|
@@ -321,6 +321,151 @@ interface FactorySignatureCatalog {
|
|
|
321
321
|
/** Sorted list of factory signatures. */
|
|
322
322
|
signatures: ReadonlyArray<FactorySignature>;
|
|
323
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* A single factory invocation, as the typed result of the translator.
|
|
326
|
+
* Lower into runtime by calling the factory at `factoryPath` with
|
|
327
|
+
* these `params`. Stable identity for downstream diffing is
|
|
328
|
+
* `(organism, orbital)`.
|
|
329
|
+
*/
|
|
330
|
+
interface FactoryCallSite {
|
|
331
|
+
/** Matches `FactorySignature.organism`. */
|
|
332
|
+
organism: string;
|
|
333
|
+
/** Matches `FactorySignature.orbital`. */
|
|
334
|
+
orbital: string;
|
|
335
|
+
/** Matches `FactorySignature.factoryPath`. Convenience pointer; the
|
|
336
|
+
* authoritative source remains the signature catalog. */
|
|
337
|
+
factoryPath: string;
|
|
338
|
+
/** Typed param surface fed to the factory at invocation time. */
|
|
339
|
+
params: FactoryCallSiteParams;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* The typed param surface every factory's call site populates. Each
|
|
343
|
+
* field on this interface corresponds to one row in the translator's
|
|
344
|
+
* domain↔factory mapping table. Adding a new domain concept means
|
|
345
|
+
* adding a field here AND wiring it in `translateDomainToParams`.
|
|
346
|
+
*
|
|
347
|
+
* Fields are all optional because not every factory consumes every
|
|
348
|
+
* concept; the translator only sets what the chosen signature
|
|
349
|
+
* advertises.
|
|
350
|
+
*/
|
|
351
|
+
interface FactoryCallSiteParams {
|
|
352
|
+
/** Override `signature.entities[0].name` (entity rename). */
|
|
353
|
+
entityName?: string;
|
|
354
|
+
/** Additional or overriding entity fields. Caller wins on collision. */
|
|
355
|
+
entityFields?: ReadonlyArray<EntityField>;
|
|
356
|
+
/** Override `signature.entities[0].persistence`. */
|
|
357
|
+
persistence?: EntityPersistence;
|
|
358
|
+
/** Per-page path overrides keyed by `signature.pages[i].name`. */
|
|
359
|
+
pagePaths?: Readonly<Record<string, string>>;
|
|
360
|
+
/** Trait config overrides keyed by `signature.traits[i].name`. Each
|
|
361
|
+
* value is a record keyed by the trait's `overridableConfigKeys`. */
|
|
362
|
+
traitOverrides?: Readonly<Record<string, {
|
|
363
|
+
config?: Readonly<Record<string, FactoryParamValue>>;
|
|
364
|
+
}>>;
|
|
365
|
+
/** Extra traits to compose into the orbital that aren't part of the
|
|
366
|
+
* canonical signature trait stack. Used when a domain behavior
|
|
367
|
+
* isn't covered by any canonical trait. */
|
|
368
|
+
extraTraits?: ReadonlyArray<TraitReference>;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Allowed leaf values for the typed factory-param surface. Same as
|
|
372
|
+
* `DomainFieldDefault` minus null, plus arrays + records to mirror
|
|
373
|
+
* the trait-config shape factories accept today.
|
|
374
|
+
*/
|
|
375
|
+
type FactoryParamValue = string | number | boolean | ReadonlyArray<FactoryParamValue> | {
|
|
376
|
+
readonly [key: string]: FactoryParamValue;
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* Discriminated union of edits to a `DomainDocument`. Each variant
|
|
380
|
+
* carries typed AST nodes already defined in this file — never raw
|
|
381
|
+
* JSON. `applyMutation` is total over this union.
|
|
382
|
+
*/
|
|
383
|
+
type DomainMutation = {
|
|
384
|
+
kind: 'add-entity';
|
|
385
|
+
entity: DomainEntity;
|
|
386
|
+
} | {
|
|
387
|
+
kind: 'remove-entity';
|
|
388
|
+
entityName: string;
|
|
389
|
+
} | {
|
|
390
|
+
kind: 'rename-entity';
|
|
391
|
+
from: string;
|
|
392
|
+
to: string;
|
|
393
|
+
} | {
|
|
394
|
+
kind: 'update-entity';
|
|
395
|
+
entityName: string;
|
|
396
|
+
entity: DomainEntity;
|
|
397
|
+
} | {
|
|
398
|
+
kind: 'add-field';
|
|
399
|
+
entityName: string;
|
|
400
|
+
field: DomainField;
|
|
401
|
+
} | {
|
|
402
|
+
kind: 'remove-field';
|
|
403
|
+
entityName: string;
|
|
404
|
+
fieldName: string;
|
|
405
|
+
} | {
|
|
406
|
+
kind: 'update-field';
|
|
407
|
+
entityName: string;
|
|
408
|
+
field: DomainField;
|
|
409
|
+
} | {
|
|
410
|
+
kind: 'add-page';
|
|
411
|
+
page: DomainPage;
|
|
412
|
+
} | {
|
|
413
|
+
kind: 'remove-page';
|
|
414
|
+
pageName: string;
|
|
415
|
+
} | {
|
|
416
|
+
kind: 'update-page';
|
|
417
|
+
pageName: string;
|
|
418
|
+
page: DomainPage;
|
|
419
|
+
} | {
|
|
420
|
+
kind: 'add-behavior';
|
|
421
|
+
behavior: DomainBehavior;
|
|
422
|
+
} | {
|
|
423
|
+
kind: 'remove-behavior';
|
|
424
|
+
behaviorName: string;
|
|
425
|
+
} | {
|
|
426
|
+
kind: 'update-behavior';
|
|
427
|
+
behaviorName: string;
|
|
428
|
+
behavior: DomainBehavior;
|
|
429
|
+
} | {
|
|
430
|
+
kind: 'add-transition';
|
|
431
|
+
behaviorName: string;
|
|
432
|
+
transition: DomainTransition;
|
|
433
|
+
} | {
|
|
434
|
+
kind: 'remove-transition';
|
|
435
|
+
behaviorName: string;
|
|
436
|
+
from: string;
|
|
437
|
+
to: string;
|
|
438
|
+
event: string;
|
|
439
|
+
} | {
|
|
440
|
+
kind: 'add-relationship';
|
|
441
|
+
entityName: string;
|
|
442
|
+
relationship: DomainRelationship;
|
|
443
|
+
} | {
|
|
444
|
+
kind: 'remove-relationship';
|
|
445
|
+
entityName: string;
|
|
446
|
+
targetEntity: string;
|
|
447
|
+
relationshipType: RelationshipType;
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* Cross-cutting presentation knobs that don't live in `DomainDocument`
|
|
451
|
+
* because they're factory-layer concerns (nav items live on a layout
|
|
452
|
+
* trait; theme is a separate `ThemeRef`). The translator reads these
|
|
453
|
+
* and threads them into the matching factory params.
|
|
454
|
+
*/
|
|
455
|
+
interface PresentationOverlay {
|
|
456
|
+
/** Nav items to add to the orbital's layout trait. The translator
|
|
457
|
+
* looks for a `signature.traits[i]` with `overridableConfigKeys`
|
|
458
|
+
* including `navItems` and writes into `traitOverrides[name].config.navItems`. */
|
|
459
|
+
navAdditions?: ReadonlyArray<PresentationNavItem>;
|
|
460
|
+
/** Optional theme ref override for the orbital. */
|
|
461
|
+
themeRef?: string;
|
|
462
|
+
}
|
|
463
|
+
interface PresentationNavItem {
|
|
464
|
+
label: string;
|
|
465
|
+
path: string;
|
|
466
|
+
/** Optional icon key (consumer-resolved). */
|
|
467
|
+
icon?: string;
|
|
468
|
+
}
|
|
324
469
|
|
|
325
470
|
/**
|
|
326
471
|
* Domain Language Tokens
|
|
@@ -802,6 +947,88 @@ declare function applySectionUpdate(schema: OrbitalSchema, sectionType: 'entity'
|
|
|
802
947
|
*/
|
|
803
948
|
declare function deleteSection(schema: OrbitalSchema, sectionType: 'entity' | 'page' | 'behavior' | 'tick', sectionId: string): OrbitalSchema;
|
|
804
949
|
|
|
950
|
+
/**
|
|
951
|
+
* Deterministic translator: one `DomainDocument` slice + one chosen
|
|
952
|
+
* `FactorySignature` → one `FactoryCallSite`. The agent picks the
|
|
953
|
+
* signature upstream via embedding-search over the catalog; this
|
|
954
|
+
* function does ZERO matching. It just lowers domain fields onto the
|
|
955
|
+
* factory's advertised param surface, field-by-field.
|
|
956
|
+
*
|
|
957
|
+
* The binding (which `DomainEntity` / `DomainPage[]` map to this
|
|
958
|
+
* orbital) is the agent's explicit decision and is passed in. No name
|
|
959
|
+
* matching, no scoring, no tie-breaks.
|
|
960
|
+
*
|
|
961
|
+
* Adding a new domain concept means:
|
|
962
|
+
* 1. Add a field on `DomainEntity` / `DomainPage` / `DomainBehavior`
|
|
963
|
+
* (`packages/almadar-core/src/domain-language/types.ts`).
|
|
964
|
+
* 2. Make sure at least one factory signature advertises a
|
|
965
|
+
* consuming knob (Phase 1.5 gate — generated by
|
|
966
|
+
* almadar-pattern-sync from `.orb`).
|
|
967
|
+
* 3. Add one helper-fn row below that lowers the new field into
|
|
968
|
+
* `FactoryCallSiteParams`.
|
|
969
|
+
*
|
|
970
|
+
* If a binding field has no signature consumer, the translator emits
|
|
971
|
+
* a typed warning and SKIPS the field — that's the loud signal the
|
|
972
|
+
* field shouldn't have been admitted to the language.
|
|
973
|
+
*/
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* The slice of `DomainDocument` that maps onto the chosen signature.
|
|
977
|
+
* The agent assembles this when it picks the signature: it knows
|
|
978
|
+
* which `DomainEntity` / `DomainPage[]` are this orbital's
|
|
979
|
+
* responsibility.
|
|
980
|
+
*/
|
|
981
|
+
interface TranslationBinding {
|
|
982
|
+
/** The single domain entity this signature's orbital owns. */
|
|
983
|
+
entity: DomainEntity;
|
|
984
|
+
/** Pages from the domain doc that map to this orbital's pages. The
|
|
985
|
+
* translator pairs them with `signature.pages[]` by name. */
|
|
986
|
+
pages?: ReadonlyArray<DomainPage>;
|
|
987
|
+
}
|
|
988
|
+
interface TranslationWarning {
|
|
989
|
+
/** Dotted path of the domain field that couldn't be lowered. */
|
|
990
|
+
field: string;
|
|
991
|
+
/** Human-readable reason. */
|
|
992
|
+
reason: string;
|
|
993
|
+
}
|
|
994
|
+
interface TranslationResult {
|
|
995
|
+
callSite: FactoryCallSite;
|
|
996
|
+
warnings: ReadonlyArray<TranslationWarning>;
|
|
997
|
+
}
|
|
998
|
+
declare function translateDomainToParams(binding: TranslationBinding, signature: FactorySignature, presentation?: PresentationOverlay): TranslationResult;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Structural diff between two `FactoryCallSite[]` lists. Pure typed,
|
|
1002
|
+
* no side effects. Used by downstream consumers (agent planner, UI
|
|
1003
|
+
* cascade view) to turn a "previous calls" + "next calls" pair into a
|
|
1004
|
+
* minimal change set.
|
|
1005
|
+
*
|
|
1006
|
+
* Identity for diffing is `(organism, orbital)`. Renames are not
|
|
1007
|
+
* handled here — they show up as a delete + add. The agent layer is
|
|
1008
|
+
* expected to merge those back into a `'rename'` op if it can prove
|
|
1009
|
+
* the underlying domain entity was renamed.
|
|
1010
|
+
*/
|
|
1011
|
+
|
|
1012
|
+
type CallSiteDiff = {
|
|
1013
|
+
kind: 'add';
|
|
1014
|
+
orbitalName: string;
|
|
1015
|
+
next: FactoryCallSite;
|
|
1016
|
+
} | {
|
|
1017
|
+
kind: 'delete';
|
|
1018
|
+
orbitalName: string;
|
|
1019
|
+
prior: FactoryCallSite;
|
|
1020
|
+
} | {
|
|
1021
|
+
kind: 'edit';
|
|
1022
|
+
orbitalName: string;
|
|
1023
|
+
prior: FactoryCallSite;
|
|
1024
|
+
next: FactoryCallSite;
|
|
1025
|
+
} | {
|
|
1026
|
+
kind: 'keep';
|
|
1027
|
+
orbitalName: string;
|
|
1028
|
+
call: FactoryCallSite;
|
|
1029
|
+
};
|
|
1030
|
+
declare function diffFactoryCalls(prior: ReadonlyArray<FactoryCallSite>, next: ReadonlyArray<FactoryCallSite>): ReadonlyArray<CallSiteDiff>;
|
|
1031
|
+
|
|
805
1032
|
/**
|
|
806
1033
|
* Section Mapping
|
|
807
1034
|
*
|
|
@@ -1074,4 +1301,26 @@ declare function getRegistryStats(): {
|
|
|
1074
1301
|
*/
|
|
1075
1302
|
declare function generateDomainLanguageReference(): string;
|
|
1076
1303
|
|
|
1077
|
-
|
|
1304
|
+
/**
|
|
1305
|
+
* Pure reducer for `DomainMutation` over `DomainDocument`.
|
|
1306
|
+
*
|
|
1307
|
+
* No I/O. No randomness. Returns a new typed `DomainDocument`
|
|
1308
|
+
* (immutable update) so callers can preserve prior state for
|
|
1309
|
+
* cross-turn stability. One total switch over the discriminated
|
|
1310
|
+
* union — the compiler enforces exhaustiveness via the `never`
|
|
1311
|
+
* default branch.
|
|
1312
|
+
*
|
|
1313
|
+
* Companion to `translateDomainToParams`: the UI/agent emits typed
|
|
1314
|
+
* `DomainMutation[]`, the reducer applies them, the translator
|
|
1315
|
+
* lowers the result onto factory call sites.
|
|
1316
|
+
*/
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Apply one mutation to the document. The original is not modified.
|
|
1320
|
+
* Mutations targeting missing entities/pages/behaviors/fields are
|
|
1321
|
+
* silently no-ops — callers that care should validate via
|
|
1322
|
+
* `findEntity`-style helpers before applying.
|
|
1323
|
+
*/
|
|
1324
|
+
declare function applyMutation(doc: DomainDocument, mut: DomainMutation): DomainDocument;
|
|
1325
|
+
|
|
1326
|
+
export { type ASTNode, type CallSiteDiff, type ComparisonCondition, type ComparisonOperator, type DomainBehavior, type DomainChunk, type DomainDocument, type DomainEffect, type DomainEntity, type DomainField, type DomainFieldDefault, type DomainFieldItems, type DomainFieldType, type DomainGuard, type DomainMutation, type DomainPage, type DomainPageAction, type DomainPageSection, type DomainRelationship, type DomainTick, type DomainToSchemaResult, type DomainTransition, EFFECT_REGISTRY, type EffectMapping, type EffectType, EntityPersistence, FIELD_TYPE_REGISTRY, type FactoryCallSite, type FactoryCallSiteParams, type FactoryEntitySignature, type FactoryPageSignature, type FactoryParamValue, type FactorySignature, type FactorySignatureCatalog, type FactorySignatureEntityField, type FactoryTraitSignature, type FieldCheckCondition, type FieldReference, type FieldTypeMapping, GUARD_REGISTRY, type GuardCondition, type GuardMapping, KEYWORDS, Lexer, type LogicalCondition, type LogicalOperator, MULTI_WORD_KEYWORDS, type MappingStore, type MergeResult, type ParseError, type ParseResult, type PresentationNavItem, type PresentationOverlay, type RelationshipType, type SchemaFieldType, type SchemaToDomainResult, type SectionMapping, type SourceLocation, type SourceRange, type Token, TokenType, TraitScope, type TranslationBinding, type TranslationResult, type TranslationWarning, type UserCheckCondition, applyMutation, applySectionUpdate, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createMappingStore, deleteSection, detectChanges, diffFactoryCalls, domainKeywordToSchemaType, findMapping, findMappingByPath, findMappingsByType, formatBehaviorToDomain, formatBehaviorToSchema, formatDomainGuardToSchema, formatEntityToDomain, formatEntityToSchema, formatGuardConditionToDomain, formatGuardToDomain, formatGuardToSchema, formatMergeSummary, formatPageToDomain, formatPageToSchema, formatSchemaEntityToDomain, formatSchemaGuardToDomain, formatSchemaPageToDomain, formatSchemaTraitToDomain, generateDomainLanguageReference, generateSectionId, getEffectMapping, getFieldTypeMapping, getGuardMapping, getRegisteredEffects, getRegisteredFieldTypes, getRegisteredGuards, getRegistryStats, getSchemaPath, hasSchemaChanged, isEffectRegistered, isFieldTypeRegistered, isGuardRegistered, mergeDomainChunks, parseBehavior, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseGuard, parsePage, parseSectionId, removeMapping, resolveConflict, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, tokenize, translateDomainToParams, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };
|
|
@@ -6397,6 +6397,251 @@ function parseEffectFromText(text) {
|
|
|
6397
6397
|
}
|
|
6398
6398
|
}
|
|
6399
6399
|
|
|
6400
|
+
// src/domain-language/types.ts
|
|
6401
|
+
var DOMAIN_TO_SCHEMA_FIELD_TYPE = {
|
|
6402
|
+
"text": "string",
|
|
6403
|
+
"long text": "string",
|
|
6404
|
+
"number": "number",
|
|
6405
|
+
"currency": "number",
|
|
6406
|
+
"yes/no": "boolean",
|
|
6407
|
+
"date": "date",
|
|
6408
|
+
"timestamp": "timestamp",
|
|
6409
|
+
"datetime": "datetime",
|
|
6410
|
+
"list": "array",
|
|
6411
|
+
"object": "object",
|
|
6412
|
+
"enum": "enum",
|
|
6413
|
+
"relation": "relation"
|
|
6414
|
+
};
|
|
6415
|
+
var UI_SLOTS2 = [
|
|
6416
|
+
"main",
|
|
6417
|
+
"sidebar",
|
|
6418
|
+
"modal",
|
|
6419
|
+
"drawer",
|
|
6420
|
+
"overlay",
|
|
6421
|
+
"center",
|
|
6422
|
+
"toast",
|
|
6423
|
+
"hud-top",
|
|
6424
|
+
"hud-bottom",
|
|
6425
|
+
"floating",
|
|
6426
|
+
"system"
|
|
6427
|
+
];
|
|
6428
|
+
|
|
6429
|
+
// src/domain-language/sync/translate-domain-to-params.ts
|
|
6430
|
+
function translateDomainToParams(binding, signature, presentation) {
|
|
6431
|
+
const warnings = [];
|
|
6432
|
+
const params = {};
|
|
6433
|
+
applyEntityName(binding.entity, signature, params);
|
|
6434
|
+
applyEntityFields(binding.entity, signature, params, warnings);
|
|
6435
|
+
applyPersistence(binding.entity, signature, params, warnings);
|
|
6436
|
+
applyPagePaths(binding.pages ?? [], signature, params, warnings);
|
|
6437
|
+
applyPresentation(presentation, signature, params, warnings);
|
|
6438
|
+
return {
|
|
6439
|
+
callSite: {
|
|
6440
|
+
organism: signature.organism,
|
|
6441
|
+
orbital: signature.orbital,
|
|
6442
|
+
factoryPath: signature.factoryPath,
|
|
6443
|
+
params
|
|
6444
|
+
},
|
|
6445
|
+
warnings
|
|
6446
|
+
};
|
|
6447
|
+
}
|
|
6448
|
+
function applyEntityName(entity, signature, params) {
|
|
6449
|
+
if (signature.entities.length === 0) return;
|
|
6450
|
+
if (entity.name === signature.entities[0].name) return;
|
|
6451
|
+
params.entityName = entity.name;
|
|
6452
|
+
}
|
|
6453
|
+
function applyEntityFields(entity, signature, params, warnings) {
|
|
6454
|
+
if (signature.entities.length === 0) {
|
|
6455
|
+
if (entity.fields.length > 0) {
|
|
6456
|
+
warnings.push({
|
|
6457
|
+
field: `entity.${entity.name}.fields`,
|
|
6458
|
+
reason: "factory signature does not advertise an entity surface"
|
|
6459
|
+
});
|
|
6460
|
+
}
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6463
|
+
const canonical = new Set(signature.entities[0].fields.map((f) => f.name));
|
|
6464
|
+
const extras = [];
|
|
6465
|
+
for (const f of entity.fields) {
|
|
6466
|
+
if (canonical.has(f.name)) continue;
|
|
6467
|
+
const lowered = lowerField(f);
|
|
6468
|
+
if (lowered) extras.push(lowered);
|
|
6469
|
+
}
|
|
6470
|
+
if (extras.length > 0) params.entityFields = extras;
|
|
6471
|
+
}
|
|
6472
|
+
function applyPersistence(entity, signature, params, warnings) {
|
|
6473
|
+
if (!entity.persistence) return;
|
|
6474
|
+
if (signature.entities.length === 0) {
|
|
6475
|
+
warnings.push({
|
|
6476
|
+
field: `entity.${entity.name}.persistence`,
|
|
6477
|
+
reason: "factory signature has no entity to apply persistence to"
|
|
6478
|
+
});
|
|
6479
|
+
return;
|
|
6480
|
+
}
|
|
6481
|
+
if (entity.persistence === signature.entities[0].persistence) return;
|
|
6482
|
+
params.persistence = entity.persistence;
|
|
6483
|
+
}
|
|
6484
|
+
function applyPagePaths(pages, signature, params, warnings) {
|
|
6485
|
+
if (pages.length === 0) return;
|
|
6486
|
+
const sigPages = new Map(signature.pages.map((p) => [p.name, p]));
|
|
6487
|
+
const overrides = {};
|
|
6488
|
+
for (const p of pages) {
|
|
6489
|
+
const sig = sigPages.get(p.name);
|
|
6490
|
+
if (!sig) {
|
|
6491
|
+
warnings.push({
|
|
6492
|
+
field: `page.${p.name}.url`,
|
|
6493
|
+
reason: `factory signature has no page named "${p.name}"`
|
|
6494
|
+
});
|
|
6495
|
+
continue;
|
|
6496
|
+
}
|
|
6497
|
+
if (sig.defaultPath !== p.url) overrides[p.name] = p.url;
|
|
6498
|
+
}
|
|
6499
|
+
if (Object.keys(overrides).length > 0) params.pagePaths = overrides;
|
|
6500
|
+
}
|
|
6501
|
+
function applyPresentation(overlay, signature, params, warnings) {
|
|
6502
|
+
if (!overlay?.navAdditions || overlay.navAdditions.length === 0) return;
|
|
6503
|
+
const target = signature.traits.find(
|
|
6504
|
+
(t) => t.overridableConfigKeys.includes("navItems")
|
|
6505
|
+
);
|
|
6506
|
+
if (!target) {
|
|
6507
|
+
warnings.push({
|
|
6508
|
+
field: "presentation.navAdditions",
|
|
6509
|
+
reason: "factory signature has no trait advertising a `navItems` config key"
|
|
6510
|
+
});
|
|
6511
|
+
return;
|
|
6512
|
+
}
|
|
6513
|
+
const existing = params.traitOverrides?.[target.name] ?? {};
|
|
6514
|
+
const existingConfig = existing.config ?? {};
|
|
6515
|
+
const items = overlay.navAdditions.map(
|
|
6516
|
+
navItemToParamValue
|
|
6517
|
+
);
|
|
6518
|
+
params.traitOverrides = {
|
|
6519
|
+
...params.traitOverrides,
|
|
6520
|
+
[target.name]: {
|
|
6521
|
+
...existing,
|
|
6522
|
+
config: { ...existingConfig, navItems: items }
|
|
6523
|
+
}
|
|
6524
|
+
};
|
|
6525
|
+
}
|
|
6526
|
+
function lowerField(f) {
|
|
6527
|
+
const schemaType = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.fieldType];
|
|
6528
|
+
if (!schemaType) return void 0;
|
|
6529
|
+
const out = {
|
|
6530
|
+
name: f.name,
|
|
6531
|
+
type: schemaType
|
|
6532
|
+
};
|
|
6533
|
+
if (f.required === true) out.required = true;
|
|
6534
|
+
if (f.enumValues && f.enumValues.length > 0) out.values = [...f.enumValues];
|
|
6535
|
+
if (f.default !== void 0) out.default = lowerDefault(f.default);
|
|
6536
|
+
if (f.items) {
|
|
6537
|
+
const itemSchema = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.items.type];
|
|
6538
|
+
if (itemSchema) out.items = { type: itemSchema };
|
|
6539
|
+
}
|
|
6540
|
+
return out;
|
|
6541
|
+
}
|
|
6542
|
+
function lowerDefault(d) {
|
|
6543
|
+
if (d === void 0 || d === null) return d;
|
|
6544
|
+
if (typeof d === "string" || typeof d === "number" || typeof d === "boolean") {
|
|
6545
|
+
return d;
|
|
6546
|
+
}
|
|
6547
|
+
if (Array.isArray(d)) {
|
|
6548
|
+
return d.map(lowerDefault);
|
|
6549
|
+
}
|
|
6550
|
+
if (typeof d === "object") {
|
|
6551
|
+
const out = {};
|
|
6552
|
+
for (const [k, v] of Object.entries(d)) out[k] = lowerDefault(v);
|
|
6553
|
+
return out;
|
|
6554
|
+
}
|
|
6555
|
+
return void 0;
|
|
6556
|
+
}
|
|
6557
|
+
function navItemToParamValue(item) {
|
|
6558
|
+
const out = {
|
|
6559
|
+
label: item.label,
|
|
6560
|
+
path: item.path
|
|
6561
|
+
};
|
|
6562
|
+
if (item.icon) out.icon = item.icon;
|
|
6563
|
+
return out;
|
|
6564
|
+
}
|
|
6565
|
+
|
|
6566
|
+
// src/domain-language/sync/diff-factory-calls.ts
|
|
6567
|
+
function diffFactoryCalls(prior, next) {
|
|
6568
|
+
const out = [];
|
|
6569
|
+
const priorByKey = new Map(prior.map((c) => [callKey(c), c]));
|
|
6570
|
+
const nextByKey = new Map(next.map((c) => [callKey(c), c]));
|
|
6571
|
+
for (const [key, p] of priorByKey) {
|
|
6572
|
+
const n = nextByKey.get(key);
|
|
6573
|
+
if (!n) {
|
|
6574
|
+
out.push({ kind: "delete", orbitalName: p.orbital, prior: p });
|
|
6575
|
+
continue;
|
|
6576
|
+
}
|
|
6577
|
+
if (paramsEqual(p.params, n.params)) {
|
|
6578
|
+
out.push({ kind: "keep", orbitalName: p.orbital, call: n });
|
|
6579
|
+
} else {
|
|
6580
|
+
out.push({ kind: "edit", orbitalName: p.orbital, prior: p, next: n });
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6583
|
+
for (const [key, n] of nextByKey) {
|
|
6584
|
+
if (!priorByKey.has(key)) {
|
|
6585
|
+
out.push({ kind: "add", orbitalName: n.orbital, next: n });
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
return out;
|
|
6589
|
+
}
|
|
6590
|
+
function callKey(c) {
|
|
6591
|
+
return `${c.organism}::${c.orbital}`;
|
|
6592
|
+
}
|
|
6593
|
+
function paramsEqual(a, b) {
|
|
6594
|
+
return canonicalParams(a) === canonicalParams(b);
|
|
6595
|
+
}
|
|
6596
|
+
function canonicalParams(p) {
|
|
6597
|
+
const keys = [
|
|
6598
|
+
"entityFields",
|
|
6599
|
+
"entityName",
|
|
6600
|
+
"extraTraits",
|
|
6601
|
+
"pagePaths",
|
|
6602
|
+
"persistence",
|
|
6603
|
+
"traitOverrides"
|
|
6604
|
+
];
|
|
6605
|
+
const parts = [];
|
|
6606
|
+
for (const k of keys) {
|
|
6607
|
+
const v = p[k];
|
|
6608
|
+
if (v === void 0) continue;
|
|
6609
|
+
parts.push(`${k}:${canonicalNode(v)}`);
|
|
6610
|
+
}
|
|
6611
|
+
return `{${parts.join(",")}}`;
|
|
6612
|
+
}
|
|
6613
|
+
function canonicalNode(v) {
|
|
6614
|
+
if (v === void 0) return "u";
|
|
6615
|
+
if (typeof v === "string") return JSON.stringify(v);
|
|
6616
|
+
if (Array.isArray(v)) {
|
|
6617
|
+
return `[${v.map((x) => canonicalParamValue(x)).join(",")}]`;
|
|
6618
|
+
}
|
|
6619
|
+
const keys = Object.keys(v).sort();
|
|
6620
|
+
const parts = [];
|
|
6621
|
+
for (const k of keys) {
|
|
6622
|
+
const child = v[k];
|
|
6623
|
+
parts.push(`${JSON.stringify(k)}:${canonicalParamValue(child)}`);
|
|
6624
|
+
}
|
|
6625
|
+
return `{${parts.join(",")}}`;
|
|
6626
|
+
}
|
|
6627
|
+
function canonicalParamValue(v) {
|
|
6628
|
+
if (v === null || v === void 0) return "u";
|
|
6629
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
6630
|
+
return JSON.stringify(v);
|
|
6631
|
+
}
|
|
6632
|
+
if (Array.isArray(v)) {
|
|
6633
|
+
return `[${v.map(canonicalParamValue).join(",")}]`;
|
|
6634
|
+
}
|
|
6635
|
+
const keys = Object.keys(v).sort();
|
|
6636
|
+
const parts = [];
|
|
6637
|
+
for (const k of keys) {
|
|
6638
|
+
const child = v[k];
|
|
6639
|
+
if (child === void 0) continue;
|
|
6640
|
+
parts.push(`${JSON.stringify(k)}:${canonicalParamValue(child)}`);
|
|
6641
|
+
}
|
|
6642
|
+
return `{${parts.join(",")}}`;
|
|
6643
|
+
}
|
|
6644
|
+
|
|
6400
6645
|
// src/domain-language/sync/section-mapping.ts
|
|
6401
6646
|
function createMappingStore(mappings = []) {
|
|
6402
6647
|
return {
|
|
@@ -6617,21 +6862,6 @@ function formatMergeSummary(result) {
|
|
|
6617
6862
|
return parts.join(", ") || "empty";
|
|
6618
6863
|
}
|
|
6619
6864
|
|
|
6620
|
-
// src/domain-language/types.ts
|
|
6621
|
-
var UI_SLOTS2 = [
|
|
6622
|
-
"main",
|
|
6623
|
-
"sidebar",
|
|
6624
|
-
"modal",
|
|
6625
|
-
"drawer",
|
|
6626
|
-
"overlay",
|
|
6627
|
-
"center",
|
|
6628
|
-
"toast",
|
|
6629
|
-
"hud-top",
|
|
6630
|
-
"hud-bottom",
|
|
6631
|
-
"floating",
|
|
6632
|
-
"system"
|
|
6633
|
-
];
|
|
6634
|
-
|
|
6635
6865
|
// src/domain-language/registry.ts
|
|
6636
6866
|
var FIELD_TYPE_REGISTRY = {
|
|
6637
6867
|
string: {
|
|
@@ -7069,6 +7299,141 @@ function generateDomainLanguageReference() {
|
|
|
7069
7299
|
return lines.join("\n");
|
|
7070
7300
|
}
|
|
7071
7301
|
|
|
7072
|
-
|
|
7302
|
+
// src/domain-language/applyMutation.ts
|
|
7303
|
+
function applyMutation(doc, mut) {
|
|
7304
|
+
switch (mut.kind) {
|
|
7305
|
+
case "add-entity":
|
|
7306
|
+
return { ...doc, entities: [...doc.entities, mut.entity] };
|
|
7307
|
+
case "remove-entity":
|
|
7308
|
+
return {
|
|
7309
|
+
...doc,
|
|
7310
|
+
entities: doc.entities.filter((e) => e.name !== mut.entityName)
|
|
7311
|
+
};
|
|
7312
|
+
case "rename-entity":
|
|
7313
|
+
return {
|
|
7314
|
+
...doc,
|
|
7315
|
+
entities: replaceEntity(doc.entities, mut.from, (e) => ({
|
|
7316
|
+
...e,
|
|
7317
|
+
name: mut.to
|
|
7318
|
+
}))
|
|
7319
|
+
};
|
|
7320
|
+
case "update-entity":
|
|
7321
|
+
return {
|
|
7322
|
+
...doc,
|
|
7323
|
+
entities: replaceEntity(doc.entities, mut.entityName, () => mut.entity)
|
|
7324
|
+
};
|
|
7325
|
+
case "add-field":
|
|
7326
|
+
return {
|
|
7327
|
+
...doc,
|
|
7328
|
+
entities: replaceEntity(doc.entities, mut.entityName, (e) => ({
|
|
7329
|
+
...e,
|
|
7330
|
+
fields: [...e.fields, mut.field]
|
|
7331
|
+
}))
|
|
7332
|
+
};
|
|
7333
|
+
case "remove-field":
|
|
7334
|
+
return {
|
|
7335
|
+
...doc,
|
|
7336
|
+
entities: replaceEntity(doc.entities, mut.entityName, (e) => ({
|
|
7337
|
+
...e,
|
|
7338
|
+
fields: e.fields.filter((f) => f.name !== mut.fieldName)
|
|
7339
|
+
}))
|
|
7340
|
+
};
|
|
7341
|
+
case "update-field":
|
|
7342
|
+
return {
|
|
7343
|
+
...doc,
|
|
7344
|
+
entities: replaceEntity(doc.entities, mut.entityName, (e) => ({
|
|
7345
|
+
...e,
|
|
7346
|
+
fields: replaceField(e.fields, mut.field)
|
|
7347
|
+
}))
|
|
7348
|
+
};
|
|
7349
|
+
case "add-page":
|
|
7350
|
+
return { ...doc, pages: [...doc.pages, mut.page] };
|
|
7351
|
+
case "remove-page":
|
|
7352
|
+
return {
|
|
7353
|
+
...doc,
|
|
7354
|
+
pages: doc.pages.filter((p) => p.name !== mut.pageName)
|
|
7355
|
+
};
|
|
7356
|
+
case "update-page":
|
|
7357
|
+
return {
|
|
7358
|
+
...doc,
|
|
7359
|
+
pages: replacePage(doc.pages, mut.pageName, () => mut.page)
|
|
7360
|
+
};
|
|
7361
|
+
case "add-behavior":
|
|
7362
|
+
return { ...doc, behaviors: [...doc.behaviors, mut.behavior] };
|
|
7363
|
+
case "remove-behavior":
|
|
7364
|
+
return {
|
|
7365
|
+
...doc,
|
|
7366
|
+
behaviors: doc.behaviors.filter((b) => b.name !== mut.behaviorName)
|
|
7367
|
+
};
|
|
7368
|
+
case "update-behavior":
|
|
7369
|
+
return {
|
|
7370
|
+
...doc,
|
|
7371
|
+
behaviors: replaceBehavior(
|
|
7372
|
+
doc.behaviors,
|
|
7373
|
+
mut.behaviorName,
|
|
7374
|
+
() => mut.behavior
|
|
7375
|
+
)
|
|
7376
|
+
};
|
|
7377
|
+
case "add-transition":
|
|
7378
|
+
return {
|
|
7379
|
+
...doc,
|
|
7380
|
+
behaviors: replaceBehavior(doc.behaviors, mut.behaviorName, (b) => ({
|
|
7381
|
+
...b,
|
|
7382
|
+
transitions: [...b.transitions, mut.transition]
|
|
7383
|
+
}))
|
|
7384
|
+
};
|
|
7385
|
+
case "remove-transition":
|
|
7386
|
+
return {
|
|
7387
|
+
...doc,
|
|
7388
|
+
behaviors: replaceBehavior(doc.behaviors, mut.behaviorName, (b) => ({
|
|
7389
|
+
...b,
|
|
7390
|
+
transitions: b.transitions.filter(
|
|
7391
|
+
(t) => !matchesTransition(t, mut.from, mut.to, mut.event)
|
|
7392
|
+
)
|
|
7393
|
+
}))
|
|
7394
|
+
};
|
|
7395
|
+
case "add-relationship":
|
|
7396
|
+
return {
|
|
7397
|
+
...doc,
|
|
7398
|
+
entities: replaceEntity(doc.entities, mut.entityName, (e) => ({
|
|
7399
|
+
...e,
|
|
7400
|
+
relationships: [...e.relationships, mut.relationship]
|
|
7401
|
+
}))
|
|
7402
|
+
};
|
|
7403
|
+
case "remove-relationship":
|
|
7404
|
+
return {
|
|
7405
|
+
...doc,
|
|
7406
|
+
entities: replaceEntity(doc.entities, mut.entityName, (e) => ({
|
|
7407
|
+
...e,
|
|
7408
|
+
relationships: e.relationships.filter(
|
|
7409
|
+
(r) => !matchesRelationship(r, mut.targetEntity, mut.relationshipType)
|
|
7410
|
+
)
|
|
7411
|
+
}))
|
|
7412
|
+
};
|
|
7413
|
+
default: {
|
|
7414
|
+
return doc;
|
|
7415
|
+
}
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7418
|
+
function replaceEntity(entities, name, update) {
|
|
7419
|
+
return entities.map((e) => e.name === name ? update(e) : e);
|
|
7420
|
+
}
|
|
7421
|
+
function replaceField(fields, next) {
|
|
7422
|
+
return fields.map((f) => f.name === next.name ? next : f);
|
|
7423
|
+
}
|
|
7424
|
+
function replacePage(pages, name, update) {
|
|
7425
|
+
return pages.map((p) => p.name === name ? update(p) : p);
|
|
7426
|
+
}
|
|
7427
|
+
function replaceBehavior(behaviors, name, update) {
|
|
7428
|
+
return behaviors.map((b) => b.name === name ? update(b) : b);
|
|
7429
|
+
}
|
|
7430
|
+
function matchesTransition(t, from, to, event) {
|
|
7431
|
+
return t.fromState === from && t.toState === to && t.event === event;
|
|
7432
|
+
}
|
|
7433
|
+
function matchesRelationship(r, targetEntity, relationshipType) {
|
|
7434
|
+
return r.targetEntity === targetEntity && r.relationshipType === relationshipType;
|
|
7435
|
+
}
|
|
7436
|
+
|
|
7437
|
+
export { EFFECT_REGISTRY, FIELD_TYPE_REGISTRY, GUARD_REGISTRY, KEYWORDS, Lexer, MULTI_WORD_KEYWORDS, TokenType, applyMutation, applySectionUpdate, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createMappingStore, deleteSection, detectChanges, diffFactoryCalls, domainKeywordToSchemaType, findMapping, findMappingByPath, findMappingsByType, formatBehaviorToDomain, formatBehaviorToSchema, formatDomainGuardToSchema, formatEntityToDomain, formatEntityToSchema, formatGuardConditionToDomain, formatGuardToDomain, formatGuardToSchema, formatMergeSummary, formatPageToDomain, formatPageToSchema, formatSchemaEntityToDomain, formatSchemaGuardToDomain, formatSchemaPageToDomain, formatSchemaTraitToDomain, generateDomainLanguageReference, generateSectionId, getEffectMapping, getFieldTypeMapping, getGuardMapping, getRegisteredEffects, getRegisteredFieldTypes, getRegisteredGuards, getRegistryStats, getSchemaPath, hasSchemaChanged, isEffectRegistered, isFieldTypeRegistered, isGuardRegistered, mergeDomainChunks, parseBehavior, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseGuard, parsePage, parseSectionId, removeMapping, resolveConflict, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, tokenize, translateDomainToParams, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };
|
|
7073
7438
|
//# sourceMappingURL=index.js.map
|
|
7074
7439
|
//# sourceMappingURL=index.js.map
|