@almadar/core 1.0.16 → 1.0.18

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.
@@ -1,4 +1,4 @@
1
- import { bp as SExpr, T as Entity, aZ as Page, O as OrbitalSchema, b$ as Trait } from '../schema-zGCZtr5W.js';
1
+ import { bq as SExpr, V as Entity, a_ as Page, O as OrbitalSchema, b$ as Trait } from '../schema-N46ASk3M.js';
2
2
  import 'zod';
3
3
  import '@almadar/patterns';
4
4
 
@@ -915,4 +915,14 @@ declare function getRegistryStats(): {
915
915
  uiSlots: number;
916
916
  };
917
917
 
918
- export { type ASTNode, type ComparisonCondition, type ComparisonOperator, type DomainBehavior, type DomainChunk, type DomainDocument, type DomainEffect, type DomainEntity, type DomainField, type DomainFieldType, type DomainGuard, type DomainPage, type DomainPageAction, type DomainPageSection, type DomainRelationship, type DomainTick, type DomainToSchemaResult, type DomainTransition, EFFECT_REGISTRY, type EffectMapping, type EffectType, 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, 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, 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 };
918
+ /**
919
+ * Domain Language Reference — pure function that generates reference docs from the type registry.
920
+ *
921
+ * Separated from generate-docs.ts (CLI script) so it can be compiled and exported.
922
+ */
923
+ /**
924
+ * Generate the complete Domain Language reference document as a string.
925
+ */
926
+ declare function generateDomainLanguageReference(): string;
927
+
928
+ export { type ASTNode, type ComparisonCondition, type ComparisonOperator, type DomainBehavior, type DomainChunk, type DomainDocument, type DomainEffect, type DomainEntity, type DomainField, type DomainFieldType, type DomainGuard, type DomainPage, type DomainPageAction, type DomainPageSection, type DomainRelationship, type DomainTick, type DomainToSchemaResult, type DomainTransition, EFFECT_REGISTRY, type EffectMapping, type EffectType, 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, 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 };
@@ -3322,11 +3322,30 @@ var FieldTypeSchema = z.enum([
3322
3322
  "enum",
3323
3323
  "relation"
3324
3324
  ]);
3325
+ var RelationCardinalitySchema = z.enum([
3326
+ "one",
3327
+ "many",
3328
+ "one-to-many",
3329
+ "many-to-one",
3330
+ "many-to-many"
3331
+ ]);
3325
3332
  var RelationConfigSchema = z.object({
3326
3333
  entity: z.string().min(1, "Target entity is required"),
3327
3334
  field: z.string().optional(),
3328
- cardinality: z.enum(["one", "many"]).optional(),
3329
- onDelete: z.enum(["cascade", "nullify", "restrict"]).optional()
3335
+ cardinality: RelationCardinalitySchema.optional(),
3336
+ onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
3337
+ // Legacy compatibility fields
3338
+ foreignKey: z.string().optional(),
3339
+ target: z.string().optional(),
3340
+ type: RelationCardinalitySchema.optional()
3341
+ }).transform((data) => {
3342
+ const normalized = {
3343
+ entity: data.entity || data.target || "",
3344
+ cardinality: data.cardinality || data.type,
3345
+ field: data.field,
3346
+ onDelete: data.onDelete
3347
+ };
3348
+ return normalized;
3330
3349
  });
3331
3350
  var FieldFormatSchema = z.enum([
3332
3351
  "email",
@@ -4048,7 +4067,7 @@ z.string().refine(
4048
4067
  if (!val.startsWith("@")) return false;
4049
4068
  const parts = val.slice(1).split(".");
4050
4069
  if (parts.length === 0 || parts[0] === "") return false;
4051
- return parts.every((part) => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(part));
4070
+ return parts.every((part) => /^[\p{L}_][\p{L}0-9_]*$/u.test(part));
4052
4071
  },
4053
4072
  { message: "Invalid binding format. Must be @name or @name.path.to.field" }
4054
4073
  );
@@ -6591,6 +6610,160 @@ function getRegistryStats() {
6591
6610
  };
6592
6611
  }
6593
6612
 
