arkos 1.2.13-beta → 1.2.13-test.1
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/app.js +138 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/modules/base/base.middlewares.js +4 -4
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/swagger/swagger.router.js +62 -43
- package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +82 -62
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +23 -16
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +40 -11
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +419 -9
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +253 -0
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +31 -20
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
- package/dist/cjs/paths.js +9 -1
- package/dist/cjs/server.js +85 -5
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/arkos-config.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +7 -7
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/start.js +4 -3
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
- package/dist/cjs/utils/features/api.features.js +1 -1
- package/dist/cjs/utils/features/api.features.js.map +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +43 -21
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js +451 -0
- package/dist/cjs/utils/prisma/enhaced-prisma-json-schema-generator.js.map +1 -0
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +88 -0
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +1 -0
- package/dist/cjs/utils/prisma/prisma-schema-parser.js +158 -0
- package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +1 -0
- package/dist/cjs/utils/prisma/types.js +3 -0
- package/dist/cjs/utils/prisma/types.js.map +1 -0
- package/dist/esm/index.d.mts +280 -0
- package/dist/esm/index.mjs +22 -0
- package/dist/exports/index.js +1 -0
- package/dist/types/arkos-config.js +1 -0
- package/dist/types/auth.js +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/modules/base/base.middlewares.d.ts +4 -4
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +2 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +2 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.d.ts +2 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.d.ts +2 -1
- package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +34 -0
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +2 -2
- package/dist/types/router-config.js +1 -0
- package/dist/types/types/arkos-config.d.ts +3 -1
- package/dist/types/utils/helpers/models.helpers.d.ts +18 -4
- package/dist/types/utils/prisma/enhaced-prisma-json-schema-generator.d.ts +34 -0
- package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +10 -0
- package/dist/types/utils/prisma/prisma-schema-parser.d.ts +18 -0
- package/dist/types/utils/prisma/types.d.ts +48 -0
- package/dist/utils/arkos-env.js +1 -0
- package/dist/utils/dotenv.helpers.js +1 -0
- package/dist/utils/sheu.js +1 -0
- package/dist/utils/validate-dto.js +1 -0
- package/dist/utils/validate-schema.js +1 -0
- package/package.json +11 -6
- package/dist/esm/app.js +0 -1
- package/dist/esm/app.js.map +0 -1
- package/dist/esm/exports/auth/index.js +0 -2
- package/dist/esm/exports/auth/index.js.map +0 -1
- package/dist/esm/exports/controllers/index.js +0 -4
- package/dist/esm/exports/controllers/index.js.map +0 -1
- package/dist/esm/exports/error-handler/index.js +0 -4
- package/dist/esm/exports/error-handler/index.js.map +0 -1
- package/dist/esm/exports/index.js +0 -8
- package/dist/esm/exports/index.js.map +0 -1
- package/dist/esm/exports/middlewares/index.js +0 -2
- package/dist/esm/exports/middlewares/index.js.map +0 -1
- package/dist/esm/exports/prisma/index.js +0 -3
- package/dist/esm/exports/prisma/index.js.map +0 -1
- package/dist/esm/exports/services/index.js +0 -9
- package/dist/esm/exports/services/index.js.map +0 -1
- package/dist/esm/exports/utils/index.js +0 -4
- package/dist/esm/exports/utils/index.js.map +0 -1
- package/dist/esm/exports/validation/index.js +0 -4
- package/dist/esm/exports/validation/index.js.map +0 -1
- package/dist/esm/modules/auth/auth.controller.js +0 -187
- package/dist/esm/modules/auth/auth.controller.js.map +0 -1
- package/dist/esm/modules/auth/auth.router.js +0 -44
- package/dist/esm/modules/auth/auth.router.js.map +0 -1
- package/dist/esm/modules/auth/auth.service.js +0 -178
- package/dist/esm/modules/auth/auth.service.js.map +0 -1
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +0 -73
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -1
- package/dist/esm/modules/base/base.controller.js +0 -150
- package/dist/esm/modules/base/base.controller.js.map +0 -1
- package/dist/esm/modules/base/base.middlewares.js +0 -81
- package/dist/esm/modules/base/base.middlewares.js.map +0 -1
- package/dist/esm/modules/base/base.router.js +0 -17
- package/dist/esm/modules/base/base.router.js.map +0 -1
- package/dist/esm/modules/base/base.service.js +0 -120
- package/dist/esm/modules/base/base.service.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +0 -77
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +0 -44
- package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +0 -89
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +0 -165
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +0 -1
- package/dist/esm/modules/email/email.service.js +0 -97
- package/dist/esm/modules/email/email.service.js.map +0 -1
- package/dist/esm/modules/error-handler/error-handler.controller.js +0 -107
- package/dist/esm/modules/error-handler/error-handler.controller.js.map +0 -1
- package/dist/esm/modules/error-handler/utils/app-error.js +0 -15
- package/dist/esm/modules/error-handler/utils/app-error.js.map +0 -1
- package/dist/esm/modules/error-handler/utils/catch-async.js +0 -10
- package/dist/esm/modules/error-handler/utils/catch-async.js.map +0 -1
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +0 -160
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +0 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +0 -266
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +0 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +0 -38
- package/dist/esm/modules/file-upload/file-upload.router.js.map +0 -1
- package/dist/esm/modules/file-upload/file-upload.service.js +0 -314
- package/dist/esm/modules/file-upload/file-upload.service.js.map +0 -1
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +0 -87
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -1
- package/dist/esm/modules/swagger/swagger.router.js +0 -94
- package/dist/esm/modules/swagger/swagger.router.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -247
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -63
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -38
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -19
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +0 -24
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +0 -436
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +0 -159
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -84
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
- package/dist/esm/paths.js +0 -1
- package/dist/esm/paths.js.map +0 -1
- package/dist/esm/server.js +0 -5
- package/dist/esm/server.js.map +0 -1
- package/dist/esm/types/arkos-config.js +0 -2
- package/dist/esm/types/arkos-config.js.map +0 -1
- package/dist/esm/types/auth.js +0 -2
- package/dist/esm/types/auth.js.map +0 -1
- package/dist/esm/types/index.js +0 -8
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/router-config.js +0 -2
- package/dist/esm/types/router-config.js.map +0 -1
- package/dist/esm/utils/arkos-env.js +0 -7
- package/dist/esm/utils/arkos-env.js.map +0 -1
- package/dist/esm/utils/cli/build.js +0 -206
- package/dist/esm/utils/cli/build.js.map +0 -1
- package/dist/esm/utils/cli/dev.js +0 -249
- package/dist/esm/utils/cli/dev.js.map +0 -1
- package/dist/esm/utils/cli/generate.js +0 -183
- package/dist/esm/utils/cli/generate.js.map +0 -1
- package/dist/esm/utils/cli/index.js +0 -74
- package/dist/esm/utils/cli/index.js.map +0 -1
- package/dist/esm/utils/cli/start.js +0 -86
- package/dist/esm/utils/cli/start.js.map +0 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +0 -16
- package/dist/esm/utils/cli/utils/cli.helpers.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +0 -33
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -18
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +0 -232
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +0 -61
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +0 -37
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +0 -32
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generators.js +0 -25
- package/dist/esm/utils/cli/utils/template-generators.js.map +0 -1
- package/dist/esm/utils/dotenv.helpers.js +0 -37
- package/dist/esm/utils/dotenv.helpers.js.map +0 -1
- package/dist/esm/utils/features/api.features.js +0 -160
- package/dist/esm/utils/features/api.features.js.map +0 -1
- package/dist/esm/utils/features/change-case.features.js +0 -31
- package/dist/esm/utils/features/change-case.features.js.map +0 -1
- package/dist/esm/utils/helpers/api.features.helpers.js +0 -103
- package/dist/esm/utils/helpers/api.features.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/change-case.helpers.js +0 -161
- package/dist/esm/utils/helpers/change-case.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/deepmerge.helper.js +0 -113
- package/dist/esm/utils/helpers/deepmerge.helper.js.map +0 -1
- package/dist/esm/utils/helpers/fs.helpers.js +0 -52
- package/dist/esm/utils/helpers/fs.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/global.helpers.js +0 -47
- package/dist/esm/utils/helpers/global.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/models.helpers.js +0 -300
- package/dist/esm/utils/helpers/models.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/prisma.helpers.js +0 -44
- package/dist/esm/utils/helpers/prisma.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/query-parser.helpers.js +0 -40
- package/dist/esm/utils/helpers/query-parser.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/routers.helpers.js +0 -16
- package/dist/esm/utils/helpers/routers.helpers.js.map +0 -1
- package/dist/esm/utils/helpers/text.helpers.js +0 -22
- package/dist/esm/utils/helpers/text.helpers.js.map +0 -1
- package/dist/esm/utils/sheu.js +0 -117
- package/dist/esm/utils/sheu.js.map +0 -1
- package/dist/esm/utils/validate-dto.js +0 -11
- package/dist/esm/utils/validate-dto.js.map +0 -1
- package/dist/esm/utils/validate-schema.js +0 -9
- package/dist/esm/utils/validate-schema.js.map +0 -1
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
function isMergeableObject(value) {
|
|
2
|
-
return isNonNullObject(value) && !isSpecial(value);
|
|
3
|
-
}
|
|
4
|
-
function isNonNullObject(value) {
|
|
5
|
-
return !!value && typeof value === "object";
|
|
6
|
-
}
|
|
7
|
-
function isSpecial(value) {
|
|
8
|
-
const stringValue = Object.prototype.toString.call(value);
|
|
9
|
-
return stringValue === "[object RegExp]" || stringValue === "[object Date]";
|
|
10
|
-
}
|
|
11
|
-
function emptyTarget(val) {
|
|
12
|
-
return Array.isArray(val) ? [] : {};
|
|
13
|
-
}
|
|
14
|
-
function getKeys(target) {
|
|
15
|
-
const objectKeys = Object.keys(target);
|
|
16
|
-
const symbolKeys = getEnumerableOwnPropertySymbols(target);
|
|
17
|
-
return [...objectKeys, ...symbolKeys];
|
|
18
|
-
}
|
|
19
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
20
|
-
return Object.getOwnPropertySymbols
|
|
21
|
-
? Object.getOwnPropertySymbols(target).filter(function (symbol) {
|
|
22
|
-
return Object.propertyIsEnumerable.call(target, symbol);
|
|
23
|
-
})
|
|
24
|
-
: [];
|
|
25
|
-
}
|
|
26
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
27
|
-
return options.clone !== false && options.isMergeableObject?.(value)
|
|
28
|
-
? deepmerge(emptyTarget(value), value, options)
|
|
29
|
-
: value;
|
|
30
|
-
}
|
|
31
|
-
function defaultArrayMerge(target, source, options) {
|
|
32
|
-
return target.concat(source).map(function (element) {
|
|
33
|
-
return options.cloneUnlessOtherwiseSpecified(element, options);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function getMergeFunction(key, options) {
|
|
37
|
-
if (!options.customMerge) {
|
|
38
|
-
return deepmerge;
|
|
39
|
-
}
|
|
40
|
-
const customMerge = options.customMerge(key);
|
|
41
|
-
return typeof customMerge === "function" ? customMerge : deepmerge;
|
|
42
|
-
}
|
|
43
|
-
function propertyIsOnObject(object, property) {
|
|
44
|
-
try {
|
|
45
|
-
return property in object;
|
|
46
|
-
}
|
|
47
|
-
catch (_) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function propertyIsUnsafe(target, key) {
|
|
52
|
-
return (propertyIsOnObject(target, key) &&
|
|
53
|
-
!(Object.hasOwnProperty.call(target, key) &&
|
|
54
|
-
Object.propertyIsEnumerable.call(target, key)));
|
|
55
|
-
}
|
|
56
|
-
function mergeObject(target, source, options) {
|
|
57
|
-
const destination = {};
|
|
58
|
-
if (options.isMergeableObject?.(target)) {
|
|
59
|
-
getKeys(target).forEach(function (key) {
|
|
60
|
-
destination[key] = options.cloneUnlessOtherwiseSpecified
|
|
61
|
-
? options.cloneUnlessOtherwiseSpecified(target[key], options)
|
|
62
|
-
: target[key];
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
getKeys(source).forEach(function (key) {
|
|
66
|
-
if (propertyIsUnsafe(target, key)) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (propertyIsOnObject(target, key) &&
|
|
70
|
-
options.isMergeableObject?.(source[key])) {
|
|
71
|
-
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
destination[key] = options.cloneUnlessOtherwiseSpecified
|
|
75
|
-
? options.cloneUnlessOtherwiseSpecified(source[key], options)
|
|
76
|
-
: source[key];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return destination;
|
|
80
|
-
}
|
|
81
|
-
function deepmerge(target, source, options) {
|
|
82
|
-
options = options || {};
|
|
83
|
-
const mergeOptions = {
|
|
84
|
-
arrayMerge: options.arrayMerge || defaultArrayMerge,
|
|
85
|
-
isMergeableObject: options.isMergeableObject || isMergeableObject,
|
|
86
|
-
cloneUnlessOtherwiseSpecified: options.cloneUnlessOtherwiseSpecified || cloneUnlessOtherwiseSpecified,
|
|
87
|
-
clone: options.clone,
|
|
88
|
-
customMerge: options.customMerge,
|
|
89
|
-
};
|
|
90
|
-
const sourceIsArray = Array.isArray(source);
|
|
91
|
-
const targetIsArray = Array.isArray(target);
|
|
92
|
-
const sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
93
|
-
if (!sourceAndTargetTypesMatch) {
|
|
94
|
-
return mergeOptions.cloneUnlessOtherwiseSpecified(source, mergeOptions);
|
|
95
|
-
}
|
|
96
|
-
else if (sourceIsArray) {
|
|
97
|
-
return mergeOptions.arrayMerge?.(target, source, mergeOptions);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
return mergeObject(target, source, mergeOptions);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function deepmergeAll(array, options) {
|
|
104
|
-
if (!Array.isArray(array)) {
|
|
105
|
-
throw new Error("first argument should be an array");
|
|
106
|
-
}
|
|
107
|
-
return array.reduce((prev, next) => {
|
|
108
|
-
return deepmerge(prev, next, options);
|
|
109
|
-
}, {});
|
|
110
|
-
}
|
|
111
|
-
deepmerge.all = deepmergeAll;
|
|
112
|
-
export default deepmerge;
|
|
113
|
-
//# sourceMappingURL=deepmerge.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepmerge.helper.js","sourceRoot":"","sources":["../../../../src/utils/helpers/deepmerge.helper.ts"],"names":[],"mappings":"AAqBA,SAAS,iBAAiB,CAAC,KAAU;IACnC,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,eAAe,CAAC,KAAU;IACjC,O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W,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC;IAEF,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,yBAAyB,GAAG,aAAa,KAAK,aAAa,CAAC;IAElE,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC/B,OAAO,YAAY,CAAC,6BAA6B,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1E,CAAC;SAAM,IAAI,aAAa,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CACnB,KAAuB,EACvB,OAA2B;IAE3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACjC,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,EAAE,EAAO,CAAC,CAAC;AACd,CAAC;AAED,SAAS,CAAC,GAAG,GAAG,YAAY,CAAC;AAE7B,eAAe,SAAS,CAAC","sourcesContent":["declare namespace deepmerge {\n export interface Options {\n arrayMerge?(\n target: any[],\n source: any[],\n options?: ArrayMergeOptions\n ): any[];\n clone?: boolean;\n customMerge?: (\n key: string,\n options?: Options\n ) => ((x: any, y: any) => any) | undefined;\n isMergeableObject?(value: object): boolean;\n cloneUnlessOtherwiseSpecified?(value: any, options?: Options): any;\n }\n\n export interface ArrayMergeOptions extends Options {\n cloneUnlessOtherwiseSpecified(value: any, options?: Options): any;\n }\n}\n\nfunction isMergeableObject(value: any): boolean {\n return isNonNullObject(value) && !isSpecial(value);\n}\n\nfunction isNonNullObject(value: any): boolean {\n return !!value && typeof value === \"object\";\n}\n\nfunction isSpecial(value: any): boolean {\n const stringValue = Object.prototype.toString.call(value);\n\n return stringValue === \"[object RegExp]\" || stringValue === \"[object Date]\";\n}\n\nfunction emptyTarget(val: any): any {\n return Array.isArray(val) ? [] : {};\n}\n\nfunction getKeys(target: any): (string | symbol)[] {\n const objectKeys = Object.keys(target);\n const symbolKeys = getEnumerableOwnPropertySymbols(target);\n return [...objectKeys, ...symbolKeys];\n}\n\nfunction getEnumerableOwnPropertySymbols(target: any): symbol[] {\n return Object.getOwnPropertySymbols\n ? Object.getOwnPropertySymbols(target).filter(function (symbol) {\n return Object.propertyIsEnumerable.call(target, symbol);\n })\n : [];\n}\n\nfunction cloneUnlessOtherwiseSpecified(\n value: any,\n options: deepmerge.Options\n): any {\n return options.clone !== false && options.isMergeableObject?.(value)\n ? deepmerge(emptyTarget(value), value, options)\n : value;\n}\n\nfunction defaultArrayMerge(\n target: any[],\n source: any[],\n options: deepmerge.ArrayMergeOptions\n): any[] {\n return target.concat(source).map(function (element) {\n return options.cloneUnlessOtherwiseSpecified(element, options);\n });\n}\n\nfunction getMergeFunction(\n key: string,\n options: deepmerge.Options\n): (x: any, y: any, options?: deepmerge.Options) => any {\n if (!options.customMerge) {\n return deepmerge;\n }\n const customMerge = options.customMerge(key);\n return typeof customMerge === \"function\" ? customMerge : deepmerge;\n}\n\nfunction propertyIsOnObject(object: any, property: string | symbol): boolean {\n try {\n return property in object;\n } catch (_) {\n return false;\n }\n}\n\nfunction propertyIsUnsafe(target: any, key: string | symbol): boolean {\n return (\n propertyIsOnObject(target, key) &&\n !(\n Object.hasOwnProperty.call(target, key) &&\n Object.propertyIsEnumerable.call(target, key)\n )\n );\n}\n\nfunction mergeObject(\n target: any,\n source: any,\n options: deepmerge.Options\n): any {\n const destination: any = {};\n if (options.isMergeableObject?.(target)) {\n getKeys(target).forEach(function (key) {\n destination[key] = options.cloneUnlessOtherwiseSpecified\n ? options.cloneUnlessOtherwiseSpecified(target[key], options)\n : target[key];\n });\n }\n getKeys(source).forEach(function (key) {\n if (propertyIsUnsafe(target, key)) {\n return;\n }\n\n if (\n propertyIsOnObject(target, key) &&\n options.isMergeableObject?.(source[key])\n ) {\n destination[key] = getMergeFunction(key as string, options)(\n target[key],\n source[key],\n options\n );\n } else {\n destination[key] = options.cloneUnlessOtherwiseSpecified\n ? options.cloneUnlessOtherwiseSpecified(source[key], options)\n : source[key];\n }\n });\n return destination;\n}\n\nfunction deepmerge<T>(\n target: Partial<T>,\n source: Partial<T>,\n options?: deepmerge.Options\n): T;\nfunction deepmerge<T1, T2>(\n target: Partial<T1>,\n source: Partial<T2>,\n options?: deepmerge.Options\n): T1 & T2;\nfunction deepmerge(target: any, source: any, options?: deepmerge.Options): any {\n options = options || {};\n\n // Ensure default implementations\n const mergeOptions: deepmerge.ArrayMergeOptions = {\n arrayMerge: options.arrayMerge || defaultArrayMerge,\n isMergeableObject: options.isMergeableObject || isMergeableObject,\n cloneUnlessOtherwiseSpecified:\n options.cloneUnlessOtherwiseSpecified || cloneUnlessOtherwiseSpecified,\n clone: options.clone,\n customMerge: options.customMerge,\n };\n\n const sourceIsArray = Array.isArray(source);\n const targetIsArray = Array.isArray(target);\n const sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n if (!sourceAndTargetTypesMatch) {\n return mergeOptions.cloneUnlessOtherwiseSpecified(source, mergeOptions);\n } else if (sourceIsArray) {\n return mergeOptions.arrayMerge?.(target, source, mergeOptions);\n } else {\n return mergeObject(target, source, mergeOptions);\n }\n}\n\nfunction deepmergeAll<T extends Record<string, any> = Record<string, any>>(\n array: ReadonlyArray<T>,\n options?: deepmerge.Options\n): T {\n if (!Array.isArray(array)) {\n throw new Error(\"first argument should be an array\");\n }\n\n return array.reduce((prev, next) => {\n return deepmerge(prev, next, options);\n }, {} as T);\n}\n\ndeepmerge.all = deepmergeAll;\n\nexport default deepmerge;\n"]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { promisify } from "util";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
export const statAsync = promisify(fs.stat);
|
|
5
|
-
export const accessAsync = promisify(fs.access);
|
|
6
|
-
export const mkdirAsync = promisify(fs.mkdir);
|
|
7
|
-
export const crd = () => process.env.ARKOS_BUILD === "true"
|
|
8
|
-
? process.cwd() + "/.build/"
|
|
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
|
-
const escapedCwd = cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
-
return path.replace(new RegExp(`${escapedCwd}/?`, "g"), "");
|
|
16
|
-
}
|
|
17
|
-
export let userFileExtension;
|
|
18
|
-
export const getUserFileExtension = () => {
|
|
19
|
-
if (userFileExtension)
|
|
20
|
-
return userFileExtension;
|
|
21
|
-
try {
|
|
22
|
-
const currentDir = process.cwd();
|
|
23
|
-
const hasTsConfig = fs.existsSync(path.join(currentDir, "tsconfig.json"));
|
|
24
|
-
const hasAppTs = fs.existsSync(path.join(currentDir, "src", "app.ts"));
|
|
25
|
-
const hasAppJs = fs.existsSync(path.join(currentDir, "src", "app.js"));
|
|
26
|
-
const isBuildMode = process.env.ARKOS_BUILD === "true";
|
|
27
|
-
if (isBuildMode)
|
|
28
|
-
userFileExtension = "js";
|
|
29
|
-
else if (hasTsConfig)
|
|
30
|
-
userFileExtension = "ts";
|
|
31
|
-
else if (hasAppTs && !hasAppJs)
|
|
32
|
-
userFileExtension = "ts";
|
|
33
|
-
else if (hasAppJs)
|
|
34
|
-
userFileExtension = "js";
|
|
35
|
-
else
|
|
36
|
-
userFileExtension = "js";
|
|
37
|
-
return userFileExtension;
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
userFileExtension = "js";
|
|
41
|
-
return userFileExtension;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export function checkFileExists(filePath) {
|
|
45
|
-
try {
|
|
46
|
-
return fs.existsSync(path.resolve(filePath));
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=fs.helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,CACtB,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;IAChC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,UAAU;IAC5B,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAQpB,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAEvE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EA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C;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC;AAgBF,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\nimport path from \"path\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\n\nexport const crd = () =>\n process.env.ARKOS_BUILD === \"true\"\n ? process.cwd() + \"/.build/\"\n : process.cwd();\n\n/**\n * Removes the current working directory prefix from the given path.\n * Handles cases with or without a trailing slash in cwd.\n * @param path - The path to clean\n * @returns The path without the cwd prefix\n */\nexport function fullCleanCwd(path: string): string {\n if (typeof path !== \"string\") throw new Error(\"Path must be a string\");\n\n const cwd = process.cwd().replace(/\\/+$/, \"\"); // remove trailing slashes\n const escapedCwd = cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"); // escape regex special chars\n\n return path.replace(new RegExp(`${escapedCwd}/?`, \"g\"), \"\"); // remove cwd + optional slash\n}\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Detects the file extension that should be used in the current execution context\n * Returns 'ts' when TypeScript config exists and not in build mode, otherwise 'js'\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n const currentDir = process.cwd();\n\n // Check for tsconfig.json in current directory\n const hasTsConfig = fs.existsSync(path.join(currentDir, \"tsconfig.json\"));\n\n // Check for main app files\n const hasAppTs = fs.existsSync(path.join(currentDir, \"src\", \"app.ts\"));\n const hasAppJs = fs.existsSync(path.join(currentDir, \"src\", \"app.js\"));\n\n // Check environment variable for build mode\n const isBuildMode = process.env.ARKOS_BUILD === \"true\";\n\n // Decision logic (prioritized)\n if (isBuildMode) userFileExtension = \"js\";\n else if (hasTsConfig) userFileExtension = \"ts\";\n else if (hasAppTs && !hasAppJs) userFileExtension = \"ts\";\n else if (hasAppJs) userFileExtension = \"js\";\n else userFileExtension = \"js\";\n\n return userFileExtension;\n } catch (e) {\n // Default to js if anything goes wrong\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n\n/**\n * Checks if a file exists at the specified file path.\n *\n * @param filePath - The path to the file to check\n * @returns {boolean} True if the file exists, false otherwise or if there's an error\n *\n * @example\n * ```ts\n * const exists = checkFileExists('./path/to/file.txt');\n * if (exists) {\n * console.info('File exists!');\n * }\n * ```\n */\nexport function checkFileExists(filePath: string): boolean {\n try {\n return fs.existsSync(path.resolve(filePath));\n } catch (error) {\n return false;\n }\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { createRequire } from "module";
|
|
4
|
-
import { pathToFileURL } from "url";
|
|
5
|
-
export function getPackageJson() {
|
|
6
|
-
try {
|
|
7
|
-
const pkgPath = path.join(process.cwd(), "package.json");
|
|
8
|
-
if (fs.existsSync(pkgPath)) {
|
|
9
|
-
return JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
console.error("Error checking package.json:", err);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function isEsm() {
|
|
17
|
-
const pkg = getPackageJson();
|
|
18
|
-
return pkg?.type === "module";
|
|
19
|
-
}
|
|
20
|
-
export async function importModule(modulePath, options = { fixExtension: true }) {
|
|
21
|
-
if (!options.fixExtension || modulePath.endsWith(".ts") || !isEsm())
|
|
22
|
-
return await import(modulePath);
|
|
23
|
-
const userRequire = createRequire(pathToFileURL(process.cwd() + "/package.json"));
|
|
24
|
-
const resolved = userRequire.resolve(modulePath);
|
|
25
|
-
return await import(pathToFileURL(resolved));
|
|
26
|
-
}
|
|
27
|
-
export function detectPackageManagerFromUserAgent() {
|
|
28
|
-
const userAgent = process.env.npm_config_user_agent || "";
|
|
29
|
-
if (!userAgent)
|
|
30
|
-
return "npm";
|
|
31
|
-
if (userAgent.includes("cnpm"))
|
|
32
|
-
return "cnpm";
|
|
33
|
-
if (userAgent.includes("pnpm"))
|
|
34
|
-
return "pnpm";
|
|
35
|
-
if (userAgent.includes("yarn"))
|
|
36
|
-
return "yarn";
|
|
37
|
-
if (userAgent.includes("npm"))
|
|
38
|
-
return "npm";
|
|
39
|
-
if (userAgent.includes("bun"))
|
|
40
|
-
return "bun";
|
|
41
|
-
if (userAgent.includes("corepack"))
|
|
42
|
-
return "corepack";
|
|
43
|
-
if (userAgent.includes("deno"))
|
|
44
|
-
return "deno";
|
|
45
|
-
return "npm";
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=global.helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;I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CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE9C,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"module\";\nimport { pathToFileURL } from \"url\";\nimport { getUserFileExtension } from \"./fs.helpers\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg?.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n if (!options.fixExtension || modulePath.endsWith(\".ts\") || !isEsm())\n return await import(modulePath);\n\n // When importing user modules: mainly on ESM environment\n const userRequire = createRequire(\n pathToFileURL(process.cwd() + \"/package.json\")\n );\n const resolved = userRequire.resolve(modulePath);\n return await import(pathToFileURL(resolved) as any);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers.js";
|
|
4
|
-
import { crd, getUserFileExtension } from "./fs.helpers.js";
|
|
5
|
-
import { importModule } from "./global.helpers.js";
|
|
6
|
-
import { killServerChildProcess } from "../cli/utils/cli.helpers.js";
|
|
7
|
-
let prismaModelsModules = {};
|
|
8
|
-
export function setModelModules(modelName, modules) {
|
|
9
|
-
prismaModelsModules[kebabCase(modelName)] = modules;
|
|
10
|
-
}
|
|
11
|
-
export function getModelModules(modelName) {
|
|
12
|
-
return prismaModelsModules[kebabCase(modelName)];
|
|
13
|
-
}
|
|
14
|
-
export function getFileModelModulesFileStructure(modelName) {
|
|
15
|
-
const kebabModelName = kebabCase(modelName).toLowerCase();
|
|
16
|
-
const isAuthModule = modelName.toLowerCase() === "auth";
|
|
17
|
-
const ext = getUserFileExtension();
|
|
18
|
-
return {
|
|
19
|
-
core: {
|
|
20
|
-
service: `${kebabModelName}.service.${ext}`,
|
|
21
|
-
controller: `${kebabModelName}.controller.${ext}`,
|
|
22
|
-
middlewares: `${kebabModelName}.middlewares.${ext}`,
|
|
23
|
-
authConfigs: `${kebabModelName}.auth-configs.${ext}`,
|
|
24
|
-
authConfigsNew: `${kebabModelName}.auth.${ext}`,
|
|
25
|
-
prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,
|
|
26
|
-
prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,
|
|
27
|
-
router: `${kebabModelName}.router.${ext}`,
|
|
28
|
-
},
|
|
29
|
-
dtos: isAuthModule
|
|
30
|
-
? {
|
|
31
|
-
login: `login.dto.${ext}`,
|
|
32
|
-
signup: `signup.dto.${ext}`,
|
|
33
|
-
updateMe: `update-me.dto.${ext}`,
|
|
34
|
-
updatePassword: `update-password.dto.${ext}`,
|
|
35
|
-
}
|
|
36
|
-
: {
|
|
37
|
-
model: `${kebabModelName}.dto.${ext}`,
|
|
38
|
-
create: `create-${kebabModelName}.dto.${ext}`,
|
|
39
|
-
createMany: `create-many-${kebabModelName}.dto.${ext}`,
|
|
40
|
-
update: `update-${kebabModelName}.dto.${ext}`,
|
|
41
|
-
updateMany: `update-many-${kebabModelName}.dto.${ext}`,
|
|
42
|
-
findOne: `find-one-${kebabModelName}.dto.${ext}`,
|
|
43
|
-
findMany: `find-many-${kebabModelName}.dto.${ext}`,
|
|
44
|
-
query: `query-${kebabModelName}.dto.${ext}`,
|
|
45
|
-
},
|
|
46
|
-
schemas: isAuthModule
|
|
47
|
-
? {
|
|
48
|
-
login: `login.schema.${ext}`,
|
|
49
|
-
signup: `signup.schema.${ext}`,
|
|
50
|
-
updateMe: `update-me.schema.${ext}`,
|
|
51
|
-
updatePassword: `update-password.schema.${ext}`,
|
|
52
|
-
}
|
|
53
|
-
: {
|
|
54
|
-
model: `${kebabModelName}.schema.${ext}`,
|
|
55
|
-
create: `create-${kebabModelName}.schema.${ext}`,
|
|
56
|
-
createMany: `create-many-${kebabModelName}.schema.${ext}`,
|
|
57
|
-
update: `update-${kebabModelName}.schema.${ext}`,
|
|
58
|
-
updateMany: `update-many-${kebabModelName}.schema.${ext}`,
|
|
59
|
-
findOne: `find-one-${kebabModelName}.schema.${ext}`,
|
|
60
|
-
findMany: `find-many-${kebabModelName}.schema.${ext}`,
|
|
61
|
-
query: `query-${kebabModelName}.schema.${ext}`,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export async function processSubdir(modelName, type) {
|
|
66
|
-
const moduleDir = path.resolve(crd(), "src", "modules", kebabCase(modelName));
|
|
67
|
-
const subdir = path.join(moduleDir, type);
|
|
68
|
-
const fileStructure = getFileModelModulesFileStructure(modelName);
|
|
69
|
-
const result = {};
|
|
70
|
-
try {
|
|
71
|
-
await fs.promises.access(subdir).catch(() => {
|
|
72
|
-
return;
|
|
73
|
-
});
|
|
74
|
-
await Promise.all(Object.entries(fileStructure[type]).map(async ([key, fileName]) => {
|
|
75
|
-
const filePath = path.join(subdir, fileName);
|
|
76
|
-
try {
|
|
77
|
-
const module = await importModule(filePath).catch(() => null);
|
|
78
|
-
if (module)
|
|
79
|
-
result[key] = module.default;
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
console.error(error);
|
|
83
|
-
}
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
console.error(error);
|
|
88
|
-
}
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
|
-
export function validateNamingConventions(key, fileName, result) {
|
|
92
|
-
if (key === "prismaQueryOptions") {
|
|
93
|
-
if (result.prismaQueryOptions) {
|
|
94
|
-
killServerChildProcess();
|
|
95
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("prisma-query-options", "query")} at once, please choose only one name convention. \n`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else if (key === "prismaQueryOptionsNew") {
|
|
99
|
-
if (result.prismaQueryOptions) {
|
|
100
|
-
killServerChildProcess();
|
|
101
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("query", "prisma-query-options")} at once, please choose only one name convention. \n`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (key === "authConfigs") {
|
|
105
|
-
if (result.authConfigs) {
|
|
106
|
-
killServerChildProcess();
|
|
107
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth-configs", "auth")} at once, please choose only one name convention. \n`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (key === "authConfigsNew") {
|
|
111
|
-
if (result.authConfigs) {
|
|
112
|
-
killServerChildProcess();
|
|
113
|
-
throw new Error(`\n Cannot use both ${fileName} and ${fileName.replace("auth", "auth-configs")} at once, please choose only one name convention. \n`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
export function assignModuleToResult(key, module, result) {
|
|
118
|
-
if (key === "prismaQueryOptions" || key === "prismaQueryOptionsNew") {
|
|
119
|
-
result.prismaQueryOptions = module.default || module;
|
|
120
|
-
}
|
|
121
|
-
else if (key === "authConfigs" || key === "authConfigsNew") {
|
|
122
|
-
result.authConfigs = module.default || module;
|
|
123
|
-
}
|
|
124
|
-
else if (key === "middlewares" || key === "router") {
|
|
125
|
-
result[key] = module;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
result[key] = module.default || module;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
export async function importPrismaModelModules(modelName, arkosConfig) {
|
|
132
|
-
const moduleDir = path.resolve(crd(), "src", "modules", kebabCase(modelName));
|
|
133
|
-
const result = {
|
|
134
|
-
dtos: {},
|
|
135
|
-
schemas: {},
|
|
136
|
-
};
|
|
137
|
-
if (getModelModules(modelName))
|
|
138
|
-
return getModelModules(modelName);
|
|
139
|
-
const fileStructure = getFileModelModulesFileStructure(modelName);
|
|
140
|
-
await Promise.all(Object.entries(fileStructure.core).map(async ([key, fileName]) => {
|
|
141
|
-
const filePath = path.join(moduleDir, fileName);
|
|
142
|
-
try {
|
|
143
|
-
const module = await importModule(filePath).catch((err) => {
|
|
144
|
-
if (!err.message.includes("Cannot find module")) {
|
|
145
|
-
console.error(`Failed to import ${fileName}: \n`);
|
|
146
|
-
console.error(err);
|
|
147
|
-
killServerChildProcess();
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
if (module) {
|
|
152
|
-
validateNamingConventions(key, fileName, result);
|
|
153
|
-
assignModuleToResult(key, module, result);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
catch (err) {
|
|
157
|
-
if (err.message.includes("Cannot use both"))
|
|
158
|
-
throw err;
|
|
159
|
-
console.error(err);
|
|
160
|
-
killServerChildProcess();
|
|
161
|
-
}
|
|
162
|
-
}));
|
|
163
|
-
const validationSubdir = arkosConfig.validation?.resolver
|
|
164
|
-
? arkosConfig.validation.resolver === "zod"
|
|
165
|
-
? "schemas"
|
|
166
|
-
: "dtos"
|
|
167
|
-
: null;
|
|
168
|
-
let validators = {};
|
|
169
|
-
if (validationSubdir)
|
|
170
|
-
validators = await processSubdir(modelName, validationSubdir);
|
|
171
|
-
prismaModelsModules[modelName] = {
|
|
172
|
-
...result,
|
|
173
|
-
...(validationSubdir && { [validationSubdir]: validators }),
|
|
174
|
-
};
|
|
175
|
-
return {
|
|
176
|
-
...result,
|
|
177
|
-
...(validationSubdir && { [validationSubdir]: validators }),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
export const prismaModelRelationFields = {};
|
|
181
|
-
export function getAllPrismaFiles(dirPath, fileList = []) {
|
|
182
|
-
const files = fs.readdirSync(dirPath);
|
|
183
|
-
files?.forEach((file) => {
|
|
184
|
-
const filePath = path.join(dirPath, file);
|
|
185
|
-
const stat = fs.statSync(filePath);
|
|
186
|
-
if (stat.isDirectory() && file !== "migrations") {
|
|
187
|
-
fileList = getAllPrismaFiles(filePath, fileList);
|
|
188
|
-
}
|
|
189
|
-
else if (stat.isFile() && file.endsWith(".prisma")) {
|
|
190
|
-
fileList.push(filePath);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
return fileList;
|
|
194
|
-
}
|
|
195
|
-
const modelRegex = /model\s+(\w+)\s*{/g;
|
|
196
|
-
export const models = [];
|
|
197
|
-
export let prismaSchemasContent;
|
|
198
|
-
export const prismaModelsUniqueFields = [];
|
|
199
|
-
export function initializePrismaModels() {
|
|
200
|
-
const prismaContent = [];
|
|
201
|
-
const files = getAllPrismaFiles("./prisma");
|
|
202
|
-
for (const file of files) {
|
|
203
|
-
const content = fs.readFileSync(file, "utf-8");
|
|
204
|
-
if (!prismaContent?.includes?.(content))
|
|
205
|
-
prismaContent.push(content);
|
|
206
|
-
}
|
|
207
|
-
const content = prismaContent
|
|
208
|
-
.join("\n")
|
|
209
|
-
.replace(modelRegex, (_, modelName) => {
|
|
210
|
-
if (!models?.includes?.(modelName))
|
|
211
|
-
models.push(camelCase(modelName.trim()));
|
|
212
|
-
return `model ${modelName} {`;
|
|
213
|
-
});
|
|
214
|
-
const copiedContent = content;
|
|
215
|
-
prismaSchemasContent = content;
|
|
216
|
-
for (const model of models) {
|
|
217
|
-
const modelName = pascalCase(model);
|
|
218
|
-
const modelStart = copiedContent.indexOf(`model ${modelName} {`);
|
|
219
|
-
const modelEnd = copiedContent.indexOf("}", modelStart);
|
|
220
|
-
const modelDefinition = copiedContent.slice(modelStart, modelEnd);
|
|
221
|
-
const relations = {
|
|
222
|
-
singular: [],
|
|
223
|
-
list: [],
|
|
224
|
-
};
|
|
225
|
-
const lines = modelDefinition.split("\n");
|
|
226
|
-
for (const line of lines) {
|
|
227
|
-
const trimmedLine = line.trim();
|
|
228
|
-
if (!trimmedLine ||
|
|
229
|
-
trimmedLine.startsWith("model") ||
|
|
230
|
-
trimmedLine.startsWith("//") ||
|
|
231
|
-
trimmedLine.startsWith("/*"))
|
|
232
|
-
continue;
|
|
233
|
-
const [fieldName, type] = trimmedLine.split(/\s+/);
|
|
234
|
-
const isUnique = trimmedLine?.includes?.("@unique");
|
|
235
|
-
if (isUnique) {
|
|
236
|
-
const existingFields = prismaModelsUniqueFields[model] || [];
|
|
237
|
-
const alreadyExists = existingFields.some((field) => field.name === fieldName &&
|
|
238
|
-
field.type === type &&
|
|
239
|
-
field.isUnique === isUnique);
|
|
240
|
-
if (!alreadyExists) {
|
|
241
|
-
prismaModelsUniqueFields[model] = [
|
|
242
|
-
...existingFields,
|
|
243
|
-
{ name: fieldName, type, isUnique },
|
|
244
|
-
];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
const cleanType = type?.replace("[]", "").replace("?", "");
|
|
248
|
-
if (trimmedLine?.includes?.("@relation") ||
|
|
249
|
-
trimmedLine.match(/\s+\w+(\[\])?(\s+@|$)/) ||
|
|
250
|
-
models?.includes?.(camelCase(cleanType || ""))) {
|
|
251
|
-
const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);
|
|
252
|
-
const typeStart = copiedContent.indexOf(`type ${cleanType} {`);
|
|
253
|
-
if (!cleanType ||
|
|
254
|
-
enumStart >= 0 ||
|
|
255
|
-
typeStart >= 0 ||
|
|
256
|
-
cleanType === "String" ||
|
|
257
|
-
cleanType === "Int" ||
|
|
258
|
-
cleanType === "Float" ||
|
|
259
|
-
cleanType === "Boolean" ||
|
|
260
|
-
cleanType === "DateTime" ||
|
|
261
|
-
cleanType === "Bytes" ||
|
|
262
|
-
cleanType === "Decimal" ||
|
|
263
|
-
cleanType === "BigInt" ||
|
|
264
|
-
cleanType === "Json") {
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
if (!type?.includes?.("[]")) {
|
|
268
|
-
relations.singular.push({
|
|
269
|
-
name: fieldName,
|
|
270
|
-
type: cleanType,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
relations.list.push({
|
|
275
|
-
name: fieldName,
|
|
276
|
-
type: cleanType,
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
prismaModelRelationFields[modelName] = relations;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
export function getPrismaModelRelations(modelName) {
|
|
285
|
-
modelName = pascalCase(modelName);
|
|
286
|
-
if (!(modelName in prismaModelRelationFields))
|
|
287
|
-
return;
|
|
288
|
-
return prismaModelRelationFields[modelName];
|
|
289
|
-
}
|
|
290
|
-
function getModels() {
|
|
291
|
-
return models;
|
|
292
|
-
}
|
|
293
|
-
export function getPrismaSchemasContent() {
|
|
294
|
-
return prismaSchemasContent;
|
|
295
|
-
}
|
|
296
|
-
function getModelUniqueFields(modelName) {
|
|
297
|
-
return prismaModelsUniqueFields[modelName];
|
|
298
|
-
}
|
|
299
|
-
export { getModels, getModelUniqueFields };
|
|
300
|
-
//# sourceMappingURL=models.helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/help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,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\nimport { ArkosConfig } from \"../../exports\";\n\ntype ModeModules = Awaited<ReturnType<typeof importPrismaModelModules>>;\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<string, ModeModules> = {};\n\nexport function setModelModules(modelName: string, modules: ModeModules) {\n prismaModelsModules[kebabCase(modelName)] = modules;\n}\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n const result: Record<string, any> = {};\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n\n return result;\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos?: Record<string, any>;\n schemas?: Record<string, any>;\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {importPrismaModelModulesReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"middlewares\" || key === \"router\") {\n result[key] = module;\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importPrismaModelModules(\n modelName: string,\n arkosConfig: ArkosConfig\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n let validators = {};\n if (validationSubdir)\n validators = await processSubdir(modelName, validationSubdir);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n prismaModelsModules[modelName] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
|