@almadar/core 7.17.0 → 7.19.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.
@@ -13,6 +13,24 @@ import '@almadar/patterns';
13
13
  * @packageDocumentation
14
14
  */
15
15
 
16
+ /**
17
+ * Field type mapping: OrbitalSchema type → Domain Language keyword
18
+ *
19
+ * This is the single source of truth for type conversion.
20
+ * When adding new field types to OrbitalSchema, add the mapping here.
21
+ */
22
+ declare const FIELD_TYPE_MAPPING: {
23
+ readonly string: "text";
24
+ readonly number: "number";
25
+ readonly boolean: "yes/no";
26
+ readonly date: "date";
27
+ readonly timestamp: "timestamp";
28
+ readonly datetime: "datetime";
29
+ readonly array: "list";
30
+ readonly object: "object";
31
+ readonly enum: "enum";
32
+ readonly relation: "relation";
33
+ };
16
34
  /**
17
35
  * Effect operator mapping: Both systems use the same operator names
18
36
  */
@@ -41,6 +59,10 @@ interface ASTNode {
41
59
  * Note: These map to OrbitalSchema types via DOMAIN_TO_SCHEMA_FIELD_TYPE
42
60
  */
43
61
  type DomainFieldType = 'text' | 'long text' | 'number' | 'currency' | 'date' | 'timestamp' | 'datetime' | 'yes/no' | 'enum' | 'list' | 'object' | 'relation';
62
+ /**
63
+ * OrbitalSchema field types (for reference)
64
+ */
65
+ type SchemaFieldType = keyof typeof FIELD_TYPE_MAPPING;
44
66
  /**
45
67
  * Default value for a `DomainField`. Mirrors the JSON-leaf shape an
46
68
  * `EntityField.default` may carry on `OrbitalSchema`: scalar, list, or
@@ -216,6 +238,89 @@ interface ParseResult<T> {
216
238
  errors: ParseError[];
217
239
  warnings: ParseError[];
218
240
  }
241
+ /**
242
+ * One field on a factory's canonical entity, in signature form. Mirrors
243
+ * the subset of `EntityField` that the projector needs to score a
244
+ * domain-entity match. Auto-added audit fields (id / createdAt /
245
+ * updatedAt) are omitted by the extractor.
246
+ */
247
+ interface FactorySignatureEntityField {
248
+ name: string;
249
+ type: SchemaFieldType;
250
+ required: boolean;
251
+ }
252
+ /**
253
+ * The canonical entity a factory produces. Almost always one entity
254
+ * per orbital; modeled as an array to keep the door open for orbitals
255
+ * that compose multiple entities.
256
+ */
257
+ interface FactoryEntitySignature {
258
+ /** Canonical entity name the factory's params build (e.g. `"ChatMessage"`). */
259
+ name: string;
260
+ /** Fields the factory emits, post-auto-field stripping. */
261
+ fields: ReadonlyArray<FactorySignatureEntityField>;
262
+ /** Persistence mode declared on the canonical entity in the `.orb`. */
263
+ persistence: EntityPersistence;
264
+ }
265
+ /**
266
+ * One trait the factory composes into the orbital. The projector reads
267
+ * these to determine which factory's trait stack covers a given
268
+ * `DomainBehavior` + which override knobs a presentation overlay can
269
+ * deterministically target. Trait identity is by `name` only; the
270
+ * projector matches structurally on the event / config arrays — no
271
+ * inferred "kind" tag.
272
+ */
273
+ interface FactoryTraitSignature {
274
+ /** Canonical trait name post-rename (e.g. `"ChatMessageList"`). */
275
+ name: string;
276
+ /** Event keys this trait emits (post-rename). Read directly from
277
+ * the trait's `emits[].event`. */
278
+ emittedEvents: ReadonlyArray<string>;
279
+ /** Event keys this trait listens for. Read directly from `listens[].event`. */
280
+ listenedEvents: ReadonlyArray<string>;
281
+ /** Config keys overridable via `traitOverrides.<name>.config.<key>`.
282
+ * Read directly from the trait's `config` declaration block. */
283
+ overridableConfigKeys: ReadonlyArray<string>;
284
+ }
285
+ /** One page the factory emits. The path is the factory default; the
286
+ * projector may override via `params.pagePath` or `params.pages[].path`. */
287
+ interface FactoryPageSignature {
288
+ name: string;
289
+ defaultPath: string;
290
+ primaryEntity: string;
291
+ }
292
+ interface FactorySignature {
293
+ /** Organism the factory belongs to (e.g. `"std-realtime-chat"`). */
294
+ organism: string;
295
+ /** Orbital this factory builds within that organism. */
296
+ orbital: string;
297
+ /** Tier the factory sits in (informational; drives nothing today). */
298
+ tier: 'atoms' | 'molecules' | 'organisms';
299
+ /** Path of the generated factory source (relative to the std root). */
300
+ factoryPath: string;
301
+ /** Canonical entity surface(s) the factory produces. */
302
+ entities: ReadonlyArray<FactoryEntitySignature>;
303
+ /** Trait stack the factory composes. */
304
+ traits: ReadonlyArray<FactoryTraitSignature>;
305
+ /** Pages the factory emits. */
306
+ pages: ReadonlyArray<FactoryPageSignature>;
307
+ /** Union of all `traits[].emittedEvents`. */
308
+ emittedEvents: ReadonlyArray<string>;
309
+ /** Union of all `traits[].listenedEvents`. */
310
+ listenedEvents: ReadonlyArray<string>;
311
+ }
312
+ /**
313
+ * Aggregate catalog written to
314
+ * `packages/almadar-std/behaviors/registry/factory-signatures.json`.
315
+ * Sorted by organism then orbital. One entry per factory in the
316
+ * regenerate pipeline.
317
+ */
318
+ interface FactorySignatureCatalog {
319
+ /** Generated-by version stamp (the `@almadar/std` minor it shipped in). */
320
+ generatedFromStdVersion: string;
321
+ /** Sorted list of factory signatures. */
322
+ signatures: ReadonlyArray<FactorySignature>;
323
+ }
219
324
 
220
325
  /**
221
326
  * Domain Language Tokens
@@ -969,4 +1074,4 @@ declare function getRegistryStats(): {
969
1074
  */
970
1075
  declare function generateDomainLanguageReference(): string;
971
1076
 
972
- export { type ASTNode, 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 DomainPage, type DomainPageAction, type DomainPageSection, type DomainRelationship, type DomainTick, type DomainToSchemaResult, type DomainTransition, EFFECT_REGISTRY, type EffectMapping, type EffectType, EntityPersistence, FIELD_TYPE_REGISTRY, 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 RelationshipType, type SchemaToDomainResult, type SectionMapping, type SourceLocation, type SourceRange, type Token, TokenType, TraitScope, type UserCheckCondition, applySectionUpdate, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createMappingStore, deleteSection, detectChanges, 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, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };
1077
+ export { type ASTNode, 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 DomainPage, type DomainPageAction, type DomainPageSection, type DomainRelationship, type DomainTick, type DomainToSchemaResult, type DomainTransition, EFFECT_REGISTRY, type EffectMapping, type EffectType, EntityPersistence, FIELD_TYPE_REGISTRY, type FactoryEntitySignature, type FactoryPageSignature, 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 RelationshipType, type SchemaToDomainResult, type SectionMapping, type SourceLocation, type SourceRange, type Token, TokenType, TraitScope, type UserCheckCondition, applySectionUpdate, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createMappingStore, deleteSection, detectChanges, 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, updateMappingRange, updateSchemaHash, upsertMapping, validateDomainChunk };