topsyde-utils 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/index.d.ts +0 -12
  2. package/dist/index.js +0 -11
  3. package/dist/index.js.map +1 -1
  4. package/dist/utils/index.d.ts +0 -3
  5. package/dist/utils/index.js +0 -3
  6. package/dist/utils/index.js.map +1 -1
  7. package/package.json +12 -45
  8. package/src/__tests__/singleton.test.ts +0 -143
  9. package/src/index.ts +0 -32
  10. package/src/utils/index.ts +0 -3
  11. package/dist/client/api/base.api.d.ts +0 -63
  12. package/dist/client/api/base.api.js +0 -61
  13. package/dist/client/api/base.api.js.map +0 -1
  14. package/dist/client/api/index.d.ts +0 -2
  15. package/dist/client/api/index.js +0 -5
  16. package/dist/client/api/index.js.map +0 -1
  17. package/dist/client/rxjs/index.d.ts +0 -1
  18. package/dist/client/rxjs/index.js +0 -4
  19. package/dist/client/rxjs/index.js.map +0 -1
  20. package/dist/client/rxjs/useRxjs.d.ts +0 -17
  21. package/dist/client/rxjs/useRxjs.js +0 -87
  22. package/dist/client/rxjs/useRxjs.js.map +0 -1
  23. package/dist/client/vite/plugins/index.d.ts +0 -2
  24. package/dist/client/vite/plugins/index.js +0 -5
  25. package/dist/client/vite/plugins/index.js.map +0 -1
  26. package/dist/client/vite/plugins/topsydeUtilsVitePlugin.d.ts +0 -9
  27. package/dist/client/vite/plugins/topsydeUtilsVitePlugin.js +0 -74
  28. package/dist/client/vite/plugins/topsydeUtilsVitePlugin.js.map +0 -1
  29. package/dist/external/index.d.ts +0 -1
  30. package/dist/external/index.js +0 -4
  31. package/dist/external/index.js.map +0 -1
  32. package/dist/external/re-exports.d.ts +0 -16
  33. package/dist/external/re-exports.js +0 -24
  34. package/dist/external/re-exports.js.map +0 -1
  35. package/dist/utils/BaseDto.d.ts +0 -33
  36. package/dist/utils/BaseDto.js +0 -69
  37. package/dist/utils/BaseDto.js.map +0 -1
  38. package/dist/utils/BaseEntity.d.ts +0 -31
  39. package/dist/utils/BaseEntity.js +0 -37
  40. package/dist/utils/BaseEntity.js.map +0 -1
  41. package/dist/utils/dto_validators/IsNumberOrRangeConstraint.d.ts +0 -9
  42. package/dist/utils/dto_validators/IsNumberOrRangeConstraint.js +0 -85
  43. package/dist/utils/dto_validators/IsNumberOrRangeConstraint.js.map +0 -1
  44. package/dist/utils/dto_validators/index.d.ts +0 -1
  45. package/dist/utils/dto_validators/index.js +0 -4
  46. package/dist/utils/dto_validators/index.js.map +0 -1
  47. package/src/__tests__/app.test.ts +0 -206
  48. package/src/client/api/base.api.ts +0 -111
  49. package/src/client/api/index.ts +0 -5
  50. package/src/client/rxjs/index.ts +0 -4
  51. package/src/client/rxjs/useRxjs.ts +0 -113
  52. package/src/client/vite/plugins/index.ts +0 -5
  53. package/src/client/vite/plugins/topsydeUtilsVitePlugin.ts +0 -80
  54. package/src/external/index.ts +0 -4
  55. package/src/external/re-exports.ts +0 -54
  56. package/src/utils/BaseDto.ts +0 -77
  57. package/src/utils/BaseEntity.ts +0 -49
  58. package/src/utils/dto_validators/IsNumberOrRangeConstraint.ts +0 -32
  59. package/src/utils/dto_validators/index.ts +0 -4
