@lokascript/framework 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +29 -516
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +20 -128
- package/dist/core/index.js.map +1 -1
- package/dist/core/pattern-matching/index.js +19 -12
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/tokenization/index.js.map +1 -1
- package/dist/core/types.d.ts +7 -354
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +21 -129
- package/dist/core/types.js.map +1 -1
- package/dist/generation/diagnostics.d.ts +5 -115
- package/dist/generation/diagnostics.d.ts.map +1 -1
- package/dist/generation/index.js +20 -77
- package/dist/generation/index.js.map +1 -1
- package/dist/index.cjs +189 -1458
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -1347
- package/dist/index.js.map +1 -1
- package/dist/interfaces/value-extractor.d.ts +20 -0
- package/dist/interfaces/value-extractor.d.ts.map +1 -1
- package/dist/ir/explicit-parser.d.ts +2 -83
- package/dist/ir/explicit-parser.d.ts.map +1 -1
- package/dist/ir/explicit-renderer.d.ts +2 -31
- package/dist/ir/explicit-renderer.d.ts.map +1 -1
- package/dist/ir/index.js +89 -1260
- package/dist/ir/index.js.map +1 -1
- package/dist/ir/protocol-json.d.ts +2 -70
- package/dist/ir/protocol-json.d.ts.map +1 -1
- package/dist/ir/references.d.ts +2 -16
- package/dist/ir/references.d.ts.map +1 -1
- package/dist/ir/types.d.ts +2 -148
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/parsing/index.js +19 -12
- package/dist/parsing/index.js.map +1 -1
- package/dist/schema/command-schema.d.ts +3 -92
- package/dist/schema/command-schema.d.ts.map +1 -1
- package/dist/schema/index.js +3 -20
- package/dist/schema/index.js.map +1 -1
- package/dist/testing/index.js +1133 -755
- package/dist/testing/index.js.map +1 -1
- package/package.json +6 -2
- package/src/core/types.ts +71 -600
- package/src/generation/diagnostics.ts +12 -233
- package/src/interfaces/value-extractor.ts +32 -0
- package/src/ir/explicit-parser.ts +12 -792
- package/src/ir/explicit-renderer.ts +2 -195
- package/src/ir/from-interchange.test.ts +91 -4
- package/src/ir/from-interchange.ts +59 -0
- package/src/ir/protocol-json.test.ts +16 -7
- package/src/ir/protocol-json.ts +9 -748
- package/src/ir/references.ts +2 -30
- package/src/ir/types.ts +18 -190
- package/src/schema/command-schema.ts +3 -134
package/dist/core/types.d.ts
CHANGED
|
@@ -1,221 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Core Types — re-exported from @lokascript/intent + framework-specific extensions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the MEANING of DSL commands independent of surface syntax.
|
|
4
|
+
* The universal semantic types (SemanticNode, SemanticValue, etc.) now live in
|
|
5
|
+
* @lokascript/intent and are re-exported here for backward compatibility.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
7
|
+
* Framework-specific types (tokenization, pattern matching) are defined below.
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* This is generic - each DSL defines its own set of actions.
|
|
14
|
-
*
|
|
15
|
-
* Examples:
|
|
16
|
-
* - Hyperscript: 'toggle', 'add', 'remove', 'fetch'
|
|
17
|
-
* - SQL: 'select', 'insert', 'update', 'delete'
|
|
18
|
-
* - Animation: 'animate', 'fade', 'slide', 'rotate'
|
|
19
|
-
*/
|
|
20
|
-
export type ActionType = string;
|
|
21
|
-
/**
|
|
22
|
-
* Semantic role represents the grammatical function of a part of a command.
|
|
23
|
-
* This is generic - each DSL can define its own roles, though common ones include:
|
|
24
|
-
*
|
|
25
|
-
* Common roles across DSLs:
|
|
26
|
-
* - action: The verb/command
|
|
27
|
-
* - patient: What is being acted upon
|
|
28
|
-
* - destination: Where something goes
|
|
29
|
-
* - source: Where something comes from
|
|
30
|
-
* - condition: Boolean expressions
|
|
31
|
-
* - quantity: Numeric amounts
|
|
32
|
-
* - duration: Time spans
|
|
33
|
-
*
|
|
34
|
-
* Examples:
|
|
35
|
-
* - Hyperscript: 'patient', 'destination', 'source', 'event', 'style'
|
|
36
|
-
* - SQL: 'columns', 'table', 'condition', 'orderBy', 'limit'
|
|
37
|
-
* - Animation: 'target', 'duration', 'easing', 'delay'
|
|
38
|
-
*/
|
|
39
|
-
export type SemanticRole = string;
|
|
40
|
-
/**
|
|
41
|
-
* A semantic value represents a typed piece of data in a semantic node.
|
|
42
|
-
* Values are language-neutral - they capture what something IS, not how it's written.
|
|
43
|
-
*/
|
|
44
|
-
export type SemanticValue = LiteralValue | SelectorValue | ReferenceValue | PropertyPathValue | ExpressionValue | FlagValue;
|
|
45
|
-
/**
|
|
46
|
-
* Expected value types for role tokens.
|
|
47
|
-
* Shared between RoleSpec (command-schemas) and RolePatternToken.
|
|
48
|
-
*/
|
|
49
|
-
export type ExpectedType = SemanticValue['type'];
|
|
50
|
-
export interface LiteralValue {
|
|
51
|
-
readonly type: 'literal';
|
|
52
|
-
readonly value: string | number | boolean;
|
|
53
|
-
readonly dataType?: 'string' | 'number' | 'boolean' | 'duration';
|
|
54
|
-
}
|
|
55
|
-
export interface SelectorValue {
|
|
56
|
-
readonly type: 'selector';
|
|
57
|
-
readonly value: string;
|
|
58
|
-
readonly selectorKind?: 'id' | 'class' | 'attribute' | 'element' | 'complex' | 'identifier';
|
|
59
|
-
}
|
|
60
|
-
export interface ReferenceValue {
|
|
61
|
-
readonly type: 'reference';
|
|
62
|
-
readonly value: string;
|
|
63
|
-
}
|
|
64
|
-
export interface PropertyPathValue {
|
|
65
|
-
readonly type: 'property-path';
|
|
66
|
-
readonly object: SemanticValue;
|
|
67
|
-
readonly property: string;
|
|
68
|
-
}
|
|
69
|
-
export interface ExpressionValue {
|
|
70
|
-
readonly type: 'expression';
|
|
71
|
-
/** Raw expression string for complex expressions that need further parsing */
|
|
72
|
-
readonly raw: string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* A boolean flag value — present (+flag) or negated (~flag).
|
|
76
|
-
* Used in declarative domains for no-value attributes like primary-key, not-null.
|
|
77
|
-
*/
|
|
78
|
-
export interface FlagValue {
|
|
79
|
-
readonly type: 'flag';
|
|
80
|
-
readonly name: string;
|
|
81
|
-
readonly enabled: boolean;
|
|
82
|
-
}
|
|
83
|
-
/** A metadata annotation on a node (v1.2). */
|
|
84
|
-
export interface Annotation {
|
|
85
|
-
readonly name: string;
|
|
86
|
-
readonly value?: string;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* A type constraint diagnostic attached to a node (v1.2).
|
|
90
|
-
*
|
|
91
|
-
* Named `ProtocolDiagnostic` to avoid collision with the framework's own
|
|
92
|
-
* `Diagnostic` type (which has `severity: 'error' | 'warning' | 'info'`
|
|
93
|
-
* and `suggestion?: string`).
|
|
94
|
-
*/
|
|
95
|
-
export interface ProtocolDiagnostic {
|
|
96
|
-
readonly level: 'error' | 'warning';
|
|
97
|
-
readonly role: string;
|
|
98
|
-
readonly message: string;
|
|
99
|
-
readonly code: string;
|
|
100
|
-
}
|
|
101
|
-
/** Async coordination variant (v1.2). */
|
|
102
|
-
export type AsyncVariant = 'all' | 'race';
|
|
103
|
-
/** A single arm in a match command (v1.2). */
|
|
104
|
-
export interface MatchArm {
|
|
105
|
-
readonly pattern: SemanticValue;
|
|
106
|
-
readonly body: SemanticNode[];
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Base interface for all semantic nodes.
|
|
110
|
-
* Semantic nodes capture the MEANING of DSL constructs.
|
|
111
|
-
*/
|
|
112
|
-
export interface SemanticNode {
|
|
113
|
-
readonly kind: 'command' | 'event-handler' | 'conditional' | 'compound' | 'loop';
|
|
114
|
-
readonly action: ActionType;
|
|
115
|
-
readonly roles: ReadonlyMap<SemanticRole, SemanticValue>;
|
|
116
|
-
readonly metadata?: SemanticMetadata;
|
|
117
|
-
/** Metadata annotations (v1.2). */
|
|
118
|
-
readonly annotations?: readonly Annotation[];
|
|
119
|
-
/** Diagnostics from parsing, validation, and schema checks (v1.2, extended v1.2.1). */
|
|
120
|
-
readonly diagnostics?: readonly Diagnostic[];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Metadata about the source of a semantic node.
|
|
124
|
-
* Useful for debugging, error messages, and round-trip conversion.
|
|
125
|
-
*/
|
|
126
|
-
export interface SemanticMetadata {
|
|
127
|
-
readonly sourceLanguage?: string;
|
|
128
|
-
readonly sourceText?: string;
|
|
129
|
-
readonly sourcePosition?: SourcePosition;
|
|
130
|
-
readonly patternId?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Confidence score for the parse (0-1).
|
|
133
|
-
* Higher values indicate more certain matches.
|
|
134
|
-
* - 1.0: Exact match with all roles captured
|
|
135
|
-
* - 0.8-0.99: High confidence with minor uncertainty
|
|
136
|
-
* - 0.6-0.8: Medium confidence (normalization, defaults applied)
|
|
137
|
-
* - <0.6: Low confidence (may need fallback)
|
|
138
|
-
*/
|
|
139
|
-
readonly confidence?: number;
|
|
140
|
-
}
|
|
141
|
-
export interface SourcePosition {
|
|
142
|
-
readonly start: number;
|
|
143
|
-
readonly end: number;
|
|
144
|
-
readonly line?: number;
|
|
145
|
-
readonly column?: number;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* A command semantic node - represents a single DSL command.
|
|
149
|
-
*
|
|
150
|
-
* v1.2 adds optional fields for try/catch/finally, async coordination (all/race),
|
|
151
|
-
* and pattern matching (match/arms). These are encoded as fields on command nodes
|
|
152
|
-
* (matching the protocol wire format) rather than new node kinds.
|
|
153
|
-
*/
|
|
154
|
-
export interface CommandSemanticNode extends SemanticNode {
|
|
155
|
-
readonly kind: 'command';
|
|
156
|
-
/** try body — commands to execute in the try block (v1.2). */
|
|
157
|
-
readonly body?: readonly SemanticNode[];
|
|
158
|
-
/** catch branch — commands to execute on error (v1.2). */
|
|
159
|
-
readonly catchBranch?: readonly SemanticNode[];
|
|
160
|
-
/** finally branch — cleanup commands that always execute (v1.2). */
|
|
161
|
-
readonly finallyBranch?: readonly SemanticNode[];
|
|
162
|
-
/** Async coordination variant: all (wait for all) or race (first wins) (v1.2). */
|
|
163
|
-
readonly asyncVariant?: AsyncVariant;
|
|
164
|
-
/** Async body — concurrent commands for all/race (v1.2). */
|
|
165
|
-
readonly asyncBody?: readonly SemanticNode[];
|
|
166
|
-
/** Match arms — pattern/body pairs for match command (v1.2). */
|
|
167
|
-
readonly arms?: readonly MatchArm[];
|
|
168
|
-
/** Default arm — executed when no match arm matches (v1.2). */
|
|
169
|
-
readonly defaultArm?: readonly SemanticNode[];
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* An event handler semantic node - represents trigger-based commands.
|
|
173
|
-
* E.g., "on click [commands]" in hyperscript, or "when condition [commands]" in other DSLs.
|
|
174
|
-
*/
|
|
175
|
-
export interface EventHandlerSemanticNode extends SemanticNode {
|
|
176
|
-
readonly kind: 'event-handler';
|
|
177
|
-
readonly body: SemanticNode[];
|
|
178
|
-
readonly eventModifiers?: EventModifiers;
|
|
179
|
-
readonly additionalEvents?: readonly SemanticValue[];
|
|
180
|
-
readonly parameterNames?: readonly string[];
|
|
181
|
-
}
|
|
182
|
-
export interface EventModifiers {
|
|
183
|
-
readonly once?: boolean;
|
|
184
|
-
readonly debounce?: number;
|
|
185
|
-
readonly throttle?: number;
|
|
186
|
-
readonly queue?: 'first' | 'last' | 'all' | 'none';
|
|
187
|
-
readonly from?: SemanticValue;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* A conditional semantic node - represents "if [condition] then [body] else [body]".
|
|
191
|
-
*/
|
|
192
|
-
export interface ConditionalSemanticNode extends SemanticNode {
|
|
193
|
-
readonly kind: 'conditional';
|
|
194
|
-
readonly thenBranch: SemanticNode[];
|
|
195
|
-
readonly elseBranch?: SemanticNode[];
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* A compound semantic node - represents multiple chained statements.
|
|
199
|
-
*/
|
|
200
|
-
export interface CompoundSemanticNode extends SemanticNode {
|
|
201
|
-
readonly kind: 'compound';
|
|
202
|
-
readonly statements: SemanticNode[];
|
|
203
|
-
readonly chainType: 'then' | 'and' | 'async' | 'sequential' | 'pipe';
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Loop variant discriminant for different loop types.
|
|
207
|
-
*/
|
|
208
|
-
export type LoopVariant = 'forever' | 'times' | 'for' | 'while' | 'until';
|
|
209
|
-
/**
|
|
210
|
-
* A loop semantic node - represents repeat/for/while loops.
|
|
211
|
-
*/
|
|
212
|
-
export interface LoopSemanticNode extends SemanticNode {
|
|
213
|
-
readonly kind: 'loop';
|
|
214
|
-
readonly loopVariant: LoopVariant;
|
|
215
|
-
readonly body: SemanticNode[];
|
|
216
|
-
readonly loopVariable?: string;
|
|
217
|
-
readonly indexVariable?: string;
|
|
218
|
-
}
|
|
9
|
+
export type { ActionType, SemanticRole, SemanticValue, ExpectedType, LiteralValue, SelectorValue, ReferenceValue, PropertyPathValue, ExpressionValue, FlagValue, Annotation, ProtocolDiagnostic, AsyncVariant, MatchArm, SemanticNode, SemanticMetadata, SourcePosition, CommandSemanticNode, EventHandlerSemanticNode, EventModifiers, ConditionalSemanticNode, CompoundSemanticNode, LoopVariant, LoopSemanticNode, LSEEnvelope, } from '@lokascript/intent';
|
|
10
|
+
export { createLiteral, createSelector, createReference, createPropertyPath, createExpression, createFlag, createCommandNode, createEventHandlerNode, createConditionalNode, createCompoundNode, createLoopNode, createTryNode, createAsyncNode, createMatchNode, extractValue, extractRoleValue, getRoleValue, } from '@lokascript/intent';
|
|
11
|
+
import type { ActionType, SemanticRole, SemanticValue, SelectorValue, ExpectedType, SourcePosition } from '@lokascript/intent';
|
|
219
12
|
/**
|
|
220
13
|
* Token kind - categorizes what type of token this is.
|
|
221
14
|
*/
|
|
@@ -227,13 +20,9 @@ export interface LanguageToken {
|
|
|
227
20
|
readonly value: string;
|
|
228
21
|
readonly kind: TokenKind;
|
|
229
22
|
readonly position: SourcePosition;
|
|
230
|
-
/** Normalized form from explicit keyword map */
|
|
231
23
|
readonly normalized?: string;
|
|
232
|
-
/** Morphologically normalized stem */
|
|
233
24
|
readonly stem?: string;
|
|
234
|
-
/** Confidence in the morphological stem (0.0-1.0) */
|
|
235
25
|
readonly stemConfidence?: number;
|
|
236
|
-
/** Additional metadata for specific token types */
|
|
237
26
|
readonly metadata?: Record<string, unknown>;
|
|
238
27
|
}
|
|
239
28
|
/**
|
|
@@ -242,22 +31,13 @@ export interface LanguageToken {
|
|
|
242
31
|
export interface TokenStream {
|
|
243
32
|
readonly tokens: readonly LanguageToken[];
|
|
244
33
|
readonly language: string;
|
|
245
|
-
/** Look at token at current position + offset without consuming */
|
|
246
34
|
peek(offset?: number): LanguageToken | null;
|
|
247
|
-
/** Consume and return current token, advance position */
|
|
248
35
|
advance(): LanguageToken;
|
|
249
|
-
/** Check if we've consumed all tokens */
|
|
250
36
|
isAtEnd(): boolean;
|
|
251
|
-
/** Save current position for backtracking */
|
|
252
37
|
mark(): StreamMark;
|
|
253
|
-
/** Restore to a saved position */
|
|
254
38
|
reset(mark: StreamMark): void;
|
|
255
|
-
/** Get current position */
|
|
256
39
|
position(): number;
|
|
257
40
|
}
|
|
258
|
-
/**
|
|
259
|
-
* Stream mark for backtracking during parsing.
|
|
260
|
-
*/
|
|
261
41
|
export interface StreamMark {
|
|
262
42
|
readonly position: number;
|
|
263
43
|
}
|
|
@@ -267,56 +47,33 @@ export interface StreamMark {
|
|
|
267
47
|
export interface LanguageTokenizer {
|
|
268
48
|
readonly language: string;
|
|
269
49
|
readonly direction: 'ltr' | 'rtl';
|
|
270
|
-
/** Convert input string to token stream */
|
|
271
50
|
tokenize(input: string): TokenStream;
|
|
272
|
-
/** Classify a single token */
|
|
273
51
|
classifyToken(token: string): TokenKind;
|
|
274
52
|
}
|
|
275
|
-
/**
|
|
276
|
-
* A language pattern defines how a semantic structure appears in a specific language.
|
|
277
|
-
*/
|
|
278
53
|
export interface LanguagePattern {
|
|
279
|
-
/** Unique identifier for this pattern */
|
|
280
54
|
readonly id: string;
|
|
281
|
-
/** ISO 639-1 language code */
|
|
282
55
|
readonly language: string;
|
|
283
|
-
/** Which command this pattern matches */
|
|
284
56
|
readonly command: ActionType;
|
|
285
|
-
/** Priority for disambiguation (higher = checked first) */
|
|
286
57
|
readonly priority: number;
|
|
287
|
-
/** The pattern template with role placeholders */
|
|
288
58
|
readonly template: PatternTemplate;
|
|
289
|
-
/** Rules for extracting semantic roles from matched tokens */
|
|
290
59
|
readonly extraction: ExtractionRules;
|
|
291
|
-
/** Optional constraints on when this pattern applies */
|
|
292
60
|
readonly constraints?: PatternConstraints;
|
|
293
61
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Pattern template - defines expected token sequence.
|
|
296
|
-
*/
|
|
297
62
|
export interface PatternTemplate {
|
|
298
|
-
/** Human-readable template string */
|
|
299
63
|
readonly format: string;
|
|
300
|
-
/** Parsed token sequence for matching */
|
|
301
64
|
readonly tokens: PatternToken[];
|
|
302
65
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Pattern token - literal, role placeholder, or group.
|
|
305
|
-
*/
|
|
306
66
|
export type PatternToken = LiteralPatternToken | RolePatternToken | GroupPatternToken;
|
|
307
67
|
export interface LiteralPatternToken {
|
|
308
68
|
readonly type: 'literal';
|
|
309
69
|
readonly value: string;
|
|
310
|
-
/** Alternative spellings/forms that also match */
|
|
311
70
|
readonly alternatives?: string[];
|
|
312
71
|
}
|
|
313
72
|
export interface RolePatternToken {
|
|
314
73
|
readonly type: 'role';
|
|
315
74
|
readonly role: SemanticRole;
|
|
316
75
|
readonly optional?: boolean;
|
|
317
|
-
/** Expected value types (for validation) */
|
|
318
76
|
readonly expectedTypes?: Array<ExpectedType>;
|
|
319
|
-
/** When true, captures all remaining tokens until next marker or end */
|
|
320
77
|
readonly greedy?: boolean;
|
|
321
78
|
}
|
|
322
79
|
export interface GroupPatternToken {
|
|
@@ -324,138 +81,34 @@ export interface GroupPatternToken {
|
|
|
324
81
|
readonly tokens: PatternToken[];
|
|
325
82
|
readonly optional?: boolean;
|
|
326
83
|
}
|
|
327
|
-
/**
|
|
328
|
-
* Rules for extracting semantic values from matched tokens.
|
|
329
|
-
*/
|
|
330
84
|
export interface ExtractionRules {
|
|
331
85
|
readonly [role: string]: ExtractionRule;
|
|
332
86
|
}
|
|
333
87
|
export interface ExtractionRule {
|
|
334
|
-
/** Position-based extraction (0-indexed from pattern start) */
|
|
335
88
|
readonly position?: number;
|
|
336
|
-
/** Marker-based extraction (find value after this marker) */
|
|
337
89
|
readonly marker?: string;
|
|
338
|
-
/** Alternative markers that also work */
|
|
339
90
|
readonly markerAlternatives?: string[];
|
|
340
|
-
/** Transform the extracted value */
|
|
341
91
|
readonly transform?: (raw: string) => SemanticValue;
|
|
342
|
-
/** Default value if not found (for optional roles) */
|
|
343
92
|
readonly default?: SemanticValue;
|
|
344
|
-
/** Static value extraction */
|
|
345
93
|
readonly value?: string;
|
|
346
|
-
/** Extract value from a pattern role by name */
|
|
347
94
|
readonly fromRole?: string;
|
|
348
95
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Additional constraints on pattern applicability.
|
|
351
|
-
*/
|
|
352
96
|
export interface PatternConstraints {
|
|
353
|
-
/** Required roles that must be present */
|
|
354
97
|
readonly requiredRoles?: SemanticRole[];
|
|
355
|
-
/** Roles that must NOT be present */
|
|
356
98
|
readonly forbiddenRoles?: SemanticRole[];
|
|
357
|
-
/** Valid selector types for the patient role */
|
|
358
99
|
readonly validPatientTypes?: Array<SelectorValue['selectorKind']>;
|
|
359
|
-
/** Pattern IDs this conflicts with */
|
|
360
100
|
readonly conflictsWith?: string[];
|
|
361
101
|
}
|
|
362
|
-
/**
|
|
363
|
-
* Result of matching a pattern against tokens.
|
|
364
|
-
*/
|
|
365
102
|
export interface PatternMatchResult {
|
|
366
103
|
readonly pattern: LanguagePattern;
|
|
367
104
|
readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;
|
|
368
105
|
readonly consumedTokens: number;
|
|
369
106
|
readonly confidence: number;
|
|
370
107
|
}
|
|
371
|
-
/**
|
|
372
|
-
* Error when pattern matching fails.
|
|
373
|
-
*/
|
|
374
108
|
export interface PatternMatchError {
|
|
375
109
|
readonly message: string;
|
|
376
110
|
readonly position: SourcePosition;
|
|
377
111
|
readonly expectedPatterns?: string[];
|
|
378
112
|
readonly partialMatch?: Partial<PatternMatchResult>;
|
|
379
113
|
}
|
|
380
|
-
/**
|
|
381
|
-
* Create a literal value
|
|
382
|
-
*/
|
|
383
|
-
export declare function createLiteral(value: string | number | boolean, dataType?: 'string' | 'number' | 'boolean' | 'duration'): LiteralValue;
|
|
384
|
-
/**
|
|
385
|
-
* Create a selector value
|
|
386
|
-
*/
|
|
387
|
-
export declare function createSelector(value: string, selectorKind?: SelectorValue['selectorKind']): SelectorValue;
|
|
388
|
-
/**
|
|
389
|
-
* Create a reference value
|
|
390
|
-
*/
|
|
391
|
-
export declare function createReference(value: string): ReferenceValue;
|
|
392
|
-
/**
|
|
393
|
-
* Create a property path value
|
|
394
|
-
*/
|
|
395
|
-
export declare function createPropertyPath(object: SemanticValue, property: string): PropertyPathValue;
|
|
396
|
-
/**
|
|
397
|
-
* Create an expression value
|
|
398
|
-
*/
|
|
399
|
-
export declare function createExpression(raw: string): ExpressionValue;
|
|
400
|
-
/**
|
|
401
|
-
* Create a boolean flag value (+flag or ~flag)
|
|
402
|
-
*/
|
|
403
|
-
export declare function createFlag(name: string, enabled?: boolean): FlagValue;
|
|
404
|
-
/**
|
|
405
|
-
* Create a command semantic node
|
|
406
|
-
*/
|
|
407
|
-
export declare function createCommandNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, metadata?: SemanticMetadata): CommandSemanticNode;
|
|
408
|
-
/**
|
|
409
|
-
* Create an event handler semantic node
|
|
410
|
-
*/
|
|
411
|
-
export declare function createEventHandlerNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, body: SemanticNode[], metadata?: SemanticMetadata, eventModifiers?: EventModifiers): EventHandlerSemanticNode;
|
|
412
|
-
/**
|
|
413
|
-
* Create a conditional semantic node
|
|
414
|
-
*/
|
|
415
|
-
export declare function createConditionalNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, thenBranch: SemanticNode[], elseBranch?: SemanticNode[], metadata?: SemanticMetadata): ConditionalSemanticNode;
|
|
416
|
-
/**
|
|
417
|
-
* Create a compound semantic node
|
|
418
|
-
*/
|
|
419
|
-
export declare function createCompoundNode(statements: SemanticNode[], chainType?: CompoundSemanticNode['chainType'], metadata?: SemanticMetadata): CompoundSemanticNode;
|
|
420
|
-
/**
|
|
421
|
-
* Extract a string value from a SemanticValue.
|
|
422
|
-
*
|
|
423
|
-
* Handles all value types in the SemanticValue union:
|
|
424
|
-
* - ExpressionValue: returns `raw`
|
|
425
|
-
* - LiteralValue/SelectorValue/ReferenceValue: returns `value` as string
|
|
426
|
-
* - PropertyPathValue: returns `object.property` path
|
|
427
|
-
*
|
|
428
|
-
* This is the standard way to get a display string from any semantic value,
|
|
429
|
-
* eliminating the need for `as any` casts in domain code generators.
|
|
430
|
-
*/
|
|
431
|
-
export declare function extractValue(value: SemanticValue): string;
|
|
432
|
-
/**
|
|
433
|
-
* Extract a string value from a named role on a SemanticNode.
|
|
434
|
-
*
|
|
435
|
-
* Convenience wrapper: looks up the role, returns empty string if missing.
|
|
436
|
-
* Eliminates the common `const x = node.roles.get('role'); const val = x ? extractValue(x as any) : '';` pattern.
|
|
437
|
-
*/
|
|
438
|
-
export declare function extractRoleValue(node: SemanticNode, role: string): string;
|
|
439
|
-
/**
|
|
440
|
-
* Create a loop semantic node
|
|
441
|
-
*/
|
|
442
|
-
export declare function createLoopNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, loopVariant: LoopVariant, body: SemanticNode[], loopVariable?: string, indexVariable?: string, metadata?: SemanticMetadata): LoopSemanticNode;
|
|
443
|
-
/**
|
|
444
|
-
* Create a try/catch/finally command node (v1.2).
|
|
445
|
-
*/
|
|
446
|
-
export declare function createTryNode(body: SemanticNode[], catchBranch?: SemanticNode[], finallyBranch?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
447
|
-
/**
|
|
448
|
-
* Create an async coordination (all/race) command node (v1.2).
|
|
449
|
-
*/
|
|
450
|
-
export declare function createAsyncNode(variant: AsyncVariant, asyncBody: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
451
|
-
/**
|
|
452
|
-
* Create a match command node with pattern arms (v1.2).
|
|
453
|
-
*/
|
|
454
|
-
export declare function createMatchNode(roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, arms: MatchArm[], defaultArm?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
455
|
-
/** Wire format envelope with version metadata (v1.2). */
|
|
456
|
-
export interface LSEEnvelope {
|
|
457
|
-
readonly lseVersion: string;
|
|
458
|
-
readonly features?: readonly string[];
|
|
459
|
-
readonly nodes: readonly SemanticNode[];
|
|
460
|
-
}
|
|
461
114
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAM5D;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAMlC;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,SAAS,CAAC;AAEd;;;GAGG;AACH,MAA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AE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAC5D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACrD"}
|
package/dist/core/types.js
CHANGED
|
@@ -1,132 +1,23 @@
|
|
|
1
1
|
// src/core/types.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
|
|
22
|
-
const node = {
|
|
23
|
-
kind: "command",
|
|
24
|
-
action,
|
|
25
|
-
roles: rolesMap
|
|
26
|
-
};
|
|
27
|
-
if (metadata) {
|
|
28
|
-
return { ...node, metadata };
|
|
29
|
-
}
|
|
30
|
-
return node;
|
|
31
|
-
}
|
|
32
|
-
function createEventHandlerNode(action, roles, body, metadata, eventModifiers) {
|
|
33
|
-
const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
|
|
34
|
-
const base = {
|
|
35
|
-
kind: "event-handler",
|
|
36
|
-
action,
|
|
37
|
-
roles: rolesMap,
|
|
38
|
-
body
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
...base,
|
|
42
|
-
...eventModifiers && { eventModifiers },
|
|
43
|
-
...metadata && { metadata }
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function createConditionalNode(action, roles, thenBranch, elseBranch, metadata) {
|
|
47
|
-
const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
|
|
48
|
-
const base = {
|
|
49
|
-
kind: "conditional",
|
|
50
|
-
action,
|
|
51
|
-
roles: rolesMap,
|
|
52
|
-
thenBranch
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
...base,
|
|
56
|
-
...elseBranch && { elseBranch },
|
|
57
|
-
...metadata && { metadata }
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function createCompoundNode(statements, chainType = "sequential", metadata) {
|
|
61
|
-
const base = {
|
|
62
|
-
kind: "compound",
|
|
63
|
-
action: "compound",
|
|
64
|
-
roles: /* @__PURE__ */ new Map(),
|
|
65
|
-
statements,
|
|
66
|
-
chainType
|
|
67
|
-
};
|
|
68
|
-
return metadata ? { ...base, metadata } : base;
|
|
69
|
-
}
|
|
70
|
-
function extractValue(value) {
|
|
71
|
-
if (value.type === "flag") return value.name;
|
|
72
|
-
if ("raw" in value && value.raw !== void 0) return String(value.raw);
|
|
73
|
-
if ("value" in value && value.value !== void 0) return String(value.value);
|
|
74
|
-
if (value.type === "property-path") return `${extractValue(value.object)}.${value.property}`;
|
|
75
|
-
return "";
|
|
76
|
-
}
|
|
77
|
-
function extractRoleValue(node, role) {
|
|
78
|
-
const value = node.roles.get(role);
|
|
79
|
-
if (!value) return "";
|
|
80
|
-
return extractValue(value);
|
|
81
|
-
}
|
|
82
|
-
function createLoopNode(action, roles, loopVariant, body, loopVariable, indexVariable, metadata) {
|
|
83
|
-
const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
|
|
84
|
-
const base = {
|
|
85
|
-
kind: "loop",
|
|
86
|
-
action,
|
|
87
|
-
roles: rolesMap,
|
|
88
|
-
loopVariant,
|
|
89
|
-
body
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
...base,
|
|
93
|
-
...loopVariable && { loopVariable },
|
|
94
|
-
...indexVariable && { indexVariable },
|
|
95
|
-
...metadata && { metadata }
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function createTryNode(body, catchBranch, finallyBranch, metadata) {
|
|
99
|
-
return {
|
|
100
|
-
kind: "command",
|
|
101
|
-
action: "try",
|
|
102
|
-
roles: /* @__PURE__ */ new Map(),
|
|
103
|
-
body,
|
|
104
|
-
...catchBranch && catchBranch.length > 0 ? { catchBranch } : {},
|
|
105
|
-
...finallyBranch && finallyBranch.length > 0 ? { finallyBranch } : {},
|
|
106
|
-
...metadata ? { metadata } : {}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function createAsyncNode(variant, asyncBody, metadata) {
|
|
110
|
-
return {
|
|
111
|
-
kind: "command",
|
|
112
|
-
action: variant,
|
|
113
|
-
roles: /* @__PURE__ */ new Map(),
|
|
114
|
-
asyncVariant: variant,
|
|
115
|
-
asyncBody,
|
|
116
|
-
...metadata ? { metadata } : {}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function createMatchNode(roles, arms, defaultArm, metadata) {
|
|
120
|
-
const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
|
|
121
|
-
return {
|
|
122
|
-
kind: "command",
|
|
123
|
-
action: "match",
|
|
124
|
-
roles: rolesMap,
|
|
125
|
-
arms,
|
|
126
|
-
...defaultArm && defaultArm.length > 0 ? { defaultArm } : {},
|
|
127
|
-
...metadata ? { metadata } : {}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
createLiteral,
|
|
4
|
+
createSelector,
|
|
5
|
+
createReference,
|
|
6
|
+
createPropertyPath,
|
|
7
|
+
createExpression,
|
|
8
|
+
createFlag,
|
|
9
|
+
createCommandNode,
|
|
10
|
+
createEventHandlerNode,
|
|
11
|
+
createConditionalNode,
|
|
12
|
+
createCompoundNode,
|
|
13
|
+
createLoopNode,
|
|
14
|
+
createTryNode,
|
|
15
|
+
createAsyncNode,
|
|
16
|
+
createMatchNode,
|
|
17
|
+
extractValue,
|
|
18
|
+
extractRoleValue,
|
|
19
|
+
getRoleValue
|
|
20
|
+
} from "@lokascript/intent";
|
|
130
21
|
export {
|
|
131
22
|
createAsyncNode,
|
|
132
23
|
createCommandNode,
|
|
@@ -143,6 +34,7 @@ export {
|
|
|
143
34
|
createSelector,
|
|
144
35
|
createTryNode,
|
|
145
36
|
extractRoleValue,
|
|
146
|
-
extractValue
|
|
37
|
+
extractValue,
|
|
38
|
+
getRoleValue
|
|
147
39
|
};
|
|
148
40
|
//# sourceMappingURL=types.js.map
|