arkos 1.1.71-test → 1.1.73-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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTemplate = generateTemplate;
4
+ const fs_helpers_1 = require("../../helpers/fs.helpers");
4
5
  function generateTemplate(type, options = {}) {
5
6
  switch (type) {
6
7
  case "controller":
@@ -9,14 +10,14 @@ function generateTemplate(type, options = {}) {
9
10
  return generateServiceTemplate(options);
10
11
  case "router":
11
12
  return generateRouterTemplate(options);
12
- case "auth":
13
- return generateAuthConfigTemplate();
14
- case "query":
15
- return generateQueryConfigTemplate(options);
16
- case "middleware":
17
- return generateMiddlewareTemplate(options);
13
+ case "auth-configs":
14
+ return generateAuthConfigsTemplate(options);
15
+ case "query-options":
16
+ return generateQueryOptionsTemplate(options);
17
+ case "middlewares":
18
+ return generateMiddlewaresTemplate(options);
18
19
  default:
19
- throw new Error(`Unknown template type: ${type}`);
20
+ throw new Error(`\n Unknown template type: ${type}`);
20
21
  }
21
22
  }
22
23
  function generateControllerTemplate(options) {
@@ -38,22 +39,33 @@ function generateControllerTemplate(options) {
38
39
  }
39
40
  function generateServiceTemplate(options) {
40
41
  const { modelName, imports } = options;
42
+ const ext = (0, fs_helpers_1.getUserFileExtension)();
43
+ const isTypeScript = ext === "ts";
41
44
  if (!modelName)
42
45
  throw new Error("Model name is required for service template");
43
- return `import { BaseService } from "${imports?.baseService || "arkos/services"}";
46
+ const prismaImport = isTypeScript
47
+ ? `import { prisma } from "../../utils/prisma";\n`
48
+ : "";
49
+ const baseServiceImport = isTypeScript
50
+ ? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
51
+ : `import { BaseService } from "${imports?.baseService || "arkos/services"}";`;
52
+ const typeParameter = isTypeScript
53
+ ? `<typeof prisma.${modelName.camel}>`
54
+ : "";
55
+ return `${prismaImport}${baseServiceImport}
44
56
 
45
- class ${modelName.pascal}Service extends BaseService {
46
- constructor() {
47
- super("${modelName.kebab}");
48
- }
49
-
50
- // Add your custom service methods here
57
+ class ${modelName.pascal}Service extends BaseService${typeParameter} {
58
+ constructor() {
59
+ super("${modelName.kebab}");
51
60
  }
52
-
53
- const ${modelName.camel}Service = new ${modelName.pascal}Service();
54
-
55
- export default ${modelName.camel}Service;
56
- `;
61
+
62
+ // Add your custom service methods here
63
+ }
64
+
65
+ const ${modelName.camel}Service = new ${modelName.pascal}Service();
66
+
67
+ export default ${modelName.camel}Service;
68
+ `;
57
69
  }
58
70
  function generateRouterTemplate(options) {
59
71
  const { modelName, imports } = options;
@@ -74,127 +86,313 @@ function generateRouterTemplate(options) {
74
86
  export default ${modelName.camel}Router;
75
87
  `;
76
88
  }
77
- function generateAuthConfigTemplate() {
78
- return `export const authConfig = {
79
- jwt: {
80
- secret: process.env.JWT_SECRET || 'your-secret-key',
81
- expiresIn: process.env.JWT_EXPIRES_IN || '7d',
82
- refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',
83
- },
84
- bcrypt: {
85
- saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),
86
- },
87
- cookie: {
88
- name: process.env.COOKIE_NAME || 'arkos-token',
89
- maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days
90
- httpOnly: true,
91
- secure: process.env.NODE_ENV === 'production',
92
- sameSite: 'strict' as const,
93
- },
94
- rateLimit: {
95
- windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes
96
- max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts
97
- },
98
- email: {
99
- verification: {
100
- required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',
101
- expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',
102
- },
103
- passwordReset: {
104
- expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',
105
- },
106
- },
107
- };
89
+ function generateAuthConfigsTemplate(options) {
90
+ const { modelName } = options;
91
+ const ext = (0, fs_helpers_1.getUserFileExtension)();
92
+ const isTypeScript = ext === "ts";
93
+ if (!modelName)
94
+ throw new Error("Model name is required for auth config template");
95
+ const imports = isTypeScript
96
+ ? `import { AuthConfigs } from 'arkos/prisma';\n`
97
+ : "";
98
+ const typeAnnotation = isTypeScript ? `: AuthConfigs` : "";
99
+ return `${imports}
100
+ const ${modelName.camel}AuthConfigs${typeAnnotation} = {
101
+ authenticationControl: {
102
+ // Create: true,
103
+ // Update: true,
104
+ // Delete: true,
105
+ // View: false,
106
+ },
108
107
 
109
- export default authConfig;
110
- `;
108
+ // Only when using Static RBAC
109
+ accessControl: {
110
+ // Create: ["Admin"],
111
+ // Update: ["Admin", "Manager"],
112
+ // Delete: ["Admin"],
113
+ // View: ["User", "Admin", "Guest"],
114
+ },
115
+ };
116
+
117
+ export default ${modelName.camel}AuthConfigs;
118
+ `;
111
119
  }
112
- function generateQueryConfigTemplate(options) {
120
+ function generateQueryOptionsTemplate(options) {
113
121
  const { modelName } = options;
122
+ const isAuth = modelName?.camel === "auth";
123
+ const ext = (0, fs_helpers_1.getUserFileExtension)();
124
+ const isTypeScript = ext === "ts";
114
125
  if (!modelName)
115
126
  throw new Error("Model name is required for query config template");
116
- return `export const ${modelName.camel}QueryOptions = {
117
- // Define searchable fields
118
- searchFields: [
119
- // 'name',
120
- // 'email',
121
- // 'description',
122
- ],
123
-
124
- // Define filterable fields
125
- filterFields: [
126
- // 'status',
127
- // 'type',
128
- // 'createdAt',
129
- ],
130
-
131
- // Define sortable fields
132
- sortFields: [
133
- 'id',
134
- 'createdAt',
135
- 'updatedAt',
136
- // Add other sortable fields
137
- ],
138
-
139
- // Define relations to include
140
- include: {
141
- // relationName: true,
142
- // relationName: {
143
- // select: {
144
- // id: true,
145
- // name: true,
146
- // }
147
- // }
148
- },
149
-
150
- // Define fields to select (if not all)
151
- select: {
152
- // id: true,
153
- // name: true,
154
- // email: true,
155
- // createdAt: true,
156
- // updatedAt: true,
157
- },
158
-
159
- // Default pagination
160
- pagination: {
161
- defaultLimit: 10,
162
- maxLimit: 100,
163
- },
164
-
165
- // Default sorting
166
- defaultSort: {
167
- field: 'createdAt',
168
- order: 'desc' as const,
169
- },
170
- };
171
-
172
- export default ${modelName.camel}QueryOptions;
173
- `;
127
+ const imports = isAuth
128
+ ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
129
+ : `import { PrismaQueryOptions } from 'arkos/prisma'`;
130
+ const typeAnnotation = isTypeScript
131
+ ? isAuth
132
+ ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.pascal}>`
133
+ : `: PrismaQueryOptions<typeof prisma.${modelName.pascal}>`
134
+ : "";
135
+ const prismaImport = isTypeScript
136
+ ? `import { prisma } from "../../utils/prisma";\n`
137
+ : "";
138
+ if (isAuth) {
139
+ return `${prismaImport}${imports};
140
+
141
+ const ${modelName.camel}QueryOptions${typeAnnotation} = {
142
+ getMe: {},
143
+ updateMe: {},
144
+ deleteMe: {},
145
+ login: {},
146
+ signup: {},
147
+ updatePassword: {},
174
148
  }
175
- function generateMiddlewareTemplate(options) {
176
- const { middlewareName } = options;
177
- if (!middlewareName)
178
- throw new Error("Middleware name is required for middleware template");
179
- return `import { Request, Response, NextFunction } from 'express';
180
-
181
- export const ${middlewareName.camel}Middleware = (
182
- req: Request,
183
- res: Response,
184
- next: NextFunction
185
- ): void => {
186
- try {
187
- // Add your middleware logic here
188
- console.log(\`${middlewareName.pascal} middleware executed for \${req.method} \${req.path}\`);
189
-
190
- // Continue to next middleware
191
- next();
192
- } catch (error) {
193
- next(error);
149
+
150
+ export default ${modelName.camel}QueryOptions;
151
+ `;
194
152
  }
195
- };
196
-
197
- export default ${middlewareName.camel}Middleware;
198
- `;
153
+ else {
154
+ return `${prismaImport}${imports};
155
+
156
+ const ${modelName.camel}QueryOptions${typeAnnotation} = {
157
+ // for all queries
158
+ queryOptions: {},
159
+ findOne: {},
160
+ findMany: {},
161
+ deleteMany: {},
162
+ updateMany: {},
163
+ createMany: {},
164
+ createOne: {},
165
+ updateOne: {},
166
+ deleteOne: {},
167
+ }
168
+
169
+ export default ${modelName.camel}QueryOptions;
170
+ `;
171
+ }
172
+ }
173
+ function generateMiddlewaresTemplate(options) {
174
+ const { modelName } = options;
175
+ const ext = (0, fs_helpers_1.getUserFileExtension)();
176
+ const isTypeScript = ext === "ts";
177
+ if (!modelName)
178
+ throw new Error("Model name is required for middleware template");
179
+ const isAuth = modelName.camel === "auth";
180
+ const isFileUpload = modelName.camel === "fileUpload" || modelName.camel === "file-upload";
181
+ const requestType = isTypeScript ? "ArkosRequest" : "req";
182
+ const responseType = isTypeScript ? "ArkosResponse" : "res";
183
+ const nextType = isTypeScript ? "ArkosNextFunction" : "next";
184
+ const baseImports = isTypeScript
185
+ ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from "arkos";
186
+ import { catchAsync } from "arkos/error-handler";`
187
+ : `import { catchAsync } from "arkos/error-handler";`;
188
+ const functionParams = isTypeScript
189
+ ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`
190
+ : `req, res, next`;
191
+ if (isAuth) {
192
+ return `${baseImports}
193
+
194
+ // export const beforeGetMe = catchAsync(
195
+ // async (${functionParams}) => {
196
+ // // Your logic here
197
+ // next();
198
+ // }
199
+ // );
200
+
201
+ // export const afterGetMe = catchAsync(
202
+ // async (${functionParams}) => {
203
+ // // Your logic here
204
+ // next();
205
+ // }
206
+ // );
207
+
208
+ // export const beforeLogin = catchAsync(
209
+ // async (${functionParams}) => {
210
+ // // Your logic here
211
+ // next();
212
+ // }
213
+ // );
214
+
215
+ // export const afterLogin = catchAsync(
216
+ // async (${functionParams}) => {
217
+ // // Your logic here
218
+ // next();
219
+ // }
220
+ // );
221
+
222
+ // export const beforeLogout = catchAsync(
223
+ // async (${functionParams}) => {
224
+ // // Your logic here
225
+ // next();
226
+ // }
227
+ // );
228
+
229
+ // export const afterLogout = catchAsync(
230
+ // async (${functionParams}) => {
231
+ // // Your logic here
232
+ // next();
233
+ // }
234
+ // );
235
+
236
+ // export const beforeSignup = catchAsync(
237
+ // async (${functionParams}) => {
238
+ // // Your logic here
239
+ // next();
240
+ // }
241
+ // );
242
+
243
+ // export const afterSignup = catchAsync(
244
+ // async (${functionParams}) => {
245
+ // // Your logic here
246
+ // next();
247
+ // }
248
+ // );
249
+
250
+ // export const beforeUpdatePassword = catchAsync(
251
+ // async (${functionParams}) => {
252
+ // // Your logic here
253
+ // next();
254
+ // }
255
+ // );
256
+
257
+ // export const afterUpdatePassword = catchAsync(
258
+ // async (${functionParams}) => {
259
+ // // Your logic here
260
+ // next();
261
+ // }
262
+ // );
263
+ `;
264
+ }
265
+ if (isFileUpload) {
266
+ return `${baseImports}
267
+
268
+ // export const beforeUploadFile = catchAsync(
269
+ // async (${functionParams}) => {
270
+ // // Your logic here
271
+ // next();
272
+ // }
273
+ // );
274
+
275
+ // export const afterUploadFile = catchAsync(
276
+ // async (${functionParams}) => {
277
+ // // Your logic here
278
+ // next();
279
+ // }
280
+ // );
281
+ `;
282
+ }
283
+ return `${baseImports}
284
+
285
+ // export const beforeCreateOne = catchAsync(
286
+ // async (${functionParams}) => {
287
+ // // Your logic here
288
+ // next();
289
+ // }
290
+ // );
291
+
292
+ // export const afterCreateOne = catchAsync(
293
+ // async (${functionParams}) => {
294
+ // // Your logic here
295
+ // next();
296
+ // }
297
+ // );
298
+
299
+ // export const beforeFindOne = catchAsync(
300
+ // async (${functionParams}) => {
301
+ // // Your logic here
302
+ // next();
303
+ // }
304
+ // );
305
+
306
+ // export const afterFindOne = catchAsync(
307
+ // async (${functionParams}) => {
308
+ // // Your logic here
309
+ // next();
310
+ // }
311
+ // );
312
+
313
+ // export const beforeFindMany = catchAsync(
314
+ // async (${functionParams}) => {
315
+ // // Your logic here
316
+ // next();
317
+ // }
318
+ // );
319
+
320
+ // export const afterFindMany = catchAsync(
321
+ // async (${functionParams}) => {
322
+ // // Your logic here
323
+ // next();
324
+ // }
325
+ // );
326
+
327
+ // export const beforeUpdateOne = catchAsync(
328
+ // async (${functionParams}) => {
329
+ // // Your logic here
330
+ // next();
331
+ // }
332
+ // );
333
+
334
+ // export const afterUpdateOne = catchAsync(
335
+ // async (${functionParams}) => {
336
+ // // Your logic here
337
+ // next();
338
+ // }
339
+ // );
340
+
341
+ // export const beforeDeleteOne = catchAsync(
342
+ // async (${functionParams}) => {
343
+ // // Your logic here
344
+ // next();
345
+ // }
346
+ // );
347
+
348
+ // export const afterDeleteOne = catchAsync(
349
+ // async (${functionParams}) => {
350
+ // // Your logic here
351
+ // next();
352
+ // }
353
+ // );
354
+
355
+ // export const beforeCreateMany = catchAsync(
356
+ // async (${functionParams}) => {
357
+ // // Your logic here
358
+ // next();
359
+ // }
360
+ // );
361
+
362
+ // export const afterCreateMany = catchAsync(
363
+ // async (${functionParams}) => {
364
+ // // Your logic here
365
+ // next();
366
+ // }
367
+ // );
368
+
369
+ // export const beforeUpdateMany = catchAsync(
370
+ // async (${functionParams}) => {
371
+ // // Your logic here
372
+ // next();
373
+ // }
374
+ // );
375
+
376
+ // export const afterUpdateMany = catchAsync(
377
+ // async (${functionParams}) => {
378
+ // // Your logic here
379
+ // next();
380
+ // }
381
+ // );
382
+
383
+ // export const beforeDeleteMany = catchAsync(
384
+ // async (${functionParams}) => {
385
+ // // Your logic here
386
+ // next();
387
+ // }
388
+ // );
389
+
390
+ // export const afterDeleteMany = catchAsync(
391
+ // async (${functionParams}) => {
392
+ // // Your logic here
393
+ // next();
394
+ // }
395
+ // );
396
+ `;
199
397
  }
200
398
  //# sourceMappingURL=generators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/generators.ts"],"names":[],"mappings":";;AAkBA,4CAoBC;AApBD,SAAgB,gBAAgB,CAC9B,IAAY,EACZ,UAA2B,EAAE;IAE7B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,0BAA0B,CAAC,OAAO,C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AO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAE9E,OAAO;kCACyB,OAAO,EAAE,UAAU,IAAI,OAAO;WACrD,SAAS,CAAC,KAAK,oBACtB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C;;UAEQ,SAAS,CAAC,KAAK;;;iBAGR,SAAS,CAAC,KAAK,WAAW,SAAS,CAAC,KAAK;;;OAGnD,SAAS,CAAC,KAAK,yBAClB,SAAS,CAAC,KACZ;;mBAEiB,SAAS,CAAC,KAAK;GAC/B,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCN,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,OAAwB;IAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAEtE,OAAO,gBAAgB,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAwDrB,SAAS,CAAC,KAAK;GAC/B,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B,CAAC,OAAwB;IAC1D,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAEnC,IAAI,CAAC,cAAc;QACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IAEzE,OAAO;;iBAEQ,cAAc,CAAC,KAAK;;;;;;;sBAOf,cAAc,CAAC,MAAM;;;;;;;;;mBASxB,cAAc,CAAC,KAAK;GACpC,CAAC;AACJ,CAAC","sourcesContent":["interface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface TemplateOptions {\n modelName?: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions = {}\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth\":\n return generateAuthConfigTemplate();\n case \"query\":\n return generateQueryConfigTemplate(options);\n case \"middleware\":\n return generateMiddlewareTemplate(options);\n default:\n throw new Error(`Unknown template type: ${type}`);\n }\n}\n\nfunction generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \n class ${modelName.pascal}Controller extends BaseController {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n }\n \n const ${modelName.camel}Controller = new ${modelName.pascal}Controller();\n \n export default ${modelName.camel}Controller;\n `;\n}\n\nfunction generateServiceTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for service template\");\n\n return `import { BaseService } from \"${\n imports?.baseService || \"arkos/services\"\n }\";\n \n class ${modelName.pascal}Service extends BaseService {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n \n // Add your custom service methods here\n }\n \n const ${modelName.camel}Service = new ${modelName.pascal}Service();\n \n export default ${modelName.camel}Service;\n `;\n}\n\nfunction 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 return `import { Router } from \"express\";\n import { createRoutes } from \"${imports?.baseRouter || \"arkos\"}\";\n import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\";\n \n const ${modelName.camel}Router = Router();\n \n // Generate CRUD routes automatically\n createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);\n \n // Add custom routes here\n // ${modelName.camel}Router.get('/custom', ${\n modelName.camel\n }Controller.customMethod);\n \n export default ${modelName.camel}Router;\n `;\n}\n\nfunction generateAuthConfigTemplate(): string {\n return `export const authConfig = {\n jwt: {\n secret: process.env.JWT_SECRET || 'your-secret-key',\n expiresIn: process.env.JWT_EXPIRES_IN || '7d',\n refreshExpiresIn: process.env.JWT_REFRESH_EXPIRES_IN || '30d',\n },\n bcrypt: {\n saltRounds: parseInt(process.env.BCRYPT_SALT_ROUNDS || '12'),\n },\n cookie: {\n name: process.env.COOKIE_NAME || 'arkos-token',\n maxAge: parseInt(process.env.COOKIE_MAX_AGE || '604800000'), // 7 days\n httpOnly: true,\n secure: process.env.NODE_ENV === 'production',\n sameSite: 'strict' as const,\n },\n rateLimit: {\n windowMs: parseInt(process.env.RATE_LIMIT_WINDOW || '900000'), // 15 minutes\n max: parseInt(process.env.RATE_LIMIT_MAX || '5'), // 5 attempts\n },\n email: {\n verification: {\n required: process.env.EMAIL_VERIFICATION_REQUIRED === 'true',\n expiresIn: process.env.EMAIL_VERIFICATION_EXPIRES_IN || '24h',\n },\n passwordReset: {\n expiresIn: process.env.PASSWORD_RESET_EXPIRES_IN || '1h',\n },\n },\n };\n \n export default authConfig;\n `;\n}\n\nfunction generateQueryConfigTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n return `export const ${modelName.camel}QueryOptions = {\n // Define searchable fields\n searchFields: [\n // 'name',\n // 'email',\n // 'description',\n ],\n \n // Define filterable fields\n filterFields: [\n // 'status',\n // 'type',\n // 'createdAt',\n ],\n \n // Define sortable fields\n sortFields: [\n 'id',\n 'createdAt',\n 'updatedAt',\n // Add other sortable fields\n ],\n \n // Define relations to include\n include: {\n // relationName: true,\n // relationName: {\n // select: {\n // id: true,\n // name: true,\n // }\n // }\n },\n \n // Define fields to select (if not all)\n select: {\n // id: true,\n // name: true,\n // email: true,\n // createdAt: true,\n // updatedAt: true,\n },\n \n // Default pagination\n pagination: {\n defaultLimit: 10,\n maxLimit: 100,\n },\n \n // Default sorting\n defaultSort: {\n field: 'createdAt',\n order: 'desc' as const,\n },\n };\n \n export default ${modelName.camel}QueryOptions;\n `;\n}\n\nfunction generateMiddlewareTemplate(options: TemplateOptions): string {\n const { middlewareName } = options;\n\n if (!middlewareName)\n throw new Error(\"Middleware name is required for middleware template\");\n\n return `import { Request, Response, NextFunction } from 'express';\n \n export const ${middlewareName.camel}Middleware = (\n req: Request,\n res: Response,\n next: NextFunction\n ): void => {\n try {\n // Add your middleware logic here\n console.log(\\`${middlewareName.pascal} middleware executed for \\${req.method} \\${req.path}\\`);\n \n // Continue to next middleware\n next();\n } catch (error) {\n next(error);\n }\n };\n \n export default ${middlewareName.camel}Middleware;\n `;\n}\n"]}
1
+ {"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/generators.ts"],"names":[],"mappings":";;AAoBA,4CAoBC;AAxCD,yDAAgE;AAoBhE,SAAgB,gBAAgB,CAC9B,IAAY,EACZ,UAA2B,EAAE;IAE7B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY;YACf,OAAO,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,SAAS;YACZ,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACzC,KAAK,cAAc;YACjB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,aAAa;YAChB,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;QAC9C;YACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,OAAwB;IAC1D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;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,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;;;cAGX,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\";\n\ninterface ModelName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface MiddlewareName {\n pascal: string;\n camel: string;\n kebab: string;\n}\n\ninterface TemplateOptions {\n modelName?: ModelName;\n middlewareName?: MiddlewareName;\n imports?: Record<string, string>;\n}\n\nexport function generateTemplate(\n type: string,\n options: TemplateOptions = {}\n): string {\n switch (type) {\n case \"controller\":\n return generateControllerTemplate(options);\n case \"service\":\n return generateServiceTemplate(options);\n case \"router\":\n return generateRouterTemplate(options);\n case \"auth-configs\":\n return generateAuthConfigsTemplate(options);\n case \"query-options\":\n return generateQueryOptionsTemplate(options);\n case \"middlewares\":\n return generateMiddlewaresTemplate(options);\n default:\n throw new Error(`\\n Unknown template type: ${type}`);\n }\n}\n\nfunction generateControllerTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName)\n throw new Error(\"Model name is required for controller template\");\n\n return `import { BaseController } from \"${\n imports?.baseController || \"arkos/controllers\"\n }\";\n \n class ${modelName.pascal}Controller extends BaseController {\n constructor() {\n super(\"${modelName.kebab}\");\n }\n }\n \n const ${modelName.camel}Controller = new ${modelName.pascal}Controller();\n \n export default ${modelName.camel}Controller;\n `;\n}\n\nfunction 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\nfunction 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 return `import { Router } from \"express\";\n import { createRoutes } from \"${imports?.baseRouter || \"arkos\"}\";\n import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\";\n \n const ${modelName.camel}Router = Router();\n \n // Generate CRUD routes automatically\n createRoutes(${modelName.camel}Router, ${modelName.camel}Controller);\n \n // Add custom routes here\n // ${modelName.camel}Router.get('/custom', ${\n modelName.camel\n }Controller.customMethod);\n \n export default ${modelName.camel}Router;\n `;\n}\n\nfunction generateAuthConfigsTemplate(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 auth config template\");\n\n // Generate imports for TypeScript\n const imports = isTypeScript\n ? `import { AuthConfigs } from 'arkos/prisma';\\n`\n : \"\";\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript ? `: AuthConfigs` : \"\";\n\n return `${imports}\nconst ${modelName.camel}AuthConfigs${typeAnnotation} = {\n authenticationControl: {\n // Create: true,\n // Update: true,\n // Delete: true,\n // View: false,\n },\n \n // Only when using Static RBAC\n accessControl: {\n // Create: [\"Admin\"],\n // Update: [\"Admin\", \"Manager\"],\n // Delete: [\"Admin\"],\n // View: [\"User\", \"Admin\", \"Guest\"],\n },\n};\n\nexport default ${modelName.camel}AuthConfigs;\n`;\n}\n\nfunction 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.pascal}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.pascal}>`\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\nfunction 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// 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 }\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AACjC,4CAAoB;AACpB,gDAAwB;AAEX,QAAA,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;AAC/B,QAAA,WAAW,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC;AACnC,QAAA,UAAU,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,KAAK,CAAC,CAAC;AACvC,MAAM,GAAG,GAAG,GAAG,EAAE,CACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;IAChC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU;IAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAHP,QAAA,GAAG,OAGI;AASb,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,IAAI,yBAAiB;QAAE,OAAO,yBAAiB,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAGjC,MAAM,WAAW,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QAG1E,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAGvD,IAAI,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YAChC,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,OAAO,yBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,yBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,yBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,oBAAoB,wBAyB/B","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\nexport const crd = () =>\n process.env.ARKOS_BUILD === \"true\"\n ? process.cwd() + \"/.build/\"\n : process.cwd();\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Detects the file extension that should be used in the current execution context\n * Returns 'ts' when TypeScript config exists and not in build mode, otherwise 'js'\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n const currentDir = process.cwd();\n\n // Check for tsconfig.json in current directory\n const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n // Check environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // If tsconfig exists and not in build mode, use TypeScript\n if (hasTsConfig && !isBuildMode) {\n userFileExtension = \"ts\";\n } else {\n userFileExtension = \"js\";\n }\n\n return userFileExtension;\n } catch (e) {\n // Default to js if anything goes wrong\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n"]}
1
+ {"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AACjC,4CAAoB;AACpB,gDAAwB;AAEX,QAAA,SAAS,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,IAAI,CAAC,CAAC;AAC/B,QAAA,WAAW,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,MAAM,CAAC,CAAC;AACnC,QAAA,UAAU,GAAG,IAAA,gBAAS,EAAC,YAAE,CAAC,KAAK,CAAC,CAAC;AAEvC,MAAM,GAAG,GAAG,GAAG,EAAE,CACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;IAChC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU;IAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAHP,QAAA,GAAG,OAGI;AASb,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,IAAI,yBAAiB;QAAE,OAAO,yBAAiB,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAGjC,MAAM,WAAW,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;QAG1E,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM,CAAC;QAGvD,IAAI,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YAChC,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,yBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,OAAO,yBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,yBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,yBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,oBAAoB,wBAyB/B","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\n\nexport const crd = () =>\n process.env.ARKOS_BUILD === \"true\"\n ? process.cwd() + \"/.build/\"\n : process.cwd();\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Detects the file extension that should be used in the current execution context\n * Returns 'ts' when TypeScript config exists and not in build mode, otherwise 'js'\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n const currentDir = process.cwd();\n\n // Check for tsconfig.json in current directory\n const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n // Check environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // If tsconfig exists and not in build mode, use TypeScript\n if (hasTsConfig && !isBuildMode) {\n userFileExtension = \"ts\";\n } else {\n userFileExtension = \"js\";\n }\n\n return userFileExtension;\n } catch (e) {\n // Default to js if anything goes wrong\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n"]}