webpipe-js 2.0.26 → 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 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) return bt;
1063
+ if (bt !== null) {
1064
+ format = "backtick";
1065
+ return bt;
1066
+ }
1063
1067
  const qt = this.tryParse(() => this.parseQuotedString());
1064
- if (qt !== null) return qt;
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) return num;
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();
@@ -1377,13 +1390,8 @@ function printTest(test) {
1377
1390
  });
1378
1391
  lines.push(` when ${formatWhen(test.when)}`);
1379
1392
  if (test.variables) {
1380
- test.variables.forEach(([name, value]) => {
1381
- const formattedValue = (() => {
1382
- if (value.startsWith("`") || value.startsWith('"')) return value;
1383
- if (value === "true" || value === "false" || /^\d+$/.test(value)) return value;
1384
- if (value.includes("{") || value.includes("[") || value.includes("\n")) return `\`${value}\``;
1385
- return `"${value}"`;
1386
- })();
1393
+ test.variables.forEach(([name, value, format]) => {
1394
+ const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
1387
1395
  lines.push(` let ${name} = ${formattedValue}`);
1388
1396
  });
1389
1397
  }
@@ -1421,6 +1429,13 @@ function printDescribe(describe) {
1421
1429
  } else {
1422
1430
  lines.push(describeLine);
1423
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
+ }
1424
1439
  describe.mocks.forEach((mock) => {
1425
1440
  lines.push(printMock(mock));
1426
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,7 +150,7 @@ type ResultBranchType = {
149
150
  };
150
151
  interface Describe {
151
152
  name: string;
152
- variables: Array<[string, string]>;
153
+ variables: Array<[string, string, LetValueFormat]>;
153
154
  mocks: Mock[];
154
155
  tests: It[];
155
156
  lineNumber?: number;
@@ -163,7 +164,7 @@ interface It {
163
164
  name: string;
164
165
  mocks: Mock[];
165
166
  when: When;
166
- variables?: Array<[string, string]>;
167
+ variables?: Array<[string, string, LetValueFormat]>;
167
168
  input?: string;
168
169
  body?: string;
169
170
  headers?: string;
@@ -246,4 +247,4 @@ declare function formatTagExpr(expr: TagExpr): string;
246
247
  declare function formatPipelineRef(ref: PipelineRef): string[];
247
248
  declare function formatWhen(when: When): string;
248
249
 
249
- 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,7 +150,7 @@ type ResultBranchType = {
149
150
  };
150
151
  interface Describe {
151
152
  name: string;
152
- variables: Array<[string, string]>;
153
+ variables: Array<[string, string, LetValueFormat]>;
153
154
  mocks: Mock[];
154
155
  tests: It[];
155
156
  lineNumber?: number;
@@ -163,7 +164,7 @@ interface It {
163
164
  name: string;
164
165
  mocks: Mock[];
165
166
  when: When;
166
- variables?: Array<[string, string]>;
167
+ variables?: Array<[string, string, LetValueFormat]>;
167
168
  input?: string;
168
169
  body?: string;
169
170
  headers?: string;
@@ -246,4 +247,4 @@ declare function formatTagExpr(expr: TagExpr): string;
246
247
  declare function formatPipelineRef(ref: PipelineRef): string[];
247
248
  declare function formatWhen(when: When): string;
248
249
 
249
- 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) return bt;
1013
+ if (bt !== null) {
1014
+ format = "backtick";
1015
+ return bt;
1016
+ }
1013
1017
  const qt = this.tryParse(() => this.parseQuotedString());
1014
- if (qt !== null) return qt;
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) return num;
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();
@@ -1327,13 +1340,8 @@ function printTest(test) {
1327
1340
  });
1328
1341
  lines.push(` when ${formatWhen(test.when)}`);
1329
1342
  if (test.variables) {
1330
- test.variables.forEach(([name, value]) => {
1331
- const formattedValue = (() => {
1332
- if (value.startsWith("`") || value.startsWith('"')) return value;
1333
- if (value === "true" || value === "false" || /^\d+$/.test(value)) return value;
1334
- if (value.includes("{") || value.includes("[") || value.includes("\n")) return `\`${value}\``;
1335
- return `"${value}"`;
1336
- })();
1343
+ test.variables.forEach(([name, value, format]) => {
1344
+ const formattedValue = format === "quoted" ? `"${value}"` : format === "backtick" ? `\`${value}\`` : value;
1337
1345
  lines.push(` let ${name} = ${formattedValue}`);
1338
1346
  });
1339
1347
  }
@@ -1371,6 +1379,13 @@ function printDescribe(describe) {
1371
1379
  } else {
1372
1380
  lines.push(describeLine);
1373
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
+ }
1374
1389
  describe.mocks.forEach((mock) => {
1375
1390
  lines.push(printMock(mock));
1376
1391
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",