arkos 1.1.12-test → 1.1.13-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app.js +1 -1
- package/dist/cjs/app.js.map +1 -1
- package/dist/cjs/modules/auth/auth.controller.js +53 -64
- package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
- package/dist/cjs/modules/auth/auth.router.js +46 -58
- package/dist/cjs/modules/auth/auth.router.js.map +1 -1
- package/dist/cjs/modules/auth/auth.service.js +75 -97
- package/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +6 -7
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js.map +1 -1
- package/dist/cjs/modules/base/base.controller.js +30 -46
- package/dist/cjs/modules/base/base.controller.js.map +1 -1
- package/dist/cjs/modules/base/base.middlewares.js +17 -21
- package/dist/cjs/modules/base/base.middlewares.js.map +1 -1
- package/dist/cjs/modules/base/base.router.js +6 -17
- package/dist/cjs/modules/base/base.router.js.map +1 -1
- package/dist/cjs/modules/base/base.service.js +128 -116
- package/dist/cjs/modules/base/base.service.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js +3 -5
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js.map +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +36 -47
- 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 +30 -40
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/cjs/modules/email/email.service.js +28 -39
- package/dist/cjs/modules/email/email.service.js.map +1 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js +6 -3
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js +3 -12
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +17 -31
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/cjs/modules/file-uploader/file-uploader.controller.js +18 -27
- package/dist/cjs/modules/file-uploader/file-uploader.controller.js.map +1 -1
- package/dist/cjs/modules/file-uploader/file-uploader.router.js +23 -34
- package/dist/cjs/modules/file-uploader/file-uploader.router.js.map +1 -1
- package/dist/cjs/modules/file-uploader/file-uploader.service.js +117 -131
- 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 +15 -26
- 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/utils/cli/build.js +9 -2
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +43 -48
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/start.js +35 -38
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/features/api.features.js +26 -33
- package/dist/cjs/utils/features/api.features.js.map +1 -1
- package/dist/cjs/utils/helpers/api.features.helpers.js +4 -6
- package/dist/cjs/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/change-case.helpers.js +28 -36
- package/dist/cjs/utils/helpers/change-case.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/deepmerge.helper.js +4 -8
- package/dist/cjs/utils/helpers/deepmerge.helper.js.map +1 -1
- package/dist/cjs/utils/helpers/global.helpers.js +2 -13
- package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/models.helpers.js +65 -80
- package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +23 -34
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/cjs/utils/validate-dto.js +6 -17
- package/dist/cjs/utils/validate-dto.js.map +1 -1
- package/dist/cjs/utils/validate-schema.js +6 -17
- package/dist/cjs/utils/validate-schema.js.map +1 -1
- package/dist/es2020/app.js +1 -1
- package/dist/es2020/app.js.map +1 -1
- package/dist/es2020/modules/auth/auth.controller.js +53 -64
- package/dist/es2020/modules/auth/auth.controller.js.map +1 -1
- package/dist/es2020/modules/auth/auth.router.js +46 -58
- package/dist/es2020/modules/auth/auth.router.js.map +1 -1
- package/dist/es2020/modules/auth/auth.service.js +75 -97
- package/dist/es2020/modules/auth/auth.service.js.map +1 -1
- package/dist/es2020/modules/auth/utils/helpers/auth.controller.helpers.js +6 -7
- package/dist/es2020/modules/auth/utils/helpers/auth.controller.helpers.js.map +1 -1
- package/dist/es2020/modules/base/base.controller.js +30 -46
- package/dist/es2020/modules/base/base.controller.js.map +1 -1
- package/dist/es2020/modules/base/base.middlewares.js +17 -21
- package/dist/es2020/modules/base/base.middlewares.js.map +1 -1
- package/dist/es2020/modules/base/base.router.js +6 -17
- package/dist/es2020/modules/base/base.router.js.map +1 -1
- package/dist/es2020/modules/base/base.service.js +128 -116
- package/dist/es2020/modules/base/base.service.js.map +1 -1
- package/dist/es2020/modules/base/utils/helpers/base.controller.helpers.js +3 -5
- package/dist/es2020/modules/base/utils/helpers/base.controller.helpers.js.map +1 -1
- package/dist/es2020/modules/base/utils/helpers/base.router.helpers.js +36 -47
- 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 +30 -40
- package/dist/es2020/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/es2020/modules/email/email.service.js +28 -39
- package/dist/es2020/modules/email/email.service.js.map +1 -1
- package/dist/es2020/modules/error-handler/error-handler.controller.js +6 -3
- package/dist/es2020/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/es2020/modules/error-handler/utils/catch-async.js +3 -12
- package/dist/es2020/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/es2020/modules/error-handler/utils/error-handler.helpers.js +17 -31
- package/dist/es2020/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/es2020/modules/file-uploader/file-uploader.controller.js +18 -27
- package/dist/es2020/modules/file-uploader/file-uploader.controller.js.map +1 -1
- package/dist/es2020/modules/file-uploader/file-uploader.router.js +23 -34
- package/dist/es2020/modules/file-uploader/file-uploader.router.js.map +1 -1
- package/dist/es2020/modules/file-uploader/file-uploader.service.js +117 -131
- 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 +15 -26
- 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/utils/cli/build.js +9 -2
- package/dist/es2020/utils/cli/build.js.map +1 -1
- package/dist/es2020/utils/cli/dev.js +43 -48
- package/dist/es2020/utils/cli/dev.js.map +1 -1
- package/dist/es2020/utils/cli/start.js +35 -38
- package/dist/es2020/utils/cli/start.js.map +1 -1
- package/dist/es2020/utils/features/api.features.js +26 -33
- package/dist/es2020/utils/features/api.features.js.map +1 -1
- package/dist/es2020/utils/helpers/api.features.helpers.js +4 -6
- package/dist/es2020/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/change-case.helpers.js +28 -36
- package/dist/es2020/utils/helpers/change-case.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/deepmerge.helper.js +4 -8
- package/dist/es2020/utils/helpers/deepmerge.helper.js.map +1 -1
- package/dist/es2020/utils/helpers/global.helpers.js +2 -13
- package/dist/es2020/utils/helpers/global.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/models.helpers.js +65 -80
- package/dist/es2020/utils/helpers/models.helpers.js.map +1 -1
- package/dist/es2020/utils/helpers/prisma.helpers.js +23 -34
- package/dist/es2020/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/es2020/utils/validate-dto.js +6 -17
- package/dist/es2020/utils/validate-dto.js.map +1 -1
- package/dist/es2020/utils/validate-schema.js +6 -17
- package/dist/es2020/utils/validate-schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.features.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/api.features.helpers.ts"],"names":[],"mappings":";;AAiDA,sEAiHC;AA7ID,MAAM,oBAAoB,GAAgB;IACxC,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC;IAC3D,aAAa,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC;IACrE,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC;CAChE,CAAC;AAwBF,SAAgB,6BAA6B,CAC3C,KAA0B,EAE1B,cAA2B,oBAAoB;IAE/C,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAC7D,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"api.features.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/api.features.helpers.ts"],"names":[],"mappings":";;AAiDA,sEAiHC;AA7ID,MAAM,oBAAoB,GAAgB;IACxC,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC;IAC3D,aAAa,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC;IACrE,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC;CAChE,CAAC;AAwBF,SAAgB,6BAA6B,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AK,CAAC,CAAC;IACzB,CAAC;IAGD,IAAI,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IACxC,CAAC;IAGD,IAAI,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC;QACzD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Configuration types for field type mapping\n */\ninterface FieldConfig {\n dateFields: string[];\n booleanFields: string[];\n numericFields: string[];\n}\n\n/**\n * Type for the structured filter object returned by the parser\n */\ntype ParsedFilter = {\n [key: string]: any;\n orderBy?: Record<string, \"asc\" | \"desc\">;\n OR?: Record<string, any>[];\n};\n\n/**\n * Default configuration for field types\n */\nconst DEFAULT_FIELD_CONFIG: FieldConfig = {\n dateFields: [\"createdAt\", \"updatedAt\", \"deletedAt\", \"date\"],\n booleanFields: [\"isActive\", \"isDeleted\", \"isPublished\", \"isArchived\"],\n numericFields: [\"age\", \"price\", \"quantity\", \"amount\", \"rating\"],\n};\n\n/**\n * Parses query parameters into a structured filter object compatible with Prisma queries.\n * Supports various operators and data type conversions.\n *\n * @param query - Object containing query parameters\n * @param fieldConfig - Optional configuration for field type mapping\n * @returns Structured filter object for database queries\n *\n * @example\n * // Basic usage\n * parseQueryParamsWithModifiers({ name__contains: 'john' })\n * // => { name: { contains: 'john', mode: 'sensitive' } }\n *\n * @example\n * // Complex query\n * parseQueryParamsWithModifiers({\n * name__not__equals: 'john',\n * age__gt: '25',\n * tags__in: 'tag1,tag2',\n * orderBy__createdAt: 'desc'\n * })\n */\nexport function parseQueryParamsWithModifiers(\n query: Record<string, any>,\n // excludedFields: string[],\n fieldConfig: FieldConfig = DEFAULT_FIELD_CONFIG\n): ParsedFilter {\n return Object.entries(JSON.parse(JSON.stringify(query))).reduce(\n (acc, [key, value]) => {\n const parts = key.split(\"__\");\n if (!value && value !== false && value !== \"false\" && parts.length < 2)\n return acc;\n\n // Convert value to string if it's not already\n const stringValue = Array.isArray(value) ? value[0]?.toString() : value;\n\n if (parts.length < 2) {\n acc[key] =\n typeof value === \"string\" && !Number.isNaN(value)\n ? convertValue(stringValue, parts[0], fieldConfig)\n : value;\n return acc;\n }\n const fieldName = parts[0];\n\n // Handle ordering\n if (fieldName === \"orderBy\" && parts.length === 2) {\n if (!acc.orderBy) acc.orderBy = {};\n acc.orderBy[parts[1]] = stringValue as \"asc\" | \"desc\";\n return acc;\n }\n\n // Handle simple equals case\n if (parts.length === 1) {\n acc[fieldName] = {\n equals: convertValue(stringValue, fieldName, fieldConfig),\n };\n return acc;\n }\n\n let currentLevel = acc;\n let currentKey = fieldName;\n\n // Build nested structure\n for (let i = 1; i < parts.length - 1; i++) {\n if (!currentLevel[currentKey]) {\n currentLevel[currentKey] = {};\n }\n currentLevel = currentLevel[currentKey];\n currentKey = parts[i];\n }\n\n const lastOperator = parts[parts.length - 1];\n\n // Handle special operators\n switch (lastOperator) {\n case \"icontains\":\n currentLevel[currentKey] = {\n contains: stringValue,\n mode: \"insensitive\",\n };\n break;\n\n case \"contains\":\n currentLevel[currentKey] = {\n contains: stringValue,\n mode: \"sensitive\",\n };\n break;\n\n case \"in\":\n case \"notIn\":\n currentLevel[currentKey] = {\n [lastOperator]: stringValue\n .split(\",\")\n .map((v: string) =>\n convertValue(v.trim(), fieldName, fieldConfig)\n ),\n };\n break;\n\n case \"or\":\n const values: string[] = stringValue.split(\",\");\n if (!acc.OR) acc.OR = [];\n acc.OR.push(\n ...values.map((val) => ({\n [fieldName]: {\n equals: convertValue(val.trim(), fieldName, fieldConfig),\n },\n }))\n );\n break;\n\n case \"isNull\":\n currentLevel[currentKey] = {\n equals: stringValue.toLowerCase() === \"true\" ? null : undefined,\n };\n break;\n\n case \"isEmpty\":\n currentLevel[currentKey] = {\n equals: stringValue.toLowerCase() === \"true\" ? \"\" : undefined,\n };\n break;\n\n default:\n currentLevel[currentKey] = {\n [lastOperator]: convertValue(stringValue, fieldName, fieldConfig),\n };\n }\n\n return acc;\n },\n {} as ParsedFilter\n );\n}\n\n/**\n * Converts string values to appropriate types based on field configuration\n * \n * // Example usage:\n/*\n const query = {\n name__not__equals: 'uanela',\n email__contains: 'example.com',\n description__icontains: 'test',\n age__gt: '25',\n status: 'active',\n tags__in: 'tag1,tag2,tag3',\n createdAt__gt: '2024-01-01',\n isActive: 'true',\n orderBy__createdAt: 'desc'\n };\n \n const result = parseQueryParamsWithModifiers(query);\n */\nfunction convertValue(\n value: string,\n fieldName: string,\n config: FieldConfig\n): any {\n // Handle date fields\n if (config.dateFields?.includes?.(fieldName) && value) {\n return new Date(value);\n }\n\n // Handle boolean fields\n if (config.booleanFields?.includes?.(fieldName) && value) {\n return value.toLowerCase() === \"true\";\n }\n\n // Handle numeric fields\n if (config.numericFields?.includes?.(fieldName) && value) {\n return Number(value);\n }\n\n return value;\n}\n"]}
|
|
@@ -37,31 +37,28 @@ function split(value) {
|
|
|
37
37
|
return result.slice(start, end).split(/\0/g);
|
|
38
38
|
}
|
|
39
39
|
function splitSeparateNumbers(value) {
|
|
40
|
-
var _a;
|
|
41
40
|
const words = split(value);
|
|
42
41
|
for (let i = 0; i < words.length; i++) {
|
|
43
42
|
const word = words[i];
|
|
44
43
|
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
45
44
|
if (match) {
|
|
46
|
-
const offset = match.index + (
|
|
45
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
47
46
|
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
return words;
|
|
51
50
|
}
|
|
52
51
|
function noCase(input, options) {
|
|
53
|
-
var _a;
|
|
54
52
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
55
53
|
return (prefix +
|
|
56
|
-
words.map(lowerFactory(options
|
|
54
|
+
words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") +
|
|
57
55
|
suffix);
|
|
58
56
|
}
|
|
59
57
|
function camelCase(input, options) {
|
|
60
|
-
var _a;
|
|
61
58
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
62
|
-
const lower = lowerFactory(options
|
|
63
|
-
const upper = upperFactory(options
|
|
64
|
-
const transform =
|
|
59
|
+
const lower = lowerFactory(options?.locale);
|
|
60
|
+
const upper = upperFactory(options?.locale);
|
|
61
|
+
const transform = options?.mergeAmbiguousCharacters
|
|
65
62
|
? capitalCaseTransformFactory(lower, upper)
|
|
66
63
|
: pascalCaseTransformFactory(lower, upper);
|
|
67
64
|
return (prefix +
|
|
@@ -71,54 +68,50 @@ function camelCase(input, options) {
|
|
|
71
68
|
return lower(word);
|
|
72
69
|
return transform(word, index);
|
|
73
70
|
})
|
|
74
|
-
.join(
|
|
71
|
+
.join(options?.delimiter ?? "") +
|
|
75
72
|
suffix);
|
|
76
73
|
}
|
|
77
74
|
function pascalCase(input, options) {
|
|
78
|
-
var _a;
|
|
79
75
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
80
|
-
const lower = lowerFactory(options
|
|
81
|
-
const upper = upperFactory(options
|
|
82
|
-
const transform =
|
|
76
|
+
const lower = lowerFactory(options?.locale);
|
|
77
|
+
const upper = upperFactory(options?.locale);
|
|
78
|
+
const transform = options?.mergeAmbiguousCharacters
|
|
83
79
|
? capitalCaseTransformFactory(lower, upper)
|
|
84
80
|
: pascalCaseTransformFactory(lower, upper);
|
|
85
|
-
return prefix + words.map(transform).join(
|
|
81
|
+
return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
|
|
86
82
|
}
|
|
87
83
|
function pascalSnakeCase(input, options) {
|
|
88
|
-
return capitalCase(input,
|
|
84
|
+
return capitalCase(input, { delimiter: "_", ...options });
|
|
89
85
|
}
|
|
90
86
|
function capitalCase(input, options) {
|
|
91
|
-
var _a;
|
|
92
87
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
93
|
-
const lower = lowerFactory(options
|
|
94
|
-
const upper = upperFactory(options
|
|
88
|
+
const lower = lowerFactory(options?.locale);
|
|
89
|
+
const upper = upperFactory(options?.locale);
|
|
95
90
|
return (prefix +
|
|
96
91
|
words
|
|
97
92
|
.map(capitalCaseTransformFactory(lower, upper))
|
|
98
|
-
.join(
|
|
93
|
+
.join(options?.delimiter ?? " ") +
|
|
99
94
|
suffix);
|
|
100
95
|
}
|
|
101
96
|
function constantCase(input, options) {
|
|
102
|
-
var _a;
|
|
103
97
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
104
98
|
return (prefix +
|
|
105
|
-
words.map(upperFactory(options
|
|
99
|
+
words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") +
|
|
106
100
|
suffix);
|
|
107
101
|
}
|
|
108
102
|
function dotCase(input, options) {
|
|
109
|
-
return noCase(input,
|
|
103
|
+
return noCase(input, { delimiter: ".", ...options });
|
|
110
104
|
}
|
|
111
105
|
function kebabCase(input, options) {
|
|
112
|
-
return noCase(input,
|
|
106
|
+
return noCase(input, { delimiter: "-", ...options });
|
|
113
107
|
}
|
|
114
108
|
function pathCase(input, options) {
|
|
115
|
-
return noCase(input,
|
|
109
|
+
return noCase(input, { delimiter: "/", ...options });
|
|
116
110
|
}
|
|
117
111
|
function sentenceCase(input, options) {
|
|
118
|
-
var _a;
|
|
119
112
|
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
120
|
-
const lower = lowerFactory(options
|
|
121
|
-
const upper = upperFactory(options
|
|
113
|
+
const lower = lowerFactory(options?.locale);
|
|
114
|
+
const upper = upperFactory(options?.locale);
|
|
122
115
|
const transform = capitalCaseTransformFactory(lower, upper);
|
|
123
116
|
return (prefix +
|
|
124
117
|
words
|
|
@@ -127,14 +120,14 @@ function sentenceCase(input, options) {
|
|
|
127
120
|
return transform(word);
|
|
128
121
|
return lower(word);
|
|
129
122
|
})
|
|
130
|
-
.join(
|
|
123
|
+
.join(options?.delimiter ?? " ") +
|
|
131
124
|
suffix);
|
|
132
125
|
}
|
|
133
126
|
function snakeCase(input, options) {
|
|
134
|
-
return noCase(input,
|
|
127
|
+
return noCase(input, { delimiter: "_", ...options });
|
|
135
128
|
}
|
|
136
129
|
function trainCase(input, options) {
|
|
137
|
-
return capitalCase(input,
|
|
130
|
+
return capitalCase(input, { delimiter: "-", ...options });
|
|
138
131
|
}
|
|
139
132
|
function lowerFactory(locale) {
|
|
140
133
|
return locale === false
|
|
@@ -157,22 +150,21 @@ function pascalCaseTransformFactory(lower, upper) {
|
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
152
|
function splitPrefixSuffix(input, options = {}) {
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const suffixCharacters = (_c = options.suffixCharacters) !== null && _c !== void 0 ? _c : DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
153
|
+
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
154
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
155
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
164
156
|
let prefixIndex = 0;
|
|
165
157
|
let suffixIndex = input.length;
|
|
166
158
|
while (prefixIndex < input.length) {
|
|
167
159
|
const char = input.charAt(prefixIndex);
|
|
168
|
-
if (!
|
|
160
|
+
if (!prefixCharacters?.includes?.(char))
|
|
169
161
|
break;
|
|
170
162
|
prefixIndex++;
|
|
171
163
|
}
|
|
172
164
|
while (suffixIndex > prefixIndex) {
|
|
173
165
|
const index = suffixIndex - 1;
|
|
174
166
|
const char = input.charAt(index);
|
|
175
|
-
if (!
|
|
167
|
+
if (!suffixCharacters?.includes?.(char))
|
|
176
168
|
break;
|
|
177
169
|
suffixIndex = index;
|
|
178
170
|
}
|
|
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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"]}
|
|
1
|
+
{"version":3,"file":"change-case.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/change-case.helpers.ts"],"names":[],"mappings":";;AA6CA,sBAkBC;AAKD,oDAWC;AAKD,wBAOC;AAKD,8BAiBC;AAKD,gCAQC;AAKD,0CAEC;AAKD,kCAWC;AAKD,oCAOC;AAKD,0BAEC;AAKD,8BAEC;AAKD,4BAEC;AAKD,oCAeC;AAKD,8BAEC;AAK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WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC;YAAE,MAAM;QAC/C,WAAW,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,WAAW,GAAG,WAAW,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,WAAW,GAAG,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC;YAAE,MAAM;QAC/C,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"]}
|
|
@@ -26,8 +26,7 @@ function getEnumerableOwnPropertySymbols(target) {
|
|
|
26
26
|
: [];
|
|
27
27
|
}
|
|
28
28
|
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
29
|
-
|
|
30
|
-
return options.clone !== false && ((_a = options.isMergeableObject) === null || _a === void 0 ? void 0 : _a.call(options, value))
|
|
29
|
+
return options.clone !== false && options.isMergeableObject?.(value)
|
|
31
30
|
? deepmerge(emptyTarget(value), value, options)
|
|
32
31
|
: value;
|
|
33
32
|
}
|
|
@@ -57,9 +56,8 @@ function propertyIsUnsafe(target, key) {
|
|
|
57
56
|
Object.propertyIsEnumerable.call(target, key)));
|
|
58
57
|
}
|
|
59
58
|
function mergeObject(target, source, options) {
|
|
60
|
-
var _a;
|
|
61
59
|
const destination = {};
|
|
62
|
-
if (
|
|
60
|
+
if (options.isMergeableObject?.(target)) {
|
|
63
61
|
getKeys(target).forEach(function (key) {
|
|
64
62
|
destination[key] = options.cloneUnlessOtherwiseSpecified
|
|
65
63
|
? options.cloneUnlessOtherwiseSpecified(target[key], options)
|
|
@@ -67,12 +65,11 @@ function mergeObject(target, source, options) {
|
|
|
67
65
|
});
|
|
68
66
|
}
|
|
69
67
|
getKeys(source).forEach(function (key) {
|
|
70
|
-
var _a;
|
|
71
68
|
if (propertyIsUnsafe(target, key)) {
|
|
72
69
|
return;
|
|
73
70
|
}
|
|
74
71
|
if (propertyIsOnObject(target, key) &&
|
|
75
|
-
|
|
72
|
+
options.isMergeableObject?.(source[key])) {
|
|
76
73
|
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
77
74
|
}
|
|
78
75
|
else {
|
|
@@ -84,7 +81,6 @@ function mergeObject(target, source, options) {
|
|
|
84
81
|
return destination;
|
|
85
82
|
}
|
|
86
83
|
function deepmerge(target, source, options) {
|
|
87
|
-
var _a;
|
|
88
84
|
options = options || {};
|
|
89
85
|
const mergeOptions = {
|
|
90
86
|
arrayMerge: options.arrayMerge || defaultArrayMerge,
|
|
@@ -100,7 +96,7 @@ function deepmerge(target, source, options) {
|
|
|
100
96
|
return mergeOptions.cloneUnlessOtherwiseSpecified(source, mergeOptions);
|
|
101
97
|
}
|
|
102
98
|
else if (sourceIsArray) {
|
|
103
|
-
return
|
|
99
|
+
return mergeOptions.arrayMerge?.(target, source, mergeOptions);
|
|
104
100
|
}
|
|
105
101
|
else {
|
|
106
102
|
return mergeObject(target, source, mergeOptions);
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,KAAU;IAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE1D,OAAO,WAAW,KAAK,iBAAiB,IAAI,WAAW,KAAK,eAAe,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,SAAS,OAAO,CAAC,MAAW;IAC1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,+BAA+B,CAAC,MAAM,CAAC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AC;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,kBAAe,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"]}
|
|
@@ -32,20 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
36
|
exports.importModule = importModule;
|
|
46
|
-
function importModule(path) {
|
|
47
|
-
return
|
|
48
|
-
return yield Promise.resolve(`${path}`).then(s => __importStar(require(s)));
|
|
49
|
-
});
|
|
37
|
+
async function importModule(path) {
|
|
38
|
+
return await Promise.resolve(`${path}`).then(s => __importStar(require(s)));
|
|
50
39
|
}
|
|
51
40
|
//# sourceMappingURL=global.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAEC;AAFM,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,OAAO,yBAAa,IAAI,uCAAC,CAAC;AAC5B,CAAC","sourcesContent":["export async function importModule(path: string) {\n return await import(path);\n}\n"]}
|
|
@@ -32,15 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
37
|
};
|
|
@@ -110,76 +101,72 @@ function getFileModelModulesFileStructure(modelName) {
|
|
|
110
101
|
},
|
|
111
102
|
};
|
|
112
103
|
}
|
|
113
|
-
function processSubdir(modelName, type, result) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const filePath = path_1.default.join(subdir, fileName);
|
|
126
|
-
try {
|
|
127
|
-
const module = yield Promise.resolve(`${filePath}`).then(s => __importStar(require(s))).catch(() => null);
|
|
128
|
-
if (module) {
|
|
129
|
-
if (isAuthModule) {
|
|
130
|
-
const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);
|
|
131
|
-
const expectedName = `${pascalKey}${type === "dtos" ? "Dto" : "Schema"}`;
|
|
132
|
-
result[type][key] = module.default;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
const expectedName = key === "model"
|
|
136
|
-
? `${pascalModelName}${type === "dtos" ? "Dto" : "Schema"}`
|
|
137
|
-
: `${key.charAt(0).toUpperCase() + key.slice(1)}${pascalModelName}${type === "dtos" ? "Dto" : "Schema"}`;
|
|
138
|
-
result[type][key] = module.default;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
}
|
|
144
|
-
})));
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function importPrismaModelModules(modelName) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const moduleDir = path_1.default.resolve((0, fs_helpers_1.crd)(), "src", "modules", modelName);
|
|
153
|
-
const result = {
|
|
154
|
-
dtos: {},
|
|
155
|
-
schemas: {},
|
|
156
|
-
};
|
|
157
|
-
const fileStructure = getFileModelModulesFileStructure(modelName);
|
|
158
|
-
yield Promise.all(Object.entries(fileStructure.core).map((_a) => __awaiter(this, [_a], void 0, function* ([key, fileName]) {
|
|
159
|
-
const filePath = path_1.default.join(moduleDir, fileName);
|
|
104
|
+
async function processSubdir(modelName, type, result) {
|
|
105
|
+
const moduleDir = path_1.default.resolve(process.cwd(), "src", "modules", (0, change_case_helpers_1.kebabCase)(modelName));
|
|
106
|
+
const subdir = path_1.default.join(moduleDir, type);
|
|
107
|
+
const pascalModelName = (0, change_case_helpers_1.pascalCase)(modelName);
|
|
108
|
+
const fileStructure = getFileModelModulesFileStructure(modelName);
|
|
109
|
+
const isAuthModule = modelName.toLowerCase() === "auth";
|
|
110
|
+
try {
|
|
111
|
+
await fs_1.default.promises.access(subdir).catch(() => {
|
|
112
|
+
return;
|
|
113
|
+
});
|
|
114
|
+
await Promise.all(Object.entries(fileStructure[type]).map(async ([key, fileName]) => {
|
|
115
|
+
const filePath = path_1.default.join(subdir, fileName);
|
|
160
116
|
try {
|
|
161
|
-
const module =
|
|
117
|
+
const module = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s))).catch(() => null);
|
|
162
118
|
if (module) {
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
result[key] = module.default
|
|
119
|
+
if (isAuthModule) {
|
|
120
|
+
const pascalKey = key.charAt(0).toUpperCase() + key.slice(1);
|
|
121
|
+
const expectedName = `${pascalKey}${type === "dtos" ? "Dto" : "Schema"}`;
|
|
122
|
+
result[type][key] = module.default;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const expectedName = key === "model"
|
|
126
|
+
? `${pascalModelName}${type === "dtos" ? "Dto" : "Schema"}`
|
|
127
|
+
: `${key.charAt(0).toUpperCase() + key.slice(1)}${pascalModelName}${type === "dtos" ? "Dto" : "Schema"}`;
|
|
128
|
+
result[type][key] = module.default;
|
|
129
|
+
}
|
|
167
130
|
}
|
|
168
131
|
}
|
|
169
|
-
catch (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
132
|
+
catch (error) {
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function importPrismaModelModules(modelName) {
|
|
140
|
+
const moduleDir = path_1.default.resolve((0, fs_helpers_1.crd)(), "src", "modules", modelName);
|
|
141
|
+
const result = {
|
|
142
|
+
dtos: {},
|
|
143
|
+
schemas: {},
|
|
144
|
+
};
|
|
145
|
+
const fileStructure = getFileModelModulesFileStructure(modelName);
|
|
146
|
+
await Promise.all(Object.entries(fileStructure.core).map(async ([key, fileName]) => {
|
|
147
|
+
const filePath = path_1.default.join(moduleDir, fileName);
|
|
148
|
+
try {
|
|
149
|
+
const module = await (0, global_helpers_1.importModule)(filePath).catch(() => null);
|
|
150
|
+
if (module) {
|
|
151
|
+
if (key === "middlewares")
|
|
152
|
+
result[key] = module;
|
|
153
|
+
else
|
|
154
|
+
result[key] = module.default || module;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch { }
|
|
158
|
+
}));
|
|
159
|
+
await Promise.all([
|
|
160
|
+
processSubdir(modelName, "dtos", result),
|
|
161
|
+
processSubdir(modelName, "schemas", result),
|
|
162
|
+
]);
|
|
163
|
+
exports.prismaModelsModules[modelName] = result;
|
|
164
|
+
return result;
|
|
178
165
|
}
|
|
179
166
|
exports.prismaModelRelationFields = {};
|
|
180
167
|
function getAllPrismaFiles(dirPath, fileList = []) {
|
|
181
168
|
const files = fs_1.default.readdirSync(dirPath);
|
|
182
|
-
files
|
|
169
|
+
files?.forEach((file) => {
|
|
183
170
|
const filePath = path_1.default.join(dirPath, file);
|
|
184
171
|
const stat = fs_1.default.statSync(filePath);
|
|
185
172
|
if (stat.isDirectory() && file !== "migrations") {
|
|
@@ -195,19 +182,17 @@ const modelRegex = /model\s+(\w+)\s*{/g;
|
|
|
195
182
|
exports.models = [];
|
|
196
183
|
exports.prismaModelsUniqueFields = [];
|
|
197
184
|
function initializePrismaModels(testName) {
|
|
198
|
-
var _a, _b, _c, _d, _e;
|
|
199
185
|
const prismaContent = [];
|
|
200
186
|
const files = getAllPrismaFiles("./prisma");
|
|
201
187
|
for (const file of files) {
|
|
202
188
|
const content = fs_1.default.readFileSync(file, "utf-8");
|
|
203
|
-
if (!
|
|
189
|
+
if (!prismaContent?.includes?.(content))
|
|
204
190
|
prismaContent.push(content);
|
|
205
191
|
}
|
|
206
192
|
const content = prismaContent
|
|
207
193
|
.join("\n")
|
|
208
194
|
.replace(modelRegex, (_, modelName) => {
|
|
209
|
-
|
|
210
|
-
if (!((_a = exports.models === null || exports.models === void 0 ? void 0 : exports.models.includes) === null || _a === void 0 ? void 0 : _a.call(exports.models, modelName)))
|
|
195
|
+
if (!exports.models?.includes?.(modelName))
|
|
211
196
|
exports.models.push((0, change_case_helpers_1.camelCase)(modelName.trim()));
|
|
212
197
|
return `model ${modelName} {`;
|
|
213
198
|
});
|
|
@@ -228,7 +213,7 @@ function initializePrismaModels(testName) {
|
|
|
228
213
|
trimmedLine.startsWith("//"))
|
|
229
214
|
continue;
|
|
230
215
|
const [fieldName, type] = trimmedLine.split(/\s+/);
|
|
231
|
-
const isUnique =
|
|
216
|
+
const isUnique = trimmedLine?.includes?.("@unique");
|
|
232
217
|
if (isUnique) {
|
|
233
218
|
const existingFields = exports.prismaModelsUniqueFields[model] || [];
|
|
234
219
|
const alreadyExists = existingFields.some((field) => field.name === fieldName &&
|
|
@@ -241,10 +226,10 @@ function initializePrismaModels(testName) {
|
|
|
241
226
|
];
|
|
242
227
|
}
|
|
243
228
|
}
|
|
244
|
-
const cleanType = type
|
|
245
|
-
if (
|
|
229
|
+
const cleanType = type?.replace("[]", "").replace("?", "");
|
|
230
|
+
if (trimmedLine?.includes?.("@relation") ||
|
|
246
231
|
trimmedLine.match(/\s+\w+(\[\])?(\s+@|$)/) ||
|
|
247
|
-
|
|
232
|
+
exports.models?.includes?.((0, change_case_helpers_1.camelCase)(cleanType || ""))) {
|
|
248
233
|
const enumStart = content.indexOf(`enum ${cleanType} {`);
|
|
249
234
|
const typeStart = content.indexOf(`type ${cleanType} {`);
|
|
250
235
|
if (!cleanType ||
|
|
@@ -261,7 +246,7 @@ function initializePrismaModels(testName) {
|
|
|
261
246
|
cleanType === "Json") {
|
|
262
247
|
continue;
|
|
263
248
|
}
|
|
264
|
-
if (!
|
|
249
|
+
if (!type?.includes?.("[]")) {
|
|
265
250
|
relations.singular.push({
|
|
266
251
|
name: fieldName,
|
|
267
252
|
type: cleanType,
|