webpipe-js 2.0.33 → 2.0.35

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
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  printQueryResolver: () => printQueryResolver,
47
47
  printRoute: () => printRoute,
48
48
  printTest: () => printTest,
49
+ printTypeResolver: () => printTypeResolver,
49
50
  printVariable: () => printVariable
50
51
  });
51
52
  module.exports = __toCommonJS(index_exports);
@@ -152,6 +153,7 @@ var Parser = class {
152
153
  let graphqlSchema;
153
154
  const queries = [];
154
155
  const mutations = [];
156
+ const resolvers = [];
155
157
  let featureFlags;
156
158
  while (!this.eof()) {
157
159
  this.skipWhitespaceOnly();
@@ -187,6 +189,12 @@ var Parser = class {
187
189
  mutations.push(mutation);
188
190
  continue;
189
191
  }
192
+ const resolver = this.tryParse(() => this.parseTypeResolver());
193
+ if (resolver) {
194
+ resolver.lineNumber = this.getLineNumber(start);
195
+ resolvers.push(resolver);
196
+ continue;
197
+ }
190
198
  const flags = this.tryParse(() => this.parseFeatureFlags());
191
199
  if (flags) {
192
200
  featureFlags = flags;
@@ -231,7 +239,7 @@ var Parser = class {
231
239
  const start = Math.max(0, idx);
232
240
  this.report("Unclosed backtick-delimited string", start, start + 1, "warning");
233
241
  }
234
- return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations, featureFlags };
242
+ return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations, resolvers, featureFlags };
235
243
  }
