@almadar/core 7.17.0 → 7.18.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,102 @@ interface ParseResult<T> {
216
238
  errors: ParseError[];
217
239
  warnings: ParseError[];
218
240
  }
241
+ /**
242
+ * Inferred role of a trait within an orbital. Driven by heuristics over
243
+ * the trait body (state-machine event names, AppLayout suffix, etc.)
244
+ * during signature extraction. Stays a closed union so the Phase 2
245
+ * projector can pattern-match exhaustively; `'other'` is the
246
+ * catch-all for traits that don't fit a known kind.
247
+ */
248
+ type FactoryTraitKind = 'list' | 'detail' | 'modal' | 'layout' | 'wizard' | 'tabs' | 'realtime' | 'browse' | 'inspector' | 'navigation' | 'lifecycle' | 'access-control' | 'audit' | 'persistor' | 'other';
249
+ /**
250
+ * One field on a factory's canonical entity, in signature form. Mirrors
251
+ * the subset of `EntityField` that the projector needs to score a
252
+ * domain-entity match. Auto-added audit fields (id / createdAt /
253
+ * updatedAt) are omitted by the extractor.
254
+ */
255
+ interface FactorySignatureEntityField {
256
+ name: string;
257
+ type: SchemaFieldType;
258
+ required: boolean;
259
+ }
260
+ /**
261
+ * The canonical entity a factory produces. Almost always one entity
262
+ * per orbital; modeled as an array to keep the door open for orbitals
263
+ * that compose multiple entities.
264
+ */
265
+ interface FactoryEntitySignature {
266
+ /** Canonical entity name the factory's params build (e.g. `"ChatMessage"`). */
267
+ name: string;
268
+ /** Fields the factory emits, post-auto-field stripping. */
269
+ fields: ReadonlyArray<FactorySignatureEntityField>;
270
+ /** Default persistence mode the factory emits; overridable by params. */
271
+ persistence: EntityPersistence;
272
+ /** True when the factory's params accept an `entityName` override. */
273
+ renameable: boolean;
274
+ /**
275
+ * True when the factory's params accept appending extra fields via
276
+ * `params.fields[]`. Almost always true; declared explicitly so the
277
+ * projector can introspect.
278
+ */
279
+ fieldsExtensible: boolean;
280
+ }
281
+ /**
282
+ * One trait the factory composes into the orbital. The projector reads
283
+ * these to determine which factory's trait stack covers a given
284
+ * `DomainBehavior` + which override knobs a presentation overlay can
285
+ * deterministically target.
286
+ */
287
+ interface FactoryTraitSignature {
288
+ /** Canonical trait name post-rename (e.g. `"ChatMessageList"`). */
289
+ name: string;
290
+ kind: FactoryTraitKind;
291
+ /** Event keys this trait emits (post-rename). */
292
+ emittedEvents: ReadonlyArray<string>;
293
+ /** Event keys this trait listens for. */
294
+ listenedEvents: ReadonlyArray<string>;
295
+ /** Config keys overridable via `traitOverrides.<name>.config.<key>`. */
296
+ overridableConfigKeys: ReadonlyArray<string>;
297
+ }
298
+ /** One page the factory emits. The path is the factory default; the
299
+ * projector may override via `params.pagePath` or `params.pages[].path`. */
300
+ interface FactoryPageSignature {
301
+ name: string;
302
+ defaultPath: string;
303
+ primaryEntity: string;
304
+ }
305
+ interface FactorySignature {
306
+ /** Organism the factory belongs to (e.g. `"std-realtime-chat"`). */
307
+ organism: string;
308
+ /** Orbital this factory builds within that organism. */
309
+ orbital: string;
310
+ /** Tier the factory sits in (informational; drives nothing today). */
311
+ tier: 'atoms' | 'molecules' | 'organisms';
312
+ /** Path of the generated factory source (relative to the std root). */
313
+ factoryPath: string;
314
+ /** Canonical entity surface(s) the factory produces. */
315
+ entities: ReadonlyArray<FactoryEntitySignature>;
316
+ /** Trait stack the factory composes. */
317
+ traits: ReadonlyArray<FactoryTraitSignature>;
318
+ /** Pages the factory emits. */
319
+ pages: ReadonlyArray<FactoryPageSignature>;
320
+ /** Union of all `traits[].emittedEvents`. */
321
+ emittedEvents: ReadonlyArray<string>;
322
+ /** Union of all `traits[].listenedEvents`. */
323
+ listenedEvents: ReadonlyArray<string>;
324
+ }
325
+ /**
326
+ * Aggregate catalog written to
327
+ * `packages/almadar-std/behaviors/registry/factory-signatures.json`.
328
+ * Sorted by organism then orbital. One entry per factory in the
329
+ * regenerate pipeline.
330
+ */
331
+ interface FactorySignatureCatalog {
332
+ /** Generated-by version stamp (the `@almadar/std` minor it shipped in). */
333
+ generatedFromStdVersion: string;
334
+ /** Sorted list of factory signatures. */
335
+ signatures: ReadonlyArray<FactorySignature>;
336
+ }
219
337
 
220
338
  /**
221
339
  * Domain Language Tokens
@@ -969,4 +1087,4 @@ declare function getRegistryStats(): {
969
1087
  */
970
1088
  declare function generateDomainLanguageReference(): string;
971
1089
 
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 };
1090
+ 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 FactoryTraitKind, 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 };