webpipe-js 2.0.28 → 2.0.29
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 +31 -5
- package/dist/{index.d.cts → index.d.mts} +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +30 -5
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
formatWhen: () => formatWhen,
|
|
31
31
|
getPipelineRanges: () => getPipelineRanges,
|
|
32
32
|
getTestLetVariableRanges: () => getTestLetVariableRanges,
|
|
33
|
+
getTestLetVariables: () => getTestLetVariables,
|
|
33
34
|
getVariableRanges: () => getVariableRanges,
|
|
34
35
|
parseProgram: () => parseProgram,
|
|
35
36
|
parseProgramWithDiagnostics: () => parseProgramWithDiagnostics,
|
|
@@ -56,7 +57,9 @@ var Parser = class {
|
|
|
56
57
|
this.diagnostics = [];
|
|
57
58
|
this.pipelineRanges = /* @__PURE__ */ new Map();
|
|
58
59
|
this.variableRanges = /* @__PURE__ */ new Map();
|
|
59
|
-
this.
|
|
60
|
+
this.testLetVariables = [];
|
|
61
|
+
this.currentDescribeName = null;
|
|
62
|
+
this.currentTestName = null;
|
|
60
63
|
this.text = text;
|
|
61
64
|
this.len = text.length;
|
|
62
65
|
}
|
|
@@ -69,8 +72,8 @@ var Parser = class {
|
|
|
69
72
|
getVariableRanges() {
|
|
70
73
|
return new Map(this.variableRanges);
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
return
|
|
75
|
+
getTestLetVariables() {
|
|
76
|
+
return [...this.testLetVariables];
|
|
74
77
|
}
|
|
75
78
|
report(message, start, end, severity) {
|
|
76
79
|
this.diagnostics.push({ message, start, end, severity });
|
|
@@ -1061,7 +1064,15 @@ var Parser = class {
|
|
|
1061
1064
|
const nameStart = this.pos;
|
|
1062
1065
|
const name = this.parseIdentifier();
|
|
1063
1066
|
const nameEnd = this.pos;
|
|
1064
|
-
this.
|
|
1067
|
+
if (this.currentDescribeName !== null) {
|
|
1068
|
+
this.testLetVariables.push({
|
|
1069
|
+
name,
|
|
1070
|
+
describeName: this.currentDescribeName,
|
|
1071
|
+
testName: this.currentTestName || void 0,
|
|
1072
|
+
start: nameStart,
|
|
1073
|
+
end: nameEnd
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1065
1076
|
this.skipInlineSpaces();
|
|
1066
1077
|
this.expect("=");
|
|
1067
1078
|
this.skipInlineSpaces();
|
|
@@ -1119,6 +1130,7 @@ var Parser = class {
|
|
|
1119
1130
|
const name = this.consumeWhile((c) => c !== '"');
|
|
1120
1131
|
this.expect('"');
|
|
1121
1132
|
this.skipSpaces();
|
|
1133
|
+
this.currentTestName = name;
|
|
1122
1134
|
const mocks = [];
|
|
1123
1135
|
while (true) {
|
|
1124
1136
|
const m = this.tryParse(() => this.parseMock());
|
|
@@ -1207,6 +1219,7 @@ var Parser = class {
|
|
|
1207
1219
|
if (!c) break;
|
|
1208
1220
|
conditions.push(c);
|
|
1209
1221
|
}
|
|
1222
|
+
this.currentTestName = null;
|
|
1210
1223
|
return {
|
|
1211
1224
|
name,
|
|
1212
1225
|
mocks: [...mocks, ...extraMocks],
|
|
@@ -1228,6 +1241,7 @@ var Parser = class {
|
|
|
1228
1241
|
this.expect('"');
|
|
1229
1242
|
const inlineComment = this.parseInlineComment();
|
|
1230
1243
|
this.skipSpaces();
|
|
1244
|
+
this.currentDescribeName = name;
|
|
1231
1245
|
const variables = [];
|
|
1232
1246
|
const mocks = [];
|
|
1233
1247
|
const tests = [];
|
|
@@ -1255,6 +1269,7 @@ var Parser = class {
|
|
|
1255
1269
|
}
|
|
1256
1270
|
break;
|
|
1257
1271
|
}
|
|
1272
|
+
this.currentDescribeName = null;
|
|
1258
1273
|
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1259
1274
|
}
|
|
1260
1275
|
};
|
|
@@ -1277,10 +1292,20 @@ function getVariableRanges(text) {
|
|
|
1277
1292
|
parser.parseProgram();
|
|
1278
1293
|
return parser.getVariableRanges();
|
|
1279
1294
|
}
|
|
1295
|
+
function getTestLetVariables(text) {
|
|
1296
|
+
const parser = new Parser(text);
|
|
1297
|
+
parser.parseProgram();
|
|
1298
|
+
return parser.getTestLetVariables();
|
|
1299
|
+
}
|
|
1280
1300
|
function getTestLetVariableRanges(text) {
|
|
1281
1301
|
const parser = new Parser(text);
|
|
1282
1302
|
parser.parseProgram();
|
|
1283
|
-
|
|
1303
|
+
const variables = parser.getTestLetVariables();
|
|
1304
|
+
const map = /* @__PURE__ */ new Map();
|
|
1305
|
+
for (const v of variables) {
|
|
1306
|
+
map.set(v.name, { start: v.start, end: v.end });
|
|
1307
|
+
}
|
|
1308
|
+
return map;
|
|
1284
1309
|
}
|
|
1285
1310
|
var ParseFailure = class extends Error {
|
|
1286
1311
|
constructor(message, at) {
|
|
@@ -1671,6 +1696,7 @@ function formatWhen(when) {
|
|
|
1671
1696
|
formatWhen,
|
|
1672
1697
|
getPipelineRanges,
|
|
1673
1698
|
getTestLetVariableRanges,
|
|
1699
|
+
getTestLetVariables,
|
|
1674
1700
|
getVariableRanges,
|
|
1675
1701
|
parseProgram,
|
|
1676
1702
|
parseProgramWithDiagnostics,
|
|
@@ -212,6 +212,13 @@ interface ParseDiagnostic {
|
|
|
212
212
|
end: number;
|
|
213
213
|
severity: DiagnosticSeverity;
|
|
214
214
|
}
|
|
215
|
+
interface TestLetVariable {
|
|
216
|
+
name: string;
|
|
217
|
+
describeName: string;
|
|
218
|
+
testName?: string;
|
|
219
|
+
start: number;
|
|
220
|
+
end: number;
|
|
221
|
+
}
|
|
215
222
|
declare function parseProgram(text: string): Program;
|
|
216
223
|
declare function parseProgramWithDiagnostics(text: string): {
|
|
217
224
|
program: Program;
|
|
@@ -225,6 +232,7 @@ declare function getVariableRanges(text: string): Map<string, {
|
|
|
225
232
|
start: number;
|
|
226
233
|
end: number;
|
|
227
234
|
}>;
|
|
235
|
+
declare function getTestLetVariables(text: string): TestLetVariable[];
|
|
228
236
|
declare function getTestLetVariableRanges(text: string): Map<string, {
|
|
229
237
|
start: number;
|
|
230
238
|
end: number;
|
|
@@ -251,4 +259,4 @@ declare function formatTagExpr(expr: TagExpr): string;
|
|
|
251
259
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
252
260
|
declare function formatWhen(when: When): string;
|
|
253
261
|
|
|
254
|
-
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, getTestLetVariableRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
|
262
|
+
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 TestLetVariable, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getTestLetVariableRanges, getTestLetVariables, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,13 @@ interface ParseDiagnostic {
|
|
|
212
212
|
end: number;
|
|
213
213
|
severity: DiagnosticSeverity;
|
|
214
214
|
}
|
|
215
|
+
interface TestLetVariable {
|
|
216
|
+
name: string;
|
|
217
|
+
describeName: string;
|
|
218
|
+
testName?: string;
|
|
219
|
+
start: number;
|
|
220
|
+
end: number;
|
|
221
|
+
}
|
|
215
222
|
declare function parseProgram(text: string): Program;
|
|
216
223
|
declare function parseProgramWithDiagnostics(text: string): {
|
|
217
224
|
program: Program;
|
|
@@ -225,6 +232,7 @@ declare function getVariableRanges(text: string): Map<string, {
|
|
|
225
232
|
start: number;
|
|
226
233
|
end: number;
|
|
227
234
|
}>;
|
|
235
|
+
declare function getTestLetVariables(text: string): TestLetVariable[];
|
|
228
236
|
declare function getTestLetVariableRanges(text: string): Map<string, {
|
|
229
237
|
start: number;
|
|
230
238
|
end: number;
|
|
@@ -251,4 +259,4 @@ declare function formatTagExpr(expr: TagExpr): string;
|
|
|
251
259
|
declare function formatPipelineRef(ref: PipelineRef): string[];
|
|
252
260
|
declare function formatWhen(when: When): string;
|
|
253
261
|
|
|
254
|
-
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, getTestLetVariableRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
|
262
|
+
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 TestLetVariable, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getTestLetVariableRanges, getTestLetVariables, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,9 @@ var Parser = class {
|
|
|
5
5
|
this.diagnostics = [];
|
|
6
6
|
this.pipelineRanges = /* @__PURE__ */ new Map();
|
|
7
7
|
this.variableRanges = /* @__PURE__ */ new Map();
|
|
8
|
-
this.
|
|
8
|
+
this.testLetVariables = [];
|
|
9
|
+
this.currentDescribeName = null;
|
|
10
|
+
this.currentTestName = null;
|
|
9
11
|
this.text = text;
|
|
10
12
|
this.len = text.length;
|
|
11
13
|
}
|
|
@@ -18,8 +20,8 @@ var Parser = class {
|
|
|
18
20
|
getVariableRanges() {
|
|
19
21
|
return new Map(this.variableRanges);
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
+
getTestLetVariables() {
|
|
24
|
+
return [...this.testLetVariables];
|
|
23
25
|
}
|
|
24
26
|
report(message, start, end, severity) {
|
|
25
27
|
this.diagnostics.push({ message, start, end, severity });
|
|
@@ -1010,7 +1012,15 @@ var Parser = class {
|
|
|
1010
1012
|
const nameStart = this.pos;
|
|
1011
1013
|
const name = this.parseIdentifier();
|
|
1012
1014
|
const nameEnd = this.pos;
|
|
1013
|
-
this.
|
|
1015
|
+
if (this.currentDescribeName !== null) {
|
|
1016
|
+
this.testLetVariables.push({
|
|
1017
|
+
name,
|
|
1018
|
+
describeName: this.currentDescribeName,
|
|
1019
|
+
testName: this.currentTestName || void 0,
|
|
1020
|
+
start: nameStart,
|
|
1021
|
+
end: nameEnd
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1014
1024
|
this.skipInlineSpaces();
|
|
1015
1025
|
this.expect("=");
|
|
1016
1026
|
this.skipInlineSpaces();
|
|
@@ -1068,6 +1078,7 @@ var Parser = class {
|
|
|
1068
1078
|
const name = this.consumeWhile((c) => c !== '"');
|
|
1069
1079
|
this.expect('"');
|
|
1070
1080
|
this.skipSpaces();
|
|
1081
|
+
this.currentTestName = name;
|
|
1071
1082
|
const mocks = [];
|
|
1072
1083
|
while (true) {
|
|
1073
1084
|
const m = this.tryParse(() => this.parseMock());
|
|
@@ -1156,6 +1167,7 @@ var Parser = class {
|
|
|
1156
1167
|
if (!c) break;
|
|
1157
1168
|
conditions.push(c);
|
|
1158
1169
|
}
|
|
1170
|
+
this.currentTestName = null;
|
|
1159
1171
|
return {
|
|
1160
1172
|
name,
|
|
1161
1173
|
mocks: [...mocks, ...extraMocks],
|
|
@@ -1177,6 +1189,7 @@ var Parser = class {
|
|
|
1177
1189
|
this.expect('"');
|
|
1178
1190
|
const inlineComment = this.parseInlineComment();
|
|
1179
1191
|
this.skipSpaces();
|
|
1192
|
+
this.currentDescribeName = name;
|
|
1180
1193
|
const variables = [];
|
|
1181
1194
|
const mocks = [];
|
|
1182
1195
|
const tests = [];
|
|
@@ -1204,6 +1217,7 @@ var Parser = class {
|
|
|
1204
1217
|
}
|
|
1205
1218
|
break;
|
|
1206
1219
|
}
|
|
1220
|
+
this.currentDescribeName = null;
|
|
1207
1221
|
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
|
|
1208
1222
|
}
|
|
1209
1223
|
};
|
|
@@ -1226,10 +1240,20 @@ function getVariableRanges(text) {
|
|
|
1226
1240
|
parser.parseProgram();
|
|
1227
1241
|
return parser.getVariableRanges();
|
|
1228
1242
|
}
|
|
1243
|
+
function getTestLetVariables(text) {
|
|
1244
|
+
const parser = new Parser(text);
|
|
1245
|
+
parser.parseProgram();
|
|
1246
|
+
return parser.getTestLetVariables();
|
|
1247
|
+
}
|
|
1229
1248
|
function getTestLetVariableRanges(text) {
|
|
1230
1249
|
const parser = new Parser(text);
|
|
1231
1250
|
parser.parseProgram();
|
|
1232
|
-
|
|
1251
|
+
const variables = parser.getTestLetVariables();
|
|
1252
|
+
const map = /* @__PURE__ */ new Map();
|
|
1253
|
+
for (const v of variables) {
|
|
1254
|
+
map.set(v.name, { start: v.start, end: v.end });
|
|
1255
|
+
}
|
|
1256
|
+
return map;
|
|
1233
1257
|
}
|
|
1234
1258
|
var ParseFailure = class extends Error {
|
|
1235
1259
|
constructor(message, at) {
|
|
@@ -1619,6 +1643,7 @@ export {
|
|
|
1619
1643
|
formatWhen,
|
|
1620
1644
|
getPipelineRanges,
|
|
1621
1645
|
getTestLetVariableRanges,
|
|
1646
|
+
getTestLetVariables,
|
|
1622
1647
|
getVariableRanges,
|
|
1623
1648
|
parseProgram,
|
|
1624
1649
|
parseProgramWithDiagnostics,
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpipe-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.29",
|
|
4
4
|
"description": "Web Pipe parser",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "William Cotton",
|
|
7
|
-
"type": "module",
|
|
8
7
|
"main": "./dist/index.cjs",
|
|
9
8
|
"module": "./dist/index.mjs",
|
|
10
9
|
"types": "./dist/index.d.ts",
|