webpipe-js 2.0.25 → 2.0.27
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 +33 -12
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +33 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1057,21 +1057,31 @@ var Parser = class {
|
|
|
1057
1057
|
this.skipInlineSpaces();
|
|
1058
1058
|
this.expect("=");
|
|
1059
1059
|
this.skipInlineSpaces();
|
|
1060
|
+
let format;
|
|
1060
1061
|
const value = (() => {
|
|
1061
1062
|
const bt = this.tryParse(() => this.parseBacktickString());
|
|
1062
|
-
if (bt !== null)
|
|
1063
|
+
if (bt !== null) {
|
|
1064
|
+
format = "backtick";
|
|
1065
|
+
return bt;
|
|
1066
|
+
}
|
|
1063
1067
|
const qt = this.tryParse(() => this.parseQuotedString());
|
|
1064
|
-
if (qt !== null)
|
|
1068
|
+
if (qt !== null) {
|
|
1069
|
+
format = "quoted";
|
|
1070
|
+
return qt;
|
|
1071
|
+
}
|
|
1065
1072
|
if (this.text.startsWith("null", this.pos)) {
|
|
1066
1073
|
this.pos += 4;
|
|
1074
|
+
format = "bare";
|
|
1067
1075
|
return "null";
|
|
1068
1076
|
}
|
|
1069
1077
|
if (this.text.startsWith("true", this.pos)) {
|
|
1070
1078
|
this.pos += 4;
|
|
1079
|
+
format = "bare";
|
|
1071
1080
|
return "true";
|
|
1072
1081
|
}
|
|
1073
1082
|
if (this.text.startsWith("false", this.pos)) {
|
|
1074
1083
|
this.pos += 5;
|
|
1084
|
+
format = "bare";
|
|
1075
1085
|
return "false";
|
|
1076
1086
|
}
|
|
1077
1087
|
const num = this.tryParse(() => {
|
|
@@ -1085,10 +1095,13 @@ var Parser = class {
|
|
|
1085
1095
|
}
|
|
1086
1096
|
return digits;
|
|
1087
1097
|
});
|
|
1088
|
-
if (num !== null)
|
|
1098
|
+
if (num !== null) {
|
|
1099
|
+
format = "bare";
|
|
1100
|
+
return num;
|
|
1101
|
+
}
|
|
1089
1102
|
throw new Error("let value");
|
|
1090
1103
|
})();
|
|
1091
|
-
return [name, value];
|
|
1104
|
+
return [name, value, format];
|
|
1092
1105
|
}
|
|
1093
1106
|
parseIt() {
|
|
1094
1107
|
this.skipSpaces();
|
|
@@ -1207,10 +1220,16 @@ var Parser = class {
|
|
|
1207
1220
|
this.expect('"');
|
|
1208
1221
|
const inlineComment = this.parseInlineComment();
|
|
1209
1222
|
this.skipSpaces();
|
|
1223
|
+
const variables = [];
|
|
1210
1224
|
const mocks = [];
|
|
1211
1225
|
const tests = [];
|
|
1212
1226
|
while (true) {
|
|
1213
1227
|
this.skipSpaces();
|
|
1228
|
+
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1229
|
+
if (letBinding) {
|
|
1230
|
+
variables.push(letBinding);
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1214
1233
|
const withMock = this.tryParse(() => this.parseMock());
|
|
1215
1234
|
if (withMock) {
|
|
1216
1235
|
mocks.push(withMock);
|
|
@@ -1228,7 +1247,7 @@ var Parser = class {
|
|
|
1228
1247
|
}
|
|
1229
1248
|
break;
|
|
1230
1249
|
}
|
|
1231
|
-
return { name, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1250
|
+
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1232
1251
|
}
|
|
1233
1252
|
};
|
|
1234
1253
|
function parseProgram(text) {
|
|
@@ -1371,13 +1390,8 @@ function printTest(test) {
|
|
|
1371
1390
|
});
|
|
1372
1391
|
lines.push(` when ${formatWhen(test.when)}`);
|
|
1373
1392
|
if (test.variables) {
|
|
1374
|
-
test.variables.forEach(([name, value]) => {
|
|
1375
|
-
const formattedValue =
|
|
1376
|
-
if (value.startsWith("`") || value.startsWith('"')) return value;
|
|
1377
|
-
if (value === "true" || value === "false" || /^\d+$/.test(value)) return value;
|
|
1378
|
-
if (value.includes("{") || value.includes("[") || value.includes("\n")) return `\`${value}\``;
|
|
1379
|
-
return `"${value}"`;
|
|
1380
|
-
})();
|
|
1393
|
+
test.variables.forEach(([name, value, format]) => {
|
|
1394
|
+
const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
|
|
1381
1395
|
lines.push(` let ${name} = ${formattedValue}`);
|
|
1382
1396
|
});
|
|
1383
1397
|
}
|
|
@@ -1415,6 +1429,13 @@ function printDescribe(describe) {
|
|
|
1415
1429
|
} else {
|
|
1416
1430
|
lines.push(describeLine);
|
|
1417
1431
|
}
|
|
1432
|
+
if (describe.variables && describe.variables.length > 0) {
|
|
1433
|
+
describe.variables.forEach(([name, value, format]) => {
|
|
1434
|
+
const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
|
|
1435
|
+
lines.push(` let ${name} = ${formattedValue}`);
|
|
1436
|
+
});
|
|
1437
|
+
lines.push("");
|
|
1438
|
+
}
|
|
1418
1439
|
describe.mocks.forEach((mock) => {
|
|
1419
1440
|
lines.push(printMock(mock));
|
|
1420
1441
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -88,6 +88,7 @@ interface Pipeline {
|
|
|
88
88
|
steps: PipelineStep[];
|
|
89
89
|
}
|
|
90
90
|
type ConfigType = 'backtick' | 'quoted' | 'identifier';
|
|
91
|
+
type LetValueFormat = 'quoted' | 'backtick' | 'bare';
|
|
91
92
|
interface Tag {
|
|
92
93
|
name: string;
|
|
93
94
|
negated: boolean;
|
|
@@ -149,6 +150,7 @@ type ResultBranchType = {
|
|
|
149
150
|
};
|
|
150
151
|
interface Describe {
|
|
151
152
|
name: string;
|
|
153
|
+
variables: Array<[string, string, LetValueFormat]>;
|
|
152
154
|
mocks: Mock[];
|
|
153
155
|
tests: It[];
|
|
154
156
|
lineNumber?: number;
|
|
@@ -162,7 +164,7 @@ interface It {
|
|
|
162
164
|
name: string;
|
|
163
165
|
mocks: Mock[];
|
|
164
166
|
when: When;
|
|
165
|
-
variables?: Array<[string, string]>;
|
|
167
|
+
variables?: Array<[string, string, LetValueFormat]>;
|
|
166
168
|
input?: string;
|
|
167
169
|
body?: string;
|
|
168
170
|
headers?: string;
|
|
@@ -245,4 +247,4 @@ declare function formatTagExpr(expr: TagExpr): string;
|
|
|
245
247
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
246
248
|
declare function formatWhen(when: When): string;
|
|
247
249
|
|
|
248
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, 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 TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
|
250
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, 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 TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, 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
|
@@ -88,6 +88,7 @@ interface Pipeline {
|
|
|
88
88
|
steps: PipelineStep[];
|
|
89
89
|
}
|
|
90
90
|
type ConfigType = 'backtick' | 'quoted' | 'identifier';
|
|
91
|
+
type LetValueFormat = 'quoted' | 'backtick' | 'bare';
|
|
91
92
|
interface Tag {
|
|
92
93
|
name: string;
|
|
93
94
|
negated: boolean;
|
|
@@ -149,6 +150,7 @@ type ResultBranchType = {
|
|
|
149
150
|
};
|
|
150
151
|
interface Describe {
|
|
151
152
|
name: string;
|
|
153
|
+
variables: Array<[string, string, LetValueFormat]>;
|
|
152
154
|
mocks: Mock[];
|
|
153
155
|
tests: It[];
|
|
154
156
|
lineNumber?: number;
|
|
@@ -162,7 +164,7 @@ interface It {
|
|
|
162
164
|
name: string;
|
|
163
165
|
mocks: Mock[];
|
|
164
166
|
when: When;
|
|
165
|
-
variables?: Array<[string, string]>;
|
|
167
|
+
variables?: Array<[string, string, LetValueFormat]>;
|
|
166
168
|
input?: string;
|
|
167
169
|
body?: string;
|
|
168
170
|
headers?: string;
|
|
@@ -245,4 +247,4 @@ declare function formatTagExpr(expr: TagExpr): string;
|
|
|
245
247
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
246
248
|
declare function formatWhen(when: When): string;
|
|
247
249
|
|
|
248
|
-
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, 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 TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
|
250
|
+
export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, 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 TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.mjs
CHANGED
|
@@ -1007,21 +1007,31 @@ var Parser = class {
|
|
|
1007
1007
|
this.skipInlineSpaces();
|
|
1008
1008
|
this.expect("=");
|
|
1009
1009
|
this.skipInlineSpaces();
|
|
1010
|
+
let format;
|
|
1010
1011
|
const value = (() => {
|
|
1011
1012
|
const bt = this.tryParse(() => this.parseBacktickString());
|
|
1012
|
-
if (bt !== null)
|
|
1013
|
+
if (bt !== null) {
|
|
1014
|
+
format = "backtick";
|
|
1015
|
+
return bt;
|
|
1016
|
+
}
|
|
1013
1017
|
const qt = this.tryParse(() => this.parseQuotedString());
|
|
1014
|
-
if (qt !== null)
|
|
1018
|
+
if (qt !== null) {
|
|
1019
|
+
format = "quoted";
|
|
1020
|
+
return qt;
|
|
1021
|
+
}
|
|
1015
1022
|
if (this.text.startsWith("null", this.pos)) {
|
|
1016
1023
|
this.pos += 4;
|
|
1024
|
+
format = "bare";
|
|
1017
1025
|
return "null";
|
|
1018
1026
|
}
|
|
1019
1027
|
if (this.text.startsWith("true", this.pos)) {
|
|
1020
1028
|
this.pos += 4;
|
|
1029
|
+
format = "bare";
|
|
1021
1030
|
return "true";
|
|
1022
1031
|
}
|
|
1023
1032
|
if (this.text.startsWith("false", this.pos)) {
|
|
1024
1033
|
this.pos += 5;
|
|
1034
|
+
format = "bare";
|
|
1025
1035
|
return "false";
|
|
1026
1036
|
}
|
|
1027
1037
|
const num = this.tryParse(() => {
|
|
@@ -1035,10 +1045,13 @@ var Parser = class {
|
|
|
1035
1045
|
}
|
|
1036
1046
|
return digits;
|
|
1037
1047
|
});
|
|
1038
|
-
if (num !== null)
|
|
1048
|
+
if (num !== null) {
|
|
1049
|
+
format = "bare";
|
|
1050
|
+
return num;
|
|
1051
|
+
}
|
|
1039
1052
|
throw new Error("let value");
|
|
1040
1053
|
})();
|
|
1041
|
-
return [name, value];
|
|
1054
|
+
return [name, value, format];
|
|
1042
1055
|
}
|
|
1043
1056
|
parseIt() {
|
|
1044
1057
|
this.skipSpaces();
|
|
@@ -1157,10 +1170,16 @@ var Parser = class {
|
|
|
1157
1170
|
this.expect('"');
|
|
1158
1171
|
const inlineComment = this.parseInlineComment();
|
|
1159
1172
|
this.skipSpaces();
|
|
1173
|
+
const variables = [];
|
|
1160
1174
|
const mocks = [];
|
|
1161
1175
|
const tests = [];
|
|
1162
1176
|
while (true) {
|
|
1163
1177
|
this.skipSpaces();
|
|
1178
|
+
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1179
|
+
if (letBinding) {
|
|
1180
|
+
variables.push(letBinding);
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1164
1183
|
const withMock = this.tryParse(() => this.parseMock());
|
|
1165
1184
|
if (withMock) {
|
|
1166
1185
|
mocks.push(withMock);
|
|
@@ -1178,7 +1197,7 @@ var Parser = class {
|
|
|
1178
1197
|
}
|
|
1179
1198
|
break;
|
|
1180
1199
|
}
|
|
1181
|
-
return { name, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1200
|
+
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1182
1201
|
}
|
|
1183
1202
|
};
|
|
1184
1203
|
function parseProgram(text) {
|
|
@@ -1321,13 +1340,8 @@ function printTest(test) {
|
|
|
1321
1340
|
});
|
|
1322
1341
|
lines.push(` when ${formatWhen(test.when)}`);
|
|
1323
1342
|
if (test.variables) {
|
|
1324
|
-
test.variables.forEach(([name, value]) => {
|
|
1325
|
-
const formattedValue =
|
|
1326
|
-
if (value.startsWith("`") || value.startsWith('"')) return value;
|
|
1327
|
-
if (value === "true" || value === "false" || /^\d+$/.test(value)) return value;
|
|
1328
|
-
if (value.includes("{") || value.includes("[") || value.includes("\n")) return `\`${value}\``;
|
|
1329
|
-
return `"${value}"`;
|
|
1330
|
-
})();
|
|
1343
|
+
test.variables.forEach(([name, value, format]) => {
|
|
1344
|
+
const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
|
|
1331
1345
|
lines.push(` let ${name} = ${formattedValue}`);
|
|
1332
1346
|
});
|
|
1333
1347
|
}
|
|
@@ -1365,6 +1379,13 @@ function printDescribe(describe) {
|
|
|
1365
1379
|
} else {
|
|
1366
1380
|
lines.push(describeLine);
|
|
1367
1381
|
}
|
|
1382
|
+
if (describe.variables && describe.variables.length > 0) {
|
|
1383
|
+
describe.variables.forEach(([name, value, format]) => {
|
|
1384
|
+
const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
|
|
1385
|
+
lines.push(` let ${name} = ${formattedValue}`);
|
|
1386
|
+
});
|
|
1387
|
+
lines.push("");
|
|
1388
|
+
}
|
|
1368
1389
|
describe.mocks.forEach((mock) => {
|
|
1369
1390
|
lines.push(printMock(mock));
|
|
1370
1391
|
});
|