236
244
  eof() {
237
245
  return this.pos >= this.len;
@@ -514,9 +522,15 @@ var Parser = class {
514
522
  const name = this.parseIdentifier();
515
523
  const args = this.parseInlineArgs();
516
524
  this.skipInlineSpaces();
517
- this.expect(":");
518
- this.skipInlineSpaces();
519
- const { config, configType } = this.parseStepConfig();
525
+ let config = "";
526
+ let configType = "quoted";
527
+ if (this.cur() === ":") {
528
+ this.pos++;
529
+ this.skipInlineSpaces();
530
+ const res = this.parseStepConfig();
531
+ config = res.config;
532
+ configType = res.configType;
533
+ }
520
534
  const condition = this.parseStepCondition();
521
535
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
522
536
  this.skipWhitespaceOnly();
@@ -990,6 +1004,22 @@ var Parser = class {
990
1004
  this.skipWhitespaceOnly();
991
1005
  return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
992
1006
  }
1007
+ parseTypeResolver() {
1008
+ const start = this.pos;
1009
+ this.expect("resolver");
1010
+ this.skipInlineSpaces();
1011
+ const typeName = this.parseIdentifier();
1012
+ this.expect(".");
1013
+ const fieldName = this.parseIdentifier();
1014
+ this.skipInlineSpaces();
1015
+ this.expect("=");
1016
+ const inlineComment = this.parseInlineComment();
1017
+ this.skipWhitespaceOnly();
1018
+ const pipeline = this.parsePipeline();
1019
+ const end = this.pos;
1020
+ this.skipWhitespaceOnly();
1021
+ return { typeName, fieldName, pipeline, inlineComment: inlineComment || void 0, start, end };
1022
+ }
993
1023
  parseFeatureFlags() {
994
1024
  this.expect("featureFlags");
995
1025
  this.skipInlineSpaces();
@@ -1586,6 +1616,19 @@ function printMutationResolver(mutation) {
1586
1616
  });
1587
1617
  return lines.join("\n");
1588
1618
  }
1619
+ function printTypeResolver(resolver) {
1620
+ const lines = [];
1621
+ const resolverLine = `resolver ${resolver.typeName}.${resolver.fieldName} =`;
1622
+ if (resolver.inlineComment) {
1623
+ lines.push(`${resolverLine} ${printComment(resolver.inlineComment)}`);
1624
+ } else {
1625
+ lines.push(resolverLine);
1626
+ }
1627
+ resolver.pipeline.steps.forEach((step) => {
1628
+ lines.push(formatPipelineStep(step));
1629
+ });
1630
+ return lines.join("\n");
1631
+ }
1589
1632
  function printMock(mock, indent = " ") {
1590
1633
  return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
1591
1634
  }
@@ -1694,6 +1737,9 @@ function prettyPrint(program) {
1694
1737
  program.mutations.forEach((mutation) => {
1695
1738
  allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
1696
1739
  });
1740
+ program.resolvers.forEach((resolver) => {
1741
+ allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
1742
+ });
1697
1743
  program.routes.forEach((route) => {
1698
1744
  allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
1699
1745
  });
@@ -1731,6 +1777,10 @@ function prettyPrint(program) {
1731
1777
  lines.push(printMutationResolver(entry.item));
1732
1778
  lines.push("");
1733
1779
  break;
1780
+ case "resolver":
1781
+ lines.push(printTypeResolver(entry.item));
1782
+ lines.push("");
1783
+ break;
1734
1784
  case "route":
1735
1785
  lines.push(printRoute(entry.item));
1736
1786
  lines.push("");
@@ -1906,5 +1956,6 @@ function formatWhen(when) {
1906
1956
  printQueryResolver,
1907
1957
  printRoute,
1908
1958
  printTest,
1959
+ printTypeResolver,
1909
1960
  printVariable
1910
1961
  });
package/dist/index.d.cts CHANGED
@@ -8,6 +8,7 @@ interface Program {
8
8
  graphqlSchema?: GraphQLSchema;
9
9
  queries: QueryResolver[];
10
10
  mutations: MutationResolver[];
11
+ resolvers: TypeResolver[];
11
12
  featureFlags?: Pipeline;
12
13
  }
13
14
  interface Comment {
@@ -84,6 +85,15 @@ interface MutationResolver {
84
85
  start: number;
85
86
  end: number;
86
87
  }
88
+ interface TypeResolver {
89
+ typeName: string;
90
+ fieldName: string;
91
+ pipeline: Pipeline;
92
+ lineNumber?: number;
93
+ inlineComment?: Comment;
94
+ start: number;
95
+ end: number;
96
+ }
87
97
  interface Route {
88
98
  method: string;
89
99
  path: string;
@@ -306,6 +316,7 @@ declare function printVariable(variable: Variable): string;
306
316
  declare function printGraphQLSchema(schema: GraphQLSchema): string;
307
317
  declare function printQueryResolver(query: QueryResolver): string;
308
318
  declare function printMutationResolver(mutation: MutationResolver): string;
319
+ declare function printTypeResolver(resolver: TypeResolver): string;
309
320
  declare function printMock(mock: Mock, indent?: string): string;
310
321
  declare function printCondition(condition: Condition, indent?: string): string;
311
322
  declare function printTest(test: It): string;
@@ -321,4 +332,4 @@ declare function formatTagExpr(expr: TagExpr): string;
321
332
  declare function formatPipelineRef(ref: PipelineRef): string[];
322
333
  declare function formatWhen(when: When): string;
323
334
 
324
- 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 LetVariable, 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 };
335
+ 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 LetVariable, 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 TypeResolver, 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, printTypeResolver, printVariable };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ interface Program {
8
8
  graphqlSchema?: GraphQLSchema;
9
9
  queries: QueryResolver[];
10
10
  mutations: MutationResolver[];
11
+ resolvers: TypeResolver[];
11
12
  featureFlags?: Pipeline;
12
13
  }
13
14
  interface Comment {
@@ -84,6 +85,15 @@ interface MutationResolver {
84
85
  start: number;
85
86
  end: number;
86
87
  }
88
+ interface TypeResolver {
89
+ typeName: string;
90
+ fieldName: string;
91
+ pipeline: Pipeline;
92
+ lineNumber?: number;
93
+ inlineComment?: Comment;
94
+ start: number;
95
+ end: number;
96
+ }
87
97
  interface Route {
88
98
  method: string;
89
99
  path: string;
@@ -306,6 +316,7 @@ declare function printVariable(variable: Variable): string;
306
316
  declare function printGraphQLSchema(schema: GraphQLSchema): string;
307
317
  declare function printQueryResolver(query: QueryResolver): string;
308
318
  declare function printMutationResolver(mutation: MutationResolver): string;
319
+ declare function printTypeResolver(resolver: TypeResolver): string;
309
320
  declare function printMock(mock: Mock, indent?: string): string;
310
321
  declare function printCondition(condition: Condition, indent?: string): string;
311
322
  declare function printTest(test: It): string;
@@ -321,4 +332,4 @@ declare function formatTagExpr(expr: TagExpr): string;
321
332
  declare function formatPipelineRef(ref: PipelineRef): string[];
322
333
  declare function formatWhen(when: When): string;
323
334
 
324
- 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 LetVariable, 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 };
335
+ 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 LetVariable, 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 TypeResolver, 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, printTypeResolver, printVariable };
package/dist/index.mjs CHANGED
@@ -100,6 +100,7 @@ var Parser = class {
100
100
  let graphqlSchema;
101
101
  const queries = [];
102
102
  const mutations = [];
103
+ const resolvers = [];
103
104
  let featureFlags;
104
105
  while (!this.eof()) {
105
106
  this.skipWhitespaceOnly();
@@ -135,6 +136,12 @@ var Parser = class {
135
136
  mutations.push(mutation);
136
137
  continue;
137
138
  }
139
+ const resolver = this.tryParse(() => this.parseTypeResolver());
140
+ if (resolver) {
141
+ resolver.lineNumber = this.getLineNumber(start);
142
+ resolvers.push(resolver);
143
+ continue;
144
+ }
138
145
  const flags = this.tryParse(() => this.parseFeatureFlags());
139
146
  if (flags) {
140
147
  featureFlags = flags;
@@ -179,7 +186,7 @@ var Parser = class {
179
186
  const start = Math.max(0, idx);
180
187
  this.report("Unclosed backtick-delimited string", start, start + 1, "warning");
181
188
  }
182
- return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations, featureFlags };
189
+ return { configs, pipelines, variables, routes, describes, comments, graphqlSchema, queries, mutations, resolvers, featureFlags };
183
190
  }
184
191
  eof() {
185
192
  return this.pos >= this.len;
@@ -462,9 +469,15 @@ var Parser = class {
462
469
  const name = this.parseIdentifier();
463
470
  const args = this.parseInlineArgs();
464
471
  this.skipInlineSpaces();
465
- this.expect(":");
466
- this.skipInlineSpaces();
467
- const { config, configType } = this.parseStepConfig();
472
+ let config = "";
473
+ let configType = "quoted";
474
+ if (this.cur() === ":") {
475
+ this.pos++;
476
+ this.skipInlineSpaces();
477
+ const res = this.parseStepConfig();
478
+ config = res.config;
479
+ configType = res.configType;
480
+ }
468
481
  const condition = this.parseStepCondition();
469
482
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
470
483
  this.skipWhitespaceOnly();
@@ -938,6 +951,22 @@ var Parser = class {
938
951
  this.skipWhitespaceOnly();
939
952
  return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
940
953
  }
954
+ parseTypeResolver() {
955
+ const start = this.pos;
956
+ this.expect("resolver");
957
+ this.skipInlineSpaces();
958
+ const typeName = this.parseIdentifier();
959
+ this.expect(".");
960
+ const fieldName = this.parseIdentifier();
961
+ this.skipInlineSpaces();
962
+ this.expect("=");
963
+ const inlineComment = this.parseInlineComment();
964
+ this.skipWhitespaceOnly();
965
+ const pipeline = this.parsePipeline();
966
+ const end = this.pos;
967
+ this.skipWhitespaceOnly();
968
+ return { typeName, fieldName, pipeline, inlineComment: inlineComment || void 0, start, end };
969
+ }
941
970
  parseFeatureFlags() {
942
971
  this.expect("featureFlags");
943
972
  this.skipInlineSpaces();
@@ -1534,6 +1563,19 @@ function printMutationResolver(mutation) {
1534
1563
  });
1535
1564
  return lines.join("\n");
1536
1565
  }
1566
+ function printTypeResolver(resolver) {
1567
+ const lines = [];
1568
+ const resolverLine = `resolver ${resolver.typeName}.${resolver.fieldName} =`;
1569
+ if (resolver.inlineComment) {
1570
+ lines.push(`${resolverLine} ${printComment(resolver.inlineComment)}`);
1571
+ } else {
1572
+ lines.push(resolverLine);
1573
+ }
1574
+ resolver.pipeline.steps.forEach((step) => {
1575
+ lines.push(formatPipelineStep(step));
1576
+ });
1577
+ return lines.join("\n");
1578
+ }
1537
1579
  function printMock(mock, indent = " ") {
1538
1580
  return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
1539
1581
  }
@@ -1642,6 +1684,9 @@ function prettyPrint(program) {
1642
1684
  program.mutations.forEach((mutation) => {
1643
1685
  allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
1644
1686
  });
1687
+ program.resolvers.forEach((resolver) => {
1688
+ allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
1689
+ });
1645
1690
  program.routes.forEach((route) => {
1646
1691
  allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
1647
1692
  });
@@ -1679,6 +1724,10 @@ function prettyPrint(program) {
1679
1724
  lines.push(printMutationResolver(entry.item));
1680
1725
  lines.push("");
1681
1726
  break;
1727
+ case "resolver":
1728
+ lines.push(printTypeResolver(entry.item));
1729
+ lines.push("");
1730
+ break;
1682
1731
  case "route":
1683
1732
  lines.push(printRoute(entry.item));
1684
1733
  lines.push("");
@@ -1853,5 +1902,6 @@ export {
1853
1902
  printQueryResolver,
1854
1903
  printRoute,
1855
1904
  printTest,
1905
+ printTypeResolver,
1856
1906
  printVariable
1857
1907
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.33",
3
+ "version": "2.0.35",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",