@@ -1,87 +0,0 @@
1
- import { onBeforeUnmount, onMounted, ref } from "vue";
2
- import { Guards, Lib } from "../../utils/index.js";
3
- import { Rxjs } from "../../utils/Rxjs.js";
4
- export const useRxjs = (_namespace, actions, options) => {
5
- const subs = ref(new Map());
6
- const _actions = ref(actions);
7
- const instance = Rxjs.GetInstance();
8
- const namespaces = ref(Guards.IsArray(_namespace) ? _namespace : [_namespace]);
9
- namespaces.value.forEach((ns) => {
10
- if (instance.has(ns))
11
- return;
12
- console.log("Creating namespace", ns);
13
- instance.create(ns);
14
- });
15
- function _getAction(cta, ns) {
16
- if (Guards.IsArray(_namespace))
17
- return _actions.value?.[ns]?.[cta];
18
- return _actions.value?.[cta];
19
- }
20
- function $next(firstParam, secondParam) {
21
- // Check if second param is a payload object (has both 'cta' and 'data' properties)
22
- if (secondParam && typeof secondParam === "object" && "cta" in secondParam && "data" in secondParam) {
23
- const ns = firstParam;
24
- const payload = secondParam;
25
- instance.next(ns, payload);
26
- return;
27
- }
28
- // Otherwise treat first param as cta and second as data
29
- const cta = firstParam;
30
- const data = secondParam;
31
- const namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];
32
- namespaces.forEach((ns) => {
33
- instance.next(ns, { cta, data });
34
- });
35
- }
36
- function $clear(namespace) {
37
- instance.clear(namespace);
38
- }
39
- function $subscribe(actions) {
40
- _actions.value = actions;
41
- $unsubscribe(); // Clear existing subscriptions
42
- const namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];
43
- namespaces.forEach((ns) => {
44
- if (!instance.namespaces.has(ns)) {
45
- Lib.Warn(`Rxjs namespace ${ns} does not exist`);
46
- return;
47
- }
48
- if (subs.value.has(ns))
49
- return;
50
- subs.value.set(ns, instance.subscribe(ns, ({ cta, data }) => {
51
- const action = _getAction(cta, ns) || (() => { });
52
- action(data);
53
- }));
54
- });
55
- }
56
- function $unsubscribe() {
57
- subs.value.forEach((sub) => sub.unsubscribe());
58
- subs.value.clear();
59
- }
60
- function $mount() {
61
- if (subs.value.size > 0 || !actions)
62
- return;
63
- $subscribe(actions);
64
- }
65
- function $unmount() {
66
- $unsubscribe();
67
- }
68
- if (!options?.static_instance) {
69
- onMounted(() => {
70
- $mount();
71
- });
72
- }
73
- if (!options?.static_instance) {
74
- onBeforeUnmount(() => {
75
- $unmount();
76
- });
77
- }
78
- return {
79
- $next,
80
- $clear,
81
- $subscribe,
82
- $unsubscribe,
83
- $mount,
84
- $unmount,
85
- };
86
- };
87
- //# sourceMappingURL=useRxjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRxjs.js","sourceRoot":"","sources":["../../../src/client/rxjs/useRxjs.ts"],"names":[],"mappings":"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","sourcesContent":["import { Subscription } from \"rxjs\";\nimport { onBeforeUnmount, onMounted, ref } from \"vue\";\nimport { Guards, Lib } from \"../../utils\";\nimport { I_RxjsPayload, Rxjs, RxjsNamespaces } from \"../../utils/Rxjs\";\n\nexport type RxjsDataType = string | Record<string, any>;\nexport type NamespaceActions = Record<string, (data: any) => void>;\nexport type MultiNamespaceActions<T extends string> = Partial<Record<RxjsNamespaces<T>, NamespaceActions>>;\n\nexport const useRxjs = <T extends string>(\n\t_namespace: RxjsNamespaces<T> | RxjsNamespaces<T>[],\n\tactions?: NamespaceActions | MultiNamespaceActions<T>,\n\toptions?: { static_instance: boolean },\n) => {\n\tconst subs = ref<Map<RxjsNamespaces<T>, Subscription>>(new Map());\n\tconst _actions = ref(actions);\n\tconst instance = Rxjs.GetInstance<Rxjs<T>>();\n\tconst namespaces = ref<RxjsNamespaces<T>[]>(Guards.IsArray(_namespace) ? _namespace : [_namespace]);\n\n\tnamespaces.value.forEach((ns) => {\n\t\tif (instance.has(ns)) return;\n\t\tconsole.log(\"Creating namespace\", ns);\n\t\tinstance.create(ns);\n\t});\n\n\tfunction _getAction(cta: string, ns: RxjsNamespaces<T>) {\n\t\tif (Guards.IsArray(_namespace)) return _actions.value?.[ns]?.[cta];\n\t\treturn _actions.value?.[cta];\n\t}\n\n\tfunction $next(namespace: RxjsNamespaces<T>, payload: I_RxjsPayload<any>): void;\n\tfunction $next(cta: string, data: RxjsDataType): void;\n\tfunction $next(firstParam: RxjsNamespaces<T> | string, secondParam: I_RxjsPayload<RxjsDataType> | any): void {\n\t\t// Check if second param is a payload object (has both 'cta' and 'data' properties)\n\t\tif (secondParam && typeof secondParam === \"object\" && \"cta\" in secondParam && \"data\" in secondParam) {\n\t\t\tconst ns = firstParam as RxjsNamespaces<T>;\n\t\t\tconst payload: I_RxjsPayload<any> = secondParam;\n\t\t\tinstance.next(ns, payload);\n\t\t\treturn;\n\t\t}\n\n\t\t// Otherwise treat first param as cta and second as data\n\t\tconst cta = firstParam as string;\n\t\tconst data = secondParam as RxjsDataType;\n\t\tconst namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];\n\t\tnamespaces.forEach((ns) => {\n\t\t\tinstance.next(ns, { cta, data });\n\t\t});\n\t}\n\n\tfunction $clear(namespace: RxjsNamespaces<T>) {\n\t\tinstance.clear(namespace);\n\t}\n\n\tfunction $subscribe(actions: NamespaceActions | MultiNamespaceActions<T>) {\n\t\t_actions.value = actions;\n\t\t$unsubscribe(); // Clear existing subscriptions\n\n\t\tconst namespaces = Guards.IsArray(_namespace) ? _namespace : [_namespace];\n\n\t\tnamespaces.forEach((ns) => {\n\t\t\tif (!instance.namespaces.has(ns)) {\n\t\t\t\tLib.Warn(`Rxjs namespace ${ns} does not exist`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (subs.value.has(ns)) return;\n\n\t\t\tsubs.value.set(\n\t\t\t\tns,\n\t\t\t\tinstance.subscribe(ns, ({ cta, data }) => {\n\t\t\t\t\tconst action = _getAction(cta, ns) || (() => {});\n\t\t\t\t\taction(data);\n\t\t\t\t}),\n\t\t\t);\n\t\t});\n\t}\n\n\tfunction $unsubscribe() {\n\t\tsubs.value.forEach((sub) => sub.unsubscribe());\n\t\tsubs.value.clear();\n\t}\n\n\tfunction $mount() {\n\t\tif (subs.value.size > 0 || !actions) return;\n\t\t$subscribe(actions);\n\t}\n\n\tfunction $unmount() {\n\t\t$unsubscribe();\n\t}\n\n\tif (!options?.static_instance) {\n\t\tonMounted(() => {\n\t\t\t$mount();\n\t\t});\n\t}\n\n\tif (!options?.static_instance) {\n\t\tonBeforeUnmount(() => {\n\t\t\t$unmount();\n\t\t});\n\t}\n\n\treturn {\n\t\t$next,\n\t\t$clear,\n\t\t$subscribe,\n\t\t$unsubscribe,\n\t\t$mount,\n\t\t$unmount,\n\t};\n};\n"]}
@@ -1,2 +0,0 @@
1
- export * from './topsydeUtilsVitePlugin';
2
- export { default as TopsydeUtilsVitePlugin } from './topsydeUtilsVitePlugin';
@@ -1,5 +0,0 @@
1
- // This file is auto-generated by scripts/generate-indexes.ts
2
- // Do not edit this file directly
3
- export * from './topsydeUtilsVitePlugin.js';
4
- export { default as TopsydeUtilsVitePlugin } from './topsydeUtilsVitePlugin.js';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/vite/plugins/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './topsydeUtilsVitePlugin';\nexport { default as TopsydeUtilsVitePlugin } from './topsydeUtilsVitePlugin';\n"]}
@@ -1,9 +0,0 @@
1
- import type { Plugin } from "vite";
2
- /**
3
- * Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments
4
- * by disabling sourcemaps and providing mock implementations of Node.js modules.
5
- *
6
- * @returns A single Vite plugin with all necessary functionality
7
- */
8
- export declare function TopsydeUtilsVitePlugin(): Plugin;
9
- export default TopsydeUtilsVitePlugin;
@@ -1,74 +0,0 @@
1
- /**
2
- * Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments
3
- * by disabling sourcemaps and providing mock implementations of Node.js modules.
4
- *
5
- * @returns A single Vite plugin with all necessary functionality
6
- */
7
- export function TopsydeUtilsVitePlugin() {
8
- return {
9
- name: "topsyde-utils-compatibility",
10
- // Disable sourcemaps for topsyde-utils
11
- transform(code, id) {
12
- if (id.includes("node_modules/topsyde-utils")) {
13
- return {
14
- code,
15
- map: { mappings: "" }, // Return empty sourcemap
16
- };
17
- }
18
- },
19
- // Handle virtual modules for Node.js built-ins
20
- resolveId(id) {
21
- if (id === "virtual:path" || id === "virtual:fs") {
22
- return id;
23
- }
24
- return null;
25
- },
26
- // Provide virtual module implementations
27
- load(id) {
28
- if (id === "virtual:path") {
29
- return `
30
- export function join() { return ''; }
31
- export function resolve() { return ''; }
32
- export function dirname() { return ''; }
33
- export function basename() { return ''; }
34
- export function extname() { return ''; }
35
- export default { join, resolve, dirname, basename, extname };
36
- `;
37
- }
38
- if (id === "virtual:fs") {
39
- return `
40
- export function readFileSync() { return ''; }
41
- export function existsSync() { return false; }
42
- export function writeFileSync() { return null; }
43
- export function readdirSync() { return []; }
44
- export function statSync() {
45
- return {
46
- isDirectory: () => false,
47
- isFile: () => true
48
- };
49
- }
50
- export default { readFileSync, existsSync, writeFileSync, readdirSync, statSync };
51
- `;
52
- }
53
- return null;
54
- },
55
- // Configure aliases and optimization
56
- config() {
57
- return {
58
- resolve: {
59
- alias: {
60
- // Alias Node.js built-ins to virtual modules
61
- path: "virtual:path",
62
- fs: "virtual:fs",
63
- },
64
- },
65
- optimizeDeps: {
66
- exclude: ["topsyde-utils"],
67
- },
68
- };
69
- },
70
- };
71
- }
72
- // Export as default for compatibility with different import styles
73
- export default TopsydeUtilsVitePlugin;
74
- //# sourceMappingURL=topsydeUtilsVitePlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"topsydeUtilsVitePlugin.js","sourceRoot":"","sources":["../../../../src/client/vite/plugins/topsydeUtilsVitePlugin.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB;IACrC,OAAO;QACN,IAAI,EAAE,6BAA6B;QAEnC,uCAAuC;QACvC,SAAS,CAAC,IAAI,EAAE,EAAE;YACjB,IAAI,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;gBAC/C,OAAO;oBACN,IAAI;oBACJ,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,yBAAyB;iBAChD,CAAC;YACH,CAAC;QACF,CAAC;QAED,+CAA+C;QAC/C,SAAS,CAAC,EAAE;YACX,IAAI,EAAE,KAAK,cAAc,IAAI,EAAE,KAAK,YAAY,EAAE,CAAC;gBAClD,OAAO,EAAE,CAAC;YACX,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,yCAAyC;QACzC,IAAI,CAAC,EAAE;YACN,IAAI,EAAE,KAAK,cAAc,EAAE,CAAC;gBAC3B,OAAO;;;;;;;SAOF,CAAC;YACP,CAAC;YACD,IAAI,EAAE,KAAK,YAAY,EAAE,CAAC;gBACzB,OAAO;;;;;;;;;;;;SAYF,CAAC;YACP,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,qCAAqC;QACrC,MAAM;YACL,OAAO;gBACN,OAAO,EAAE;oBACR,KAAK,EAAE;wBACN,6CAA6C;wBAC7C,IAAI,EAAE,cAAc;wBACpB,EAAE,EAAE,YAAY;qBAChB;iBACD;gBACD,YAAY,EAAE;oBACb,OAAO,EAAE,CAAC,eAAe,CAAC;iBAC1B;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,eAAe,sBAAsB,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Creates a Vite plugin that provides compatibility for topsyde-utils in browser environments\n * by disabling sourcemaps and providing mock implementations of Node.js modules.\n * \n * @returns A single Vite plugin with all necessary functionality\n */\nexport function TopsydeUtilsVitePlugin(): Plugin {\n\treturn {\n\t\tname: \"topsyde-utils-compatibility\",\n\n\t\t// Disable sourcemaps for topsyde-utils\n\t\ttransform(code, id) {\n\t\t\tif (id.includes(\"node_modules/topsyde-utils\")) {\n\t\t\t\treturn {\n\t\t\t\t\tcode,\n\t\t\t\t\tmap: { mappings: \"\" }, // Return empty sourcemap\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t// Handle virtual modules for Node.js built-ins\n\t\tresolveId(id) {\n\t\t\tif (id === \"virtual:path\" || id === \"virtual:fs\") {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\t// Provide virtual module implementations\n\t\tload(id) {\n\t\t\tif (id === \"virtual:path\") {\n\t\t\t\treturn `\n export function join() { return ''; }\n export function resolve() { return ''; }\n export function dirname() { return ''; }\n export function basename() { return ''; }\n export function extname() { return ''; }\n export default { join, resolve, dirname, basename, extname };\n `;\n\t\t\t}\n\t\t\tif (id === \"virtual:fs\") {\n\t\t\t\treturn `\n export function readFileSync() { return ''; }\n export function existsSync() { return false; }\n export function writeFileSync() { return null; }\n export function readdirSync() { return []; }\n export function statSync() { \n return { \n isDirectory: () => false,\n isFile: () => true\n }; \n }\n export default { readFileSync, existsSync, writeFileSync, readdirSync, statSync };\n `;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\t// Configure aliases and optimization\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: {\n\t\t\t\t\talias: {\n\t\t\t\t\t\t// Alias Node.js built-ins to virtual modules\n\t\t\t\t\t\tpath: \"virtual:path\",\n\t\t\t\t\t\tfs: \"virtual:fs\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptimizeDeps: {\n\t\t\t\t\texclude: [\"topsyde-utils\"],\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\n// Export as default for compatibility with different import styles\nexport default TopsydeUtilsVitePlugin;\n"]}
@@ -1 +0,0 @@
1
- export * from './re-exports';
@@ -1,4 +0,0 @@
1
- // This file is auto-generated by scripts/generate-indexes.ts
2
- // Do not edit this file directly
3
- export * from './re-exports.js';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/external/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,cAAc,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './re-exports';\n"]}
@@ -1,16 +0,0 @@
1
- /**
2
- * Re-exports of external dependencies for convenience
3
- *
4
- * This module re-exports commonly used types, classes, and decorators from
5
- * class-transformer and class-validator to provide a single import source
6
- * for projects using topsyde-utils.
7
- *
8
- * This prevents the need to separately install these dependencies in
9
- * consuming projects, as they're already bundled with topsyde-utils.
10
- */
11
- export type { ClassConstructor, ClassTransformOptions } from "class-transformer";
12
- export { instanceToPlain, plainToInstance } from "class-transformer";
13
- export { Expose } from "class-transformer";
14
- export { ValidationError } from "class-validator";
15
- export { validateSync } from "class-validator";
16
- export { IsArray, IsBoolean, IsDate, IsEnum, IsNumber, IsObject, IsOptional, IsString, Validate, IsAlphanumeric, IsBooleanString, IsDateString, IsDecimal, IsDefined, IsNumberString, IsNotEmpty, IsNotEmptyObject, } from "class-validator";
@@ -1,24 +0,0 @@
1
- /**
2
- * Re-exports of external dependencies for convenience
3
- *
4
- * This module re-exports commonly used types, classes, and decorators from
5
- * class-transformer and class-validator to provide a single import source
6
- * for projects using topsyde-utils.
7
- *
8
- * This prevents the need to separately install these dependencies in
9
- * consuming projects, as they're already bundled with topsyde-utils.
10
- */
11
- // Core transformation functions
12
- export { instanceToPlain, plainToInstance } from "class-transformer";
13
- // Decorators
14
- export { Expose } from "class-transformer";
15
- // ============================================================================
16
- // class-validator exports
17
- // ============================================================================
18
- // Types and Classes
19
- export { ValidationError } from "class-validator";
20
- // Validation function
21
- export { validateSync } from "class-validator";
22
- // Property decorators
23
- export { IsArray, IsBoolean, IsDate, IsEnum, IsNumber, IsObject, IsOptional, IsString, Validate, IsAlphanumeric, IsBooleanString, IsDateString, IsDecimal, IsDefined, IsNumberString, IsNotEmpty, IsNotEmptyObject, } from "class-validator";
24
- //# sourceMappingURL=re-exports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../../src/external/re-exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,gCAAgC;AAChC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAErE,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,sBAAsB;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,sBAAsB;AACtB,OAAO,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,eAAe,EACf,YAAY,EACZ,SAAS,EACT,SAAS,EACT,cAAc,EACd,UAAU,EACV,gBAAgB,GAChB,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * Re-exports of external dependencies for convenience\n *\n * This module re-exports commonly used types, classes, and decorators from\n * class-transformer and class-validator to provide a single import source\n * for projects using topsyde-utils.\n *\n * This prevents the need to separately install these dependencies in\n * consuming projects, as they're already bundled with topsyde-utils.\n */\n\n// ============================================================================\n// class-transformer exports\n// ============================================================================\n\n// Types\nexport type { ClassConstructor, ClassTransformOptions } from \"class-transformer\";\n\n// Core transformation functions\nexport { instanceToPlain, plainToInstance } from \"class-transformer\";\n\n// Decorators\nexport { Expose } from \"class-transformer\";\n\n// ============================================================================\n// class-validator exports\n// ============================================================================\n\n// Types and Classes\nexport { ValidationError } from \"class-validator\";\n\n// Validation function\nexport { validateSync } from \"class-validator\";\n\n// Property decorators\nexport {\n\tIsArray,\n\tIsBoolean,\n\tIsDate,\n\tIsEnum,\n\tIsNumber,\n\tIsObject,\n\tIsOptional,\n\tIsString,\n\tValidate,\n\tIsAlphanumeric,\n\tIsBooleanString,\n\tIsDateString,\n\tIsDecimal,\n\tIsDefined,\n\tIsNumberString,\n\tIsNotEmpty,\n\tIsNotEmptyObject,\n} from \"class-validator\";\n"]}
@@ -1,33 +0,0 @@
1
- import type { ClassConstructor, ClassTransformOptions } from "class-transformer";
2
- import { ValidationError } from "class-validator";
3
- /**
4
- * Base typesafe class for Data Transfer Objects (DTOs)
5
- */
6
- export declare abstract class Dto {
7
- /**
8
- * Default options for class transformation
9
- */
10
- protected static readonly defaultTransformOptions: ClassTransformOptions;
11
- /**
12
- * Validates the DTO instance
13
- * @throws ValidationError[] if validation fails
14
- */
15
- validate(): ValidationError[];
16
- /**
17
- * Converts the DTO to a plain object
18
- * @param options - Class transformer options for controlling exposure and transformation
19
- * @returns Plain object representation of the DTO
20
- */
21
- toJSON<T = Record<string, unknown>>(include_undefined?: boolean, options?: ClassTransformOptions): T;
22
- /**
23
- * Creates a new instance of the DTO with validation (infers class from `this`)
24
- * @param data - Data to create the DTO from
25
- * @param options - Class transformer options
26
- * @returns New instance of the DTO
27
- */
28
- static Create<T extends Dto>(this: ClassConstructor<T>, data: Record<string, unknown>, options?: ClassTransformOptions): T;
29
- /**
30
- * Creates an array of DTOs from an array of plain objects
31
- */
32
- static CreateMany<T extends Dto>(this: ClassConstructor<T>, dataArray: Record<string, unknown>[], options?: ClassTransformOptions): T[];
33
- }
@@ -1,69 +0,0 @@
1
- import { instanceToPlain, plainToInstance } from "class-transformer";
2
- import Guards from "./Guards.js";
3
- import { validateSync } from "class-validator";
4
- /**
5
- * Base typesafe class for Data Transfer Objects (DTOs)
6
- */
7
- export class Dto {
8
- /**
9
- * Validates the DTO instance
10
- * @throws ValidationError[] if validation fails
11
- */
12
- validate() {
13
- const errors = validateSync(this, {
14
- validationError: { target: false },
15
- forbidUnknownValues: true,
16
- });
17
- if (errors.length > 0) {
18
- throw errors;
19
- }
20
- return errors;
21
- }
22
- /**
23
- * Converts the DTO to a plain object
24
- * @param options - Class transformer options for controlling exposure and transformation
25
- * @returns Plain object representation of the DTO
26
- */
27
- toJSON(include_undefined = true, options) {
28
- const value = instanceToPlain(this, {
29
- ...Dto.defaultTransformOptions,
30
- ...options,
31
- });
32
- if (!include_undefined) {
33
- return Object.fromEntries(Object.entries(value).filter(([_, v]) => !Guards.IsNil(v)));
34
- }
35
- return value;
36
- }
37
- /**
38
- * Creates a new instance of the DTO with validation (infers class from `this`)
39
- * @param data - Data to create the DTO from
40
- * @param options - Class transformer options
41
- * @returns New instance of the DTO
42
- */
43
- static Create(data, options = {}) {
44
- const instance = plainToInstance(this, data, {
45
- ...Dto.defaultTransformOptions,
46
- ...options,
47
- });
48
- return instance;
49
- }
50
- /**
51
- * Creates an array of DTOs from an array of plain objects
52
- */
53
- static CreateMany(dataArray, options = {}) {
54
- return plainToInstance(this, dataArray, {
55
- ...Dto.defaultTransformOptions,
56
- ...options,
57
- });
58
- }
59
- }
60
- /**
61
- * Default options for class transformation
62
- */
63
- Dto.defaultTransformOptions = {
64
- excludeExtraneousValues: true,
65
- enableCircularCheck: true,
66
- exposeDefaultValues: true,
67
- enableImplicitConversion: false, // Safer default, especially when using class-validator
68
- };
69
- //# sourceMappingURL=BaseDto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseDto.js","sourceRoot":"","sources":["../../src/utils/BaseDto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAmB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAgB,GAAG;IAWxB;;;OAGG;IACI,QAAQ;QACd,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE;YACjC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;YAClC,mBAAmB,EAAE,IAAI;SACzB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,MAAM,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,MAAM,CAA8B,oBAA6B,IAAI,EAAE,OAA+B;QAC5G,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE;YACnC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAM,CAAC;QAER,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAM,CAAC;QACvH,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAA2C,IAA6B,EAAE,UAAiC,EAAE;QAChI,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE;YAC5C,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAA2C,SAAoC,EAAE,UAAiC,EAAE;QAC3I,OAAO,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE;YACvC,GAAG,GAAG,CAAC,uBAAuB;YAC9B,GAAG,OAAO;SACV,CAAQ,CAAC;IACX,CAAC;;AAlED;;GAEG;AACuB,2BAAuB,GAA0B;IAC1E,uBAAuB,EAAE,IAAI;IAC7B,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,wBAAwB,EAAE,KAAK,EAAE,uDAAuD;CACxF,CAAC","sourcesContent":["import type { ClassConstructor, ClassTransformOptions } from \"class-transformer\";\nimport { instanceToPlain, plainToInstance } from \"class-transformer\";\nimport Guards from \"./Guards\";\nimport { ValidationError, validateSync } from \"class-validator\";\n\n/**\n * Base typesafe class for Data Transfer Objects (DTOs)\n */\nexport abstract class Dto {\n\t/**\n\t * Default options for class transformation\n\t */\n\tprotected static readonly defaultTransformOptions: ClassTransformOptions = {\n\t\texcludeExtraneousValues: true,\n\t\tenableCircularCheck: true,\n\t\texposeDefaultValues: true,\n\t\tenableImplicitConversion: false, // Safer default, especially when using class-validator\n\t};\n\n\t/**\n\t * Validates the DTO instance\n\t * @throws ValidationError[] if validation fails\n\t */\n\tpublic validate(): ValidationError[] {\n\t\tconst errors = validateSync(this, {\n\t\t\tvalidationError: { target: false },\n\t\t\tforbidUnknownValues: true,\n\t\t});\n\t\tif (errors.length > 0) {\n\t\t\tthrow errors;\n\t\t}\n\t\treturn errors;\n\t}\n\n\t/**\n\t * Converts the DTO to a plain object\n\t * @param options - Class transformer options for controlling exposure and transformation\n\t * @returns Plain object representation of the DTO\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(include_undefined: boolean = true, options?: ClassTransformOptions): T {\n\t\tconst value = instanceToPlain(this, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T;\n\n\t\tif (!include_undefined) {\n\t\t\treturn Object.fromEntries(Object.entries(value as Record<string, unknown>).filter(([_, v]) => !Guards.IsNil(v))) as T;\n\t\t}\n\n\t\treturn value;\n\t}\n\n\t/**\n\t * Creates a new instance of the DTO with validation (infers class from `this`)\n\t * @param data - Data to create the DTO from\n\t * @param options - Class transformer options\n\t * @returns New instance of the DTO\n\t */\n\tpublic static Create<T extends Dto>(this: ClassConstructor<T>, data: Record<string, unknown>, options: ClassTransformOptions = {}): T {\n\t\tconst instance = plainToInstance(this, data, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates an array of DTOs from an array of plain objects\n\t */\n\tpublic static CreateMany<T extends Dto>(this: ClassConstructor<T>, dataArray: Record<string, unknown>[], options: ClassTransformOptions = {}): T[] {\n\t\treturn plainToInstance(this, dataArray, {\n\t\t\t...Dto.defaultTransformOptions,\n\t\t\t...options,\n\t\t}) as T[];\n\t}\n}\n"]}
@@ -1,31 +0,0 @@
1
- import { ClassConstructor } from "class-transformer";
2
- import { Dto } from "./BaseDto";
3
- export default abstract class BaseEntity {
4
- /**
5
- * Converts entity to plain object
6
- */
7
- toJSON<T = Record<string, unknown>>(): T;
8
- /**
9
- * Abstract method - entities must define how to convert to DTO
10
- */
11
- abstract toDto(): Dto;
12
- /**
13
- * Updates entity with partial data (immutable - returns new instance)
14
- * @param data - Partial data to update
15
- * @param validate - Whether to validate after update (default: true)
16
- */
17
- update<T extends BaseEntity>(this: T, data: Partial<T>): T;
18
- /**
19
- * Creates a new entity instance from DTO (infers class from `this`)
20
- *
21
- * NOTE: This is a BASE implementation that uses plainToInstance.
22
- * Derived classes should override if they need custom construction logic.
23
- *
24
- * @param dto - DTO to create entity from
25
- */
26
- static FromDto<T extends BaseEntity>(this: ClassConstructor<T>, dto: Dto): T;
27
- /**
28
- * Creates multiple entities from DTOs
29
- */
30
- static FromDtos<T extends BaseEntity>(this: ClassConstructor<T>, dtos: Dto[]): T[];
31
- }
@@ -1,37 +0,0 @@
1
- import { instanceToPlain, plainToInstance } from "class-transformer";
2
- export default class BaseEntity {
3
- /**
4
- * Converts entity to plain object
5
- */
6
- toJSON() {
7
- return instanceToPlain(this);
8
- }
9
- /**
10
- * Updates entity with partial data (immutable - returns new instance)
11
- * @param data - Partial data to update
12
- * @param validate - Whether to validate after update (default: true)
13
- */
14
- update(data) {
15
- const updated = Object.assign(Object.create(Object.getPrototypeOf(this)), this, data);
16
- return updated;
17
- }
18
- /**
19
- * Creates a new entity instance from DTO (infers class from `this`)
20
- *
21
- * NOTE: This is a BASE implementation that uses plainToInstance.
22
- * Derived classes should override if they need custom construction logic.
23
- *
24
- * @param dto - DTO to create entity from
25
- */
26
- static FromDto(dto) {
27
- const instance = plainToInstance(this, dto.toJSON());
28
- return instance;
29
- }
30
- /**
31
- * Creates multiple entities from DTOs
32
- */
33
- static FromDtos(dtos) {
34
- return plainToInstance(this, dtos.map((dto) => dto.toJSON()));
35
- }
36
- }
37
- //# sourceMappingURL=BaseEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseEntity.js","sourceRoot":"","sources":["../../src/utils/BaseEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGvF,MAAM,CAAC,OAAO,OAAgB,UAAU;IACvC;;OAEG;IACI,MAAM;QACZ,OAAO,eAAe,CAAC,IAAI,CAAM,CAAC;IACnC,CAAC;IAOD;;;;OAIG;IACI,MAAM,CAAgC,IAAgB;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtF,OAAO,OAAO,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,OAAO,CAAkD,GAAQ;QAC9E,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAkD,IAAW;QAClF,OAAO,eAAe,CACrB,IAAI,EACJ,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAC/B,CAAC;IACH,CAAC;CACD","sourcesContent":["import { ClassConstructor, instanceToPlain, plainToInstance } from \"class-transformer\";\nimport { Dto } from \"./BaseDto\";\n\nexport default abstract class BaseEntity {\n\t/**\n\t * Converts entity to plain object\n\t */\n\tpublic toJSON<T = Record<string, unknown>>(): T {\n\t\treturn instanceToPlain(this) as T;\n\t}\n\n\t/**\n\t * Abstract method - entities must define how to convert to DTO\n\t */\n\tpublic abstract toDto(): Dto;\n\n\t/**\n\t * Updates entity with partial data (immutable - returns new instance)\n\t * @param data - Partial data to update\n\t * @param validate - Whether to validate after update (default: true)\n\t */\n\tpublic update<T extends BaseEntity>(this: T, data: Partial<T>): T {\n\t\tconst updated = Object.assign(Object.create(Object.getPrototypeOf(this)), this, data);\n\t\treturn updated;\n\t}\n\n\t/**\n\t * Creates a new entity instance from DTO (infers class from `this`)\n\t *\n\t * NOTE: This is a BASE implementation that uses plainToInstance.\n\t * Derived classes should override if they need custom construction logic.\n\t *\n\t * @param dto - DTO to create entity from\n\t */\n\tpublic static FromDto<T extends BaseEntity>(this: ClassConstructor<T>, dto: Dto): T {\n\t\tconst instance = plainToInstance(this, dto.toJSON());\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Creates multiple entities from DTOs\n\t */\n\tpublic static FromDtos<T extends BaseEntity>(this: ClassConstructor<T>, dtos: Dto[]): T[] {\n\t\treturn plainToInstance(\n\t\t\tthis,\n\t\t\tdtos.map((dto) => dto.toJSON()),\n\t\t);\n\t}\n}\n"]}
@@ -1,9 +0,0 @@
1
- import { ValidatorConstraintInterface, ValidationArguments } from "class-validator";
2
- /**
3
- * Custom validator for number | number[] type
4
- * Validates that value is either a single number or a 2-element number array [min, max]
5
- */
6
- export declare class IsNumberOrRangeConstraint implements ValidatorConstraintInterface {
7
- validate(value: any, args: ValidationArguments): boolean;
8
- defaultMessage(args: ValidationArguments): string;
9
- }
@@ -1,85 +0,0 @@
1
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
- var _, done = false;
7
- for (var i = decorators.length - 1; i >= 0; i--) {
8
- var context = {};
9
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
- if (kind === "accessor") {
14
- if (result === void 0) continue;
15
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
- if (_ = accept(result.get)) descriptor.get = _;
17
- if (_ = accept(result.set)) descriptor.set = _;
18
- if (_ = accept(result.init)) initializers.unshift(_);
19
- }
20
- else if (_ = accept(result)) {
21
- if (kind === "field") initializers.unshift(_);
22
- else descriptor[key] = _;
23
- }
24
- }
25
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
- done = true;
27
- };
28
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
- var useValue = arguments.length > 2;
30
- for (var i = 0; i < initializers.length; i++) {
31
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
- }
33
- return useValue ? value : void 0;
34
- };
35
- var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
36
- if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
37
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
38
- };
39
- import { ValidatorConstraint } from "class-validator";
40
- /**
41
- * Custom validator for number | number[] type
42
- * Validates that value is either a single number or a 2-element number array [min, max]
43
- */
44
- let IsNumberOrRangeConstraint = (() => {
45
- let _classDecorators = [ValidatorConstraint({ name: "isNumberOrRange", async: false })];
46
- let _classDescriptor;
47
- let _classExtraInitializers = [];
48
- let _classThis;
49
- var IsNumberOrRangeConstraint = _classThis = class {
50
- validate(value, args) {
51
- // Allow single number
52
- if (typeof value === "number" && !isNaN(value)) {
53
- return true;
54
- }
55
- // Allow array of exactly 2 numbers (range)
56
- if (Array.isArray(value)) {
57
- if (value.length !== 2)
58
- return false;
59
- if (typeof value[0] !== "number" || isNaN(value[0]))
60
- return false;
61
- if (typeof value[1] !== "number" || isNaN(value[1]))
62
- return false;
63
- // Optional: Validate min <= max
64
- if (value[0] > value[1])
65
- return false;
66
- return true;
67
- }
68
- return false;
69
- }
70
- defaultMessage(args) {
71
- return "Value must be a number or a 2-element number array [min, max]";
72
- }
73
- };
74
- __setFunctionName(_classThis, "IsNumberOrRangeConstraint");
75
- (() => {
76
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
77
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
78
- IsNumberOrRangeConstraint = _classThis = _classDescriptor.value;
79
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
80
- __runInitializers(_classThis, _classExtraInitializers);
81
- })();
82
- return IsNumberOrRangeConstraint = _classThis;
83
- })();
84
- export { IsNumberOrRangeConstraint };
85
- //# sourceMappingURL=IsNumberOrRangeConstraint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsNumberOrRangeConstraint.js","sourceRoot":"","sources":["../../../src/utils/dto_validators/IsNumberOrRangeConstraint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAqD,MAAM,iBAAiB,CAAC;AAEzG;;;GAGG;IAGU,yBAAyB;4BADrC,mBAAmB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;;;;;QAE9D,QAAQ,CAAC,KAAU,EAAE,IAAyB;YAC7C,sBAAsB;YACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAC;YACb,CAAC;YAED,2CAA2C;YAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,KAAK,CAAC;gBACrC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAAE,OAAO,KAAK,CAAC;gBAClE,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAAE,OAAO,KAAK,CAAC;gBAClE,gCAAgC;gBAChC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;oBAAE,OAAO,KAAK,CAAC;gBACtC,OAAO,IAAI,CAAC;YACb,CAAC;YAED,OAAO,KAAK,CAAC;QACd,CAAC;QAED,cAAc,CAAC,IAAyB;YACvC,OAAO,+DAA+D,CAAC;QACxE,CAAC;;;;;QAtBF,6KAuBC;;;QAvBY,uDAAyB;;;;SAAzB,yBAAyB","sourcesContent":["import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments } from \"class-validator\";\n\n/**\n * Custom validator for number | number[] type\n * Validates that value is either a single number or a 2-element number array [min, max]\n */\n\n@ValidatorConstraint({ name: \"isNumberOrRange\", async: false })\nexport class IsNumberOrRangeConstraint implements ValidatorConstraintInterface {\n\tvalidate(value: any, args: ValidationArguments) {\n\t\t// Allow single number\n\t\tif (typeof value === \"number\" && !isNaN(value)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Allow array of exactly 2 numbers (range)\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length !== 2) return false;\n\t\t\tif (typeof value[0] !== \"number\" || isNaN(value[0])) return false;\n\t\t\tif (typeof value[1] !== \"number\" || isNaN(value[1])) return false;\n\t\t\t// Optional: Validate min <= max\n\t\t\tif (value[0] > value[1]) return false;\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tdefaultMessage(args: ValidationArguments) {\n\t\treturn \"Value must be a number or a 2-element number array [min, max]\";\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- export * from './IsNumberOrRangeConstraint';
@@ -1,4 +0,0 @@
1
- // This file is auto-generated by scripts/generate-indexes.ts
2
- // Do not edit this file directly
3
- export * from './IsNumberOrRangeConstraint.js';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/dto_validators/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AAEjC,cAAc,6BAA6B,CAAC","sourcesContent":["// This file is auto-generated by scripts/generate-indexes.ts\n// Do not edit this file directly\n\nexport * from './IsNumberOrRangeConstraint';\n"]}