@snowtop/ent 0.1.0-alpha157 → 0.1.0-alpha159
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/graphql/graphql.d.ts +49 -2
- package/package.json +1 -1
- package/schema/schema.d.ts +1 -1
- package/scripts/custom_graphql.js +28 -24
package/graphql/graphql.d.ts
CHANGED
|
@@ -1,12 +1,58 @@
|
|
|
1
1
|
import { GraphQLScalarType } from "graphql";
|
|
2
|
-
import { FieldMap } from "
|
|
2
|
+
import type { FieldMap } from "../schema";
|
|
3
3
|
import { ProcessedField as ParsedProcessedField } from "../parse_schema/parse";
|
|
4
|
+
import { ImportPath } from "../schema/schema";
|
|
4
5
|
interface ClassType<T = any> {
|
|
5
6
|
new (...args: any[]): T;
|
|
6
7
|
}
|
|
7
8
|
declare type StringToStringMap = {
|
|
8
9
|
[key: string]: string;
|
|
9
10
|
};
|
|
11
|
+
interface CustomFieldInput {
|
|
12
|
+
graphQLName?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
functionName?: string;
|
|
15
|
+
args?: Field[];
|
|
16
|
+
results?: Field[];
|
|
17
|
+
fieldType: CustomFieldTypeInput;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
interface CustomTopLevelInput {
|
|
21
|
+
class?: string;
|
|
22
|
+
graphQLName?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
functionName?: string;
|
|
25
|
+
edgeName?: string;
|
|
26
|
+
args?: Field[];
|
|
27
|
+
results?: Field[];
|
|
28
|
+
extraImports?: ImportPath[];
|
|
29
|
+
functionContents?: string;
|
|
30
|
+
fieldType: CustomFieldTypeInput;
|
|
31
|
+
description?: string;
|
|
32
|
+
list?: boolean;
|
|
33
|
+
connection?: boolean;
|
|
34
|
+
resultType?: string;
|
|
35
|
+
}
|
|
36
|
+
type CustomFieldInputMap = {
|
|
37
|
+
[key: string]: CustomFieldInput[];
|
|
38
|
+
};
|
|
39
|
+
type CustomTypeInputMap = {
|
|
40
|
+
[key: string]: CustomTypeInput;
|
|
41
|
+
};
|
|
42
|
+
interface CustomObjectInput {
|
|
43
|
+
name: string;
|
|
44
|
+
graphQLName?: string;
|
|
45
|
+
fields?: CustomFieldInput[];
|
|
46
|
+
}
|
|
47
|
+
export interface CustomGraphQLInput {
|
|
48
|
+
fields?: CustomFieldInputMap;
|
|
49
|
+
inputs?: CustomObjectInput[];
|
|
50
|
+
objects?: CustomObjectInput[];
|
|
51
|
+
args?: CustomObjectInput[];
|
|
52
|
+
queries?: CustomTopLevelInput[];
|
|
53
|
+
mutations?: CustomTopLevelInput[];
|
|
54
|
+
customTypes?: CustomTypeInputMap;
|
|
55
|
+
}
|
|
10
56
|
export interface CustomTypeInput {
|
|
11
57
|
type: string;
|
|
12
58
|
importPath: string;
|
|
@@ -60,6 +106,7 @@ export declare enum CustomFieldType {
|
|
|
60
106
|
Function = "FUNCTION",
|
|
61
107
|
AsyncFunction = "ASYNC_FUNCTION"
|
|
62
108
|
}
|
|
109
|
+
export type CustomFieldTypeInput = "ACCESSOR" | "FIELD" | "FUNCTION" | "ASYNC_FUNCTION";
|
|
63
110
|
interface CustomFieldImpl {
|
|
64
111
|
nodeName: string;
|
|
65
112
|
gqlName: string;
|
|
@@ -71,7 +118,7 @@ interface CustomFieldImpl {
|
|
|
71
118
|
export interface CustomField extends CustomFieldImpl {
|
|
72
119
|
args: Field[];
|
|
73
120
|
results: Field[];
|
|
74
|
-
extraImports?:
|
|
121
|
+
extraImports?: ImportPath[];
|
|
75
122
|
functionContents?: string;
|
|
76
123
|
edgeName?: string;
|
|
77
124
|
}
|
package/package.json
CHANGED
package/schema/schema.d.ts
CHANGED
|
@@ -60,14 +60,7 @@ async function readInputs() {
|
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function processCustomObjects(l, gqlCapture,
|
|
64
|
-
let m;
|
|
65
|
-
if (input) {
|
|
66
|
-
m = gqlCapture.getCustomInputObjects();
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
m = gqlCapture.getCustomObjects();
|
|
70
|
-
}
|
|
63
|
+
function processCustomObjects(l, gqlCapture, m) {
|
|
71
64
|
for (const input of l) {
|
|
72
65
|
m.set(input.name, {
|
|
73
66
|
nodeName: input.graphQLName || input.name,
|
|
@@ -93,6 +86,18 @@ function transformArgs(f, gqlCapture) {
|
|
|
93
86
|
return ret;
|
|
94
87
|
});
|
|
95
88
|
}
|
|
89
|
+
function transformFieldTypeInput(input) {
|
|
90
|
+
switch (input) {
|
|
91
|
+
case "ACCESSOR":
|
|
92
|
+
return graphql_1.CustomFieldType.Accessor;
|
|
93
|
+
case "ASYNC_FUNCTION":
|
|
94
|
+
return graphql_1.CustomFieldType.AsyncFunction;
|
|
95
|
+
case "FUNCTION":
|
|
96
|
+
return graphql_1.CustomFieldType.Function;
|
|
97
|
+
case "FIELD":
|
|
98
|
+
return graphql_1.CustomFieldType.Field;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
96
101
|
function transformResultType(f) {
|
|
97
102
|
return f.resultType
|
|
98
103
|
? [
|
|
@@ -110,11 +115,11 @@ function transformResultType(f) {
|
|
|
110
115
|
function processTopLevel(l, l2, gqlCapture) {
|
|
111
116
|
for (const custom of l) {
|
|
112
117
|
l2.push({
|
|
113
|
-
nodeName: custom.class,
|
|
114
|
-
functionName: custom.functionName || custom.name,
|
|
115
|
-
gqlName: custom.graphQLName || custom.name,
|
|
118
|
+
nodeName: custom.class ?? "",
|
|
119
|
+
functionName: custom.functionName || custom.name || "",
|
|
120
|
+
gqlName: custom.graphQLName || custom.name || "",
|
|
116
121
|
edgeName: custom.edgeName,
|
|
117
|
-
fieldType: custom.fieldType,
|
|
122
|
+
fieldType: transformFieldTypeInput(custom.fieldType),
|
|
118
123
|
args: transformArgs(custom, gqlCapture),
|
|
119
124
|
results: transformResultType(custom),
|
|
120
125
|
description: custom.description,
|
|
@@ -134,9 +139,9 @@ function processCustomFields(fields, gqlCapture, nodeName) {
|
|
|
134
139
|
for (const f of fields) {
|
|
135
140
|
results.push({
|
|
136
141
|
nodeName: nodeName,
|
|
137
|
-
gqlName: f.graphQLName || f.name,
|
|
138
|
-
functionName: f.functionName || f.name,
|
|
139
|
-
fieldType: f.fieldType,
|
|
142
|
+
gqlName: f.graphQLName || f.name || "",
|
|
143
|
+
functionName: f.functionName || f.name || "",
|
|
144
|
+
fieldType: transformFieldTypeInput(f.fieldType),
|
|
140
145
|
args: transformArgs(f, gqlCapture),
|
|
141
146
|
results: transformResultType(f),
|
|
142
147
|
description: f.description,
|
|
@@ -194,10 +199,13 @@ async function processJSON(gqlCapture, json) {
|
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
if (json.inputs) {
|
|
197
|
-
processCustomObjects(json.inputs, gqlCapture,
|
|
202
|
+
processCustomObjects(json.inputs, gqlCapture, gqlCapture.getCustomInputObjects());
|
|
198
203
|
}
|
|
199
204
|
if (json.objects) {
|
|
200
|
-
processCustomObjects(json.objects, gqlCapture);
|
|
205
|
+
processCustomObjects(json.objects, gqlCapture, gqlCapture.getCustomObjects());
|
|
206
|
+
}
|
|
207
|
+
if (json.args) {
|
|
208
|
+
processCustomObjects(json.args, gqlCapture, gqlCapture.getCustomArgs());
|
|
201
209
|
}
|
|
202
210
|
if (json.queries) {
|
|
203
211
|
processTopLevel(json.queries, gqlCapture.getCustomQueries(), gqlCapture);
|
|
@@ -419,13 +427,9 @@ async function main() {
|
|
|
419
427
|
const buildClasses = (fields) => {
|
|
420
428
|
fields.forEach((field) => {
|
|
421
429
|
if (field.nodeName && !nodesMap.has(field.nodeName)) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
classes[field.nodeName] = { ...info.class, path: info.file.path };
|
|
426
|
-
buildFiles(info.file);
|
|
427
|
-
}
|
|
428
|
-
catch (err) { }
|
|
430
|
+
let info = imports.getInfoForClass(field.nodeName);
|
|
431
|
+
classes[field.nodeName] = { ...info.class, path: info.file.path };
|
|
432
|
+
buildFiles(info.file);
|
|
429
433
|
}
|
|
430
434
|
buildClasses2(field.args);
|
|
431
435
|
buildClasses2(field.results);
|