webpipe-js 2.0.7 → 2.0.10
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 +78 -3
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.mjs +78 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -330,7 +330,7 @@ var Parser = class {
|
|
|
330
330
|
return content;
|
|
331
331
|
}
|
|
332
332
|
parseMethod() {
|
|
333
|
-
const methods = ["GET", "POST", "PUT", "
|
|
333
|
+
const methods = ["GET", "POST", "PUT", "DELETE"];
|
|
334
334
|
for (const m of methods) {
|
|
335
335
|
if (this.text.startsWith(m, this.pos)) {
|
|
336
336
|
this.pos += m.length;
|
|
@@ -459,6 +459,8 @@ var Parser = class {
|
|
|
459
459
|
if (result) return result;
|
|
460
460
|
const ifStep = this.tryParse(() => this.parseIfStep());
|
|
461
461
|
if (ifStep) return ifStep;
|
|
462
|
+
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
463
|
+
if (dispatchStep) return dispatchStep;
|
|
462
464
|
return this.parseRegularStep();
|
|
463
465
|
}
|
|
464
466
|
parseRegularStep() {
|
|
@@ -470,8 +472,31 @@ var Parser = class {
|
|
|
470
472
|
this.skipInlineSpaces();
|
|
471
473
|
const { config, configType } = this.parseStepConfig();
|
|
472
474
|
const tags = this.parseTags();
|
|
475
|
+
const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
|
|
473
476
|
this.skipWhitespaceOnly();
|
|
474
|
-
return { kind: "Regular", name, config, configType, tags };
|
|
477
|
+
return { kind: "Regular", name, config, configType, tags, parsedJoinTargets };
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Pre-parse join config into task names at parse time.
|
|
481
|
+
* This avoids repeated parsing in the hot path during execution.
|
|
482
|
+
*/
|
|
483
|
+
parseJoinTaskNames(config) {
|
|
484
|
+
const trimmed = config.trim();
|
|
485
|
+
if (trimmed.startsWith("[")) {
|
|
486
|
+
try {
|
|
487
|
+
const names2 = JSON.parse(trimmed);
|
|
488
|
+
if (Array.isArray(names2) && names2.every((n) => typeof n === "string")) {
|
|
489
|
+
return names2;
|
|
490
|
+
}
|
|
491
|
+
} catch {
|
|
492
|
+
return void 0;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const names = trimmed.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
496
|
+
if (names.length === 0) {
|
|
497
|
+
return void 0;
|
|
498
|
+
}
|
|
499
|
+
return names;
|
|
475
500
|
}
|
|
476
501
|
parseResultStep() {
|
|
477
502
|
this.skipWhitespaceOnly();
|
|
@@ -534,6 +559,41 @@ var Parser = class {
|
|
|
534
559
|
});
|
|
535
560
|
return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
|
|
536
561
|
}
|
|
562
|
+
parseDispatchStep() {
|
|
563
|
+
this.skipWhitespaceOnly();
|
|
564
|
+
this.expect("|>");
|
|
565
|
+
this.skipInlineSpaces();
|
|
566
|
+
this.expect("dispatch");
|
|
567
|
+
this.skipSpaces();
|
|
568
|
+
const branches = [];
|
|
569
|
+
while (true) {
|
|
570
|
+
const branch = this.tryParse(() => this.parseDispatchBranch());
|
|
571
|
+
if (!branch) break;
|
|
572
|
+
branches.push(branch);
|
|
573
|
+
this.skipSpaces();
|
|
574
|
+
}
|
|
575
|
+
const defaultBranch = this.tryParse(() => {
|
|
576
|
+
this.expect("default:");
|
|
577
|
+
this.skipSpaces();
|
|
578
|
+
return this.parseIfPipeline("end");
|
|
579
|
+
});
|
|
580
|
+
this.skipSpaces();
|
|
581
|
+
this.tryParse(() => {
|
|
582
|
+
this.expect("end");
|
|
583
|
+
return true;
|
|
584
|
+
});
|
|
585
|
+
return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
|
|
586
|
+
}
|
|
587
|
+
parseDispatchBranch() {
|
|
588
|
+
this.skipSpaces();
|
|
589
|
+
this.expect("case");
|
|
590
|
+
this.skipInlineSpaces();
|
|
591
|
+
const tag = this.parseTag();
|
|
592
|
+
this.expect(":");
|
|
593
|
+
this.skipSpaces();
|
|
594
|
+
const pipeline = this.parseIfPipeline("case", "default:", "end");
|
|
595
|
+
return { tag, pipeline };
|
|
596
|
+
}
|
|
537
597
|
parseIfPipeline(...stopKeywords) {
|
|
538
598
|
const steps = [];
|
|
539
599
|
while (true) {
|
|
@@ -1067,7 +1127,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1067
1127
|
});
|
|
1068
1128
|
});
|
|
1069
1129
|
return lines.join("\n");
|
|
1070
|
-
} else {
|
|
1130
|
+
} else if (step.kind === "If") {
|
|
1071
1131
|
const lines = [`${indent}|> if`];
|
|
1072
1132
|
step.condition.steps.forEach((condStep) => {
|
|
1073
1133
|
lines.push(formatPipelineStep(condStep, indent + " "));
|
|
@@ -1083,6 +1143,21 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1083
1143
|
});
|
|
1084
1144
|
}
|
|
1085
1145
|
return lines.join("\n");
|
|
1146
|
+
} else {
|
|
1147
|
+
const lines = [`${indent}|> dispatch`];
|
|
1148
|
+
step.branches.forEach((branch) => {
|
|
1149
|
+
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
1150
|
+
branch.pipeline.steps.forEach((branchStep) => {
|
|
1151
|
+
lines.push(formatPipelineStep(branchStep, indent + " "));
|
|
1152
|
+
});
|
|
1153
|
+
});
|
|
1154
|
+
if (step.default) {
|
|
1155
|
+
lines.push(`${indent} default:`);
|
|
1156
|
+
step.default.steps.forEach((defaultStep) => {
|
|
1157
|
+
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
return lines.join("\n");
|
|
1086
1161
|
}
|
|
1087
1162
|
}
|
|
1088
1163
|
function formatStepConfig(config, configType) {
|
package/dist/index.d.cts
CHANGED
|
@@ -99,6 +99,7 @@ type PipelineStep = {
|
|
|
99
99
|
config: string;
|
|
100
100
|
configType: ConfigType;
|
|
101
101
|
tags: Tag[];
|
|
102
|
+
parsedJoinTargets?: string[];
|
|
102
103
|
} | {
|
|
103
104
|
kind: 'Result';
|
|
104
105
|
branches: ResultBranch[];
|
|
@@ -107,7 +108,15 @@ type PipelineStep = {
|
|
|
107
108
|
condition: Pipeline;
|
|
108
109
|
thenBranch: Pipeline;
|
|
109
110
|
elseBranch?: Pipeline;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'Dispatch';
|
|
113
|
+
branches: DispatchBranch[];
|
|
114
|
+
default?: Pipeline;
|
|
110
115
|
};
|
|
116
|
+
interface DispatchBranch {
|
|
117
|
+
tag: Tag;
|
|
118
|
+
pipeline: Pipeline;
|
|
119
|
+
}
|
|
111
120
|
interface ResultBranch {
|
|
112
121
|
branchType: ResultBranchType;
|
|
113
122
|
statusCode: number;
|
|
@@ -199,4 +208,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
199
208
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
200
209
|
declare function formatWhen(when: When): string;
|
|
201
210
|
|
|
202
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, 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 };
|
|
211
|
+
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
|
@@ -99,6 +99,7 @@ type PipelineStep = {
|
|
|
99
99
|
config: string;
|
|
100
100
|
configType: ConfigType;
|
|
101
101
|
tags: Tag[];
|
|
102
|
+
parsedJoinTargets?: string[];
|
|
102
103
|
} | {
|
|
103
104
|
kind: 'Result';
|
|
104
105
|
branches: ResultBranch[];
|
|
@@ -107,7 +108,15 @@ type PipelineStep = {
|
|
|
107
108
|
condition: Pipeline;
|
|
108
109
|
thenBranch: Pipeline;
|
|
109
110
|
elseBranch?: Pipeline;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'Dispatch';
|
|
113
|
+
branches: DispatchBranch[];
|
|
114
|
+
default?: Pipeline;
|
|
110
115
|
};
|
|
116
|
+
interface DispatchBranch {
|
|
117
|
+
tag: Tag;
|
|
118
|
+
pipeline: Pipeline;
|
|
119
|
+
}
|
|
111
120
|
interface ResultBranch {
|
|
112
121
|
branchType: ResultBranchType;
|
|
113
122
|
statusCode: number;
|
|
@@ -199,4 +208,4 @@ declare function formatTag(tag: Tag): string;
|
|
|
199
208
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
200
209
|
declare function formatWhen(when: When): string;
|
|
201
210
|
|
|
202
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, 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 };
|
|
211
|
+
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
|
@@ -281,7 +281,7 @@ var Parser = class {
|
|
|
281
281
|
return content;
|
|
282
282
|
}
|
|
283
283
|
parseMethod() {
|
|
284
|
-
const methods = ["GET", "POST", "PUT", "
|
|
284
|
+
const methods = ["GET", "POST", "PUT", "DELETE"];
|
|
285
285
|
for (const m of methods) {
|
|
286
286
|
if (this.text.startsWith(m, this.pos)) {
|
|
287
287
|
this.pos += m.length;
|
|
@@ -410,6 +410,8 @@ var Parser = class {
|
|
|
410
410
|
if (result) return result;
|
|
411
411
|
const ifStep = this.tryParse(() => this.parseIfStep());
|
|
412
412
|
if (ifStep) return ifStep;
|
|
413
|
+
const dispatchStep = this.tryParse(() => this.parseDispatchStep());
|
|
414
|
+
if (dispatchStep) return dispatchStep;
|
|
413
415
|
return this.parseRegularStep();
|
|
414
416
|
}
|
|
415
417
|
parseRegularStep() {
|
|
@@ -421,8 +423,31 @@ var Parser = class {
|
|
|
421
423
|
this.skipInlineSpaces();
|
|
422
424
|
const { config, configType } = this.parseStepConfig();
|
|
423
425
|
const tags = this.parseTags();
|
|
426
|
+
const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
|
|
424
427
|
this.skipWhitespaceOnly();
|
|
425
|
-
return { kind: "Regular", name, config, configType, tags };
|
|
428
|
+
return { kind: "Regular", name, config, configType, tags, parsedJoinTargets };
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Pre-parse join config into task names at parse time.
|
|
432
|
+
* This avoids repeated parsing in the hot path during execution.
|
|
433
|
+
*/
|
|
434
|
+
parseJoinTaskNames(config) {
|
|
435
|
+
const trimmed = config.trim();
|
|
436
|
+
if (trimmed.startsWith("[")) {
|
|
437
|
+
try {
|
|
438
|
+
const names2 = JSON.parse(trimmed);
|
|
439
|
+
if (Array.isArray(names2) && names2.every((n) => typeof n === "string")) {
|
|
440
|
+
return names2;
|
|
441
|
+
}
|
|
442
|
+
} catch {
|
|
443
|
+
return void 0;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const names = trimmed.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
447
|
+
if (names.length === 0) {
|
|
448
|
+
return void 0;
|
|
449
|
+
}
|
|
450
|
+
return names;
|
|
426
451
|
}
|
|
427
452
|
parseResultStep() {
|
|
428
453
|
this.skipWhitespaceOnly();
|
|
@@ -485,6 +510,41 @@ var Parser = class {
|
|
|
485
510
|
});
|
|
486
511
|
return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
|
|
487
512
|
}
|
|
513
|
+
parseDispatchStep() {
|
|
514
|
+
this.skipWhitespaceOnly();
|
|
515
|
+
this.expect("|>");
|
|
516
|
+
this.skipInlineSpaces();
|
|
517
|
+
this.expect("dispatch");
|
|
518
|
+
this.skipSpaces();
|
|
519
|
+
const branches = [];
|
|
520
|
+
while (true) {
|
|
521
|
+
const branch = this.tryParse(() => this.parseDispatchBranch());
|
|
522
|
+
if (!branch) break;
|
|
523
|
+
branches.push(branch);
|
|
524
|
+
this.skipSpaces();
|
|
525
|
+
}
|
|
526
|
+
const defaultBranch = this.tryParse(() => {
|
|
527
|
+
this.expect("default:");
|
|
528
|
+
this.skipSpaces();
|
|
529
|
+
return this.parseIfPipeline("end");
|
|
530
|
+
});
|
|
531
|
+
this.skipSpaces();
|
|
532
|
+
this.tryParse(() => {
|
|
533
|
+
this.expect("end");
|
|
534
|
+
return true;
|
|
535
|
+
});
|
|
536
|
+
return { kind: "Dispatch", branches, default: defaultBranch || void 0 };
|
|
537
|
+
}
|
|
538
|
+
parseDispatchBranch() {
|
|
539
|
+
this.skipSpaces();
|
|
540
|
+
this.expect("case");
|
|
541
|
+
this.skipInlineSpaces();
|
|
542
|
+
const tag = this.parseTag();
|
|
543
|
+
this.expect(":");
|
|
544
|
+
this.skipSpaces();
|
|
545
|
+
const pipeline = this.parseIfPipeline("case", "default:", "end");
|
|
546
|
+
return { tag, pipeline };
|
|
547
|
+
}
|
|
488
548
|
parseIfPipeline(...stopKeywords) {
|
|
489
549
|
const steps = [];
|
|
490
550
|
while (true) {
|
|
@@ -1018,7 +1078,7 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1018
1078
|
});
|
|
1019
1079
|
});
|
|
1020
1080
|
return lines.join("\n");
|
|
1021
|
-
} else {
|
|
1081
|
+
} else if (step.kind === "If") {
|
|
1022
1082
|
const lines = [`${indent}|> if`];
|
|
1023
1083
|
step.condition.steps.forEach((condStep) => {
|
|
1024
1084
|
lines.push(formatPipelineStep(condStep, indent + " "));
|
|
@@ -1034,6 +1094,21 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
1034
1094
|
});
|
|
1035
1095
|
}
|
|
1036
1096
|
return lines.join("\n");
|
|
1097
|
+
} else {
|
|
1098
|
+
const lines = [`${indent}|> dispatch`];
|
|
1099
|
+
step.branches.forEach((branch) => {
|
|
1100
|
+
lines.push(`${indent} case ${formatTag(branch.tag)}:`);
|
|
1101
|
+
branch.pipeline.steps.forEach((branchStep) => {
|
|
1102
|
+
lines.push(formatPipelineStep(branchStep, indent + " "));
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
if (step.default) {
|
|
1106
|
+
lines.push(`${indent} default:`);
|
|
1107
|
+
step.default.steps.forEach((defaultStep) => {
|
|
1108
|
+
lines.push(formatPipelineStep(defaultStep, indent + " "));
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
return lines.join("\n");
|
|
1037
1112
|
}
|
|
1038
1113
|
}
|
|
1039
1114
|
function formatStepConfig(config, configType) {
|