@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/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as OrbitalSchema } from './schema-
|
|
2
|
-
export { A as AGENT_DOMAIN_CATEGORIES,
|
|
1
|
+
import { O as OrbitalSchema, S as State, a as OrbitalDefinition } from './schema-N46ASk3M.js';
|
|
2
|
+
export { A as AGENT_DOMAIN_CATEGORIES, b as ALLOWED_CUSTOM_COMPONENTS, c as AgentDomainCategory, d as AgentDomainCategorySchema, e as AllowedCustomComponent, f as AnimationDef, g as AnimationDefInput, h as AnimationDefSchema, i as AssetMap, j as AssetMapInput, k as AssetMapSchema, l as AssetMapping, m as AssetMappingInput, n as AssetMappingSchema, C as CORE_BINDINGS, o as CallServiceConfig, p as ComputedEventContract, q as ComputedEventContractSchema, r as ComputedEventListener, s as ComputedEventListenerSchema, t as CoreBinding, u as CustomPatternDefinition, v as CustomPatternDefinitionInput, w as CustomPatternDefinitionSchema, x as CustomPatternMap, y as CustomPatternMapInput, z as CustomPatternMapSchema, D as DesignPreferences, B as DesignPreferencesInput, E as DesignPreferencesSchema, F as DesignTokens, G as DesignTokensInput, H as DesignTokensSchema, I as DomainCategory, J as DomainCategorySchema, K as DomainContext, L as DomainContextInput, M as DomainContextSchema, N as DomainVocabulary, P as DomainVocabularySchema, Q as ENTITY_ROLES, R as Effect, T as EffectInput, U as EffectSchema, V as Entity, W as EntityField, X as EntityFieldInput, Y as EntityFieldSchema, Z as EntityPersistence, _ as EntityPersistenceSchema, $ as EntityRef, a0 as EntityRefSchema, a1 as EntityRefStringSchema, a2 as EntityRole, a3 as EntityRoleSchema, a4 as EntitySchema, a5 as EntitySemanticRole, a6 as EntitySemanticRoleSchema, a7 as Event, a8 as EventInput, a9 as EventListener, aa as EventListenerSchema, ab as EventPayloadField, ac as EventPayloadFieldSchema, ad as EventSchema, ae as EventScope, af as EventScopeSchema, ag as EventSemanticRole, ah as EventSemanticRoleSchema, ai as EventSource, aj as EventSourceSchema, ak as Expression, al as ExpressionInput, am as ExpressionSchema, an as Field, ao as FieldFormat, ap as FieldFormatSchema, aq as FieldSchema, ar as FieldType, as as FieldTypeSchema, at as FullOrbitalUnit, au as GAME_TYPES, av as GameSubCategory, aw as GameSubCategorySchema, ax as GameType, ay as GameTypeSchema, az as Guard, aA as GuardInput, aB as GuardSchema, aC as McpServiceDef, aD as McpServiceDefSchema, aE as NodeClassification, aF as NodeClassificationSchema, at as Orbital, aG as OrbitalConfig, aH as OrbitalConfigInput, aI as OrbitalConfigSchema, aJ as OrbitalDefinitionSchema, aK as OrbitalEntity, aL as OrbitalEntityInput, aM as OrbitalEntitySchema, aN as OrbitalInput, aO as OrbitalPage, aP as OrbitalPageInput, aQ as OrbitalPageSchema, aR as OrbitalPageStrictInput, aS as OrbitalPageStrictSchema, aT as OrbitalSchemaInput, aU as OrbitalSchemaSchema, aV as OrbitalTraitRef, aW as OrbitalTraitRefSchema, aX as OrbitalUnit, aY as OrbitalUnitSchema, aZ as OrbitalZodSchema, a_ as Page, a$ as PageRef, b0 as PageRefObject, b1 as PageRefObjectSchema, b2 as PageRefSchema, b3 as PageRefStringSchema, b4 as PageSchema, b5 as PageTraitRef, b6 as PageTraitRefSchema, b7 as ParsedBinding, b8 as PayloadField, b9 as PayloadFieldSchema, ba as PresentationType, bb as RelatedLink, bc as RelatedLinkSchema, bd as RelationConfig, be as RelationConfigSchema, bf as RenderUIConfig, bg as RequiredField, bh as RequiredFieldSchema, bi as ResolvedAsset, bj as ResolvedAssetInput, bk as ResolvedAssetSchema, bl as RestAuthConfig, bm as RestAuthConfigSchema, bn as RestServiceDef, bo as RestServiceDefSchema, bp as SERVICE_TYPES, bq as SExpr, br as SExprAtom, bs as SExprAtomSchema, bt as SExprInput, bu as SExprSchema, bv as SemanticAssetRef, bw as SemanticAssetRefInput, bx as SemanticAssetRefSchema, by as ServiceDefinition, bz as ServiceDefinitionSchema, bA as ServiceRef, bB as ServiceRefSchema, bC as ServiceRefStringSchema, bD as ServiceType, bE as ServiceTypeSchema, bF as SocketEvents, bG as SocketEventsSchema, bH as SocketServiceDef, bI as SocketServiceDefSchema, bJ as StateInput, bK as StateMachine, bL as StateMachineInput, bM as StateMachineSchema, bN as StateSchema, bO as StateSemanticRole, bP as StateSemanticRoleSchema, bQ as SuggestedGuard, bR as SuggestedGuardSchema, bS as ThemeDefinition, bT as ThemeDefinitionSchema, bU as ThemeRef, bV as ThemeRefSchema, bW as ThemeRefStringSchema, bX as ThemeTokens, bY as ThemeTokensSchema, bZ as ThemeVariant, b_ as ThemeVariantSchema, b$ as Trait, c0 as TraitCategory, c1 as TraitCategorySchema, c2 as TraitDataEntity, c3 as TraitDataEntitySchema, c4 as TraitEntityField, c5 as TraitEntityFieldSchema, c6 as TraitEventContract, c7 as TraitEventContractSchema, c8 as TraitEventListener, c9 as TraitEventListenerSchema, ca as TraitInput, cb as TraitRef, cc as TraitRefSchema, cd as TraitReference, ce as TraitReferenceInput, cf as TraitReferenceSchema, cg as TraitSchema, ch as TraitTick, ci as TraitTickSchema, cj as TraitUIBinding, ck as Transition, cl as TransitionInput, cm as TransitionSchema, cn as UISlot, co as UISlotSchema, cp as UI_SLOTS, cq as UXHints, cr as UXHintsSchema, cs as UseDeclaration, ct as UseDeclarationSchema, cu as UserPersona, cv as UserPersonaInput, cw as UserPersonaSchema, cx as VISUAL_STYLES, cy as ViewType, cz as ViewTypeSchema, cA as VisualStyle, cB as VisualStyleSchema, cC as callService, cD as collectBindings, cE as createAssetKey, cF as deriveCollection, cG as despawn, cH as doEffects, cI as emit, cJ as findService, cK as getArgs, cL as getDefaultAnimationsForRole, cM as getOperator, cN as getServiceNames, cO as getTraitConfig, cP as getTraitName, cQ as hasService, cR as isBinding, cS as isCircuitEvent, cT as isEffect, cU as isEntityReference, cV as isImportedTraitRef, cW as isInlineTrait, cX as isMcpService, cY as isOrbitalDefinition, cZ as isPageReference, c_ as isPageReferenceObject, c$ as isPageReferenceString, d0 as isRestService, d1 as isRuntimeEntity, d2 as isSExpr, d3 as isSExprAtom, d4 as isSExprCall, d5 as isSExprEffect, d6 as isServiceReference, d7 as isSingletonEntity, d8 as isSocketService, d9 as isThemeReference, da as isValidBinding, db as navigate, dc as normalizeTraitRef, dd as notify, de as parseAssetKey, df as parseBinding, dg as parseEntityRef, dh as parseImportedTraitRef, di as parseOrbitalSchema, dj as parsePageRef, dk as parseServiceRef, dl as persist, dm as renderUI, dn as safeParseOrbitalSchema, dp as set, dq as sexpr, dr as spawn, ds as validateAssetAnimations, dt as walkSExpr } from './schema-N46ASk3M.js';
|
|
3
3
|
import { ResolvedIR, ResolvedEntity, ResolvedPage, ResolvedTrait, SchemaChange, CategorizedRemovals, PageContentReduction } from './types/index.js';
|
|
4
|
-
export { AppSummary, BINDING_CONTEXT_RULES, BINDING_DOCS, BindingContext, BindingSchema, ChangeAuthor, ChangeSetDocument, ChangeSummary, CreateFlow, DEFAULT_INTERACTION_MODELS, DeleteFlow, EditFlow, HistoryMeta, InteractionModel, InteractionModelInput, InteractionModelSchema, ListInteraction, OperatorName, PatternTypeSchema, ResolvedEntityBinding, ResolvedField, ResolvedNavigation, ResolvedPattern, ResolvedSection, ResolvedSectionEvent, ResolvedTraitBinding, ResolvedTraitDataEntity, ResolvedTraitEvent, ResolvedTraitGuard, ResolvedTraitListener, ResolvedTraitState, ResolvedTraitTick, ResolvedTraitTransition, ResolvedTraitUIBinding, SaveOptions, SaveResult, SnapshotDocument, StatsView, TransitionFrom, ValidationDocument, ValidationIssue, ValidationMeta, ValidationResults, ViewFlow, createEmptyResolvedPage, createEmptyResolvedTrait, createResolvedField, getAllOperators, getAllPatternTypes, getBindingExamples, getInteractionModelForDomain, inferTsType, isResolvedIR, validateBindingInContext } from './types/index.js';
|
|
5
|
-
export { ASTNode, ComparisonCondition, ComparisonOperator, DomainBehavior, DomainChunk, DomainDocument, DomainEffect, DomainEntity, DomainField, DomainFieldType, DomainGuard, DomainPage, DomainPageAction, DomainPageSection, DomainRelationship, DomainTick, DomainToSchemaResult, DomainTransition, EFFECT_REGISTRY, EffectMapping, EffectType, FIELD_TYPE_REGISTRY, FieldCheckCondition, FieldReference, FieldTypeMapping, GUARD_REGISTRY, GuardCondition, GuardMapping, KEYWORDS, Lexer, LogicalCondition, LogicalOperator, MULTI_WORD_KEYWORDS, MappingStore, MergeResult, ParseError, ParseResult, RelationshipType, SchemaToDomainResult, SectionMapping, SourceLocation, SourceRange, Token, TokenType, 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 } from './domain-language/index.js';
|
|
4
|
+
export { AppSummary, BINDING_CONTEXT_RULES, BINDING_DOCS, BindingContext, BindingSchema, ChangeAuthor, ChangeSetDocument, ChangeSummary, CreateFlow, DEFAULT_INTERACTION_MODELS, DeleteFlow, EditFlow, GitHubLink, HistoryMeta, InteractionModel, InteractionModelInput, InteractionModelSchema, ListInteraction, OperatorName, PatternTypeSchema, ResolvedEntityBinding, ResolvedField, ResolvedNavigation, ResolvedPattern, ResolvedSection, ResolvedSectionEvent, ResolvedTraitBinding, ResolvedTraitDataEntity, ResolvedTraitEvent, ResolvedTraitGuard, ResolvedTraitListener, ResolvedTraitState, ResolvedTraitTick, ResolvedTraitTransition, ResolvedTraitUIBinding, SaveOptions, SaveResult, SnapshotDocument, StatsView, TransitionFrom, ValidationDocument, ValidationIssue, ValidationMeta, ValidationResults, ViewFlow, createEmptyResolvedPage, createEmptyResolvedTrait, createResolvedField, getAllOperators, getAllPatternTypes, getBindingExamples, getInteractionModelForDomain, inferTsType, isResolvedIR, validateBindingInContext } from './types/index.js';
|
|
5
|
+
export { ASTNode, ComparisonCondition, ComparisonOperator, DomainBehavior, DomainChunk, DomainDocument, DomainEffect, DomainEntity, DomainField, DomainFieldType, DomainGuard, DomainPage, DomainPageAction, DomainPageSection, DomainRelationship, DomainTick, DomainToSchemaResult, DomainTransition, EFFECT_REGISTRY, EffectMapping, EffectType, FIELD_TYPE_REGISTRY, FieldCheckCondition, FieldReference, FieldTypeMapping, GUARD_REGISTRY, GuardCondition, GuardMapping, KEYWORDS, Lexer, LogicalCondition, LogicalOperator, MULTI_WORD_KEYWORDS, MappingStore, MergeResult, ParseError, ParseResult, RelationshipType, SchemaToDomainResult, SectionMapping, SourceLocation, SourceRange, Token, TokenType, 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 } from './domain-language/index.js';
|
|
6
6
|
export { CATEGORIES, CategoryMeta, OPERATORS, OPERATORS_SCHEMA, OPERATOR_NAMES, OperatorCategory, OperatorMeta, OperatorStats, OperatorsSchema, TargetPlatform, getOperatorMeta, getOperatorStats, getOperatorsByCategory, getOperatorsForTarget, isEffectOperator, isGuardOperator, isKnownOperator, validateOperatorArity } from '@almadar/operators';
|
|
7
7
|
export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';
|
|
8
8
|
import 'zod';
|
|
@@ -137,4 +137,40 @@ declare function detectPageContentReduction(beforePages: unknown[], afterPages:
|
|
|
137
137
|
*/
|
|
138
138
|
declare function hasSignificantPageReduction(reductions: PageContentReduction[]): boolean;
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Orbital Summarization
|
|
142
|
+
*
|
|
143
|
+
* Deterministic orbital-to-orbital transformation:
|
|
144
|
+
* full schema in → business skeleton out.
|
|
145
|
+
*
|
|
146
|
+
* Input: OrbitalSchema. Output: OrbitalSchema.
|
|
147
|
+
* Same types — just stripped of implementation details.
|
|
148
|
+
*
|
|
149
|
+
* @packageDocumentation
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Classify a workflow from its state machine states.
|
|
154
|
+
*
|
|
155
|
+
* - CRUD: 3+ states match {browsing, creating, editing, viewing, deleting}
|
|
156
|
+
* - Wizard: 2+ states match /^step\d+$/i, OR linear chain to terminal state
|
|
157
|
+
* - Custom: everything else
|
|
158
|
+
*/
|
|
159
|
+
declare function classifyWorkflow(states: State[]): 'crud' | 'wizard' | 'custom';
|
|
160
|
+
/**
|
|
161
|
+
* Summarize a single orbital into its business skeleton.
|
|
162
|
+
*
|
|
163
|
+
* OrbitalDefinition in → OrbitalDefinition out.
|
|
164
|
+
* Strips effects, guards, payloads, theme, optional fields.
|
|
165
|
+
* Deduplicates transitions on (from, to, event).
|
|
166
|
+
*/
|
|
167
|
+
declare function summarizeOrbital(orbital: OrbitalDefinition): OrbitalDefinition;
|
|
168
|
+
/**
|
|
169
|
+
* Summarize an entire OrbitalSchema into a business skeleton.
|
|
170
|
+
*
|
|
171
|
+
* OrbitalSchema in → OrbitalSchema out.
|
|
172
|
+
* Strips schema-level metadata (domainContext, design, designTokens, customPatterns).
|
|
173
|
+
*/
|
|
174
|
+
declare function summarizeSchema(schema: OrbitalSchema): OrbitalSchema;
|
|
175
|
+
|
|
176
|
+
export { OrbitalSchema as AppSchema, CategorizedRemovals, OrbitalDefinition, OrbitalSchema, PageContentReduction, ResolvedEntity, ResolvedIR, ResolvedPage, ResolvedTrait, SchemaChange, State, categorizeRemovals, classifyWorkflow, clearSchemaCache, detectPageContentReduction, diffSchemas, getEntity, getPage, getPages, getRemovals, getSchemaCacheStats, getTrait, hasSignificantPageReduction, isDestructiveChange, requiresConfirmation, schemaToIR, summarizeOrbital, summarizeSchema };
|
package/dist/index.js
CHANGED
|
@@ -996,7 +996,7 @@ var BindingSchema = z.string().refine(
|
|
|
996
996
|
if (!val.startsWith("@")) return false;
|
|
997
997
|
const parts = val.slice(1).split(".");
|
|
998
998
|
if (parts.length === 0 || parts[0] === "") return false;
|
|
999
|
-
return parts.every((part) => /^[
|
|
999
|
+
return parts.every((part) => /^[\p{L}_][\p{L}0-9_]*$/u.test(part));
|
|
1000
1000
|
},
|
|
1001
1001
|
{ message: "Invalid binding format. Must be @name or @name.path.to.field" }
|
|
1002
1002
|
);
|
|
@@ -1020,6 +1020,21 @@ var BINDING_DOCS = {
|
|
|
1020
1020
|
description: "Current timestamp in milliseconds",
|
|
1021
1021
|
examples: ["@now"],
|
|
1022
1022
|
requiresPath: false
|
|
1023
|
+
},
|
|
1024
|
+
config: {
|
|
1025
|
+
description: "Trait configuration values",
|
|
1026
|
+
examples: ["@config.apiEndpoint", "@config.theme"],
|
|
1027
|
+
requiresPath: true
|
|
1028
|
+
},
|
|
1029
|
+
computed: {
|
|
1030
|
+
description: "Computed/calculated values",
|
|
1031
|
+
examples: ["@computed.total", "@computed.isValid"],
|
|
1032
|
+
requiresPath: true
|
|
1033
|
+
},
|
|
1034
|
+
trait: {
|
|
1035
|
+
description: "Trait context data",
|
|
1036
|
+
examples: ["@trait.name", "@trait.category"],
|
|
1037
|
+
requiresPath: true
|
|
1023
1038
|
}
|
|
1024
1039
|
};
|
|
1025
1040
|
var BINDING_CONTEXT_RULES = {
|
|
@@ -1544,6 +1559,129 @@ function hasSignificantPageReduction(reductions) {
|
|
|
1544
1559
|
return reductions.some((r) => r.isSignificant);
|
|
1545
1560
|
}
|
|
1546
1561
|
|
|
1562
|
+
// src/summarize.ts
|
|
1563
|
+
var CRUD_STATES = /* @__PURE__ */ new Set(["browsing", "creating", "editing", "viewing", "deleting"]);
|
|
1564
|
+
var STEP_PATTERN = /^step\d+$/i;
|
|
1565
|
+
function classifyWorkflow(states) {
|
|
1566
|
+
const names = states.map((s) => s.name.toLowerCase());
|
|
1567
|
+
const crudMatch = names.filter((n) => CRUD_STATES.has(n)).length;
|
|
1568
|
+
if (crudMatch >= 3) return "crud";
|
|
1569
|
+
const stepCount = names.filter((n) => STEP_PATTERN.test(n)).length;
|
|
1570
|
+
if (stepCount >= 2) return "wizard";
|
|
1571
|
+
const hasTerminal = states.some((s) => s.isTerminal || s.isFinal);
|
|
1572
|
+
const hasComplete = names.some(
|
|
1573
|
+
(n) => n === "complete" || n === "completed" || n === "done" || n === "finished"
|
|
1574
|
+
);
|
|
1575
|
+
if ((hasTerminal || hasComplete) && states.length >= 4 && crudMatch <= 1) {
|
|
1576
|
+
return "wizard";
|
|
1577
|
+
}
|
|
1578
|
+
return "custom";
|
|
1579
|
+
}
|
|
1580
|
+
function isPrimaryKey(field) {
|
|
1581
|
+
return field.primaryKey === true;
|
|
1582
|
+
}
|
|
1583
|
+
function isBusinessField(field) {
|
|
1584
|
+
if (isPrimaryKey(field)) return false;
|
|
1585
|
+
if (field.type === "enum" || field.type === "relation") return true;
|
|
1586
|
+
if (field.required) return true;
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
function summarizeEntity(entity) {
|
|
1590
|
+
const fields = entity.fields.filter(isBusinessField).map((f) => {
|
|
1591
|
+
const summary = { name: f.name, type: f.type };
|
|
1592
|
+
if (f.required) summary.required = true;
|
|
1593
|
+
if (f.type === "enum" && f.values) summary.values = f.values;
|
|
1594
|
+
if (f.type === "relation" && f.relation) summary.relation = f.relation;
|
|
1595
|
+
return summary;
|
|
1596
|
+
});
|
|
1597
|
+
return {
|
|
1598
|
+
name: entity.name,
|
|
1599
|
+
collection: entity.collection,
|
|
1600
|
+
fields
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
function summarizeTransitions(transitions) {
|
|
1604
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1605
|
+
const result = [];
|
|
1606
|
+
for (const t of transitions) {
|
|
1607
|
+
const key = `${t.from}::${t.to}::${t.event}`;
|
|
1608
|
+
if (!seen.has(key)) {
|
|
1609
|
+
seen.add(key);
|
|
1610
|
+
result.push({ from: t.from, to: t.to, event: t.event });
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
return result;
|
|
1614
|
+
}
|
|
1615
|
+
function summarizeEvents(events) {
|
|
1616
|
+
return events.map((e) => ({ key: e.key, name: e.key }));
|
|
1617
|
+
}
|
|
1618
|
+
function summarizeTrait(trait) {
|
|
1619
|
+
const states = trait.stateMachine?.states ?? [];
|
|
1620
|
+
const events = trait.stateMachine?.events ?? [];
|
|
1621
|
+
const transitions = trait.stateMachine?.transitions ?? [];
|
|
1622
|
+
const result = { name: trait.name };
|
|
1623
|
+
if (trait.category) result.category = trait.category;
|
|
1624
|
+
if (trait.linkedEntity) result.linkedEntity = trait.linkedEntity;
|
|
1625
|
+
if (trait.stateMachine) {
|
|
1626
|
+
result.stateMachine = {
|
|
1627
|
+
states: states.map((s) => {
|
|
1628
|
+
const st = { name: s.name };
|
|
1629
|
+
if (s.isInitial) st.isInitial = true;
|
|
1630
|
+
if (s.isTerminal) st.isTerminal = true;
|
|
1631
|
+
if (s.isFinal) st.isFinal = true;
|
|
1632
|
+
return st;
|
|
1633
|
+
}),
|
|
1634
|
+
events: summarizeEvents(events),
|
|
1635
|
+
transitions: summarizeTransitions(transitions)
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
if (trait.emits && trait.emits.length > 0) {
|
|
1639
|
+
result.emits = trait.emits.map((e) => ({
|
|
1640
|
+
event: e.event,
|
|
1641
|
+
...e.scope ? { scope: e.scope } : {}
|
|
1642
|
+
}));
|
|
1643
|
+
}
|
|
1644
|
+
if (trait.listens && trait.listens.length > 0) {
|
|
1645
|
+
result.listens = trait.listens.map((l) => ({
|
|
1646
|
+
event: l.event,
|
|
1647
|
+
triggers: l.triggers,
|
|
1648
|
+
...l.scope ? { scope: l.scope } : {}
|
|
1649
|
+
}));
|
|
1650
|
+
}
|
|
1651
|
+
return result;
|
|
1652
|
+
}
|
|
1653
|
+
function summarizePage(page) {
|
|
1654
|
+
const result = { name: page.name, path: page.path };
|
|
1655
|
+
if (page.traits && page.traits.length > 0) {
|
|
1656
|
+
result.traits = page.traits.map((t) => ({ ref: t.ref }));
|
|
1657
|
+
}
|
|
1658
|
+
return result;
|
|
1659
|
+
}
|
|
1660
|
+
function summarizeOrbital(orbital) {
|
|
1661
|
+
let entity;
|
|
1662
|
+
if (isEntityReference(orbital.entity)) {
|
|
1663
|
+
entity = { name: orbital.entity, fields: [] };
|
|
1664
|
+
} else {
|
|
1665
|
+
entity = summarizeEntity(orbital.entity);
|
|
1666
|
+
}
|
|
1667
|
+
const traits = orbital.traits.map((traitRef) => {
|
|
1668
|
+
if (isInlineTrait(traitRef)) {
|
|
1669
|
+
return summarizeTrait(traitRef);
|
|
1670
|
+
}
|
|
1671
|
+
return traitRef;
|
|
1672
|
+
});
|
|
1673
|
+
const pages = orbital.pages.filter((p) => typeof p === "object" && "name" in p && !("ref" in p)).map(summarizePage);
|
|
1674
|
+
return { name: orbital.name, entity, traits, pages };
|
|
1675
|
+
}
|
|
1676
|
+
function summarizeSchema(schema) {
|
|
1677
|
+
return {
|
|
1678
|
+
name: schema.name,
|
|
1679
|
+
description: schema.description,
|
|
1680
|
+
version: schema.version,
|
|
1681
|
+
orbitals: schema.orbitals.map(summarizeOrbital)
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1547
1685
|
// src/domain-language/tokens.ts
|
|
1548
1686
|
var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
1549
1687
|
TokenType2["NEWLINE"] = "NEWLINE";
|
|
@@ -7381,6 +7519,160 @@ function getRegistryStats() {
|
|
|
7381
7519
|
};
|
|
7382
7520
|
}
|
|
7383
7521
|
|
|
7384
|
-
|
|
7522
|
+
// src/domain-language/domain-language-reference.ts
|
|
7523
|
+
function generateDomainLanguageReference() {
|
|
7524
|
+
const lines = [];
|
|
7525
|
+
const stats = getRegistryStats();
|
|
7526
|
+
lines.push("# Domain Language Reference");
|
|
7527
|
+
lines.push("");
|
|
7528
|
+
lines.push("> Auto-generated from type registry");
|
|
7529
|
+
lines.push(`> Last updated: ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`);
|
|
7530
|
+
lines.push("");
|
|
7531
|
+
lines.push("This document describes the Domain Language syntax that maps to OrbitalSchema.");
|
|
7532
|
+
lines.push("Domain Language is a human-readable format that is converted to/from OrbitalSchema JSON.");
|
|
7533
|
+
lines.push("");
|
|
7534
|
+
lines.push("## Table of Contents");
|
|
7535
|
+
lines.push("");
|
|
7536
|
+
lines.push("- [Field Types](#field-types)");
|
|
7537
|
+
lines.push("- [Effects](#effects)");
|
|
7538
|
+
lines.push("- [Guards](#guards)");
|
|
7539
|
+
lines.push("- [UI Slots](#ui-slots)");
|
|
7540
|
+
lines.push("- [Bindings](#bindings)");
|
|
7541
|
+
lines.push("- [Statistics](#statistics)");
|
|
7542
|
+
lines.push("");
|
|
7543
|
+
lines.push("## Field Types");
|
|
7544
|
+
lines.push("");
|
|
7545
|
+
lines.push("| Schema Type | Domain Keywords | Description |");
|
|
7546
|
+
lines.push("|-------------|-----------------|-------------|");
|
|
7547
|
+
for (const [type, mapping] of Object.entries(FIELD_TYPE_REGISTRY)) {
|
|
7548
|
+
const keywords = mapping.domainKeywords.map((k) => `\`${k}\``).join(", ");
|
|
7549
|
+
lines.push(`| \`${type}\` | ${keywords} | - |`);
|
|
7550
|
+
}
|
|
7551
|
+
lines.push("");
|
|
7552
|
+
lines.push("## Effects");
|
|
7553
|
+
lines.push("");
|
|
7554
|
+
lines.push("Effects are actions that occur during state transitions.");
|
|
7555
|
+
lines.push("In Domain Language, they are written as human-readable statements.");
|
|
7556
|
+
lines.push("The `domain:to-schema` converter translates them to S-Expression arrays.");
|
|
7557
|
+
lines.push("");
|
|
7558
|
+
lines.push("| Operator | Domain Patterns | Description |");
|
|
7559
|
+
lines.push("|----------|-----------------|-------------|");
|
|
7560
|
+
for (const [op, mapping] of Object.entries(EFFECT_REGISTRY)) {
|
|
7561
|
+
const patterns = mapping.domainPatterns.map((p) => `\`${p}\``).join(", ");
|
|
7562
|
+
lines.push(`| \`${op}\` | ${patterns} | ${mapping.description} |`);
|
|
7563
|
+
}
|
|
7564
|
+
lines.push("");
|
|
7565
|
+
lines.push("### Effect Examples");
|
|
7566
|
+
lines.push("");
|
|
7567
|
+
lines.push("```");
|
|
7568
|
+
lines.push("# Update a field");
|
|
7569
|
+
lines.push("then update status to 'done'");
|
|
7570
|
+
lines.push("");
|
|
7571
|
+
lines.push("# Emit an event");
|
|
7572
|
+
lines.push("then emit TASK_COMPLETED");
|
|
7573
|
+
lines.push("then emit ORDER_PLACED with orderId");
|
|
7574
|
+
lines.push("");
|
|
7575
|
+
lines.push("# Render UI");
|
|
7576
|
+
lines.push("then render entity-table to main for Task");
|
|
7577
|
+
lines.push("then render form-section to modal for Order");
|
|
7578
|
+
lines.push("then render null to modal");
|
|
7579
|
+
lines.push("");
|
|
7580
|
+
lines.push("# Navigation");
|
|
7581
|
+
lines.push("then navigate to /tasks");
|
|
7582
|
+
lines.push("");
|
|
7583
|
+
lines.push("# Database");
|
|
7584
|
+
lines.push("then persist create Task");
|
|
7585
|
+
lines.push("then persist update Order");
|
|
7586
|
+
lines.push("then persist delete Item");
|
|
7587
|
+
lines.push("");
|
|
7588
|
+
lines.push("# External services");
|
|
7589
|
+
lines.push("then call stripe.charge with amount");
|
|
7590
|
+
lines.push("");
|
|
7591
|
+
lines.push("# Game effects");
|
|
7592
|
+
lines.push("then spawn Bullet at Player's position");
|
|
7593
|
+
lines.push("then despawn");
|
|
7594
|
+
lines.push("");
|
|
7595
|
+
lines.push("# Notifications");
|
|
7596
|
+
lines.push("then show success notification 'Saved!'");
|
|
7597
|
+
lines.push("```");
|
|
7598
|
+
lines.push("");
|
|
7599
|
+
lines.push("## Guards");
|
|
7600
|
+
lines.push("");
|
|
7601
|
+
lines.push("Guards are conditions that must be true for a transition to occur.");
|
|
7602
|
+
lines.push("");
|
|
7603
|
+
lines.push("| Operator | Domain Patterns | Description |");
|
|
7604
|
+
lines.push("|----------|-----------------|-------------|");
|
|
7605
|
+
for (const [op, mapping] of Object.entries(GUARD_REGISTRY)) {
|
|
7606
|
+
const patterns = mapping.domainPatterns.map((p) => `\`${p}\``).join(", ");
|
|
7607
|
+
lines.push(`| \`${op}\` | ${patterns} | ${mapping.description} |`);
|
|
7608
|
+
}
|
|
7609
|
+
lines.push("");
|
|
7610
|
+
lines.push("### Guard Examples");
|
|
7611
|
+
lines.push("");
|
|
7612
|
+
lines.push("```");
|
|
7613
|
+
lines.push("# Comparison guards");
|
|
7614
|
+
lines.push("if status is 'active'");
|
|
7615
|
+
lines.push("if amount > 100");
|
|
7616
|
+
lines.push("if health is at least 0");
|
|
7617
|
+
lines.push("if priority <= 3");
|
|
7618
|
+
lines.push("");
|
|
7619
|
+
lines.push("# Compound guards");
|
|
7620
|
+
lines.push("if health >= 30 and health < 70");
|
|
7621
|
+
lines.push("if status is 'active' or status is 'pending'");
|
|
7622
|
+
lines.push("if status is not 'deleted'");
|
|
7623
|
+
lines.push("");
|
|
7624
|
+
lines.push("# Payload checks");
|
|
7625
|
+
lines.push("if incoming amount > 0");
|
|
7626
|
+
lines.push("```");
|
|
7627
|
+
lines.push("");
|
|
7628
|
+
lines.push("## UI Slots");
|
|
7629
|
+
lines.push("");
|
|
7630
|
+
lines.push("UI slots are named regions where patterns can be rendered.");
|
|
7631
|
+
lines.push("");
|
|
7632
|
+
lines.push("| Slot | Description |");
|
|
7633
|
+
lines.push("|------|-------------|");
|
|
7634
|
+
const slotDescriptions = {
|
|
7635
|
+
"main": "Primary content area",
|
|
7636
|
+
"sidebar": "Side navigation or secondary content",
|
|
7637
|
+
"modal": "Modal dialog overlay",
|
|
7638
|
+
"drawer": "Slide-out panel",
|
|
7639
|
+
"overlay": "Full-screen overlay",
|
|
7640
|
+
"center": "Centered content area",
|
|
7641
|
+
"toast": "Toast notifications",
|
|
7642
|
+
"hud-top": "Top HUD (games)",
|
|
7643
|
+
"hud-bottom": "Bottom HUD (games)",
|
|
7644
|
+
"floating": "Floating elements",
|
|
7645
|
+
"system": "System components (invisible)"
|
|
7646
|
+
};
|
|
7647
|
+
for (const slot of UI_SLOTS2) {
|
|
7648
|
+
const desc = slotDescriptions[slot] || "-";
|
|
7649
|
+
lines.push(`| \`${slot}\` | ${desc} |`);
|
|
7650
|
+
}
|
|
7651
|
+
lines.push("");
|
|
7652
|
+
lines.push("## Bindings");
|
|
7653
|
+
lines.push("");
|
|
7654
|
+
lines.push("Bindings reference data in S-Expression context.");
|
|
7655
|
+
lines.push("In Domain Language, these are expressed more naturally.");
|
|
7656
|
+
lines.push("");
|
|
7657
|
+
lines.push("| S-Expression | Domain Language |");
|
|
7658
|
+
lines.push("|--------------|-----------------|");
|
|
7659
|
+
lines.push("| `@entity.field` | `field` or `Entity's field` |");
|
|
7660
|
+
lines.push("| `@payload.field` | `incoming field` |");
|
|
7661
|
+
lines.push("| `@state` | `current state` |");
|
|
7662
|
+
lines.push("| `@now` | `now` |");
|
|
7663
|
+
lines.push("");
|
|
7664
|
+
lines.push("## Statistics");
|
|
7665
|
+
lines.push("");
|
|
7666
|
+
lines.push("| Category | Count |");
|
|
7667
|
+
lines.push("|----------|-------|");
|
|
7668
|
+
lines.push(`| Field Types | ${stats.fieldTypes} |`);
|
|
7669
|
+
lines.push(`| Effects | ${stats.effects} |`);
|
|
7670
|
+
lines.push(`| Guards | ${stats.guards} |`);
|
|
7671
|
+
lines.push(`| UI Slots | ${stats.uiSlots} |`);
|
|
7672
|
+
lines.push("");
|
|
7673
|
+
return lines.join("\n");
|
|
7674
|
+
}
|
|
7675
|
+
|
|
7676
|
+
export { AGENT_DOMAIN_CATEGORIES, ALLOWED_CUSTOM_COMPONENTS, AgentDomainCategorySchema, AnimationDefSchema, AssetMapSchema, AssetMappingSchema, BINDING_CONTEXT_RULES, BINDING_DOCS, BindingSchema, CORE_BINDINGS, ComputedEventContractSchema, ComputedEventListenerSchema, CustomPatternDefinitionSchema, CustomPatternMapSchema, DEFAULT_INTERACTION_MODELS, DesignPreferencesSchema, DesignTokensSchema, DomainCategorySchema, DomainContextSchema, DomainVocabularySchema, EFFECT_REGISTRY, ENTITY_ROLES, EffectSchema, EntityFieldSchema, EntityPersistenceSchema, EntityRefSchema, EntityRefStringSchema, EntityRoleSchema, EntitySchema, EntitySemanticRoleSchema, EventListenerSchema, EventPayloadFieldSchema, EventSchema, EventScopeSchema, EventSemanticRoleSchema, EventSourceSchema, ExpressionSchema, FIELD_TYPE_REGISTRY, FieldFormatSchema, FieldSchema, FieldTypeSchema, GAME_TYPES, GUARD_REGISTRY, GameSubCategorySchema, GameTypeSchema, GuardSchema, InteractionModelSchema, KEYWORDS, Lexer, MULTI_WORD_KEYWORDS, McpServiceDefSchema, NodeClassificationSchema, OrbitalConfigSchema, OrbitalDefinitionSchema, OrbitalEntitySchema, OrbitalPageSchema, OrbitalPageStrictSchema, OrbitalSchemaSchema, OrbitalTraitRefSchema, OrbitalUnitSchema, OrbitalSchema as OrbitalZodSchema, PageRefObjectSchema, PageRefSchema, PageRefStringSchema, PageSchema, PageTraitRefSchema, PatternTypeSchema, PayloadFieldSchema, RelatedLinkSchema, RelationConfigSchema, RequiredFieldSchema, ResolvedAssetSchema, RestAuthConfigSchema, RestServiceDefSchema, SERVICE_TYPES, SExprAtomSchema, SExprSchema, SemanticAssetRefSchema, ServiceDefinitionSchema, ServiceRefSchema, ServiceRefStringSchema, ServiceTypeSchema, SocketEventsSchema, SocketServiceDefSchema, StateMachineSchema, StateSchema, StateSemanticRoleSchema, SuggestedGuardSchema, ThemeDefinitionSchema, ThemeRefSchema, ThemeRefStringSchema, ThemeTokensSchema, ThemeVariantSchema, TokenType, TraitCategorySchema, TraitDataEntitySchema, TraitEntityFieldSchema, TraitEventContractSchema, TraitEventListenerSchema, TraitRefSchema, TraitReferenceSchema, TraitSchema, TraitTickSchema, TransitionSchema, UISlotSchema, UI_SLOTS, UXHintsSchema, UseDeclarationSchema, UserPersonaSchema, VISUAL_STYLES, ViewTypeSchema, VisualStyleSchema, applySectionUpdate, callService, categorizeRemovals, classifyWorkflow, clearSchemaCache, collectBindings, computeSchemaHash, convertDomainToSchema, convertEntitiesToDomain, convertPagesToDomain, convertSchemaToDomain, convertTraitsToDomain, createAssetKey, createEmptyResolvedPage, createEmptyResolvedTrait, createMappingStore, createResolvedField, deleteSection, deriveCollection, despawn, detectChanges, detectPageContentReduction, diffSchemas, doEffects, domainKeywordToSchemaType, emit, findMapping, findMappingByPath, findMappingsByType, findService, formatBehaviorToDomain, formatBehaviorToSchema, formatDomainGuardToSchema, formatEntityToDomain, formatEntityToSchema, formatGuardConditionToDomain, formatGuardToDomain, formatGuardToSchema, formatMergeSummary, formatPageToDomain, formatPageToSchema, formatSchemaEntityToDomain, formatSchemaGuardToDomain, formatSchemaPageToDomain, formatSchemaTraitToDomain, generateDomainLanguageReference, generateSectionId, getAllOperators, getAllPatternTypes, getArgs, getBindingExamples, getDefaultAnimationsForRole, getEffectMapping, getEntity, getFieldTypeMapping, getGuardMapping, getInteractionModelForDomain, getOperator, getPage, getPages, getRegisteredEffects, getRegisteredFieldTypes, getRegisteredGuards, getRegistryStats, getRemovals, getSchemaCacheStats, getSchemaPath, getServiceNames, getTrait, getTraitConfig, getTraitName, hasSchemaChanged, hasService, hasSignificantPageReduction, inferTsType, isBinding, isCircuitEvent, isDestructiveChange, isEffect, isEffectRegistered, isEntityReference, isFieldTypeRegistered, isGuardRegistered, isImportedTraitRef, isInlineTrait, isMcpService, isOrbitalDefinition, isPageReference, isPageReferenceObject, isPageReferenceString, isResolvedIR, isRestService, isRuntimeEntity, isSExpr, isSExprAtom, isSExprCall, isSExprEffect, isServiceReference, isSingletonEntity, isSocketService, isThemeReference, isValidBinding, mergeDomainChunks, navigate, normalizeTraitRef, notify, parseAssetKey, parseBehavior, parseBinding, parseDomainEffect, parseDomainEffects, parseDomainGuard, parseEntity, parseEntityRef, parseGuard, parseImportedTraitRef, parseOrbitalSchema, parsePage, parsePageRef, parseSectionId, parseServiceRef, persist, removeMapping, renderUI, requiresConfirmation, resolveConflict, safeParseOrbitalSchema, schemaEntityToDomainEntity, schemaPageToDomainPage, schemaToIR, schemaTraitToDomainBehavior, schemaTypeToDomainKeyword, set, sexpr, spawn, summarizeOrbital, summarizeSchema, tokenize, updateMappingRange, updateSchemaHash, upsertMapping, validateAssetAnimations, validateBindingInContext, validateDomainChunk, walkSExpr };
|
|
7385
7677
|
//# sourceMappingURL=index.js.map
|
|
7386
7678
|
//# sourceMappingURL=index.js.map
|