webpipe-js 2.0.31 → 2.0.32

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 CHANGED
@@ -358,6 +358,7 @@ var Parser = class {
358
358
  throw new ParseFailure("step-config", this.pos);
359
359
  }
360
360
  parseTag() {
361
+ const start = this.pos;
361
362
  this.expect("@");
362
363
  const negated = this.cur() === "!";
363
364
  if (negated) this.pos++;
@@ -366,7 +367,8 @@ var Parser = class {
366
367
  if (this.cur() === "(") {
367
368
  args = this.parseTagArgs();
368
369
  }
369
- return { name, negated, args };
370
+ const end = this.pos;
371
+ return { name, negated, args, start, end };
370
372
  }
371
373
  parseTagArgs() {
372
374
  this.expect("(");
@@ -441,14 +443,17 @@ var Parser = class {
441
443
  }
442
444
  parseConfigProperty() {
443
445
  this.skipSpaces();
446
+ const start = this.pos;
444
447
  const key = this.parseIdentifier();
445
448
  this.skipInlineSpaces();
446
449
  this.expect(":");
447
450
  this.skipInlineSpaces();
448
451
  const value = this.parseConfigValue();
449
- return { key, value };
452
+ const end = this.pos;
453
+ return { key, value, start, end };
450
454
  }
451
455
  parseConfig() {
456
+ const start = this.pos;
452
457
  this.expect("config");
453
458
  this.skipInlineSpaces();
454
459
  const name = this.parseIdentifier();
@@ -466,7 +471,8 @@ var Parser = class {
466
471
  this.skipSpaces();
467
472
  this.expect("}");
468
473
  this.skipWhitespaceOnly();
469
- return { name, properties, inlineComment: inlineComment || void 0 };
474
+ const end = this.pos;
475
+ return { name, properties, inlineComment: inlineComment || void 0, start, end };
470
476
  }
471
477
  parsePipelineStep() {
472
478
  const result = this.tryParse(() => this.parseResultStep());
@@ -481,6 +487,7 @@ var Parser = class {
481
487
  }
482
488
  parseForeachStep() {
483
489
  this.skipWhitespaceOnly();
490
+ const start = this.pos;
484
491
  this.expect("|>");
485
492
  this.skipInlineSpaces();
486
493
  this.expect("foreach");
@@ -496,10 +503,12 @@ var Parser = class {
496
503
  const pipeline = this.parseIfPipeline("end");
497
504
  this.skipSpaces();
498
505
  this.expect("end");
499
- return { kind: "Foreach", selector, pipeline };
506
+ const end = this.pos;
507
+ return { kind: "Foreach", selector, pipeline, start, end };
500
508
  }
501
509
  parseRegularStep() {
502
510
  this.skipWhitespaceOnly();
511
+ const start = this.pos;
503
512
  this.expect("|>");
504
513
  this.skipInlineSpaces();
505
514
  const name = this.parseIdentifier();
@@ -509,7 +518,8 @@ var Parser = class {
509
518
  const condition = this.parseStepCondition();
510
519
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
511
520
  this.skipWhitespaceOnly();
512
- return { kind: "Regular", name, config, configType, condition, parsedJoinTargets };
521
+ const end = this.pos;
522
+ return { kind: "Regular", name, config, configType, condition, parsedJoinTargets, start, end };
513
523
  }
514
524
  /**
515
525
  * Parse optional step condition (tag expression after the config)
@@ -565,6 +575,7 @@ var Parser = class {
565
575
  }
566
576
  parseResultStep() {
567
577
  this.skipWhitespaceOnly();
578
+ const start = this.pos;
568
579
  this.expect("|>");
569
580
  this.skipInlineSpaces();
570
581
  this.expect("result");
@@ -575,10 +586,12 @@ var Parser = class {
575
586
  if (!br) break;
576
587
  branches.push(br);
577
588
  }
578
- return { kind: "Result", branches };
589
+ const end = this.pos;
590
+ return { kind: "Result", branches, start, end };
579
591
  }
580
592
  parseResultBranch() {
581
593
  this.skipSpaces();
594
+ const start = this.pos;
582
595
  const branchIdent = this.parseIdentifier();
583
596
  let branchType;
584
597
  if (branchIdent === "ok") branchType = { kind: "Ok" };
@@ -598,10 +611,12 @@ var Parser = class {
598
611
  this.expect(":");
599
612
  this.skipSpaces();
600
613
  const pipeline = this.parsePipeline();
601
- return { branchType, statusCode, pipeline };
614
+ const end = this.pos;
615
+ return { branchType, statusCode, pipeline, start, end };
602
616
  }
603
617
  parseIfStep() {
604
618
  this.skipWhitespaceOnly();
619
+ const start = this.pos;
605
620
  this.expect("|>");
606
621
  this.skipInlineSpaces();
607
622
  this.expect("if");
@@ -622,10 +637,12 @@ var Parser = class {
622
637
  this.expect("end");
623
638
  return true;
624
639
  });
625
- return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
640
+ const end = this.pos;
641
+ return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0, start, end };
626
642
  }
627
643
  parseDispatchStep() {
628
644
  this.skipWhitespaceOnly();
645
+ const start = this.pos;
629
646
  this.expect("|>");
630
647
  this.skipInlineSpaces();
631
648
  this.expect("dispatch");
@@ -647,10 +664,12 @@ var Parser = class {
647
664
  this.expect("end");
648
665
  return true;
649
666
  });
650
- return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
667
+ const end = this.pos;
668
+ return { kind: "Dispatch", branches, default: defaultBranch || void 0, start, end };
651
669
  }
652
670
  parseDispatchBranch() {
653
671
  this.skipSpaces();
672
+ const start = this.pos;
654
673
  this.expect("case");
655
674
  this.skipInlineSpaces();
656
675
  const condition = this.parseTagExpr();
@@ -658,7 +677,8 @@ var Parser = class {
658
677
  this.expect(":");
659
678
  this.skipSpaces();
660
679
  const pipeline = this.parseIfPipeline("case", "default:", "end");
661
- return { condition, pipeline };
680
+ const end = this.pos;
681
+ return { condition, pipeline, start, end };
662
682
  }
663
683
  /**
664
684
  * Parse a tag expression with boolean operators (and, or) and grouping
@@ -718,6 +738,7 @@ var Parser = class {
718
738
  return { kind: "Tag", tag };
719
739
  }
720
740
  parseIfPipeline(...stopKeywords) {
741
+ const start = this.pos;
721
742
  const steps = [];
722
743
  while (true) {
723
744
  const save = this.pos;
@@ -725,7 +746,8 @@ var Parser = class {
725
746
  for (const keyword of stopKeywords) {
726
747
  if (this.text.startsWith(keyword, this.pos)) {
727
748
  this.pos = save;
728
- return { steps };
749
+ const end2 = this.pos;
750
+ return { steps, start, end: end2 };
729
751
  }
730
752
  }
731
753
  if (!this.text.startsWith("|>", this.pos)) {
@@ -735,9 +757,11 @@ var Parser = class {
735
757
  const step = this.parsePipelineStep();
736
758
  steps.push(step);
737
759
  }
738
- return { steps };
760
+ const end = this.pos;
761
+ return { steps, start, end };
739
762
  }
740
763
  parsePipeline() {
764
+ const start = this.pos;
741
765
  const steps = [];
742
766
  while (true) {
743
767
  const save = this.pos;
@@ -749,7 +773,8 @@ var Parser = class {
749
773
  const step = this.parsePipelineStep();
750
774
  steps.push(step);
751
775
  }
752
- return { steps };
776
+ const end = this.pos;
777
+ return { steps, start, end };
753
778
  }
754
779
  parseNamedPipeline() {
755
780
  const start = this.pos;
@@ -760,24 +785,27 @@ var Parser = class {
760
785
  this.expect("=");
761
786
  const inlineComment = this.parseInlineComment();
762
787
  this.skipInlineSpaces();
763
- const beforePipeline = this.pos;
764
788
  const pipeline = this.parsePipeline();
765
789
  const end = this.pos;
766
790
  this.pipelineRanges.set(name, { start, end });
767
791
  this.skipWhitespaceOnly();
768
- return { name, pipeline, inlineComment: inlineComment || void 0 };
792
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
769
793
  }
770
794
  parsePipelineRef() {
771
795
  const inline = this.tryParse(() => this.parsePipeline());
772
- if (inline && inline.steps.length > 0) return { kind: "Inline", pipeline: inline };
796
+ if (inline && inline.steps.length > 0) {
797
+ return { kind: "Inline", pipeline: inline, start: inline.start, end: inline.end };
798
+ }
773
799
  const named = this.tryParse(() => {
774
800
  this.skipWhitespaceOnly();
801
+ const start = this.pos;
775
802
  this.expect("|>");
776
803
  this.skipInlineSpaces();
777
804
  this.expect("pipeline:");
778
805
  this.skipInlineSpaces();
779
806
  const name = this.parseIdentifier();
780
- return { kind: "Named", name };
807
+ const end = this.pos;
808
+ return { kind: "Named", name, start, end };
781
809
  });
782
810
  if (named) return named;
783
811
  throw new Error("pipeline-ref");
@@ -795,19 +823,22 @@ var Parser = class {
795
823
  const end = this.pos;
796
824
  this.variableRanges.set(`${varType}::${name}`, { start, end });
797
825
  this.skipWhitespaceOnly();
798
- return { varType, name, value, inlineComment: inlineComment || void 0 };
826
+ return { varType, name, value, inlineComment: inlineComment || void 0, start, end };
799
827
  }
800
828
  parseGraphQLSchema() {
829
+ const start = this.pos;
801
830
  this.expect("graphqlSchema");
802
831
  this.skipInlineSpaces();
803
832
  this.expect("=");
804
833
  const inlineComment = this.parseInlineComment();
805
834
  this.skipInlineSpaces();
806
835
  const sdl = this.parseBacktickString();
836
+ const end = this.pos;
807
837
  this.skipWhitespaceOnly();
808
- return { sdl, inlineComment: inlineComment || void 0 };
838
+ return { sdl, inlineComment: inlineComment || void 0, start, end };
809
839
  }
810
840
  parseQueryResolver() {
841
+ const start = this.pos;
811
842
  this.expect("query");
812
843
  this.skipInlineSpaces();
813
844
  const name = this.parseIdentifier();
@@ -816,10 +847,12 @@ var Parser = class {
816
847
  const inlineComment = this.parseInlineComment();
817
848
  this.skipWhitespaceOnly();
818
849
  const pipeline = this.parsePipeline();
850
+ const end = this.pos;
819
851
  this.skipWhitespaceOnly();
820
- return { name, pipeline, inlineComment: inlineComment || void 0 };
852
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
821
853
  }
822
854
  parseMutationResolver() {
855
+ const start = this.pos;
823
856
  this.expect("mutation");
824
857
  this.skipInlineSpaces();
825
858
  const name = this.parseIdentifier();
@@ -828,8 +861,9 @@ var Parser = class {
828
861
  const inlineComment = this.parseInlineComment();
829
862
  this.skipWhitespaceOnly();
830
863
  const pipeline = this.parsePipeline();
864
+ const end = this.pos;
831
865
  this.skipWhitespaceOnly();
832
- return { name, pipeline, inlineComment: inlineComment || void 0 };
866
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
833
867
  }
834
868
  parseFeatureFlags() {
835
869
  this.expect("featureFlags");
@@ -841,35 +875,42 @@ var Parser = class {
841
875
  return pipeline;
842
876
  }
843
877
  parseRoute() {
878
+ const start = this.pos;
844
879
  const method = this.parseMethod();
845
880
  this.skipInlineSpaces();
846
881
  const path = this.consumeWhile((c) => c !== " " && c !== "\n" && c !== "#");
847
882
  const inlineComment = this.parseInlineComment();
848
883
  this.skipSpaces();
849
884
  const pipeline = this.parsePipelineRef();
885
+ const end = this.pos;
850
886
  this.skipWhitespaceOnly();
851
- return { method, path, pipeline, inlineComment: inlineComment || void 0 };
887
+ return { method, path, pipeline, inlineComment: inlineComment || void 0, start, end };
852
888
  }
853
889
  parseWhen() {
854
890
  const calling = this.tryParse(() => {
891
+ const start = this.pos;
855
892
  this.expect("calling");
856
893
  this.skipInlineSpaces();
857
894
  const method = this.parseMethod();
858
895
  this.skipInlineSpaces();
859
896
  const path = this.consumeWhile((c) => c !== "\n");
860
- return { kind: "CallingRoute", method, path };
897
+ const end = this.pos;
898
+ return { kind: "CallingRoute", method, path, start, end };
861
899
  });
862
900
  if (calling) return calling;
863
901
  const executingPipeline = this.tryParse(() => {
902
+ const start = this.pos;
864
903
  this.expect("executing");
865
904
  this.skipInlineSpaces();
866
905
  this.expect("pipeline");
867
906
  this.skipInlineSpaces();
868
907
  const name = this.parseIdentifier();
869
- return { kind: "ExecutingPipeline", name };
908
+ const end = this.pos;
909
+ return { kind: "ExecutingPipeline", name, start, end };
870
910
  });
871
911
  if (executingPipeline) return executingPipeline;
872
912
  const executingVariable = this.tryParse(() => {
913
+ const start = this.pos;
873
914
  this.expect("executing");
874
915
  this.skipInlineSpaces();
875
916
  this.expect("variable");
@@ -877,13 +918,15 @@ var Parser = class {
877
918
  const varType = this.parseIdentifier();
878
919
  this.skipInlineSpaces();
879
920
  const name = this.parseIdentifier();
880
- return { kind: "ExecutingVariable", varType, name };
921
+ const end = this.pos;
922
+ return { kind: "ExecutingVariable", varType, name, start, end };
881
923
  });
882
924
  if (executingVariable) return executingVariable;
883
925
  throw new ParseFailure("when", this.pos);
884
926
  }
885
927
  parseCondition() {
886
928
  this.skipSpaces();
929
+ const start = this.pos;
887
930
  const ct = (() => {
888
931
  if (this.match("then")) return "Then";
889
932
  if (this.match("and")) return "And";
@@ -916,13 +959,16 @@ var Parser = class {
916
959
  if (v2 !== null) return v2;
917
960
  return this.consumeWhile((c) => c !== "\n");
918
961
  })();
962
+ const end2 = this.pos;
919
963
  return {
920
964
  conditionType: ct,
921
965
  field: "call",
922
966
  comparison: comparison2,
923
967
  value: value2,
924
968
  isCallAssertion: true,
925
- callTarget
969
+ callTarget,
970
+ start,
971
+ end: end2
926
972
  };
927
973
  }
928
974
  if (field === "selector") {
@@ -995,13 +1041,16 @@ var Parser = class {
995
1041
  } else {
996
1042
  throw new Error(`Unknown selector operation: ${operation}`);
997
1043
  }
1044
+ const end2 = this.pos;
998
1045
  return {
999
1046
  conditionType: ct,
1000
1047
  field: "selector",
1001
1048
  comparison: comparison2,
1002
1049
  value: value2,
1003
1050
  selector: selectorStr,
1004
- domAssert
1051
+ domAssert,
1052
+ start,
1053
+ end: end2
1005
1054
  };
1006
1055
  }
1007
1056
  let headerName;
@@ -1028,10 +1077,12 @@ var Parser = class {
1028
1077
  if (v2 !== null) return v2;
1029
1078
  return this.consumeWhile((c) => c !== "\n");
1030
1079
  })();
1031
- return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value };
1080
+ const end = this.pos;
1081
+ return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value, start, end };
1032
1082
  }
1033
1083
  parseMockHead(prefixWord) {
1034
1084
  this.skipSpaces();
1085
+ const start = this.pos;
1035
1086
  this.expect(prefixWord);
1036
1087
  this.skipInlineSpaces();
1037
1088
  this.expect("mock");
@@ -1050,7 +1101,8 @@ var Parser = class {
1050
1101
  this.skipInlineSpaces();
1051
1102
  const returnValue = this.parseBacktickString();
1052
1103
  this.skipSpaces();
1053
- return { target, returnValue };
1104
+ const end = this.pos;
1105
+ return { target, returnValue, start, end };
1054
1106
  }
1055
1107
  parseMock() {
1056
1108
  return this.parseMockHead("with");
package/dist/index.d.cts 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 = {
@@ -123,31 +147,45 @@ type PipelineStep = {
123
147
  configType: ConfigType;
124
148
  condition?: TagExpr;
125
149
  parsedJoinTargets?: string[];
150
+ start: number;
151
+ end: number;
126
152
  } | {
127
153
  kind: 'Result';
128
154
  branches: ResultBranch[];
155
+ start: number;
156
+ end: number;
129
157
  } | {
130
158
  kind: 'If';
131
159
  condition: Pipeline;
132
160
  thenBranch: Pipeline;
133
161
  elseBranch?: Pipeline;
162
+ start: number;
163
+ end: number;
134
164
  } | {
135
165
  kind: 'Dispatch';
136
166
  branches: DispatchBranch[];
137
167
  default?: Pipeline;
168
+ start: number;
169
+ end: number;
138
170
  } | {
139
171
  kind: 'Foreach';
140
172
  selector: string;
141
173
  pipeline: Pipeline;
174
+ start: number;
175
+ end: number;
142
176
  };
143
177
  interface DispatchBranch {
144
178
  condition: TagExpr;
145
179
  pipeline: Pipeline;
180
+ start: number;
181
+ end: number;
146
182
  }
147
183
  interface ResultBranch {
148
184
  branchType: ResultBranchType;
149
185
  statusCode: number;
150
186
  pipeline: Pipeline;
187
+ start: number;
188
+ end: number;
151
189
  }
152
190
  type ResultBranchType = {
153
191
  kind: 'Ok';
@@ -170,6 +208,8 @@ interface Describe {
170
208
  interface Mock {
171
209
  target: string;
172
210
  returnValue: string;
211
+ start: number;
212
+ end: number;
173
213
  }
174
214
  interface It {
175
215
  name: string;
@@ -188,13 +228,19 @@ type When = {
188
228
  kind: 'CallingRoute';
189
229
  method: string;
190
230
  path: string;
231
+ start: number;
232
+ end: number;
191
233
  } | {
192
234
  kind: 'ExecutingPipeline';
193
235
  name: string;
236
+ start: number;
237
+ end: number;
194
238
  } | {
195
239
  kind: 'ExecutingVariable';
196
240
  varType: string;
197
241
  name: string;
242
+ start: number;
243
+ end: number;
198
244
  };
199
245
  type DomAssertType = {
200
246
  kind: 'Exists';
@@ -217,6 +263,8 @@ interface Condition {
217
263
  callTarget?: string;
218
264
  selector?: string;
219
265
  domAssert?: DomAssertType;
266
+ start: number;
267
+ end: number;
220
268
  }
221
269
  type DiagnosticSeverity = 'error' | 'warning' | 'info';
222
270
  interface ParseDiagnostic {
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 = {
@@ -123,31 +147,45 @@ type PipelineStep = {
123
147
  configType: ConfigType;
124
148
  condition?: TagExpr;
125
149
  parsedJoinTargets?: string[];
150
+ start: number;
151
+ end: number;
126
152
  } | {
127
153
  kind: 'Result';
128
154
  branches: ResultBranch[];
155
+ start: number;
156
+ end: number;
129
157
  } | {
130
158
  kind: 'If';
131
159
  condition: Pipeline;
132
160
  thenBranch: Pipeline;
133
161
  elseBranch?: Pipeline;
162
+ start: number;
163
+ end: number;
134
164
  } | {
135
165
  kind: 'Dispatch';
136
166
  branches: DispatchBranch[];
137
167
  default?: Pipeline;
168
+ start: number;
169
+ end: number;
138
170
  } | {
139
171
  kind: 'Foreach';
140
172
  selector: string;
141
173
  pipeline: Pipeline;
174
+ start: number;
175
+ end: number;
142
176
  };
143
177
  interface DispatchBranch {
144
178
  condition: TagExpr;
145
179
  pipeline: Pipeline;
180
+ start: number;
181
+ end: number;
146
182
  }
147
183
  interface ResultBranch {
148
184
  branchType: ResultBranchType;
149
185
  statusCode: number;
150
186
  pipeline: Pipeline;
187
+ start: number;
188
+ end: number;
151
189
  }
152
190
  type ResultBranchType = {
153
191
  kind: 'Ok';
@@ -170,6 +208,8 @@ interface Describe {
170
208
  interface Mock {
171
209
  target: string;
172
210
  returnValue: string;
211
+ start: number;
212
+ end: number;
173
213
  }
174
214
  interface It {
175
215
  name: string;
@@ -188,13 +228,19 @@ type When = {
188
228
  kind: 'CallingRoute';
189
229
  method: string;
190
230
  path: string;
231
+ start: number;
232
+ end: number;
191
233
  } | {
192
234
  kind: 'ExecutingPipeline';
193
235
  name: string;
236
+ start: number;
237
+ end: number;
194
238
  } | {
195
239
  kind: 'ExecutingVariable';
196
240
  varType: string;
197
241
  name: string;
242
+ start: number;
243
+ end: number;
198
244
  };
199
245
  type DomAssertType = {
200
246
  kind: 'Exists';
@@ -217,6 +263,8 @@ interface Condition {
217
263
  callTarget?: string;
218
264
  selector?: string;
219
265
  domAssert?: DomAssertType;
266
+ start: number;
267
+ end: number;
220
268
  }
221
269
  type DiagnosticSeverity = 'error' | 'warning' | 'info';
222
270
  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
- return { name, negated, args };
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
- return { key, value };
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
- return { name, properties, inlineComment: inlineComment || void 0 };
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,10 +451,12 @@ var Parser = class {
444
451
  const pipeline = this.parseIfPipeline("end");
445
452
  this.skipSpaces();
446
453
  this.expect("end");
447
- return { kind: "Foreach", selector, pipeline };
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();
@@ -457,7 +466,8 @@ var Parser = class {
457
466
  const condition = this.parseStepCondition();
458
467
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
459
468
  this.skipWhitespaceOnly();
460
- return { kind: "Regular", name, config, configType, condition, parsedJoinTargets };
469
+ const end = this.pos;
470
+ return { kind: "Regular", name, config, configType, condition, parsedJoinTargets, start, end };
461
471
  }
462
472
  /**
463
473
  * Parse optional step condition (tag expression after the config)
@@ -513,6 +523,7 @@ var Parser = class {
513
523
  }
514
524
  parseResultStep() {
515
525
  this.skipWhitespaceOnly();
526
+ const start = this.pos;
516
527
  this.expect("|>");
517
528
  this.skipInlineSpaces();
518
529
  this.expect("result");
@@ -523,10 +534,12 @@ var Parser = class {
523
534
  if (!br) break;
524
535
  branches.push(br);
525
536
  }
526
- return { kind: "Result", branches };
537
+ const end = this.pos;
538
+ return { kind: "Result", branches, start, end };
527
539
  }
528
540
  parseResultBranch() {
529
541
  this.skipSpaces();
542
+ const start = this.pos;
530
543
  const branchIdent = this.parseIdentifier();
531
544
  let branchType;
532
545
  if (branchIdent === "ok") branchType = { kind: "Ok" };
@@ -546,10 +559,12 @@ var Parser = class {
546
559
  this.expect(":");
547
560
  this.skipSpaces();
548
561
  const pipeline = this.parsePipeline();
549
- return { branchType, statusCode, pipeline };
562
+ const end = this.pos;
563
+ return { branchType, statusCode, pipeline, start, end };
550
564
  }
551
565
  parseIfStep() {
552
566
  this.skipWhitespaceOnly();
567
+ const start = this.pos;
553
568
  this.expect("|>");
554
569
  this.skipInlineSpaces();
555
570
  this.expect("if");
@@ -570,10 +585,12 @@ var Parser = class {
570
585
  this.expect("end");
571
586
  return true;
572
587
  });
573
- return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
588
+ const end = this.pos;
589
+ return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0, start, end };
574
590
  }
575
591
  parseDispatchStep() {
576
592
  this.skipWhitespaceOnly();
593
+ const start = this.pos;
577
594
  this.expect("|>");
578
595
  this.skipInlineSpaces();
579
596
  this.expect("dispatch");
@@ -595,10 +612,12 @@ var Parser = class {
595
612
  this.expect("end");
596
613
  return true;
597
614
  });
598
- return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
615
+ const end = this.pos;
616
+ return { kind: "Dispatch", branches, default: defaultBranch || void 0, start, end };
599
617
  }
600
618
  parseDispatchBranch() {
601
619
  this.skipSpaces();
620
+ const start = this.pos;
602
621
  this.expect("case");
603
622
  this.skipInlineSpaces();
604
623
  const condition = this.parseTagExpr();
@@ -606,7 +625,8 @@ var Parser = class {
606
625
  this.expect(":");
607
626
  this.skipSpaces();
608
627
  const pipeline = this.parseIfPipeline("case", "default:", "end");
609
- return { condition, pipeline };
628
+ const end = this.pos;
629
+ return { condition, pipeline, start, end };
610
630
  }
611
631
  /**
612
632
  * Parse a tag expression with boolean operators (and, or) and grouping
@@ -666,6 +686,7 @@ var Parser = class {
666
686
  return { kind: "Tag", tag };
667
687
  }
668
688
  parseIfPipeline(...stopKeywords) {
689
+ const start = this.pos;
669
690
  const steps = [];
670
691
  while (true) {
671
692
  const save = this.pos;
@@ -673,7 +694,8 @@ var Parser = class {
673
694
  for (const keyword of stopKeywords) {
674
695
  if (this.text.startsWith(keyword, this.pos)) {
675
696
  this.pos = save;
676
- return { steps };
697
+ const end2 = this.pos;
698
+ return { steps, start, end: end2 };
677
699
  }
678
700
  }
679
701
  if (!this.text.startsWith("|>", this.pos)) {
@@ -683,9 +705,11 @@ var Parser = class {
683
705
  const step = this.parsePipelineStep();
684
706
  steps.push(step);
685
707
  }
686
- return { steps };
708
+ const end = this.pos;
709
+ return { steps, start, end };
687
710
  }
688
711
  parsePipeline() {
712
+ const start = this.pos;
689
713
  const steps = [];
690
714
  while (true) {
691
715
  const save = this.pos;
@@ -697,7 +721,8 @@ var Parser = class {
697
721
  const step = this.parsePipelineStep();
698
722
  steps.push(step);
699
723
  }
700
- return { steps };
724
+ const end = this.pos;
725
+ return { steps, start, end };
701
726
  }
702
727
  parseNamedPipeline() {
703
728
  const start = this.pos;
@@ -708,24 +733,27 @@ var Parser = class {
708
733
  this.expect("=");
709
734
  const inlineComment = this.parseInlineComment();
710
735
  this.skipInlineSpaces();
711
- const beforePipeline = this.pos;
712
736
  const pipeline = this.parsePipeline();
713
737
  const end = this.pos;
714
738
  this.pipelineRanges.set(name, { start, end });
715
739
  this.skipWhitespaceOnly();
716
- return { name, pipeline, inlineComment: inlineComment || void 0 };
740
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
717
741
  }
718
742
  parsePipelineRef() {
719
743
  const inline = this.tryParse(() => this.parsePipeline());
720
- if (inline && inline.steps.length > 0) return { kind: "Inline", pipeline: inline };
744
+ if (inline && inline.steps.length > 0) {
745
+ return { kind: "Inline", pipeline: inline, start: inline.start, end: inline.end };
746
+ }
721
747
  const named = this.tryParse(() => {
722
748
  this.skipWhitespaceOnly();
749
+ const start = this.pos;
723
750
  this.expect("|>");
724
751
  this.skipInlineSpaces();
725
752
  this.expect("pipeline:");
726
753
  this.skipInlineSpaces();
727
754
  const name = this.parseIdentifier();
728
- return { kind: "Named", name };
755
+ const end = this.pos;
756
+ return { kind: "Named", name, start, end };
729
757
  });
730
758
  if (named) return named;
731
759
  throw new Error("pipeline-ref");
@@ -743,19 +771,22 @@ var Parser = class {
743
771
  const end = this.pos;
744
772
  this.variableRanges.set(`${varType}::${name}`, { start, end });
745
773
  this.skipWhitespaceOnly();
746
- return { varType, name, value, inlineComment: inlineComment || void 0 };
774
+ return { varType, name, value, inlineComment: inlineComment || void 0, start, end };
747
775
  }
748
776
  parseGraphQLSchema() {
777
+ const start = this.pos;
749
778
  this.expect("graphqlSchema");
750
779
  this.skipInlineSpaces();
751
780
  this.expect("=");
752
781
  const inlineComment = this.parseInlineComment();
753
782
  this.skipInlineSpaces();
754
783
  const sdl = this.parseBacktickString();
784
+ const end = this.pos;
755
785
  this.skipWhitespaceOnly();
756
- return { sdl, inlineComment: inlineComment || void 0 };
786
+ return { sdl, inlineComment: inlineComment || void 0, start, end };
757
787
  }
758
788
  parseQueryResolver() {
789
+ const start = this.pos;
759
790
  this.expect("query");
760
791
  this.skipInlineSpaces();
761
792
  const name = this.parseIdentifier();
@@ -764,10 +795,12 @@ var Parser = class {
764
795
  const inlineComment = this.parseInlineComment();
765
796
  this.skipWhitespaceOnly();
766
797
  const pipeline = this.parsePipeline();
798
+ const end = this.pos;
767
799
  this.skipWhitespaceOnly();
768
- return { name, pipeline, inlineComment: inlineComment || void 0 };
800
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
769
801
  }
770
802
  parseMutationResolver() {
803
+ const start = this.pos;
771
804
  this.expect("mutation");
772
805
  this.skipInlineSpaces();
773
806
  const name = this.parseIdentifier();
@@ -776,8 +809,9 @@ var Parser = class {
776
809
  const inlineComment = this.parseInlineComment();
777
810
  this.skipWhitespaceOnly();
778
811
  const pipeline = this.parsePipeline();
812
+ const end = this.pos;
779
813
  this.skipWhitespaceOnly();
780
- return { name, pipeline, inlineComment: inlineComment || void 0 };
814
+ return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
781
815
  }
782
816
  parseFeatureFlags() {
783
817
  this.expect("featureFlags");
@@ -789,35 +823,42 @@ var Parser = class {
789
823
  return pipeline;
790
824
  }
791
825
  parseRoute() {
826
+ const start = this.pos;
792
827
  const method = this.parseMethod();
793
828
  this.skipInlineSpaces();
794
829
  const path = this.consumeWhile((c) => c !== " " && c !== "\n" && c !== "#");
795
830
  const inlineComment = this.parseInlineComment();
796
831
  this.skipSpaces();
797
832
  const pipeline = this.parsePipelineRef();
833
+ const end = this.pos;
798
834
  this.skipWhitespaceOnly();
799
- return { method, path, pipeline, inlineComment: inlineComment || void 0 };
835
+ return { method, path, pipeline, inlineComment: inlineComment || void 0, start, end };
800
836
  }
801
837
  parseWhen() {
802
838
  const calling = this.tryParse(() => {
839
+ const start = this.pos;
803
840
  this.expect("calling");
804
841
  this.skipInlineSpaces();
805
842
  const method = this.parseMethod();
806
843
  this.skipInlineSpaces();
807
844
  const path = this.consumeWhile((c) => c !== "\n");
808
- return { kind: "CallingRoute", method, path };
845
+ const end = this.pos;
846
+ return { kind: "CallingRoute", method, path, start, end };
809
847
  });
810
848
  if (calling) return calling;
811
849
  const executingPipeline = this.tryParse(() => {
850
+ const start = this.pos;
812
851
  this.expect("executing");
813
852
  this.skipInlineSpaces();
814
853
  this.expect("pipeline");
815
854
  this.skipInlineSpaces();
816
855
  const name = this.parseIdentifier();
817
- return { kind: "ExecutingPipeline", name };
856
+ const end = this.pos;
857
+ return { kind: "ExecutingPipeline", name, start, end };
818
858
  });
819
859
  if (executingPipeline) return executingPipeline;
820
860
  const executingVariable = this.tryParse(() => {
861
+ const start = this.pos;
821
862
  this.expect("executing");
822
863
  this.skipInlineSpaces();
823
864
  this.expect("variable");
@@ -825,13 +866,15 @@ var Parser = class {
825
866
  const varType = this.parseIdentifier();
826
867
  this.skipInlineSpaces();
827
868
  const name = this.parseIdentifier();
828
- return { kind: "ExecutingVariable", varType, name };
869
+ const end = this.pos;
870
+ return { kind: "ExecutingVariable", varType, name, start, end };
829
871
  });
830
872
  if (executingVariable) return executingVariable;
831
873
  throw new ParseFailure("when", this.pos);
832
874
  }
833
875
  parseCondition() {
834
876
  this.skipSpaces();
877
+ const start = this.pos;
835
878
  const ct = (() => {
836
879
  if (this.match("then")) return "Then";
837
880
  if (this.match("and")) return "And";
@@ -864,13 +907,16 @@ var Parser = class {
864
907
  if (v2 !== null) return v2;
865
908
  return this.consumeWhile((c) => c !== "\n");
866
909
  })();
910
+ const end2 = this.pos;
867
911
  return {
868
912
  conditionType: ct,
869
913
  field: "call",
870
914
  comparison: comparison2,
871
915
  value: value2,
872
916
  isCallAssertion: true,
873
- callTarget
917
+ callTarget,
918
+ start,
919
+ end: end2
874
920
  };
875
921
  }
876
922
  if (field === "selector") {
@@ -943,13 +989,16 @@ var Parser = class {
943
989
  } else {
944
990
  throw new Error(`Unknown selector operation: ${operation}`);
945
991
  }
992
+ const end2 = this.pos;
946
993
  return {
947
994
  conditionType: ct,
948
995
  field: "selector",
949
996
  comparison: comparison2,
950
997
  value: value2,
951
998
  selector: selectorStr,
952
- domAssert
999
+ domAssert,
1000
+ start,
1001
+ end: end2
953
1002
  };
954
1003
  }
955
1004
  let headerName;
@@ -976,10 +1025,12 @@ var Parser = class {
976
1025
  if (v2 !== null) return v2;
977
1026
  return this.consumeWhile((c) => c !== "\n");
978
1027
  })();
979
- return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value };
1028
+ const end = this.pos;
1029
+ return { conditionType: ct, field, headerName: headerName ?? void 0, jqExpr: jqExpr ?? void 0, comparison, value, start, end };
980
1030
  }
981
1031
  parseMockHead(prefixWord) {
982
1032
  this.skipSpaces();
1033
+ const start = this.pos;
983
1034
  this.expect(prefixWord);
984
1035
  this.skipInlineSpaces();
985
1036
  this.expect("mock");
@@ -998,7 +1049,8 @@ var Parser = class {
998
1049
  this.skipInlineSpaces();
999
1050
  const returnValue = this.parseBacktickString();
1000
1051
  this.skipSpaces();
1001
- return { target, returnValue };
1052
+ const end = this.pos;
1053
+ return { target, returnValue, start, end };
1002
1054
  }
1003
1055
  parseMock() {
1004
1056
  return this.parseMockHead("with");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",