@cedarjs/cli 5.0.0-canary.2581 → 5.0.0-canary.2582
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/commands/generate/sdl/sdlHandler.js +22 -10
- package/package.json +13 -12
|
@@ -83,21 +83,21 @@ const inputSDL = (model, required, types = {}, docs = false) => {
|
|
|
83
83
|
return !ignoredFields.includes(field.name) && field.kind !== "object";
|
|
84
84
|
}).map((field) => modelFieldToSDL({ field, required, types, docs }));
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
function idInputSDL(idType2, docs) {
|
|
87
87
|
if (!Array.isArray(idType2)) {
|
|
88
88
|
return [];
|
|
89
89
|
}
|
|
90
90
|
return idType2.map(
|
|
91
91
|
(field) => modelFieldToSDL({ field, required: true, types: {}, docs })
|
|
92
92
|
);
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
const createInputSDL = (model, types = {}, docs = false) => {
|
|
95
95
|
return inputSDL(model, true, types, docs);
|
|
96
96
|
};
|
|
97
97
|
const updateInputSDL = (model, types = {}, docs = false) => {
|
|
98
98
|
return inputSDL(model, false, types, docs);
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
function idType(model, crud) {
|
|
101
101
|
if (!crud || !model) {
|
|
102
102
|
return void 0;
|
|
103
103
|
}
|
|
@@ -111,7 +111,7 @@ const idType = (model, crud) => {
|
|
|
111
111
|
throw new Error("Failed: Could not generate SDL");
|
|
112
112
|
}
|
|
113
113
|
return idField.type;
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
115
|
const idName = (model, crud) => {
|
|
116
116
|
if (!crud) {
|
|
117
117
|
return void 0;
|
|
@@ -124,14 +124,26 @@ const idName = (model, crud) => {
|
|
|
124
124
|
return idField.name;
|
|
125
125
|
};
|
|
126
126
|
const sdlFromSchemaModel = async (name, crud, docs = false) => {
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
const schemaResult = await getSchema(name);
|
|
128
|
+
if (!schemaResult || !("fields" in schemaResult)) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`No schema definition found for \`${name}\` in schema.prisma file`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const model = schemaResult;
|
|
134
|
+
const resolvedTypes = await Promise.all(
|
|
129
135
|
model.fields.filter((field) => field.kind === "object").map(async (field) => {
|
|
130
|
-
const
|
|
131
|
-
return
|
|
136
|
+
const fieldModel = await getSchema(field.type);
|
|
137
|
+
return fieldModel && "fields" in fieldModel ? fieldModel : void 0;
|
|
132
138
|
})
|
|
133
|
-
)
|
|
134
|
-
|
|
139
|
+
);
|
|
140
|
+
const types = resolvedTypes.reduce(
|
|
141
|
+
(acc, cur) => {
|
|
142
|
+
if (!cur) {
|
|
143
|
+
return acc;
|
|
144
|
+
}
|
|
145
|
+
return { ...acc, [cur.name]: cur };
|
|
146
|
+
},
|
|
135
147
|
{}
|
|
136
148
|
);
|
|
137
149
|
const enums = (await Promise.all(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2582",
|
|
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": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "5.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.2582",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2582",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2582",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2582",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2582",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2582",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2582",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2582",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2582",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2582",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2582",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@babel/cli": "7.29.7",
|
|
98
98
|
"@babel/core": "^7.26.10",
|
|
99
|
+
"@prisma/dmmf": "7.8.0",
|
|
99
100
|
"@types/archiver": "^7.0.0",
|
|
100
101
|
"memfs": "4.57.7",
|
|
101
102
|
"node-ssh": "13.2.1",
|