webpipe-js 2.0.34 → 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 +46 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.mjs +45 -1
- package/package.json +1 -1
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;
|
|
@@ -996,6 +1004,22 @@ var Parser = class {
|
|
|
996
1004
|
this.skipWhitespaceOnly();
|
|
997
1005
|
return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
998
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
|
+
}
|
|
999
1023
|
parseFeatureFlags() {
|
|
1000
1024
|
this.expect("featureFlags");
|
|
1001
1025
|
this.skipInlineSpaces();
|
|
@@ -1592,6 +1616,19 @@ function printMutationResolver(mutation) {
|
|
|
1592
1616
|
});
|
|
1593
1617
|
return lines.join("\n");
|
|
1594
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
|
+
}
|
|
1595
1632
|
function printMock(mock, indent = " ") {
|
|
1596
1633
|
return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
|
|
1597
1634
|
}
|
|
@@ -1700,6 +1737,9 @@ function prettyPrint(program) {
|
|
|
1700
1737
|
program.mutations.forEach((mutation) => {
|
|
1701
1738
|
allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
|
|
1702
1739
|
});
|
|
1740
|
+
program.resolvers.forEach((resolver) => {
|
|
1741
|
+
allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
|
|
1742
|
+
});
|
|
1703
1743
|
program.routes.forEach((route) => {
|
|
1704
1744
|
allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
|
|
1705
1745
|
});
|
|
@@ -1737,6 +1777,10 @@ function prettyPrint(program) {
|
|
|
1737
1777
|
lines.push(printMutationResolver(entry.item));
|
|
1738
1778
|
lines.push("");
|
|
1739
1779
|
break;
|
|
1780
|
+
case "resolver":
|
|
1781
|
+
lines.push(printTypeResolver(entry.item));
|
|
1782
|
+
lines.push("");
|
|
1783
|
+
break;
|
|
1740
1784
|
case "route":
|
|
1741
1785
|
lines.push(printRoute(entry.item));
|
|
1742
1786
|
lines.push("");
|
|
@@ -1912,5 +1956,6 @@ function formatWhen(when) {
|
|
|
1912
1956
|
printQueryResolver,
|
|
1913
1957
|
printRoute,
|
|
1914
1958
|
printTest,
|
|
1959
|
+
printTypeResolver,
|
|
1915
1960
|
printVariable
|
|
1916
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;
|
|
@@ -944,6 +951,22 @@ var Parser = class {
|
|
|
944
951
|
this.skipWhitespaceOnly();
|
|
945
952
|
return { name, pipeline, inlineComment: inlineComment || void 0, start, end };
|
|
946
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
|
+
}
|
|
947
970
|
parseFeatureFlags() {
|
|
948
971
|
this.expect("featureFlags");
|
|
949
972
|
this.skipInlineSpaces();
|
|
@@ -1540,6 +1563,19 @@ function printMutationResolver(mutation) {
|
|
|
1540
1563
|
});
|
|
1541
1564
|
return lines.join("\n");
|
|
1542
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
|
+
}
|
|
1543
1579
|
function printMock(mock, indent = " ") {
|
|
1544
1580
|
return `${indent}with mock ${mock.target} returning \`${mock.returnValue}\``;
|
|
1545
1581
|
}
|
|
@@ -1648,6 +1684,9 @@ function prettyPrint(program) {
|
|
|
1648
1684
|
program.mutations.forEach((mutation) => {
|
|
1649
1685
|
allItems.push({ type: "mutation", item: mutation, lineNumber: mutation.lineNumber || 0 });
|
|
1650
1686
|
});
|
|
1687
|
+
program.resolvers.forEach((resolver) => {
|
|
1688
|
+
allItems.push({ type: "resolver", item: resolver, lineNumber: resolver.lineNumber || 0 });
|
|
1689
|
+
});
|
|
1651
1690
|
program.routes.forEach((route) => {
|
|
1652
1691
|
allItems.push({ type: "route", item: route, lineNumber: route.lineNumber || 0 });
|
|
1653
1692
|
});
|
|
@@ -1685,6 +1724,10 @@ function prettyPrint(program) {
|
|
|
1685
1724
|
lines.push(printMutationResolver(entry.item));
|
|
1686
1725
|
lines.push("");
|
|
1687
1726
|
break;
|
|
1727
|
+
case "resolver":
|
|
1728
|
+
lines.push(printTypeResolver(entry.item));
|
|
1729
|
+
lines.push("");
|
|
1730
|
+
break;
|
|
1688
1731
|
case "route":
|
|
1689
1732
|
lines.push(printRoute(entry.item));
|
|
1690
1733
|
lines.push("");
|
|
@@ -1859,5 +1902,6 @@ export {
|
|
|
1859
1902
|
printQueryResolver,
|
|
1860
1903
|
printRoute,
|
|
1861
1904
|
printTest,
|
|
1905
|
+
printTypeResolver,
|
|
1862
1906
|
printVariable
|
|
1863
1907
|
};
|