arkos 1.3.0-canary.8 → 1.3.1-beta
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/exports/services/index.js.map +1 -1
- package/dist/cjs/modules/auth/auth.router.js +1 -1
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js +1 -1
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/base/types/base.service.types.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/types/auth.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-hooks-template.js +142 -96
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-hooks-template.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +4 -9
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/esm/exports/services/index.js.map +1 -1
- package/dist/esm/modules/auth/auth.router.js +1 -1
- package/dist/esm/modules/auth/auth.router.js.map +1 -1
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/base/base.service.js +1 -1
- package/dist/esm/modules/base/base.service.js.map +1 -1
- package/dist/esm/modules/base/types/base.service.types.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/esm/types/arkos-config.js.map +1 -1
- package/dist/esm/types/auth.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-hooks-template.js +142 -96
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-hooks-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +4 -9
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
- package/dist/esm/utils/helpers/prisma.helpers.js +1 -1
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/types/exports/services/index.d.ts +2 -2
- package/dist/types/modules/base/types/base.service.types.d.ts +35 -0
- package/package.json +1 -1
|
@@ -1,98 +1,144 @@
|
|
|
1
|
-
"use strict";import{getUserFileExtension as d}from"../../../../helpers/fs.helpers.js";export default function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
"use strict";import{getUserFileExtension as d}from"../../../../helpers/fs.helpers.js";export default function A(s){const{modelName:e}=s,n=d(),o=n==="ts";if(!e)throw new Error("Model name is required for hooks template");const p=o?`// import {
|
|
2
|
+
// BeforeFindOneHookArgs,
|
|
3
|
+
// AfterFindOneHookArgs,
|
|
4
|
+
// BeforeUpdateOneHookArgs,
|
|
5
|
+
// AfterUpdateOneHookArgs,
|
|
6
|
+
// BeforeCreateOneHookArgs,
|
|
7
|
+
// AfterCreateOneHookArgs,
|
|
8
|
+
// BeforeCreateManyHookArgs,
|
|
9
|
+
// AfterCreateManyHookArgs,
|
|
10
|
+
// BeforeCountHookArgs,
|
|
11
|
+
// AfterCountHookArgs,
|
|
12
|
+
// BeforeFindManyHookArgs,
|
|
13
|
+
// AfterFindManyHookArgs,
|
|
14
|
+
// BeforeUpdateManyHookArgs,
|
|
15
|
+
// AfterUpdateManyHookArgs,
|
|
16
|
+
// BeforeDeleteOneHookArgs,
|
|
17
|
+
// AfterDeleteOneHookArgs,
|
|
18
|
+
// BeforeDeleteManyHookArgs,
|
|
19
|
+
// AfterDeleteManyHookArgs,
|
|
20
|
+
// OnCreateOneErrorHookArgs,
|
|
21
|
+
// OnCreateManyErrorHookArgs,
|
|
22
|
+
// OnCountErrorHookArgs,
|
|
23
|
+
// OnFindManyErrorHookArgs,
|
|
24
|
+
// OnFindByIdErrorHookArgs,
|
|
25
|
+
// OnFindOneErrorHookArgs,
|
|
26
|
+
// OnUpdateOneErrorHookArgs,
|
|
27
|
+
// OnUpdateManyErrorHookArgs,
|
|
28
|
+
// OnDeleteOneErrorHookArgs,
|
|
29
|
+
// OnDeleteManyErrorHookArgs
|
|
30
|
+
// } from "arkos/services";`:"",l=`"../../utils/prisma${n==="ts"?"":".js"}";`,f=`"./${e.kebab}.service${n==="ts"?"":".js"}";`,c=o?`
|
|
31
|
+
export type ${e.pascal}Delegate = typeof prisma.${e.camel};`:"",i=t=>o?{beforeFindOne:`BeforeFindOneHookArgs<${e.pascal}Delegate>`,afterFindOne:`AfterFindOneHookArgs<${e.pascal}Delegate>`,beforeUpdateOne:`BeforeUpdateOneHookArgs<${e.pascal}Delegate>`,afterUpdateOne:`AfterUpdateOneHookArgs<${e.pascal}Delegate>`,beforeCreateOne:`BeforeCreateOneHookArgs<${e.pascal}Delegate>`,afterCreateOne:`AfterCreateOneHookArgs<${e.pascal}Delegate>`,beforeCreateMany:`BeforeCreateManyHookArgs<${e.pascal}Delegate>`,afterCreateMany:`AfterCreateManyHookArgs<${e.pascal}Delegate>`,beforeCount:`BeforeCountHookArgs<${e.pascal}Delegate>`,afterCount:`AfterCountHookArgs<${e.pascal}Delegate>`,beforeFindMany:`BeforeFindManyHookArgs<${e.pascal}Delegate>`,afterFindMany:`AfterFindManyHookArgs<${e.pascal}Delegate>`,beforeUpdateMany:`BeforeUpdateManyHookArgs<${e.pascal}Delegate>`,afterUpdateMany:`AfterUpdateManyHookArgs<${e.pascal}Delegate>`,beforeDeleteOne:`BeforeDeleteOneHookArgs<${e.pascal}Delegate>`,afterDeleteOne:`AfterDeleteOneHookArgs<${e.pascal}Delegate>`,beforeDeleteMany:`BeforeDeleteManyHookArgs<${e.pascal}Delegate>`,afterDeleteMany:`AfterDeleteManyHookArgs<${e.pascal}Delegate>`,onCreateOneError:`OnCreateOneErrorHookArgs<${e.pascal}Delegate>`,onCreateManyError:`OnCreateManyErrorHookArgs<${e.pascal}Delegate>`,onCountError:`OnCountErrorHookArgs<${e.pascal}Delegate>`,onFindManyError:`OnFindManyErrorHookArgs<${e.pascal}Delegate>`,onFindByIdError:`OnFindByIdErrorHookArgs<${e.pascal}Delegate>`,onFindOneError:`OnFindOneErrorHookArgs<${e.pascal}Delegate>`,onUpdateOneError:`OnUpdateOneErrorHookArgs<${e.pascal}Delegate>`,onUpdateManyError:`OnUpdateManyErrorHookArgs<${e.pascal}Delegate>`,onDeleteOneError:`OnDeleteOneErrorHookArgs<${e.pascal}Delegate>`,onDeleteManyError:`OnDeleteManyErrorHookArgs<${e.pascal}Delegate>`}[t]:"",r=(t,a)=>{const g=i(t),y=o?`{ ${a.join(", ")} }: ${g}`:`{ ${a.join(", ")} }`;return`async function ${t}(${y}) {}`},O=`
|
|
32
|
+
// export const beforeFindOne = [
|
|
33
|
+
// ${r("beforeFindOne",["context","filters","queryOptions"])}
|
|
34
|
+
// ];
|
|
35
|
+
|
|
36
|
+
// export const afterFindOne = [
|
|
37
|
+
// ${r("afterFindOne",["context","result","filters","queryOptions"])}
|
|
38
|
+
// ];
|
|
39
|
+
|
|
40
|
+
// export const onFindOneError = [
|
|
41
|
+
// ${r("onFindOneError",["context","error","filters","queryOptions"])}
|
|
42
|
+
// ];
|
|
43
|
+
|
|
44
|
+
// export const beforeUpdateOne = [
|
|
45
|
+
// ${r("beforeUpdateOne",["context","filters","data","queryOptions"])}
|
|
46
|
+
// ];
|
|
47
|
+
|
|
48
|
+
// export const afterUpdateOne = [
|
|
49
|
+
// ${r("afterUpdateOne",["context","result","filters","data","queryOptions"])}
|
|
50
|
+
// ];
|
|
51
|
+
|
|
52
|
+
// export const onUpdateOneError = [
|
|
53
|
+
// ${r("onUpdateOneError",["context","error","filters","data","queryOptions"])}
|
|
54
|
+
// ];
|
|
55
|
+
|
|
56
|
+
// export const beforeCreateOne = [
|
|
57
|
+
// ${r("beforeCreateOne",["context","data","queryOptions"])}
|
|
58
|
+
// ];
|
|
59
|
+
|
|
60
|
+
// export const afterCreateOne = [
|
|
61
|
+
// ${r("afterCreateOne",["context","result","data","queryOptions"])}
|
|
62
|
+
// ];
|
|
63
|
+
|
|
64
|
+
// export const onCreateOneError = [
|
|
65
|
+
// ${r("onCreateOneError",["context","error","data","queryOptions"])}
|
|
66
|
+
// ];
|
|
67
|
+
|
|
68
|
+
// export const beforeCreateMany = [
|
|
69
|
+
// ${r("beforeCreateMany",["context","data","queryOptions"])}
|
|
70
|
+
// ];
|
|
71
|
+
|
|
72
|
+
// export const afterCreateMany = [
|
|
73
|
+
// ${r("afterCreateMany",["context","result","queryOptions"])}
|
|
74
|
+
// ];
|
|
75
|
+
|
|
76
|
+
// export const onCreateManyError = [
|
|
77
|
+
// ${r("onCreateManyError",["context","error","data","queryOptions"])}
|
|
78
|
+
// ];
|
|
79
|
+
|
|
80
|
+
// export const beforeCount = [
|
|
81
|
+
// ${r("beforeCount",["context","filters"])}
|
|
82
|
+
// ];
|
|
83
|
+
|
|
84
|
+
// export const afterCount = [
|
|
85
|
+
// ${r("afterCount",["context","result","filters"])}
|
|
86
|
+
// ];
|
|
87
|
+
|
|
88
|
+
// export const onCountError = [
|
|
89
|
+
// ${r("onCountError",["context","error","filters"])}
|
|
90
|
+
// ];
|
|
91
|
+
|
|
92
|
+
// export const beforeFindMany = [
|
|
93
|
+
// ${r("beforeFindMany",["context","filters","queryOptions"])}
|
|
94
|
+
// ];
|
|
95
|
+
|
|
96
|
+
// export const afterFindMany = [
|
|
97
|
+
// ${r("afterFindMany",["context","result","filters","queryOptions"])}
|
|
98
|
+
// ];
|
|
99
|
+
|
|
100
|
+
// export const onFindManyError = [
|
|
101
|
+
// ${r("onFindManyError",["context","error","filters","queryOptions"])}
|
|
102
|
+
// ];
|
|
103
|
+
|
|
104
|
+
// export const beforeUpdateMany = [
|
|
105
|
+
// ${r("beforeUpdateMany",["context","filters","data","queryOptions"])}
|
|
106
|
+
// ];
|
|
107
|
+
|
|
108
|
+
// export const afterUpdateMany = [
|
|
109
|
+
// ${r("afterUpdateMany",["context","result","filters","data","queryOptions"])}
|
|
110
|
+
// ];
|
|
111
|
+
|
|
112
|
+
// export const onUpdateManyError = [
|
|
113
|
+
// ${r("onUpdateManyError",["context","error","filters","data","queryOptions"])}
|
|
114
|
+
// ];
|
|
115
|
+
|
|
116
|
+
// export const beforeDeleteOne = [
|
|
117
|
+
// ${r("beforeDeleteOne",["context","filters"])}
|
|
118
|
+
// ];
|
|
119
|
+
|
|
120
|
+
// export const afterDeleteOne = [
|
|
121
|
+
// ${r("afterDeleteOne",["context","result","filters"])}
|
|
122
|
+
// ];
|
|
123
|
+
|
|
124
|
+
// export const onDeleteOneError = [
|
|
125
|
+
// ${r("onDeleteOneError",["context","error","filters"])}
|
|
126
|
+
// ];
|
|
127
|
+
|
|
128
|
+
// export const beforeDeleteMany = [
|
|
129
|
+
// ${r("beforeDeleteMany",["context","filters"])}
|
|
130
|
+
// ];
|
|
131
|
+
|
|
132
|
+
// export const afterDeleteMany = [
|
|
133
|
+
// ${r("afterDeleteMany",["context","result","filters"])}
|
|
134
|
+
// ];
|
|
135
|
+
|
|
136
|
+
// export const onDeleteManyError = [
|
|
137
|
+
// ${r("onDeleteManyError",["context","error","filters"])}
|
|
138
|
+
// ];
|
|
139
|
+
`;return`${p}
|
|
140
|
+
// import prisma from ${l}
|
|
141
|
+
// import ${e.camel}Service from ${f}
|
|
96
142
|
${c}
|
|
97
143
|
|
|
98
|
-
${
|
|
144
|
+
${O}`}
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-hooks-template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-hooks-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-hooks-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,OAAwB;IAExB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAE7E,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;;;;;;;;;;;;;;;;;;;yBAmBmB;QACrB,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,YAAY,GAAG,sBAAsB,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC;IAE9E,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,KAAK,WAAW,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,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,SAAS,EAAE,SAAS,CAAC,CAAC;;;;IAI3D,oBAAoB,CAAC,YAAY,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;IAIpE,oBAAoB,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;;;;IAI9E,oBAAoB,CAAC,eAAe,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;;;;IAIvF,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;;;;IAIxF,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;;;;IAIjG,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;;;;IAI/D,oBAAoB,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;IAIxE,oBAAoB,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;;;;IAIhE,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;CAE5E,CAAC;IAEA,OAAO,GAAG,WAAW;qBACF,YAAY;SACxB,SAAS,CAAC,KAAK,gBAAgB,aAAa;EACnD,cAAc;;EAEd,KAAK,EAAE,CAAC;AACV,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport default function generateHooksTemplate(\n options: TemplateOptions\n): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName) throw new Error(\"Model name is required for hooks template\");\n\n const baseImports = isTypeScript\n ? `import { \n BeforeFindOneHookArgs, \n AfterFindOneHookArgs, \n BeforeUpdateOneHookArgs, \n AfterUpdateOneHookArgs,\n BeforeCreateOneHookArgs,\n AfterCreateOneHookArgs,\n BeforeCreateManyHookArgs,\n AfterCreateManyHookArgs,\n BeforeCountHookArgs,\n AfterCountHookArgs,\n BeforeFindManyHookArgs,\n AfterFindManyHookArgs,\n BeforeUpdateManyHookArgs,\n AfterUpdateManyHookArgs,\n BeforeDeleteOneHookArgs,\n AfterDeleteOneHookArgs,\n BeforeDeleteManyHookArgs,\n AfterDeleteManyHookArgs\n} from \"arkos/services\";`\n : ``;\n\n const prismaImport = `\"../../utils/prisma${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n const serviceImport = `\"./${modelName.kebab}.service${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n const delegateExport = isTypeScript\n ? `\\nexport type ${modelName.pascal}Delegate = typeof prisma.${modelName.camel};`\n : \"\";\n\n const getHookArgsType = (hookName: string) => {\n if (!isTypeScript) return \"\";\n\n const typeMap: Record<string, string> = {\n beforeFindOne: `BeforeFindOneHookArgs<${modelName.pascal}Delegate>`,\n afterFindOne: `AfterFindOneHookArgs<${modelName.pascal}Delegate>`,\n beforeUpdateOne: `BeforeUpdateOneHookArgs<${modelName.pascal}Delegate>`,\n afterUpdateOne: `AfterUpdateOneHookArgs<${modelName.pascal}Delegate>`,\n beforeCreateOne: `BeforeCreateOneHookArgs<${modelName.pascal}Delegate>`,\n afterCreateOne: `AfterCreateOneHookArgs<${modelName.pascal}Delegate>`,\n beforeCreateMany: `BeforeCreateManyHookArgs<${modelName.pascal}Delegate>`,\n afterCreateMany: `AfterCreateManyHookArgs<${modelName.pascal}Delegate>`,\n beforeCount: `BeforeCountHookArgs<${modelName.pascal}Delegate>`,\n afterCount: `AfterCountHookArgs<${modelName.pascal}Delegate>`,\n beforeFindMany: `BeforeFindManyHookArgs<${modelName.pascal}Delegate>`,\n afterFindMany: `AfterFindManyHookArgs<${modelName.pascal}Delegate>`,\n beforeUpdateMany: `BeforeUpdateManyHookArgs<${modelName.pascal}Delegate>`,\n afterUpdateMany: `AfterUpdateManyHookArgs<${modelName.pascal}Delegate>`,\n beforeDeleteOne: `BeforeDeleteOneHookArgs<${modelName.pascal}Delegate>`,\n afterDeleteOne: `AfterDeleteOneHookArgs<${modelName.pascal}Delegate>`,\n beforeDeleteMany: `BeforeDeleteManyHookArgs<${modelName.pascal}Delegate>`,\n afterDeleteMany: `AfterDeleteManyHookArgs<${modelName.pascal}Delegate>`,\n };\n\n return typeMap[hookName];\n };\n\n const generateHookFunction = (hookName: string, params: string[]) => {\n const argsType = getHookArgsType(hookName);\n const args = isTypeScript\n ? `{ ${params.join(\", \")} }: ${argsType}`\n : `{ ${params.join(\", \")} }`;\n\n return `async function ${hookName}(${args}) {}`;\n };\n\n const hooks = `\nexport const beforeFindOne = [\n ${generateHookFunction(\"beforeFindOne\", [\"context\", \"filters\", \"queryOptions\"])}\n];\n\nexport const afterFindOne = [\n ${generateHookFunction(\"afterFindOne\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n];\n\nexport const beforeUpdateOne = [\n ${generateHookFunction(\"beforeUpdateOne\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n];\n\nexport const afterUpdateOne = [\n ${generateHookFunction(\"afterUpdateOne\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n];\n\nexport const beforeCreateOne = [\n ${generateHookFunction(\"beforeCreateOne\", [\"context\", \"data\", \"queryOptions\"])}\n];\n\nexport const afterCreateOne = [\n ${generateHookFunction(\"afterCreateOne\", [\"context\", \"result\", \"data\", \"queryOptions\"])}\n];\n\nexport const beforeCreateMany = [\n ${generateHookFunction(\"beforeCreateMany\", [\"context\", \"data\", \"queryOptions\"])}\n];\n\nexport const afterCreateMany = [\n ${generateHookFunction(\"afterCreateMany\", [\"context\", \"result\", \"queryOptions\"])}\n];\n\nexport const beforeCount = [\n ${generateHookFunction(\"beforeCount\", [\"context\", \"filters\"])}\n];\n\nexport const afterCount = [\n ${generateHookFunction(\"afterCount\", [\"context\", \"result\", \"filters\"])}\n];\n\nexport const beforeFindMany = [\n ${generateHookFunction(\"beforeFindMany\", [\"context\", \"filters\", \"queryOptions\"])}\n];\n\nexport const afterFindMany = [\n ${generateHookFunction(\"afterFindMany\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n];\n\nexport const beforeUpdateMany = [\n ${generateHookFunction(\"beforeUpdateMany\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n];\n\nexport const afterUpdateMany = [\n ${generateHookFunction(\"afterUpdateMany\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n];\n\nexport const beforeDeleteOne = [\n ${generateHookFunction(\"beforeDeleteOne\", [\"context\", \"filters\"])}\n];\n\nexport const afterDeleteOne = [\n ${generateHookFunction(\"afterDeleteOne\", [\"context\", \"result\", \"filters\"])}\n];\n\nexport const beforeDeleteMany = [\n ${generateHookFunction(\"beforeDeleteMany\", [\"context\", \"filters\"])}\n];\n\nexport const afterDeleteMany = [\n ${generateHookFunction(\"afterDeleteMany\", [\"context\", \"result\", \"filters\"])}\n];\n`;\n\n return `${baseImports}\nimport prisma from ${prismaImport}\nimport ${modelName.camel}Service from ${serviceImport}\n${delegateExport}\n\n${hooks}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"generate-hooks-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-hooks-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAKtE,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,OAAwB;IAGxB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE9B,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAGlC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,2CA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S,CAAC,CAAC;;;;OAIhE,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;;;;OAIzE,oBAAoB,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;;CAEhF,CAAC;IAGA,OAAO,GAAG,WAAW;wBACC,YAAY;YACxB,SAAS,CAAC,KAAK,gBAAgB,aAAa;EACtD,cAAc;;EAEd,KAAK,EAAE,CAAC;AACV,CAAC","sourcesContent":["// Import helper function to get user's file extension preference\nimport { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\n// Import template options interface\nimport { TemplateOptions } from \"../../template-generators\";\n\n// Main function to generate hooks template based on provided options\nexport default function generateHooksTemplate(\n options: TemplateOptions\n): string {\n // Destructure modelName from options\n const { modelName } = options;\n // Get user's preferred file extension (ts or js)\n const ext = getUserFileExtension();\n // Check if user is using TypeScript\n const isTypeScript = ext === \"ts\";\n\n // Throw error if modelName is not provided\n if (!modelName) throw new Error(\"Model name is required for hooks template\");\n\n // Define base imports for TypeScript - includes all hook argument types\n const baseImports = isTypeScript\n ? `// import { \n// BeforeFindOneHookArgs, \n// AfterFindOneHookArgs, \n// BeforeUpdateOneHookArgs, \n// AfterUpdateOneHookArgs,\n// BeforeCreateOneHookArgs,\n// AfterCreateOneHookArgs,\n// BeforeCreateManyHookArgs,\n// AfterCreateManyHookArgs,\n// BeforeCountHookArgs,\n// AfterCountHookArgs,\n// BeforeFindManyHookArgs,\n// AfterFindManyHookArgs,\n// BeforeUpdateManyHookArgs,\n// AfterUpdateManyHookArgs,\n// BeforeDeleteOneHookArgs,\n// AfterDeleteOneHookArgs,\n// BeforeDeleteManyHookArgs,\n// AfterDeleteManyHookArgs,\n// OnCreateOneErrorHookArgs,\n// OnCreateManyErrorHookArgs,\n// OnCountErrorHookArgs,\n// OnFindManyErrorHookArgs,\n// OnFindByIdErrorHookArgs,\n// OnFindOneErrorHookArgs,\n// OnUpdateOneErrorHookArgs,\n// OnUpdateManyErrorHookArgs,\n// OnDeleteOneErrorHookArgs,\n// OnDeleteManyErrorHookArgs\n// } from \"arkos/services\";`\n : ``;\n\n // Define prisma import path based on file extension\n const prismaImport = `\"../../utils/prisma${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n // Define service import path based on file extension\n const serviceImport = `\"./${modelName.kebab}.service${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";`;\n\n // Export delegate type for TypeScript only\n const delegateExport = isTypeScript\n ? `\\nexport type ${modelName.pascal}Delegate = typeof prisma.${modelName.camel};`\n : \"\";\n\n // Function to get the appropriate TypeScript type for each hook\n const getHookArgsType = (hookName: string) => {\n // Return empty string for JavaScript\n if (!isTypeScript) return \"\";\n\n // Map hook names to their corresponding TypeScript types\n const typeMap: Record<string, string> = {\n beforeFindOne: `BeforeFindOneHookArgs<${modelName.pascal}Delegate>`,\n afterFindOne: `AfterFindOneHookArgs<${modelName.pascal}Delegate>`,\n beforeUpdateOne: `BeforeUpdateOneHookArgs<${modelName.pascal}Delegate>`,\n afterUpdateOne: `AfterUpdateOneHookArgs<${modelName.pascal}Delegate>`,\n beforeCreateOne: `BeforeCreateOneHookArgs<${modelName.pascal}Delegate>`,\n afterCreateOne: `AfterCreateOneHookArgs<${modelName.pascal}Delegate>`,\n beforeCreateMany: `BeforeCreateManyHookArgs<${modelName.pascal}Delegate>`,\n afterCreateMany: `AfterCreateManyHookArgs<${modelName.pascal}Delegate>`,\n beforeCount: `BeforeCountHookArgs<${modelName.pascal}Delegate>`,\n afterCount: `AfterCountHookArgs<${modelName.pascal}Delegate>`,\n beforeFindMany: `BeforeFindManyHookArgs<${modelName.pascal}Delegate>`,\n afterFindMany: `AfterFindManyHookArgs<${modelName.pascal}Delegate>`,\n beforeUpdateMany: `BeforeUpdateManyHookArgs<${modelName.pascal}Delegate>`,\n afterUpdateMany: `AfterUpdateManyHookArgs<${modelName.pascal}Delegate>`,\n beforeDeleteOne: `BeforeDeleteOneHookArgs<${modelName.pascal}Delegate>`,\n afterDeleteOne: `AfterDeleteOneHookArgs<${modelName.pascal}Delegate>`,\n beforeDeleteMany: `BeforeDeleteManyHookArgs<${modelName.pascal}Delegate>`,\n afterDeleteMany: `AfterDeleteManyHookArgs<${modelName.pascal}Delegate>`,\n // Error hook types\n onCreateOneError: `OnCreateOneErrorHookArgs<${modelName.pascal}Delegate>`,\n onCreateManyError: `OnCreateManyErrorHookArgs<${modelName.pascal}Delegate>`,\n onCountError: `OnCountErrorHookArgs<${modelName.pascal}Delegate>`,\n onFindManyError: `OnFindManyErrorHookArgs<${modelName.pascal}Delegate>`,\n onFindByIdError: `OnFindByIdErrorHookArgs<${modelName.pascal}Delegate>`,\n onFindOneError: `OnFindOneErrorHookArgs<${modelName.pascal}Delegate>`,\n onUpdateOneError: `OnUpdateOneErrorHookArgs<${modelName.pascal}Delegate>`,\n onUpdateManyError: `OnUpdateManyErrorHookArgs<${modelName.pascal}Delegate>`,\n onDeleteOneError: `OnDeleteOneErrorHookArgs<${modelName.pascal}Delegate>`,\n onDeleteManyError: `OnDeleteManyErrorHookArgs<${modelName.pascal}Delegate>`,\n };\n\n // Return the corresponding type for the hook name\n return typeMap[hookName];\n };\n\n // Function to generate a hook function with proper TypeScript types\n const generateHookFunction = (hookName: string, params: string[]) => {\n // Get the TypeScript type for this hook\n const argsType = getHookArgsType(hookName);\n // Create function parameters with or without TypeScript types\n const args = isTypeScript\n ? `{ ${params.join(\", \")} }: ${argsType}`\n : `{ ${params.join(\", \")} }`;\n\n // Return the complete function definition\n return `async function ${hookName}(${args}) {}`;\n };\n\n // Generate all hook exports with their respective functions\n const hooks = `\n// export const beforeFindOne = [\n// ${generateHookFunction(\"beforeFindOne\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindOne = [\n// ${generateHookFunction(\"afterFindOne\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindOneError = [\n// ${generateHookFunction(\"onFindOneError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateOne = [\n// ${generateHookFunction(\"beforeUpdateOne\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateOne = [\n// ${generateHookFunction(\"afterUpdateOne\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateOneError = [\n// ${generateHookFunction(\"onUpdateOneError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateOne = [\n// ${generateHookFunction(\"beforeCreateOne\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateOne = [\n// ${generateHookFunction(\"afterCreateOne\", [\"context\", \"result\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onCreateOneError = [\n// ${generateHookFunction(\"onCreateOneError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCreateMany = [\n// ${generateHookFunction(\"beforeCreateMany\", [\"context\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterCreateMany = [\n// ${generateHookFunction(\"afterCreateMany\", [\"context\", \"result\", \"queryOptions\"])}\n// ];\n\n// export const onCreateManyError = [\n// ${generateHookFunction(\"onCreateManyError\", [\"context\", \"error\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeCount = [\n// ${generateHookFunction(\"beforeCount\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterCount = [\n// ${generateHookFunction(\"afterCount\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onCountError = [\n// ${generateHookFunction(\"onCountError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeFindMany = [\n// ${generateHookFunction(\"beforeFindMany\", [\"context\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const afterFindMany = [\n// ${generateHookFunction(\"afterFindMany\", [\"context\", \"result\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const onFindManyError = [\n// ${generateHookFunction(\"onFindManyError\", [\"context\", \"error\", \"filters\", \"queryOptions\"])}\n// ];\n\n// export const beforeUpdateMany = [\n// ${generateHookFunction(\"beforeUpdateMany\", [\"context\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const afterUpdateMany = [\n// ${generateHookFunction(\"afterUpdateMany\", [\"context\", \"result\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const onUpdateManyError = [\n// ${generateHookFunction(\"onUpdateManyError\", [\"context\", \"error\", \"filters\", \"data\", \"queryOptions\"])}\n// ];\n\n// export const beforeDeleteOne = [\n// ${generateHookFunction(\"beforeDeleteOne\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteOne = [\n// ${generateHookFunction(\"afterDeleteOne\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteOneError = [\n// ${generateHookFunction(\"onDeleteOneError\", [\"context\", \"error\", \"filters\"])}\n// ];\n\n// export const beforeDeleteMany = [\n// ${generateHookFunction(\"beforeDeleteMany\", [\"context\", \"filters\"])}\n// ];\n\n// export const afterDeleteMany = [\n// ${generateHookFunction(\"afterDeleteMany\", [\"context\", \"result\", \"filters\"])}\n// ];\n\n// export const onDeleteManyError = [\n// ${generateHookFunction(\"onDeleteManyError\", [\"context\", \"error\", \"filters\"])}\n// ];\n`;\n\n // Return the complete template with imports, exports, and hook functions\n return `${baseImports}\n// import prisma from ${prismaImport}\n// import ${modelName.camel}Service from ${serviceImport}\n${delegateExport}\n\n${hooks}`;\n}\n"]}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
"use strict";import{getUserFileExtension as m}from"../../../../helpers/fs.helpers.js";export function generateServiceTemplate(
|
|
2
|
-
`:"",
|
|
1
|
+
"use strict";import{getUserFileExtension as m}from"../../../../helpers/fs.helpers.js";export function generateServiceTemplate(i){const{modelName:e,imports:s}=i,t=m(),r=t==="ts";if(!e)throw new Error("Model name is required for service template");const o=r?`"../../utils/prisma${t==="ts"?"":".js"}";
|
|
2
|
+
`:"",a=r?`import { BaseService } from "${s?.baseService||"arkos/services"}";`:`import { BaseService } from "${s?.baseService||"arkos/services"}";`,c=r?`<typeof prisma.${e.camel}>`:"";return`${r&&"import prisma from "}${o}${a}
|
|
3
3
|
|
|
4
|
-
class ${e.pascal}Service extends BaseService${
|
|
5
|
-
constructor() {
|
|
6
|
-
super("${e.kebab}");
|
|
7
|
-
}
|
|
8
|
-
// Add your custom service methods here
|
|
9
|
-
}
|
|
4
|
+
class ${e.pascal}Service extends BaseService${c} {}
|
|
10
5
|
|
|
11
|
-
const ${e.camel}Service = new ${e.pascal}Service();
|
|
6
|
+
const ${e.camel}Service = new ${e.pascal}Service("${e.kebab}");
|
|
12
7
|
|
|
13
8
|
export default ${e.camel}Service;
|
|
14
9
|
`}
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map
CHANGED
|
@@ -1 +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,sBAAsB,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM;QAC5D,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,IAAI,qBAAqB,GAAG,YAAY,GAAG,iBAAiB;;QAE5E,SAAS,CAAC,MAAM,8BAA8B,aAAa;;
|
|
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,sBAAsB,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM;QAC5D,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,IAAI,qBAAqB,GAAG,YAAY,GAAG,iBAAiB;;QAE5E,SAAS,CAAC,MAAM,8BAA8B,aAAa;;QAE3D,SAAS,CAAC,KAAK,iBAAiB,SAAS,CAAC,MAAM,YAAY,SAAS,CAAC,KAAK;;iBAElE,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 ? `\"../../utils/prisma${ext === \"ts\" ? \"\" : \".\" + \"js\"}\";\\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 `${isTypeScript && \"import prisma from \"}${prismaImport}${baseServiceImport}\n \nclass ${modelName.pascal}Service extends BaseService${typeParameter} {}\n\nconst ${modelName.camel}Service = new ${modelName.pascal}Service(\"${modelName.kebab}\");\n\nexport default ${modelName.camel}Service;\n`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import o from"fs";import i from"../../modules/error-handler/utils/app-error.js";import{crd as s,getUserFileExtension as t}from"./fs.helpers.js";import{importModule as n}from"./global.helpers.js";export let prismaInstance=null;export async function loadPrismaModule(){if(!prismaInstance)try{let r=`${s()}/src/utils/prisma.${t()}`;if(o.existsSync(r)||(r=`${s()}/src/utils/prisma/index.${t()}`),!o.existsSync(r))throw new Error(`Could not found exported prisma insteance at ${r}`);const e=await n(r,{fixExtension:!1});if(prismaInstance=e.default||e.prisma,!prismaInstance)throw new Error("Prisma not found")}catch(r){throw r.message==="Prisma not found"?new i(`Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${t()} or src/utils/prisma/index.${t()}, read more about Arkos.js Project Structure under https://www.arkosjs.com/docs/getting-started/project-structure#utilities-directory`,500,{},"PrismaInstanceNotFound"):r}return prismaInstance}export function getPrismaInstance(){return prismaInstance}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,QAAQ,MAAM,6CAA6C,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,oBAAoB,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,IAAI,cAAc,GAAQ,IAAI,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,IAAI,CAAC;YACH,IAAI,UAAU,GAAG,GAAG,GAAG,EAAE,qBAAqB,GAAG,EAAE,EAAE,CAAC;YAEtD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC5B,UAAU,GAAG,GAAG,GAAG,EAAE,2BAA2B,GAAG,EAAE,EAAE,CAAC;YAE1D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC5B,MAAM,IAAI,KAAK,CACb,gDAAgD,UAAU,EAAE,CAC7D,CAAC;YAEJ,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE;gBAClD,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;YACH,cAAc,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC;YAE7D,IAAI,CAAC,cAAc;gBAAE,MAAM,I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EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,OAAO,KAAK,kBAAkB;gBACtC,MAAM,IAAI,QAAQ,CAChB,yGAAyG,GAAG,EAAE,8BAA8B,GAAG,EAAE,uIAAuI,EACxR,GAAG,EACH,EAAE,EACF,wBAAwB,CACzB,CAAC;YACJ,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import fs from \"fs\";\nimport AppError from \"../../modules/error-handler/utils/app-error\";\nimport { crd, getUserFileExtension as ext } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\n\nexport let prismaInstance: any = null;\n\nexport async function loadPrismaModule() {\n if (!prismaInstance) {\n try {\n let prismaPath = `${crd()}/src/utils/prisma.${ext()}`;\n\n if (!fs.existsSync(prismaPath))\n prismaPath = `${crd()}/src/utils/prisma/index.${ext()}`;\n\n if (!fs.existsSync(prismaPath))\n throw new Error(\n `Could not found exported prisma insteance at ${prismaPath}`\n );\n\n const prismaModule = await importModule(prismaPath, {\n fixExtension: false,\n });\n prismaInstance = prismaModule.default || prismaModule.prisma;\n\n if (!prismaInstance) throw new Error(\"Prisma not found\");\n } catch (error: any) {\n if (error.message === \"Prisma not found\")\n throw new AppError(\n `Could not initialize Prisma module. Make sure your prisma instance is exported under src/utils/prisma.${ext()} or src/utils/prisma/index.${ext()}, read more about Arkos.js Project Structure under https://www.arkosjs.com/docs/getting-started/project-structure#utilities-directory`,\n 500,\n {},\n \"PrismaInstanceNotFound\"\n );\n throw error;\n }\n }\n return prismaInstance;\n}\n\nexport function getPrismaInstance() {\n return prismaInstance;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-json-schema-generator.js","sourceRoot":"","sources":["../../../../src/utils/prisma/prisma-json-schema-generator.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,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Q;YACb,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC;QAEF,IAAI,OAAO,CAAC,UAAU,CAAC;YAAE,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;QAEpD,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;YAAE,OAAO,QAAQ,CAAC;QAE7C,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC;YAAE,OAAO,QAAQ,CAAC;QAEtD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,MAAM,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAC;AAElE,eAAe,yBAAyB,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport { AuthPrismaQueryOptions, PrismaQueryOptions } from \"../../types\";\nimport deepmerge from \"../helpers/deepmerge.helper\";\nimport {\n getModuleComponents,\n ValidationFileMappingKey,\n} from \"../dynamic-loader\";\nimport prismaSchemaParser from \"./prisma-schema-parser\";\nimport {\n PrismaModel,\n PrismaField,\n JsonSchema,\n JsonSchemaProperty,\n} from \"./types\";\nimport { localValidatorFileExists } from \"../../modules/swagger/utils/helpers/swagger.router.helpers\";\n\n// Add these types to your existing types file\nexport interface SchemaGenerationConfig {\n modelName: string;\n arkosConfig: ArkosConfig;\n schemasToGenerate?: ValidationFileMappingKey[];\n}\n\nexport interface GeneratedSchemas {\n [key: string]: JsonSchema;\n}\n\n/**\n * Enhanced JSON Schema generator that creates schemas based on Prisma models and query options\n */\nexport class PrismaJsonSchemaGenerator {\n schema = prismaSchemaParser.parse();\n\n /**\n * Main method to generate all schemas for a model\n */\n async generateModelSchemas(\n config: SchemaGenerationConfig\n ): Promise<GeneratedSchemas> {\n const {\n modelName,\n arkosConfig,\n schemasToGenerate = [\n \"model\",\n \"login\",\n \"signup\",\n \"getMe\",\n \"updateMe\",\n \"updatePassword\",\n \"create\",\n \"createOne\",\n \"createMany\",\n \"update\",\n \"updateOne\",\n \"updateMany\",\n \"query\",\n \"findOne\",\n \"findMany\",\n ],\n } = config;\n\n const ModuleComponents = getModuleComponents(modelName);\n const routerConfig = ModuleComponents?.router?.config || {};\n const prismaQueryOptions = ModuleComponents?.prismaQueryOptions || {};\n const authModuleModel = [\"auth\", \"me\", \"password\", \"signup\", \"login\"];\n const isAuthModule = authModuleModel.includes(modelName.toLowerCase());\n\n // Check if generation should be skipped\n if (arkosConfig?.swagger?.strict && arkosConfig.swagger.mode !== \"prisma\")\n return {};\n\n // Check if router is disabled\n if (routerConfig?.disable === true) return {};\n\n const model = this.schema.models.find(\n (m) => m.name.toLowerCase() === modelName.toLowerCase()\n );\n if (!model && !isAuthModule) return {};\n // throw new Error(`Model ${modelName} not found in schema`);\n\n const schemas: { [key: string]: JsonSchema } = {};\n\n if (isAuthModule) {\n // Generate auth-specific schemas\n await this.generateAuthSchemas(\n this.schema.models.find((m) => m.name.toLowerCase() === \"user\")!,\n schemas,\n arkosConfig,\n schemasToGenerate,\n prismaQueryOptions as AuthPrismaQueryOptions<any>\n );\n } else {\n // Generate standard CRUD schemas\n if (model)\n await this.generateCrudSchemas(\n model,\n schemas,\n arkosConfig,\n schemasToGenerate,\n prismaQueryOptions as PrismaQueryOptions<any>,\n routerConfig\n );\n }\n\n return { ...schemas };\n }\n\n /**\n * Generate auth-specific schemas\n */\n private async generateAuthSchemas(\n model: PrismaModel,\n schemas: { [key: string]: JsonSchema },\n arkosConfig: ArkosConfig,\n schemasToGenerate: ValidationFileMappingKey[],\n queryOptions?: AuthPrismaQueryOptions<any>,\n routerConfig?: RouterConfig\n ) {\n const modelName = \"Auth\";\n\n // if no auth activated forget those json schemas\n if (!arkosConfig?.authentication) return schemas;\n\n // Login schema (input)\n if (\n schemasToGenerate.includes(\"login\") &&\n !this.isEndpointDisabled(\"login\", routerConfig) &&\n !(await localValidatorFileExists(\"login\", modelName, arkosConfig))\n ) {\n schemas[`LoginSchema`] = this.generateLoginSchema(arkosConfig);\n }\n\n // Signup schema (input)\n if (\n schemasToGenerate.includes(\"signup\") &&\n !this.isEndpointDisabled(\"signup\", routerConfig) &&\n !(await localValidatorFileExists(\"signup\", modelName, arkosConfig))\n ) {\n schemas[`SignupSchema`] = this.generateSignupSchema(\n model,\n queryOptions?.signup\n );\n }\n\n // UpdateMe schema (input)\n if (\n schemasToGenerate.includes(\"updateMe\") &&\n !this.isEndpointDisabled(\"updateMe\", routerConfig) &&\n !(await localValidatorFileExists(\"updateMe\", modelName, arkosConfig))\n ) {\n schemas[`UpdateMeSchema`] = this.generateUpdateMeSchema(\n model,\n queryOptions?.updateMe\n );\n }\n\n // UpdatePassword schema (input)\n if (\n schemasToGenerate.includes(\"updatePassword\") &&\n !this.isEndpointDisabled(\"updatePassword\", routerConfig) &&\n !(await localValidatorFileExists(\n \"updatePassword\",\n modelName,\n arkosConfig\n ))\n ) {\n schemas[`UpdatePasswordSchema`] = this.generateUpdatePasswordSchema(\n model,\n queryOptions?.updatePassword\n );\n }\n\n // GetMe response schema\n if (\n schemasToGenerate.includes(\"getMe\") &&\n !this.isEndpointDisabled(\"getMe\", routerConfig) &&\n !(await localValidatorFileExists(\"getMe\", modelName, arkosConfig))\n ) {\n schemas[`GetMeSchema`] = this.generateResponseSchema(\n model,\n queryOptions?.getMe || {},\n \"findOne\"\n );\n }\n }\n\n /**\n * Generate standard CRUD schemas\n */\n private async generateCrudSchemas(\n model: PrismaModel,\n schemas: { [key: string]: JsonSchema },\n arkosConfig: ArkosConfig,\n schemasToGenerate: ValidationFileMappingKey[],\n queryOptions?: PrismaQueryOptions<any>,\n routerConfig?: RouterConfig\n ) {\n const modelName = model.name;\n\n // // Create schemas\n // if (\n // schemasToGenerate.includes(\"createOne\") &&\n // !this.isEndpointDisabled(\"createOne\", routerConfig) &&\n // !(await localValidatorFileExists(\"createOne\", modelName, arkosConfig))\n // ) {\n // schemas[`Create${modelName}ModelSchema`] = this.generateCreateSchema(\n // model,\n // this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n // );\n // }\n\n // if (\n // schemasToGenerate.includes(\"createMany\") &&\n // !this.isEndpointDisabled(\"createMany\", routerConfig) &&\n // !(await localValidatorFileExists(\"createMany\", modelName, arkosConfig))\n // ) {\n // schemas[`CreateMany${modelName}ModelSchema`] = {\n // type: \"array\",\n // items: { $ref: `#/components/schemas/Create${modelName}ModelSchema` },\n // };\n // }\n\n // // Update schemas\n // if (\n // schemasToGenerate.includes(\"updateOne\") &&\n // !this.isEndpointDisabled(\"updateOne\", routerConfig) &&\n // !(await localValidatorFileExists(\"updateOne\", modelName, arkosConfig))\n // ) {\n // schemas[`Update${modelName}ModelSchema`] = this.generateUpdateSchema(\n // model,\n // this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n // );\n // }\n\n // if (\n // schemasToGenerate.includes(\"updateMany\") &&\n // !this.isEndpointDisabled(\"updateMany\", routerConfig) &&\n // !(await localValidatorFileExists(\"updateMany\", modelName, arkosConfig))\n // ) {\n // schemas[`UpdateMany${modelName}ModelSchema`] = {\n // type: \"object\",\n // properties: {\n // data: {\n // type: \"object\",\n // $ref: `#/components/schemas/Update${modelName}ModelSchema`,\n // },\n // where: { type: \"object\" },\n // },\n // required: [\"data\"],\n // };\n // }\n // Helper function to ensure base schema exists\n\n const ensureBaseSchemaReference = async (\n operation: string,\n modelName: string\n ) => {\n const suffix =\n arkosConfig.validation?.resolver === \"zod\" ? \"Schema\" : \"Dto\";\n\n // Check if local validator file exists for single operation\n const singleOpName = operation === \"Create\" ? \"createOne\" : \"updateOne\";\n const hasLocalValidator = await localValidatorFileExists(\n singleOpName,\n modelName,\n arkosConfig\n );\n\n if (hasLocalValidator) {\n // Point to local validator schema (Schema or Dto)\n return `${operation}${modelName}${suffix}`;\n } else {\n // Point to ModelSchema, generate if doesn't exist\n const modelSchemaKey = `${operation}${modelName}ModelSchema`;\n\n if (!schemas[modelSchemaKey]) {\n // Generate ModelSchema as fallback\n if (operation === \"Create\") {\n schemas[modelSchemaKey] = this.generateCreateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n );\n } else if (operation === \"Update\") {\n schemas[modelSchemaKey] = this.generateUpdateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n );\n }\n }\n\n return modelSchemaKey;\n }\n };\n\n // Create schemas (unchanged)\n if (\n schemasToGenerate.includes(\"createOne\") &&\n !this.isEndpointDisabled(\"createOne\", routerConfig) &&\n !(await localValidatorFileExists(\"createOne\", modelName, arkosConfig))\n ) {\n schemas[`Create${modelName}ModelSchema`] = this.generateCreateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n );\n }\n\n if (\n schemasToGenerate.includes(\"createMany\") &&\n !this.isEndpointDisabled(\"createMany\", routerConfig) &&\n !(await localValidatorFileExists(\"createMany\", modelName, arkosConfig))\n ) {\n // Only fix the reference\n const baseSchemaKey = await ensureBaseSchemaReference(\n \"Create\",\n modelName\n );\n schemas[`CreateMany${modelName}ModelSchema`] = {\n type: \"array\",\n items: { $ref: `#/components/schemas/${baseSchemaKey}` },\n };\n }\n\n // Update schemas (unchanged)\n if (\n schemasToGenerate.includes(\"updateOne\") &&\n !this.isEndpointDisabled(\"updateOne\", routerConfig) &&\n !(await localValidatorFileExists(\"updateOne\", modelName, arkosConfig))\n ) {\n schemas[`Update${modelName}ModelSchema`] = this.generateUpdateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n );\n }\n\n if (\n schemasToGenerate.includes(\"updateMany\") &&\n !this.isEndpointDisabled(\"updateMany\", routerConfig) &&\n !(await localValidatorFileExists(\"updateMany\", modelName, arkosConfig))\n ) {\n // Only fix the reference\n\n const baseSchemaKey = await ensureBaseSchemaReference(\n \"Update\",\n modelName\n );\n schemas[`UpdateMany${modelName}ModelSchema`] = {\n type: \"object\",\n properties: {\n data: {\n type: \"object\",\n $ref: `#/components/schemas/${baseSchemaKey}`,\n },\n where: { type: \"object\" },\n },\n required: [\"data\"],\n };\n }\n // Response schemas\n if (\n schemasToGenerate.includes(\"findOne\") &&\n !this.isEndpointDisabled(\"findOne\", routerConfig) &&\n !(await localValidatorFileExists(\"findOne\", modelName, arkosConfig))\n ) {\n schemas[`FindOne${modelName}ModelSchema`] = this.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"findOne\"),\n \"findOne\"\n );\n }\n\n if (\n schemasToGenerate.includes(\"findMany\") &&\n !this.isEndpointDisabled(\"findMany\", routerConfig) &&\n !(await localValidatorFileExists(\"findMany\", modelName, arkosConfig))\n ) {\n schemas[`FindMany${modelName}ModelSchema`] = {\n type: \"array\",\n items: this.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"findMany\"),\n \"findMany\"\n ),\n };\n }\n }\n\n /**\n * Generate create schema (excludes ID, includes relation IDs only)\n */\n private generateCreateSchema(\n model: PrismaModel,\n _: Record<string, any>\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n const restrictedFields = [\"createdAt\", \"updatedAt\", \"deletedAt\", \"id\"];\n\n if (model.name.toLowerCase() === \"auth\")\n restrictedFields.push(\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"lastLoginAt\"\n );\n\n for (const field of model.fields) {\n // Skip ID fields\n if (field.isId || restrictedFields.includes(field.name)) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // For single relations, include only the ID field\n if (!field.isArray && field.connectionField) {\n properties[field.connectionField] = {\n type: this.mapPrismaTypeToJsonSchema(\n model.fields.find(\n (_field) => _field.name === field.connectionField\n )?.type || \"String\"\n ),\n };\n\n // Check if relation ID is required\n if (!field.isOptional && field.defaultValue === undefined)\n required.push(field.name);\n }\n // Skip array relations in create schema\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n // Field is required if not optional, no default, and not array\n if (\n !field.isOptional &&\n field.defaultValue === undefined &&\n !field.isArray\n ) {\n required.push(field.name);\n }\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Generate update schema (all fields optional, includes relation IDs only)\n */\n private generateUpdateSchema(\n model: PrismaModel,\n _: Record<string, any>\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const autoFillFields = [\"createdAt\", \"updatedAt\", \"deletedAt\", \"id\"];\n\n for (const field of model.fields) {\n // Skip ID fields\n if (field.isId || autoFillFields.includes(field.name)) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // For single relations, include only the ID field\n if (!field.isArray && field.connectionField)\n properties[field.connectionField] = {\n type: this.mapPrismaTypeToJsonSchema(\n model.fields.find(\n (_field) => _field.name === field.connectionField\n )?.type || \"String\"\n ),\n };\n\n // Skip array relations in update schema\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n }\n\n return {\n type: \"object\",\n properties,\n required: [], // All fields are optional in update\n };\n }\n\n /**\n * Generate response schema (includes nested relations based on query options)\n */\n private generateResponseSchema(\n model: PrismaModel,\n options: Record<string, any>,\n _: \"findOne\" | \"findMany\"\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n\n // Get select and include options\n const selectFields = options?.select;\n const omittedFields = options?.omit;\n const includeRelations = options?.include;\n\n for (const field of model.fields) {\n // Skip password fields\n if (field.name === \"password\") continue;\n\n // Skip ommited fields\n if (omittedFields && omittedFields[field.name]) continue;\n\n // If select is specified, only include selected fields\n if (selectFields && !selectFields[field.name]) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // Include relation if specified in include option\n if (includeRelations?.[field.name]) {\n const relationModel = this.schema.models.find(\n (m) => m.name === field.type\n );\n\n if (relationModel) {\n const relationSchema = this.generateNestedRelationSchema(\n relationModel,\n includeRelations[field.name]\n );\n properties[field.name] = field.isArray\n ? { type: \"array\", items: relationSchema }\n : relationSchema;\n }\n }\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n // Field is required if not optional (for response schemas, we include all by default)\n if (!field.isOptional) required.push(field.name);\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Generate nested relation schema\n */\n private generateNestedRelationSchema(\n model: PrismaModel,\n includeOptions: any\n ): JsonSchemaProperty {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n\n // Handle nested select\n const selectFields = includeOptions?.select;\n const nestedIncludes = includeOptions?.include;\n\n for (const field of model.fields) {\n // Skip password fields\n if (field.name.toLowerCase().includes(\"password\")) {\n continue;\n }\n\n if (selectFields && !selectFields[field.name]) {\n continue;\n }\n\n if (this.isModelRelation(field.type)) {\n if (nestedIncludes?.[field.name]) {\n const relationModel = this.schema.models.find(\n (m) => m.name === field.type\n );\n if (relationModel) {\n const nestedSchema = this.generateNestedRelationSchema(\n relationModel,\n nestedIncludes[field.name]\n );\n properties[field.name] = field.isArray\n ? { type: \"array\", items: nestedSchema }\n : nestedSchema;\n }\n }\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n if (!field.isOptional) {\n required.push(field.name);\n }\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Auth-specific schema generators\n */\n private generateLoginSchema(arkosConfig?: ArkosConfig): JsonSchema {\n const userNameFields =\n arkosConfig?.authentication?.login?.allowedUsernames || [];\n\n // Helper function to get display name for nested fields\n const getDisplayName = (field: string) => {\n if (field.includes(\".\")) return field.split(\".\").pop() || field; // Get the part after the last dot\n return field;\n };\n\n // Base schema with password (always required)\n const baseSchema: JsonSchemaProperty = {\n type: \"object\",\n properties: {\n password: {\n type: \"string\",\n minLength: 8,\n },\n },\n required: [\"password\"],\n };\n\n // Add all username fields to properties\n userNameFields.forEach((field) => {\n const displayName = getDisplayName(field);\n baseSchema.properties![displayName] = {\n type: \"string\",\n format: \"string\",\n description: `Username field: ${field}`, // Optional: show original field path\n };\n });\n\n // At least one username field must be provided along with password\n if (userNameFields.length > 0) {\n const usernameDisplayNames = userNameFields.map(getDisplayName);\n\n return {\n ...baseSchema,\n anyOf: usernameDisplayNames.map(() => ({\n required: [...baseSchema.required!],\n })),\n };\n }\n\n return baseSchema;\n }\n private generateSignupSchema(\n model: PrismaModel,\n options?: Record<string, any>\n ): JsonSchema {\n // Similar to create but might have specific required fields\n const singupSchema = this.generateCreateSchema(model, options || {});\n\n const restrictedFields = [\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"lastLoginAt\",\n ];\n restrictedFields.forEach((field) => {\n delete singupSchema?.properties?.[field];\n });\n\n return singupSchema;\n }\n\n private generateUpdateMeSchema(\n model: PrismaModel,\n options?: Record<string, any>\n ): JsonSchema {\n // Similar to update but might exclude certain fields like role, etc.\n const updateSchema = this.generateUpdateSchema(model, options || {});\n\n // Remove sensitive fields that users shouldn't update themselves\n const restrictedFields = [\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"password\",\n \"lastLoginAt\",\n ];\n restrictedFields.forEach((field) => {\n delete updateSchema?.properties?.[field];\n });\n\n return updateSchema;\n }\n\n private generateUpdatePasswordSchema(\n _: PrismaModel,\n _1?: Record<string, any>\n ): JsonSchema {\n return {\n type: \"object\",\n properties: {\n currentPassword: { type: \"string\" },\n newPassword: { type: \"string\", minLength: 8 },\n },\n required: [\"currentPassword\", \"newPassword\"],\n };\n }\n\n /**\n * Utility methods\n */\n private resolvePrismaQueryOptions(\n prismaQueryOptions?: PrismaQueryOptions<any> | AuthPrismaQueryOptions<any>,\n action?: ValidationFileMappingKey\n ): Record<string, any> {\n if (!prismaQueryOptions || !action) {\n return {};\n }\n\n const options = prismaQueryOptions as any;\n const actionOptions = options[action] || {};\n\n // Start with deprecated queryOptions (for backward compatibility)\n let mergedOptions = options.queryOptions || {};\n\n // Apply global options (replaces queryOptions)\n if (options.global)\n mergedOptions = deepmerge(mergedOptions, options.global);\n\n // Apply general operation options based on action type\n const generalOptions = this.getGeneralOptionsForAction(options, action);\n if (generalOptions)\n mergedOptions = deepmerge(mergedOptions, generalOptions);\n\n // Finally apply specific action options (highest priority)\n if (actionOptions) mergedOptions = deepmerge(mergedOptions, actionOptions);\n\n return mergedOptions;\n }\n\n /**\n * Helps in remmaping those prisma query options that combines many operations for example find, save...\n */\n private getGeneralOptionsForAction(\n options: any,\n action: ValidationFileMappingKey\n ): Record<string, any> | null {\n const actionMap: { [key: string]: string[] } = {\n find: [\"findOne\", \"findMany\"],\n create: [\"createOne\", \"createMany\"],\n update: [\"updateOne\", \"updateMany\"],\n delete: [\"deleteOne\", \"deleteMany\"],\n save: [\"createOne\", \"createMany\", \"updateOne\", \"updateMany\"],\n saveOne: [\"createOne\", \"updateOne\"],\n saveMany: [\"createMany\", \"updateMany\"],\n };\n\n for (const [optionKey, actions] of Object.entries(actionMap)) {\n if (actions.includes(action) && options[optionKey]) {\n return options[optionKey];\n }\n }\n\n return null;\n }\n\n private isEndpointDisabled(\n endpoint: string,\n routerConfig?: RouterConfig\n ): boolean {\n if (!routerConfig?.disable) return false;\n\n if (typeof routerConfig.disable === \"boolean\") {\n return routerConfig.disable;\n }\n\n return (\n routerConfig.disable[endpoint as keyof typeof routerConfig.disable] ||\n false\n );\n }\n\n private isModelRelation(typeName: string): boolean {\n return this.schema.models.some((m) => m.name === typeName);\n }\n\n private convertFieldToJsonSchema(field: PrismaField): JsonSchemaProperty {\n // Reuse the existing method from the original generator\n const baseType = this.mapPrismaTypeToJsonSchema(field.type);\n const property: JsonSchemaProperty = { type: baseType };\n\n if (field.isArray) {\n property.type = \"array\";\n property.items = { type: this.mapPrismaTypeToJsonSchema(field.type) };\n }\n\n if (field.defaultValue !== undefined) {\n property.default = field.defaultValue;\n }\n\n if (field.type === \"DateTime\") {\n property.format = \"date-time\";\n }\n\n if (this.isEnum(field.type)) {\n const enumDef = this.schema.enums.find((e) => e.name === field.type);\n if (enumDef) {\n property.enum = enumDef.values;\n }\n }\n\n return property;\n }\n\n private mapPrismaTypeToJsonSchema(prismaType: string): string {\n const typeMap: { [key: string]: string } = {\n String: \"string\",\n Int: \"number\",\n Float: \"number\",\n Boolean: \"boolean\",\n DateTime: \"string\",\n Json: \"object\",\n Bytes: \"string\",\n };\n\n if (typeMap[prismaType]) return typeMap[prismaType];\n\n if (this.isEnum(prismaType)) return \"string\";\n\n if (this.isModelRelation(prismaType)) return \"object\";\n\n return \"string\";\n }\n\n private isEnum(typeName: string): boolean {\n return this.schema.enums.some((e) => e.name === typeName);\n }\n}\n\nconst prismaJsonSchemaGenerator = new PrismaJsonSchemaGenerator();\n\nexport default prismaJsonSchemaGenerator;\n"]}
|
|
1
|
+
{"version":3,"file":"prisma-json-schema-generator.js","sourceRoot":"","sources":["../../../../src/utils/prisma/prisma-json-schema-generator.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EACL,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AAOxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAgBtG,MAAM,OAAO,yBAAyB;IAAtC;QACE,WAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAuzBtC,CAAC;IAlzBC,KAAK,CAAC,oBAAoB,CACxB,MAA8B;QAE9B,MAAM,EACJ,SAAS,EACT,WAAW,EACX,iBAAi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AAQ,CAAC;QAEtD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,MAAM,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,MAAM,yBAAyB,GAAG,IAAI,yBAAyB,EAAE,CAAC;AAElE,eAAe,yBAAyB,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport { AuthPrismaQueryOptions, PrismaQueryOptions } from \"../../types\";\nimport deepmerge from \"../helpers/deepmerge.helper\";\nimport {\n getModuleComponents,\n ValidationFileMappingKey,\n} from \"../dynamic-loader\";\nimport prismaSchemaParser from \"./prisma-schema-parser\";\nimport {\n PrismaModel,\n PrismaField,\n JsonSchema,\n JsonSchemaProperty,\n} from \"./types\";\nimport { localValidatorFileExists } from \"../../modules/swagger/utils/helpers/swagger.router.helpers\";\n\n// Add these types to your existing types file\nexport interface SchemaGenerationConfig {\n modelName: string;\n arkosConfig: ArkosConfig;\n schemasToGenerate?: ValidationFileMappingKey[];\n}\n\nexport interface GeneratedSchemas {\n [key: string]: JsonSchema;\n}\n\n/**\n * Enhanced JSON Schema generator that creates schemas based on Prisma models and query options\n */\nexport class PrismaJsonSchemaGenerator {\n schema = prismaSchemaParser.parse();\n\n /**\n * Main method to generate all schemas for a model\n */\n async generateModelSchemas(\n config: SchemaGenerationConfig\n ): Promise<GeneratedSchemas> {\n const {\n modelName,\n arkosConfig,\n schemasToGenerate = [\n \"model\",\n \"login\",\n \"signup\",\n \"getMe\",\n \"updateMe\",\n \"updatePassword\",\n \"create\",\n \"createOne\",\n \"createMany\",\n \"update\",\n \"updateOne\",\n \"updateMany\",\n \"query\",\n \"findOne\",\n \"findMany\",\n ],\n } = config;\n\n const moduleComponents = getModuleComponents(modelName);\n const routerConfig = moduleComponents?.router?.config || {};\n const prismaQueryOptions = moduleComponents?.prismaQueryOptions || {};\n const authModuleModel = [\"auth\", \"me\", \"password\", \"signup\", \"login\"];\n const isAuthModule = authModuleModel.includes(modelName.toLowerCase());\n\n // Check if generation should be skipped\n if (arkosConfig?.swagger?.strict && arkosConfig.swagger.mode !== \"prisma\")\n return {};\n\n // Check if router is disabled\n if (routerConfig?.disable === true) return {};\n\n const model = this.schema.models.find(\n (m) => m.name.toLowerCase() === modelName.toLowerCase()\n );\n if (!model && !isAuthModule) return {};\n // throw new Error(`Model ${modelName} not found in schema`);\n\n const schemas: { [key: string]: JsonSchema } = {};\n\n if (isAuthModule) {\n // Generate auth-specific schemas\n await this.generateAuthSchemas(\n this.schema.models.find((m) => m.name.toLowerCase() === \"user\")!,\n schemas,\n arkosConfig,\n schemasToGenerate,\n prismaQueryOptions as AuthPrismaQueryOptions<any>\n );\n } else {\n // Generate standard CRUD schemas\n if (model)\n await this.generateCrudSchemas(\n model,\n schemas,\n arkosConfig,\n schemasToGenerate,\n prismaQueryOptions as PrismaQueryOptions<any>,\n routerConfig\n );\n }\n\n return { ...schemas };\n }\n\n /**\n * Generate auth-specific schemas\n */\n private async generateAuthSchemas(\n model: PrismaModel,\n schemas: { [key: string]: JsonSchema },\n arkosConfig: ArkosConfig,\n schemasToGenerate: ValidationFileMappingKey[],\n queryOptions?: AuthPrismaQueryOptions<any>,\n routerConfig?: RouterConfig\n ) {\n const modelName = \"Auth\";\n\n // if no auth activated forget those json schemas\n if (!arkosConfig?.authentication) return schemas;\n\n // Login schema (input)\n if (\n schemasToGenerate.includes(\"login\") &&\n !this.isEndpointDisabled(\"login\", routerConfig) &&\n !(await localValidatorFileExists(\"login\", modelName, arkosConfig))\n ) {\n schemas[`LoginSchema`] = this.generateLoginSchema(arkosConfig);\n }\n\n // Signup schema (input)\n if (\n schemasToGenerate.includes(\"signup\") &&\n !this.isEndpointDisabled(\"signup\", routerConfig) &&\n !(await localValidatorFileExists(\"signup\", modelName, arkosConfig))\n ) {\n schemas[`SignupSchema`] = this.generateSignupSchema(\n model,\n queryOptions?.signup\n );\n }\n\n // UpdateMe schema (input)\n if (\n schemasToGenerate.includes(\"updateMe\") &&\n !this.isEndpointDisabled(\"updateMe\", routerConfig) &&\n !(await localValidatorFileExists(\"updateMe\", modelName, arkosConfig))\n ) {\n schemas[`UpdateMeSchema`] = this.generateUpdateMeSchema(\n model,\n queryOptions?.updateMe\n );\n }\n\n // UpdatePassword schema (input)\n if (\n schemasToGenerate.includes(\"updatePassword\") &&\n !this.isEndpointDisabled(\"updatePassword\", routerConfig) &&\n !(await localValidatorFileExists(\n \"updatePassword\",\n modelName,\n arkosConfig\n ))\n ) {\n schemas[`UpdatePasswordSchema`] = this.generateUpdatePasswordSchema(\n model,\n queryOptions?.updatePassword\n );\n }\n\n // GetMe response schema\n if (\n schemasToGenerate.includes(\"getMe\") &&\n !this.isEndpointDisabled(\"getMe\", routerConfig) &&\n !(await localValidatorFileExists(\"getMe\", modelName, arkosConfig))\n ) {\n schemas[`GetMeSchema`] = this.generateResponseSchema(\n model,\n queryOptions?.getMe || {},\n \"findOne\"\n );\n }\n }\n\n /**\n * Generate standard CRUD schemas\n */\n private async generateCrudSchemas(\n model: PrismaModel,\n schemas: { [key: string]: JsonSchema },\n arkosConfig: ArkosConfig,\n schemasToGenerate: ValidationFileMappingKey[],\n queryOptions?: PrismaQueryOptions<any>,\n routerConfig?: RouterConfig\n ) {\n const modelName = model.name;\n\n // // Create schemas\n // if (\n // schemasToGenerate.includes(\"createOne\") &&\n // !this.isEndpointDisabled(\"createOne\", routerConfig) &&\n // !(await localValidatorFileExists(\"createOne\", modelName, arkosConfig))\n // ) {\n // schemas[`Create${modelName}ModelSchema`] = this.generateCreateSchema(\n // model,\n // this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n // );\n // }\n\n // if (\n // schemasToGenerate.includes(\"createMany\") &&\n // !this.isEndpointDisabled(\"createMany\", routerConfig) &&\n // !(await localValidatorFileExists(\"createMany\", modelName, arkosConfig))\n // ) {\n // schemas[`CreateMany${modelName}ModelSchema`] = {\n // type: \"array\",\n // items: { $ref: `#/components/schemas/Create${modelName}ModelSchema` },\n // };\n // }\n\n // // Update schemas\n // if (\n // schemasToGenerate.includes(\"updateOne\") &&\n // !this.isEndpointDisabled(\"updateOne\", routerConfig) &&\n // !(await localValidatorFileExists(\"updateOne\", modelName, arkosConfig))\n // ) {\n // schemas[`Update${modelName}ModelSchema`] = this.generateUpdateSchema(\n // model,\n // this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n // );\n // }\n\n // if (\n // schemasToGenerate.includes(\"updateMany\") &&\n // !this.isEndpointDisabled(\"updateMany\", routerConfig) &&\n // !(await localValidatorFileExists(\"updateMany\", modelName, arkosConfig))\n // ) {\n // schemas[`UpdateMany${modelName}ModelSchema`] = {\n // type: \"object\",\n // properties: {\n // data: {\n // type: \"object\",\n // $ref: `#/components/schemas/Update${modelName}ModelSchema`,\n // },\n // where: { type: \"object\" },\n // },\n // required: [\"data\"],\n // };\n // }\n // Helper function to ensure base schema exists\n\n const ensureBaseSchemaReference = async (\n operation: string,\n modelName: string\n ) => {\n const suffix =\n arkosConfig.validation?.resolver === \"zod\" ? \"Schema\" : \"Dto\";\n\n // Check if local validator file exists for single operation\n const singleOpName = operation === \"Create\" ? \"createOne\" : \"updateOne\";\n const hasLocalValidator = await localValidatorFileExists(\n singleOpName,\n modelName,\n arkosConfig\n );\n\n if (hasLocalValidator) {\n // Point to local validator schema (Schema or Dto)\n return `${operation}${modelName}${suffix}`;\n } else {\n // Point to ModelSchema, generate if doesn't exist\n const modelSchemaKey = `${operation}${modelName}ModelSchema`;\n\n if (!schemas[modelSchemaKey]) {\n // Generate ModelSchema as fallback\n if (operation === \"Create\") {\n schemas[modelSchemaKey] = this.generateCreateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n );\n } else if (operation === \"Update\") {\n schemas[modelSchemaKey] = this.generateUpdateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n );\n }\n }\n\n return modelSchemaKey;\n }\n };\n\n // Create schemas (unchanged)\n if (\n schemasToGenerate.includes(\"createOne\") &&\n !this.isEndpointDisabled(\"createOne\", routerConfig) &&\n !(await localValidatorFileExists(\"createOne\", modelName, arkosConfig))\n ) {\n schemas[`Create${modelName}ModelSchema`] = this.generateCreateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"createOne\")\n );\n }\n\n if (\n schemasToGenerate.includes(\"createMany\") &&\n !this.isEndpointDisabled(\"createMany\", routerConfig) &&\n !(await localValidatorFileExists(\"createMany\", modelName, arkosConfig))\n ) {\n // Only fix the reference\n const baseSchemaKey = await ensureBaseSchemaReference(\n \"Create\",\n modelName\n );\n schemas[`CreateMany${modelName}ModelSchema`] = {\n type: \"array\",\n items: { $ref: `#/components/schemas/${baseSchemaKey}` },\n };\n }\n\n // Update schemas (unchanged)\n if (\n schemasToGenerate.includes(\"updateOne\") &&\n !this.isEndpointDisabled(\"updateOne\", routerConfig) &&\n !(await localValidatorFileExists(\"updateOne\", modelName, arkosConfig))\n ) {\n schemas[`Update${modelName}ModelSchema`] = this.generateUpdateSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"updateOne\")\n );\n }\n\n if (\n schemasToGenerate.includes(\"updateMany\") &&\n !this.isEndpointDisabled(\"updateMany\", routerConfig) &&\n !(await localValidatorFileExists(\"updateMany\", modelName, arkosConfig))\n ) {\n // Only fix the reference\n\n const baseSchemaKey = await ensureBaseSchemaReference(\n \"Update\",\n modelName\n );\n schemas[`UpdateMany${modelName}ModelSchema`] = {\n type: \"object\",\n properties: {\n data: {\n type: \"object\",\n $ref: `#/components/schemas/${baseSchemaKey}`,\n },\n where: { type: \"object\" },\n },\n required: [\"data\"],\n };\n }\n // Response schemas\n if (\n schemasToGenerate.includes(\"findOne\") &&\n !this.isEndpointDisabled(\"findOne\", routerConfig) &&\n !(await localValidatorFileExists(\"findOne\", modelName, arkosConfig))\n ) {\n schemas[`FindOne${modelName}ModelSchema`] = this.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"findOne\"),\n \"findOne\"\n );\n }\n\n if (\n schemasToGenerate.includes(\"findMany\") &&\n !this.isEndpointDisabled(\"findMany\", routerConfig) &&\n !(await localValidatorFileExists(\"findMany\", modelName, arkosConfig))\n ) {\n schemas[`FindMany${modelName}ModelSchema`] = {\n type: \"array\",\n items: this.generateResponseSchema(\n model,\n this.resolvePrismaQueryOptions(queryOptions, \"findMany\"),\n \"findMany\"\n ),\n };\n }\n }\n\n /**\n * Generate create schema (excludes ID, includes relation IDs only)\n */\n private generateCreateSchema(\n model: PrismaModel,\n _: Record<string, any>\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n const restrictedFields = [\"createdAt\", \"updatedAt\", \"deletedAt\", \"id\"];\n\n if (model.name.toLowerCase() === \"auth\")\n restrictedFields.push(\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"lastLoginAt\"\n );\n\n for (const field of model.fields) {\n // Skip ID fields\n if (field.isId || restrictedFields.includes(field.name)) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // For single relations, include only the ID field\n if (!field.isArray && field.connectionField) {\n properties[field.connectionField] = {\n type: this.mapPrismaTypeToJsonSchema(\n model.fields.find(\n (_field) => _field.name === field.connectionField\n )?.type || \"String\"\n ),\n };\n\n // Check if relation ID is required\n if (!field.isOptional && field.defaultValue === undefined)\n required.push(field.name);\n }\n // Skip array relations in create schema\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n // Field is required if not optional, no default, and not array\n if (\n !field.isOptional &&\n field.defaultValue === undefined &&\n !field.isArray\n ) {\n required.push(field.name);\n }\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Generate update schema (all fields optional, includes relation IDs only)\n */\n private generateUpdateSchema(\n model: PrismaModel,\n _: Record<string, any>\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const autoFillFields = [\"createdAt\", \"updatedAt\", \"deletedAt\", \"id\"];\n\n for (const field of model.fields) {\n // Skip ID fields\n if (field.isId || autoFillFields.includes(field.name)) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // For single relations, include only the ID field\n if (!field.isArray && field.connectionField)\n properties[field.connectionField] = {\n type: this.mapPrismaTypeToJsonSchema(\n model.fields.find(\n (_field) => _field.name === field.connectionField\n )?.type || \"String\"\n ),\n };\n\n // Skip array relations in update schema\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n }\n\n return {\n type: \"object\",\n properties,\n required: [], // All fields are optional in update\n };\n }\n\n /**\n * Generate response schema (includes nested relations based on query options)\n */\n private generateResponseSchema(\n model: PrismaModel,\n options: Record<string, any>,\n _: \"findOne\" | \"findMany\"\n ): JsonSchema {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n\n // Get select and include options\n const selectFields = options?.select;\n const omittedFields = options?.omit;\n const includeRelations = options?.include;\n\n for (const field of model.fields) {\n // Skip password fields\n if (field.name === \"password\") continue;\n\n // Skip ommited fields\n if (omittedFields && omittedFields[field.name]) continue;\n\n // If select is specified, only include selected fields\n if (selectFields && !selectFields[field.name]) continue;\n\n // Handle relations\n if (this.isModelRelation(field.type)) {\n // Include relation if specified in include option\n if (includeRelations?.[field.name]) {\n const relationModel = this.schema.models.find(\n (m) => m.name === field.type\n );\n\n if (relationModel) {\n const relationSchema = this.generateNestedRelationSchema(\n relationModel,\n includeRelations[field.name]\n );\n properties[field.name] = field.isArray\n ? { type: \"array\", items: relationSchema }\n : relationSchema;\n }\n }\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n // Field is required if not optional (for response schemas, we include all by default)\n if (!field.isOptional) required.push(field.name);\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Generate nested relation schema\n */\n private generateNestedRelationSchema(\n model: PrismaModel,\n includeOptions: any\n ): JsonSchemaProperty {\n const properties: { [key: string]: JsonSchemaProperty } = {};\n const required: string[] = [];\n\n // Handle nested select\n const selectFields = includeOptions?.select;\n const nestedIncludes = includeOptions?.include;\n\n for (const field of model.fields) {\n // Skip password fields\n if (field.name.toLowerCase().includes(\"password\")) {\n continue;\n }\n\n if (selectFields && !selectFields[field.name]) {\n continue;\n }\n\n if (this.isModelRelation(field.type)) {\n if (nestedIncludes?.[field.name]) {\n const relationModel = this.schema.models.find(\n (m) => m.name === field.type\n );\n if (relationModel) {\n const nestedSchema = this.generateNestedRelationSchema(\n relationModel,\n nestedIncludes[field.name]\n );\n properties[field.name] = field.isArray\n ? { type: \"array\", items: nestedSchema }\n : nestedSchema;\n }\n }\n continue;\n }\n\n const property = this.convertFieldToJsonSchema(field);\n properties[field.name] = property;\n\n if (!field.isOptional) {\n required.push(field.name);\n }\n }\n\n return {\n type: \"object\",\n properties,\n required,\n };\n }\n\n /**\n * Auth-specific schema generators\n */\n private generateLoginSchema(arkosConfig?: ArkosConfig): JsonSchema {\n const userNameFields =\n arkosConfig?.authentication?.login?.allowedUsernames || [];\n\n // Helper function to get display name for nested fields\n const getDisplayName = (field: string) => {\n if (field.includes(\".\")) return field.split(\".\").pop() || field; // Get the part after the last dot\n return field;\n };\n\n // Base schema with password (always required)\n const baseSchema: JsonSchemaProperty = {\n type: \"object\",\n properties: {\n password: {\n type: \"string\",\n minLength: 8,\n },\n },\n required: [\"password\"],\n };\n\n // Add all username fields to properties\n userNameFields.forEach((field) => {\n const displayName = getDisplayName(field);\n baseSchema.properties![displayName] = {\n type: \"string\",\n format: \"string\",\n description: `Username field: ${field}`, // Optional: show original field path\n };\n });\n\n // At least one username field must be provided along with password\n if (userNameFields.length > 0) {\n const usernameDisplayNames = userNameFields.map(getDisplayName);\n\n return {\n ...baseSchema,\n anyOf: usernameDisplayNames.map(() => ({\n required: [...baseSchema.required!],\n })),\n };\n }\n\n return baseSchema;\n }\n private generateSignupSchema(\n model: PrismaModel,\n options?: Record<string, any>\n ): JsonSchema {\n // Similar to create but might have specific required fields\n const singupSchema = this.generateCreateSchema(model, options || {});\n\n const restrictedFields = [\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"lastLoginAt\",\n ];\n restrictedFields.forEach((field) => {\n delete singupSchema?.properties?.[field];\n });\n\n return singupSchema;\n }\n\n private generateUpdateMeSchema(\n model: PrismaModel,\n options?: Record<string, any>\n ): JsonSchema {\n // Similar to update but might exclude certain fields like role, etc.\n const updateSchema = this.generateUpdateSchema(model, options || {});\n\n // Remove sensitive fields that users shouldn't update themselves\n const restrictedFields = [\n \"roles\",\n \"role\",\n \"isActive\",\n \"isStaff\",\n \"isSuperUser\",\n \"passwordChangedAt\",\n \"deletedSelfAccountAt\",\n \"password\",\n \"lastLoginAt\",\n ];\n restrictedFields.forEach((field) => {\n delete updateSchema?.properties?.[field];\n });\n\n return updateSchema;\n }\n\n private generateUpdatePasswordSchema(\n _: PrismaModel,\n _1?: Record<string, any>\n ): JsonSchema {\n return {\n type: \"object\",\n properties: {\n currentPassword: { type: \"string\" },\n newPassword: { type: \"string\", minLength: 8 },\n },\n required: [\"currentPassword\", \"newPassword\"],\n };\n }\n\n /**\n * Utility methods\n */\n private resolvePrismaQueryOptions(\n prismaQueryOptions?: PrismaQueryOptions<any> | AuthPrismaQueryOptions<any>,\n action?: ValidationFileMappingKey\n ): Record<string, any> {\n if (!prismaQueryOptions || !action) {\n return {};\n }\n\n const options = prismaQueryOptions as any;\n const actionOptions = options[action] || {};\n\n // Start with deprecated queryOptions (for backward compatibility)\n let mergedOptions = options.queryOptions || {};\n\n // Apply global options (replaces queryOptions)\n if (options.global)\n mergedOptions = deepmerge(mergedOptions, options.global);\n\n // Apply general operation options based on action type\n const generalOptions = this.getGeneralOptionsForAction(options, action);\n if (generalOptions)\n mergedOptions = deepmerge(mergedOptions, generalOptions);\n\n // Finally apply specific action options (highest priority)\n if (actionOptions) mergedOptions = deepmerge(mergedOptions, actionOptions);\n\n return mergedOptions;\n }\n\n /**\n * Helps in remmaping those prisma query options that combines many operations for example find, save...\n */\n private getGeneralOptionsForAction(\n options: any,\n action: ValidationFileMappingKey\n ): Record<string, any> | null {\n const actionMap: { [key: string]: string[] } = {\n find: [\"findOne\", \"findMany\"],\n create: [\"createOne\", \"createMany\"],\n update: [\"updateOne\", \"updateMany\"],\n delete: [\"deleteOne\", \"deleteMany\"],\n save: [\"createOne\", \"createMany\", \"updateOne\", \"updateMany\"],\n saveOne: [\"createOne\", \"updateOne\"],\n saveMany: [\"createMany\", \"updateMany\"],\n };\n\n for (const [optionKey, actions] of Object.entries(actionMap)) {\n if (actions.includes(action) && options[optionKey]) {\n return options[optionKey];\n }\n }\n\n return null;\n }\n\n private isEndpointDisabled(\n endpoint: string,\n routerConfig?: RouterConfig\n ): boolean {\n if (!routerConfig?.disable) return false;\n\n if (typeof routerConfig.disable === \"boolean\") {\n return routerConfig.disable;\n }\n\n return (\n routerConfig.disable[endpoint as keyof typeof routerConfig.disable] ||\n false\n );\n }\n\n private isModelRelation(typeName: string): boolean {\n return this.schema.models.some((m) => m.name === typeName);\n }\n\n private convertFieldToJsonSchema(field: PrismaField): JsonSchemaProperty {\n // Reuse the existing method from the original generator\n const baseType = this.mapPrismaTypeToJsonSchema(field.type);\n const property: JsonSchemaProperty = { type: baseType };\n\n if (field.isArray) {\n property.type = \"array\";\n property.items = { type: this.mapPrismaTypeToJsonSchema(field.type) };\n }\n\n if (field.defaultValue !== undefined) {\n property.default = field.defaultValue;\n }\n\n if (field.type === \"DateTime\") {\n property.format = \"date-time\";\n }\n\n if (this.isEnum(field.type)) {\n const enumDef = this.schema.enums.find((e) => e.name === field.type);\n if (enumDef) {\n property.enum = enumDef.values;\n }\n }\n\n return property;\n }\n\n private mapPrismaTypeToJsonSchema(prismaType: string): string {\n const typeMap: { [key: string]: string } = {\n String: \"string\",\n Int: \"number\",\n Float: \"number\",\n Boolean: \"boolean\",\n DateTime: \"string\",\n Json: \"object\",\n Bytes: \"string\",\n };\n\n if (typeMap[prismaType]) return typeMap[prismaType];\n\n if (this.isEnum(prismaType)) return \"string\";\n\n if (this.isModelRelation(prismaType)) return \"object\";\n\n return \"string\";\n }\n\n private isEnum(typeName: string): boolean {\n return this.schema.enums.some((e) => e.name === typeName);\n }\n}\n\nconst prismaJsonSchemaGenerator = new PrismaJsonSchemaGenerator();\n\nexport default prismaJsonSchemaGenerator;\n"]}
|