@almadar/core 7.24.0 → 7.26.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.
|
@@ -114,6 +114,14 @@ interface DomainEntity extends ASTNode {
|
|
|
114
114
|
* the entity section.
|
|
115
115
|
*/
|
|
116
116
|
persistence?: EntityPersistence;
|
|
117
|
+
/**
|
|
118
|
+
* Storage collection key. Mirrors `OrbitalSchema.entities[i].collection`.
|
|
119
|
+
* Omitted ⇒ defaults to `plural(name).toLowerCase()`. Surfaced to the
|
|
120
|
+
* factory translator so the LLM can override the storage key without
|
|
121
|
+
* touching the entity name (e.g. entity `Product` → collection
|
|
122
|
+
* `"catalog"`).
|
|
123
|
+
*/
|
|
124
|
+
collection?: string;
|
|
117
125
|
}
|
|
118
126
|
interface DomainPageSection extends ASTNode {
|
|
119
127
|
type: 'page_section';
|
|
@@ -314,6 +322,20 @@ interface FactorySignature {
|
|
|
314
322
|
emittedEvents: ReadonlyArray<string>;
|
|
315
323
|
/** Union of all `traits[].listenedEvents`. */
|
|
316
324
|
listenedEvents: ReadonlyArray<string>;
|
|
325
|
+
/**
|
|
326
|
+
* Phase 5 — canonical starting `DomainDocument` fragment the studio
|
|
327
|
+
* questionnaire renders before any user input. Lifted verbatim from
|
|
328
|
+
* the factory's resolved `.orb` by `almadar-pattern-sync`. Users
|
|
329
|
+
* append / override via `DomainMutation` from the questionnaire UI;
|
|
330
|
+
* the base itself is never edited in place (consumers compose with
|
|
331
|
+
* `mergeDocuments(base, overlay)`).
|
|
332
|
+
*
|
|
333
|
+
* Optional during the 7.26.x transition — older catalog snapshots
|
|
334
|
+
* predating the sync regeneration omit it. Consumers should fall
|
|
335
|
+
* back to building a minimal document from `entities` + `pages`
|
|
336
|
+
* when this is missing.
|
|
337
|
+
*/
|
|
338
|
+
baseDocument?: DomainDocument;
|
|
317
339
|
}
|
|
318
340
|
/**
|
|
319
341
|
* Aggregate catalog written to
|
|
@@ -361,6 +383,10 @@ interface FactoryCallSiteParams {
|
|
|
361
383
|
entityFields?: ReadonlyArray<EntityField>;
|
|
362
384
|
/** Override `signature.entities[0].persistence`. */
|
|
363
385
|
persistence?: EntityPersistence;
|
|
386
|
+
/** Override the entity's storage collection key. Defaults to
|
|
387
|
+
* `plural(entityName).toLowerCase()` at factory dispatch time
|
|
388
|
+
* when omitted. */
|
|
389
|
+
collection?: string;
|
|
364
390
|
/** Per-page path overrides keyed by `signature.pages[i].name`. */
|
|
365
391
|
pagePaths?: Readonly<Record<string, string>>;
|
|
366
392
|
/** Trait config overrides keyed by `signature.traits[i].name`. Each
|
|
@@ -1243,6 +1269,55 @@ declare function validateDomainChunk(chunk: DomainChunk): string[];
|
|
|
1243
1269
|
*/
|
|
1244
1270
|
declare function formatMergeSummary(result: MergeResult): string;
|
|
1245
1271
|
|
|
1272
|
+
/**
|
|
1273
|
+
* Phase 5 — `mergeDocuments(base, overlay)` overlay reducer.
|
|
1274
|
+
*
|
|
1275
|
+
* The studio questionnaire renders `mergeDocuments(factoryBase,
|
|
1276
|
+
* userOverlay)` as its surface — the user edits the overlay; the base
|
|
1277
|
+
* never mutates. Server-side, the planner reads the user's persisted
|
|
1278
|
+
* overlay and merges it on top of the catalog's `baseDocument` to
|
|
1279
|
+
* derive the final `DomainDocument` fed to `translateDomainToParams`.
|
|
1280
|
+
*
|
|
1281
|
+
* Semantics:
|
|
1282
|
+
* - `entities[]`, `pages[]`, `behaviors[]` matched by `name`. The
|
|
1283
|
+
* overlay's entry replaces the base's; missing names from one side
|
|
1284
|
+
* are kept verbatim from the other.
|
|
1285
|
+
* - Within a matched entity / page / behavior, overlay fields win
|
|
1286
|
+
* (overlay-replace, not deep-merge). This means a user clearing
|
|
1287
|
+
* `fields: []` is honoured rather than silently re-inflating from
|
|
1288
|
+
* the base. The questionnaire UI emits partial overlays only for
|
|
1289
|
+
* the slots the user touched, so this is the right granularity.
|
|
1290
|
+
* - Arrays inside matched entries (`entities[i].fields[]`,
|
|
1291
|
+
* `pages[i].sections[]`) are NOT field-level merged — the overlay
|
|
1292
|
+
* replaces the base array verbatim when present. For granular
|
|
1293
|
+
* additions ("add a field"), the UI authors a `DomainMutation`
|
|
1294
|
+
* and applies via `applyMutation` instead of going through
|
|
1295
|
+
* `mergeDocuments`.
|
|
1296
|
+
* - Top-level `type` is always `'document'`.
|
|
1297
|
+
*
|
|
1298
|
+
* Pure function — no I/O, no mutation of inputs. Returns a new
|
|
1299
|
+
* `DomainDocument`.
|
|
1300
|
+
*
|
|
1301
|
+
* @packageDocumentation
|
|
1302
|
+
*/
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Compose a base `DomainDocument` (factory catalog baseline) with a
|
|
1306
|
+
* user-authored overlay (questionnaire answers + edits). Entities,
|
|
1307
|
+
* pages, and behaviors are matched by `name`; the overlay replaces
|
|
1308
|
+
* any base entry with the same name. Unmatched entries on either side
|
|
1309
|
+
* survive unchanged.
|
|
1310
|
+
*
|
|
1311
|
+
* Idempotent: `mergeDocuments(d, emptyDocument)` returns a deep-copy
|
|
1312
|
+
* of `d`. `mergeDocuments(emptyDocument, d)` likewise.
|
|
1313
|
+
*
|
|
1314
|
+
* @param base The starting document (factory `baseDocument` or
|
|
1315
|
+
* organism-level union).
|
|
1316
|
+
* @param overlay The user-authored overlay carrying edits.
|
|
1317
|
+
* @returns A new merged document; neither input is mutated.
|
|
1318
|
+
*/
|
|
1319
|
+
declare function mergeDocuments(base: DomainDocument, overlay: DomainDocument): DomainDocument;
|
|
1320
|
+
|
|
1246
1321
|
/**
|
|
1247
1322
|
* Domain Language Registry
|
|
1248
1323
|
*
|
|
@@ -1396,4 +1471,4 @@ declare function generateDomainLanguageReference(): string;
|
|
|
1396
1471
|
*/
|
|
1397
1472
|
declare function applyMutation(doc: DomainDocument, mut: DomainMutation): DomainDocument;
|
|
1398
1473
|
|
|
1399
|
-
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 DomainRuleOverlayEntry, 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 OwnershipOverlayEntry, type ParseError, type ParseResult, type PresentationNavItem, type PresentationOverlay, type RelationshipType, type RuleOverlay, type SchemaFieldType, type SchemaToDomainResult, type SectionMapping, type SourceLocation, type SourceRange, type Token, TokenType, type TraitOverlay, type TraitOverlayEntry, type TraitOverlayListener, 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 };
|
|
1474
|
+
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 DomainRuleOverlayEntry, 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 OwnershipOverlayEntry, type ParseError, type ParseResult, type PresentationNavItem, type PresentationOverlay, type RelationshipType, type RuleOverlay, type SchemaFieldType, type SchemaToDomainResult, type SectionMapping, type SourceLocation, type SourceRange, type Token, TokenType, type TraitOverlay, type TraitOverlayEntry, type TraitOverlayListener, 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, mergeDocuments, mergeDomainChunks, parseBehavior, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseGuard, parsePage, parseSectionId, removeMapping, resolveConflict, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, tokenize, translateDomainToParams, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };
|
|
@@ -6436,6 +6436,7 @@ function translateDomainToParams(binding, signature, presentation, ruleOverlay,
|
|
|
6436
6436
|
applyEntityName(binding.entity, signature, params);
|
|
6437
6437
|
applyEntityFields(binding.entity, signature, params, warnings);
|
|
6438
6438
|
applyPersistence(binding.entity, signature, params, warnings);
|
|
6439
|
+
applyCollection(binding.entity, params);
|
|
6439
6440
|
applyPagePaths(binding.pages ?? [], signature, params, warnings);
|
|
6440
6441
|
applyPresentation(presentation, signature, params, warnings);
|
|
6441
6442
|
applyTraitOverlay(traitOverlay, signature, params, warnings);
|
|
@@ -6486,6 +6487,10 @@ function applyPersistence(entity, signature, params, warnings) {
|
|
|
6486
6487
|
if (entity.persistence === signature.entities[0].persistence) return;
|
|
6487
6488
|
params.persistence = entity.persistence;
|
|
6488
6489
|
}
|
|
6490
|
+
function applyCollection(entity, params) {
|
|
6491
|
+
if (!entity.collection) return;
|
|
6492
|
+
params.collection = entity.collection;
|
|
6493
|
+
}
|
|
6489
6494
|
function applyPagePaths(pages, signature, params, warnings) {
|
|
6490
6495
|
if (pages.length === 0) return;
|
|
6491
6496
|
const sigPages = new Map(signature.pages.map((p) => [p.name, p]));
|
|
@@ -7026,6 +7031,37 @@ function formatMergeSummary(result) {
|
|
|
7026
7031
|
return parts.join(", ") || "empty";
|
|
7027
7032
|
}
|
|
7028
7033
|
|
|
7034
|
+
// src/domain-language/sync/merge-documents.ts
|
|
7035
|
+
function mergeDocuments(base, overlay) {
|
|
7036
|
+
return {
|
|
7037
|
+
type: "document",
|
|
7038
|
+
entities: mergeByName(base.entities, overlay.entities),
|
|
7039
|
+
pages: mergeByName(base.pages, overlay.pages),
|
|
7040
|
+
behaviors: mergeByName(base.behaviors, overlay.behaviors)
|
|
7041
|
+
};
|
|
7042
|
+
}
|
|
7043
|
+
function mergeByName(baseItems, overlayItems) {
|
|
7044
|
+
const overlayByName = /* @__PURE__ */ new Map();
|
|
7045
|
+
for (const item of overlayItems) overlayByName.set(item.name, item);
|
|
7046
|
+
const result = [];
|
|
7047
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7048
|
+
for (const item of baseItems) {
|
|
7049
|
+
const replacement = overlayByName.get(item.name);
|
|
7050
|
+
if (replacement) {
|
|
7051
|
+
result.push(replacement);
|
|
7052
|
+
} else {
|
|
7053
|
+
result.push(item);
|
|
7054
|
+
}
|
|
7055
|
+
seen.add(item.name);
|
|
7056
|
+
}
|
|
7057
|
+
for (const item of overlayItems) {
|
|
7058
|
+
if (!seen.has(item.name)) {
|
|
7059
|
+
result.push(item);
|
|
7060
|
+
}
|
|
7061
|
+
}
|
|
7062
|
+
return result;
|
|
7063
|
+
}
|
|
7064
|
+
|
|
7029
7065
|
// src/domain-language/registry.ts
|
|
7030
7066
|
var FIELD_TYPE_REGISTRY = {
|
|
7031
7067
|
string: {
|
|
@@ -7598,6 +7634,6 @@ function matchesRelationship(r, targetEntity, relationshipType) {
|
|
|
7598
7634
|
return r.targetEntity === targetEntity && r.relationshipType === relationshipType;
|
|
7599
7635
|
}
|
|
7600
7636
|
|
|
7601
|
-
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 };
|
|
7637
|
+
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, mergeDocuments, mergeDomainChunks, parseBehavior, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseGuard, parsePage, parseSectionId, removeMapping, resolveConflict, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, tokenize, translateDomainToParams, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };
|
|
7602
7638
|
//# sourceMappingURL=index.js.map
|
|
7603
7639
|
//# sourceMappingURL=index.js.map
|