6594
- export { EFFECT_REGISTRY, FIELD_TYPE_REGISTRY, GUARD_REGISTRY, KEYWORDS, Lexer, MULTI_WORD_KEYWORDS, TokenType, 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, 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 };
6613
+ // src/domain-language/domain-language-reference.ts
6614
+ function generateDomainLanguageReference() {
6615
+ const lines = [];
6616
+ const stats = getRegistryStats();
6617
+ lines.push("# Domain Language Reference");
6618
+ lines.push("");
6619
+ lines.push("> Auto-generated from type registry");
6620
+ lines.push(`> Last updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`);
6621
+ lines.push("");
6622
+ lines.push("This document describes the Domain Language syntax that maps to OrbitalSchema.");
6623
+ lines.push("Domain Language is a human-readable format that is converted to/from OrbitalSchema JSON.");
6624
+ lines.push("");
6625
+ lines.push("## Table of Contents");
6626
+ lines.push("");
6627
+ lines.push("- [Field Types](#field-types)");
6628
+ lines.push("- [Effects](#effects)");
6629
+ lines.push("- [Guards](#guards)");
6630
+ lines.push("- [UI Slots](#ui-slots)");
6631
+ lines.push("- [Bindings](#bindings)");
6632
+ lines.push("- [Statistics](#statistics)");
6633
+ lines.push("");
6634
+ lines.push("## Field Types");
6635
+ lines.push("");
6636
+ lines.push("| Schema Type | Domain Keywords | Description |");
6637
+ lines.push("|-------------|-----------------|-------------|");
6638
+ for (const [type, mapping] of Object.entries(FIELD_TYPE_REGISTRY)) {
6639
+ const keywords = mapping.domainKeywords.map((k) => `\`${k}\``).join(", ");
6640
+ lines.push(`| \`${type}\` | ${keywords} | - |`);
6641
+ }
6642
+ lines.push("");
6643
+ lines.push("## Effects");
6644
+ lines.push("");
6645
+ lines.push("Effects are actions that occur during state transitions.");
6646
+ lines.push("In Domain Language, they are written as human-readable statements.");
6647
+ lines.push("The `domain:to-schema` converter translates them to S-Expression arrays.");
6648
+ lines.push("");
6649
+ lines.push("| Operator | Domain Patterns | Description |");
6650
+ lines.push("|----------|-----------------|-------------|");
6651
+ for (const [op, mapping] of Object.entries(EFFECT_REGISTRY)) {
6652
+ const patterns = mapping.domainPatterns.map((p) => `\`${p}\``).join(", ");
6653
+ lines.push(`| \`${op}\` | ${patterns} | ${mapping.description} |`);
6654
+ }
6655
+ lines.push("");
6656
+ lines.push("### Effect Examples");
6657
+ lines.push("");
6658
+ lines.push("```");
6659
+ lines.push("# Update a field");
6660
+ lines.push("then update status to 'done'");
6661
+ lines.push("");
6662
+ lines.push("# Emit an event");
6663
+ lines.push("then emit TASK_COMPLETED");
6664
+ lines.push("then emit ORDER_PLACED with orderId");
6665
+ lines.push("");
6666
+ lines.push("# Render UI");
6667
+ lines.push("then render entity-table to main for Task");
6668
+ lines.push("then render form-section to modal for Order");
6669
+ lines.push("then render null to modal");
6670
+ lines.push("");
6671
+ lines.push("# Navigation");
6672
+ lines.push("then navigate to /tasks");
6673
+ lines.push("");
6674
+ lines.push("# Database");
6675
+ lines.push("then persist create Task");
6676
+ lines.push("then persist update Order");
6677
+ lines.push("then persist delete Item");
6678
+ lines.push("");
6679
+ lines.push("# External services");
6680
+ lines.push("then call stripe.charge with amount");
6681
+ lines.push("");
6682
+ lines.push("# Game effects");
6683
+ lines.push("then spawn Bullet at Player's position");
6684
+ lines.push("then despawn");
6685
+ lines.push("");
6686
+ lines.push("# Notifications");
6687
+ lines.push("then show success notification 'Saved!'");
6688
+ lines.push("```");
6689
+ lines.push("");
6690
+ lines.push("## Guards");
6691
+ lines.push("");
6692
+ lines.push("Guards are conditions that must be true for a transition to occur.");
6693
+ lines.push("");
6694
+ lines.push("| Operator | Domain Patterns | Description |");
6695
+ lines.push("|----------|-----------------|-------------|");
6696
+ for (const [op, mapping] of Object.entries(GUARD_REGISTRY)) {
6697
+ const patterns = mapping.domainPatterns.map((p) => `\`${p}\``).join(", ");
6698
+ lines.push(`| \`${op}\` | ${patterns} | ${mapping.description} |`);
6699
+ }
6700
+ lines.push("");
6701
+ lines.push("### Guard Examples");
6702
+ lines.push("");
6703
+ lines.push("```");
6704
+ lines.push("# Comparison guards");
6705
+ lines.push("if status is 'active'");
6706
+ lines.push("if amount > 100");
6707
+ lines.push("if health is at least 0");
6708
+ lines.push("if priority <= 3");
6709
+ lines.push("");
6710
+ lines.push("# Compound guards");
6711
+ lines.push("if health >= 30 and health < 70");
6712
+ lines.push("if status is 'active' or status is 'pending'");
6713
+ lines.push("if status is not 'deleted'");
6714
+ lines.push("");
6715
+ lines.push("# Payload checks");
6716
+ lines.push("if incoming amount > 0");
6717
+ lines.push("```");
6718
+ lines.push("");
6719
+ lines.push("## UI Slots");
6720
+ lines.push("");
6721
+ lines.push("UI slots are named regions where patterns can be rendered.");
6722
+ lines.push("");
6723
+ lines.push("| Slot | Description |");
6724
+ lines.push("|------|-------------|");
6725
+ const slotDescriptions = {
6726
+ "main": "Primary content area",
6727
+ "sidebar": "Side navigation or secondary content",
6728
+ "modal": "Modal dialog overlay",
6729
+ "drawer": "Slide-out panel",
6730
+ "overlay": "Full-screen overlay",
6731
+ "center": "Centered content area",
6732
+ "toast": "Toast notifications",
6733
+ "hud-top": "Top HUD (games)",
6734
+ "hud-bottom": "Bottom HUD (games)",
6735
+ "floating": "Floating elements",
6736
+ "system": "System components (invisible)"
6737
+ };
6738
+ for (const slot of UI_SLOTS2) {
6739
+ const desc = slotDescriptions[slot] || "-";
6740
+ lines.push(`| \`${slot}\` | ${desc} |`);
6741
+ }
6742
+ lines.push("");
6743
+ lines.push("## Bindings");
6744
+ lines.push("");
6745
+ lines.push("Bindings reference data in S-Expression context.");
6746
+ lines.push("In Domain Language, these are expressed more naturally.");
6747
+ lines.push("");
6748
+ lines.push("| S-Expression | Domain Language |");
6749
+ lines.push("|--------------|-----------------|");
6750
+ lines.push("| `@entity.field` | `field` or `Entity's field` |");
6751
+ lines.push("| `@payload.field` | `incoming field` |");
6752
+ lines.push("| `@state` | `current state` |");
6753
+ lines.push("| `@now` | `now` |");
6754
+ lines.push("");
6755
+ lines.push("## Statistics");
6756
+ lines.push("");
6757
+ lines.push("| Category | Count |");
6758
+ lines.push("|----------|-------|");
6759
+ lines.push(`| Field Types | ${stats.fieldTypes} |`);
6760
+ lines.push(`| Effects | ${stats.effects} |`);
6761
+ lines.push(`| Guards | ${stats.guards} |`);
6762
+ lines.push(`| UI Slots | ${stats.uiSlots} |`);
6763
+ lines.push("");
6764
+ return lines.join("\n");
6765
+ }
6766
+
6767
+ export { EFFECT_REGISTRY, FIELD_TYPE_REGISTRY, GUARD_REGISTRY, KEYWORDS, Lexer, MULTI_WORD_KEYWORDS, TokenType, 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 };
6595
6768
  //# sourceMappingURL=index.js.map
6596
6769
  //# sourceMappingURL=index.js.map