@almadar/core 2.5.0 → 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 -1
- package/dist/builders.js +414 -1
- package/dist/builders.js.map +1 -1
- package/dist/compose-behaviors-CnJ5Hn4p.d.ts +119 -0
- package/dist/domain-language/index.d.ts +1 -1
- package/dist/domain-language/index.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +199 -1
- package/dist/index.js.map +1 -1
- package/dist/{schema-BrFR8WMF.d.ts → schema-obC5T1Jm.d.ts} +447 -48
- package/dist/state-machine/index.d.ts +104 -30
- 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.
|
|
101
139
|
*
|
|
102
|
-
* @param binding - Binding string starting with @
|
|
103
|
-
* @returns Parsed binding object or null if invalid
|
|
140
|
+
* @param {string} binding - Binding string starting with @
|
|
141
|
+
* @returns {ParsedBinding | null} Parsed binding object or null if invalid
|
|
142
|
+
*
|
|
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;
|
|
@@ -770,16 +856,46 @@ declare const EntitySchema: z.ZodObject<{
|
|
|
770
856
|
} | undefined;
|
|
771
857
|
}>;
|
|
772
858
|
/**
|
|
773
|
-
*
|
|
774
|
-
*
|
|
859
|
+
* Derives the collection name for a persistent entity.
|
|
860
|
+
*
|
|
861
|
+
* Generates the database collection name by converting the entity name
|
|
862
|
+
* to lowercase and adding an 's' suffix (simple pluralization).
|
|
863
|
+
* Returns undefined for non-persistent entities (runtime/singleton).
|
|
864
|
+
*
|
|
865
|
+
* @param {OrbitalEntity} entity - Entity to derive collection name for
|
|
866
|
+
* @returns {string | undefined} Collection name or undefined for non-persistent entities
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* deriveCollection({ name: 'User', persistence: 'persistent' }); // returns 'users'
|
|
870
|
+
* deriveCollection({ name: 'Task', persistence: 'runtime' }); // returns undefined
|
|
775
871
|
*/
|
|
776
872
|
declare function deriveCollection(entity: OrbitalEntity): string | undefined;
|
|
777
873
|
/**
|
|
778
|
-
*
|
|
874
|
+
* Checks if an entity is runtime-only (not persisted).
|
|
875
|
+
*
|
|
876
|
+
* Type guard to determine if an entity exists only at runtime
|
|
877
|
+
* and is not stored in the database.
|
|
878
|
+
*
|
|
879
|
+
* @param {OrbitalEntity} entity - Entity to check
|
|
880
|
+
* @returns {boolean} True if entity is runtime-only, false otherwise
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
* isRuntimeEntity({ persistence: 'runtime' }); // returns true
|
|
884
|
+
* isRuntimeEntity({ persistence: 'persistent' }); // returns false
|
|
779
885
|
*/
|
|
780
886
|
declare function isRuntimeEntity(entity: OrbitalEntity): boolean;
|
|
781
887
|
/**
|
|
782
|
-
*
|
|
888
|
+
* Checks if an entity is a singleton.
|
|
889
|
+
*
|
|
890
|
+
* Type guard to determine if an entity has a single global instance
|
|
891
|
+
* rather than multiple records in a collection.
|
|
892
|
+
*
|
|
893
|
+
* @param {OrbitalEntity} entity - Entity to check
|
|
894
|
+
* @returns {boolean} True if entity is a singleton, false otherwise
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* isSingletonEntity({ persistence: 'singleton' }); // returns true
|
|
898
|
+
* isSingletonEntity({ persistence: 'persistent' }); // returns false
|
|
783
899
|
*/
|
|
784
900
|
declare function isSingletonEntity(entity: OrbitalEntity): boolean;
|
|
785
901
|
|
|
@@ -1199,6 +1315,19 @@ declare const EffectSchema: z.ZodEffects<z.ZodArray<z.ZodUnknown, "many">, unkno
|
|
|
1199
1315
|
type EffectInput = z.input<typeof EffectSchema>;
|
|
1200
1316
|
/**
|
|
1201
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
|
|
1202
1331
|
*/
|
|
1203
1332
|
declare function isEffect(value: unknown): value is Effect;
|
|
1204
1333
|
/**
|
|
@@ -1206,18 +1335,51 @@ declare function isEffect(value: unknown): value is Effect;
|
|
|
1206
1335
|
*/
|
|
1207
1336
|
declare const isSExprEffect: typeof isEffect;
|
|
1208
1337
|
/**
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
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]
|
|
1211
1351
|
*/
|
|
1212
1352
|
declare function set(binding: string, value: SExpr): Effect;
|
|
1213
1353
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
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"]
|
|
1216
1367
|
*/
|
|
1217
1368
|
declare function emit(event: string, payload?: Record<string, unknown>): Effect;
|
|
1218
1369
|
/**
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
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" }]
|
|
1221
1383
|
*/
|
|
1222
1384
|
declare function navigate(path: string): NavigateEffect;
|
|
1223
1385
|
declare function navigate(path: string, params: Record<string, string>): NavigateEffect;
|
|
@@ -1664,8 +1826,8 @@ type StateMachineInput = z.input<typeof StateMachineSchema>;
|
|
|
1664
1826
|
* Circuit events are user-defined events that participate in the closed circuit pattern.
|
|
1665
1827
|
* Internal/system events start with underscore (e.g., _INIT, _TICK, _TIMER).
|
|
1666
1828
|
*
|
|
1667
|
-
* @param event - Event name to check
|
|
1668
|
-
* @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)
|
|
1669
1831
|
*
|
|
1670
1832
|
* @example
|
|
1671
1833
|
* isCircuitEvent('CREATE') // true
|
|
@@ -3188,17 +3350,65 @@ declare const TraitRefSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
|
3188
3350
|
/**
|
|
3189
3351
|
* Check if a trait ref is an inline Trait definition
|
|
3190
3352
|
*/
|
|
3353
|
+
/**
|
|
3354
|
+
* Checks if a trait reference is an inline trait definition.
|
|
3355
|
+
*
|
|
3356
|
+
* Type guard to determine if a TraitRef is an inline trait object
|
|
3357
|
+
* (with 'name' property) rather than a string reference or object reference.
|
|
3358
|
+
*
|
|
3359
|
+
* @param {TraitRef} traitRef - Trait reference to check
|
|
3360
|
+
* @returns {boolean} True if traitRef is an inline trait, false otherwise
|
|
3361
|
+
*
|
|
3362
|
+
* @example
|
|
3363
|
+
* isInlineTrait({ name: 'MyTrait' }); // returns true (inline)
|
|
3364
|
+
* isInlineTrait('MyTrait'); // returns false (string reference)
|
|
3365
|
+
* isInlineTrait({ ref: 'MyTrait' }); // returns false (object reference)
|
|
3366
|
+
*/
|
|
3191
3367
|
declare function isInlineTrait(traitRef: TraitRef): traitRef is Trait;
|
|
3192
3368
|
/**
|
|
3193
|
-
*
|
|
3369
|
+
* Extracts the trait name from a trait reference.
|
|
3370
|
+
*
|
|
3371
|
+
* Handles all trait reference formats (string, inline object, object reference)
|
|
3372
|
+
* and returns the canonical trait name.
|
|
3373
|
+
*
|
|
3374
|
+
* @param {TraitRef} traitRef - Trait reference to extract name from
|
|
3375
|
+
* @returns {string} Trait name
|
|
3376
|
+
*
|
|
3377
|
+
* @example
|
|
3378
|
+
* getTraitName('MyTrait'); // returns 'MyTrait'
|
|
3379
|
+
* getTraitName({ name: 'MyTrait' }); // returns 'MyTrait'
|
|
3380
|
+
* getTraitName({ ref: 'MyTrait' }); // returns 'MyTrait'
|
|
3194
3381
|
*/
|
|
3195
3382
|
declare function getTraitName(traitRef: TraitRef): string;
|
|
3196
3383
|
/**
|
|
3197
|
-
*
|
|
3384
|
+
* Extracts the configuration from a trait reference.
|
|
3385
|
+
*
|
|
3386
|
+
* Returns the configuration object for trait references that support it
|
|
3387
|
+
* (object references with 'config' property). Returns undefined for
|
|
3388
|
+
* string references and inline traits.
|
|
3389
|
+
*
|
|
3390
|
+
* @param {TraitRef} traitRef - Trait reference to extract config from
|
|
3391
|
+
* @returns {Record<string, unknown> | undefined} Trait configuration or undefined
|
|
3392
|
+
*
|
|
3393
|
+
* @example
|
|
3394
|
+
* getTraitConfig('MyTrait'); // returns undefined
|
|
3395
|
+
* getTraitConfig({ name: 'MyTrait' }); // returns undefined
|
|
3396
|
+
* getTraitConfig({ ref: 'MyTrait', config: { option: 'value' } }); // returns config object
|
|
3198
3397
|
*/
|
|
3199
3398
|
declare function getTraitConfig(traitRef: TraitRef): Record<string, unknown> | undefined;
|
|
3200
3399
|
/**
|
|
3201
|
-
*
|
|
3400
|
+
* Normalizes a trait reference to object form.
|
|
3401
|
+
*
|
|
3402
|
+
* Converts any trait reference format (string, inline, object) to a
|
|
3403
|
+
* standardized object format with 'ref' and optional 'config' properties.
|
|
3404
|
+
*
|
|
3405
|
+
* @param {TraitRef} traitRef - Trait reference to normalize
|
|
3406
|
+
* @returns {{ ref: string; config?: Record<string, unknown> }} Normalized trait reference
|
|
3407
|
+
*
|
|
3408
|
+
* @example
|
|
3409
|
+
* normalizeTraitRef('MyTrait'); // returns { ref: 'MyTrait' }
|
|
3410
|
+
* normalizeTraitRef({ name: 'MyTrait' }); // returns { ref: 'MyTrait' }
|
|
3411
|
+
* normalizeTraitRef({ ref: 'MyTrait', config: {...} }); // returns original
|
|
3202
3412
|
*/
|
|
3203
3413
|
declare function normalizeTraitRef(traitRef: TraitRef): {
|
|
3204
3414
|
ref: string;
|
|
@@ -4281,7 +4491,17 @@ declare const ThemeDefinitionSchema: z.ZodObject<{
|
|
|
4281
4491
|
*/
|
|
4282
4492
|
type ThemeRef = ThemeDefinition | string;
|
|
4283
4493
|
/**
|
|
4284
|
-
*
|
|
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
|
|
4285
4505
|
*/
|
|
4286
4506
|
declare function isThemeReference(theme: ThemeRef): theme is string;
|
|
4287
4507
|
/**
|
|
@@ -4883,7 +5103,17 @@ declare const ServiceDefinitionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
4883
5103
|
*/
|
|
4884
5104
|
type ServiceRef = ServiceDefinition | string;
|
|
4885
5105
|
/**
|
|
4886
|
-
*
|
|
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
|
|
4887
5117
|
*/
|
|
4888
5118
|
declare function isServiceReference(service: ServiceRef): service is string;
|
|
4889
5119
|
/**
|
|
@@ -5018,23 +5248,62 @@ declare const ServiceRefSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.Z
|
|
|
5018
5248
|
env?: Record<string, string> | undefined;
|
|
5019
5249
|
}>]>, z.ZodString]>;
|
|
5020
5250
|
/**
|
|
5021
|
-
*
|
|
5022
|
-
*
|
|
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
|
|
5023
5262
|
*/
|
|
5024
5263
|
declare function parseServiceRef(ref: string): {
|
|
5025
5264
|
alias: string;
|
|
5026
5265
|
serviceName: string;
|
|
5027
5266
|
} | null;
|
|
5028
5267
|
/**
|
|
5029
|
-
*
|
|
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
|
|
5030
5279
|
*/
|
|
5031
5280
|
declare function isRestService(service: ServiceDefinition): service is RestServiceDef;
|
|
5032
5281
|
/**
|
|
5033
|
-
*
|
|
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
|
|
5034
5293
|
*/
|
|
5035
5294
|
declare function isSocketService(service: ServiceDefinition): service is SocketServiceDef;
|
|
5036
5295
|
/**
|
|
5037
|
-
*
|
|
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
|
|
5038
5307
|
*/
|
|
5039
5308
|
declare function isMcpService(service: ServiceDefinition): service is McpServiceDef;
|
|
5040
5309
|
/**
|
|
@@ -5109,7 +5378,20 @@ declare const UseDeclarationSchema: z.ZodObject<{
|
|
|
5109
5378
|
*/
|
|
5110
5379
|
type EntityRef = Entity | string;
|
|
5111
5380
|
/**
|
|
5112
|
-
*
|
|
5381
|
+
* Checks if an entity reference is a string reference.
|
|
5382
|
+
*
|
|
5383
|
+
* Type guard to determine if an EntityRef is a string reference
|
|
5384
|
+
* (format: "Alias.entity") rather than an inline entity definition.
|
|
5385
|
+
*
|
|
5386
|
+
* @param {EntityRef} entity - Entity reference to check
|
|
5387
|
+
* @returns {boolean} True if entity is a string reference, false if inline definition
|
|
5388
|
+
*
|
|
5389
|
+
* @example
|
|
5390
|
+
* const ref1 = "User.entity"; // string reference
|
|
5391
|
+
* const ref2 = { name: "User", fields: [...] }; // inline definition
|
|
5392
|
+
*
|
|
5393
|
+
* isEntityReference(ref1); // returns true
|
|
5394
|
+
* isEntityReference(ref2); // returns false
|
|
5113
5395
|
*/
|
|
5114
5396
|
declare function isEntityReference(entity: EntityRef): entity is string;
|
|
5115
5397
|
/**
|
|
@@ -5215,15 +5497,56 @@ interface PageRefObject {
|
|
|
5215
5497
|
*/
|
|
5216
5498
|
type PageRef = Page | string | PageRefObject;
|
|
5217
5499
|
/**
|
|
5218
|
-
*
|
|
5500
|
+
* Checks if a page reference is a string reference.
|
|
5501
|
+
*
|
|
5502
|
+
* Type guard to determine if a PageRef is a simple string reference
|
|
5503
|
+
* (format: "Alias.pages.PageName") rather than an inline page definition or object reference.
|
|
5504
|
+
*
|
|
5505
|
+
* @param {PageRef} page - Page reference to check
|
|
5506
|
+
* @returns {boolean} True if page is a string reference, false otherwise
|
|
5507
|
+
*
|
|
5508
|
+
* @example
|
|
5509
|
+
* const ref1 = "User.pages.Profile"; // string reference
|
|
5510
|
+
* const ref2 = { name: "Dashboard", path: "/" }; // inline definition
|
|
5511
|
+
*
|
|
5512
|
+
* isPageReferenceString(ref1); // returns true
|
|
5513
|
+
* isPageReferenceString(ref2); // returns false
|
|
5219
5514
|
*/
|
|
5220
5515
|
declare function isPageReferenceString(page: PageRef): page is string;
|
|
5221
5516
|
/**
|
|
5222
|
-
*
|
|
5517
|
+
* Checks if a page reference is a reference object.
|
|
5518
|
+
*
|
|
5519
|
+
* Type guard to determine if a PageRef is an object reference
|
|
5520
|
+
* with a 'ref' property rather than an inline page definition.
|
|
5521
|
+
*
|
|
5522
|
+
* @param {PageRef} page - Page reference to check
|
|
5523
|
+
* @returns {boolean} True if page is a reference object, false otherwise
|
|
5524
|
+
*
|
|
5525
|
+
* @example
|
|
5526
|
+
* const ref1 = { ref: "User.pages.Profile", path: "/custom" }; // reference object
|
|
5527
|
+
* const ref2 = { name: "Dashboard", path: "/" }; // inline definition
|
|
5528
|
+
*
|
|
5529
|
+
* isPageReferenceObject(ref1); // returns true
|
|
5530
|
+
* isPageReferenceObject(ref2); // returns false
|
|
5223
5531
|
*/
|
|
5224
5532
|
declare function isPageReferenceObject(page: PageRef): page is PageRefObject;
|
|
5225
5533
|
/**
|
|
5226
|
-
*
|
|
5534
|
+
* Checks if a page reference is any type of reference.
|
|
5535
|
+
*
|
|
5536
|
+
* Type guard to determine if a PageRef is a reference (string or object)
|
|
5537
|
+
* rather than an inline page definition.
|
|
5538
|
+
*
|
|
5539
|
+
* @param {PageRef} page - Page reference to check
|
|
5540
|
+
* @returns {boolean} True if page is a reference, false if inline definition
|
|
5541
|
+
*
|
|
5542
|
+
* @example
|
|
5543
|
+
* const ref1 = "User.pages.Profile"; // string reference
|
|
5544
|
+
* const ref2 = { ref: "User.pages.Profile", path: "/custom" }; // object reference
|
|
5545
|
+
* const ref3 = { name: "Dashboard", path: "/" }; // inline definition
|
|
5546
|
+
*
|
|
5547
|
+
* isPageReference(ref1); // returns true
|
|
5548
|
+
* isPageReference(ref2); // returns true
|
|
5549
|
+
* isPageReference(ref3); // returns false
|
|
5227
5550
|
*/
|
|
5228
5551
|
declare function isPageReference(page: PageRef): page is string | PageRefObject;
|
|
5229
5552
|
/**
|
|
@@ -5295,27 +5618,64 @@ declare const PageRefSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
5295
5618
|
path?: string | undefined;
|
|
5296
5619
|
}>]>;
|
|
5297
5620
|
/**
|
|
5298
|
-
*
|
|
5621
|
+
* Checks if a trait reference is an imported reference.
|
|
5622
|
+
*
|
|
5623
|
+
* Determines if a trait reference uses the imported format
|
|
5624
|
+
* "Alias.traits.TraitName" rather than a simple "TraitName".
|
|
5625
|
+
*
|
|
5626
|
+
* @param {string} ref - Trait reference to check
|
|
5627
|
+
* @returns {boolean} True if reference is imported format, false otherwise
|
|
5628
|
+
*
|
|
5629
|
+
* @example
|
|
5630
|
+
* isImportedTraitRef("User.traits.Profile"); // returns true
|
|
5631
|
+
* isImportedTraitRef("Profile"); // returns false
|
|
5299
5632
|
*/
|
|
5300
5633
|
declare function isImportedTraitRef(ref: string): boolean;
|
|
5301
5634
|
/**
|
|
5302
|
-
*
|
|
5303
|
-
*
|
|
5635
|
+
* Parses an imported trait reference.
|
|
5636
|
+
*
|
|
5637
|
+
* Extracts the alias and trait name from an imported trait reference
|
|
5638
|
+
* in format "Alias.traits.TraitName". Returns null if not a valid imported reference.
|
|
5639
|
+
*
|
|
5640
|
+
* @param {string} ref - Trait reference to parse
|
|
5641
|
+
* @returns {{ alias: string; traitName: string } | null} Parsed reference or null
|
|
5642
|
+
*
|
|
5643
|
+
* @example
|
|
5644
|
+
* parseImportedTraitRef("User.traits.Profile"); // returns { alias: "User", traitName: "Profile" }
|
|
5645
|
+
* parseImportedTraitRef("Profile"); // returns null
|
|
5304
5646
|
*/
|
|
5305
5647
|
declare function parseImportedTraitRef(ref: string): {
|
|
5306
5648
|
alias: string;
|
|
5307
5649
|
traitName: string;
|
|
5308
5650
|
} | null;
|
|
5309
5651
|
/**
|
|
5310
|
-
*
|
|
5311
|
-
*
|
|
5652
|
+
* Parses an entity reference.
|
|
5653
|
+
*
|
|
5654
|
+
* Extracts the alias from an entity reference in format "Alias.entity".
|
|
5655
|
+
* Returns null if not a valid entity reference.
|
|
5656
|
+
*
|
|
5657
|
+
* @param {string} ref - Entity reference to parse
|
|
5658
|
+
* @returns {{ alias: string } | null} Parsed reference or null
|
|
5659
|
+
*
|
|
5660
|
+
* @example
|
|
5661
|
+
* parseEntityRef("User.entity"); // returns { alias: "User" }
|
|
5662
|
+
* parseEntityRef("User"); // returns null
|
|
5312
5663
|
*/
|
|
5313
5664
|
declare function parseEntityRef(ref: string): {
|
|
5314
5665
|
alias: string;
|
|
5315
5666
|
} | null;
|
|
5316
5667
|
/**
|
|
5317
|
-
*
|
|
5318
|
-
*
|
|
5668
|
+
* Parses a page reference.
|
|
5669
|
+
*
|
|
5670
|
+
* Extracts the alias and page name from a page reference
|
|
5671
|
+
* in format "Alias.pages.PageName". Returns null if not a valid page reference.
|
|
5672
|
+
*
|
|
5673
|
+
* @param {string} ref - Page reference to parse
|
|
5674
|
+
* @returns {{ alias: string; pageName: string } | null} Parsed reference or null
|
|
5675
|
+
*
|
|
5676
|
+
* @example
|
|
5677
|
+
* parsePageRef("User.pages.Profile"); // returns { alias: "User", pageName: "Profile" }
|
|
5678
|
+
* parsePageRef("Profile"); // returns null
|
|
5319
5679
|
*/
|
|
5320
5680
|
declare function parsePageRef(ref: string): {
|
|
5321
5681
|
alias: string;
|
|
@@ -13320,11 +13680,50 @@ declare const OrbitalSchemaSchema: z.ZodObject<{
|
|
|
13320
13680
|
}> | undefined;
|
|
13321
13681
|
}>;
|
|
13322
13682
|
/**
|
|
13323
|
-
*
|
|
13683
|
+
* Parses raw data into a validated OrbitalSchema.
|
|
13684
|
+
*
|
|
13685
|
+
* Uses Zod validation to ensure the data conforms to the OrbitalSchema structure.
|
|
13686
|
+
* Throws a ZodError if validation fails. For safe parsing that doesn't throw,
|
|
13687
|
+
* use `safeParseOrbitalSchema()` instead.
|
|
13688
|
+
*
|
|
13689
|
+
* @param {unknown} data - Raw data to parse (typically JSON)
|
|
13690
|
+
* @returns {OrbitalSchema} Validated orbital schema
|
|
13691
|
+
* @throws {z.ZodError} If data doesn't match OrbitalSchema structure
|
|
13692
|
+
*
|
|
13693
|
+
* @example
|
|
13694
|
+
* ```typescript
|
|
13695
|
+
* try {
|
|
13696
|
+
* const schema = parseOrbitalSchema(jsonData);
|
|
13697
|
+
* console.log('Valid schema:', schema.name);
|
|
13698
|
+
* } catch (error) {
|
|
13699
|
+
* console.error('Invalid schema:', error);
|
|
13700
|
+
* }
|
|
13701
|
+
* ```
|
|
13702
|
+
*
|
|
13703
|
+
* @see safeParseOrbitalSchema
|
|
13324
13704
|
*/
|
|
13325
13705
|
declare function parseOrbitalSchema(data: unknown): OrbitalSchema;
|
|
13326
13706
|
/**
|
|
13327
|
-
*
|
|
13707
|
+
* Safely parses raw data into a validated OrbitalSchema without throwing.
|
|
13708
|
+
*
|
|
13709
|
+
* Uses Zod's safeParse method to validate data and return a result object
|
|
13710
|
+
* instead of throwing errors. This is useful for form validation and
|
|
13711
|
+
* user input handling where you want to gracefully handle invalid data.
|
|
13712
|
+
*
|
|
13713
|
+
* @param {unknown} data - Raw data to parse (typically JSON)
|
|
13714
|
+
* @returns {z.SafeParseReturnType<OrbitalSchema, OrbitalSchema>} Parse result with success/status
|
|
13715
|
+
*
|
|
13716
|
+
* @example
|
|
13717
|
+
* ```typescript
|
|
13718
|
+
* const result = safeParseOrbitalSchema(jsonData);
|
|
13719
|
+
* if (result.success) {
|
|
13720
|
+
* console.log('Valid schema:', result.data.name);
|
|
13721
|
+
* } else {
|
|
13722
|
+
* console.error('Validation errors:', result.error);
|
|
13723
|
+
* }
|
|
13724
|
+
* ```
|
|
13725
|
+
*
|
|
13726
|
+
* @see parseOrbitalSchema
|
|
13328
13727
|
*/
|
|
13329
13728
|
declare function safeParseOrbitalSchema(data: unknown): z.SafeParseReturnType<{
|
|
13330
13729
|
name: string;
|