@cedarjs/cli 6.0.0-canary.2695 → 6.0.0-canary.2696
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.
|
@@ -46,15 +46,8 @@ const addFieldGraphQLComment = (field, str) => {
|
|
|
46
46
|
const modelFieldToSDL = ({
|
|
47
47
|
field,
|
|
48
48
|
required = true,
|
|
49
|
-
types = {},
|
|
50
49
|
docs = false
|
|
51
50
|
}) => {
|
|
52
|
-
if (Object.entries(types).length && field.kind === "object") {
|
|
53
|
-
const resolvedType = idType(types[field.type]);
|
|
54
|
-
if (typeof resolvedType === "string") {
|
|
55
|
-
field.type = resolvedType;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
51
|
const prismaTypeToGraphqlType = {
|
|
59
52
|
Json: "JSON",
|
|
60
53
|
Decimal: "Float",
|
|
@@ -73,7 +66,7 @@ const modelFieldToSDL = ({
|
|
|
73
66
|
const querySDL = (model, docs = false) => {
|
|
74
67
|
return model.fields.map((field) => modelFieldToSDL({ field, docs }));
|
|
75
68
|
};
|
|
76
|
-
const inputSDL = (model, required,
|
|
69
|
+
const inputSDL = (model, required, docs = false) => {
|
|
77
70
|
const ignoredFields = DEFAULT_IGNORE_FIELDS_FOR_INPUT;
|
|
78
71
|
return model.fields.filter((field) => {
|
|
79
72
|
const idField = model.fields.find((field2) => field2.isId);
|
|
@@ -81,21 +74,19 @@ const inputSDL = (model, required, types = {}, docs = false) => {
|
|
|
81
74
|
ignoredFields.push(idField.name);
|
|
82
75
|
}
|
|
83
76
|
return !ignoredFields.includes(field.name) && field.kind !== "object";
|
|
84
|
-
}).map((field) => modelFieldToSDL({ field, required,
|
|
77
|
+
}).map((field) => modelFieldToSDL({ field, required, docs }));
|
|
85
78
|
};
|
|
86
79
|
function idInputSDL(idType2, docs) {
|
|
87
80
|
if (!Array.isArray(idType2)) {
|
|
88
81
|
return [];
|
|
89
82
|
}
|
|
90
|
-
return idType2.map(
|
|
91
|
-
(field) => modelFieldToSDL({ field, required: true, types: {}, docs })
|
|
92
|
-
);
|
|
83
|
+
return idType2.map((field) => modelFieldToSDL({ field, required: true, docs }));
|
|
93
84
|
}
|
|
94
|
-
const createInputSDL = (model,
|
|
95
|
-
return inputSDL(model, true,
|
|
85
|
+
const createInputSDL = (model, docs = false) => {
|
|
86
|
+
return inputSDL(model, true, docs);
|
|
96
87
|
};
|
|
97
|
-
const updateInputSDL = (model,
|
|
98
|
-
return inputSDL(model, false,
|
|
88
|
+
const updateInputSDL = (model, docs = false) => {
|
|
89
|
+
return inputSDL(model, false, docs);
|
|
99
90
|
};
|
|
100
91
|
function idType(model, crud) {
|
|
101
92
|
if (!crud || !model) {
|
|
@@ -131,21 +122,6 @@ const sdlFromSchemaModel = async (name, crud, docs = false) => {
|
|
|
131
122
|
);
|
|
132
123
|
}
|
|
133
124
|
const model = schemaResult;
|
|
134
|
-
const resolvedTypes = await Promise.all(
|
|
135
|
-
model.fields.filter((field) => field.kind === "object").map(async (field) => {
|
|
136
|
-
const fieldModel = await getSchema(field.type);
|
|
137
|
-
return fieldModel && "fields" in fieldModel ? fieldModel : void 0;
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
const types = resolvedTypes.reduce(
|
|
141
|
-
(acc, cur) => {
|
|
142
|
-
if (!cur) {
|
|
143
|
-
return acc;
|
|
144
|
-
}
|
|
145
|
-
return { ...acc, [cur.name]: cur };
|
|
146
|
-
},
|
|
147
|
-
{}
|
|
148
|
-
);
|
|
149
125
|
const enums = (await Promise.all(
|
|
150
126
|
model.fields.filter((field) => field.kind === "enum").map(async (field) => {
|
|
151
127
|
const enumDef = await getEnum(field.type);
|
|
@@ -159,8 +135,8 @@ const sdlFromSchemaModel = async (name, crud, docs = false) => {
|
|
|
159
135
|
modelName,
|
|
160
136
|
modelDescription,
|
|
161
137
|
query: querySDL(model, docs).join("\n "),
|
|
162
|
-
createInput: createInputSDL(model,
|
|
163
|
-
updateInput: updateInputSDL(model,
|
|
138
|
+
createInput: createInputSDL(model, docs).join("\n "),
|
|
139
|
+
updateInput: updateInputSDL(model, docs).join("\n "),
|
|
164
140
|
idInput: idInputSDL(idTypeRes, docs).join("\n "),
|
|
165
141
|
idType: idType(model, crud),
|
|
166
142
|
idName: idName(model, crud),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2696",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.7",
|
|
35
35
|
"@babel/preset-typescript": "7.29.7",
|
|
36
|
-
"@cedarjs/api-server": "6.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "6.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "6.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "6.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "6.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "6.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "6.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "6.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "6.0.0-canary.2696",
|
|
37
|
+
"@cedarjs/cli-helpers": "6.0.0-canary.2696",
|
|
38
|
+
"@cedarjs/fastify-web": "6.0.0-canary.2696",
|
|
39
|
+
"@cedarjs/internal": "6.0.0-canary.2696",
|
|
40
|
+
"@cedarjs/prerender": "6.0.0-canary.2696",
|
|
41
|
+
"@cedarjs/project-config": "6.0.0-canary.2696",
|
|
42
|
+
"@cedarjs/structure": "6.0.0-canary.2696",
|
|
43
|
+
"@cedarjs/telemetry": "6.0.0-canary.2696",
|
|
44
|
+
"@cedarjs/utils": "6.0.0-canary.2696",
|
|
45
|
+
"@cedarjs/vite": "6.0.0-canary.2696",
|
|
46
|
+
"@cedarjs/web-server": "6.0.0-canary.2696",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.2",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|