@gql.tada/cli-utils 1.2.0 → 1.2.1-canary-e42804ea2a1e64b58239cd45b152b047b9afcd17
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/CHANGELOG.md +11 -0
- package/dist/chunks/index-chunk.js +1050 -558
- package/dist/chunks/index-chunk.js.map +1 -1
- package/dist/chunks/index-chunk.mjs +919 -425
- package/dist/chunks/index-chunk.mjs.map +1 -1
- package/dist/chunks/svelte-chunk.js +53 -51
- package/dist/chunks/svelte-chunk.js.map +1 -1
- package/dist/chunks/svelte-chunk.mjs +58 -56
- package/dist/chunks/svelte-chunk.mjs.map +1 -1
- package/dist/chunks/thread-chunk.js +97 -130
- package/dist/chunks/thread-chunk.js.map +1 -1
- package/dist/chunks/thread-chunk.mjs +94 -106
- package/dist/chunks/thread-chunk.mjs.map +1 -1
- package/dist/chunks/thread-chunk2.js +46 -82
- package/dist/chunks/thread-chunk2.js.map +1 -1
- package/dist/chunks/thread-chunk2.mjs +44 -59
- package/dist/chunks/thread-chunk2.mjs.map +1 -1
- package/dist/chunks/thread-chunk3.js +45 -50
- package/dist/chunks/thread-chunk3.js.map +1 -1
- package/dist/chunks/thread-chunk3.mjs +45 -50
- package/dist/chunks/thread-chunk3.mjs.map +1 -1
- package/dist/chunks/vue-chunk.js +18 -15
- package/dist/chunks/vue-chunk.js.map +1 -1
- package/dist/chunks/vue-chunk.mjs +18 -15
- package/dist/chunks/vue-chunk.mjs.map +1 -1
- package/dist/gql-tada-cli.js +58 -49
- package/dist/gql-tada-cli.js.map +1 -1
- package/dist/gql-tada-cli.mjs +656 -647
- package/dist/gql-tada-cli.mjs.map +1 -1
- package/package.json +2 -3
- package/dist/chunks/project-chunk.js +0 -63
- package/dist/chunks/project-chunk.js.map +0 -1
- package/dist/chunks/project-chunk.mjs +0 -65
- package/dist/chunks/project-chunk.mjs.map +0 -1
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from "typescript";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { findAllPersistedCallExpressions as i, getDocumentReferenceFromDocumentNode as n, getDocumentReferenceFromTypeQuery as t, unrollTadaFragments as a } from "@0no-co/graphqlsp/api";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { e as r, p as l } from "./index-chunk.mjs";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { c as m } from "./project-chunk.mjs";
|
|
10
|
-
|
|
11
|
-
var v = function(e) {
|
|
7
|
+
var s = function(e) {
|
|
12
8
|
e[e.Const = 1] = "Const";
|
|
13
9
|
e[e.Var = 2] = "Var";
|
|
14
10
|
e[e.Int = 3] = "Int";
|
|
@@ -17,28 +13,28 @@ var v = function(e) {
|
|
|
17
13
|
e[e.String = 6] = "String";
|
|
18
14
|
e[e.Enum = 7] = "Enum";
|
|
19
15
|
return e;
|
|
20
|
-
}(
|
|
16
|
+
}(s || {});
|
|
21
17
|
|
|
22
|
-
var
|
|
18
|
+
var o = function(e) {
|
|
23
19
|
e[e.Spread = 1] = "Spread";
|
|
24
20
|
e[e.Name = 2] = "Name";
|
|
25
21
|
return e;
|
|
26
|
-
}(
|
|
22
|
+
}(o || {});
|
|
27
23
|
|
|
28
24
|
function mapJoin(e, i, n) {
|
|
29
25
|
var t = "";
|
|
30
|
-
for (var
|
|
31
|
-
if (
|
|
26
|
+
for (var a = 0; a < e.length; a++) {
|
|
27
|
+
if (a) {
|
|
32
28
|
t += i;
|
|
33
29
|
}
|
|
34
|
-
t += n(e[
|
|
30
|
+
t += n(e[a]);
|
|
35
31
|
}
|
|
36
32
|
return t;
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
var
|
|
35
|
+
var u = "\n";
|
|
40
36
|
|
|
41
|
-
var
|
|
37
|
+
var c = {
|
|
42
38
|
OperationDefinition(e) {
|
|
43
39
|
var i = e.operation;
|
|
44
40
|
if (e.name) {
|
|
@@ -48,38 +44,38 @@ var p = {
|
|
|
48
44
|
if (!e.name) {
|
|
49
45
|
i += " ";
|
|
50
46
|
}
|
|
51
|
-
i += "(" + mapJoin(e.variableDefinitions, ", ",
|
|
47
|
+
i += "(" + mapJoin(e.variableDefinitions, ", ", c.VariableDefinition) + ")";
|
|
52
48
|
}
|
|
53
49
|
if (e.directives && e.directives.length) {
|
|
54
|
-
i += " " + mapJoin(e.directives, " ",
|
|
50
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
55
51
|
}
|
|
56
|
-
return "query" !== i ? i + " " +
|
|
52
|
+
return "query" !== i ? i + " " + c.SelectionSet(e.selectionSet) : c.SelectionSet(e.selectionSet);
|
|
57
53
|
},
|
|
58
54
|
VariableDefinition(e) {
|
|
59
|
-
var i =
|
|
55
|
+
var i = c.Variable(e.variable) + ": " + _print(e.type);
|
|
60
56
|
if (e.defaultValue) {
|
|
61
57
|
i += " = " + _print(e.defaultValue);
|
|
62
58
|
}
|
|
63
59
|
if (e.directives && e.directives.length) {
|
|
64
|
-
i += " " + mapJoin(e.directives, " ",
|
|
60
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
65
61
|
}
|
|
66
62
|
return i;
|
|
67
63
|
},
|
|
68
64
|
Field(e) {
|
|
69
65
|
var i = e.alias ? e.alias.value + ": " + e.name.value : e.name.value;
|
|
70
66
|
if (e.arguments && e.arguments.length) {
|
|
71
|
-
var n = mapJoin(e.arguments, ", ",
|
|
67
|
+
var n = mapJoin(e.arguments, ", ", c.Argument);
|
|
72
68
|
if (i.length + n.length + 2 > 80) {
|
|
73
|
-
i += "(" + (
|
|
69
|
+
i += "(" + (u += " ") + mapJoin(e.arguments, u, c.Argument) + (u = u.slice(0, -2)) + ")";
|
|
74
70
|
} else {
|
|
75
71
|
i += "(" + n + ")";
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
74
|
if (e.directives && e.directives.length) {
|
|
79
|
-
i += " " + mapJoin(e.directives, " ",
|
|
75
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
80
76
|
}
|
|
81
77
|
if (e.selectionSet) {
|
|
82
|
-
i += " " +
|
|
78
|
+
i += " " + c.SelectionSet(e.selectionSet);
|
|
83
79
|
}
|
|
84
80
|
return i;
|
|
85
81
|
},
|
|
@@ -87,7 +83,7 @@ var p = {
|
|
|
87
83
|
if (e.block) {
|
|
88
84
|
return function printBlockString(e) {
|
|
89
85
|
return '"""\n' + e.replace(/"""/g, '\\"""') + '\n"""';
|
|
90
|
-
}(e.value).replace(/\n/g,
|
|
86
|
+
}(e.value).replace(/\n/g, u);
|
|
91
87
|
} else {
|
|
92
88
|
return function printString(e) {
|
|
93
89
|
return JSON.stringify(e);
|
|
@@ -102,7 +98,7 @@ var p = {
|
|
|
102
98
|
Name: e => e.value,
|
|
103
99
|
Variable: e => "$" + e.name.value,
|
|
104
100
|
ListValue: e => "[" + mapJoin(e.values, ", ", _print) + "]",
|
|
105
|
-
ObjectValue: e => "{" + mapJoin(e.fields, ", ",
|
|
101
|
+
ObjectValue: e => "{" + mapJoin(e.fields, ", ", c.ObjectField) + "}",
|
|
106
102
|
ObjectField: e => e.name.value + ": " + _print(e.value),
|
|
107
103
|
Document(e) {
|
|
108
104
|
if (!e.definitions || !e.definitions.length) {
|
|
@@ -110,12 +106,12 @@ var p = {
|
|
|
110
106
|
}
|
|
111
107
|
return mapJoin(e.definitions, "\n\n", _print);
|
|
112
108
|
},
|
|
113
|
-
SelectionSet: e => "{" + (
|
|
109
|
+
SelectionSet: e => "{" + (u += " ") + mapJoin(e.selections, u, _print) + (u = u.slice(0, -2)) + "}",
|
|
114
110
|
Argument: e => e.name.value + ": " + _print(e.value),
|
|
115
111
|
FragmentSpread(e) {
|
|
116
112
|
var i = "..." + e.name.value;
|
|
117
113
|
if (e.directives && e.directives.length) {
|
|
118
|
-
i += " " + mapJoin(e.directives, " ",
|
|
114
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
119
115
|
}
|
|
120
116
|
return i;
|
|
121
117
|
},
|
|
@@ -125,22 +121,22 @@ var p = {
|
|
|
125
121
|
i += " on " + e.typeCondition.name.value;
|
|
126
122
|
}
|
|
127
123
|
if (e.directives && e.directives.length) {
|
|
128
|
-
i += " " + mapJoin(e.directives, " ",
|
|
124
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
129
125
|
}
|
|
130
|
-
return i + " " +
|
|
126
|
+
return i + " " + c.SelectionSet(e.selectionSet);
|
|
131
127
|
},
|
|
132
128
|
FragmentDefinition(e) {
|
|
133
129
|
var i = "fragment " + e.name.value;
|
|
134
130
|
i += " on " + e.typeCondition.name.value;
|
|
135
131
|
if (e.directives && e.directives.length) {
|
|
136
|
-
i += " " + mapJoin(e.directives, " ",
|
|
132
|
+
i += " " + mapJoin(e.directives, " ", c.Directive);
|
|
137
133
|
}
|
|
138
|
-
return i + " " +
|
|
134
|
+
return i + " " + c.SelectionSet(e.selectionSet);
|
|
139
135
|
},
|
|
140
136
|
Directive(e) {
|
|
141
137
|
var i = "@" + e.name.value;
|
|
142
138
|
if (e.arguments && e.arguments.length) {
|
|
143
|
-
i += "(" + mapJoin(e.arguments, ", ",
|
|
139
|
+
i += "(" + mapJoin(e.arguments, ", ", c.Argument) + ")";
|
|
144
140
|
}
|
|
145
141
|
return i;
|
|
146
142
|
},
|
|
@@ -149,110 +145,102 @@ var p = {
|
|
|
149
145
|
NonNullType: e => _print(e.type) + "!"
|
|
150
146
|
};
|
|
151
147
|
|
|
152
|
-
var _print = e =>
|
|
148
|
+
var _print = e => c[e.kind](e);
|
|
153
149
|
|
|
154
150
|
function print(e) {
|
|
155
|
-
|
|
156
|
-
return
|
|
151
|
+
u = "\n";
|
|
152
|
+
return c[e.kind] ? c[e.kind](e) : "";
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var v = e.dirname(o.configPath);
|
|
164
|
-
var f = new n({
|
|
165
|
-
tsConfigFilePath: o.configPath
|
|
166
|
-
});
|
|
167
|
-
var g = await u(v, f, i);
|
|
168
|
-
if (g) {
|
|
155
|
+
var m = r((async function* _runPersisted(r) {
|
|
156
|
+
var s = l(r);
|
|
157
|
+
var o = s.createExternalFiles();
|
|
158
|
+
if (o.length) {
|
|
169
159
|
yield {
|
|
170
160
|
kind: "EXTERNAL_WARNING"
|
|
171
161
|
};
|
|
162
|
+
await s.addVirtualFiles(o);
|
|
172
163
|
}
|
|
173
|
-
var
|
|
174
|
-
var
|
|
175
|
-
var n = e.resolve(v, i.getFilePath());
|
|
176
|
-
return !e.relative(o.rootPath, n).startsWith("..");
|
|
177
|
-
}));
|
|
164
|
+
var u = s.build();
|
|
165
|
+
var c = u.getSourceFiles();
|
|
178
166
|
yield {
|
|
179
167
|
kind: "FILE_COUNT",
|
|
180
|
-
fileCount:
|
|
168
|
+
fileCount: c.length
|
|
181
169
|
};
|
|
182
|
-
for (var
|
|
183
|
-
var
|
|
184
|
-
var
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
for (var
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
var
|
|
191
|
-
var
|
|
192
|
-
var
|
|
193
|
-
if (!
|
|
194
|
-
|
|
170
|
+
for (var m of c) {
|
|
171
|
+
var f = m.fileName;
|
|
172
|
+
var v = {};
|
|
173
|
+
var g = [];
|
|
174
|
+
var d = i(m);
|
|
175
|
+
for (var p of d) {
|
|
176
|
+
var S = u.getSourcePosition(m, p.getStart());
|
|
177
|
+
f = S.fileName;
|
|
178
|
+
var h = p.arguments[0];
|
|
179
|
+
var y = p.arguments[1];
|
|
180
|
+
var N = p.typeArguments && p.typeArguments[0];
|
|
181
|
+
if (!h || !e.isStringLiteral(h)) {
|
|
182
|
+
g.push({
|
|
195
183
|
message: '"graphql.persisted" must be called with a string literal as the first argument.',
|
|
196
|
-
file:
|
|
197
|
-
line:
|
|
198
|
-
col:
|
|
184
|
+
file: S.fileName,
|
|
185
|
+
line: S.line,
|
|
186
|
+
col: S.col
|
|
199
187
|
});
|
|
200
188
|
continue;
|
|
201
|
-
} else if (!
|
|
202
|
-
|
|
189
|
+
} else if (!y && !N) {
|
|
190
|
+
g.push({
|
|
203
191
|
message: '"graphql.persisted" is missing a document.\nThis may be passed as a generic such as `graphql.persisted<typeof document>` or as the second argument.',
|
|
204
|
-
file:
|
|
205
|
-
line:
|
|
206
|
-
col:
|
|
192
|
+
file: S.fileName,
|
|
193
|
+
line: S.line,
|
|
194
|
+
col: S.col
|
|
207
195
|
});
|
|
208
196
|
continue;
|
|
209
197
|
}
|
|
210
|
-
var
|
|
211
|
-
var
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
} else if (
|
|
216
|
-
|
|
217
|
-
|
|
198
|
+
var b = null;
|
|
199
|
+
var V = p;
|
|
200
|
+
if (y && (e.isCallExpression(y) || e.isIdentifier(y))) {
|
|
201
|
+
b = n(y, m.fileName, u.buildPluginInfo(r.pluginConfig)).node;
|
|
202
|
+
V = y;
|
|
203
|
+
} else if (N && e.isTypeQueryNode(N)) {
|
|
204
|
+
b = t(N, m.fileName, u.buildPluginInfo(r.pluginConfig)).node;
|
|
205
|
+
V = N;
|
|
218
206
|
}
|
|
219
|
-
if (!
|
|
220
|
-
|
|
221
|
-
message: `Could not find reference for "${
|
|
222
|
-
file:
|
|
223
|
-
line:
|
|
224
|
-
col:
|
|
207
|
+
if (!b) {
|
|
208
|
+
g.push({
|
|
209
|
+
message: `Could not find reference for "${V.getText()}".\nIf this is unexpected, please file an issue describing your case.`,
|
|
210
|
+
file: S.fileName,
|
|
211
|
+
line: S.line,
|
|
212
|
+
col: S.col
|
|
225
213
|
});
|
|
226
214
|
continue;
|
|
227
215
|
}
|
|
228
|
-
if (!
|
|
229
|
-
|
|
230
|
-
message: `The referenced document of "${
|
|
231
|
-
file:
|
|
232
|
-
line:
|
|
233
|
-
col:
|
|
216
|
+
if (!b || !e.isCallExpression(b) || !e.isNoSubstitutionTemplateLiteral(b.arguments[0]) && !e.isStringLiteral(b.arguments[0])) {
|
|
217
|
+
g.push({
|
|
218
|
+
message: `The referenced document of "${V.getText()}" contains no document string literal.\nIf this is unexpected, please file an issue describing your case.`,
|
|
219
|
+
file: S.fileName,
|
|
220
|
+
line: S.line,
|
|
221
|
+
col: S.col
|
|
234
222
|
});
|
|
235
223
|
continue;
|
|
236
224
|
}
|
|
237
|
-
var
|
|
238
|
-
var
|
|
239
|
-
if (
|
|
240
|
-
|
|
225
|
+
var D = [];
|
|
226
|
+
var J = b.arguments[0].getText().slice(1, -1);
|
|
227
|
+
if (b.arguments[1] && e.isArrayLiteralExpression(b.arguments[1])) {
|
|
228
|
+
a(b.arguments[1], D, u.buildPluginInfo(r.pluginConfig));
|
|
241
229
|
}
|
|
242
|
-
var
|
|
243
|
-
for (var
|
|
244
|
-
|
|
230
|
+
var F = J;
|
|
231
|
+
for (var I of D) {
|
|
232
|
+
F += "\n\n" + print(I);
|
|
245
233
|
}
|
|
246
|
-
|
|
234
|
+
v[h.getText().slice(1, -1)] = F;
|
|
247
235
|
}
|
|
248
236
|
yield {
|
|
249
237
|
kind: "FILE_PERSISTED",
|
|
250
|
-
filePath:
|
|
251
|
-
documents:
|
|
252
|
-
warnings:
|
|
238
|
+
filePath: f,
|
|
239
|
+
documents: v,
|
|
240
|
+
warnings: g
|
|
253
241
|
};
|
|
254
242
|
}
|
|
255
243
|
}));
|
|
256
244
|
|
|
257
|
-
export {
|
|
245
|
+
export { m as runPersisted };
|
|
258
246
|
//# sourceMappingURL=thread-chunk.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-chunk.mjs","sources":["../../src/commands/generate-persisted/thread.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"thread-chunk.mjs","sources":["../../src/commands/generate-persisted/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport { print } from '@0no-co/graphql.web';\n\nimport type { FragmentDefinitionNode } from '@0no-co/graphql.web';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport {\n findAllPersistedCallExpressions,\n getDocumentReferenceFromTypeQuery,\n getDocumentReferenceFromDocumentNode,\n unrollTadaFragments,\n} from '@0no-co/graphqlsp/api';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { PersistedSignal, PersistedWarning } from './types';\n\nexport interface PersistedParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runPersisted(params: PersistedParams): AsyncIterableIterator<PersistedSignal> {\n const factory = programFactory(params);\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const documents: Record<string, string> = {};\n const warnings: PersistedWarning[] = [];\n\n const calls = findAllPersistedCallExpressions(sourceFile);\n for (const call of calls) {\n const position = container.getSourcePosition(sourceFile, call.getStart());\n filePath = position.fileName;\n\n const hashArg = call.arguments[0];\n const docArg = call.arguments[1];\n const typeQuery = call.typeArguments && call.typeArguments[0];\n if (!hashArg || !ts.isStringLiteral(hashArg)) {\n warnings.push({\n message:\n '\"graphql.persisted\" must be called with a string literal as the first argument.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n } else if (!docArg && !typeQuery) {\n warnings.push({\n message:\n '\"graphql.persisted\" is missing a document.\\n' +\n 'This may be passed as a generic such as `graphql.persisted<typeof document>` or as the second argument.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n let foundNode: ts.CallExpression | null = null;\n let referencingNode: ts.Node = call;\n if (docArg && (ts.isCallExpression(docArg) || ts.isIdentifier(docArg))) {\n const result = getDocumentReferenceFromDocumentNode(\n docArg,\n sourceFile.fileName,\n container.buildPluginInfo(params.pluginConfig)\n );\n foundNode = result.node;\n referencingNode = docArg;\n } else if (typeQuery && ts.isTypeQueryNode(typeQuery)) {\n const result = getDocumentReferenceFromTypeQuery(\n typeQuery,\n sourceFile.fileName,\n container.buildPluginInfo(params.pluginConfig)\n );\n foundNode = result.node;\n referencingNode = typeQuery;\n }\n\n if (!foundNode) {\n warnings.push({\n message:\n `Could not find reference for \"${referencingNode.getText()}\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n if (\n !foundNode ||\n !ts.isCallExpression(foundNode) ||\n (!ts.isNoSubstitutionTemplateLiteral(foundNode.arguments[0]) &&\n !ts.isStringLiteral(foundNode.arguments[0]))\n ) {\n warnings.push({\n message:\n `The referenced document of \"${referencingNode.getText()}\" contains no document string literal.\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const fragments: FragmentDefinitionNode[] = [];\n const operation = foundNode.arguments[0].getText().slice(1, -1);\n if (foundNode.arguments[1] && ts.isArrayLiteralExpression(foundNode.arguments[1])) {\n unrollTadaFragments(\n foundNode.arguments[1],\n fragments,\n container.buildPluginInfo(params.pluginConfig)\n );\n }\n\n let document = operation;\n for (const fragment of fragments) document += '\\n\\n' + print(fragment);\n documents[hashArg.getText().slice(1, -1)] = document;\n }\n\n yield {\n kind: 'FILE_PERSISTED',\n filePath,\n documents,\n warnings,\n };\n }\n}\n\nexport const runPersisted = expose(_runPersisted);\n"],"names":["runPersisted","expose","async","_runPersisted","params","factory","programFactory","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","sourceFiles","getSourceFiles","fileCount","sourceFile","filePath","fileName","documents","warnings","calls","findAllPersistedCallExpressions","call","position","getSourcePosition","getStart","hashArg","arguments","docArg","typeQuery","typeArguments","ts","isStringLiteral","push","message","file","line","col","foundNode","referencingNode","isCallExpression","isIdentifier","getDocumentReferenceFromDocumentNode","buildPluginInfo","pluginConfig","node","isTypeQueryNode","getDocumentReferenceFromTypeQuery","getText","isNoSubstitutionTemplateLiteral","fragments","operation","slice","isArrayLiteralExpression","unrollTadaFragments","document","fragment","print"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoJaA,IAAeC,GA5H5BC,gBAAgBC,cAAcC;EAC5B,IAAMC,IAAUC,EAAeF;EAE/B,IAAMG,IAAgBF,EAAQG;EAC9B,IAAID,EAAcE,QAAQ;UAClB;MAAEC,MAAM;;UACRL,EAAQM,gBAAgBJ;AAChC;EAEA,IAAMK,IAAYP,EAAQQ;EAC1B,IAAMC,IAAcF,EAAUG;QAExB;IACJL,MAAM;IACNM,WAAWF,EAAYL;;EAGzB,KAAK,IAAMQ,KAAcH,GAAa;IACpC,IAAII,IAAWD,EAAWE;IAC1B,IAAMC,IAAoC,CAAA;IAC1C,IAAMC,IAA+B;IAErC,IAAMC,IAAQC,EAAgCN;IAC9C,KAAK,IAAMO,KAAQF,GAAO;MACxB,IAAMG,IAAWb,EAAUc,kBAAkBT,GAAYO,EAAKG;MAC9DT,IAAWO,EAASN;MAEpB,IAAMS,IAAUJ,EAAKK,UAAU;MAC/B,IAAMC,IAASN,EAAKK,UAAU;MAC9B,IAAME,IAAYP,EAAKQ,iBAAiBR,EAAKQ,cAAc;MAC3D,KAAKJ,MAAYK,EAAGC,gBAAgBN,IAAU;QAC5CP,EAASc,KAAK;UACZC,SACE;UACFC,MAAMZ,EAASN;UACfmB,MAAMb,EAASa;UACfC,KAAKd,EAASc;;QAEhB;AACF,aAAO,KAAKT,MAAWC,GAAW;QAChCV,EAASc,KAAK;UACZC,SACE;UAEFC,MAAMZ,EAASN;UACfmB,MAAMb,EAASa;UACfC,KAAKd,EAASc;;QAEhB;AACF;MAEA,IAAIC,IAAsC;MAC1C,IAAIC,IAA2BjB;MAC/B,IAAIM,MAAWG,EAAGS,iBAAiBZ,MAAWG,EAAGU,aAAab,KAAU;QAMtEU,IALeI,EACbd,GACAb,EAAWE,UACXP,EAAUiC,gBAAgBzC,EAAO0C,eAEhBC;QACnBN,IAAkBX;AACnB,aAAM,IAAIC,KAAaE,EAAGe,gBAAgBjB,IAAY;QAMrDS,IALeS,EACblB,GACAd,EAAWE,UACXP,EAAUiC,gBAAgBzC,EAAO0C,eAEhBC;QACnBN,IAAkBV;AACpB;MAEA,KAAKS,GAAW;QACdnB,EAASc,KAAK;UACZC,SACG,iCAAgCK,EAAgBS;UAEnDb,MAAMZ,EAASN;UACfmB,MAAMb,EAASa;UACfC,KAAKd,EAASc;;QAEhB;AACF;MAEA,KACGC,MACAP,EAAGS,iBAAiBF,OACnBP,EAAGkB,gCAAgCX,EAAUX,UAAU,QACtDI,EAAGC,gBAAgBM,EAAUX,UAAU,KAC1C;QACAR,EAASc,KAAK;UACZC,SACG,+BAA8BK,EAAgBS;UAEjDb,MAAMZ,EAASN;UACfmB,MAAMb,EAASa;UACfC,KAAKd,EAASc;;QAEhB;AACF;MAEA,IAAMa,IAAsC;MAC5C,IAAMC,IAAYb,EAAUX,UAAU,GAAGqB,UAAUI,MAAM,IAAI;MAC7D,IAAId,EAAUX,UAAU,MAAMI,EAAGsB,yBAAyBf,EAAUX,UAAU;QAC5E2B,EACEhB,EAAUX,UAAU,IACpBuB,GACAxC,EAAUiC,gBAAgBzC,EAAO0C;;MAIrC,IAAIW,IAAWJ;MACf,KAAK,IAAMK,KAAYN;QAAWK,KAAY,SAASE,MAAMD;;MAC7DtC,EAAUQ,EAAQsB,UAAUI,MAAM,IAAI,MAAMG;AAC9C;UAEM;MACJ/C,MAAM;MACNQ;MACAE;MACAC;;AAEJ;AACF;;"}
|
|
@@ -1,111 +1,75 @@
|
|
|
1
|
-
var e = require("
|
|
1
|
+
var e = require("typescript");
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var a = require("./index-chunk.js");
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach((function(a) {
|
|
13
|
-
if ("default" !== a) {
|
|
14
|
-
var t = Object.getOwnPropertyDescriptor(e, a);
|
|
15
|
-
Object.defineProperty(r, a, t.get ? t : {
|
|
16
|
-
enumerable: !0,
|
|
17
|
-
get: function() {
|
|
18
|
-
return e[a];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
r.default = e;
|
|
25
|
-
return r;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var i = _interopNamespaceDefault(e);
|
|
29
|
-
|
|
30
|
-
var n = t.expose((async function* _runTurbo(e) {
|
|
31
|
-
a.init({
|
|
32
|
-
typescript: r.ts
|
|
33
|
-
});
|
|
34
|
-
var n = i.dirname(e.configPath);
|
|
35
|
-
var s = new r.Project({
|
|
36
|
-
tsConfigFilePath: e.configPath,
|
|
37
|
-
skipAddingFilesFromTsConfig: !0
|
|
5
|
+
var r = a.expose((async function* _runTurbo(r) {
|
|
6
|
+
var n = a.programFactory(r);
|
|
7
|
+
n.addSourceFile({
|
|
8
|
+
fileId: "__gql-tada-override__.d.ts",
|
|
9
|
+
sourceText: t,
|
|
10
|
+
scriptKind: e.ScriptKind.TS
|
|
38
11
|
});
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
scriptKind: r.ScriptKind.TS
|
|
42
|
-
});
|
|
43
|
-
if (c._markAsInProject) {
|
|
44
|
-
c._markAsInProject();
|
|
45
|
-
}
|
|
46
|
-
s.addSourceFilesFromTsConfig(e.configPath);
|
|
47
|
-
var p = await t.loadVirtualCode(n, s, r.ts);
|
|
48
|
-
if (p) {
|
|
12
|
+
var l = n.createExternalFiles();
|
|
13
|
+
if (l.length) {
|
|
49
14
|
yield {
|
|
50
15
|
kind: "EXTERNAL_WARNING"
|
|
51
16
|
};
|
|
17
|
+
await n.addVirtualFiles(l);
|
|
52
18
|
}
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
return !i.relative(e.rootPath, a).startsWith("..");
|
|
56
|
-
}));
|
|
19
|
+
var o = n.build();
|
|
20
|
+
var s = o.getSourceFiles();
|
|
57
21
|
yield {
|
|
58
22
|
kind: "FILE_COUNT",
|
|
59
|
-
fileCount:
|
|
23
|
+
fileCount: s.length
|
|
60
24
|
};
|
|
61
|
-
var d =
|
|
62
|
-
for (var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
for (var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
if (!
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
25
|
+
var d = o.program.getTypeChecker();
|
|
26
|
+
for (var p of s) {
|
|
27
|
+
var u = p.fileName;
|
|
28
|
+
var g = {};
|
|
29
|
+
var c = [];
|
|
30
|
+
var f = findAllCallExpressions(p, r.pluginConfig);
|
|
31
|
+
for (var y of f) {
|
|
32
|
+
var T = d.getTypeAtLocation(y);
|
|
33
|
+
var m = d.getTypeAtLocation(y.arguments[0]);
|
|
34
|
+
if (!T.symbol || "TadaDocumentNode" !== T.symbol.getEscapedName()) {
|
|
35
|
+
var v = o.getSourcePosition(p, y.getStart());
|
|
36
|
+
u = v.fileName;
|
|
37
|
+
c.push({
|
|
74
38
|
message: 'The discovered document is not of type "TadaDocumentNode".\nIf this is unexpected, please file an issue describing your case.',
|
|
75
|
-
file:
|
|
76
|
-
line:
|
|
77
|
-
col:
|
|
39
|
+
file: v.fileName,
|
|
40
|
+
line: v.line,
|
|
41
|
+
col: v.col
|
|
78
42
|
});
|
|
79
43
|
continue;
|
|
80
44
|
}
|
|
81
|
-
|
|
45
|
+
g["value" in m && "string" == typeof m.value && 0 == (m.flags & e.TypeFlags.StringLiteral) ? JSON.stringify(m.value) : d.typeToString(m, y, i)] = d.typeToString(T, y, i);
|
|
82
46
|
}
|
|
83
47
|
yield {
|
|
84
48
|
kind: "FILE_TURBO",
|
|
85
|
-
filePath:
|
|
86
|
-
cache:
|
|
87
|
-
warnings:
|
|
49
|
+
filePath: u,
|
|
50
|
+
cache: g,
|
|
51
|
+
warnings: c
|
|
88
52
|
};
|
|
89
53
|
}
|
|
90
54
|
}));
|
|
91
55
|
|
|
92
|
-
var
|
|
56
|
+
var i = e.TypeFormatFlags.NoTruncation | e.TypeFormatFlags.NoTypeReduction | e.TypeFormatFlags.InTypeAlias | e.TypeFormatFlags.UseFullyQualifiedType | e.TypeFormatFlags.GenerateNamesForShadowedTypeParams | e.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | e.TypeFormatFlags.AllowUniqueESSymbolType | e.TypeFormatFlags.WriteTypeArgumentsOfSignature;
|
|
93
57
|
|
|
94
|
-
var
|
|
58
|
+
var t = "\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n".trim();
|
|
95
59
|
|
|
96
|
-
function findAllCallExpressions(
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
!function find(
|
|
100
|
-
if (
|
|
101
|
-
|
|
60
|
+
function findAllCallExpressions(a, r) {
|
|
61
|
+
var i = [];
|
|
62
|
+
var t = new Set([ r.template, "graphql", "gql" ].filter(Boolean));
|
|
63
|
+
!function find(a) {
|
|
64
|
+
if (e.isCallExpression(a) && t.has(a.expression.getText())) {
|
|
65
|
+
i.push(a);
|
|
102
66
|
return;
|
|
103
67
|
} else {
|
|
104
|
-
|
|
68
|
+
e.forEachChild(a, find);
|
|
105
69
|
}
|
|
106
|
-
}(
|
|
107
|
-
return
|
|
70
|
+
}(a);
|
|
71
|
+
return i;
|
|
108
72
|
}
|
|
109
73
|
|
|
110
|
-
exports.runTurbo =
|
|
74
|
+
exports.runTurbo = r;
|
|
111
75
|
//# sourceMappingURL=thread-chunk2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-chunk2.js","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"thread-chunk2.js","sources":["../../src/commands/turbo/thread.ts"],"sourcesContent":["import ts from 'typescript';\nimport type { GraphQLSPConfig } from '@gql.tada/internal';\n\nimport { programFactory } from '../../ts';\nimport { expose } from '../../threads';\n\nimport type { TurboSignal, TurboWarning } from './types';\n\nexport interface TurboParams {\n rootPath: string;\n configPath: string;\n pluginConfig: GraphQLSPConfig;\n}\n\nasync function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSignal> {\n const factory = programFactory(params);\n\n // NOTE: We add our override declaration here before loading all files\n // This sets `__cacheDisabled` on the turbo cache, which disables the cache temporarily\n // If we don't disable the cache then we couldn't regenerate it from inferred types\n factory.addSourceFile({\n fileId: '__gql-tada-override__.d.ts',\n sourceText: DECLARATION_OVERRIDE,\n scriptKind: ts.ScriptKind.TS,\n });\n\n const externalFiles = factory.createExternalFiles();\n if (externalFiles.length) {\n yield { kind: 'EXTERNAL_WARNING' };\n await factory.addVirtualFiles(externalFiles);\n }\n\n const container = factory.build();\n const sourceFiles = container.getSourceFiles();\n\n yield {\n kind: 'FILE_COUNT',\n fileCount: sourceFiles.length,\n };\n\n const checker = container.program.getTypeChecker();\n for (const sourceFile of sourceFiles) {\n let filePath = sourceFile.fileName;\n const cache: Record<string, string> = {};\n const warnings: TurboWarning[] = [];\n\n const calls = findAllCallExpressions(sourceFile, params.pluginConfig);\n for (const call of calls) {\n const returnType = checker.getTypeAtLocation(call);\n const argumentType = checker.getTypeAtLocation(call.arguments[0]);\n // NOTE: `returnType.symbol` is incorrectly typed and is in fact\n // optional and not always present\n if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {\n const position = container.getSourcePosition(sourceFile, call.getStart());\n filePath = position.fileName;\n warnings.push({\n message:\n `The discovered document is not of type \"TadaDocumentNode\".\\n` +\n 'If this is unexpected, please file an issue describing your case.',\n file: position.fileName,\n line: position.line,\n col: position.col,\n });\n continue;\n }\n\n const key: string =\n 'value' in argumentType &&\n typeof argumentType.value === 'string' &&\n (argumentType.flags & ts.TypeFlags.StringLiteral) === 0\n ? JSON.stringify(argumentType.value)\n : checker.typeToString(argumentType, call, BUILDER_FLAGS);\n cache[key] = checker.typeToString(returnType, call, BUILDER_FLAGS);\n }\n\n yield {\n kind: 'FILE_TURBO',\n filePath,\n cache,\n warnings,\n };\n }\n}\n\nexport const runTurbo = expose(_runTurbo);\n\nconst BUILDER_FLAGS: ts.TypeFormatFlags =\n ts.TypeFormatFlags.NoTruncation |\n ts.TypeFormatFlags.NoTypeReduction |\n ts.TypeFormatFlags.InTypeAlias |\n ts.TypeFormatFlags.UseFullyQualifiedType |\n ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams |\n ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope |\n ts.TypeFormatFlags.AllowUniqueESSymbolType |\n ts.TypeFormatFlags.WriteTypeArgumentsOfSignature;\n\nconst DECLARATION_OVERRIDE = `\nimport * as _gqlTada from 'gql.tada';\ndeclare module 'gql.tada' {\n interface setupCache {\n readonly __cacheDisabled: true;\n }\n}\n`.trim();\n\nfunction findAllCallExpressions(\n sourceFile: ts.SourceFile,\n config: GraphQLSPConfig\n): Array<ts.CallExpression> {\n const result: ts.CallExpression[] = [];\n const templates = new Set([config.template, 'graphql', 'gql'].filter(Boolean));\n function find(node: ts.Node) {\n if (ts.isCallExpression(node) && templates.has(node.expression.getText())) {\n result.push(node);\n return;\n } else {\n ts.forEachChild(node, find);\n }\n }\n find(sourceFile);\n return result;\n}\n"],"names":["runTurbo","expose","async","_runTurbo","params","factory","programFactory","addSourceFile","fileId","sourceText","DECLARATION_OVERRIDE","scriptKind","ts","ScriptKind","TS","externalFiles","createExternalFiles","length","kind","addVirtualFiles","container","build","sourceFiles","getSourceFiles","fileCount","checker","program","getTypeChecker","sourceFile","filePath","fileName","cache","warnings","calls","findAllCallExpressions","pluginConfig","call","returnType","getTypeAtLocation","argumentType","arguments","symbol","getEscapedName","position","getSourcePosition","getStart","push","message","file","line","col","value","flags","TypeFlags","StringLiteral","JSON","stringify","typeToString","BUILDER_FLAGS","TypeFormatFlags","NoTruncation","NoTypeReduction","InTypeAlias","UseFullyQualifiedType","GenerateNamesForShadowedTypeParams","UseAliasDefinedOutsideCurrentScope","AllowUniqueESSymbolType","WriteTypeArgumentsOfSignature","trim","config","result","templates","Set","template","filter","Boolean","find","node","isCallExpression","has","expression","getText","forEachChild"],"mappings":";;;;IAoFaA,IAAWC,EAAMA,QAtE9BC,gBAAgBC,UAAUC;EACxB,IAAMC,IAAUC,iBAAeF;EAK/BC,EAAQE,cAAc;IACpBC,QAAQ;IACRC,YAAYC;IACZC,YAAYC,EAAGC,WAAWC;;EAG5B,IAAMC,IAAgBV,EAAQW;EAC9B,IAAID,EAAcE,QAAQ;UAClB;MAAEC,MAAM;;UACRb,EAAQc,gBAAgBJ;AAChC;EAEA,IAAMK,IAAYf,EAAQgB;EAC1B,IAAMC,IAAcF,EAAUG;QAExB;IACJL,MAAM;IACNM,WAAWF,EAAYL;;EAGzB,IAAMQ,IAAUL,EAAUM,QAAQC;EAClC,KAAK,IAAMC,KAAcN,GAAa;IACpC,IAAIO,IAAWD,EAAWE;IAC1B,IAAMC,IAAgC,CAAA;IACtC,IAAMC,IAA2B;IAEjC,IAAMC,IAAQC,uBAAuBN,GAAYxB,EAAO+B;IACxD,KAAK,IAAMC,KAAQH,GAAO;MACxB,IAAMI,IAAaZ,EAAQa,kBAAkBF;MAC7C,IAAMG,IAAed,EAAQa,kBAAkBF,EAAKI,UAAU;MAG9D,KAAKH,EAAWI,UAAiD,uBAAvCJ,EAAWI,OAAOC,kBAAyC;QACnF,IAAMC,IAAWvB,EAAUwB,kBAAkBhB,GAAYQ,EAAKS;QAC9DhB,IAAWc,EAASb;QACpBE,EAASc,KAAK;UACZC,SACG;UAEHC,MAAML,EAASb;UACfmB,MAAMN,EAASM;UACfC,KAAKP,EAASO;;QAEhB;AACF;MAQAnB,EALE,WAAWQ,KACmB,mBAAvBA,EAAaY,SACkC,MAArDZ,EAAaa,QAAQxC,EAAGyC,UAAUC,iBAC/BC,KAAKC,UAAUjB,EAAaY,SAC5B1B,EAAQgC,aAAalB,GAAcH,GAAMsB,MAClCjC,EAAQgC,aAAapB,GAAYD,GAAMsB;AACtD;UAEM;MACJxC,MAAM;MACNW;MACAE;MACAC;;AAEJ;AACF;;AAIA,IAAM0B,IACJ9C,EAAG+C,gBAAgBC,eACnBhD,EAAG+C,gBAAgBE,kBACnBjD,EAAG+C,gBAAgBG,cACnBlD,EAAG+C,gBAAgBI,wBACnBnD,EAAG+C,gBAAgBK,qCACnBpD,EAAG+C,gBAAgBM,qCACnBrD,EAAG+C,gBAAgBO,0BACnBtD,EAAG+C,gBAAgBQ;;AAErB,IAAMzD,IAAwB,gJAO5B0D;;AAEF,SAASlC,uBACPN,GACAyC;EAEA,IAAMC,IAA8B;EACpC,IAAMC,IAAY,IAAIC,IAAI,EAACH,EAAOI,UAAU,WAAW,QAAOC,OAAOC;GACrE,SAASC,KAAKC;IACZ,IAAIjE,EAAGkE,iBAAiBD,MAASN,EAAUQ,IAAIF,EAAKG,WAAWC,YAAY;MACzEX,EAAOxB,KAAK+B;MACZ;AACF;MACEjE,EAAGsE,aAAaL,GAAMD;;AAE1B,GACAA,CAAKhD;EACL,OAAO0C;AACT;;"}
|