webpipe-js 2.0.9 → 2.0.11
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 +71 -42
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +71 -42
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -461,41 +461,28 @@ var Parser = class {
|
|
|
461
461
|
if (ifStep) return ifStep;
|
|
462
462
|
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
463
463
|
if (dispatchStep) return dispatchStep;
|
|
464
|
+
const foreachStep = this.tryParse(() => this.parseForeachStep());
|
|
465
|
+
if (foreachStep) return foreachStep;
|
|
464
466
|
return this.parseRegularStep();
|
|
465
467
|
}
|
|
466
|
-
|
|
468
|
+
parseForeachStep() {
|
|
467
469
|
this.skipWhitespaceOnly();
|
|
468
470
|
this.expect("|>");
|
|
469
471
|
this.skipInlineSpaces();
|
|
470
|
-
this.expect("
|
|
471
|
-
this.
|
|
472
|
-
|
|
473
|
-
while (true) {
|
|
474
|
-
const dispatchCase = this.tryParse(() => this.parseDispatchCase());
|
|
475
|
-
if (!dispatchCase) break;
|
|
476
|
-
cases.push(dispatchCase);
|
|
472
|
+
this.expect("foreach");
|
|
473
|
+
if (this.cur() !== " " && this.cur() !== " ") {
|
|
474
|
+
throw new ParseFailure("space after foreach", this.pos);
|
|
477
475
|
}
|
|
478
|
-
const defaultBranch = this.tryParse(() => this.parseDispatchDefault());
|
|
479
|
-
return { kind: "Dispatch", cases, default: defaultBranch || void 0 };
|
|
480
|
-
}
|
|
481
|
-
parseDispatchCase() {
|
|
482
|
-
this.skipSpaces();
|
|
483
|
-
this.expect("case");
|
|
484
476
|
this.skipInlineSpaces();
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
477
|
+
const selector = this.consumeWhile((c) => c !== "\n" && c !== "#").trim();
|
|
478
|
+
if (selector.length === 0) {
|
|
479
|
+
throw new ParseFailure("foreach selector", this.pos);
|
|
480
|
+
}
|
|
488
481
|
this.skipSpaces();
|
|
489
|
-
const pipeline = this.
|
|
490
|
-
return { condition, pipeline };
|
|
491
|
-
}
|
|
492
|
-
parseDispatchDefault() {
|
|
482
|
+
const pipeline = this.parseIfPipeline("end");
|
|
493
483
|
this.skipSpaces();
|
|
494
|
-
this.expect("
|
|
495
|
-
|
|
496
|
-
this.expect(":");
|
|
497
|
-
this.skipSpaces();
|
|
498
|
-
return this.parsePipeline();
|
|
484
|
+
this.expect("end");
|
|
485
|
+
return { kind: "Foreach", selector, pipeline };
|
|
499
486
|
}
|
|
500
487
|
parseRegularStep() {
|
|
501
488
|
this.skipWhitespaceOnly();
|
|
@@ -593,6 +580,41 @@ var Parser = class {
|
|
|
593
580
|
});
|
|
594
581
|
return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
|
|
595
582
|
}
|
|
583
|
+
parseDispatchStep() {
|
|
584
|
+
this.skipWhitespaceOnly();
|
|
585
|
+
this.expect("|>");
|
|
586
|
+
this.skipInlineSpaces();
|
|
587
|
+
this.expect("dispatch");
|
|
588
|
+
this.skipSpaces();
|
|
589
|
+
const branches = [];
|
|
590
|
+
while (true) {
|
|
591
|
+
const branch = this.tryParse(() => this.parseDispatchBranch());
|
|
592
|
+
if (!branch) break;
|
|
593
|
+
branches.push(branch);
|
|
594
|
+
this.skipSpaces();
|
|
595
|
+
}
|
|
596
|
+
const defaultBranch = this.tryParse(() => {
|
|
597
|
+
this.expect("default:");
|
|
598
|
+
this.skipSpaces();
|
|
599
|
+
return this.parseIfPipeline("end");
|
|
600
|
+
});
|
|
601
|
+
this.skipSpaces();
|
|
602
|
+
this.tryParse(() => {
|
|
603
|
+
this.expect("end");
|
|
604
|
+
return true;
|
|
605
|
+
});
|
|
606
|
+
return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
|
|
607
|
+
}
|
|
608
|
+
parseDispatchBranch() {
|
|
609
|
+
this.skipSpaces();
|
|
610
|
+
this.expect("case");
|
|
611
|
+
this.skipInlineSpaces();
|
|
612
|
+
const tag = this.parseTag();
|
|
613
|
+
this.expect(":");
|
|
614
|
+
this.skipSpaces();
|
|
615
|
+
const pipeline = this.parseIfPipeline("case", "default:", "end");
|
|
616
|
+
return { tag, pipeline };
|
|
617
|
+
}
|
|
596
618
|
parseIfPipeline(...stopKeywords) {
|
|
597
619
|
const steps = [];
|
|
598
620
|
while (true) {
|
|
@@ -1126,22 +1148,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1126
1148
|
});
|
|
1127
1149
|
});
|
|
1128
1150
|
return lines.join("\n");
|
|
1129
|
-
} else if (step.kind === "
|
|
1130
|
-
const lines = [`${indent}|> dispatch`];
|
|
1131
|
-
step.cases.forEach((dispatchCase) => {
|
|
1132
|
-
lines.push(`${indent} case ${formatTag(dispatchCase.condition)}:`);
|
|
1133
|
-
dispatchCase.pipeline.steps.forEach((caseStep) => {
|
|
1134
|
-
lines.push(formatPipelineStep(caseStep, indent + " "));
|
|
1135
|
-
});
|
|
1136
|
-
});
|
|
1137
|
-
if (step.default) {
|
|
1138
|
-
lines.push(`${indent} default:`);
|
|
1139
|
-
step.default.steps.forEach((defaultStep) => {
|
|
1140
|
-
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
return lines.join("\n");
|
|
1144
|
-
} else {
|
|
1151
|
+
} else if (step.kind === "If") {
|
|
1145
1152
|
const lines = [`${indent}|> if`];
|
|
1146
1153
|
step.condition.steps.forEach((condStep) => {
|
|
1147
1154
|
lines.push(formatPipelineStep(condStep, indent + " "));
|
|
@@ -1157,6 +1164,28 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1157
1164
|
});
|
|
1158
1165
|
}
|
|
1159
1166
|
return lines.join("\n");
|
|
1167
|
+
} else if (step.kind === "Dispatch") {
|
|
1168
|
+
const lines = [`${indent}|> dispatch`];
|
|
1169
|
+
step.branches.forEach((branch) => {
|
|
1170
|
+
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
1171
|
+
branch.pipeline.steps.forEach((branchStep) => {
|
|
1172
|
+
lines.push(formatPipelineStep(branchStep, indent + " "));
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1175
|
+
if (step.default) {
|
|
1176
|
+
lines.push(`${indent} default:`);
|
|
1177
|
+
step.default.steps.forEach((defaultStep) => {
|
|
1178
|
+
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
return lines.join("\n");
|
|
1182
|
+
} else {
|
|
1183
|
+
const lines = [`${indent}|> foreach ${step.selector}`];
|
|
1184
|
+
step.pipeline.steps.forEach((innerStep) => {
|
|
1185
|
+
lines.push(formatPipelineStep(innerStep, indent + " "));
|
|
1186
|
+
});
|
|
1187
|
+
lines.push(`${indent}end`);
|
|
1188
|
+
return lines.join("\n");
|
|
1160
1189
|
}
|
|
1161
1190
|
}
|
|
1162
1191
|
function formatStepConfig(config, configType) {
|
package/dist/index.d.cts
CHANGED
|
@@ -110,11 +110,15 @@ type PipelineStep = {
|
|
|
110
110
|
elseBranch?: Pipeline;
|
|
111
111
|
} | {
|
|
112
112
|
kind: 'Dispatch';
|
|
113
|
-
|
|
113
|
+
branches: DispatchBranch[];
|
|
114
114
|
default?: Pipeline;
|
|
115
|
+
} | {
|
|
116
|
+
kind: 'Foreach';
|
|
117
|
+
selector: string;
|
|
118
|
+
pipeline: Pipeline;
|
|
115
119
|
};
|
|
116
|
-
interface
|
|
117
|
-
|
|
120
|
+
interface DispatchBranch {
|
|
121
|
+
tag: Tag;
|
|
118
122
|
pipeline: Pipeline;
|
|
119
123
|
}
|
|
120
124
|
interface ResultBranch {
|
|
@@ -208,4 +212,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
208
212
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
209
213
|
declare function formatWhen(when: When): string;
|
|
210
214
|
|
|
211
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type
|
|
215
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type GraphQLSchema, type It, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,11 +110,15 @@ type PipelineStep = {
|
|
|
110
110
|
elseBranch?: Pipeline;
|
|
111
111
|
} | {
|
|
112
112
|
kind: 'Dispatch';
|
|
113
|
-
|
|
113
|
+
branches: DispatchBranch[];
|
|
114
114
|
default?: Pipeline;
|
|
115
|
+
} | {
|
|
116
|
+
kind: 'Foreach';
|
|
117
|
+
selector: string;
|
|
118
|
+
pipeline: Pipeline;
|
|
115
119
|
};
|
|
116
|
-
interface
|
|
117
|
-
|
|
120
|
+
interface DispatchBranch {
|
|
121
|
+
tag: Tag;
|
|
118
122
|
pipeline: Pipeline;
|
|
119
123
|
}
|
|
120
124
|
interface ResultBranch {
|
|
@@ -208,4 +212,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
208
212
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
209
213
|
declare function formatWhen(when: When): string;
|
|
210
214
|
|
|
211
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type
|
|
215
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type GraphQLSchema, type It, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.mjs
CHANGED
|
@@ -412,41 +412,28 @@ var Parser = class {
|
|
|
412
412
|
if (ifStep) return ifStep;
|
|
413
413
|
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
414
414
|
if (dispatchStep) return dispatchStep;
|
|
415
|
+
const foreachStep = this.tryParse(() => this.parseForeachStep());
|
|
416
|
+
if (foreachStep) return foreachStep;
|
|
415
417
|
return this.parseRegularStep();
|
|
416
418
|
}
|
|
417
|
-
|
|
419
|
+
parseForeachStep() {
|
|
418
420
|
this.skipWhitespaceOnly();
|
|
419
421
|
this.expect("|>");
|
|
420
422
|
this.skipInlineSpaces();
|
|
421
|
-
this.expect("
|
|
422
|
-
this.
|
|
423
|
-
|
|
424
|
-
while (true) {
|
|
425
|
-
const dispatchCase = this.tryParse(() => this.parseDispatchCase());
|
|
426
|
-
if (!dispatchCase) break;
|
|
427
|
-
cases.push(dispatchCase);
|
|
423
|
+
this.expect("foreach");
|
|
424
|
+
if (this.cur() !== " " && this.cur() !== " ") {
|
|
425
|
+
throw new ParseFailure("space after foreach", this.pos);
|
|
428
426
|
}
|
|
429
|
-
const defaultBranch = this.tryParse(() => this.parseDispatchDefault());
|
|
430
|
-
return { kind: "Dispatch", cases, default: defaultBranch || void 0 };
|
|
431
|
-
}
|
|
432
|
-
parseDispatchCase() {
|
|
433
|
-
this.skipSpaces();
|
|
434
|
-
this.expect("case");
|
|
435
427
|
this.skipInlineSpaces();
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
const selector = this.consumeWhile((c) => c !== "\n" && c !== "#").trim();
|
|
429
|
+
if (selector.length === 0) {
|
|
430
|
+
throw new ParseFailure("foreach selector", this.pos);
|
|
431
|
+
}
|
|
439
432
|
this.skipSpaces();
|
|
440
|
-
const pipeline = this.
|
|
441
|
-
return { condition, pipeline };
|
|
442
|
-
}
|
|
443
|
-
parseDispatchDefault() {
|
|
433
|
+
const pipeline = this.parseIfPipeline("end");
|
|
444
434
|
this.skipSpaces();
|
|
445
|
-
this.expect("
|
|
446
|
-
|
|
447
|
-
this.expect(":");
|
|
448
|
-
this.skipSpaces();
|
|
449
|
-
return this.parsePipeline();
|
|
435
|
+
this.expect("end");
|
|
436
|
+
return { kind: "Foreach", selector, pipeline };
|
|
450
437
|
}
|
|
451
438
|
parseRegularStep() {
|
|
452
439
|
this.skipWhitespaceOnly();
|
|
@@ -544,6 +531,41 @@ var Parser = class {
|
|
|
544
531
|
});
|
|
545
532
|
return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
|
|
546
533
|
}
|
|
534
|
+
parseDispatchStep() {
|
|
535
|
+
this.skipWhitespaceOnly();
|
|
536
|
+
this.expect("|>");
|
|
537
|
+
this.skipInlineSpaces();
|
|
538
|
+
this.expect("dispatch");
|
|
539
|
+
this.skipSpaces();
|
|
540
|
+
const branches = [];
|
|
541
|
+
while (true) {
|
|
542
|
+
const branch = this.tryParse(() => this.parseDispatchBranch());
|
|
543
|
+
if (!branch) break;
|
|
544
|
+
branches.push(branch);
|
|
545
|
+
this.skipSpaces();
|
|
546
|
+
}
|
|
547
|
+
const defaultBranch = this.tryParse(() => {
|
|
548
|
+
this.expect("default:");
|
|
549
|
+
this.skipSpaces();
|
|
550
|
+
return this.parseIfPipeline("end");
|
|
551
|
+
});
|
|
552
|
+
this.skipSpaces();
|
|
553
|
+
this.tryParse(() => {
|
|
554
|
+
this.expect("end");
|
|
555
|
+
return true;
|
|
556
|
+
});
|
|
557
|
+
return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
|
|
558
|
+
}
|
|
559
|
+
parseDispatchBranch() {
|
|
560
|
+
this.skipSpaces();
|
|
561
|
+
this.expect("case");
|
|
562
|
+
this.skipInlineSpaces();
|
|
563
|
+
const tag = this.parseTag();
|
|
564
|
+
this.expect(":");
|
|
565
|
+
this.skipSpaces();
|
|
566
|
+
const pipeline = this.parseIfPipeline("case", "default:", "end");
|
|
567
|
+
return { tag, pipeline };
|
|
568
|
+
}
|
|
547
569
|
parseIfPipeline(...stopKeywords) {
|
|
548
570
|
const steps = [];
|
|
549
571
|
while (true) {
|
|
@@ -1077,22 +1099,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1077
1099
|
});
|
|
1078
1100
|
});
|
|
1079
1101
|
return lines.join("\n");
|
|
1080
|
-
} else if (step.kind === "
|
|
1081
|
-
const lines = [`${indent}|> dispatch`];
|
|
1082
|
-
step.cases.forEach((dispatchCase) => {
|
|
1083
|
-
lines.push(`${indent} case ${formatTag(dispatchCase.condition)}:`);
|
|
1084
|
-
dispatchCase.pipeline.steps.forEach((caseStep) => {
|
|
1085
|
-
lines.push(formatPipelineStep(caseStep, indent + " "));
|
|
1086
|
-
});
|
|
1087
|
-
});
|
|
1088
|
-
if (step.default) {
|
|
1089
|
-
lines.push(`${indent} default:`);
|
|
1090
|
-
step.default.steps.forEach((defaultStep) => {
|
|
1091
|
-
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
return lines.join("\n");
|
|
1095
|
-
} else {
|
|
1102
|
+
} else if (step.kind === "If") {
|
|
1096
1103
|
const lines = [`${indent}|> if`];
|
|
1097
1104
|
step.condition.steps.forEach((condStep) => {
|
|
1098
1105
|
lines.push(formatPipelineStep(condStep, indent + " "));
|
|
@@ -1108,6 +1115,28 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1108
1115
|
});
|
|
1109
1116
|
}
|
|
1110
1117
|
return lines.join("\n");
|
|
1118
|
+
} else if (step.kind === "Dispatch") {
|
|
1119
|
+
const lines = [`${indent}|> dispatch`];
|
|
1120
|
+
step.branches.forEach((branch) => {
|
|
1121
|
+
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
1122
|
+
branch.pipeline.steps.forEach((branchStep) => {
|
|
1123
|
+
lines.push(formatPipelineStep(branchStep, indent + " "));
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
if (step.default) {
|
|
1127
|
+
lines.push(`${indent} default:`);
|
|
1128
|
+
step.default.steps.forEach((defaultStep) => {
|
|
1129
|
+
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
return lines.join("\n");
|
|
1133
|
+
} else {
|
|
1134
|
+
const lines = [`${indent}|> foreach ${step.selector}`];
|
|
1135
|
+
step.pipeline.steps.forEach((innerStep) => {
|
|
1136
|
+
lines.push(formatPipelineStep(innerStep, indent + " "));
|
|
1137
|
+
});
|
|
1138
|
+
lines.push(`${indent}end`);
|
|
1139
|
+
return lines.join("\n");
|
|
1111
1140
|
}
|
|
1112
1141
|
}
|
|
1113
1142
|
function formatStepConfig(config, configType) {
|