webpipe-js 2.0.31 → 2.0.33
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/index.cjs +208 -30
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.mjs +208 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -21,10 +21,14 @@ interface Config {
|
|
|
21
21
|
properties: ConfigProperty[];
|
|
22
22
|
lineNumber?: number;
|
|
23
23
|
inlineComment?: Comment;
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
24
26
|
}
|
|
25
27
|
interface ConfigProperty {
|
|
26
28
|
key: string;
|
|
27
29
|
value: ConfigValue;
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
28
32
|
}
|
|
29
33
|
type ConfigValue = {
|
|
30
34
|
kind: 'String';
|
|
@@ -45,6 +49,8 @@ interface NamedPipeline {
|
|
|
45
49
|
pipeline: Pipeline;
|
|
46
50
|
lineNumber?: number;
|
|
47
51
|
inlineComment?: Comment;
|
|
52
|
+
start: number;
|
|
53
|
+
end: number;
|
|
48
54
|
}
|
|
49
55
|
interface Variable {
|
|
50
56
|
varType: string;
|
|
@@ -52,23 +58,31 @@ interface Variable {
|
|
|
52
58
|
value: string;
|
|
53
59
|
lineNumber?: number;
|
|
54
60
|
inlineComment?: Comment;
|
|
61
|
+
start: number;
|
|
62
|
+
end: number;
|
|
55
63
|
}
|
|
56
64
|
interface GraphQLSchema {
|
|
57
65
|
sdl: string;
|
|
58
66
|
lineNumber?: number;
|
|
59
67
|
inlineComment?: Comment;
|
|
68
|
+
start: number;
|
|
69
|
+
end: number;
|
|
60
70
|
}
|
|
61
71
|
interface QueryResolver {
|
|
62
72
|
name: string;
|
|
63
73
|
pipeline: Pipeline;
|
|
64
74
|
lineNumber?: number;
|
|
65
75
|
inlineComment?: Comment;
|
|
76
|
+
start: number;
|
|
77
|
+
end: number;
|
|
66
78
|
}
|
|
67
79
|
interface MutationResolver {
|
|
68
80
|
name: string;
|
|
69
81
|
pipeline: Pipeline;
|
|
70
82
|
lineNumber?: number;
|
|
71
83
|
inlineComment?: Comment;
|
|
84
|
+
start: number;
|
|
85
|
+
end: number;
|
|
72
86
|
}
|
|
73
87
|
interface Route {
|
|
74
88
|
method: string;
|
|
@@ -76,16 +90,24 @@ interface Route {
|
|
|
76
90
|
pipeline: PipelineRef;
|
|
77
91
|
lineNumber?: number;
|
|
78
92
|
inlineComment?: Comment;
|
|
93
|
+
start: number;
|
|
94
|
+
end: number;
|
|
79
95
|
}
|
|
80
96
|
type PipelineRef = {
|
|
81
97
|
kind: 'Inline';
|
|
82
98
|
pipeline: Pipeline;
|
|
99
|
+
start: number;
|
|
100
|
+
end: number;
|
|
83
101
|
} | {
|
|
84
102
|
kind: 'Named';
|
|
85
103
|
name: string;
|
|
104
|
+
start: number;
|
|
105
|
+
end: number;
|
|
86
106
|
};
|
|
87
107
|
interface Pipeline {
|
|
88
108
|
steps: PipelineStep[];
|
|
109
|
+
start: number;
|
|
110
|
+
end: number;
|
|
89
111
|
}
|
|
90
112
|
type ConfigType = 'backtick' | 'quoted' | 'identifier';
|
|
91
113
|
type LetValueFormat = 'quoted' | 'backtick' | 'bare';
|
|
@@ -102,6 +124,8 @@ interface Tag {
|
|
|
102
124
|
name: string;
|
|
103
125
|
negated: boolean;
|
|
104
126
|
args: string[];
|
|
127
|
+
start: number;
|
|
128
|
+
end: number;
|
|
105
129
|
}
|
|
106
130
|
/** A boolean expression of tags for dispatch routing */
|
|
107
131
|
type TagExpr = {
|
|
@@ -119,35 +143,50 @@ type TagExpr = {
|
|
|
119
143
|
type PipelineStep = {
|
|
120
144
|
kind: 'Regular';
|
|
121
145
|
name: string;
|
|
146
|
+
args: string[];
|
|
122
147
|
config: string;
|
|
123
148
|
configType: ConfigType;
|
|
124
149
|
condition?: TagExpr;
|
|
125
150
|
parsedJoinTargets?: string[];
|
|
151
|
+
start: number;
|
|
152
|
+
end: number;
|
|
126
153
|
} | {
|
|
127
154
|
kind: 'Result';
|
|
128
155
|
branches: ResultBranch[];
|
|
156
|
+
start: number;
|
|
157
|
+
end: number;
|
|
129
158
|
} | {
|
|
130
159
|
kind: 'If';
|
|
131
160
|
condition: Pipeline;
|
|
132
161
|
thenBranch: Pipeline;
|
|
133
162
|
elseBranch?: Pipeline;
|
|
163
|
+
start: number;
|
|
164
|
+
end: number;
|
|
134
165
|
} | {
|
|
135
166
|
kind: 'Dispatch';
|
|
136
167
|
branches: DispatchBranch[];
|
|
137
168
|
default?: Pipeline;
|
|
169
|
+
start: number;
|
|
170
|
+
end: number;
|
|
138
171
|
} | {
|
|
139
172
|
kind: 'Foreach';
|
|
140
173
|
selector: string;
|
|
141
174
|
pipeline: Pipeline;
|
|
175
|
+
start: number;
|
|
176
|
+
end: number;
|
|
142
177
|
};
|
|
143
178
|
interface DispatchBranch {
|
|
144
179
|
condition: TagExpr;
|
|
145
180
|
pipeline: Pipeline;
|
|
181
|
+
start: number;
|
|
182
|
+
end: number;
|
|
146
183
|
}
|
|
147
184
|
interface ResultBranch {
|
|
148
185
|
branchType: ResultBranchType;
|
|
149
186
|
statusCode: number;
|
|
150
187
|
pipeline: Pipeline;
|
|
188
|
+
start: number;
|
|
189
|
+
end: number;
|
|
151
190
|
}
|
|
152
191
|
type ResultBranchType = {
|
|
153
192
|
kind: 'Ok';
|
|
@@ -170,6 +209,8 @@ interface Describe {
|
|
|
170
209
|
interface Mock {
|
|
171
210
|
target: string;
|
|
172
211
|
returnValue: string;
|
|
212
|
+
start: number;
|
|
213
|
+
end: number;
|
|
173
214
|
}
|
|
174
215
|
interface It {
|
|
175
216
|
name: string;
|
|
@@ -188,13 +229,19 @@ type When = {
|
|
|
188
229
|
kind: 'CallingRoute';
|
|
189
230
|
method: string;
|
|
190
231
|
path: string;
|
|
232
|
+
start: number;
|
|
233
|
+
end: number;
|
|
191
234
|
} | {
|
|
192
235
|
kind: 'ExecutingPipeline';
|
|
193
236
|
name: string;
|
|
237
|
+
start: number;
|
|
238
|
+
end: number;
|
|
194
239
|
} | {
|
|
195
240
|
kind: 'ExecutingVariable';
|
|
196
241
|
varType: string;
|
|
197
242
|
name: string;
|
|
243
|
+
start: number;
|
|
244
|
+
end: number;
|
|
198
245
|
};
|
|
199
246
|
type DomAssertType = {
|
|
200
247
|
kind: 'Exists';
|
|
@@ -217,6 +264,8 @@ interface Condition {
|
|
|
217
264
|
callTarget?: string;
|
|
218
265
|
selector?: string;
|
|
219
266
|
domAssert?: DomAssertType;
|
|
267
|
+
start: number;
|
|
268
|
+
end: number;
|
|
220
269
|
}
|
|
221
270
|
type DiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
222
271
|
interface ParseDiagnostic {
|
package/dist/index.mjs
CHANGED
|
@@ -306,6 +306,7 @@ var Parser = class {
|
|
|
306
306
|
throw new ParseFailure("step-config", this.pos);
|
|
307
307
|
}
|
|
308
308
|
parseTag() {
|
|
309
|
+
const start = this.pos;
|
|
309
310
|
this.expect("@");
|
|
310
311
|
const negated = this.cur() === "!";
|
|
311
312
|
if (negated) this.pos++;
|
|
@@ -314,7 +315,8 @@ var Parser = class {
|
|
|
314
315
|
if (this.cur() === "(") {
|
|
315
316
|
args = this.parseTagArgs();
|
|
316
317
|
}
|
|
317
|
-
|
|
318
|
+
const end = this.pos;
|
|
319
|
+
return { name, negated, args, start, end };
|
|
318
320
|
}
|
|
319
321
|
parseTagArgs() {
|
|
320
322
|
this.expect("(");
|
|
@@ -389,14 +391,17 @@ var Parser = class {
|
|
|
389
391
|
}
|
|
390
392
|
parseConfigProperty() {
|
|
391
393
|
this.skipSpaces();
|
|
394
|
+
const start = this.pos;
|
|
392
395
|
const key = this.parseIdentifier();
|
|
393
396
|
this.skipInlineSpaces();
|
|
394
397
|
this.expect(":");
|
|
395
398
|
this.skipInlineSpaces();
|
|
396
399
|
const value = this.parseConfigValue();
|
|
397
|
-
|
|
400
|
+
const end = this.pos;
|
|
401
|
+
return { key, value, start, end };
|
|
398
402
|
}
|
|
399
403
|
parseConfig() {
|
|
404
|
+
const start = this.pos;
|
|
400
405
|
this.expect("config");
|
|
401
406
|
this.skipInlineSpaces();
|
|
402
407
|
const name = this.parseIdentifier();
|
|
@@ -414,7 +419,8 @@ var Parser = class {
|
|
|
414
419
|
this.skipSpaces();
|
|
415
420
|
this.expect("}");
|
|
416
421
|
this.skipWhitespaceOnly();
|
|
417
|
-
|
|
422
|
+
const end = this.pos;
|
|
423
|
+
return { name, properties, inlineComment: inlineComment || void 0, start, end };
|
|
418
424
|
}
|
|
419
425
|
parsePipelineStep() {
|
|
420
426
|
const result = this.tryParse(() => this.parseResultStep());
|
|
@@ -429,6 +435,7 @@ var Parser = class {
|
|
|
429
435
|
}
|
|
430
436
|
parseForeachStep() {
|
|
431
437
|
this.skipWhitespaceOnly();
|
|
438
|
+
const start = this.pos;
|
|
432
439
|
this.expect("|>");
|
|
433
440
|
this.skipInlineSpaces();
|
|
434
441
|
this.expect("foreach");
|
|
@@ -444,20 +451,25 @@ var Parser = class {
|
|
|
444
451
|
const pipeline = this.parseIfPipeline("end");
|
|
445
452
|
this.skipSpaces();
|
|
446
453
|
this.expect("end");
|
|
447
|
-
|
|
454
|
+
const end = this.pos;
|
|
455
|
+
return { kind: "Foreach", selector, pipeline, start, end };
|
|
448
456
|
}
|
|
449
457
|
parseRegularStep() {
|
|
450
458
|
this.skipWhitespaceOnly();
|
|
459
|
+
const start = this.pos;
|
|
451
460
|
this.expect("|>");
|
|
452
461
|
this.skipInlineSpaces();
|
|
453
462
|
const name = this.parseIdentifier();
|
|
463
|
+
const args = this.parseInlineArgs();
|
|
464
|
+
this.skipInlineSpaces();
|
|
454
465
|
this.expect(":");
|
|
455
466
|
this.skipInlineSpaces();
|
|
456
467
|
const { config, configType } = this.parseStepConfig();
|
|
457
468
|
const condition = this.parseStepCondition();
|
|
458
469
|
const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
|
|
459
470
|
this.skipWhitespaceOnly();
|
|
460
|
-
|
|
471
|
+
const end = this.pos;
|
|
472
|
+
return { kind: "Regular", name, args, config, configType, condition, parsedJoinTargets, start, end };
|
|
461
473
|
}
|
|
462
474
|
/**
|
|
463
475
|
* Parse optional step condition (tag expression after the config)
|
|
@@ -511,8 +523,132 @@ var Parser = class {
|
|
|
511
523
|
}
|
|
512
524
|
return names;
|
|
513
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* Split argument content by commas while respecting nesting depth and strings
|
|
528
|
+
* Example: `"url", {a:1, b:2}` -> [`"url"`, `{a:1, b:2}`]
|
|
529
|
+
*/
|
|
530
|
+
splitBalancedArgs(content) {
|
|
531
|
+
const args = [];
|
|
532
|
+
let current = "";
|
|
533
|
+
let depth = 0;
|
|
534
|
+
let inString = false;
|
|
535
|
+
let stringChar = "";
|
|
536
|
+
let escapeNext = false;
|
|
537
|
+
for (let i = 0; i < content.length; i++) {
|
|
538
|
+
const ch = content[i];
|
|
539
|
+
if (escapeNext) {
|
|
540
|
+
current += ch;
|
|
541
|
+
escapeNext = false;
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (ch === "\\" && inString) {
|
|
545
|
+
current += ch;
|
|
546
|
+
escapeNext = true;
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if ((ch === '"' || ch === "`") && !inString) {
|
|
550
|
+
inString = true;
|
|
551
|
+
stringChar = ch;
|
|
552
|
+
current += ch;
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
if (ch === stringChar && inString) {
|
|
556
|
+
inString = false;
|
|
557
|
+
stringChar = "";
|
|
558
|
+
current += ch;
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (inString) {
|
|
562
|
+
current += ch;
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
if (ch === "(" || ch === "[" || ch === "{") {
|
|
566
|
+
depth++;
|
|
567
|
+
current += ch;
|
|
568
|
+
} else if (ch === ")" || ch === "]" || ch === "}") {
|
|
569
|
+
depth--;
|
|
570
|
+
current += ch;
|
|
571
|
+
} else if (ch === "," && depth === 0) {
|
|
572
|
+
args.push(current.trim());
|
|
573
|
+
current = "";
|
|
574
|
+
} else {
|
|
575
|
+
current += ch;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (current.trim().length > 0) {
|
|
579
|
+
args.push(current.trim());
|
|
580
|
+
}
|
|
581
|
+
return args;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Parse inline arguments: middleware(arg1, arg2) or middleware[arg1, arg2]
|
|
585
|
+
* Returns the array of argument strings and advances position past the closing bracket
|
|
586
|
+
*/
|
|
587
|
+
parseInlineArgs() {
|
|
588
|
+
const trimmedStart = this.pos;
|
|
589
|
+
this.skipInlineSpaces();
|
|
590
|
+
const ch = this.cur();
|
|
591
|
+
if (ch !== "(" && ch !== "[") {
|
|
592
|
+
this.pos = trimmedStart;
|
|
593
|
+
return [];
|
|
594
|
+
}
|
|
595
|
+
const openChar = ch;
|
|
596
|
+
const closeChar = openChar === "(" ? ")" : "]";
|
|
597
|
+
this.pos++;
|
|
598
|
+
let depth = 1;
|
|
599
|
+
let inString = false;
|
|
600
|
+
let stringChar = "";
|
|
601
|
+
let escapeNext = false;
|
|
602
|
+
const contentStart = this.pos;
|
|
603
|
+
while (!this.eof() && depth > 0) {
|
|
604
|
+
const c = this.cur();
|
|
605
|
+
if (escapeNext) {
|
|
606
|
+
this.pos++;
|
|
607
|
+
escapeNext = false;
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
if (c === "\\" && inString) {
|
|
611
|
+
this.pos++;
|
|
612
|
+
escapeNext = true;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
if ((c === '"' || c === "`") && !inString) {
|
|
616
|
+
inString = true;
|
|
617
|
+
stringChar = c;
|
|
618
|
+
this.pos++;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
if (c === stringChar && inString) {
|
|
622
|
+
inString = false;
|
|
623
|
+
stringChar = "";
|
|
624
|
+
this.pos++;
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
if (!inString) {
|
|
628
|
+
if (c === openChar) {
|
|
629
|
+
depth++;
|
|
630
|
+
} else if (c === closeChar) {
|
|
631
|
+
depth--;
|
|
632
|
+
if (depth === 0) {
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
this.pos++;
|
|
638
|
+
}
|
|
639
|
+
if (depth !== 0) {
|
|
640
|
+
throw new ParseFailure(`unclosed ${openChar}`, contentStart);
|
|
641
|
+
}
|
|
642
|
+
const argsContent = this.text.slice(contentStart, this.pos);
|
|
643
|
+
this.pos++;
|
|
644
|
+
if (argsContent.trim().length === 0) {
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
647
|
+
return this.splitBalancedArgs(argsContent);
|
|
648
|
+
}
|
|
514
649
|
parseResultStep() {
|
|
515
650
|
this.skipWhitespaceOnly();
|
|
651
|
+
const start = this.pos;
|
|
516
652
|
this.expect("|>");
|
|
517
653
|
this.skipInlineSpaces();
|
|
518
654
|
this.expect("result");
|
|
@@ -523,10 +659,12 @@ var Parser = class {
|
|
|
523
659
|
if (!br) break;
|
|
524
660
|
branches.push(br);
|
|
525
661
|
}
|
|
526
|
-
|
|
662
|
+
const end = this.pos;
|
|
663
|
+
return { kind: "Result", branches, start, end };
|
|
527
664
|
}
|
|
528
665
|
parseResultBranch() {
|
|
529
666
|
this.skipSpaces();
|
|
667
|
+
const start = this.pos;
|
|
530
668
|
const branchIdent = this.parseIdentifier();
|
|
531
669
|
let branchType;
|
|
532
670
|
if (branchIdent === "ok") branchType = { kind: "Ok" };
|
|
@@ -546,10 +684,12 @@ var Parser = class {
|
|
|
546
684
|
this.expect(":");
|
|
547
685
|
this.skipSpaces();
|
|
548
686
|
const pipeline = this.parsePipeline();
|
|
549
|
-
|
|
687
|
+
const end = this.pos;
|
|
688
|
+
return { branchType, statusCode, pipeline, start, end };
|
|
550
689
|
}
|
|
551
690
|
parseIfStep() {
|
|
552
691
|
this.skipWhitespaceOnly();
|
|
692
|
+
const start = this.pos;
|
|
553
693
|
this.expect("|>");
|
|
554
694
|
this.skipInlineSpaces();
|
|
555
695
|
this.expect("if");
|
|
@@ -570,10 +710,12 @@ var Parser = class {
|
|
|
570
710
|
this.expect("end");
|
|
571
711
|
return true;
|
|
572
712
|
});
|
|
573
|
-
|
|
713
|
+
const end = this.pos;
|
|
714
|
+
return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0, start, end };
|
|
574
715
|
}
|
|
575
716
|
parseDispatchStep() {
|
|
576
717
|
this.skipWhitespaceOnly();
|
|
718
|
+
const start = this.pos;
|
|
577
719
|
this.expect("|>");
|
|
578
720
|
this.skipInlineSpaces();
|
|
579
721
|
this.expect("dispatch");
|
|
@@ -595,10 +737,12 @@ var Parser = class {
|
|
|
595
737
|
this.expect("end");
|
|
596
738
|
return true;
|
|
597
739
|
});
|
|
598
|
-
|
|
740
|
+
const end = this.pos;
|
|
741
|
+
return { kind: "Dispatch", branches, default: defaultBranch || void 0, start, end };
|
|
599
742
|
}
|
|
600
743
|
parseDispatchBranch() {
|
|
601
744
|
this.skipSpaces();
|
|
745
|
+
const start = this.pos;
|
|
602
746
|
this.expect("case");
|
|
603
747
|
this.skipInlineSpaces();
|
|
604
748
|
const condition = this.parseTagExpr();
|
|
@@ -606,7 +750,8 @@ var Parser = class {
|
|
|
606
750
|
this.expect(":");
|
|
607
751
|
this.skipSpaces();
|
|
608
752
|
const pipeline = this.parseIfPipeline("case", "default:", "end");
|
|
609
|
-
|
|
753
|
+
const end = this.pos;
|
|
754
|
+
return { condition, pipeline, start, end };
|
|
610
755
|
}
|
|
611
756
|
/**
|
|
612
757
|
* Parse a tag expression with boolean operators (and, or) and grouping
|
|
@@ -666,6 +811,7 @@ var Parser = class {
|
|
|
666
811
|
return { kind: "Tag", tag };
|
|
667
812
|
}
|
|
668
813
|
parseIfPipeline(...stopKeywords) {
|
|
814
|
+
const start = this.pos;
|
|
669
815
|
const steps = [];
|
|
670
816
|
while (true) {
|
|
671
817
|
const save = this.pos;
|
|
@@ -673,7 +819,8 @@ var Parser = class {
|
|
|
673
819
|
for (const keyword of stopKeywords) {
|
|
674
820
|
if (this.text.startsWith(keyword, this.pos)) {
|
|
675
821
|
this.pos = save;
|
|
676
|
-
|
|
822
|
+
const end2 = this.pos;
|
|
823
|
+
return { steps, start, end: end2 };
|
|
677
824
|
}
|
|
678
825
|
}
|
|
679
826
|
if (!this.text.startsWith("|>", this.pos)) {
|
|
@@ -683,9 +830,11 @@ var Parser = class {
|
|
|
683
830
|
const step = this.parsePipelineStep();
|
|
684
831
|
steps.push(step);
|
|
685
832
|
}
|
|
686
|
-
|
|
833
|
+
const end = this.pos;
|
|
834
|
+
return { steps, start, end };
|
|
687
835
|
}
|
|
688
836
|
parsePipeline() {
|
|
837
|
+
const start = this.pos;
|
|
689
838
|
const steps = [];
|
|
690
839
|
while (true) {
|
|
691
840
|
const save = this.pos;
|
|
@@ -697,7 +846,8 @@ var Parser = class {
|
|
|
697
846
|
const step = this.parsePipelineStep();
|
|
698
847
|
steps.push(step);
|
|
699
848
|
}
|
|
700
|
-
|
|
849
|
+
const end = this.pos;
|
|
850
|
+
return { steps, start, end };
|
|
701
851
|
}
|
|
702
852
|
parseNamedPipeline() {
|
|
703
853
|
const start = this.pos;
|
|
@@ -708,24 +858,27 @@ var Parser = class {
|
|
|
708
858
|
this.expect("=");
|
|
709
859
|
const inlineComment = this.parseInlineComment();
|
|
710
860
|
this.skipInlineSpaces();
|
|
711
|
-
const beforePipeline = this.pos;
|
|
712
861
|
const pipeline = this.parsePipeline();
|
|
713
862
|
const end = this.pos;
|
|
714
863
|
this.pipelineRanges.set(name, { start, end });
|
|
715
864
|
this.skipWhitespaceOnly();
|
|
716
|
-
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
865
|
+
return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
717
866
|
}
|
|
718
867
|
parsePipelineRef() {
|
|
719
868
|
const inline = this.tryParse(() => this.parsePipeline());
|
|
720
|
-
if (inline && inline.steps.length > 0)
|
|
869
|
+
if (inline && inline.steps.length > 0) {
|
|
870
|
+
return { kind: "Inline", pipeline: inline, start: inline.start, end: inline.end };
|
|
871
|
+
}
|
|
721
872
|
const named = this.tryParse(() => {
|
|
722
873
|
this.skipWhitespaceOnly();
|
|
874
|
+
const start = this.pos;
|
|
723
875
|
this.expect("|>");
|
|
724
876
|
this.skipInlineSpaces();
|
|
725
877
|
this.expect("pipeline:");
|
|
726
878
|
this.skipInlineSpaces();
|
|
727
879
|
const name = this.parseIdentifier();
|
|
728
|
-
|
|
880
|
+
const end = this.pos;
|
|
881
|
+
return { kind: "Named", name, start, end };
|
|
729
882
|
});
|
|
730
883
|
if (named) return named;
|
|
731
884
|
throw new Error("pipeline-ref");
|
|
@@ -743,19 +896,22 @@ var Parser = class {
|
|
|
743
896
|
const end = this.pos;
|
|
744
897
|
this.variableRanges.set(`${varType}::${name}`, { start, end });
|
|
745
898
|
this.skipWhitespaceOnly();
|
|
746
|
-
return { varType, name, value, inlineComment: inlineComment || void 0 };
|
|
899
|
+
return { varType, name, value, inlineComment: inlineComment || void 0, start, end };
|
|
747
900
|
}
|
|
748
901
|
parseGraphQLSchema() {
|
|
902
|
+
const start = this.pos;
|
|
749
903
|
this.expect("graphqlSchema");
|
|
750
904
|
this.skipInlineSpaces();
|
|
751
905
|
this.expect("=");
|
|
752
906
|
const inlineComment = this.parseInlineComment();
|
|
753
907
|
this.skipInlineSpaces();
|
|
754
908
|
const sdl = this.parseBacktickString();
|
|
909
|
+
const end = this.pos;
|
|
755
910
|
this.skipWhitespaceOnly();
|
|
756
|
-
return { sdl, inlineComment: inlineComment || void 0 };
|
|
911
|
+
return { sdl, inlineComment: inlineComment || void 0, start, end };
|
|
757
912
|
}
|
|
758
913
|
parseQueryResolver() {
|
|
914
|
+
const start = this.pos;
|
|
759
915
|
this.expect("query");
|
|
760
916
|
this.skipInlineSpaces();
|
|
761
917
|
const name = this.parseIdentifier();
|
|
@@ -764,10 +920,12 @@ var Parser = class {
|
|
|
764
920
|
const inlineComment = this.parseInlineComment();
|
|
765
921
|
this.skipWhitespaceOnly();
|
|
766
922
|
const pipeline = this.parsePipeline();
|
|
923
|
+
const end = this.pos;
|
|
767
924
|
this.skipWhitespaceOnly();
|
|
768
|
-
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
925
|
+
return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
769
926
|
}
|
|
770
927
|
parseMutationResolver() {
|
|
928
|
+
const start = this.pos;
|
|
771
929
|
this.expect("mutation");
|
|
772
930
|
this.skipInlineSpaces();
|
|
773
931
|
const name = this.parseIdentifier();
|
|
@@ -776,8 +934,9 @@ var Parser = class {
|
|
|
776
934
|
const inlineComment = this.parseInlineComment();
|
|
777
935
|
this.skipWhitespaceOnly();
|
|
778
936
|
const pipeline = this.parsePipeline();
|
|
937
|
+
const end = this.pos;
|
|
779
938
|
this.skipWhitespaceOnly();
|
|
780
|
-
return { name, pipeline, inlineComment: inlineComment || void 0 };
|
|
939
|
+
return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
781
940
|
}
|
|
782
941
|
parseFeatureFlags() {
|
|
783
942
|
this.expect("featureFlags");
|
|
@@ -789,35 +948,42 @@ var Parser = class {
|
|
|
789
948
|
return pipeline;
|
|
790
949
|
}
|
|
791
950
|
parseRoute() {
|
|
951
|
+
const start = this.pos;
|
|
792
952
|
const method = this.parseMethod();
|
|
793
953
|
this.skipInlineSpaces();
|
|
794
954
|
const path = this.consumeWhile((c) => c !== " " && c !== "\n" && c !== "#");
|
|
795
955
|
const inlineComment = this.parseInlineComment();
|
|
796
956
|
this.skipSpaces();
|
|
797
957
|
const pipeline = this.parsePipelineRef();
|
|
958
|
+
const end = this.pos;
|
|
798
959
|
this.skipWhitespaceOnly();
|
|
799
|
-
return { method, path, pipeline, inlineComment: inlineComment || void 0 };
|
|
960
|
+
return { method, path, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
800
961
|
}
|
|
801
962
|
parseWhen() {
|
|
802
963
|
const calling = this.tryParse(() => {
|
|
964
|
+
const start = this.pos;
|
|
803
965
|
this.expect("calling");
|
|
804
966
|
this.skipInlineSpaces();
|
|
805
967
|
const method = this.parseMethod();
|
|
806
968
|
this.skipInlineSpaces();
|
|
807
969
|
const path = this.consumeWhile((c) => c !== "\n");
|
|
808
|
-
|
|
970
|
+
const end = this.pos;
|
|
971
|
+
return { kind: "CallingRoute", method, path, start, end };
|
|
809
972
|
});
|
|
810
973
|
if (calling) return calling;
|
|
811
974
|
const executingPipeline = this.tryParse(() => {
|
|
975
|
+
const start = this.pos;
|
|
812
976
|
this.expect("executing");
|
|
813
977
|
this.skipInlineSpaces();
|
|
814
978
|
this.expect("pipeline");
|
|
815
979
|
this.skipInlineSpaces();
|
|
816
980
|
const name = this.parseIdentifier();
|
|
817
|
-
|
|
981
|
+
const end = this.pos;
|
|
982
|
+
return { kind: "ExecutingPipeline", name, start, end };
|
|
818
983
|
});
|
|
819
984
|
if (executingPipeline) return executingPipeline;
|
|
820
985
|
const executingVariable = this.tryParse(() => {
|
|
986
|
+
const start = this.pos;
|
|
821
987
|
this.expect("executing");
|
|
822
988
|
this.skipInlineSpaces();
|
|
823
989
|
this.expect("variable");
|
|
@@ -825,13 +991,15 @@ var Parser = class {
|
|
|
825
991
|
const varType = this.parseIdentifier();
|
|
826
992
|
this.skipInlineSpaces();
|
|
827
993
|
const name = this.parseIdentifier();
|
|
828
|
-
|
|
994
|
+
const end = this.pos;
|
|
995
|
+
return { kind: "ExecutingVariable", varType, name, start, end };
|
|
829
996
|
});
|
|
830
997
|
if (executingVariable) return executingVariable;
|
|
831
998
|
throw new ParseFailure("when", this.pos);
|
|
832
999
|
}
|
|
833
1000
|
parseCondition() {
|
|
834
1001
|
this.skipSpaces();
|
|
1002
|
+
const start = this.pos;
|
|
835
1003
|
const ct = (() => {
|
|
836
1004
|
if (this.match("then")) return "Then";
|
|
837
1005
|
if (this.match("and")) return "And";
|
|
@@ -864,13 +1032,16 @@ var Parser = class {
|
|
|
864
1032
|
if (v2 !== null) return v2;
|
|
865
1033
|
return this.consumeWhile((c) => c !== "\n");
|
|
866
1034
|
})();
|
|
1035
|
+
const end2 = this.pos;
|
|
867
1036
|
return {
|
|
868
1037
|
conditionType: ct,
|
|
869
1038
|
field: "call",
|
|
870
1039
|
comparison: comparison2,
|
|
871
1040
|
value: value2,
|
|
872
1041
|
isCallAssertion: true,
|
|
873
|
-
callTarget
|
|
1042
|
+
callTarget,
|
|
1043
|
+
start,
|
|
1044
|
+
end: end2
|
|
874
1045
|
};
|
|
875
1046
|
}
|
|
876
1047
|
if (field === "selector") {
|
|
@@ -943,13 +1114,16 @@ var Parser = class {
|
|
|
943
1114
|
} else {
|
|
944
1115
|
throw new Error(`Unknown selector operation: ${operation}`);
|
|
945
1116
|
}
|
|
1117
|
+
const end2 = this.pos;
|
|
946
1118
|
return {
|
|
947
1119
|
conditionType: ct,
|
|
948
1120
|
field: "selector",
|
|
949
1121
|
comparison: comparison2,
|
|
950
1122
|
value: value2,
|
|
951
1123
|
selector: selectorStr,
|
|
952
|
-
domAssert
|
|
1124
|
+
domAssert,
|
|
1125
|
+
start,
|
|
1126
|
+
end: end2
|
|
953
1127
|
};
|
|
954
1128
|
}
|
|
955
1129
|
let headerName;
|
|
@@ -976,10 +1150,12 @@ var Parser = class {
|
|
|
976
1150
|
if (v2 !== null) return v2;
|
|
977
1151
|
return this.consumeWhile((c) => c !== "\n");
|
|
978
1152
|
})();
|
|
979
|
-
|
|
1153
|
+
const end = this.pos;
|
|
1154
|
+
return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value, start, end };
|
|
980
1155
|
}
|
|
981
1156
|
parseMockHead(prefixWord) {
|
|
982
1157
|
this.skipSpaces();
|
|
1158
|
+
const start = this.pos;
|
|
983
1159
|
this.expect(prefixWord);
|
|
984
1160
|
this.skipInlineSpaces();
|
|
985
1161
|
this.expect("mock");
|
|
@@ -998,7 +1174,8 @@ var Parser = class {
|
|
|
998
1174
|
this.skipInlineSpaces();
|
|
999
1175
|
const returnValue = this.parseBacktickString();
|
|
1000
1176
|
this.skipSpaces();
|
|
1001
|
-
|
|
1177
|
+
const end = this.pos;
|
|
1178
|
+
return { target, returnValue, start, end };
|
|
1002
1179
|
}
|
|
1003
1180
|
parseMock() {
|
|
1004
1181
|
return this.parseMockHead("with");
|
|
@@ -1537,9 +1714,10 @@ function formatConfigValue(value) {
|
|
|
1537
1714
|
}
|
|
1538
1715
|
function formatPipelineStep(step, indent = " ") {
|
|
1539
1716
|
if (step.kind === "Regular") {
|
|
1717
|
+
const argsPart = step.args.length > 0 ? `(${step.args.join(", ")})` : "";
|
|
1540
1718
|
const configPart = formatStepConfig(step.config, step.configType);
|
|
1541
1719
|
const conditionPart = step.condition ? " " + formatTagExpr(step.condition) : "";
|
|
1542
|
-
return `${indent}|> ${step.name}: ${configPart}${conditionPart}`;
|
|
1720
|
+
return `${indent}|> ${step.name}${argsPart}: ${configPart}${conditionPart}`;
|
|
1543
1721
|
} else if (step.kind === "Result") {
|
|
1544
1722
|
const lines = [`${indent}|> result`];
|
|
1545
1723
|
step.branches.forEach((branch) => {
|