arkos 1.1.92-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/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 +5 -2
- 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/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 +5 -2
- 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/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
package/dist/es2020/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
|
+
export function generateQueryOptionsTemplate(options) {
|
|
3
|
+
const { modelName } = options;
|
|
4
|
+
const isAuth = modelName?.camel === "auth";
|
|
5
|
+
const ext = getUserFileExtension();
|
|
6
|
+
const isTypeScript = ext === "ts";
|
|
7
|
+
if (!modelName)
|
|
8
|
+
throw new Error("Model name is required for query config template");
|
|
9
|
+
const imports = isAuth
|
|
10
|
+
? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
|
|
11
|
+
: `import { PrismaQueryOptions } from 'arkos/prisma'`;
|
|
12
|
+
const typeAnnotation = isTypeScript
|
|
13
|
+
? isAuth
|
|
14
|
+
? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
15
|
+
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
16
|
+
: "";
|
|
17
|
+
const prismaImport = isTypeScript
|
|
18
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
19
|
+
: "";
|
|
20
|
+
if (isAuth) {
|
|
21
|
+
return `${prismaImport}${imports};
|
|
22
|
+
|
|
23
|
+
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
24
|
+
getMe: {},
|
|
25
|
+
updateMe: {},
|
|
26
|
+
deleteMe: {},
|
|
27
|
+
login: {},
|
|
28
|
+
signup: {},
|
|
29
|
+
updatePassword: {},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ${modelName.camel}QueryOptions;
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return `${prismaImport}${imports};
|
|
37
|
+
|
|
38
|
+
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
39
|
+
// for all queries
|
|
40
|
+
queryOptions: {},
|
|
41
|
+
findOne: {},
|
|
42
|
+
findMany: {},
|
|
43
|
+
deleteMany: {},
|
|
44
|
+
updateMany: {},
|
|
45
|
+
createMany: {},
|
|
46
|
+
createOne: {},
|
|
47
|
+
updateOne: {},
|
|
48
|
+
deleteOne: {},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default ${modelName.camel}QueryOptions;
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=generate-prisma-query-options.js.map
|
|
@@ -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":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,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,oBAAoB,EAAE,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,32 @@
|
|
|
1
|
+
import pluralize from "pluralize";
|
|
2
|
+
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers";
|
|
3
|
+
export function generateRouterTemplate(options) {
|
|
4
|
+
const { modelName, imports } = options;
|
|
5
|
+
if (!modelName)
|
|
6
|
+
throw new Error("Model name is required for router template");
|
|
7
|
+
const ext = getUserFileExtension();
|
|
8
|
+
const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
|
|
9
|
+
const controllerExists = checkFileExists(controllerPath);
|
|
10
|
+
const controllerImportLine = controllerExists
|
|
11
|
+
? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
|
|
12
|
+
: `// import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`;
|
|
13
|
+
const controllerHandlerLine = controllerExists
|
|
14
|
+
? ` ${modelName.camel}Controller.someHandler`
|
|
15
|
+
: ` // ${modelName.camel}Controller.someHandler`;
|
|
16
|
+
return `import { Router } from 'express'
|
|
17
|
+
import { authService } from 'arkos/services'
|
|
18
|
+
${controllerImportLine}
|
|
19
|
+
|
|
20
|
+
const ${modelName.camel}Router = Router()
|
|
21
|
+
|
|
22
|
+
${modelName.camel}Router.post(
|
|
23
|
+
'/custom-endpoint', // resolves to /api/${pluralize(modelName.kebab)}/custom-endpoint
|
|
24
|
+
authService.authenticate,
|
|
25
|
+
authService.handleAccessControl('CustomAction', '${modelName.kebab}'),
|
|
26
|
+
${controllerHandlerLine}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export default ${modelName.camel}Router
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=generate-router-template.js.map
|
package/dist/es2020/utils/cli/utils/template-generator/templates/generate-router-template.js.map
ADDED
|
@@ -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":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,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,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,gBAAgB,GAAG,eAAe,CAAC,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,SAAS,CACjD,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,32 @@
|
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
|
+
export function generateServiceTemplate(options) {
|
|
3
|
+
const { modelName, imports } = options;
|
|
4
|
+
const ext = getUserFileExtension();
|
|
5
|
+
const isTypeScript = ext === "ts";
|
|
6
|
+
if (!modelName)
|
|
7
|
+
throw new Error("Model name is required for service template");
|
|
8
|
+
const prismaImport = isTypeScript
|
|
9
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
10
|
+
: "";
|
|
11
|
+
const baseServiceImport = isTypeScript
|
|
12
|
+
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
13
|
+
: `import { BaseService } from "${imports?.baseService || "arkos/services"}";`;
|
|
14
|
+
const typeParameter = isTypeScript
|
|
15
|
+
? `<typeof prisma.${modelName.camel}>`
|
|
16
|
+
: "";
|
|
17
|
+
return `${prismaImport}${baseServiceImport}
|
|
18
|
+
|
|
19
|
+
class ${modelName.pascal}Service extends BaseService${typeParameter} {
|
|
20
|
+
constructor() {
|
|
21
|
+
super("${modelName.kebab}");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Add your custom service methods here
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ${modelName.camel}Service = new ${modelName.pascal}Service();
|
|
28
|
+
|
|
29
|
+
export default ${modelName.camel}Service;
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=generate-service-template.js.map
|
package/dist/es2020/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":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,uBAAuB,CAAC,OAAwB;IAC9D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,GAAG,GAAG,oBAAoB,EAAE,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"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template";
|
|
2
|
+
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template";
|
|
3
|
+
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares";
|
|
4
|
+
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options";
|
|
5
|
+
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template";
|
|
6
|
+
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template";
|
|
3
7
|
export function generateTemplate(type, options = {}) {
|
|
4
8
|
switch (type) {
|
|
5
9
|
case "controller":
|
|
@@ -18,427 +22,4 @@ export function generateTemplate(type, options = {}) {
|
|
|
18
22
|
throw new Error(`\n Unknown template type: ${type}`);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
function generateControllerTemplate(options) {
|
|
22
|
-
const { modelName, imports } = options;
|
|
23
|
-
if (!modelName)
|
|
24
|
-
throw new Error("Model name is required for controller template");
|
|
25
|
-
return `import { BaseController } from "${imports?.baseController || "arkos/controllers"}";
|
|
26
|
-
|
|
27
|
-
class ${modelName.pascal}Controller extends BaseController {
|
|
28
|
-
constructor() {
|
|
29
|
-
super("${modelName.kebab}");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const ${modelName.camel}Controller = new ${modelName.pascal}Controller();
|
|
34
|
-
|
|
35
|
-
export default ${modelName.camel}Controller;
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
function generateServiceTemplate(options) {
|
|
39
|
-
const { modelName, imports } = options;
|
|
40
|
-
const ext = getUserFileExtension();
|
|
41
|
-
const isTypeScript = ext === "ts";
|
|
42
|
-
if (!modelName)
|
|
43
|
-
throw new Error("Model name is required for service template");
|
|
44
|
-
const prismaImport = isTypeScript
|
|
45
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
46
|
-
: "";
|
|
47
|
-
const baseServiceImport = isTypeScript
|
|
48
|
-
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
49
|
-
: `import { BaseService } from "${imports?.baseService || "arkos/services"}";`;
|
|
50
|
-
const typeParameter = isTypeScript
|
|
51
|
-
? `<typeof prisma.${modelName.camel}>`
|
|
52
|
-
: "";
|
|
53
|
-
return `${prismaImport}${baseServiceImport}
|
|
54
|
-
|
|
55
|
-
class ${modelName.pascal}Service extends BaseService${typeParameter} {
|
|
56
|
-
constructor() {
|
|
57
|
-
super("${modelName.kebab}");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Add your custom service methods here
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const ${modelName.camel}Service = new ${modelName.pascal}Service();
|
|
64
|
-
|
|
65
|
-
export default ${modelName.camel}Service;
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
function generateRouterTemplate(options) {
|
|
69
|
-
const { modelName, imports } = options;
|
|
70
|
-
if (!modelName)
|
|
71
|
-
throw new Error("Model name is required for router template");
|
|
72
|
-
const ext = getUserFileExtension();
|
|
73
|
-
const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
|
|
74
|
-
const controllerExists = checkFileExists(controllerPath);
|
|
75
|
-
const controllerImportLine = controllerExists
|
|
76
|
-
? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
|
|
77
|
-
: `// import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`;
|
|
78
|
-
const controllerHandlerLine = controllerExists
|
|
79
|
-
? ` ${modelName.camel}Controller.someHandler`
|
|
80
|
-
: ` // ${modelName.camel}Controller.someHandler`;
|
|
81
|
-
return `import { Router } from 'express'
|
|
82
|
-
import { authService } from 'arkos/services'
|
|
83
|
-
${controllerImportLine}
|
|
84
|
-
|
|
85
|
-
const ${modelName.camel}Router = Router()
|
|
86
|
-
|
|
87
|
-
${modelName.camel}Router.post(
|
|
88
|
-
'/custom-endpoint', // resolves to /api/${pluralize(modelName.kebab)}/custom-endpoint
|
|
89
|
-
authService.authenticate,
|
|
90
|
-
authService.handleAccessControl('CustomAction', '${modelName.kebab}'),
|
|
91
|
-
${controllerHandlerLine}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
export default ${modelName.camel}Router
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
function generateAuthConfigsTemplate(options) {
|
|
98
|
-
const { modelName } = options;
|
|
99
|
-
const ext = getUserFileExtension();
|
|
100
|
-
const isTypeScript = ext === "ts";
|
|
101
|
-
if (!modelName)
|
|
102
|
-
throw new Error("Model name is required for auth config template");
|
|
103
|
-
const imports = isTypeScript
|
|
104
|
-
? `import { AuthConfigs } from 'arkos/prisma';\n`
|
|
105
|
-
: "";
|
|
106
|
-
const typeAnnotation = isTypeScript ? `: AuthConfigs` : "";
|
|
107
|
-
return `${imports}
|
|
108
|
-
const ${modelName.camel}AuthConfigs${typeAnnotation} = {
|
|
109
|
-
authenticationControl: {
|
|
110
|
-
// Create: true,
|
|
111
|
-
// Update: true,
|
|
112
|
-
// Delete: true,
|
|
113
|
-
// View: false,
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
// Only when using Static RBAC
|
|
117
|
-
accessControl: {
|
|
118
|
-
// Create: ["Admin"],
|
|
119
|
-
// Update: ["Admin", "Manager"],
|
|
120
|
-
// Delete: ["Admin"],
|
|
121
|
-
// View: ["User", "Admin", "Guest"],
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export default ${modelName.camel}AuthConfigs;
|
|
126
|
-
`;
|
|
127
|
-
}
|
|
128
|
-
function generateQueryOptionsTemplate(options) {
|
|
129
|
-
const { modelName } = options;
|
|
130
|
-
const isAuth = modelName?.camel === "auth";
|
|
131
|
-
const ext = getUserFileExtension();
|
|
132
|
-
const isTypeScript = ext === "ts";
|
|
133
|
-
if (!modelName)
|
|
134
|
-
throw new Error("Model name is required for query config template");
|
|
135
|
-
const imports = isAuth
|
|
136
|
-
? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`
|
|
137
|
-
: `import { PrismaQueryOptions } from 'arkos/prisma'`;
|
|
138
|
-
const typeAnnotation = isTypeScript
|
|
139
|
-
? isAuth
|
|
140
|
-
? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
141
|
-
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
142
|
-
: "";
|
|
143
|
-
const prismaImport = isTypeScript
|
|
144
|
-
? `import { prisma } from "../../utils/prisma";\n`
|
|
145
|
-
: "";
|
|
146
|
-
if (isAuth) {
|
|
147
|
-
return `${prismaImport}${imports};
|
|
148
|
-
|
|
149
|
-
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
150
|
-
getMe: {},
|
|
151
|
-
updateMe: {},
|
|
152
|
-
deleteMe: {},
|
|
153
|
-
login: {},
|
|
154
|
-
signup: {},
|
|
155
|
-
updatePassword: {},
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export default ${modelName.camel}QueryOptions;
|
|
159
|
-
`;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
return `${prismaImport}${imports};
|
|
163
|
-
|
|
164
|
-
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
165
|
-
// for all queries
|
|
166
|
-
queryOptions: {},
|
|
167
|
-
findOne: {},
|
|
168
|
-
findMany: {},
|
|
169
|
-
deleteMany: {},
|
|
170
|
-
updateMany: {},
|
|
171
|
-
createMany: {},
|
|
172
|
-
createOne: {},
|
|
173
|
-
updateOne: {},
|
|
174
|
-
deleteOne: {},
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export default ${modelName.camel}QueryOptions;
|
|
178
|
-
`;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function generateMiddlewaresTemplate(options) {
|
|
182
|
-
const { modelName } = options;
|
|
183
|
-
const ext = getUserFileExtension();
|
|
184
|
-
const isTypeScript = ext === "ts";
|
|
185
|
-
if (!modelName)
|
|
186
|
-
throw new Error("Model name is required for middleware template");
|
|
187
|
-
const isAuth = modelName.camel === "auth";
|
|
188
|
-
const isFileUpload = modelName.camel === "fileUpload" || modelName.camel === "file-upload";
|
|
189
|
-
const requestType = isTypeScript ? "ArkosRequest" : "req";
|
|
190
|
-
const responseType = isTypeScript ? "ArkosResponse" : "res";
|
|
191
|
-
const nextType = isTypeScript ? "ArkosNextFunction" : "next";
|
|
192
|
-
const baseImports = isTypeScript
|
|
193
|
-
? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from "arkos";
|
|
194
|
-
import { catchAsync } from "arkos/error-handler";`
|
|
195
|
-
: `import { catchAsync } from "arkos/error-handler";`;
|
|
196
|
-
const functionParams = isTypeScript
|
|
197
|
-
? `req: ${requestType}, res: ${responseType}, next: ${nextType}`
|
|
198
|
-
: `req, res, next`;
|
|
199
|
-
if (isAuth) {
|
|
200
|
-
return `${baseImports}
|
|
201
|
-
|
|
202
|
-
// export const beforeGetMe = catchAsync(
|
|
203
|
-
// async (${functionParams}) => {
|
|
204
|
-
// // Your logic here
|
|
205
|
-
// next();
|
|
206
|
-
// }
|
|
207
|
-
// );
|
|
208
|
-
|
|
209
|
-
// export const afterGetMe = catchAsync(
|
|
210
|
-
// async (${functionParams}) => {
|
|
211
|
-
// // Your logic here
|
|
212
|
-
// next();
|
|
213
|
-
// }
|
|
214
|
-
// );
|
|
215
|
-
|
|
216
|
-
// export const beforeLogin = catchAsync(
|
|
217
|
-
// async (${functionParams}) => {
|
|
218
|
-
// // Your logic here
|
|
219
|
-
// next();
|
|
220
|
-
// }
|
|
221
|
-
// );
|
|
222
|
-
|
|
223
|
-
// export const afterLogin = catchAsync(
|
|
224
|
-
// async (${functionParams}) => {
|
|
225
|
-
// // Your logic here
|
|
226
|
-
// next();
|
|
227
|
-
// }
|
|
228
|
-
// );
|
|
229
|
-
|
|
230
|
-
// export const beforeLogout = catchAsync(
|
|
231
|
-
// async (${functionParams}) => {
|
|
232
|
-
// // Your logic here
|
|
233
|
-
// next();
|
|
234
|
-
// }
|
|
235
|
-
// );
|
|
236
|
-
|
|
237
|
-
// export const afterLogout = catchAsync(
|
|
238
|
-
// async (${functionParams}) => {
|
|
239
|
-
// // Your logic here
|
|
240
|
-
// next();
|
|
241
|
-
// }
|
|
242
|
-
// );
|
|
243
|
-
|
|
244
|
-
// export const beforeSignup = catchAsync(
|
|
245
|
-
// async (${functionParams}) => {
|
|
246
|
-
// // Your logic here
|
|
247
|
-
// next();
|
|
248
|
-
// }
|
|
249
|
-
// );
|
|
250
|
-
|
|
251
|
-
// export const afterSignup = catchAsync(
|
|
252
|
-
// async (${functionParams}) => {
|
|
253
|
-
// // Your logic here
|
|
254
|
-
// next();
|
|
255
|
-
// }
|
|
256
|
-
// );
|
|
257
|
-
|
|
258
|
-
// export const beforeUpdatePassword = catchAsync(
|
|
259
|
-
// async (${functionParams}) => {
|
|
260
|
-
// // Your logic here
|
|
261
|
-
// next();
|
|
262
|
-
// }
|
|
263
|
-
// );
|
|
264
|
-
|
|
265
|
-
// export const afterUpdatePassword = catchAsync(
|
|
266
|
-
// async (${functionParams}) => {
|
|
267
|
-
// // Your logic here
|
|
268
|
-
// next();
|
|
269
|
-
// }
|
|
270
|
-
// );
|
|
271
|
-
`;
|
|
272
|
-
}
|
|
273
|
-
if (isFileUpload) {
|
|
274
|
-
return `${baseImports}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// export const beforeFindFile = catchAsync(
|
|
278
|
-
// async (${functionParams}) => {
|
|
279
|
-
// // Your logic here
|
|
280
|
-
// next();
|
|
281
|
-
// }
|
|
282
|
-
// );
|
|
283
|
-
|
|
284
|
-
// There is not afterFindFile: because the main handler is handleded by express.static()
|
|
285
|
-
|
|
286
|
-
// export const beforeUploadFile = catchAsync(
|
|
287
|
-
// async (${functionParams}) => {
|
|
288
|
-
// // Your logic here
|
|
289
|
-
// next();
|
|
290
|
-
// }
|
|
291
|
-
// );
|
|
292
|
-
|
|
293
|
-
// export const afterUploadFile = catchAsync(
|
|
294
|
-
// async (${functionParams}) => {
|
|
295
|
-
// // Your logic here
|
|
296
|
-
// next();
|
|
297
|
-
// }
|
|
298
|
-
// );
|
|
299
|
-
|
|
300
|
-
// export const beforeUpdateFile = catchAsync(
|
|
301
|
-
// async (${functionParams}) => {
|
|
302
|
-
// // Your logic here
|
|
303
|
-
// next();
|
|
304
|
-
// }
|
|
305
|
-
// );
|
|
306
|
-
|
|
307
|
-
// export const afterUpdateFile = catchAsync(
|
|
308
|
-
// async (${functionParams}) => {
|
|
309
|
-
// // Your logic here
|
|
310
|
-
// next();
|
|
311
|
-
// }
|
|
312
|
-
// );
|
|
313
|
-
|
|
314
|
-
// export const beforeDeleteFile = catchAsync(
|
|
315
|
-
// async (${functionParams}) => {
|
|
316
|
-
// // Your logic here
|
|
317
|
-
// next();
|
|
318
|
-
// }
|
|
319
|
-
// );
|
|
320
|
-
|
|
321
|
-
// export const afterDeleteFile = catchAsync(
|
|
322
|
-
// async (${functionParams}) => {
|
|
323
|
-
// // Your logic here
|
|
324
|
-
// next();
|
|
325
|
-
// }
|
|
326
|
-
// );
|
|
327
|
-
`;
|
|
328
|
-
}
|
|
329
|
-
return `${baseImports}
|
|
330
|
-
|
|
331
|
-
// export const beforeCreateOne = catchAsync(
|
|
332
|
-
// async (${functionParams}) => {
|
|
333
|
-
// // Your logic here
|
|
334
|
-
// next();
|
|
335
|
-
// }
|
|
336
|
-
// );
|
|
337
|
-
|
|
338
|
-
// export const afterCreateOne = catchAsync(
|
|
339
|
-
// async (${functionParams}) => {
|
|
340
|
-
// // Your logic here
|
|
341
|
-
// next();
|
|
342
|
-
// }
|
|
343
|
-
// );
|
|
344
|
-
|
|
345
|
-
// export const beforeFindOne = catchAsync(
|
|
346
|
-
// async (${functionParams}) => {
|
|
347
|
-
// // Your logic here
|
|
348
|
-
// next();
|
|
349
|
-
// }
|
|
350
|
-
// );
|
|
351
|
-
|
|
352
|
-
// export const afterFindOne = catchAsync(
|
|
353
|
-
// async (${functionParams}) => {
|
|
354
|
-
// // Your logic here
|
|
355
|
-
// next();
|
|
356
|
-
// }
|
|
357
|
-
// );
|
|
358
|
-
|
|
359
|
-
// export const beforeFindMany = catchAsync(
|
|
360
|
-
// async (${functionParams}) => {
|
|
361
|
-
// // Your logic here
|
|
362
|
-
// next();
|
|
363
|
-
// }
|
|
364
|
-
// );
|
|
365
|
-
|
|
366
|
-
// export const afterFindMany = catchAsync(
|
|
367
|
-
// async (${functionParams}) => {
|
|
368
|
-
// // Your logic here
|
|
369
|
-
// next();
|
|
370
|
-
// }
|
|
371
|
-
// );
|
|
372
|
-
|
|
373
|
-
// export const beforeUpdateOne = catchAsync(
|
|
374
|
-
// async (${functionParams}) => {
|
|
375
|
-
// // Your logic here
|
|
376
|
-
// next();
|
|
377
|
-
// }
|
|
378
|
-
// );
|
|
379
|
-
|
|
380
|
-
// export const afterUpdateOne = catchAsync(
|
|
381
|
-
// async (${functionParams}) => {
|
|
382
|
-
// // Your logic here
|
|
383
|
-
// next();
|
|
384
|
-
// }
|
|
385
|
-
// );
|
|
386
|
-
|
|
387
|
-
// export const beforeDeleteOne = catchAsync(
|
|
388
|
-
// async (${functionParams}) => {
|
|
389
|
-
// // Your logic here
|
|
390
|
-
// next();
|
|
391
|
-
// }
|
|
392
|
-
// );
|
|
393
|
-
|
|
394
|
-
// export const afterDeleteOne = catchAsync(
|
|
395
|
-
// async (${functionParams}) => {
|
|
396
|
-
// // Your logic here
|
|
397
|
-
// next();
|
|
398
|
-
// }
|
|
399
|
-
// );
|
|
400
|
-
|
|
401
|
-
// export const beforeCreateMany = catchAsync(
|
|
402
|
-
// async (${functionParams}) => {
|
|
403
|
-
// // Your logic here
|
|
404
|
-
// next();
|
|
405
|
-
// }
|
|
406
|
-
// );
|
|
407
|
-
|
|
408
|
-
// export const afterCreateMany = catchAsync(
|
|
409
|
-
// async (${functionParams}) => {
|
|
410
|
-
// // Your logic here
|
|
411
|
-
// next();
|
|
412
|
-
// }
|
|
413
|
-
// );
|
|
414
|
-
|
|
415
|
-
// export const beforeUpdateMany = catchAsync(
|
|
416
|
-
// async (${functionParams}) => {
|
|
417
|
-
// // Your logic here
|
|
418
|
-
// next();
|
|
419
|
-
// }
|
|
420
|
-
// );
|
|
421
|
-
|
|
422
|
-
// export const afterUpdateMany = catchAsync(
|
|
423
|
-
// async (${functionParams}) => {
|
|
424
|
-
// // Your logic here
|
|
425
|
-
// next();
|
|
426
|
-
// }
|
|
427
|
-
// );
|
|
428
|
-
|
|
429
|
-
// export const beforeDeleteMany = catchAsync(
|
|
430
|
-
// async (${functionParams}) => {
|
|
431
|
-
// // Your logic here
|
|
432
|
-
// next();
|
|
433
|
-
// }
|
|
434
|
-
// );
|
|
435
|
-
|
|
436
|
-
// export const afterDeleteMany = catchAsync(
|
|
437
|
-
// async (${functionParams}) => {
|
|
438
|
-
// // Your logic here
|
|
439
|
-
// next();
|
|
440
|
-
// }
|
|
441
|
-
// );
|
|
442
|
-
`;
|
|
443
|
-
}
|
|
444
25
|
//# sourceMappingURL=template-generators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAoBlC,MAAM,UAAU,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,C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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 pluralize from \"pluralize\";\nimport {\n checkFileExists,\n getUserFileExtension,\n} 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 // 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\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.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\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\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"]}
|
|
1
|
+
{"version":3,"file":"template-generators.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/template-generators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,+DAA+D,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8DAA8D,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAoBnG,MAAM,UAAU,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","sourcesContent":["import { generateControllerTemplate } from \"./template-generator/templates/generate-controller-template\";\nimport { generateAuthConfigsTemplate } from \"./template-generator/templates/generate-auth-configs-template\";\nimport { generateMiddlewaresTemplate } from \"./template-generator/templates/generate-middlewares\";\nimport { generateQueryOptionsTemplate } from \"./template-generator/templates/generate-prisma-query-options\";\nimport { generateRouterTemplate } from \"./template-generator/templates/generate-router-template\";\nimport { generateServiceTemplate } from \"./template-generator/templates/generate-service-template\";\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\nexport interface 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"]}
|
|
@@ -7,6 +7,12 @@ export const mkdirAsync = promisify(fs.mkdir);
|
|
|
7
7
|
export const crd = () => process.env.ARKOS_BUILD === "true"
|
|
8
8
|
? process.cwd() + "/.build/"
|
|
9
9
|
: process.cwd();
|
|
10
|
+
export function fullCleanCwd(path) {
|
|
11
|
+
if (typeof path !== "string")
|
|
12
|
+
throw new Error("Path must be a string");
|
|
13
|
+
const cwd = process.cwd().replace(/\/+$/, "");
|
|
14
|
+
return path.replace(new RegExp(`^${cwd}/?`), "");
|
|
15
|
+
}
|
|
10
16
|
export let userFileExtension;
|
|
11
17
|
export const getUserFileExtension = () => {
|
|
12
18
|
if (userFileExtension)
|