arkos 1.1.91-test → 1.1.93-test
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/cjs/modules/auth/auth.controller.js +1 -1
- package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js +7 -5
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +6 -5
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
- package/dist/cjs/utils/cli/build.js +1 -1
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +36 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js +21 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +268 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +58 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +38 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +35 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generators.js +12 -434
- package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
- package/dist/cjs/utils/helpers/fs.helpers.js +7 -0
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/es2020/modules/auth/auth.controller.js +1 -1
- package/dist/es2020/modules/auth/auth.controller.js.map +1 -1
- package/dist/es2020/modules/base/base.middlewares.js.map +1 -1
- package/dist/es2020/modules/base/base.service.js +7 -5
- package/dist/es2020/modules/base/base.service.js.map +1 -1
- package/dist/es2020/modules/file-upload/utils/helpers/file-upload.helpers.js +6 -5
- package/dist/es2020/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
- package/dist/es2020/utils/cli/build.js +1 -1
- package/dist/es2020/utils/cli/build.js.map +1 -1
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +33 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-controller-template.js +18 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-middlewares.js +265 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +55 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js +32 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-service-template.js +32 -0
- package/dist/es2020/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -0
- package/dist/es2020/utils/cli/utils/template-generators.js +6 -425
- package/dist/es2020/utils/cli/utils/template-generators.js.map +1 -1
- package/dist/es2020/utils/helpers/fs.helpers.js +6 -0
- package/dist/es2020/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/types/modules/base/base.service.d.ts +31 -31
- package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +3 -3
- package/dist/types/utils/cli/utils/template-generator/templates/generate-auth-configs-template.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generator/templates/generate-controller-template.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generator/templates/generate-middlewares.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generator/templates/generate-prisma-query-options.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generator/templates/generate-router-template.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generator/templates/generate-service-template.d.ts +2 -0
- package/dist/types/utils/cli/utils/template-generators.d.ts +1 -1
- package/dist/types/utils/helpers/fs.helpers.d.ts +1 -0
- package/package.json +10 -30
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMiddlewaresTemplate = generateMiddlewaresTemplate;
|
|
4
|
+
const fs_helpers_1 = require("../../../../helpers/fs.helpers");
|
|
5
|
+
function generateMiddlewaresTemplate(options) {
|
|
6
|
+
const { modelName } = options;
|
|
7
|
+
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
8
|
+
const isTypeScript = ext === "ts";
|
|
9
|
+
if (!modelName)
|
|
10
|
+
throw new Error("Model name is required for middleware template");
|
|
11
|
+
const isAuth = modelName.camel === "auth";
|
|
12
|
+
const isFileUpload = modelName.camel === "fileUpload" || modelName.camel === "file-upload";
|
|
13
|
+
const requestType = isTypeScript ? "ArkosRequest" : "req";
|
|
14
|
+
const responseType = isTypeScript ? "ArkosResponse" : "res";
|
|
15
|
+
const nextType = isTypeScript ? "ArkosNextFunction" : "next";
|
|
16
|
+
const baseImports = isTypeScript
|
|
17
|
+
? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from "arkos";
|
|
18
|
+
import { catchAsync } from "arkos/error-handler";`
|
|
19
|
+
: `import { catchAsync } from "arkos/error-handler";`;
|
|
20
|
+
const functionParams = isTypeScript
|
|
21
|
+
? `req: ${requestType}, res: ${responseType}, next: ${nextType}`
|
|
22
|
+
: `req, res, next`;
|
|
23
|
+
if (isAuth) {
|
|
24
|
+
return `${baseImports}
|
|
25
|
+
|
|
26
|
+
// export const beforeGetMe = catchAsync(
|
|
27
|
+
// async (${functionParams}) => {
|
|
28
|
+
// // Your logic here
|
|
29
|
+
// next();
|
|
30
|
+
// }
|
|
31
|
+
// );
|
|
32
|
+
|
|
33
|
+
// export const afterGetMe = catchAsync(
|
|
34
|
+
// async (${functionParams}) => {
|
|
35
|
+
// // Your logic here
|
|
36
|
+
// next();
|
|
37
|
+
// }
|
|
38
|
+
// );
|
|
39
|
+
|
|
40
|
+
// export const beforeLogin = catchAsync(
|
|
41
|
+
// async (${functionParams}) => {
|
|
42
|
+
// // Your logic here
|
|
43
|
+
// next();
|
|
44
|
+
// }
|
|
45
|
+
// );
|
|
46
|
+
|
|
47
|
+
// export const afterLogin = catchAsync(
|
|
48
|
+
// async (${functionParams}) => {
|
|
49
|
+
// // Your logic here
|
|
50
|
+
// next();
|
|
51
|
+
// }
|
|
52
|
+
// );
|
|
53
|
+
|
|
54
|
+
// export const beforeLogout = catchAsync(
|
|
55
|
+
// async (${functionParams}) => {
|
|
56
|
+
// // Your logic here
|
|
57
|
+
// next();
|
|
58
|
+
// }
|
|
59
|
+
// );
|
|
60
|
+
|
|
61
|
+
// export const afterLogout = catchAsync(
|
|
62
|
+
// async (${functionParams}) => {
|
|
63
|
+
// // Your logic here
|
|
64
|
+
// next();
|
|
65
|
+
// }
|
|
66
|
+
// );
|
|
67
|
+
|
|
68
|
+
// export const beforeSignup = catchAsync(
|
|
69
|
+
// async (${functionParams}) => {
|
|
70
|
+
// // Your logic here
|
|
71
|
+
// next();
|
|
72
|
+
// }
|
|
73
|
+
// );
|
|
74
|
+
|
|
75
|
+
// export const afterSignup = catchAsync(
|
|
76
|
+
// async (${functionParams}) => {
|
|
77
|
+
// // Your logic here
|
|
78
|
+
// next();
|
|
79
|
+
// }
|
|
80
|
+
// );
|
|
81
|
+
|
|
82
|
+
// export const beforeUpdatePassword = catchAsync(
|
|
83
|
+
// async (${functionParams}) => {
|
|
84
|
+
// // Your logic here
|
|
85
|
+
// next();
|
|
86
|
+
// }
|
|
87
|
+
// );
|
|
88
|
+
|
|
89
|
+
// export const afterUpdatePassword = catchAsync(
|
|
90
|
+
// async (${functionParams}) => {
|
|
91
|
+
// // Your logic here
|
|
92
|
+
// next();
|
|
93
|
+
// }
|
|
94
|
+
// );
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
if (isFileUpload) {
|
|
98
|
+
return `${baseImports}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// export const beforeFindFile = catchAsync(
|
|
102
|
+
// async (${functionParams}) => {
|
|
103
|
+
// // Your logic here
|
|
104
|
+
// next();
|
|
105
|
+
// }
|
|
106
|
+
// );
|
|
107
|
+
|
|
108
|
+
// There is not afterFindFile: because the main handler is handleded by express.static()
|
|
109
|
+
|
|
110
|
+
// export const beforeUploadFile = catchAsync(
|
|
111
|
+
// async (${functionParams}) => {
|
|
112
|
+
// // Your logic here
|
|
113
|
+
// next();
|
|
114
|
+
// }
|
|
115
|
+
// );
|
|
116
|
+
|
|
117
|
+
// export const afterUploadFile = catchAsync(
|
|
118
|
+
// async (${functionParams}) => {
|
|
119
|
+
// // Your logic here
|
|
120
|
+
// next();
|
|
121
|
+
// }
|
|
122
|
+
// );
|
|
123
|
+
|
|
124
|
+
// export const beforeUpdateFile = catchAsync(
|
|
125
|
+
// async (${functionParams}) => {
|
|
126
|
+
// // Your logic here
|
|
127
|
+
// next();
|
|
128
|
+
// }
|
|
129
|
+
// );
|
|
130
|
+
|
|
131
|
+
// export const afterUpdateFile = catchAsync(
|
|
132
|
+
// async (${functionParams}) => {
|
|
133
|
+
// // Your logic here
|
|
134
|
+
// next();
|
|
135
|
+
// }
|
|
136
|
+
// );
|
|
137
|
+
|
|
138
|
+
// export const beforeDeleteFile = catchAsync(
|
|
139
|
+
// async (${functionParams}) => {
|
|
140
|
+
// // Your logic here
|
|
141
|
+
// next();
|
|
142
|
+
// }
|
|
143
|
+
// );
|
|
144
|
+
|
|
145
|
+
// export const afterDeleteFile = catchAsync(
|
|
146
|
+
// async (${functionParams}) => {
|
|
147
|
+
// // Your logic here
|
|
148
|
+
// next();
|
|
149
|
+
// }
|
|
150
|
+
// );
|
|
151
|
+
`;
|
|
152
|
+
}
|
|
153
|
+
return `${baseImports}
|
|
154
|
+
|
|
155
|
+
// export const beforeCreateOne = catchAsync(
|
|
156
|
+
// async (${functionParams}) => {
|
|
157
|
+
// // Your logic here
|
|
158
|
+
// next();
|
|
159
|
+
// }
|
|
160
|
+
// );
|
|
161
|
+
|
|
162
|
+
// export const afterCreateOne = catchAsync(
|
|
163
|
+
// async (${functionParams}) => {
|
|
164
|
+
// // Your logic here
|
|
165
|
+
// next();
|
|
166
|
+
// }
|
|
167
|
+
// );
|
|
168
|
+
|
|
169
|
+
// export const beforeFindOne = catchAsync(
|
|
170
|
+
// async (${functionParams}) => {
|
|
171
|
+
// // Your logic here
|
|
172
|
+
// next();
|
|
173
|
+
// }
|
|
174
|
+
// );
|
|
175
|
+
|
|
176
|
+
// export const afterFindOne = catchAsync(
|
|
177
|
+
// async (${functionParams}) => {
|
|
178
|
+
// // Your logic here
|
|
179
|
+
// next();
|
|
180
|
+
// }
|
|
181
|
+
// );
|
|
182
|
+
|
|
183
|
+
// export const beforeFindMany = catchAsync(
|
|
184
|
+
// async (${functionParams}) => {
|
|
185
|
+
// // Your logic here
|
|
186
|
+
// next();
|
|
187
|
+
// }
|
|
188
|
+
// );
|
|
189
|
+
|
|
190
|
+
// export const afterFindMany = catchAsync(
|
|
191
|
+
// async (${functionParams}) => {
|
|
192
|
+
// // Your logic here
|
|
193
|
+
// next();
|
|
194
|
+
// }
|
|
195
|
+
// );
|
|
196
|
+
|
|
197
|
+
// export const beforeUpdateOne = catchAsync(
|
|
198
|
+
// async (${functionParams}) => {
|
|
199
|
+
// // Your logic here
|
|
200
|
+
// next();
|
|
201
|
+
// }
|
|
202
|
+
// );
|
|
203
|
+
|
|
204
|
+
// export const afterUpdateOne = catchAsync(
|
|
205
|
+
// async (${functionParams}) => {
|
|
206
|
+
// // Your logic here
|
|
207
|
+
// next();
|
|
208
|
+
// }
|
|
209
|
+
// );
|
|
210
|
+
|
|
211
|
+
// export const beforeDeleteOne = catchAsync(
|
|
212
|
+
// async (${functionParams}) => {
|
|
213
|
+
// // Your logic here
|
|
214
|
+
// next();
|
|
215
|
+
// }
|
|
216
|
+
// );
|
|
217
|
+
|
|
218
|
+
// export const afterDeleteOne = catchAsync(
|
|
219
|
+
// async (${functionParams}) => {
|
|
220
|
+
// // Your logic here
|
|
221
|
+
// next();
|
|
222
|
+
// }
|
|
223
|
+
// );
|
|
224
|
+
|
|
225
|
+
// export const beforeCreateMany = catchAsync(
|
|
226
|
+
// async (${functionParams}) => {
|
|
227
|
+
// // Your logic here
|
|
228
|
+
// next();
|
|
229
|
+
// }
|
|
230
|
+
// );
|
|
231
|
+
|
|
232
|
+
// export const afterCreateMany = catchAsync(
|
|
233
|
+
// async (${functionParams}) => {
|
|
234
|
+
// // Your logic here
|
|
235
|
+
// next();
|
|
236
|
+
// }
|
|
237
|
+
// );
|
|
238
|
+
|
|
239
|
+
// export const beforeUpdateMany = catchAsync(
|
|
240
|
+
// async (${functionParams}) => {
|
|
241
|
+
// // Your logic here
|
|
242
|
+
// next();
|
|
243
|
+
// }
|
|
244
|
+
// );
|
|
245
|
+
|
|
246
|
+
// export const afterUpdateMany = catchAsync(
|
|
247
|
+
// async (${functionParams}) => {
|
|
248
|
+
// // Your logic here
|
|
249
|
+
// next();
|
|
250
|
+
// }
|
|
251
|
+
// );
|
|
252
|
+
|
|
253
|
+
// export const beforeDeleteMany = catchAsync(
|
|
254
|
+
// async (${functionParams}) => {
|
|
255
|
+
// // Your logic here
|
|
256
|
+
// next();
|
|
257
|
+
// }
|
|
258
|
+
// );
|
|
259
|
+
|
|
260
|
+
// export const afterDeleteMany = catchAsync(
|
|
261
|
+
// async (${functionParams}) => {
|
|
262
|
+
// // Your logic here
|
|
263
|
+
// next();
|
|
264
|
+
// }
|
|
265
|
+
// );
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=generate-middlewares.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-middlewares.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-middlewares.ts"],"names":[],"mappings":";;AAGA,kEAiRC;AApRD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;IAGxE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7D,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;kDAC4C;QAC9C,CAAC,CAAC,mDAAmD,CAAC;IAExD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,QAAQ,WAAW,UAAU,YAAY,WAAW,QAAQ,EAAE;QAChE,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,WAAW;;;cAGX,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,CAAC;IACA,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,WAAW;;;;cAIX,cAAc;;;;;;;;;cASd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,CAAC;IACA,CAAC;IAGD,OAAO,GAAG,WAAW;;;cAGT,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n // Generate imports based on TypeScript/JavaScript\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";\nimport { catchAsync } from \"arkos/error-handler\";`\n : `import { catchAsync } from \"arkos/error-handler\";`;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterGetMe = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeLogin = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterLogin = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeLogout = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterLogout = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeSignup = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterSignup = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdatePassword = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdatePassword = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// There is not afterFindFile: because the main handler is handleded by express.static()\n\n// export const beforeUploadFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUploadFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n }\n\n // Regular model middlewares\n return `${baseImports}\n\n// export const beforeCreateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterCreateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeFindOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterFindOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeFindMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterFindMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeCreateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterCreateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n}\n"]}
|
package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateQueryOptionsTemplate = generateQueryOptionsTemplate;
|
|
4
|
+
const fs_helpers_1 = require("../../../../helpers/fs.helpers");
|
|
5
|
+
function generateQueryOptionsTemplate(options) {
|
|
6
|
+
const { modelName } = options;
|
|
7
|
+
const isAuth = modelName?.camel === "auth";
|
|
8
|
+
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
9
|
+
const isTypeScript = ext === "ts";
|
|
10
|
+
if (!modelName)
|
|
11
|
+
throw new Error("Model name is required for query config template");
|
|
12
|
+
const imports = isAuth
|
|
13
|
+
? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
|
|
14
|
+
: `import { PrismaQueryOptions } from 'arkos/prisma'`;
|
|
15
|
+
const typeAnnotation = isTypeScript
|
|
16
|
+
? isAuth
|
|
17
|
+
? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
18
|
+
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
19
|
+
: "";
|
|
20
|
+
const prismaImport = isTypeScript
|
|
21
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
22
|
+
: "";
|
|
23
|
+
if (isAuth) {
|
|
24
|
+
return `${prismaImport}${imports};
|
|
25
|
+
|
|
26
|
+
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
27
|
+
getMe: {},
|
|
28
|
+
updateMe: {},
|
|
29
|
+
deleteMe: {},
|
|
30
|
+
login: {},
|
|
31
|
+
signup: {},
|
|
32
|
+
updatePassword: {},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default ${modelName.camel}QueryOptions;
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return `${prismaImport}${imports};
|
|
40
|
+
|
|
41
|
+
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
42
|
+
// for all queries
|
|
43
|
+
queryOptions: {},
|
|
44
|
+
findOne: {},
|
|
45
|
+
findMany: {},
|
|
46
|
+
deleteMany: {},
|
|
47
|
+
updateMany: {},
|
|
48
|
+
createMany: {},
|
|
49
|
+
createOne: {},
|
|
50
|
+
updateOne: {},
|
|
51
|
+
deleteOne: {},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default ${modelName.camel}QueryOptions;
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=generate-prisma-query-options.js.map
|
package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-prisma-query-options.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-prisma-query-options.ts"],"names":[],"mappings":";;AAGA,oEA6DC;AAhED,+DAAsE;AAGtE,SAAgB,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAGtE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAGxD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;iBAanC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n // Generate imports\n const imports = isAuth\n ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`\n : `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : \"\";\n\n // Generate prisma import if TypeScript\n const prismaImport = isTypeScript\n ? `import { prisma } from \"../../utils/prisma\";\\n`\n : \"\";\n\n if (isAuth) {\n // Auth template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n // Regular template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n // for all queries\n queryOptions: {},\n findOne: {},\n findMany: {},\n deleteMany: {},\n updateMany: {},\n createMany: {},\n createOne: {},\n updateOne: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateRouterTemplate = generateRouterTemplate;
|
|
7
|
+
const pluralize_1 = __importDefault(require("pluralize"));
|
|
8
|
+
const fs_helpers_1 = require("../../../../helpers/fs.helpers");
|
|
9
|
+
function generateRouterTemplate(options) {
|
|
10
|
+
const { modelName, imports } = options;
|
|
11
|
+
if (!modelName)
|
|
12
|
+
throw new Error("Model name is required for router template");
|
|
13
|
+
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
14
|
+
const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
|
|
15
|
+
const controllerExists = (0, fs_helpers_1.checkFileExists)(controllerPath);
|
|
16
|
+
const controllerImportLine = controllerExists
|
|
17
|
+
? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
|
|
18
|
+
: `// import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`;
|
|
19
|
+
const controllerHandlerLine = controllerExists
|
|
20
|
+
? ` ${modelName.camel}Controller.someHandler`
|
|
21
|
+
: ` // ${modelName.camel}Controller.someHandler`;
|
|
22
|
+
return `import { Router } from 'express'
|
|
23
|
+
import { authService } from 'arkos/services'
|
|
24
|
+
${controllerImportLine}
|
|
25
|
+
|
|
26
|
+
const ${modelName.camel}Router = Router()
|
|
27
|
+
|
|
28
|
+
${modelName.camel}Router.post(
|
|
29
|
+
'/custom-endpoint', // resolves to /api/${(0, pluralize_1.default)(modelName.kebab)}/custom-endpoint
|
|
30
|
+
authService.authenticate,
|
|
31
|
+
authService.handleAccessControl('CustomAction', '${modelName.kebab}'),
|
|
32
|
+
${controllerHandlerLine}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export default ${modelName.camel}Router
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=generate-router-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-router-template.ts"],"names":[],"mappings":";;;;;AAOA,wDAyCC;AAhDD,0DAAkC;AAClC,+DAGwC;AAGxC,SAAgB,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG;QACL,CAAC,CAAC,aAAa,SAAS,CAAC,KAAK,oBAC1B,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,wBAAwB;QAC9C,CAAC,CAAC,QAAQ,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEpD,OAAO;;EAEP,oBAAoB;;QAEd,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;4CAC2B,IAAA,mBAAS,EACjD,SAAS,CAAC,KAAK,CAChB;;qDAEkD,SAAS,CAAC,KAAK;EAClE,qBAAqB;;;iBAGN,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n // Check if controller file exists\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`\n : `// import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`;\n\n const controllerHandlerLine = controllerExists\n ? ` ${modelName.camel}Controller.someHandler`\n : ` // ${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\n${controllerImportLine}\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.post(\n '/custom-endpoint', // resolves to /api/${pluralize(\n modelName.kebab\n )}/custom-endpoint\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateServiceTemplate = generateServiceTemplate;
|
|
4
|
+
const fs_helpers_1 = require("../../../../helpers/fs.helpers");
|
|
5
|
+
function generateServiceTemplate(options) {
|
|
6
|
+
const { modelName, imports } = options;
|
|
7
|
+
const ext = (0, fs_helpers_1.getUserFileExtension)();
|
|
8
|
+
const isTypeScript = ext === "ts";
|
|
9
|
+
if (!modelName)
|
|
10
|
+
throw new Error("Model name is required for service template");
|
|
11
|
+
const prismaImport = isTypeScript
|
|
12
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
13
|
+
: "";
|
|
14
|
+
const baseServiceImport = isTypeScript
|
|
15
|
+
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
16
|
+
: `import { BaseService } from "${imports?.baseService || "arkos/services"}";`;
|
|
17
|
+
const typeParameter = isTypeScript
|
|
18
|
+
? `<typeof prisma.${modelName.camel}>`
|
|
19
|
+
: "";
|
|
20
|
+
return `${prismaImport}${baseServiceImport}
|
|
21
|
+
|
|
22
|
+
class ${modelName.pascal}Service extends BaseService${typeParameter} {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("${modelName.kebab}");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Add your custom service methods here
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ${modelName.camel}Service = new ${modelName.pascal}Service();
|
|
31
|
+
|
|
32
|
+
export default ${modelName.camel}Service;
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=generate-service-template.js.map
|
package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-service-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-service-template.ts"],"names":[],"mappings":";;AAGA,0DAwCC;AA3CD,+DAAsE;AAGtE,SAAgB,uBAAuB,CAAC,OAAwB;IAC9D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAGjE,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,iBAAiB,GAAG,YAAY;QACpC,CAAC,CAAC,gCACE,OAAO,EAAE,WAAW,IAAI,gBAC1B,IAAI;QACN,CAAC,CAAC,gCACE,OAAO,EAAE,WAAW,IAAI,gBAC1B,IAAI,CAAC;IAGT,MAAM,aAAa,GAAG,YAAY;QAChC,CAAC,CAAC,kBAAkB,SAAS,CAAC,KAAK,GAAG;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,YAAY,GAAG,iBAAiB;;QAEpC,SAAS,CAAC,MAAM,8BAA8B,aAAa;;aAEtD,SAAS,CAAC,KAAK;;;;;;QAMpB,SAAS,CAAC,KAAK,iBAAiB,SAAS,CAAC,MAAM;;iBAEvC,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for service template\");\n\n // Generate imports\n const prismaImport = isTypeScript\n ? `import { prisma } from \"../../utils/prisma\";\\n`\n : \"\";\n\n const baseServiceImport = isTypeScript\n ? `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";`\n : `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";`;\n\n // Generate type parameter for TypeScript\n const typeParameter = isTypeScript\n ? `<typeof prisma.${modelName.camel}>`\n : \"\";\n\n return `${prismaImport}${baseServiceImport}\n \nclass ${modelName.pascal}Service extends BaseService${typeParameter} {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n\n // Add your custom service methods here\n}\n\nconst ${modelName.camel}Service = new ${modelName.pascal}Service();\n\nexport default ${modelName.camel}Service;\n`;\n}\n"]}
|