webpipe-js 0.1.7 → 0.1.8
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 +14 -31
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +14 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -240,11 +240,11 @@ var Parser = class {
|
|
|
240
240
|
}
|
|
241
241
|
parseStepConfig() {
|
|
242
242
|
const bt = this.tryParse(() => this.parseBacktickString());
|
|
243
|
-
if (bt !== null) return bt;
|
|
243
|
+
if (bt !== null) return { config: bt, configType: "backtick" };
|
|
244
244
|
const dq = this.tryParse(() => this.parseQuotedString());
|
|
245
|
-
if (dq !== null) return dq;
|
|
245
|
+
if (dq !== null) return { config: dq, configType: "quoted" };
|
|
246
246
|
const id = this.tryParse(() => this.parseIdentifier());
|
|
247
|
-
if (id !== null) return id;
|
|
247
|
+
if (id !== null) return { config: id, configType: "identifier" };
|
|
248
248
|
throw new ParseFailure("step-config", this.pos);
|
|
249
249
|
}
|
|
250
250
|
parseConfigValue() {
|
|
@@ -316,9 +316,9 @@ var Parser = class {
|
|
|
316
316
|
const name = this.parseIdentifier();
|
|
317
317
|
this.expect(":");
|
|
318
318
|
this.skipInlineSpaces();
|
|
319
|
-
const config = this.parseStepConfig();
|
|
319
|
+
const { config, configType } = this.parseStepConfig();
|
|
320
320
|
this.skipSpaces();
|
|
321
|
-
return { kind: "Regular", name, config };
|
|
321
|
+
return { kind: "Regular", name, config, configType };
|
|
322
322
|
}
|
|
323
323
|
parseResultStep() {
|
|
324
324
|
this.skipSpaces();
|
|
@@ -698,7 +698,7 @@ function formatConfigValue(value) {
|
|
|
698
698
|
}
|
|
699
699
|
function formatPipelineStep(step, indent = " ") {
|
|
700
700
|
if (step.kind === "Regular") {
|
|
701
|
-
return `${indent}|> ${step.name}: ${formatStepConfig(step.config)}`;
|
|
701
|
+
return `${indent}|> ${step.name}: ${formatStepConfig(step.config, step.configType)}`;
|
|
702
702
|
} else {
|
|
703
703
|
const lines = [`${indent}|> result`];
|
|
704
704
|
step.branches.forEach((branch) => {
|
|
@@ -711,33 +711,16 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
711
711
|
return lines.join("\n");
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
|
-
function formatStepConfig(config) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return config;
|
|
714
|
+
function formatStepConfig(config, configType) {
|
|
715
|
+
switch (configType) {
|
|
716
|
+
case "backtick":
|
|
717
|
+
return `\`${config}\``;
|
|
718
|
+
case "quoted":
|
|
719
|
+
return `"${config}"`;
|
|
720
|
+
case "identifier":
|
|
721
|
+
return config;
|
|
723
722
|
}
|
|
724
723
|
}
|
|
725
|
-
function isAuthStringValue(config) {
|
|
726
|
-
const authValues = [
|
|
727
|
-
"login",
|
|
728
|
-
"logout",
|
|
729
|
-
"register",
|
|
730
|
-
"required",
|
|
731
|
-
"optional"
|
|
732
|
-
];
|
|
733
|
-
if (authValues.includes(config)) {
|
|
734
|
-
return true;
|
|
735
|
-
}
|
|
736
|
-
if (config.startsWith("type:")) {
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
return false;
|
|
740
|
-
}
|
|
741
724
|
function formatPipelineRef(ref) {
|
|
742
725
|
if (ref.kind === "Named") {
|
|
743
726
|
return [` |> pipeline: ${ref.name}`];
|
package/dist/index.d.cts
CHANGED
|
@@ -51,10 +51,12 @@ type PipelineRef = {
|
|
|
51
51
|
interface Pipeline {
|
|
52
52
|
steps: PipelineStep[];
|
|
53
53
|
}
|
|
54
|
+
type ConfigType = 'backtick' | 'quoted' | 'identifier';
|
|
54
55
|
type PipelineStep = {
|
|
55
56
|
kind: 'Regular';
|
|
56
57
|
name: string;
|
|
57
58
|
config: string;
|
|
59
|
+
configType: ConfigType;
|
|
58
60
|
} | {
|
|
59
61
|
kind: 'Result';
|
|
60
62
|
branches: ResultBranch[];
|
|
@@ -138,8 +140,8 @@ declare function printDescribe(describe: Describe): string;
|
|
|
138
140
|
declare function prettyPrint(program: Program): string;
|
|
139
141
|
declare function formatConfigValue(value: ConfigValue): string;
|
|
140
142
|
declare function formatPipelineStep(step: PipelineStep, indent?: string): string;
|
|
141
|
-
declare function formatStepConfig(config: string): string;
|
|
143
|
+
declare function formatStepConfig(config: string, configType: ConfigType): string;
|
|
142
144
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
143
145
|
declare function formatWhen(when: When): string;
|
|
144
146
|
|
|
145
|
-
export { type Condition, type Config, type ConfigProperty, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
|
147
|
+
export { type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
package/dist/index.d.ts
CHANGED
|
@@ -51,10 +51,12 @@ type PipelineRef = {
|
|
|
51
51
|
interface Pipeline {
|
|
52
52
|
steps: PipelineStep[];
|
|
53
53
|
}
|
|
54
|
+
type ConfigType = 'backtick' | 'quoted' | 'identifier';
|
|
54
55
|
type PipelineStep = {
|
|
55
56
|
kind: 'Regular';
|
|
56
57
|
name: string;
|
|
57
58
|
config: string;
|
|
59
|
+
configType: ConfigType;
|
|
58
60
|
} | {
|
|
59
61
|
kind: 'Result';
|
|
60
62
|
branches: ResultBranch[];
|
|
@@ -138,8 +140,8 @@ declare function printDescribe(describe: Describe): string;
|
|
|
138
140
|
declare function prettyPrint(program: Program): string;
|
|
139
141
|
declare function formatConfigValue(value: ConfigValue): string;
|
|
140
142
|
declare function formatPipelineStep(step: PipelineStep, indent?: string): string;
|
|
141
|
-
declare function formatStepConfig(config: string): string;
|
|
143
|
+
declare function formatStepConfig(config: string, configType: ConfigType): string;
|
|
142
144
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
143
145
|
declare function formatWhen(when: When): string;
|
|
144
146
|
|
|
145
|
-
export { type Condition, type Config, type ConfigProperty, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
|
147
|
+
export { type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type It, type Mock, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type ResultBranch, type ResultBranchType, type Route, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printCondition, printConfig, printDescribe, printMock, printPipeline, printRoute, printTest, printVariable };
|
package/dist/index.mjs
CHANGED
|
@@ -197,11 +197,11 @@ var Parser = class {
|
|
|
197
197
|
}
|
|
198
198
|
parseStepConfig() {
|
|
199
199
|
const bt = this.tryParse(() => this.parseBacktickString());
|
|
200
|
-
if (bt !== null) return bt;
|
|
200
|
+
if (bt !== null) return { config: bt, configType: "backtick" };
|
|
201
201
|
const dq = this.tryParse(() => this.parseQuotedString());
|
|
202
|
-
if (dq !== null) return dq;
|
|
202
|
+
if (dq !== null) return { config: dq, configType: "quoted" };
|
|
203
203
|
const id = this.tryParse(() => this.parseIdentifier());
|
|
204
|
-
if (id !== null) return id;
|
|
204
|
+
if (id !== null) return { config: id, configType: "identifier" };
|
|
205
205
|
throw new ParseFailure("step-config", this.pos);
|
|
206
206
|
}
|
|
207
207
|
parseConfigValue() {
|
|
@@ -273,9 +273,9 @@ var Parser = class {
|
|
|
273
273
|
const name = this.parseIdentifier();
|
|
274
274
|
this.expect(":");
|
|
275
275
|
this.skipInlineSpaces();
|
|
276
|
-
const config = this.parseStepConfig();
|
|
276
|
+
const { config, configType } = this.parseStepConfig();
|
|
277
277
|
this.skipSpaces();
|
|
278
|
-
return { kind: "Regular", name, config };
|
|
278
|
+
return { kind: "Regular", name, config, configType };
|
|
279
279
|
}
|
|
280
280
|
parseResultStep() {
|
|
281
281
|
this.skipSpaces();
|
|
@@ -655,7 +655,7 @@ function formatConfigValue(value) {
|
|
|
655
655
|
}
|
|
656
656
|
function formatPipelineStep(step, indent = " ") {
|
|
657
657
|
if (step.kind === "Regular") {
|
|
658
|
-
return `${indent}|> ${step.name}: ${formatStepConfig(step.config)}`;
|
|
658
|
+
return `${indent}|> ${step.name}: ${formatStepConfig(step.config, step.configType)}`;
|
|
659
659
|
} else {
|
|
660
660
|
const lines = [`${indent}|> result`];
|
|
661
661
|
step.branches.forEach((branch) => {
|
|
@@ -668,33 +668,16 @@ function formatPipelineStep(step, indent = " ") {
|
|
|
668
668
|
return lines.join("\n");
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function formatStepConfig(config) {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return config;
|
|
671
|
+
function formatStepConfig(config, configType) {
|
|
672
|
+
switch (configType) {
|
|
673
|
+
case "backtick":
|
|
674
|
+
return `\`${config}\``;
|
|
675
|
+
case "quoted":
|
|
676
|
+
return `"${config}"`;
|
|
677
|
+
case "identifier":
|
|
678
|
+
return config;
|
|
680
679
|
}
|
|
681
680
|
}
|
|
682
|
-
function isAuthStringValue(config) {
|
|
683
|
-
const authValues = [
|
|
684
|
-
"login",
|
|
685
|
-
"logout",
|
|
686
|
-
"register",
|
|
687
|
-
"required",
|
|
688
|
-
"optional"
|
|
689
|
-
];
|
|
690
|
-
if (authValues.includes(config)) {
|
|
691
|
-
return true;
|
|
692
|
-
}
|
|
693
|
-
if (config.startsWith("type:")) {
|
|
694
|
-
return true;
|
|
695
|
-
}
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
698
681
|
function formatPipelineRef(ref) {
|
|
699
682
|
if (ref.kind === "Named") {
|
|
700
683
|
return [` |> pipeline: ${ref.name}`];
|