@almadar/core 2.5.1 → 2.5.2
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/dist/builders.d.ts +2 -2
- package/dist/builders.js.map +1 -1
- package/dist/{compose-behaviors-ClEyviUI.d.ts → compose-behaviors-CnJ5Hn4p.d.ts} +1 -1
- package/dist/domain-language/index.d.ts +1 -1
- package/dist/domain-language/index.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js.map +1 -1
- package/dist/{schema-DmrHbrqM.d.ts → schema-obC5T1Jm.d.ts} +219 -28
- package/dist/state-machine/index.d.ts +14 -3
- package/dist/state-machine/index.js.map +1 -1
- package/dist/types/index.d.ts +90 -4
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -63,17 +63,52 @@ declare const ExpressionSchema: z.ZodType<Expression>;
|
|
|
63
63
|
declare function isSExpr(value: unknown): value is SExpr[];
|
|
64
64
|
/**
|
|
65
65
|
* Type guard for S-expression atoms (non-array values).
|
|
66
|
-
*
|
|
66
|
+
*
|
|
67
|
+
* Validates that a value is an S-expression atom (literal value).
|
|
68
|
+
* Includes null, strings, numbers, booleans, and objects. Used to
|
|
69
|
+
* distinguish atomic values from S-expression calls (arrays).
|
|
70
|
+
*
|
|
71
|
+
* @param {unknown} value - Value to check
|
|
72
|
+
* @returns {boolean} True if value is an S-expression atom, false otherwise
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* isSExprAtom('hello'); // returns true
|
|
76
|
+
* isSExprAtom(42); // returns true
|
|
77
|
+
* isSExprAtom(null); // returns true
|
|
78
|
+
* isSExprAtom({ key: 'value' }); // returns true
|
|
79
|
+
* isSExprAtom(['+', 1, 2]); // returns false
|
|
67
80
|
*/
|
|
68
81
|
declare function isSExprAtom(value: unknown): value is SExprAtom;
|
|
69
82
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
83
|
+
* Checks if a value is a binding reference.
|
|
84
|
+
*
|
|
85
|
+
* Validates that a string is a binding reference (starts with @).
|
|
86
|
+
* Bindings reference runtime values like @entity.health, @payload.amount, @now.
|
|
87
|
+
* Used for identifying bindings in S-expressions and validation.
|
|
88
|
+
*
|
|
89
|
+
* @param {unknown} value - Value to check
|
|
90
|
+
* @returns {boolean} True if value is a binding reference, false otherwise
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* isBinding('@entity.health'); // returns true
|
|
94
|
+
* isBinding('@payload.amount'); // returns true
|
|
95
|
+
* isBinding('not-a-binding'); // returns false
|
|
96
|
+
* isBinding(123); // returns false
|
|
72
97
|
*/
|
|
73
98
|
declare function isBinding(value: unknown): value is string;
|
|
74
99
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
100
|
+
* Checks if a value is a valid S-expression call (array with operator).
|
|
101
|
+
*
|
|
102
|
+
* Alias for isSExpr() - validates S-expression call structure.
|
|
103
|
+
* Used to distinguish between S-expression calls and atom values.
|
|
104
|
+
*
|
|
105
|
+
* @param {unknown} value - Value to check
|
|
106
|
+
* @returns {boolean} True if value is a valid S-expression call, false otherwise
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* isSExprCall(['+', 1, 2]); // returns true
|
|
110
|
+
* isSExprCall(['set', '@entity.health', 100]); // returns true
|
|
111
|
+
* isSExprCall('not-a-call'); // returns false
|
|
77
112
|
*/
|
|
78
113
|
declare function isSExprCall(value: unknown): value is SExpr[];
|
|
79
114
|
/**
|
|
@@ -96,11 +131,19 @@ interface ParsedBinding {
|
|
|
96
131
|
declare const CORE_BINDINGS: readonly ["entity", "payload", "state", "now", "config", "computed", "trait"];
|
|
97
132
|
type CoreBinding = (typeof CORE_BINDINGS)[number];
|
|
98
133
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
134
|
+
* Parses a binding reference into its components.
|
|
135
|
+
*
|
|
136
|
+
* Deconstructs a binding string (e.g., '@entity.health') into its constituent
|
|
137
|
+
* parts: type, root, path, and original string. Does NOT use regex - uses
|
|
138
|
+
* structured string operations for reliability and maintainability.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} binding - Binding string starting with @
|
|
141
|
+
* @returns {ParsedBinding | null} Parsed binding object or null if invalid
|
|
101
142
|
*
|
|
102
|
-
* @
|
|
103
|
-
* @returns
|
|
143
|
+
* @example
|
|
144
|
+
* parseBinding('@entity.health'); // returns { type: 'core', root: 'entity', path: ['health'], original: '@entity.health' }
|
|
145
|
+
* parseBinding('@User.name'); // returns { type: 'entity', root: 'User', path: ['name'], original: '@User.name' }
|
|
146
|
+
* parseBinding('not-a-binding'); // returns null
|
|
104
147
|
*/
|
|
105
148
|
declare function parseBinding(binding: string): ParsedBinding | null;
|
|
106
149
|
/**
|
|
@@ -569,22 +612,65 @@ type AssetMappingInput = z.input<typeof AssetMappingSchema>;
|
|
|
569
612
|
type AssetMapInput = z.input<typeof AssetMapSchema>;
|
|
570
613
|
type AnimationDefInput = z.input<typeof AnimationDefSchema>;
|
|
571
614
|
/**
|
|
572
|
-
*
|
|
615
|
+
* Creates a semantic asset key from role and category.
|
|
616
|
+
*
|
|
617
|
+
* Generates a unique asset identifier by combining role and category
|
|
618
|
+
* with a colon separator. Used for asset management and lookup.
|
|
619
|
+
*
|
|
620
|
+
* @param {EntityRole} role - Entity role (e.g., 'player', 'enemy')
|
|
621
|
+
* @param {string} category - Asset category (e.g., 'sprite', 'animation')
|
|
622
|
+
* @returns {string} Asset key in format 'role:category'
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* createAssetKey('player', 'sprite'); // returns 'player:sprite'
|
|
626
|
+
* createAssetKey('enemy', 'animation'); // returns 'enemy:animation'
|
|
573
627
|
*/
|
|
574
628
|
declare function createAssetKey(role: EntityRole, category: string): string;
|
|
575
629
|
/**
|
|
576
|
-
*
|
|
630
|
+
* Parses an asset key into role and category components.
|
|
631
|
+
*
|
|
632
|
+
* Deconstructs an asset key string (format 'role:category') into its
|
|
633
|
+
* constituent parts. Returns null if the key format is invalid.
|
|
634
|
+
*
|
|
635
|
+
* @param {string} key - Asset key in format 'role:category'
|
|
636
|
+
* @returns {{ role: string; category: string } | null} Parsed components or null
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* parseAssetKey('player:sprite'); // returns { role: 'player', category: 'sprite' }
|
|
640
|
+
* parseAssetKey('enemy:animation'); // returns { role: 'enemy', category: 'animation' }
|
|
641
|
+
* parseAssetKey('invalid'); // returns null
|
|
577
642
|
*/
|
|
578
643
|
declare function parseAssetKey(key: string): {
|
|
579
644
|
role: string;
|
|
580
645
|
category: string;
|
|
581
646
|
} | null;
|
|
582
647
|
/**
|
|
583
|
-
*
|
|
648
|
+
* Gets common animations for an entity role.
|
|
649
|
+
*
|
|
650
|
+
* Returns an array of default animation names appropriate for the
|
|
651
|
+
* specified entity role. Used for asset configuration and validation.
|
|
652
|
+
*
|
|
653
|
+
* @param {EntityRole} role - Entity role
|
|
654
|
+
* @returns {string[]} Array of default animation names
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* getDefaultAnimationsForRole('player'); // returns ['idle', 'run', 'jump', 'fall', 'attack', 'hurt', 'die']
|
|
658
|
+
* getDefaultAnimationsForRole('enemy'); // returns ['idle', 'walk', 'attack', 'hurt', 'die']
|
|
584
659
|
*/
|
|
585
660
|
declare function getDefaultAnimationsForRole(role: EntityRole): string[];
|
|
586
661
|
/**
|
|
587
|
-
*
|
|
662
|
+
* Validates that an asset reference has required animations.
|
|
663
|
+
*
|
|
664
|
+
* Checks if an asset reference contains all required animations.
|
|
665
|
+
* Returns an error message if validation fails, or null if valid.
|
|
666
|
+
*
|
|
667
|
+
* @param {SemanticAssetRef} assetRef - Asset reference to validate
|
|
668
|
+
* @param {string[]} requiredAnimations - Required animation names
|
|
669
|
+
* @returns {string | null} Error message or null if valid
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* validateAssetAnimations(assetRef, ['idle', 'run']); // returns null if valid
|
|
673
|
+
* validateAssetAnimations(assetRef, ['missing-animation']); // returns error message
|
|
588
674
|
*/
|
|
589
675
|
declare function validateAssetAnimations(assetRef: SemanticAssetRef, requiredAnimations: string[]): {
|
|
590
676
|
valid: boolean;
|
|
@@ -1229,6 +1315,19 @@ declare const EffectSchema: z.ZodEffects<z.ZodArray<z.ZodUnknown, "many">, unkno
|
|
|
1229
1315
|
type EffectInput = z.input<typeof EffectSchema>;
|
|
1230
1316
|
/**
|
|
1231
1317
|
* Type guard to check if a value is a valid Effect (S-expression).
|
|
1318
|
+
*
|
|
1319
|
+
* Validates that a value conforms to the Effect structure. Effects are
|
|
1320
|
+
* represented as arrays where the first element is a string (effect type)
|
|
1321
|
+
* and subsequent elements are parameters. Used for runtime validation
|
|
1322
|
+
* of effect structures.
|
|
1323
|
+
*
|
|
1324
|
+
* @param {unknown} value - Value to check
|
|
1325
|
+
* @returns {boolean} True if value is a valid Effect, false otherwise
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* isEffect(['set', '@entity.health', 100]); // returns true
|
|
1329
|
+
* isEffect('not-an-effect'); // returns false
|
|
1330
|
+
* isEffect([]); // returns false
|
|
1232
1331
|
*/
|
|
1233
1332
|
declare function isEffect(value: unknown): value is Effect;
|
|
1234
1333
|
/**
|
|
@@ -1236,18 +1335,51 @@ declare function isEffect(value: unknown): value is Effect;
|
|
|
1236
1335
|
*/
|
|
1237
1336
|
declare const isSExprEffect: typeof isEffect;
|
|
1238
1337
|
/**
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1338
|
+
* Creates a set effect for state updates.
|
|
1339
|
+
*
|
|
1340
|
+
* Generates an effect that sets a binding to a value. Used in state
|
|
1341
|
+
* machine transitions to update entity fields, UI state, or other
|
|
1342
|
+
* mutable data.
|
|
1343
|
+
*
|
|
1344
|
+
* @param {string} binding - Target binding (e.g., '@entity.health')
|
|
1345
|
+
* @param {SExpr} value - Value to set (can be literal or expression)
|
|
1346
|
+
* @returns {Effect} Set effect array
|
|
1347
|
+
*
|
|
1348
|
+
* @example
|
|
1349
|
+
* set('@entity.health', 100); // returns ["set", "@entity.health", 100]
|
|
1350
|
+
* set('@state.loading', false); // returns ["set", "@state.loading", false]
|
|
1241
1351
|
*/
|
|
1242
1352
|
declare function set(binding: string, value: SExpr): Effect;
|
|
1243
1353
|
/**
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1354
|
+
* Creates an emit effect for event dispatching.
|
|
1355
|
+
*
|
|
1356
|
+
* Generates an effect that emits an event with optional payload.
|
|
1357
|
+
* Used in state machine transitions to trigger events that can be
|
|
1358
|
+
* handled by other traits, services, or external systems.
|
|
1359
|
+
*
|
|
1360
|
+
* @param {string} event - Event name to emit
|
|
1361
|
+
* @param {Record<string, unknown>} [payload] - Optional event payload
|
|
1362
|
+
* @returns {Effect} Emit effect array
|
|
1363
|
+
*
|
|
1364
|
+
* @example
|
|
1365
|
+
* emit('PLAYER_DIED', { playerId: '@entity.id' }); // returns ["emit", "PLAYER_DIED", { playerId: "@entity.id" }]
|
|
1366
|
+
* emit('GAME_STARTED'); // returns ["emit", "GAME_STARTED"]
|
|
1246
1367
|
*/
|
|
1247
1368
|
declare function emit(event: string, payload?: Record<string, unknown>): Effect;
|
|
1248
1369
|
/**
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1370
|
+
* Creates a navigation effect for page routing.
|
|
1371
|
+
*
|
|
1372
|
+
* Generates an effect that navigates to a specified path with optional
|
|
1373
|
+
* parameters. Used in state machine transitions to change pages or
|
|
1374
|
+
* update URL parameters.
|
|
1375
|
+
*
|
|
1376
|
+
* @param {string} path - Target path (e.g., '/tasks')
|
|
1377
|
+
* @param {Record<string, string>} [params] - Optional URL parameters
|
|
1378
|
+
* @returns {NavigateEffect} Navigation effect array
|
|
1379
|
+
*
|
|
1380
|
+
* @example
|
|
1381
|
+
* navigate('/tasks'); // returns ["navigate", "/tasks"]
|
|
1382
|
+
* navigate('/user', { id: '123' }); // returns ["navigate", "/user", { id: "123" }]
|
|
1251
1383
|
*/
|
|
1252
1384
|
declare function navigate(path: string): NavigateEffect;
|
|
1253
1385
|
declare function navigate(path: string, params: Record<string, string>): NavigateEffect;
|
|
@@ -1694,8 +1826,8 @@ type StateMachineInput = z.input<typeof StateMachineSchema>;
|
|
|
1694
1826
|
* Circuit events are user-defined events that participate in the closed circuit pattern.
|
|
1695
1827
|
* Internal/system events start with underscore (e.g., _INIT, _TICK, _TIMER).
|
|
1696
1828
|
*
|
|
1697
|
-
* @param event - Event name to check
|
|
1698
|
-
* @returns true if event is a circuit event (doesn't start with underscore)
|
|
1829
|
+
* @param {string} event - Event name to check
|
|
1830
|
+
* @returns {boolean} true if event is a circuit event (doesn't start with underscore)
|
|
1699
1831
|
*
|
|
1700
1832
|
* @example
|
|
1701
1833
|
* isCircuitEvent('CREATE') // true
|
|
@@ -4359,7 +4491,17 @@ declare const ThemeDefinitionSchema: z.ZodObject<{
|
|
|
4359
4491
|
*/
|
|
4360
4492
|
type ThemeRef = ThemeDefinition | string;
|
|
4361
4493
|
/**
|
|
4362
|
-
*
|
|
4494
|
+
* Checks if a theme reference is a string.
|
|
4495
|
+
*
|
|
4496
|
+
* Type guard to determine if a theme reference is a string reference
|
|
4497
|
+
* (format: "Alias.theme") rather than an inline theme definition.
|
|
4498
|
+
*
|
|
4499
|
+
* @param {ThemeRef} theme - Theme reference to check
|
|
4500
|
+
* @returns {boolean} True if theme is a string reference, false otherwise
|
|
4501
|
+
*
|
|
4502
|
+
* @example
|
|
4503
|
+
* isThemeReference("Ocean.theme"); // returns true
|
|
4504
|
+
* isThemeReference({ name: "ocean", colors: {...} }); // returns false
|
|
4363
4505
|
*/
|
|
4364
4506
|
declare function isThemeReference(theme: ThemeRef): theme is string;
|
|
4365
4507
|
/**
|
|
@@ -4961,7 +5103,17 @@ declare const ServiceDefinitionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
4961
5103
|
*/
|
|
4962
5104
|
type ServiceRef = ServiceDefinition | string;
|
|
4963
5105
|
/**
|
|
4964
|
-
*
|
|
5106
|
+
* Checks if a service reference is a string.
|
|
5107
|
+
*
|
|
5108
|
+
* Type guard to determine if a service reference is a string reference
|
|
5109
|
+
* (format: "Alias.services.ServiceName") rather than an inline service definition.
|
|
5110
|
+
*
|
|
5111
|
+
* @param {ServiceRef} service - Service reference to check
|
|
5112
|
+
* @returns {boolean} True if service is a string reference, false otherwise
|
|
5113
|
+
*
|
|
5114
|
+
* @example
|
|
5115
|
+
* isServiceReference("Weather.services.openweather"); // returns true
|
|
5116
|
+
* isServiceReference({ name: "weather", type: "rest" }); // returns false
|
|
4965
5117
|
*/
|
|
4966
5118
|
declare function isServiceReference(service: ServiceRef): service is string;
|
|
4967
5119
|
/**
|
|
@@ -5096,23 +5248,62 @@ declare const ServiceRefSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.Z
|
|
|
5096
5248
|
env?: Record<string, string> | undefined;
|
|
5097
5249
|
}>]>, z.ZodString]>;
|
|
5098
5250
|
/**
|
|
5099
|
-
*
|
|
5100
|
-
*
|
|
5251
|
+
* Parses a service reference into its components.
|
|
5252
|
+
*
|
|
5253
|
+
* Extracts the alias and service name from a service reference string
|
|
5254
|
+
* in format "Alias.services.ServiceName". Returns null if not a valid reference.
|
|
5255
|
+
*
|
|
5256
|
+
* @param {string} ref - Service reference string
|
|
5257
|
+
* @returns {{ alias: string; serviceName: string } | null} Parsed components or null
|
|
5258
|
+
*
|
|
5259
|
+
* @example
|
|
5260
|
+
* parseServiceRef("Weather.services.openweather"); // returns { alias: "Weather", serviceName: "openweather" }
|
|
5261
|
+
* parseServiceRef("invalid"); // returns null
|
|
5101
5262
|
*/
|
|
5102
5263
|
declare function parseServiceRef(ref: string): {
|
|
5103
5264
|
alias: string;
|
|
5104
5265
|
serviceName: string;
|
|
5105
5266
|
} | null;
|
|
5106
5267
|
/**
|
|
5107
|
-
*
|
|
5268
|
+
* Checks if a service definition is a REST service.
|
|
5269
|
+
*
|
|
5270
|
+
* Type guard to determine if a service definition represents a REST API service.
|
|
5271
|
+
* Used for service type discrimination and validation.
|
|
5272
|
+
*
|
|
5273
|
+
* @param {ServiceDefinition} service - Service definition to check
|
|
5274
|
+
* @returns {boolean} True if service is a REST service, false otherwise
|
|
5275
|
+
*
|
|
5276
|
+
* @example
|
|
5277
|
+
* isRestService({ name: "weather", type: "rest", baseUrl: "..." }); // returns true
|
|
5278
|
+
* isRestService({ name: "chat", type: "socket" }); // returns false
|
|
5108
5279
|
*/
|
|
5109
5280
|
declare function isRestService(service: ServiceDefinition): service is RestServiceDef;
|
|
5110
5281
|
/**
|
|
5111
|
-
*
|
|
5282
|
+
* Checks if a service definition is a Socket service.
|
|
5283
|
+
*
|
|
5284
|
+
* Type guard to determine if a service definition represents a WebSocket service.
|
|
5285
|
+
* Used for service type discrimination and validation.
|
|
5286
|
+
*
|
|
5287
|
+
* @param {ServiceDefinition} service - Service definition to check
|
|
5288
|
+
* @returns {boolean} True if service is a Socket service, false otherwise
|
|
5289
|
+
*
|
|
5290
|
+
* @example
|
|
5291
|
+
* isSocketService({ name: "chat", type: "socket", url: "wss://..." }); // returns true
|
|
5292
|
+
* isSocketService({ name: "weather", type: "rest" }); // returns false
|
|
5112
5293
|
*/
|
|
5113
5294
|
declare function isSocketService(service: ServiceDefinition): service is SocketServiceDef;
|
|
5114
5295
|
/**
|
|
5115
|
-
*
|
|
5296
|
+
* Checks if a service definition is an MCP service.
|
|
5297
|
+
*
|
|
5298
|
+
* Type guard to determine if a service definition represents an MCP
|
|
5299
|
+
* (Multiplayer Control Protocol) service. Used for service type discrimination.
|
|
5300
|
+
*
|
|
5301
|
+
* @param {ServiceDefinition} service - Service definition to check
|
|
5302
|
+
* @returns {boolean} True if service is an MCP service, false otherwise
|
|
5303
|
+
*
|
|
5304
|
+
* @example
|
|
5305
|
+
* isMcpService({ name: "game", type: "mcp", serverUrl: "..." }); // returns true
|
|
5306
|
+
* isMcpService({ name: "chat", type: "socket" }); // returns false
|
|
5116
5307
|
*/
|
|
5117
5308
|
declare function isMcpService(service: ServiceDefinition): service is McpServiceDef;
|
|
5118
5309
|
/**
|
|
@@ -71,9 +71,20 @@ interface GraphTransition {
|
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* Builds an adjacency list from state machine transitions.
|
|
75
|
+
*
|
|
76
|
+
* Constructs a state transition graph where each state maps to an array
|
|
77
|
+
* of outgoing edges (events and target states). Wildcard transitions
|
|
78
|
+
* (from === '*') are excluded since they don't represent fixed edges.
|
|
79
|
+
* Used as the foundation for state machine analysis, traversal, and verification.
|
|
80
|
+
*
|
|
81
|
+
* @param {GraphTransition[]} transitions - Array of state transitions
|
|
82
|
+
* @returns {Map<string, StateEdge[]>} State transition graph
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const graph = buildStateGraph(transitions);
|
|
86
|
+
* const edgesFromInitial = graph.get('initial'); // Array of outgoing edges
|
|
87
|
+
* console.log(`Initial state has ${edgesFromInitial?.length} transitions`);
|
|
77
88
|
*/
|
|
78
89
|
declare function buildStateGraph(transitions: GraphTransition[]): Map<string, StateEdge[]>;
|
|
79
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/state-machine/graph.ts","../../src/state-machine/bfs.ts","../../src/state-machine/guard-payloads.ts","../../src/state-machine/replay-paths.ts"],"names":[],"mappings":";AAgBO,SAAS,gBACd,WAAA,EAC0B;AAC1B,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAyB;AAC3C,EAAA,KAAA,MAAW,KAAK,WAAA,EAAa;AAC3B,IAAA,IAAI,CAAA,CAAE,SAAS,GAAA,EAAK;AACpB,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAA,EAAM,EAAE,CAAA;AAC5C,IAAA,KAAA,CAAM,GAAA,CAAI,C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gB,IAAI,CAAA;AAClF,MAAA,MAAM,mBAAA,GACJ,UAAA,CAAW,QAAA,IACX,UAAA,CAAW,aAAA,CAAc,IAAA,CAAK,CAAC,CAAA,KAAM,qBAAA,CAAsB,GAAA,CAAI,CAAC,CAAC,CAAA;AAEnE,MAAA,MAAM,IAAA,GAAmB;AAAA,QACvB,OAAO,UAAA,CAAW,KAAA;AAAA,QAClB,SAAA,EAAW,KAAA;AAAA,QACX,SAAS,UAAA,CAAW,EAAA;AAAA,QACpB,IAAA,EAAM,cAAc,IAAA,IAAQ,MAAA;AAAA,QAC5B,eAAA,EAAiB,cAAc,WAAA,IAAe,MAAA;AAAA,QAC9C,eAAA,EAAiB,mBAAA;AAAA,QACjB,eAAe,UAAA,CAAW,aAAA,CAAc,MAAA,GAAS,CAAA,GAAI,WAAW,aAAA,GAAgB;AAAA,OAClF;AAEA,MAAA,MAAM,OAAA,GAAU,CAAC,GAAG,IAAA,EAAM,IAAI,CAAA;AAC9B,MAAA,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,EAAA,EAAI,OAAO,CAAA;AACtC,MAAA,KAAA,CAAM,KAAK,EAAE,KAAA,EAAO,WAAW,EAAA,EAAI,IAAA,EAAM,SAAS,CAAA;AAAA,IACpD;AAAA,EACF;AAEA,EAAA,OAAO,WAAA;AACT","file":"index.js","sourcesContent":["/**\n * State Graph Construction\n *\n * Build an adjacency list from state machine transitions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, StateEdge } from './types.js';\n\n/**\n * Build an adjacency list: state -> [{ event, to }].\n * Wildcard transitions (from === '*') are excluded since they\n * don't represent fixed edges in the graph.\n */\nexport function buildStateGraph(\n transitions: GraphTransition[]\n): Map<string, StateEdge[]> {\n const graph = new Map<string, StateEdge[]>();\n for (const t of transitions) {\n if (t.from === '*') continue;\n if (!graph.has(t.from)) graph.set(t.from, []);\n graph.get(t.from)!.push({ event: t.event, to: t.to });\n }\n return graph;\n}\n","/**\n * BFS Reachability Algorithms\n *\n * Breadth-first search over state machine graphs.\n * Extracted from orbital-verify-unified/src/analyze.ts and phase3-server.ts.\n *\n * @packageDocumentation\n */\n\nimport type { BFSNode, StateEdge } from './types.js';\nimport { buildStateGraph } from './graph.js';\nimport type { GraphTransition } from './types.js';\n\n/**\n * Collects all reachable states from an initial state using breadth-first search.\n * \n * Performs BFS traversal of the state machine to find all states reachable\n * from the initial state, up to the specified maximum depth. Used for\n * state machine analysis, verification, and test coverage assessment.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=5] - Maximum search depth\n * @returns {Set<string>} Set of reachable state names\n * \n * @example\n * const reachable = collectReachableStates(transitions, 'initial', 10);\n * console.log('Reachable states:', Array.from(reachable));\n */\nexport function collectReachableStates(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth = 5\n): Set<string> {\n const graph = buildStateGraph(transitions);\n const visited = new Set<string>([initialState]);\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n if (!visited.has(edge.to)) {\n visited.add(edge.to);\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n\n return visited;\n}\n\n/**\n * Walks all reachable (state, event) pairs using BFS and invokes callback for each.\n * \n * Traverses the state machine using breadth-first search and calls the visitor\n * function for each (state, edge) pair encountered. Used by server verification\n * to test transitions by POSTing to endpoints and checking responses.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} maxDepth - Maximum BFS depth\n * @param {(state: string, edge: StateEdge, depth: number) => Promise<boolean>} visitor - Callback for each pair\n * @returns {Promise<{ visitedPairs: Set<string>; walkedEdges: number }>} Traversal statistics\n * \n * @example\n * const result = await walkStatePairs(transitions, 'initial', 5, async (state, edge) => {\n * console.log(`Transition: ${state} --${edge.event}--> ${edge.to}`);\n * return true; // Continue exploration\n * });\n * console.log(`Visited ${result.visitedPairs.size} state-event pairs`);\n */\nexport async function walkStatePairs(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth: number,\n visitor: (state: string, edge: StateEdge, depth: number) => Promise<boolean>\n): Promise<{ visitedPairs: Set<string>; walkedEdges: number }> {\n const graph = buildStateGraph(transitions);\n const visitedPairs = new Set<string>();\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n let walkedEdges = 0;\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n const pairKey = `${current.state}:${edge.event}`;\n if (visitedPairs.has(pairKey)) continue;\n visitedPairs.add(pairKey);\n\n const shouldEnqueue = await visitor(current.state, edge, current.depth);\n walkedEdges++;\n\n if (shouldEnqueue) {\n const stateVisited = [...visitedPairs].some((k) => k.startsWith(`${edge.to}:`));\n if (!stateVisited) {\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n }\n\n return { visitedPairs, walkedEdges };\n}\n","/**\n * Guard Payload Builder\n *\n * Derive pass and fail payloads from guard s-expressions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GuardPayload } from './types.js';\n\n/**\n * Extracts the first segment of a payload field reference.\n * \n * Parses binding references in the format \"@payload.field\" and extracts\n * the first field name segment. Used for identifying payload fields in\n * guard conditions for test data generation.\n * \n * @param {unknown} ref - Binding reference to extract from\n * @returns {string | null} First field segment or null for non-payload references\n * \n * @example\n * extractPayloadFieldRef('@payload.item'); // returns 'item'\n * extractPayloadFieldRef('@payload.data.weight'); // returns 'data'\n * extractPayloadFieldRef('@entity.id'); // returns null\n * extractPayloadFieldRef('@user.name'); // returns null\n */\nexport function extractPayloadFieldRef(ref: unknown): string | null {\n if (typeof ref !== 'string') return null;\n const match = ref.match(/^@payload\\.([A-Za-z0-9_]+)/);\n return match ? match[1] : null;\n}\n\n/**\n * Builds test payloads that satisfy or violate guard conditions.\n * \n * Generates pass/fail test data for guard s-expressions used in state machine\n * transitions. Pass payloads satisfy the guard condition (allowing transition),\n * fail payloads violate it (blocking transition). Used for automated testing\n * and validation of state machine behavior.\n * \n * Supports operators: not-nil, nil, eq, not-eq, gt, gte, lt, lte, and, or, not\n * \n * @param {unknown} guard - Guard s-expression to analyze\n * @returns {GuardPayload} Object with pass and fail payloads\n * \n * @example\n * // Guard: ['not-nil', '@payload.completed']\n * buildGuardPayloads(['not-nil', '@payload.completed']);\n * // Returns: { pass: { completed: 'mock-test-value' }, fail: { completed: null } }\n * \n * @example\n * // Guard: ['eq', '@payload.status', 'active']\n * buildGuardPayloads(['eq', '@payload.status', 'active']);\n * // Returns: { pass: { status: 'active' }, fail: { status: 'not-active' } }\n * \n * @example\n * // Guard: ['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]\n * buildGuardPayloads(['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]);\n * // Returns: { pass: { id: 'mock-test-value', status: 'ready' }, fail: { id: null } }\n */\nexport function buildGuardPayloads(guard: unknown): GuardPayload {\n if (!Array.isArray(guard) || guard.length === 0) {\n return { pass: {}, fail: {} };\n }\n\n const op = String(guard[0]);\n\n if (op === 'not-nil' || op === 'not_nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mock-test-value' }, fail: { [field]: null } };\n }\n\n if (op === 'nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: {}, fail: { [field]: 'mock-test-value' } };\n }\n\n if (op === 'eq' || op === '==' || op === '=') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const failVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : null;\n return { pass: { [field]: val }, fail: { [field]: failVal } };\n }\n }\n\n if (op === 'not-eq' || op === '!=' || op === 'neq') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const passVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : 'other';\n return { pass: { [field]: passVal }, fail: { [field]: val } };\n }\n }\n\n if (op === 'gt' || op === '>') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n + 1 }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'gte' || op === '>=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'lt' || op === '<') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n - 1 }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'lte' || op === '<=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'and') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: { ...s1.pass, ...s2.pass }, fail: s1.fail };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'or') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'not') {\n const inner = buildGuardPayloads(guard[1]);\n return { pass: inner.fail, fail: inner.pass };\n }\n\n return { pass: {}, fail: {} };\n}\n","/**\n * Replay Path Builder\n *\n * Compute the shortest path (replay steps) from an initial state\n * to every reachable state in a state machine. Used by browser\n * verification to navigate through states before running assertions.\n *\n * Extracted from orbital-verify-unified/src/analyze.ts (collectDataMutationTests).\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, ReplayStep, PayloadFieldSchema } from './types.js';\n\n/** Entity-data sentinel payload fields: presence means transition needs a selected row */\nconst ENTITY_PAYLOAD_FIELDS = new Set(['data', 'row', 'item', 'id']);\n\n/**\n * Extended transition with render and payload info needed for replay path building.\n * Compatible with orbital-verify's UnifiedTransition.\n */\nexport interface ReplayTransition extends GraphTransition {\n hasGuard: boolean;\n guard?: unknown[];\n payloadFields: string[];\n payloadSchema: PayloadFieldSchema[];\n renderEffects: Array<{\n slot: string;\n patternType: string | null;\n }>;\n}\n\n/**\n * Builds the shortest replay paths from initial state to all reachable states.\n * \n * Computes step-by-step navigation paths for state machine testing and verification.\n * Uses breadth-first search to find shortest paths up to specified depth limit.\n * Each path contains replay steps with event, state, and payload information\n * needed to reproduce state transitions in tests.\n * \n * @param {ReplayTransition[]} transitions - Transitions with render/payload information\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=3] - Maximum path length (default: 3)\n * @returns {Map<string, ReplayStep[]>} Map of state names to replay step arrays\n * \n * @example\n * // Build paths from 'initial' state\n * const paths = buildReplayPaths(transitions, 'initial', 5);\n * \n * // Get steps to reach 'completed' state\n * const stepsToComplete = paths.get('completed');\n * \n * // Execute replay steps\n * for (const step of stepsToComplete) {\n * await dispatchEvent(step.event, step.payload);\n * }\n */\nexport function buildReplayPaths(\n transitions: ReplayTransition[],\n initialState: string,\n maxDepth = 3\n): Map<string, ReplayStep[]> {\n type QueueNode = { state: string; path: ReplayStep[] };\n\n const queue: QueueNode[] = [{ state: initialState, path: [] }];\n const replayPaths = new Map<string, ReplayStep[]>();\n replayPaths.set(initialState, []);\n\n while (queue.length > 0) {\n const { state, path } = queue.shift()!;\n if (path.length >= maxDepth) continue;\n\n const fromHere = transitions.filter(\n (t) => t.from === state && t.event !== 'INIT',\n );\n\n for (const transition of fromHere) {\n if (replayPaths.has(transition.to)) continue;\n\n const renderEffect = transition.renderEffects.find((re) => re.patternType !== null);\n const stepNeedsEntityData =\n transition.hasGuard ||\n transition.payloadFields.some((f) => ENTITY_PAYLOAD_FIELDS.has(f));\n\n const step: ReplayStep = {\n event: transition.event,\n fromState: state,\n toState: transition.to,\n slot: renderEffect?.slot ?? 'main',\n expectedPattern: renderEffect?.patternType ?? undefined,\n needsEntityData: stepNeedsEntityData,\n payloadSchema: transition.payloadSchema.length > 0 ? transition.payloadSchema : undefined,\n };\n\n const newPath = [...path, step];\n replayPaths.set(transition.to, newPath);\n queue.push({ state: transition.to, path: newPath });\n }\n }\n\n return replayPaths;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/state-machine/graph.ts","../../src/state-machine/bfs.ts","../../src/state-machine/guard-payloads.ts","../../src/state-machine/replay-paths.ts"],"names":[],"mappings":";AA2BO,SAAS,gBACd,WAAA,EAC0B;AAC1B,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAyB;AAC3C,EAAA,KAAA,MAAW,KAAK,WAAA,EAAa;AAC3B,IAAA,IAAI,CAAA,CAAE,SAAS,GAAA,EAAK;AACpB,IAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,EAAG,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAA,EAAM,EAAE,CAAA;AAC5C,IAAA,KAAA,CAAM,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,CAAG,IAAA,CAAK,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,CAAA;AAAA,EACtD;AACA,EAAA,OAAO,KAAA;AACT;;;ACRO,SAAS,sBAAA,CACd,WAAA,EACA,YAAA,EACA,QAAA,GAAW,CAAA,EACE;AACb,EAAA,MAAM,KAAA,GAAQ,gBAAgB,WAAW,CAAA;AACzC,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AW,EAAA;AAAA,QACpB,IAAA,EAAM,cAAc,IAAA,IAAQ,MAAA;AAAA,QAC5B,eAAA,EAAiB,cAAc,WAAA,IAAe,MAAA;AAAA,QAC9C,eAAA,EAAiB,mBAAA;AAAA,QACjB,eAAe,UAAA,CAAW,aAAA,CAAc,MAAA,GAAS,CAAA,GAAI,WAAW,aAAA,GAAgB;AAAA,OAClF;AAEA,MAAA,MAAM,OAAA,GAAU,CAAC,GAAG,IAAA,EAAM,IAAI,CAAA;AAC9B,MAAA,WAAA,CAAY,GAAA,CAAI,UAAA,CAAW,EAAA,EAAI,OAAO,CAAA;AACtC,MAAA,KAAA,CAAM,KAAK,EAAE,KAAA,EAAO,WAAW,EAAA,EAAI,IAAA,EAAM,SAAS,CAAA;AAAA,IACpD;AAAA,EACF;AAEA,EAAA,OAAO,WAAA;AACT","file":"index.js","sourcesContent":["/**\n * State Graph Construction\n *\n * Build an adjacency list from state machine transitions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, StateEdge } from './types.js';\n\n/**\n * Builds an adjacency list from state machine transitions.\n * \n * Constructs a state transition graph where each state maps to an array\n * of outgoing edges (events and target states). Wildcard transitions\n * (from === '*') are excluded since they don't represent fixed edges.\n * Used as the foundation for state machine analysis, traversal, and verification.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @returns {Map<string, StateEdge[]>} State transition graph\n * \n * @example\n * const graph = buildStateGraph(transitions);\n * const edgesFromInitial = graph.get('initial'); // Array of outgoing edges\n * console.log(`Initial state has ${edgesFromInitial?.length} transitions`);\n */\nexport function buildStateGraph(\n transitions: GraphTransition[]\n): Map<string, StateEdge[]> {\n const graph = new Map<string, StateEdge[]>();\n for (const t of transitions) {\n if (t.from === '*') continue;\n if (!graph.has(t.from)) graph.set(t.from, []);\n graph.get(t.from)!.push({ event: t.event, to: t.to });\n }\n return graph;\n}\n","/**\n * BFS Reachability Algorithms\n *\n * Breadth-first search over state machine graphs.\n * Extracted from orbital-verify-unified/src/analyze.ts and phase3-server.ts.\n *\n * @packageDocumentation\n */\n\nimport type { BFSNode, StateEdge } from './types.js';\nimport { buildStateGraph } from './graph.js';\nimport type { GraphTransition } from './types.js';\n\n/**\n * Collects all reachable states from an initial state using breadth-first search.\n * \n * Performs BFS traversal of the state machine to find all states reachable\n * from the initial state, up to the specified maximum depth. Used for\n * state machine analysis, verification, and test coverage assessment.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=5] - Maximum search depth\n * @returns {Set<string>} Set of reachable state names\n * \n * @example\n * const reachable = collectReachableStates(transitions, 'initial', 10);\n * console.log('Reachable states:', Array.from(reachable));\n */\nexport function collectReachableStates(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth = 5\n): Set<string> {\n const graph = buildStateGraph(transitions);\n const visited = new Set<string>([initialState]);\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n if (!visited.has(edge.to)) {\n visited.add(edge.to);\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n\n return visited;\n}\n\n/**\n * Walks all reachable (state, event) pairs using BFS and invokes callback for each.\n * \n * Traverses the state machine using breadth-first search and calls the visitor\n * function for each (state, edge) pair encountered. Used by server verification\n * to test transitions by POSTing to endpoints and checking responses.\n * \n * @param {GraphTransition[]} transitions - Array of state transitions\n * @param {string} initialState - Starting state name\n * @param {number} maxDepth - Maximum BFS depth\n * @param {(state: string, edge: StateEdge, depth: number) => Promise<boolean>} visitor - Callback for each pair\n * @returns {Promise<{ visitedPairs: Set<string>; walkedEdges: number }>} Traversal statistics\n * \n * @example\n * const result = await walkStatePairs(transitions, 'initial', 5, async (state, edge) => {\n * console.log(`Transition: ${state} --${edge.event}--> ${edge.to}`);\n * return true; // Continue exploration\n * });\n * console.log(`Visited ${result.visitedPairs.size} state-event pairs`);\n */\nexport async function walkStatePairs(\n transitions: GraphTransition[],\n initialState: string,\n maxDepth: number,\n visitor: (state: string, edge: StateEdge, depth: number) => Promise<boolean>\n): Promise<{ visitedPairs: Set<string>; walkedEdges: number }> {\n const graph = buildStateGraph(transitions);\n const visitedPairs = new Set<string>();\n const queue: BFSNode[] = [{ state: initialState, depth: 0 }];\n let walkedEdges = 0;\n\n while (queue.length > 0) {\n const current = queue.shift()!;\n if (current.depth >= maxDepth) continue;\n\n const edges = graph.get(current.state) ?? [];\n for (const edge of edges) {\n const pairKey = `${current.state}:${edge.event}`;\n if (visitedPairs.has(pairKey)) continue;\n visitedPairs.add(pairKey);\n\n const shouldEnqueue = await visitor(current.state, edge, current.depth);\n walkedEdges++;\n\n if (shouldEnqueue) {\n const stateVisited = [...visitedPairs].some((k) => k.startsWith(`${edge.to}:`));\n if (!stateVisited) {\n queue.push({ state: edge.to, depth: current.depth + 1 });\n }\n }\n }\n }\n\n return { visitedPairs, walkedEdges };\n}\n","/**\n * Guard Payload Builder\n *\n * Derive pass and fail payloads from guard s-expressions.\n * Extracted from orbital-verify-unified/src/analyze.ts.\n *\n * @packageDocumentation\n */\n\nimport type { GuardPayload } from './types.js';\n\n/**\n * Extracts the first segment of a payload field reference.\n * \n * Parses binding references in the format \"@payload.field\" and extracts\n * the first field name segment. Used for identifying payload fields in\n * guard conditions for test data generation.\n * \n * @param {unknown} ref - Binding reference to extract from\n * @returns {string | null} First field segment or null for non-payload references\n * \n * @example\n * extractPayloadFieldRef('@payload.item'); // returns 'item'\n * extractPayloadFieldRef('@payload.data.weight'); // returns 'data'\n * extractPayloadFieldRef('@entity.id'); // returns null\n * extractPayloadFieldRef('@user.name'); // returns null\n */\nexport function extractPayloadFieldRef(ref: unknown): string | null {\n if (typeof ref !== 'string') return null;\n const match = ref.match(/^@payload\\.([A-Za-z0-9_]+)/);\n return match ? match[1] : null;\n}\n\n/**\n * Builds test payloads that satisfy or violate guard conditions.\n * \n * Generates pass/fail test data for guard s-expressions used in state machine\n * transitions. Pass payloads satisfy the guard condition (allowing transition),\n * fail payloads violate it (blocking transition). Used for automated testing\n * and validation of state machine behavior.\n * \n * Supports operators: not-nil, nil, eq, not-eq, gt, gte, lt, lte, and, or, not\n * \n * @param {unknown} guard - Guard s-expression to analyze\n * @returns {GuardPayload} Object with pass and fail payloads\n * \n * @example\n * // Guard: ['not-nil', '@payload.completed']\n * buildGuardPayloads(['not-nil', '@payload.completed']);\n * // Returns: { pass: { completed: 'mock-test-value' }, fail: { completed: null } }\n * \n * @example\n * // Guard: ['eq', '@payload.status', 'active']\n * buildGuardPayloads(['eq', '@payload.status', 'active']);\n * // Returns: { pass: { status: 'active' }, fail: { status: 'not-active' } }\n * \n * @example\n * // Guard: ['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]\n * buildGuardPayloads(['and', ['not-nil', '@payload.id'], ['eq', '@payload.status', 'ready']]);\n * // Returns: { pass: { id: 'mock-test-value', status: 'ready' }, fail: { id: null } }\n */\nexport function buildGuardPayloads(guard: unknown): GuardPayload {\n if (!Array.isArray(guard) || guard.length === 0) {\n return { pass: {}, fail: {} };\n }\n\n const op = String(guard[0]);\n\n if (op === 'not-nil' || op === 'not_nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: { [field]: 'mock-test-value' }, fail: { [field]: null } };\n }\n\n if (op === 'nil') {\n const field = extractPayloadFieldRef(guard[1]);\n if (field) return { pass: {}, fail: { [field]: 'mock-test-value' } };\n }\n\n if (op === 'eq' || op === '==' || op === '=') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const failVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : null;\n return { pass: { [field]: val }, fail: { [field]: failVal } };\n }\n }\n\n if (op === 'not-eq' || op === '!=' || op === 'neq') {\n const field = extractPayloadFieldRef(guard[1]);\n const val = guard[2];\n if (field && val !== undefined) {\n const passVal =\n typeof val === 'number' ? val + 1\n : typeof val === 'string' ? `not-${val}`\n : 'other';\n return { pass: { [field]: passVal }, fail: { [field]: val } };\n }\n }\n\n if (op === 'gt' || op === '>') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n + 1 }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'gte' || op === '>=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n - 1 } };\n }\n\n if (op === 'lt' || op === '<') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n - 1 }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'lte' || op === '<=') {\n const field = extractPayloadFieldRef(guard[1]);\n const n = typeof guard[2] === 'number' ? guard[2] : 0;\n if (field) return { pass: { [field]: n }, fail: { [field]: n + 1 } };\n }\n\n if (op === 'and') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: { ...s1.pass, ...s2.pass }, fail: s1.fail };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'or') {\n const subs = (guard.slice(1) as unknown[]).filter(Array.isArray);\n if (subs.length >= 2) {\n const s1 = buildGuardPayloads(subs[0]);\n const s2 = buildGuardPayloads(subs[1]);\n return { pass: s1.pass, fail: { ...s1.fail, ...s2.fail } };\n }\n if (subs.length === 1) return buildGuardPayloads(subs[0]);\n }\n\n if (op === 'not') {\n const inner = buildGuardPayloads(guard[1]);\n return { pass: inner.fail, fail: inner.pass };\n }\n\n return { pass: {}, fail: {} };\n}\n","/**\n * Replay Path Builder\n *\n * Compute the shortest path (replay steps) from an initial state\n * to every reachable state in a state machine. Used by browser\n * verification to navigate through states before running assertions.\n *\n * Extracted from orbital-verify-unified/src/analyze.ts (collectDataMutationTests).\n *\n * @packageDocumentation\n */\n\nimport type { GraphTransition, ReplayStep, PayloadFieldSchema } from './types.js';\n\n/** Entity-data sentinel payload fields: presence means transition needs a selected row */\nconst ENTITY_PAYLOAD_FIELDS = new Set(['data', 'row', 'item', 'id']);\n\n/**\n * Extended transition with render and payload info needed for replay path building.\n * Compatible with orbital-verify's UnifiedTransition.\n */\nexport interface ReplayTransition extends GraphTransition {\n hasGuard: boolean;\n guard?: unknown[];\n payloadFields: string[];\n payloadSchema: PayloadFieldSchema[];\n renderEffects: Array<{\n slot: string;\n patternType: string | null;\n }>;\n}\n\n/**\n * Builds the shortest replay paths from initial state to all reachable states.\n * \n * Computes step-by-step navigation paths for state machine testing and verification.\n * Uses breadth-first search to find shortest paths up to specified depth limit.\n * Each path contains replay steps with event, state, and payload information\n * needed to reproduce state transitions in tests.\n * \n * @param {ReplayTransition[]} transitions - Transitions with render/payload information\n * @param {string} initialState - Starting state name\n * @param {number} [maxDepth=3] - Maximum path length (default: 3)\n * @returns {Map<string, ReplayStep[]>} Map of state names to replay step arrays\n * \n * @example\n * // Build paths from 'initial' state\n * const paths = buildReplayPaths(transitions, 'initial', 5);\n * \n * // Get steps to reach 'completed' state\n * const stepsToComplete = paths.get('completed');\n * \n * // Execute replay steps\n * for (const step of stepsToComplete) {\n * await dispatchEvent(step.event, step.payload);\n * }\n */\nexport function buildReplayPaths(\n transitions: ReplayTransition[],\n initialState: string,\n maxDepth = 3\n): Map<string, ReplayStep[]> {\n type QueueNode = { state: string; path: ReplayStep[] };\n\n const queue: QueueNode[] = [{ state: initialState, path: [] }];\n const replayPaths = new Map<string, ReplayStep[]>();\n replayPaths.set(initialState, []);\n\n while (queue.length > 0) {\n const { state, path } = queue.shift()!;\n if (path.length >= maxDepth) continue;\n\n const fromHere = transitions.filter(\n (t) => t.from === state && t.event !== 'INIT',\n );\n\n for (const transition of fromHere) {\n if (replayPaths.has(transition.to)) continue;\n\n const renderEffect = transition.renderEffects.find((re) => re.patternType !== null);\n const stepNeedsEntityData =\n transition.hasGuard ||\n transition.payloadFields.some((f) => ENTITY_PAYLOAD_FIELDS.has(f));\n\n const step: ReplayStep = {\n event: transition.event,\n fromState: state,\n toState: transition.to,\n slot: renderEffect?.slot ?? 'main',\n expectedPattern: renderEffect?.patternType ?? undefined,\n needsEntityData: stepNeedsEntityData,\n payloadSchema: transition.payloadSchema.length > 0 ? transition.payloadSchema : undefined,\n };\n\n const newPath = [...path, step];\n replayPaths.set(transition.to, newPath);\n queue.push({ state: transition.to, path: newPath });\n }\n }\n\n return replayPaths;\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bs as SExpr } from '../schema-
|
|
2
|
-
export { A as AGENT_DOMAIN_CATEGORIES, e as ALLOWED_CUSTOM_COMPONENTS, f as AgentDomainCategory, g as AgentDomainCategorySchema, h as AllowedCustomComponent, i as AnimationDef, j as AnimationDefInput, k as AnimationDefSchema, b as AppSchema, l as AssetMap, m as AssetMapInput, n as AssetMapSchema, o as AssetMapping, p as AssetMappingInput, q as AssetMappingSchema, C as CORE_BINDINGS, r as CallServiceConfig, s as ComputedEventContract, t as ComputedEventContractSchema, u as ComputedEventListener, v as ComputedEventListenerSchema, w as CoreBinding, x as CustomPatternDefinition, y as CustomPatternDefinitionInput, z as CustomPatternDefinitionSchema, B as CustomPatternMap, D as CustomPatternMapInput, F as CustomPatternMapSchema, G as DesignPreferences, H as DesignPreferencesInput, I as DesignPreferencesSchema, J as DesignTokens, K as DesignTokensInput, L as DesignTokensSchema, M as DomainCategory, N as DomainCategorySchema, Q as DomainContext, R as DomainContextInput, U as DomainContextSchema, V as DomainVocabulary, W as DomainVocabularySchema, X as ENTITY_ROLES, Y as Effect, Z as EffectInput, _ as EffectSchema, d as Entity, E as EntityField, $ as EntityFieldInput, a0 as EntityFieldSchema, a as EntityPersistence, a1 as EntityPersistenceSchema, a2 as EntityRef, a3 as EntityRefSchema, a4 as EntityRefStringSchema, a5 as EntityRole, a6 as EntityRoleSchema, a7 as EntitySchema, a8 as EntitySemanticRole, a9 as EntitySemanticRoleSchema, aa as Event, ab as EventInput, ac as EventListener, ad as EventListenerSchema, ae as EventPayloadField, af as EventPayloadFieldSchema, ag as EventSchema, ah as EventScope, ai as EventScopeSchema, aj as EventSemanticRole, ak as EventSemanticRoleSchema, al as EventSource, am as EventSourceSchema, an as Expression, ao as ExpressionInput, ap as ExpressionSchema, aq as Field, ar as FieldFormat, as as FieldFormatSchema, at as FieldSchema, au as FieldType, av as FieldTypeSchema, aw as FullOrbitalUnit, ax as GAME_TYPES, ay as GameSubCategory, az as GameSubCategorySchema, aA as GameType, aB as GameTypeSchema, aC as Guard, aD as GuardInput, aE as GuardSchema, aF as McpServiceDef, aG as McpServiceDefSchema, aH as NodeClassification, aI as NodeClassificationSchema, aw as Orbital, aJ as OrbitalConfig, aK as OrbitalConfigInput, aL as OrbitalConfigSchema, O as OrbitalDefinition, aM as OrbitalDefinitionSchema, aN as OrbitalEntity, aO as OrbitalEntityInput, aP as OrbitalEntitySchema, aQ as OrbitalInput, aR as OrbitalPage, aS as OrbitalPageInput, aT as OrbitalPageSchema, aU as OrbitalPageStrictInput, aV as OrbitalPageStrictSchema, b as OrbitalSchema, aW as OrbitalSchemaInput, aX as OrbitalSchemaSchema, aY as OrbitalTraitRef, aZ as OrbitalTraitRefSchema, a_ as OrbitalUnit, a$ as OrbitalUnitSchema, b0 as OrbitalZodSchema, P as Page, b1 as PageRef, b2 as PageRefObject, b3 as PageRefObjectSchema, b4 as PageRefSchema, b5 as PageRefStringSchema, b6 as PageSchema, b7 as PageTraitRef, b8 as PageTraitRefSchema, b9 as ParsedBinding, ba as PayloadField, bb as PayloadFieldSchema, bc as PresentationType, bd as RelatedLink, be as RelatedLinkSchema, bf as RelationConfig, bg as RelationConfigSchema, bh as RenderUIConfig, bi as RequiredField, bj as RequiredFieldSchema, bk as ResolvedAsset, bl as ResolvedAssetInput, bm as ResolvedAssetSchema, bn as RestAuthConfig, bo as RestAuthConfigSchema, bp as RestServiceDef, bq as RestServiceDefSchema, br as SERVICE_TYPES, bt as SExprAtom, bu as SExprAtomSchema, bv as SExprInput, bw as SExprSchema, bx as SemanticAssetRef, by as SemanticAssetRefInput, bz as SemanticAssetRefSchema, bA as ServiceDefinition, bB as ServiceDefinitionSchema, bC as ServiceRef, bD as ServiceRefSchema, bE as ServiceRefStringSchema, bF as ServiceType, bG as ServiceTypeSchema, bH as SocketEvents, bI as SocketEventsSchema, bJ as SocketServiceDef, bK as SocketServiceDefSchema, S as State, bL as StateInput, bM as StateMachine, bN as StateMachineInput, bO as StateMachineSchema, bP as StateSchema, bQ as StateSemanticRole, bR as StateSemanticRoleSchema, bS as SuggestedGuard, bT as SuggestedGuardSchema, bU as ThemeDefinition, bV as ThemeDefinitionSchema, bW as ThemeRef, bX as ThemeRefSchema, bY as ThemeRefStringSchema, bZ as ThemeTokens, b_ as ThemeTokensSchema, b$ as ThemeVariant, c0 as ThemeVariantSchema, c as Trait, c1 as TraitCategory, c2 as TraitCategorySchema, c3 as TraitDataEntity, c4 as TraitDataEntitySchema, c5 as TraitEntityField, c6 as TraitEntityFieldSchema, T 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-
|
|
1
|
+
import { bs as SExpr } from '../schema-obC5T1Jm.js';
|
|
2
|
+
export { A as AGENT_DOMAIN_CATEGORIES, e as ALLOWED_CUSTOM_COMPONENTS, f as AgentDomainCategory, g as AgentDomainCategorySchema, h as AllowedCustomComponent, i as AnimationDef, j as AnimationDefInput, k as AnimationDefSchema, b as AppSchema, l as AssetMap, m as AssetMapInput, n as AssetMapSchema, o as AssetMapping, p as AssetMappingInput, q as AssetMappingSchema, C as CORE_BINDINGS, r as CallServiceConfig, s as ComputedEventContract, t as ComputedEventContractSchema, u as ComputedEventListener, v as ComputedEventListenerSchema, w as CoreBinding, x as CustomPatternDefinition, y as CustomPatternDefinitionInput, z as CustomPatternDefinitionSchema, B as CustomPatternMap, D as CustomPatternMapInput, F as CustomPatternMapSchema, G as DesignPreferences, H as DesignPreferencesInput, I as DesignPreferencesSchema, J as DesignTokens, K as DesignTokensInput, L as DesignTokensSchema, M as DomainCategory, N as DomainCategorySchema, Q as DomainContext, R as DomainContextInput, U as DomainContextSchema, V as DomainVocabulary, W as DomainVocabularySchema, X as ENTITY_ROLES, Y as Effect, Z as EffectInput, _ as EffectSchema, d as Entity, E as EntityField, $ as EntityFieldInput, a0 as EntityFieldSchema, a as EntityPersistence, a1 as EntityPersistenceSchema, a2 as EntityRef, a3 as EntityRefSchema, a4 as EntityRefStringSchema, a5 as EntityRole, a6 as EntityRoleSchema, a7 as EntitySchema, a8 as EntitySemanticRole, a9 as EntitySemanticRoleSchema, aa as Event, ab as EventInput, ac as EventListener, ad as EventListenerSchema, ae as EventPayloadField, af as EventPayloadFieldSchema, ag as EventSchema, ah as EventScope, ai as EventScopeSchema, aj as EventSemanticRole, ak as EventSemanticRoleSchema, al as EventSource, am as EventSourceSchema, an as Expression, ao as ExpressionInput, ap as ExpressionSchema, aq as Field, ar as FieldFormat, as as FieldFormatSchema, at as FieldSchema, au as FieldType, av as FieldTypeSchema, aw as FullOrbitalUnit, ax as GAME_TYPES, ay as GameSubCategory, az as GameSubCategorySchema, aA as GameType, aB as GameTypeSchema, aC as Guard, aD as GuardInput, aE as GuardSchema, aF as McpServiceDef, aG as McpServiceDefSchema, aH as NodeClassification, aI as NodeClassificationSchema, aw as Orbital, aJ as OrbitalConfig, aK as OrbitalConfigInput, aL as OrbitalConfigSchema, O as OrbitalDefinition, aM as OrbitalDefinitionSchema, aN as OrbitalEntity, aO as OrbitalEntityInput, aP as OrbitalEntitySchema, aQ as OrbitalInput, aR as OrbitalPage, aS as OrbitalPageInput, aT as OrbitalPageSchema, aU as OrbitalPageStrictInput, aV as OrbitalPageStrictSchema, b as OrbitalSchema, aW as OrbitalSchemaInput, aX as OrbitalSchemaSchema, aY as OrbitalTraitRef, aZ as OrbitalTraitRefSchema, a_ as OrbitalUnit, a$ as OrbitalUnitSchema, b0 as OrbitalZodSchema, P as Page, b1 as PageRef, b2 as PageRefObject, b3 as PageRefObjectSchema, b4 as PageRefSchema, b5 as PageRefStringSchema, b6 as PageSchema, b7 as PageTraitRef, b8 as PageTraitRefSchema, b9 as ParsedBinding, ba as PayloadField, bb as PayloadFieldSchema, bc as PresentationType, bd as RelatedLink, be as RelatedLinkSchema, bf as RelationConfig, bg as RelationConfigSchema, bh as RenderUIConfig, bi as RequiredField, bj as RequiredFieldSchema, bk as ResolvedAsset, bl as ResolvedAssetInput, bm as ResolvedAssetSchema, bn as RestAuthConfig, bo as RestAuthConfigSchema, bp as RestServiceDef, bq as RestServiceDefSchema, br as SERVICE_TYPES, bt as SExprAtom, bu as SExprAtomSchema, bv as SExprInput, bw as SExprSchema, bx as SemanticAssetRef, by as SemanticAssetRefInput, bz as SemanticAssetRefSchema, bA as ServiceDefinition, bB as ServiceDefinitionSchema, bC as ServiceRef, bD as ServiceRefSchema, bE as ServiceRefStringSchema, bF as ServiceType, bG as ServiceTypeSchema, bH as SocketEvents, bI as SocketEventsSchema, bJ as SocketServiceDef, bK as SocketServiceDefSchema, S as State, bL as StateInput, bM as StateMachine, bN as StateMachineInput, bO as StateMachineSchema, bP as StateSchema, bQ as StateSemanticRole, bR as StateSemanticRoleSchema, bS as SuggestedGuard, bT as SuggestedGuardSchema, bU as ThemeDefinition, bV as ThemeDefinitionSchema, bW as ThemeRef, bX as ThemeRefSchema, bY as ThemeRefStringSchema, bZ as ThemeTokens, b_ as ThemeTokensSchema, b$ as ThemeVariant, c0 as ThemeVariantSchema, c as Trait, c1 as TraitCategory, c2 as TraitCategorySchema, c3 as TraitDataEntity, c4 as TraitDataEntitySchema, c5 as TraitEntityField, c6 as TraitEntityFieldSchema, T 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-obC5T1Jm.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export { CATEGORIES, CategoryMeta, OPERATORS, OPERATORS_SCHEMA, OPERATOR_NAMES, OperatorCategory, OperatorMeta, OperatorStats, OperatorsSchema, TargetPlatform, getOperatorMeta, getOperatorStats, getOperatorsByCategory, getOperatorsForTarget, isEffectOperator, isGuardOperator, isKnownOperator, validateOperatorArity } from '@almadar/operators';
|
|
5
5
|
export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@almadar/patterns';
|
|
@@ -13,7 +13,25 @@ export { PATTERN_TYPES, PatternConfig, PatternType, isValidPatternType } from '@
|
|
|
13
13
|
* @packageDocumentation
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Get all operator names.
|
|
18
|
+
*
|
|
19
|
+
* Returns a list of all registered S-expression operator names.
|
|
20
|
+
* This is a legacy alias - prefer importing OPERATOR_NAMES directly
|
|
21
|
+
* from @almadar/operators for new code.
|
|
22
|
+
*
|
|
23
|
+
* @returns {string[]} Array of operator names
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const operators = getAllOperators();
|
|
27
|
+
* // Returns: ['set', 'emit', 'navigate', 'renderUI', ...]
|
|
28
|
+
*/
|
|
16
29
|
declare const getAllOperators: () => string[];
|
|
30
|
+
/**
|
|
31
|
+
* Operator name type.
|
|
32
|
+
*
|
|
33
|
+
* Represents a valid operator name string.
|
|
34
|
+
*/
|
|
17
35
|
type OperatorName = string;
|
|
18
36
|
|
|
19
37
|
/**
|
|
@@ -201,7 +219,18 @@ declare const InteractionModelSchema: z.ZodObject<{
|
|
|
201
219
|
*/
|
|
202
220
|
declare const DEFAULT_INTERACTION_MODELS: Record<string, InteractionModel>;
|
|
203
221
|
/**
|
|
204
|
-
*
|
|
222
|
+
* Gets the interaction model for a domain.
|
|
223
|
+
*
|
|
224
|
+
* Retrieves the appropriate interaction model configuration based on the
|
|
225
|
+
* specified domain. Falls back to the business model if no specific
|
|
226
|
+
* domain match is found.
|
|
227
|
+
*
|
|
228
|
+
* @param {string} domain - Domain name (e.g., 'healthcare', 'education')
|
|
229
|
+
* @returns {InteractionModel} Interaction model configuration
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* getInteractionModelForDomain('healthcare'); // returns healthcare-specific model
|
|
233
|
+
* getInteractionModelForDomain('unknown'); // returns business fallback model
|
|
205
234
|
*/
|
|
206
235
|
declare function getInteractionModelForDomain(domain: string): InteractionModel;
|
|
207
236
|
type InteractionModelInput = z.input<typeof InteractionModelSchema>;
|
|
@@ -222,7 +251,16 @@ type InteractionModelInput = z.input<typeof InteractionModelSchema>;
|
|
|
222
251
|
declare const PatternTypeSchema: z.ZodString;
|
|
223
252
|
/**
|
|
224
253
|
* Get all valid pattern types from the registry.
|
|
225
|
-
*
|
|
254
|
+
*
|
|
255
|
+
* Returns a complete list of pattern type names from the canonical
|
|
256
|
+
* @almadar/patterns registry. Use this to iterate over or validate
|
|
257
|
+
* pattern types programmatically.
|
|
258
|
+
*
|
|
259
|
+
* @returns {string[]} Array of pattern type names
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* const types = getAllPatternTypes();
|
|
263
|
+
* // Returns: ['data-table', 'detail-view', 'form-section', ...]
|
|
226
264
|
*/
|
|
227
265
|
declare function getAllPatternTypes(): string[];
|
|
228
266
|
|
|
@@ -523,6 +561,27 @@ interface ServiceEvents<EventMap extends Record<string, Record<string, unknown>>
|
|
|
523
561
|
* typedBus.on('LLM_ERROR', (payload) => { payload.error; }); // payload is typed
|
|
524
562
|
* ```
|
|
525
563
|
*/
|
|
564
|
+
/**
|
|
565
|
+
* Creates a typed event bus from an untyped bus implementation.
|
|
566
|
+
*
|
|
567
|
+
* This wrapper adds TypeScript type safety to event emission and listening.
|
|
568
|
+
* The generic `EventMap` defines the shape of all events and their payloads.
|
|
569
|
+
*
|
|
570
|
+
* @template EventMap - Type mapping event names to their payload types
|
|
571
|
+
* @param {Object} bus - Untyped event bus implementation
|
|
572
|
+
* @param {Function} bus.emit - Function to emit events
|
|
573
|
+
* @param {Function} bus.on - Function to listen to events
|
|
574
|
+
* @returns {ServiceEvents<EventMap>} Typed event bus interface
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* interface MyEvents {
|
|
578
|
+
* 'user.created': { id: string; name: string };
|
|
579
|
+
* 'user.deleted': { id: string };
|
|
580
|
+
* }
|
|
581
|
+
*
|
|
582
|
+
* const typedBus = createTypedEventBus<MyEvents>(rawBus);
|
|
583
|
+
* typedBus.emit('user.created', { id: '123', name: 'Alice' });
|
|
584
|
+
*/
|
|
526
585
|
declare function createTypedEventBus<EventMap extends Record<string, Record<string, unknown>>>(bus: {
|
|
527
586
|
emit(event: string, payload?: unknown, meta?: Record<string, unknown>): void;
|
|
528
587
|
on(event: string, handler: (payload: unknown, meta?: Record<string, unknown>) => void): () => void;
|
|
@@ -584,6 +643,17 @@ interface LazyService<T> {
|
|
|
584
643
|
}
|
|
585
644
|
/**
|
|
586
645
|
* Create a lazy singleton from a factory function.
|
|
646
|
+
*
|
|
647
|
+
* Creates a service that lazily initializes on first access and caches the instance.
|
|
648
|
+
* Useful for expensive resources like database connections or API clients.
|
|
649
|
+
*
|
|
650
|
+
* @template T - The type of service to create
|
|
651
|
+
* @param {() => T} factory - Factory function that creates the service instance
|
|
652
|
+
* @returns {LazyService<T>} Lazy service with get() and reset() methods
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* const dbService = createLazyService(() => new DatabaseClient(config));
|
|
656
|
+
* const db = dbService.get(); // Initializes on first call
|
|
587
657
|
*/
|
|
588
658
|
declare function createLazyService<T>(factory: () => T): LazyService<T>;
|
|
589
659
|
|
|
@@ -853,6 +923,22 @@ declare function createResolvedField(field: {
|
|
|
853
923
|
validation?: unknown;
|
|
854
924
|
values?: string[];
|
|
855
925
|
}): ResolvedField;
|
|
926
|
+
/**
|
|
927
|
+
* Type guard to check if an object is a ResolvedIR.
|
|
928
|
+
*
|
|
929
|
+
* Validates that an unknown value conforms to the ResolvedIR structure.
|
|
930
|
+
* Checks for required properties and correct types. Used for runtime
|
|
931
|
+
* type checking and validation.
|
|
932
|
+
*
|
|
933
|
+
* @param {unknown} ir - Value to check
|
|
934
|
+
* @returns {boolean} True if value is ResolvedIR, false otherwise
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* if (isResolvedIR(schema)) {
|
|
938
|
+
* // Type-safe access to ResolvedIR properties
|
|
939
|
+
* console.log('Valid IR:', schema.appName);
|
|
940
|
+
* }
|
|
941
|
+
*/
|
|
856
942
|
declare function isResolvedIR(ir: unknown): ir is ResolvedIR;
|
|
857
943
|
|
|
858
944
|
export { type AppSummary, BINDING_CONTEXT_RULES, BINDING_DOCS, type BindingContext, BindingSchema, type CategorizedRemovals, type ChangeAuthor, type ChangeSetDocument, type ChangeSummary, type CreateFlow, DEFAULT_INTERACTION_MODELS, type DeleteFlow, type EditFlow, type GitHubLink, type HistoryMeta, type InteractionModel, type InteractionModelInput, InteractionModelSchema, type LazyService, type ListInteraction, type OperatorName, type PageContentReduction, PatternTypeSchema, type PersistActionName, type ResolvedEntity, type ResolvedEntityBinding, type ResolvedField, type ResolvedIR, type ResolvedNavigation, type ResolvedPage, type ResolvedPattern, type ResolvedSection, type ResolvedSectionEvent, type ResolvedTrait, type ResolvedTraitBinding, type ResolvedTraitDataEntity, type ResolvedTraitEvent, type ResolvedTraitGuard, type ResolvedTraitListener, type ResolvedTraitState, type ResolvedTraitTick, type ResolvedTraitTransition, type ResolvedTraitUIBinding, SExpr, type SaveOptions, type SaveResult, type SchemaChange, type ServiceAction, type ServiceActionName, type ServiceContract, type ServiceEvents, type SnapshotDocument, type StatsView, type StoreContract, type StoreFilter, type StoreFilterOp, type TransitionFrom, type ValidationDocument, type ValidationIssue, type ValidationMeta, type ValidationResults, type ViewFlow, createEmptyResolvedPage, createEmptyResolvedTrait, createLazyService, createResolvedField, createTypedEventBus, getAllOperators, getAllPatternTypes, getBindingExamples, getInteractionModelForDomain, inferTsType, isResolvedIR, validateBindingInContext };
|