webpipe-js 2.0.34 → 2.0.36

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;
@@ -516,18 +524,22 @@ var Parser = class {
516
524
  this.skipInlineSpaces();
517
525
  let config = "";
518
526
  let configType = "quoted";
527
+ let configStart = void 0;
528
+ let configEnd = void 0;
519
529
  if (this.cur() === ":") {
520
530
  this.pos++;
521
531
  this.skipInlineSpaces();
532
+ configStart = this.pos;
522
533
  const res = this.parseStepConfig();
523
534
  config = res.config;
524
535
  configType = res.configType;
536
+ configEnd = this.pos;
525
537
  }
526
538
  const condition = this.parseStepCondition();
527
539
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
528
540
  this.skipWhitespaceOnly();
529
541
  const end = this.pos;
530
- return { kind: "Regular", name, args, config, configType, condition, parsedJoinTargets, start, end };
542
+ return { kind: "Regular", name, args, config, configType, configStart, configEnd, condition, parsedJoinTargets, start, end };
531
543
  }
532
544
  /**
533
545
  * Parse optional step condition (tag expression after the config)
@@ -996,6 +1008,22 @@ var Parser = class {
996
1008
  this.skipWhitespaceOnly();
997
1009
  return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
998
1010
  }
1011
+ parseTypeResolver() {
1012
+ const start = this.pos;
1013
+ this.expect("resolver");
1014
+ this.skipInlineSpaces();
1015
+ const typeName = this.parseIdentifier();
1016
+ this.expect(".");
1017
+ const fieldName = this.parseIdentifier();
1018
+ this.skipInlineSpaces();
1019
+ this.expect("=");
1020
+ const inlineComment = this.parseInlineComment();
1021
+ this.skipWhitespaceOnly();
1022
+ const pipeline = this.parsePipeline();
1023
+ const end = this.pos;
1024
+ this.skipWhitespaceOnly();
1025
+ return { typeName, fieldName, pipeline, inlineComment: inlineComment || void 0, start, end };
1026
+ }
999
1027
  parseFeatureFlags() {
1000
1028
  this.expect("featureFlags");
1001
1029
  this.skipInlineSpaces();
@@ -1592,6 +1620,19 @@ function printMutationResolver(mutation) {
1592
1620
  });
1593
1621
  return lines.join("\n");
1594
1622
  }
1623
+ function printTypeResolver(resolver) {
1624
+ const lines = [];
1625
+ const resolverLine = `resolver ${resolver.typeName}.${resolver.fieldName} =`;
1626
+ if (resolver.inlineComment) {
1627
+ lines.push(`${resolverLine} ${printComment(resolver.inlineComment)}`);
1628
+ } else {
1629
+ lines.push(resolverLine);
1630
+ }
1631
+ resolver.pipeline.steps.forEach((step) => {
1632
+ lines.push(formatPipelineStep(step));
1633
+ });
1634
+ return lines.join("\n");
1635
+ }
1595
1636
  function printMock(mock, indent = " ") {
1596
1637
  return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
1597
1638
  }
@@ -1700,6 +1741,9 @@ function prettyPrint(program) {
1700
1741
  program.mutations.forEach((mutation) => {
1701
1742
  allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
1702
1743
  });
1744
+ program.resolvers.forEach((resolver) => {
1745
+ allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
1746
+ });
1703
1747
  program.routes.forEach((route) => {
1704
1748
  allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
1705
1749
  });
@@ -1737,6 +1781,10 @@ function prettyPrint(program) {
1737
1781
  lines.push(printMutationResolver(entry.item));
1738
1782
  lines.push("");
1739
1783
  break;
1784
+ case "resolver":
1785
+ lines.push(printTypeResolver(entry.item));
1786
+ lines.push("");
1787
+ break;
1740
1788
  case "route":
1741
1789
  lines.push(printRoute(entry.item));
1742
1790
  lines.push("");
@@ -1912,5 +1960,6 @@ function formatWhen(when) {
1912
1960
  printQueryResolver,
1913
1961
  printRoute,
1914
1962
  printTest,
1963
+ printTypeResolver,
1915
1964
  printVariable
1916
1965
  });
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;
@@ -146,6 +156,8 @@ type PipelineStep = {
146
156
  args: string[];
147
157
  config: string;
148
158
  configType: ConfigType;
159
+ configStart?: number;
160
+ configEnd?: number;
149
161
  condition?: TagExpr;
150
162
  parsedJoinTargets?: string[];
151
163
  start: number;
@@ -306,6 +318,7 @@ declare function printVariable(variable: Variable): string;
306
318
  declare function printGraphQLSchema(schema: GraphQLSchema): string;
307
319
  declare function printQueryResolver(query: QueryResolver): string;
308
320
  declare function printMutationResolver(mutation: MutationResolver): string;
321
+ declare function printTypeResolver(resolver: TypeResolver): string;
309
322
  declare function printMock(mock: Mock, indent?: string): string;
310
323
  declare function printCondition(condition: Condition, indent?: string): string;
311
324
  declare function printTest(test: It): string;
@@ -321,4 +334,4 @@ declare function formatTagExpr(expr: TagExpr): string;
321
334
  declare function formatPipelineRef(ref: PipelineRef): string[];
322
335
  declare function formatWhen(when: When): string;
323
336
 
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 };
337
+ 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;
@@ -146,6 +156,8 @@ type PipelineStep = {
146
156
  args: string[];
147
157
  config: string;
148
158
  configType: ConfigType;
159
+ configStart?: number;
160
+ configEnd?: number;
149
161
  condition?: TagExpr;
150
162
  parsedJoinTargets?: string[];
151
163
  start: number;
@@ -306,6 +318,7 @@ declare function printVariable(variable: Variable): string;
306
318
  declare function printGraphQLSchema(schema: GraphQLSchema): string;
307
319
  declare function printQueryResolver(query: QueryResolver): string;
308
320
  declare function printMutationResolver(mutation: MutationResolver): string;
321
+ declare function printTypeResolver(resolver: TypeResolver): string;
309
322
  declare function printMock(mock: Mock, indent?: string): string;
310
323
  declare function printCondition(condition: Condition, indent?: string): string;
311
324
  declare function printTest(test: It): string;
@@ -321,4 +334,4 @@ declare function formatTagExpr(expr: TagExpr): string;
321
334
  declare function formatPipelineRef(ref: PipelineRef): string[];
322
335
  declare function formatWhen(when: When): string;
323
336
 
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 };
337
+ 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;
@@ -464,18 +471,22 @@ var Parser = class {
464
471
  this.skipInlineSpaces();
465
472
  let config = "";
466
473
  let configType = "quoted";
474
+ let configStart = void 0;
475
+ let configEnd = void 0;
467
476
  if (this.cur() === ":") {
468
477
  this.pos++;
469
478
  this.skipInlineSpaces();
479
+ configStart = this.pos;
470
480
  const res = this.parseStepConfig();
471
481
  config = res.config;
472
482
  configType = res.configType;
483
+ configEnd = this.pos;
473
484
  }
474
485
  const condition = this.parseStepCondition();
475
486
  const parsedJoinTargets = name === "join" ? this.parseJoinTaskNames(config) : void 0;
476
487
  this.skipWhitespaceOnly();
477
488
  const end = this.pos;
478
- return { kind: "Regular", name, args, config, configType, condition, parsedJoinTargets, start, end };
489
+ return { kind: "Regular", name, args, config, configType, configStart, configEnd, condition, parsedJoinTargets, start, end };
479
490
  }
480
491
  /**
481
492
  * Parse optional step condition (tag expression after the config)
@@ -944,6 +955,22 @@ var Parser = class {
944
955
  this.skipWhitespaceOnly();
945
956
  return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
946
957
  }
958
+ parseTypeResolver() {
959
+ const start = this.pos;
960
+ this.expect("resolver");
961
+ this.skipInlineSpaces();
962
+ const typeName = this.parseIdentifier();
963
+ this.expect(".");
964
+ const fieldName = this.parseIdentifier();
965
+ this.skipInlineSpaces();
966
+ this.expect("=");
967
+ const inlineComment = this.parseInlineComment();
968
+ this.skipWhitespaceOnly();
969
+ const pipeline = this.parsePipeline();
970
+ const end = this.pos;
971
+ this.skipWhitespaceOnly();
972
+ return { typeName, fieldName, pipeline, inlineComment: inlineComment || void 0, start, end };
973
+ }
947
974
  parseFeatureFlags() {
948
975
  this.expect("featureFlags");
949
976
  this.skipInlineSpaces();
@@ -1540,6 +1567,19 @@ function printMutationResolver(mutation) {
1540
1567
  });
1541
1568
  return lines.join("\n");
1542
1569
  }
1570
+ function printTypeResolver(resolver) {
1571
+ const lines = [];
1572
+ const resolverLine = `resolver ${resolver.typeName}.${resolver.fieldName} =`;
1573
+ if (resolver.inlineComment) {
1574
+ lines.push(`${resolverLine} ${printComment(resolver.inlineComment)}`);
1575
+ } else {
1576
+ lines.push(resolverLine);
1577
+ }
1578
+ resolver.pipeline.steps.forEach((step) => {
1579
+ lines.push(formatPipelineStep(step));
1580
+ });
1581
+ return lines.join("\n");
1582
+ }
1543
1583
  function printMock(mock, indent = " ") {
1544
1584
  return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
1545
1585
  }
@@ -1648,6 +1688,9 @@ function prettyPrint(program) {
1648
1688
  program.mutations.forEach((mutation) => {
1649
1689
  allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
1650
1690
  });
1691
+ program.resolvers.forEach((resolver) => {
1692
+ allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
1693
+ });
1651
1694
  program.routes.forEach((route) => {
1652
1695
  allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
1653
1696
  });
@@ -1685,6 +1728,10 @@ function prettyPrint(program) {
1685
1728
  lines.push(printMutationResolver(entry.item));
1686
1729
  lines.push("");
1687
1730
  break;
1731
+ case "resolver":
1732
+ lines.push(printTypeResolver(entry.item));
1733
+ lines.push("");
1734
+ break;
1688
1735
  case "route":
1689
1736
  lines.push(printRoute(entry.item));
1690
1737
  lines.push("");
@@ -1859,5 +1906,6 @@ export {
1859
1906
  printQueryResolver,
1860
1907
  printRoute,
1861
1908
  printTest,
1909
+ printTypeResolver,
1862
1910
  printVariable
1863
1911
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",