arkos 1.0.19-beta → 1.0.20-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/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/exports/middlewares/index.js +7 -0
- package/dist/cjs/exports/middlewares/index.js.map +1 -0
- package/dist/cjs/modules/auth/auth.controller.js +31 -26
- package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
- package/dist/cjs/modules/auth/auth.router.js +4 -5
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +27 -24
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +4 -4
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +2 -29
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js +37 -1
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/base.router.js +2 -2
- package/dist/cjs/modules/base/base.router.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +2 -3
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +9 -11
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -0
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/cjs/modules/file-uploader/file-uploader.service.js +4 -4
- package/dist/cjs/modules/file-uploader/file-uploader.service.js.map +1 -1
- package/dist/cjs/modules/file-uploader/utils/helpers/file-uploader.helpers.js +7 -5
- package/dist/cjs/modules/file-uploader/utils/helpers/file-uploader.helpers.js.map +1 -1
- package/dist/cjs/server.js +1 -1
- package/dist/cjs/server.js.map +1 -1
- package/dist/cjs/types/auth.js.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/features/api.features.js +3 -2
- package/dist/cjs/utils/features/api.features.js.map +1 -1
- package/dist/cjs/utils/helpers/api.features.helpers.js +4 -4
- package/dist/cjs/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/base.controller.helpers.js +77 -35
- package/dist/cjs/utils/helpers/base.controller.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/change-case.helpers.js +3 -3
- package/dist/cjs/utils/helpers/change-case.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +35 -30
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/scripts/generate-insomnia-collection.js +228 -0
- package/dist/cjs/utils/scripts/generate-insomnia-collection.js.map +1 -0
- package/dist/cjs/utils/scripts/index.js +12 -0
- package/dist/cjs/utils/scripts/index.js.map +1 -0
- package/dist/es2020/app.js +1 -1
- package/dist/es2020/app.js.map +1 -1
- package/dist/es2020/exports/middlewares/index.js +2 -0
- package/dist/es2020/exports/middlewares/index.js.map +1 -0
- package/dist/es2020/modules/auth/auth.controller.js +32 -27
- package/dist/es2020/modules/auth/auth.controller.js.map +1 -1
- package/dist/es2020/modules/auth/auth.router.js +1 -2
- package/dist/es2020/modules/auth/auth.router.js.map +1 -1
- package/dist/es2020/modules/auth/auth.service.js +27 -24
- package/dist/es2020/modules/auth/auth.service.js.map +1 -1
- package/dist/es2020/modules/auth/utils/helpers/auth.controller.helpers.js +4 -4
- package/dist/es2020/modules/auth/utils/helpers/auth.controller.helpers.js.map +1 -1
- package/dist/es2020/modules/base/base.controller.js +2 -29
- package/dist/es2020/modules/base/base.controller.js.map +1 -1
- package/dist/es2020/modules/base/base.middlewares.js +33 -1
- package/dist/es2020/modules/base/base.middlewares.js.map +1 -1
- package/dist/es2020/modules/base/base.router.js +2 -2
- package/dist/es2020/modules/base/base.router.js.map +1 -1
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js +1 -2
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
- package/dist/es2020/modules/base/utils/helpers/base.service.helpers.js +9 -11
- package/dist/es2020/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/es2020/modules/error-handler/error-handler.controller.js +2 -0
- package/dist/es2020/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/es2020/modules/error-handler/utils/catch-async.js +1 -1
- package/dist/es2020/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/es2020/modules/file-uploader/file-uploader.service.js +4 -4
- package/dist/es2020/modules/file-uploader/file-uploader.service.js.map +1 -1
- package/dist/es2020/modules/file-uploader/utils/helpers/file-uploader.helpers.js +7 -5
- package/dist/es2020/modules/file-uploader/utils/helpers/file-uploader.helpers.js.map +1 -1
- package/dist/es2020/server.js +1 -1
- package/dist/es2020/server.js.map +1 -1
- package/dist/es2020/types/auth.js.map +1 -1
- package/dist/es2020/types/index.js.map +1 -1
- package/dist/es2020/utils/features/api.features.js +3 -2
- package/dist/es2020/utils/features/api.features.js.map +1 -1
- package/dist/es2020/utils/helpers/api.features.helpers.js +4 -4
- package/dist/es2020/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/base.controller.helpers.js +75 -31
- package/dist/es2020/utils/helpers/base.controller.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/change-case.helpers.js +3 -3
- package/dist/es2020/utils/helpers/change-case.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/models.helpers.js +35 -30
- package/dist/es2020/utils/helpers/models.helpers.js.map +1 -1
- package/dist/es2020/utils/scripts/generate-insomnia-collection.js +189 -0
- package/dist/es2020/utils/scripts/generate-insomnia-collection.js.map +1 -0
- package/dist/es2020/utils/scripts/index.js +10 -0
- package/dist/es2020/utils/scripts/index.js.map +1 -0
- package/dist/types/exports/middlewares/index.d.ts +1 -0
- package/dist/types/modules/auth/auth.service.d.ts +3 -3
- package/dist/types/modules/base/base.middlewares.d.ts +6 -1
- package/dist/types/modules/base/utils/helpers/base.service.helpers.d.ts +1 -1
- package/dist/types/types/auth.d.ts +9 -8
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/utils/helpers/base.controller.helpers.d.ts +4 -6
- package/dist/types/utils/scripts/generate-insomnia-collection.d.ts +1 -0
- package/dist/types/utils/scripts/index.d.ts +2 -0
- package/package.json +10 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.controller.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/base.controller.helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.controller.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/base.controller.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAuC,EAAE,CAAC;IAEtD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;;QAC5C,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;YAErB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBACvD,MAAM,CAAC,IAAI,CAAC;oBACV,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;oBAC5B,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI;iBAC5B,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;Q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,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { getExpressApp } from \"../../server\";\n\nexport const getAppRoutes = () => {\n const app = getExpressApp();\n const routes: { method: string; path: string }[] = [];\n\n app._router.stack.forEach((middleware: any) => {\n if (middleware.route) {\n // Direct routes on the app\n Object.keys(middleware.route.methods).forEach((method) => {\n routes.push({\n method: method.toUpperCase(),\n path: middleware.route.path,\n });\n });\n } else if (middleware.handle && middleware.handle.stack) {\n // Extract the base path from the middleware's regexp pattern\n let basePath = \"\";\n if (middleware.regexp) {\n // Handle pattern like /^\\/api\\/?(?=\\/|$)/i\n const regexpStr = middleware.regexp.toString();\n\n // More robust pattern matching\n if (regexpStr.includes?.(\"/?(?=\")) {\n // Extract everything between the start and the '/?(?=' pattern\n const match = regexpStr.match(/\\/\\^(\\\\\\/[^?]+)/);\n if (match) {\n // Clean up the extracted path\n basePath = match[1].replace(/\\\\\\//g, \"/\");\n }\n } else {\n // Handle other regexp patterns\n const simpleMatch = regexpStr.match(/\\/\\^(\\\\\\/[^\\\\]+)/);\n if (simpleMatch) {\n basePath = simpleMatch[1].replace(/\\\\\\//g, \"/\");\n }\n }\n }\n\n // Process routes in the middleware's router\n middleware.handle.stack.forEach((routerMiddleware: any) => {\n if (routerMiddleware.route) {\n Object.keys(routerMiddleware.route.methods).forEach((method) => {\n let routePath = routerMiddleware.route.path;\n let fullPath;\n\n // Check if routePath already contains regex artifacts\n if (routePath.includes?.(\"/?(?=\")) {\n // Extract the actual path from the regex pattern\n const pathMatch = routePath.match(/\\/\\^?(\\\\\\/[^?]+|\\/[^?]+)/);\n if (pathMatch) {\n const cleanPath = pathMatch[1].replace(/\\\\\\//g, \"/\");\n fullPath = basePath ? basePath + cleanPath : cleanPath;\n } else {\n // If we can't clean it, at least extract what's after '/?(?='\n const fallbackMatch = routePath.match(/\\?\\(\\?=([^)]+)/);\n if (fallbackMatch) {\n fullPath = fallbackMatch[1];\n } else {\n fullPath = routePath; // Use as is if no pattern matches\n }\n }\n } else {\n // Normal path joining\n fullPath = basePath\n ? basePath.replace(/\\/$/, \"\") +\n (routePath.startsWith(\"/\") ? routePath : \"/\" + routePath)\n : routePath;\n }\n\n // Clean up any remaining regex artifacts\n fullPath = fullPath\n .replace(/\\\\\\//g, \"/\")\n .replace(/\\^/g, \"\")\n .replace(/\\$/g, \"\");\n\n // Remove any \"/?(?=\" patterns that might remain\n if (fullPath.includes?.(\"/?(?=\")) {\n fullPath = fullPath.replace(/\\/\\?\\(\\?=[^)]*\\)/g, \"\");\n }\n\n routes.push({\n method: method.toUpperCase(),\n path: fullPath,\n });\n });\n }\n });\n }\n });\n\n return routes;\n};\n"]}
|
|
@@ -141,7 +141,7 @@ function pascalCaseTransformFactory(lower, upper) {
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
function splitPrefixSuffix(input, options = {}) {
|
|
144
|
-
var _a, _b, _c;
|
|
144
|
+
var _a, _b, _c, _d, _e;
|
|
145
145
|
const splitFn = (_a = options.split) !== null && _a !== void 0 ? _a : (options.separateNumbers ? splitSeparateNumbers : split);
|
|
146
146
|
const prefixCharacters = (_b = options.prefixCharacters) !== null && _b !== void 0 ? _b : DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
147
147
|
const suffixCharacters = (_c = options.suffixCharacters) !== null && _c !== void 0 ? _c : DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
@@ -149,14 +149,14 @@ function splitPrefixSuffix(input, options = {}) {
|
|
|
149
149
|
let suffixIndex = input.length;
|
|
150
150
|
while (prefixIndex < input.length) {
|
|
151
151
|
const char = input.charAt(prefixIndex);
|
|
152
|
-
if (!(prefixCharacters === null || prefixCharacters === void 0 ? void 0 : prefixCharacters.includes(char)))
|
|
152
|
+
if (!((_d = prefixCharacters === null || prefixCharacters === void 0 ? void 0 : prefixCharacters.includes) === null || _d === void 0 ? void 0 : _d.call(prefixCharacters, char)))
|
|
153
153
|
break;
|
|
154
154
|
prefixIndex++;
|
|
155
155
|
}
|
|
156
156
|
while (suffixIndex > prefixIndex) {
|
|
157
157
|
const index = suffixIndex - 1;
|
|
158
158
|
const char = input.charAt(index);
|
|
159
|
-
if (!(suffixCharacters === null || suffixCharacters === void 0 ? void 0 : suffixCharacters.includes(char)))
|
|
159
|
+
if (!((_e = suffixCharacters === null || suffixCharacters === void 0 ? void 0 : suffixCharacters.includes) === null || _e === void 0 ? void 0 : _e.call(suffixCharacters, char)))
|
|
160
160
|
break;
|
|
161
161
|
suffixIndex = index;
|
|
162
162
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-case.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/change-case.helpers.ts"],"names":[],"mappings":"AACA,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AACtD,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAG5D,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAGzD,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAG9C,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAGrC,MAAM,gCAAgC,GAAG,EAAE,CAAC;AA+B5C,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE1B,MAAM,GAAG,MAAM;SACZ,OAAO,CAAC,oBAAoB,EAAE,mBAAmB,CAAC;SAClD,OAAO,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;IAEtD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEpD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IAGxB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI;QAAE,KAAK,EAAE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,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,WAAW,GAAG,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;YAAE,MAAM;QAC7C,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC9C,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;KACzB,CAAC;AACJ,CAAC","sourcesContent":["// Regexps involved with splitting words in various case formats.\nconst SPLIT_LOWER_UPPER_RE = /([\\p{Ll}\\d])(\\p{Lu})/gu;\nconst SPLIT_UPPER_UPPER_RE = /(\\p{Lu})([\\p{Lu}][\\p{Ll}])/gu;\n\n// Used to iterate over the initial split result and separate numbers.\nconst SPLIT_SEPARATE_NUMBER_RE = /(\\d)\\p{Ll}|(\\p{L})\\d/u;\n\n// Regexp involved with stripping non-word characters from the result.\nconst DEFAULT_STRIP_REGEXP = /[^\\p{L}\\d]+/giu;\n\n// The replacement value for splits.\nconst SPLIT_REPLACE_VALUE = \"$1\\0$2\";\n\n// The default characters to keep after transforming case.\nconst DEFAULT_PREFIX_SUFFIX_CHARACTERS = \"\";\n\n/**\n * Supported locale values. Use `false` to ignore locale.\n * Defaults to `undefined`, which uses the host environment.\n */\nexport type Locale = string[] | string | false | undefined;\n\n/**\n * Options used for converting strings to pascal/camel case.\n */\nexport interface PascalCaseOptions extends Options {\n mergeAmbiguousCharacters?: boolean;\n}\n\n/**\n * Options used for converting strings to any case.\n */\nexport interface Options {\n locale?: Locale;\n split?: (value: string) => string[];\n /** @deprecated Pass `split: splitSeparateNumbers` instead. */\n separateNumbers?: boolean;\n delimiter?: string;\n prefixCharacters?: string;\n suffixCharacters?: string;\n}\n\n/**\n * Split any cased input strings into an array of words.\n */\nexport function split(value: string) {\n let result = value.trim();\n\n result = result\n .replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)\n .replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);\n\n result = result.replace(DEFAULT_STRIP_REGEXP, \"\\0\");\n\n let start = 0;\n let end = result.length;\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === \"\\0\") start++;\n if (start === end) return [];\n while (result.charAt(end - 1) === \"\\0\") end--;\n\n return result.slice(start, end).split(/\\0/g);\n}\n\n/**\n * Split the input string into an array of words, separating numbers.\n */\nexport function splitSeparateNumbers(value: string) {\n const words = split(value);\n for (let i = 0; i < words.length; i++) {\n const word = words[i];\n const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);\n if (match) {\n const offset = match.index + (match[1] ?? match[2]).length;\n words.splice(i, 1, word.slice(0, offset), word.slice(offset));\n }\n }\n return words;\n}\n\n/**\n * Convert a string to space separated lower case (`foo bar`).\n */\nexport function noCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n return (\n prefix +\n words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to camel case (`fooBar`).\n */\nexport function camelCase(input: string, options?: PascalCaseOptions) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = options?.mergeAmbiguousCharacters\n ? capitalCaseTransformFactory(lower, upper)\n : pascalCaseTransformFactory(lower, upper);\n return (\n prefix +\n words\n .map((word, index) => {\n if (index === 0) return lower(word);\n return transform(word, index);\n })\n .join(options?.delimiter ?? \"\") +\n suffix\n );\n}\n\n/**\n * Convert a string to pascal case (`FooBar`).\n */\nexport function pascalCase(input: string, options?: PascalCaseOptions) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = options?.mergeAmbiguousCharacters\n ? capitalCaseTransformFactory(lower, upper)\n : pascalCaseTransformFactory(lower, upper);\n return prefix + words.map(transform).join(options?.delimiter ?? \"\") + suffix;\n}\n\n/**\n * Convert a string to pascal snake case (`Foo_Bar`).\n */\nexport function pascalSnakeCase(input: string, options?: Options) {\n return capitalCase(input, { delimiter: \"_\", ...options });\n}\n\n/**\n * Convert a string to capital case (`Foo Bar`).\n */\nexport function capitalCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n return (\n prefix +\n words\n .map(capitalCaseTransformFactory(lower, upper))\n .join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to constant case (`FOO_BAR`).\n */\nexport function constantCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n return (\n prefix +\n words.map(upperFactory(options?.locale)).join(options?.delimiter ?? \"_\") +\n suffix\n );\n}\n\n/**\n * Convert a string to dot case (`foo.bar`).\n */\nexport function dotCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \".\", ...options });\n}\n\n/**\n * Convert a string to kebab case (`foo-bar`).\n */\nexport function kebabCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"-\", ...options });\n}\n\n/**\n * Convert a string to path case (`foo/bar`).\n */\nexport function pathCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"/\", ...options });\n}\n\n/**\n * Convert a string to path case (`Foo bar`).\n */\nexport function sentenceCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = capitalCaseTransformFactory(lower, upper);\n return (\n prefix +\n words\n .map((word, index) => {\n if (index === 0) return transform(word);\n return lower(word);\n })\n .join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to snake case (`foo_bar`).\n */\nexport function snakeCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"_\", ...options });\n}\n\n/**\n * Convert a string to header case (`Foo-Bar`).\n */\nexport function trainCase(input: string, options?: Options) {\n return capitalCase(input, { delimiter: \"-\", ...options });\n}\n\nfunction lowerFactory(locale: Locale): (input: string) => string {\n return locale === false\n ? (input: string) => input.toLowerCase()\n : (input: string) => input.toLocaleLowerCase(locale);\n}\n\nfunction upperFactory(locale: Locale): (input: string) => string {\n return locale === false\n ? (input: string) => input.toUpperCase()\n : (input: string) => input.toLocaleUpperCase(locale);\n}\n\nfunction capitalCaseTransformFactory(\n lower: (input: string) => string,\n upper: (input: string) => string\n) {\n return (word: string) => `${upper(word[0])}${lower(word.slice(1))}`;\n}\n\nfunction pascalCaseTransformFactory(\n lower: (input: string) => string,\n upper: (input: string) => string\n) {\n return (word: string, index: number) => {\n const char0 = word[0];\n const initial =\n index > 0 && char0 >= \"0\" && char0 <= \"9\" ? \"_\" + char0 : upper(char0);\n return initial + lower(word.slice(1));\n };\n}\n\nfunction splitPrefixSuffix(\n input: string,\n options: Options = {}\n): [string, string[], string] {\n const splitFn =\n options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);\n const prefixCharacters =\n options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;\n const suffixCharacters =\n options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;\n let prefixIndex = 0;\n let suffixIndex = input.length;\n\n while (prefixIndex < input.length) {\n const char = input.charAt(prefixIndex);\n if (!prefixCharacters?.includes(char)) break;\n prefixIndex++;\n }\n\n while (suffixIndex > prefixIndex) {\n const index = suffixIndex - 1;\n const char = input.charAt(index);\n if (!suffixCharacters?.includes(char)) break;\n suffixIndex = index;\n }\n\n return [\n input.slice(0, prefixIndex),\n splitFn(input.slice(prefixIndex, suffixIndex)),\n input.slice(suffixIndex),\n ];\n}\n"]}
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C;QAC9C,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC;KACzB,CAAC;AACJ,CAAC","sourcesContent":["// Regexps involved with splitting words in various case formats.\nconst SPLIT_LOWER_UPPER_RE = /([\\p{Ll}\\d])(\\p{Lu})/gu;\nconst SPLIT_UPPER_UPPER_RE = /(\\p{Lu})([\\p{Lu}][\\p{Ll}])/gu;\n\n// Used to iterate over the initial split result and separate numbers.\nconst SPLIT_SEPARATE_NUMBER_RE = /(\\d)\\p{Ll}|(\\p{L})\\d/u;\n\n// Regexp involved with stripping non-word characters from the result.\nconst DEFAULT_STRIP_REGEXP = /[^\\p{L}\\d]+/giu;\n\n// The replacement value for splits.\nconst SPLIT_REPLACE_VALUE = \"$1\\0$2\";\n\n// The default characters to keep after transforming case.\nconst DEFAULT_PREFIX_SUFFIX_CHARACTERS = \"\";\n\n/**\n * Supported locale values. Use `false` to ignore locale.\n * Defaults to `undefined`, which uses the host environment.\n */\nexport type Locale = string[] | string | false | undefined;\n\n/**\n * Options used for converting strings to pascal/camel case.\n */\nexport interface PascalCaseOptions extends Options {\n mergeAmbiguousCharacters?: boolean;\n}\n\n/**\n * Options used for converting strings to any case.\n */\nexport interface Options {\n locale?: Locale;\n split?: (value: string) => string[];\n /** @deprecated Pass `split: splitSeparateNumbers` instead. */\n separateNumbers?: boolean;\n delimiter?: string;\n prefixCharacters?: string;\n suffixCharacters?: string;\n}\n\n/**\n * Split any cased input strings into an array of words.\n */\nexport function split(value: string) {\n let result = value.trim();\n\n result = result\n .replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)\n .replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);\n\n result = result.replace(DEFAULT_STRIP_REGEXP, \"\\0\");\n\n let start = 0;\n let end = result.length;\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === \"\\0\") start++;\n if (start === end) return [];\n while (result.charAt(end - 1) === \"\\0\") end--;\n\n return result.slice(start, end).split(/\\0/g);\n}\n\n/**\n * Split the input string into an array of words, separating numbers.\n */\nexport function splitSeparateNumbers(value: string) {\n const words = split(value);\n for (let i = 0; i < words.length; i++) {\n const word = words[i];\n const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);\n if (match) {\n const offset = match.index + (match[1] ?? match[2]).length;\n words.splice(i, 1, word.slice(0, offset), word.slice(offset));\n }\n }\n return words;\n}\n\n/**\n * Convert a string to space separated lower case (`foo bar`).\n */\nexport function noCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n return (\n prefix +\n words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to camel case (`fooBar`).\n */\nexport function camelCase(input: string, options?: PascalCaseOptions) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = options?.mergeAmbiguousCharacters\n ? capitalCaseTransformFactory(lower, upper)\n : pascalCaseTransformFactory(lower, upper);\n return (\n prefix +\n words\n .map((word, index) => {\n if (index === 0) return lower(word);\n return transform(word, index);\n })\n .join(options?.delimiter ?? \"\") +\n suffix\n );\n}\n\n/**\n * Convert a string to pascal case (`FooBar`).\n */\nexport function pascalCase(input: string, options?: PascalCaseOptions) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = options?.mergeAmbiguousCharacters\n ? capitalCaseTransformFactory(lower, upper)\n : pascalCaseTransformFactory(lower, upper);\n return prefix + words.map(transform).join(options?.delimiter ?? \"\") + suffix;\n}\n\n/**\n * Convert a string to pascal snake case (`Foo_Bar`).\n */\nexport function pascalSnakeCase(input: string, options?: Options) {\n return capitalCase(input, { delimiter: \"_\", ...options });\n}\n\n/**\n * Convert a string to capital case (`Foo Bar`).\n */\nexport function capitalCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n return (\n prefix +\n words\n .map(capitalCaseTransformFactory(lower, upper))\n .join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to constant case (`FOO_BAR`).\n */\nexport function constantCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n return (\n prefix +\n words.map(upperFactory(options?.locale)).join(options?.delimiter ?? \"_\") +\n suffix\n );\n}\n\n/**\n * Convert a string to dot case (`foo.bar`).\n */\nexport function dotCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \".\", ...options });\n}\n\n/**\n * Convert a string to kebab case (`foo-bar`).\n */\nexport function kebabCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"-\", ...options });\n}\n\n/**\n * Convert a string to path case (`foo/bar`).\n */\nexport function pathCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"/\", ...options });\n}\n\n/**\n * Convert a string to path case (`Foo bar`).\n */\nexport function sentenceCase(input: string, options?: Options) {\n const [prefix, words, suffix] = splitPrefixSuffix(input, options);\n const lower = lowerFactory(options?.locale);\n const upper = upperFactory(options?.locale);\n const transform = capitalCaseTransformFactory(lower, upper);\n return (\n prefix +\n words\n .map((word, index) => {\n if (index === 0) return transform(word);\n return lower(word);\n })\n .join(options?.delimiter ?? \" \") +\n suffix\n );\n}\n\n/**\n * Convert a string to snake case (`foo_bar`).\n */\nexport function snakeCase(input: string, options?: Options) {\n return noCase(input, { delimiter: \"_\", ...options });\n}\n\n/**\n * Convert a string to header case (`Foo-Bar`).\n */\nexport function trainCase(input: string, options?: Options) {\n return capitalCase(input, { delimiter: \"-\", ...options });\n}\n\nfunction lowerFactory(locale: Locale): (input: string) => string {\n return locale === false\n ? (input: string) => input.toLowerCase()\n : (input: string) => input.toLocaleLowerCase(locale);\n}\n\nfunction upperFactory(locale: Locale): (input: string) => string {\n return locale === false\n ? (input: string) => input.toUpperCase()\n : (input: string) => input.toLocaleUpperCase(locale);\n}\n\nfunction capitalCaseTransformFactory(\n lower: (input: string) => string,\n upper: (input: string) => string\n) {\n return (word: string) => `${upper(word[0])}${lower(word.slice(1))}`;\n}\n\nfunction pascalCaseTransformFactory(\n lower: (input: string) => string,\n upper: (input: string) => string\n) {\n return (word: string, index: number) => {\n const char0 = word[0];\n const initial =\n index > 0 && char0 >= \"0\" && char0 <= \"9\" ? \"_\" + char0 : upper(char0);\n return initial + lower(word.slice(1));\n };\n}\n\nfunction splitPrefixSuffix(\n input: string,\n options: Options = {}\n): [string, string[], string] {\n const splitFn =\n options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);\n const prefixCharacters =\n options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;\n const suffixCharacters =\n options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;\n let prefixIndex = 0;\n let suffixIndex = input.length;\n\n while (prefixIndex < input.length) {\n const char = input.charAt(prefixIndex);\n if (!prefixCharacters?.includes?.(char)) break;\n prefixIndex++;\n }\n\n while (suffixIndex > prefixIndex) {\n const index = suffixIndex - 1;\n const char = input.charAt(index);\n if (!suffixCharacters?.includes?.(char)) break;\n suffixIndex = index;\n }\n\n return [\n input.slice(0, prefixIndex),\n splitFn(input.slice(prefixIndex, suffixIndex)),\n input.slice(suffixIndex),\n ];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
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;AAEpB,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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AO,iBAAiB,CAAC;YAC3B,CAAC;QACH,CAAC;QAGD,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\n\n// // Runtime-agnostic approach with proper TypeScript support\n// export const extension = (() => {\n// // Safely detect environment without direct import.meta reference\n// let currentFile = \"\";\n\n// // Try to determine the current file using environment-specific approaches\n// try {\n// if (typeof process !== \"undefined\" && process.env) {\n// // Node.js environment - use __filename\n// currentFile = __filename || \"\";\n// } else {\n// // Handle other environments (browser, Deno, etc.)\n// // This branch won't be reached in CommonJS builds\n// if (typeof (global as any)?.document === \"undefined\") {\n// // Non-browser environment that might support import.meta\n// // We'll use eval to prevent direct parsing of import.meta\n// currentFile = new Function(\n// \"return typeof import.meta !== 'undefined' ? import.meta.url : ''\"\n// )();\n// }\n// }\n// } catch (e) {\n// // Ignore errors during detection\n// }\n\n// // Check file extension\n// if (currentFile.endsWith(\".ts\") || currentFile.endsWith(\".tsx\")) {\n// return \"ts\";\n// }\n\n// // Use \"any\" type and conditional checks to avoid TypeScript errors\n// try {\n// // Check for Deno\n// const globalObj = globalThis as any;\n// if (typeof globalObj.Deno !== \"undefined\" && globalObj.Deno.emit) {\n// return \"ts\";\n// }\n\n// // Check for Bun\n// if (typeof globalObj.Bun !== \"undefined\") {\n// return \"ts\";\n// }\n\n// // Check for newer Node with TS support\n// if (\n// typeof process !== \"undefined\" &&\n// process.versions &&\n// parseInt((process.versions as any).node.split(\".\")[0]) >= 18\n// ) {\n// const isUsingTypeScript = new Error().stack?.includes(\".ts:\");\n// if (isUsingTypeScript) return \"ts\";\n// }\n// } catch (e) {\n// // Ignore errors during detection\n// }\n\n// return \"js\";\n// })();\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Immediately detects if the user's project uses TypeScript or JavaScript\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n // Only works in Node.js environment\n const fs = require(\"fs\");\n const path = require(\"path\");\n\n // Get the project root\n const projectRoot = process.cwd();\n\n // Check for tsconfig.json in project root as the fastest check\n if (fs.existsSync(path.join(projectRoot, \"tsconfig.json\"))) {\n userFileExtension = \"ts\";\n return userFileExtension;\n }\n\n // Check common src directories\n const srcDirs = [\"src\", \"source\", \"app\", \"lib\"]\n .map((dir) => path.join(projectRoot, dir))\n .filter((dir) => fs.existsSync(dir) && fs.statSync(dir).isDirectory());\n\n // Add project root to directories to check\n srcDirs.push(projectRoot);\n\n // Check each directory for .ts files\n for (const dir of srcDirs) {\n const files = fs.readdirSync(dir);\n if (\n files.some((file: any) => file.endsWith(\".ts\") || file.endsWith(\".tsx\"))\n ) {\n userFileExtension = \"ts\";\n return userFileExtension;\n }\n }\n\n // Default to js if no TypeScript indicators found\n userFileExtension = \"js\";\n return userFileExtension;\n } catch (e) {\n // Fallback to js if any errors occur\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"fs.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/fs.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,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,C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,OAAO,iBAAiB,CAAC;YAC3B,CAAC;QACH,CAAC;QAGD,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QAEX,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { promisify } from \"util\";\nimport fs from \"fs\";\n\nexport const statAsync = promisify(fs.stat);\nexport const accessAsync = promisify(fs.access);\nexport const mkdirAsync = promisify(fs.mkdir);\n\n// // Runtime-agnostic approach with proper TypeScript support\n// export const extension = (() => {\n// // Safely detect environment without direct import.meta reference\n// let currentFile = \"\";\n\n// // Try to determine the current file using environment-specific approaches\n// try {\n// if (typeof process !== \"undefined\" && process.env) {\n// // Node.js environment - use __filename\n// currentFile = __filename || \"\";\n// } else {\n// // Handle other environments (browser, Deno, etc.)\n// // This branch won't be reached in CommonJS builds\n// if (typeof (global as any)?.document === \"undefined\") {\n// // Non-browser environment that might support import.meta\n// // We'll use eval to prevent direct parsing of import.meta\n// currentFile = new Function(\n// \"return typeof import.meta !== 'undefined' ? import.meta.url : ''\"\n// )();\n// }\n// }\n// } catch (e) {\n// // Ignore errors during detection\n// }\n\n// // Check file extension\n// if (currentFile.endsWith(\".ts\") || currentFile.endsWith(\".tsx\")) {\n// return \"ts\";\n// }\n\n// // Use \"any\" type and conditional checks to avoid TypeScript errors\n// try {\n// // Check for Deno\n// const globalObj = globalThis as any;\n// if (typeof globalObj.Deno !== \"undefined\" && globalObj.Deno.emit) {\n// return \"ts\";\n// }\n\n// // Check for Bun\n// if (typeof globalObj.Bun !== \"undefined\") {\n// return \"ts\";\n// }\n\n// // Check for newer Node with TS support\n// if (\n// typeof process !== \"undefined\" &&\n// process.versions &&\n// parseInt((process.versions as any).node.split(\".\")[0]) >= 18\n// ) {\n// const isUsingTypeScript = new Error().stack?.includes?.(\".ts:\");\n// if (isUsingTypeScript) return \"ts\";\n// }\n// } catch (e) {\n// // Ignore errors during detection\n// }\n\n// return \"js\";\n// })();\n\nexport let userFileExtension: \"ts\" | \"js\" | undefined;\n\n/**\n * Immediately detects if the user's project uses TypeScript or JavaScript\n * @returns 'ts' | 'js'\n */\nexport const getUserFileExtension = (): \"ts\" | \"js\" => {\n if (userFileExtension) return userFileExtension;\n\n try {\n // Only works in Node.js environment\n const fs = require(\"fs\");\n const path = require(\"path\");\n\n // Get the project root\n const projectRoot = process.cwd();\n\n // Check for tsconfig.json in project root as the fastest check\n if (fs.existsSync(path.join(projectRoot, \"tsconfig.json\"))) {\n userFileExtension = \"ts\";\n return userFileExtension;\n }\n\n // Check common src directories\n const srcDirs = [\"src\", \"source\", \"app\", \"lib\"]\n .map((dir) => path.join(projectRoot, dir))\n .filter((dir) => fs.existsSync(dir) && fs.statSync(dir).isDirectory());\n\n // Add project root to directories to check\n srcDirs.push(projectRoot);\n\n // Check each directory for .ts files\n for (const dir of srcDirs) {\n const files = fs.readdirSync(dir);\n if (\n files.some((file: any) => file.endsWith(\".ts\") || file.endsWith(\".tsx\"))\n ) {\n userFileExtension = \"ts\";\n return userFileExtension;\n }\n }\n\n // Default to js if no TypeScript indicators found\n userFileExtension = \"js\";\n return userFileExtension;\n } catch (e) {\n // Fallback to js if any errors occur\n userFileExtension = \"js\";\n return userFileExtension;\n }\n};\n"]}
|
|
@@ -20,40 +20,41 @@ export function getFileModelModulesFileStructure(modelName) {
|
|
|
20
20
|
const kebabModelName = kebabCase(modelName).toLowerCase();
|
|
21
21
|
const lowerModelName = kebabModelName.toLowerCase();
|
|
22
22
|
const isAuthModule = modelName.toLowerCase() === "auth";
|
|
23
|
+
const ext = getUserFileExtension();
|
|
23
24
|
return {
|
|
24
25
|
core: {
|
|
25
|
-
service: `${kebabModelName}.service.${
|
|
26
|
-
controller: `${kebabModelName}.controller.${
|
|
27
|
-
middlewares: `${kebabModelName}.middlewares.${
|
|
28
|
-
authConfigs: `${kebabModelName}.auth-configs.${
|
|
29
|
-
prismaQueryOptions: `${kebabModelName}.prisma-query-options.${
|
|
30
|
-
router: `${kebabModelName}.router.${
|
|
26
|
+
service: `${kebabModelName}.service.${ext}`,
|
|
27
|
+
controller: `${kebabModelName}.controller.${ext}`,
|
|
28
|
+
middlewares: `${kebabModelName}.middlewares.${ext}`,
|
|
29
|
+
authConfigs: `${kebabModelName}.auth-configs.${ext}`,
|
|
30
|
+
prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,
|
|
31
|
+
router: `${kebabModelName}.router.${ext}`,
|
|
31
32
|
},
|
|
32
33
|
dtos: isAuthModule
|
|
33
34
|
? {
|
|
34
|
-
login: `login.dto.${
|
|
35
|
-
signup: `signup.dto.${
|
|
36
|
-
updateMe: `update-me.dto.${
|
|
37
|
-
updatePassword: `update-password.dto.${
|
|
35
|
+
login: `login.dto.${ext}`,
|
|
36
|
+
signup: `signup.dto.${ext}`,
|
|
37
|
+
updateMe: `update-me.dto.${ext}`,
|
|
38
|
+
updatePassword: `update-password.dto.${ext}`,
|
|
38
39
|
}
|
|
39
40
|
: {
|
|
40
|
-
model: `${lowerModelName}.dto.${
|
|
41
|
-
create: `create-${lowerModelName}.dto.${
|
|
42
|
-
update: `update-${lowerModelName}.dto.${
|
|
43
|
-
query: `query-${lowerModelName}.dto.${
|
|
41
|
+
model: `${lowerModelName}.dto.${ext}`,
|
|
42
|
+
create: `create-${lowerModelName}.dto.${ext}`,
|
|
43
|
+
update: `update-${lowerModelName}.dto.${ext}`,
|
|
44
|
+
query: `query-${lowerModelName}.dto.${ext}`,
|
|
44
45
|
},
|
|
45
46
|
schemas: isAuthModule
|
|
46
47
|
? {
|
|
47
|
-
login: `login.schema.${
|
|
48
|
-
signup: `signup.schema.${
|
|
49
|
-
updateMe: `update-me.schema.${
|
|
50
|
-
updatePassword: `update-password.schema.${
|
|
48
|
+
login: `login.schema.${ext}`,
|
|
49
|
+
signup: `signup.schema.${ext}`,
|
|
50
|
+
updateMe: `update-me.schema.${ext}`,
|
|
51
|
+
updatePassword: `update-password.schema.${ext}`,
|
|
51
52
|
}
|
|
52
53
|
: {
|
|
53
|
-
model: `${lowerModelName}.schema.${
|
|
54
|
-
create: `create-${lowerModelName}.schema.${
|
|
55
|
-
update: `update-${lowerModelName}.schema.${
|
|
56
|
-
query: `query-${lowerModelName}.schema.${
|
|
54
|
+
model: `${lowerModelName}.schema.${ext}`,
|
|
55
|
+
create: `create-${lowerModelName}.schema.${ext}`,
|
|
56
|
+
update: `update-${lowerModelName}.schema.${ext}`,
|
|
57
|
+
query: `query-${lowerModelName}.schema.${ext}`,
|
|
57
58
|
},
|
|
58
59
|
};
|
|
59
60
|
}
|
|
@@ -142,17 +143,19 @@ const modelRegex = /model\s+(\w+)\s*{/g;
|
|
|
142
143
|
export const models = [];
|
|
143
144
|
export const prismaModelsUniqueFields = [];
|
|
144
145
|
export function initializePrismaModels(testName) {
|
|
146
|
+
var _a, _b, _c, _d, _e;
|
|
145
147
|
const prismaContent = [];
|
|
146
148
|
const files = getAllPrismaFiles("./prisma");
|
|
147
149
|
for (const file of files) {
|
|
148
150
|
const content = fs.readFileSync(file, "utf-8");
|
|
149
|
-
if (!(prismaContent === null || prismaContent === void 0 ? void 0 : prismaContent.includes(content)))
|
|
151
|
+
if (!((_a = prismaContent === null || prismaContent === void 0 ? void 0 : prismaContent.includes) === null || _a === void 0 ? void 0 : _a.call(prismaContent, content)))
|
|
150
152
|
prismaContent.push(content);
|
|
151
153
|
}
|
|
152
154
|
const content = prismaContent
|
|
153
155
|
.join("\n")
|
|
154
156
|
.replace(modelRegex, (_, modelName) => {
|
|
155
|
-
|
|
157
|
+
var _a;
|
|
158
|
+
if (!((_a = models === null || models === void 0 ? void 0 : models.includes) === null || _a === void 0 ? void 0 : _a.call(models, modelName)))
|
|
156
159
|
models.push(camelCase(modelName.trim()));
|
|
157
160
|
return `model ${modelName} {`;
|
|
158
161
|
});
|
|
@@ -173,7 +176,7 @@ export function initializePrismaModels(testName) {
|
|
|
173
176
|
trimmedLine.startsWith("//"))
|
|
174
177
|
continue;
|
|
175
178
|
const [fieldName, type] = trimmedLine.split(/\s+/);
|
|
176
|
-
const isUnique = trimmedLine === null || trimmedLine === void 0 ? void 0 : trimmedLine.includes("@unique");
|
|
179
|
+
const isUnique = (_b = trimmedLine === null || trimmedLine === void 0 ? void 0 : trimmedLine.includes) === null || _b === void 0 ? void 0 : _b.call(trimmedLine, "@unique");
|
|
177
180
|
if (isUnique) {
|
|
178
181
|
const existingFields = prismaModelsUniqueFields[model] || [];
|
|
179
182
|
const alreadyExists = existingFields.some((field) => field.name === fieldName &&
|
|
@@ -187,12 +190,14 @@ export function initializePrismaModels(testName) {
|
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
192
|
const cleanType = type === null || type === void 0 ? void 0 : type.replace("[]", "").replace("?", "");
|
|
190
|
-
if ((trimmedLine === null || trimmedLine === void 0 ? void 0 : trimmedLine.includes("@relation")) ||
|
|
193
|
+
if (((_c = trimmedLine === null || trimmedLine === void 0 ? void 0 : trimmedLine.includes) === null || _c === void 0 ? void 0 : _c.call(trimmedLine, "@relation")) ||
|
|
191
194
|
trimmedLine.match(/\s+\w+(\[\])?(\s+@|$)/) ||
|
|
192
|
-
(models === null || models === void 0 ? void 0 : models.includes(camelCase(cleanType || "")))) {
|
|
193
|
-
const
|
|
195
|
+
((_d = models === null || models === void 0 ? void 0 : models.includes) === null || _d === void 0 ? void 0 : _d.call(models, camelCase(cleanType || "")))) {
|
|
196
|
+
const enumStart = content.indexOf(`enum ${cleanType} {`);
|
|
197
|
+
const typeStart = content.indexOf(`type ${cleanType} {`);
|
|
194
198
|
if (!cleanType ||
|
|
195
|
-
|
|
199
|
+
enumStart >= 0 ||
|
|
200
|
+
typeStart >= 0 ||
|
|
196
201
|
cleanType === "String" ||
|
|
197
202
|
cleanType === "Int" ||
|
|
198
203
|
cleanType === "Float" ||
|
|
@@ -204,7 +209,7 @@ export function initializePrismaModels(testName) {
|
|
|
204
209
|
cleanType === "Json") {
|
|
205
210
|
continue;
|
|
206
211
|
}
|
|
207
|
-
if (!(type === null || type === void 0 ? void 0 : type.includes("[]"))) {
|
|
212
|
+
if (!((_e = type === null || type === void 0 ? void 0 : type.includes) === null || _e === void 0 ? void 0 : _e.call(type, "[]"))) {
|
|
208
213
|
relations.singular.push({
|
|
209
214
|
name: fieldName,
|
|
210
215
|
type: cleanType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,IAAI,mBAAmB,GAG1B,EAAE,CAAC;AAEP,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,SAAiB;IAChE,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IACpD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IAExD,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,cAAc,YAAY,oBAAoB,EAAE,EAAE;YAC9D,UAAU,EAAE,GAAG,cAAc,eAAe,oBAAoB,EAAE,EAAE;YACpE,WAAW,EAAE,GAAG,cAAc,gBAAgB,oBAAoB,EAAE,EAAE;YACtE,WAAW,EAAE,GAAG,cAAc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;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,yBAAyB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED,sBAAsB,EAAE,CAAC;AAQzB,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACvD,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAElC,IAAI,CAAC,CAAC,SAAS,IAAI,yBAAyB,CAAC;QAAE,OAAO;IACtD,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,MAAM,CAAC;AAChB,CAAC;AAMD,SAAS,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 { getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\n\nexport let prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\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 lowerModelName = kebabModelName.toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n\n return {\n core: {\n service: `${kebabModelName}.service.${getUserFileExtension()}`,\n controller: `${kebabModelName}.controller.${getUserFileExtension()}`,\n middlewares: `${kebabModelName}.middlewares.${getUserFileExtension()}`,\n authConfigs: `${kebabModelName}.auth-configs.${getUserFileExtension()}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${getUserFileExtension()}`,\n router: `${kebabModelName}.router.${getUserFileExtension()}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${getUserFileExtension()}`,\n signup: `signup.dto.${getUserFileExtension()}`,\n updateMe: `update-me.dto.${getUserFileExtension()}`,\n updatePassword: `update-password.dto.${getUserFileExtension()}`,\n }\n : {\n model: `${lowerModelName}.dto.${getUserFileExtension()}`,\n create: `create-${lowerModelName}.dto.${getUserFileExtension()}`,\n update: `update-${lowerModelName}.dto.${getUserFileExtension()}`,\n query: `query-${lowerModelName}.dto.${getUserFileExtension()}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${getUserFileExtension()}`,\n signup: `signup.schema.${getUserFileExtension()}`,\n updateMe: `update-me.schema.${getUserFileExtension()}`,\n updatePassword: `update-password.schema.${getUserFileExtension()}`,\n }\n : {\n model: `${lowerModelName}.schema.${getUserFileExtension()}`,\n create: `create-${lowerModelName}.schema.${getUserFileExtension()}`,\n update: `update-${lowerModelName}.schema.${getUserFileExtension()}`,\n query: `query-${lowerModelName}.schema.${getUserFileExtension()}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(\n process.cwd(),\n \"src\",\n \"modules\",\n kebabCase(modelName)\n );\n\n const subdir = path.join(moduleDir, type);\n const pascalModelName = pascalCase(modelName);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n const isAuthModule = modelName.toLowerCase() === \"auth\";\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 import(filePath).catch(() => null);\n if (module) {\n if (isAuthModule) {\n // Auth module uses different naming conventions\n const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);\n const expectedName = `${pascalKey}${\n type === \"dtos\" ? \"Dto\" : \"Schema\"\n }`;\n result[type][key] = module.default;\n } else {\n // Standard modules\n const expectedName =\n key === \"model\"\n ? `${pascalModelName}${type === \"dtos\" ? \"Dto\" : \"Schema\"}`\n : `${\n key.charAt(0).toUpperCase() + key.slice(1)\n }${pascalModelName}${type === \"dtos\" ? \"Dto\" : \"Schema\"}`;\n\n result[type][key] = module.default;\n }\n }\n } catch (error) {\n // Silent fail - file might not exist\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\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): Promise<Record<string, any>> {\n const moduleDir = path.resolve(process.cwd(), \"src\", \"modules\", modelName);\n\n const result: {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: any;\n prismaQueryOptions?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\n } = {\n dtos: {},\n schemas: {},\n };\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\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(() => null);\n if (module) {\n if (key === \"middlewares\") result[key] = module;\n else result[key as keyof typeof result] = module.default || module;\n }\n } catch {}\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Cache the result\n prismaModelsModules[modelName] = result;\n\n return result;\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 const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels(testName?: string) {\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 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 for (const model of models) {\n const modelName = pascalCase(model);\n\n // let modelFile;\n // for (const file of files) {\n // const filePath = path.join(file);\n // const stats = fs.statSync(filePath);\n\n // if (stats.isFile()) {\n // const content = fs.readFileSync(filePath, \"utf-8\");\n // prismaContent.push(content);\n // if (content?.includes(`model ${modelName} {`)) {\n // modelFile = file;\n // break;\n // }\n // }\n // }\n\n // if (!modelFile) {\n // return;\n // }\n\n // const content = fs.readFileSync(path.join(modelFile), \"utf-8\");\n const modelStart = content.indexOf(`model ${modelName} {`);\n const modelEnd = content.indexOf(\"}\", modelStart);\n const modelDefinition = content.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 )\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 modelStart = content.indexOf(`enum ${cleanType} {`);\n\n if (\n !cleanType ||\n modelStart >= 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\ninitializePrismaModels();\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(modelName: string) {\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() {\n return models;\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) {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
|
|
1
|
+
{"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,IAAI,mBAAmB,GAG1B,EAAE,CAAC;AAEP,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,mBAAmB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,SAAiB;IAChE,MAAM,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IACpD,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACxD,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO;QACL,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,cAAc,YAAY,GAAG,EAAE;YAC3C,UAAU,EAAE,GAAG,cAAc,eAAe,GAAG,EAAE;YACjD,WAAW,EAAE,GAAG,cAAc,gBAAgB,GAAG,EAAE;YACnD,WAAW,EAAE,GAAG,cAAc,iBAAi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,CAAC;gBACL,CAAC;YACH,CAAC;YAED,yBAAyB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED,sBAAsB,EAAE,CAAC;AAQzB,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACvD,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAElC,IAAI,CAAC,CAAC,SAAS,IAAI,yBAAyB,CAAC;QAAE,OAAO;IACtD,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,MAAM,CAAC;AAChB,CAAC;AAMD,SAAS,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 { getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\n\nexport let prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\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 lowerModelName = kebabModelName.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 prismaQueryOptions: `${kebabModelName}.prisma-query-options.${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: `${lowerModelName}.dto.${ext}`,\n create: `create-${lowerModelName}.dto.${ext}`,\n update: `update-${lowerModelName}.dto.${ext}`,\n query: `query-${lowerModelName}.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: `${lowerModelName}.schema.${ext}`,\n create: `create-${lowerModelName}.schema.${ext}`,\n update: `update-${lowerModelName}.schema.${ext}`,\n query: `query-${lowerModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(\n process.cwd(),\n \"src\",\n \"modules\",\n kebabCase(modelName)\n );\n\n const subdir = path.join(moduleDir, type);\n const pascalModelName = pascalCase(modelName);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n const isAuthModule = modelName.toLowerCase() === \"auth\";\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 import(filePath).catch(() => null);\n if (module) {\n if (isAuthModule) {\n // Auth module uses different naming conventions\n const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);\n const expectedName = `${pascalKey}${\n type === \"dtos\" ? \"Dto\" : \"Schema\"\n }`;\n result[type][key] = module.default;\n } else {\n // Standard modules\n const expectedName =\n key === \"model\"\n ? `${pascalModelName}${type === \"dtos\" ? \"Dto\" : \"Schema\"}`\n : `${\n key.charAt(0).toUpperCase() + key.slice(1)\n }${pascalModelName}${type === \"dtos\" ? \"Dto\" : \"Schema\"}`;\n\n result[type][key] = module.default;\n }\n }\n } catch (error) {\n // Silent fail - file might not exist\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\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): Promise<Record<string, any>> {\n const moduleDir = path.resolve(process.cwd(), \"src\", \"modules\", modelName);\n\n const result: {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: any;\n prismaQueryOptions?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\n } = {\n dtos: {},\n schemas: {},\n };\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\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(() => null);\n if (module) {\n if (key === \"middlewares\") result[key] = module;\n else result[key as keyof typeof result] = module.default || module;\n }\n } catch {}\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Cache the result\n prismaModelsModules[modelName] = result;\n\n return result;\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 const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels(testName?: string) {\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 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 for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = content.indexOf(`model ${modelName} {`);\n const modelEnd = content.indexOf(\"}\", modelStart);\n const modelDefinition = content.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 )\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 = content.indexOf(`enum ${cleanType} {`);\n const typeStart = content.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 // && !content.includes?.(`model ${cleanType} {`)\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\ninitializePrismaModels();\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(modelName: string) {\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() {\n return models;\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) {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { kebabCase } from "../helpers/change-case.helpers";
|
|
11
|
+
import fs from "fs";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import pluralize from "pluralize";
|
|
14
|
+
import { getAppRoutes } from "../helpers/base.controller.helpers";
|
|
15
|
+
function generateInsomniaCollection() {
|
|
16
|
+
const routes = getAppRoutes();
|
|
17
|
+
const resourceTypes = [
|
|
18
|
+
...new Set(routes.map((route) => route.path.split("/")[1] || "root")),
|
|
19
|
+
];
|
|
20
|
+
const collection = {
|
|
21
|
+
_type: "export",
|
|
22
|
+
__export_format: 4,
|
|
23
|
+
__export_date: new Date().toISOString(),
|
|
24
|
+
__export_source: "script-generated",
|
|
25
|
+
resources: [],
|
|
26
|
+
};
|
|
27
|
+
collection.resources.push({
|
|
28
|
+
_id: "wrk_arkos",
|
|
29
|
+
parentId: null,
|
|
30
|
+
modified: new Date().toISOString(),
|
|
31
|
+
created: new Date().toISOString(),
|
|
32
|
+
name: "Project API",
|
|
33
|
+
description: "Automatically generated Arkos API collection",
|
|
34
|
+
_type: "workspace",
|
|
35
|
+
});
|
|
36
|
+
const routesByResource = resourceTypes.reduce((acc, resourceType) => {
|
|
37
|
+
if (resourceType === "root")
|
|
38
|
+
return acc;
|
|
39
|
+
acc[resourceType] = {
|
|
40
|
+
findMany: routes.find((r) => r.method === "GET" && r.path === `/${resourceType}`),
|
|
41
|
+
findOne: routes.find((r) => r.method === "GET" && r.path === `/${resourceType}/:id`),
|
|
42
|
+
createOne: routes.find((r) => r.method === "POST" && r.path === `/${resourceType}`),
|
|
43
|
+
createMany: routes.find((r) => r.method === "POST" && r.path === `/${resourceType}/many`),
|
|
44
|
+
updateOne: routes.find((r) => r.method === "PATCH" && r.path === `/${resourceType}/:id`),
|
|
45
|
+
updateMany: routes.find((r) => r.method === "PATCH" && r.path === `/${resourceType}/many`),
|
|
46
|
+
deleteOne: routes.find((r) => r.method === "DELETE" && r.path === `/${resourceType}/:id`),
|
|
47
|
+
deleteMany: routes.find((r) => r.method === "DELETE" && r.path === `/${resourceType}/many`),
|
|
48
|
+
};
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
Object.entries(routesByResource).forEach(([resourceType, resourceRoutes], index) => {
|
|
52
|
+
const folderId = `fld_${resourceType}`;
|
|
53
|
+
collection.resources.push({
|
|
54
|
+
_id: folderId,
|
|
55
|
+
parentId: "wrk_arkos",
|
|
56
|
+
modified: new Date().toISOString(),
|
|
57
|
+
created: new Date().toISOString(),
|
|
58
|
+
name: resourceType
|
|
59
|
+
.replace(/-/g, " ")
|
|
60
|
+
.replace(/\b\w/g, (l) => l.toUpperCase()),
|
|
61
|
+
description: `${resourceType
|
|
62
|
+
.replace(/-/g, " ")
|
|
63
|
+
.replace(/\b\w/g, (l) => l.toUpperCase())} endpoints`,
|
|
64
|
+
environment: {},
|
|
65
|
+
environmentPropertyOrder: null,
|
|
66
|
+
metaSortKey: -1000 + index * 100,
|
|
67
|
+
_type: "request_group",
|
|
68
|
+
});
|
|
69
|
+
const methodMappings = [
|
|
70
|
+
{ key: "findMany", name: "Find Many", method: "GET" },
|
|
71
|
+
{ key: "findOne", name: "Find One", method: "GET" },
|
|
72
|
+
{ key: "createOne", name: "Create One", method: "POST" },
|
|
73
|
+
{ key: "createMany", name: "Create Many", method: "POST" },
|
|
74
|
+
{ key: "updateOne", name: "Update One", method: "PATCH" },
|
|
75
|
+
{ key: "updateMany", name: "Update Many", method: "PATCH" },
|
|
76
|
+
{ key: "deleteOne", name: "Delete One", method: "DELETE" },
|
|
77
|
+
{ key: "deleteMany", name: "Delete Many", method: "DELETE" },
|
|
78
|
+
];
|
|
79
|
+
methodMappings.forEach((mapping, routeIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const route = resourceRoutes[mapping.key];
|
|
81
|
+
if (!route)
|
|
82
|
+
return;
|
|
83
|
+
const modelName = kebabCase(pluralize.singular(mapping.key));
|
|
84
|
+
const reqId = `req_${resourceType}_${mapping.key}`;
|
|
85
|
+
const dtoPath = path.join(process.cwd(), `src/modules/${modelName}/dtos`);
|
|
86
|
+
const dotMapping = {
|
|
87
|
+
createOne: `create-${modelName}.dto.ts`,
|
|
88
|
+
updateOne: `create-${modelName}.dto.ts`,
|
|
89
|
+
};
|
|
90
|
+
const dto = yield import(path.join(dtoPath, dotMapping[mapping.key]));
|
|
91
|
+
collection.resources.push({
|
|
92
|
+
_id: reqId,
|
|
93
|
+
parentId: folderId,
|
|
94
|
+
modified: new Date().toISOString(),
|
|
95
|
+
created: new Date().toISOString(),
|
|
96
|
+
url: `{{BASE_URL}}/${route.path}`,
|
|
97
|
+
name: mapping.name,
|
|
98
|
+
description: `${mapping.method} request for ${route.path}`,
|
|
99
|
+
method: route.method,
|
|
100
|
+
body: route.method !== "GET"
|
|
101
|
+
? {
|
|
102
|
+
mimeType: "application/json",
|
|
103
|
+
text: route.method === "POST" || route.method === "PATCH"
|
|
104
|
+
? route.path.includes("/many")
|
|
105
|
+
? "[{}]"
|
|
106
|
+
: "{}"
|
|
107
|
+
: "[]",
|
|
108
|
+
}
|
|
109
|
+
: {},
|
|
110
|
+
parameters: route.path.includes(":")
|
|
111
|
+
? route.path
|
|
112
|
+
.split("/")
|
|
113
|
+
.filter((p) => p.startsWith(":"))
|
|
114
|
+
.map((param) => ({
|
|
115
|
+
id: `par_${param.slice(1)}`,
|
|
116
|
+
name: param.slice(1),
|
|
117
|
+
value: "",
|
|
118
|
+
description: `${param.slice(1)} parameter`,
|
|
119
|
+
disabled: false,
|
|
120
|
+
}))
|
|
121
|
+
: [],
|
|
122
|
+
headers: route.method !== "GET"
|
|
123
|
+
? [
|
|
124
|
+
{
|
|
125
|
+
name: "Content-Type",
|
|
126
|
+
value: "application/json",
|
|
127
|
+
},
|
|
128
|
+
]
|
|
129
|
+
: [],
|
|
130
|
+
authentication: {},
|
|
131
|
+
metaSortKey: -1000 + routeIndex * 10,
|
|
132
|
+
isPrivate: false,
|
|
133
|
+
settingStoreCookies: true,
|
|
134
|
+
settingSendCookies: true,
|
|
135
|
+
settingDisableRenderRequestBody: false,
|
|
136
|
+
settingEncodeUrl: true,
|
|
137
|
+
settingRebuildPath: true,
|
|
138
|
+
settingFollowRedirects: "global",
|
|
139
|
+
_type: "request",
|
|
140
|
+
});
|
|
141
|
+
}));
|
|
142
|
+
});
|
|
143
|
+
const rootFolderId = "fld_root";
|
|
144
|
+
collection.resources.push({
|
|
145
|
+
_id: rootFolderId,
|
|
146
|
+
parentId: "wrk_arkos",
|
|
147
|
+
modified: new Date().toISOString(),
|
|
148
|
+
created: new Date().toISOString(),
|
|
149
|
+
name: "Root",
|
|
150
|
+
description: "Root API endpoints",
|
|
151
|
+
environment: {},
|
|
152
|
+
environmentPropertyOrder: null,
|
|
153
|
+
metaSortKey: -100,
|
|
154
|
+
_type: "request_group",
|
|
155
|
+
});
|
|
156
|
+
const rootRoutes = routes.filter((route) => route.path === "/api" || route.path === "/available-routes");
|
|
157
|
+
rootRoutes.forEach((route, index) => {
|
|
158
|
+
collection.resources.push({
|
|
159
|
+
_id: `req_root_${route.path.slice(1)}`,
|
|
160
|
+
parentId: rootFolderId,
|
|
161
|
+
modified: new Date().toISOString(),
|
|
162
|
+
created: new Date().toISOString(),
|
|
163
|
+
url: `{{BASE_URL}}/${route.path}`,
|
|
164
|
+
name: route.path === "/api" ? "Welcome" : "Available Routes",
|
|
165
|
+
description: `${route.method} request for ${route.path}`,
|
|
166
|
+
method: route.method,
|
|
167
|
+
body: {},
|
|
168
|
+
parameters: [],
|
|
169
|
+
headers: [],
|
|
170
|
+
authentication: {},
|
|
171
|
+
metaSortKey: -1000 + index * 10,
|
|
172
|
+
isPrivate: false,
|
|
173
|
+
settingStoreCookies: true,
|
|
174
|
+
settingSendCookies: true,
|
|
175
|
+
settingDisableRenderRequestBody: false,
|
|
176
|
+
settingEncodeUrl: true,
|
|
177
|
+
settingRebuildPath: true,
|
|
178
|
+
settingFollowRedirects: "global",
|
|
179
|
+
_type: "request",
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
return collection;
|
|
183
|
+
}
|
|
184
|
+
export function writeInsomniaCollectionJson() {
|
|
185
|
+
const insomniaCollection = generateInsomniaCollection();
|
|
186
|
+
fs.writeFileSync(path.join(process.cwd(), ".cache", "insomnia-collection.json"), JSON.stringify(insomniaCollection, null, 2));
|
|
187
|
+
console.log("Insomnia collection generated successfully! .cache/insomnia-collection.json");
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=generate-insomnia-collection.js.map
|