@almadar/core 1.0.17 → 2.0.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/LICENSE +21 -72
- package/README.md +25 -0
- package/dist/domain-language/index.d.ts +12 -2
- package/dist/domain-language/index.js +156 -2
- package/dist/domain-language/index.js.map +1 -1
- package/dist/index.d.ts +41 -5
- package/dist/index.js +294 -2
- package/dist/index.js.map +1 -1
- package/dist/{schema-DYj-zJWb.d.ts → schema-N46ASk3M.d.ts} +2 -2
- package/dist/types/index.d.ts +33 -3
- package/dist/types/index.js +16 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +6 -5
package/LICENSE
CHANGED
|
@@ -1,72 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
23
|
-
available distribution of a specific version of the Licensed Work under this
|
|
24
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
25
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
26
|
-
above terminate.
|
|
27
|
-
|
|
28
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
29
|
-
currently in effect as described in this License, you must purchase a
|
|
30
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
31
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
32
|
-
|
|
33
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
34
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
35
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
36
|
-
for each version of the Licensed Work released by Licensor.
|
|
37
|
-
|
|
38
|
-
You must conspicuously display this License on each original or modified copy
|
|
39
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
40
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
41
|
-
License apply to your use of that work.
|
|
42
|
-
|
|
43
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
44
|
-
terminate your rights under this License for the current and all other
|
|
45
|
-
versions of the Licensed Work.
|
|
46
|
-
|
|
47
|
-
This License does not grant you any right in any trademark or logo of
|
|
48
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
49
|
-
Licensor as expressly required by this License).
|
|
50
|
-
|
|
51
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
52
|
-
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
53
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
54
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
55
|
-
TITLE.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
60
|
-
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
61
|
-
|
|
62
|
-
ADDITIONAL TERMS:
|
|
63
|
-
|
|
64
|
-
Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
|
|
65
|
-
|
|
66
|
-
TRADEMARKS:
|
|
67
|
-
|
|
68
|
-
"Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
|
|
69
|
-
Almadar FZE. You may not use these trademarks without prior written
|
|
70
|
-
permission from Almadar FZE.
|
|
71
|
-
|
|
72
|
-
For licensing inquiries: licensing@almadar.io
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Almadar Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @almadar/core
|
|
2
|
+
|
|
3
|
+
> Core schema types and definitions for Almadar
|
|
4
|
+
|
|
5
|
+
Part of the [Almadar](https://github.com/almadar-io/almadar) platform.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @almadar/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { /* ... */ } from '@almadar/core';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
<!-- Document public exports here -->
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 };
|
|
@@ -4067,7 +4067,7 @@ z.string().refine(
|
|
|
4067
4067
|
if (!val.startsWith("@")) return false;
|
|
4068
4068
|
const parts = val.slice(1).split(".");
|
|
4069
4069
|
if (parts.length === 0 || parts[0] === "") return false;
|
|
4070
|
-
return parts.every((part) => /^[
|
|
4070
|
+
return parts.every((part) => /^[\p{L}_][\p{L}0-9_]*$/u.test(part));
|
|
4071
4071
|
},
|
|
4072
4072
|
{ message: "Invalid binding format. Must be @name or @name.path.to.field" }
|
|
4073
4073
|
);
|
|
@@ -6610,6 +6610,160 @@ function getRegistryStats() {
|
|
|
6610
6610
|
};
|
|
6611
6611
|
}
|
|
6612
6612
|
|
|
6613
|
-
|
|
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 };
|
|
6614
6768
|
//# sourceMappingURL=index.js.map
|
|
6615
6769
|
//# sourceMappingURL=index.js.map
|