av6-core 1.3.10 → 1.4.0
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/.cursor/debug-check-prisma.ts +100 -0
- package/.cursor/debug.log +10 -0
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +146 -127
- package/dist/index.mjs +146 -127
- package/package.json +4 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// #region agent log
|
|
2
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:1',message:'Starting Prisma client check',data:{timestamp:Date.now()},sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
3
|
+
// #endregion
|
|
4
|
+
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
|
|
8
|
+
const workspaceRoot = path.resolve(__dirname, '..');
|
|
9
|
+
const nodeModulesPath = path.join(workspaceRoot, 'node_modules');
|
|
10
|
+
const prismaClientPath = path.join(nodeModulesPath, '@prisma', 'client');
|
|
11
|
+
const prismaGeneratedPath = path.join(nodeModulesPath, '.prisma', 'client');
|
|
12
|
+
|
|
13
|
+
// #region agent log
|
|
14
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:10',message:'Checking paths',data:{workspaceRoot,prismaClientPath,prismaGeneratedPath,prismaClientExists:fs.existsSync(prismaClientPath),prismaGeneratedExists:fs.existsSync(prismaGeneratedPath)},sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
15
|
+
// #endregion
|
|
16
|
+
|
|
17
|
+
// Check if @prisma/client package exists
|
|
18
|
+
const prismaClientExists = fs.existsSync(prismaClientPath);
|
|
19
|
+
const prismaGeneratedExists = fs.existsSync(prismaGeneratedPath);
|
|
20
|
+
|
|
21
|
+
// #region agent log
|
|
22
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:18',message:'Path check results',data:{prismaClientExists,prismaGeneratedExists},sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});
|
|
23
|
+
// #endregion
|
|
24
|
+
|
|
25
|
+
// Try to read package.json from @prisma/client
|
|
26
|
+
let prismaClientPackageJson: any = null;
|
|
27
|
+
if (prismaClientExists) {
|
|
28
|
+
try {
|
|
29
|
+
const packageJsonPath = path.join(prismaClientPath, 'package.json');
|
|
30
|
+
// #region agent log
|
|
31
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:26',message:'Reading @prisma/client package.json',data:{packageJsonPath,exists:fs.existsSync(packageJsonPath)},sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
32
|
+
// #endregion
|
|
33
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
34
|
+
prismaClientPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
35
|
+
// #region agent log
|
|
36
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:30',message:'@prisma/client package.json content',data:{name:prismaClientPackageJson?.name,version:prismaClientPackageJson?.version,exports:prismaClientPackageJson?.exports},sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
37
|
+
// #endregion
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// #region agent log
|
|
41
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:34',message:'Error reading package.json',data:{error:String(e)},sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});
|
|
42
|
+
// #endregion
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check index.d.ts in @prisma/client
|
|
47
|
+
let indexDtsContent: string | null = null;
|
|
48
|
+
if (prismaClientExists) {
|
|
49
|
+
try {
|
|
50
|
+
const indexDtsPath = path.join(prismaClientPath, 'index.d.ts');
|
|
51
|
+
// #region agent log
|
|
52
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:43',message:'Reading index.d.ts',data:{indexDtsPath,exists:fs.existsSync(indexDtsPath)},sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
|
|
53
|
+
// #endregion
|
|
54
|
+
if (fs.existsSync(indexDtsPath)) {
|
|
55
|
+
indexDtsContent = fs.readFileSync(indexDtsPath, 'utf-8');
|
|
56
|
+
// #region agent log
|
|
57
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:47',message:'index.d.ts content',data:{content:indexDtsContent.substring(0,200)},sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
|
|
58
|
+
// #endregion
|
|
59
|
+
}
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// #region agent log
|
|
62
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:51',message:'Error reading index.d.ts',data:{error:String(e)},sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});
|
|
63
|
+
// #endregion
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Try to dynamically import PrismaClient
|
|
68
|
+
let prismaClientImportSuccess = false;
|
|
69
|
+
let prismaClientImportError: string | null = null;
|
|
70
|
+
try {
|
|
71
|
+
// #region agent log
|
|
72
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:60',message:'Attempting dynamic import of PrismaClient',data:{},sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
73
|
+
// #endregion
|
|
74
|
+
const prismaModule = require('@prisma/client');
|
|
75
|
+
// #region agent log
|
|
76
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:63',message:'Module loaded',data:{hasPrismaClient:!!prismaModule.PrismaClient,exports:Object.keys(prismaModule)},sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
77
|
+
// #endregion
|
|
78
|
+
if (prismaModule.PrismaClient) {
|
|
79
|
+
prismaClientImportSuccess = true;
|
|
80
|
+
} else {
|
|
81
|
+
prismaClientImportError = 'PrismaClient not found in exports: ' + Object.keys(prismaModule).join(', ');
|
|
82
|
+
}
|
|
83
|
+
} catch (e) {
|
|
84
|
+
prismaClientImportError = String(e);
|
|
85
|
+
// #region agent log
|
|
86
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:72',message:'Dynamic import failed',data:{error:prismaClientImportError},sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});
|
|
87
|
+
// #endregion
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// #region agent log
|
|
91
|
+
fetch('http://127.0.0.1:7244/ingest/0a9f7972-5d03-4255-b5c9-6164f846fb46',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'debug-check-prisma.ts:76',message:'Final summary',data:{prismaClientExists,prismaGeneratedExists,prismaClientImportSuccess,prismaClientImportError,hasPackageJson:!!prismaClientPackageJson,hasIndexDts:!!indexDtsContent},sessionId:'debug-session',runId:'run1',hypothesisId:'ALL'})}).catch(()=>{});
|
|
92
|
+
// #endregion
|
|
93
|
+
|
|
94
|
+
console.log('Prisma Client Check Complete');
|
|
95
|
+
console.log('Prisma Client Package Exists:', prismaClientExists);
|
|
96
|
+
console.log('Prisma Generated Client Exists:', prismaGeneratedExists);
|
|
97
|
+
console.log('PrismaClient Import Success:', prismaClientImportSuccess);
|
|
98
|
+
if (prismaClientImportError) {
|
|
99
|
+
console.log('PrismaClient Import Error:', prismaClientImportError);
|
|
100
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{"location":"debug-check-prisma.ts:1","message":"Starting Prisma client check","data":{"timestamp":1768564718778},"sessionId":"debug-session","runId":"run1","hypothesisId":"A"}
|
|
2
|
+
{"location":"debug-check-prisma.ts:18","message":"Path check results","data":{"prismaClientExists":true,"prismaGeneratedExists":false},"sessionId":"debug-session","runId":"run1","hypothesisId":"A"}
|
|
3
|
+
{"location":"debug-check-prisma.ts:26","message":"Reading @prisma/client package.json","data":{"packageJsonPath":"C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\@prisma\\client\\package.json","exists":true},"sessionId":"debug-session","runId":"run1","hypothesisId":"B"}
|
|
4
|
+
{"location":"debug-check-prisma.ts:30","message":"@prisma/client package.json content","data":{"name":"@prisma/client","version":"6.19.2","exports":{"./package.json":"./package.json",".":{"require":{"types":"./default.d.ts","node":"./default.js","edge-light":"./default.js","workerd":"./default.js","worker":"./default.js","browser":"./index-browser.js"},"import":{"types":"./default.d.ts","node":"./default.js","edge-light":"./default.js","workerd":"./default.js","worker":"./default.js","browser":"./index-browser.js"},"default":"./default.js"},"./edge":{"types":"./edge.d.ts","require":"./edge.js","import":"./edge.js","default":"./edge.js"},"./react-native":{"types":"./react-native.d.ts","require":"./react-native.js","import":"./react-native.js","default":"./react-native.js"},"./extension":{"types":"./extension.d.ts","require":"./extension.js","import":"./extension.js","default":"./extension.js"},"./index-browser":{"types":"./index.d.ts","require":"./index-browser.js","import":"./index-browser.js","default":"./index-browser.js"},"./index":{"types":"./index.d.ts","require":"./index.js","import":"./index.js","default":"./index.js"},"./wasm":{"types":"./wasm.d.ts","require":"./wasm.js","import":"./wasm.mjs","default":"./wasm.mjs"},"./runtime/client":{"types":"./runtime/client.d.ts","node":{"require":"./runtime/client.js","default":"./runtime/client.js"},"require":"./runtime/client.js","import":"./runtime/client.mjs","default":"./runtime/client.mjs"},"./runtime/library":{"types":"./runtime/library.d.ts","require":"./runtime/library.js","import":"./runtime/library.mjs","default":"./runtime/library.mjs"},"./runtime/binary":{"types":"./runtime/binary.d.ts","require":"./runtime/binary.js","import":"./runtime/binary.mjs","default":"./runtime/binary.mjs"},"./runtime/wasm-engine-edge":{"types":"./runtime/wasm-engine-edge.d.ts","require":"./runtime/wasm-engine-edge.js","import":"./runtime/wasm-engine-edge.mjs","default":"./runtime/wasm-engine-edge.mjs"},"./runtime/wasm-compiler-edge":{"types":"./runtime/wasm-compiler-edge.d.ts","require":"./runtime/wasm-compiler-edge.js","import":"./runtime/wasm-compiler-edge.mjs","default":"./runtime/wasm-compiler-edge.mjs"},"./runtime/edge":{"types":"./runtime/edge.d.ts","require":"./runtime/edge.js","import":"./runtime/edge-esm.js","default":"./runtime/edge-esm.js"},"./runtime/react-native":{"types":"./runtime/react-native.d.ts","require":"./runtime/react-native.js","import":"./runtime/react-native.js","default":"./runtime/react-native.js"},"./runtime/index-browser":{"types":"./runtime/index-browser.d.ts","require":"./runtime/index-browser.js","import":"./runtime/index-browser.mjs","default":"./runtime/index-browser.mjs"},"./generator-build":{"require":"./generator-build/index.js","import":"./generator-build/index.js","default":"./generator-build/index.js"},"./sql":{"require":{"types":"./sql.d.ts","node":"./sql.js","default":"./sql.js"},"import":{"types":"./sql.d.ts","node":"./sql.mjs","default":"./sql.mjs"},"default":"./sql.js"},"./*":"./*"}},"sessionId":"debug-session","runId":"run1","hypothesisId":"B"}
|
|
5
|
+
{"location":"debug-check-prisma.ts:43","message":"Reading index.d.ts","data":{"indexDtsPath":"C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\@prisma\\client\\index.d.ts","exists":true},"sessionId":"debug-session","runId":"run1","hypothesisId":"C"}
|
|
6
|
+
{"location":"debug-check-prisma.ts:47","message":"index.d.ts content","data":{"content":"export * from '.prisma/client/default'\n"},"sessionId":"debug-session","runId":"run1","hypothesisId":"C"}
|
|
7
|
+
{"location":"debug-check-prisma.ts:60","message":"Attempting dynamic import of PrismaClient","data":{},"sessionId":"debug-session","runId":"run1","hypothesisId":"D"}
|
|
8
|
+
{"location":"debug-check-prisma.ts:72","message":"Dynamic import failed","data":{"error":"Error: Cannot find module '.prisma/client/default'\nRequire stack:\n- C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\.pnpm\\@prisma+client@6.19.2_prism_6b2b1af085fe6797f5a5ea830937a8e3\\node_modules\\@prisma\\client\\default.js\n- C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\.cursor\\debug-check-prisma.ts"},"sessionId":"debug-session","runId":"run1","hypothesisId":"D"}
|
|
9
|
+
{"location":"debug-check-prisma.ts:76","message":"Final summary","data":{"prismaClientExists":true,"prismaGeneratedExists":false,"prismaClientImportSuccess":false,"prismaClientImportError":"Error: Cannot find module '.prisma/client/default'\nRequire stack:\n- C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\.pnpm\\@prisma+client@6.19.2_prism_6b2b1af085fe6797f5a5ea830937a8e3\\node_modules\\@prisma\\client\\default.js\n- C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\.cursor\\debug-check-prisma.ts","hasPackageJson":true,"hasIndexDts":true},"sessionId":"debug-session","runId":"run1","hypothesisId":"ALL"}
|
|
10
|
+
{"location":"debug-check-prisma.ts:10","message":"Checking paths","data":{"workspaceRoot":"C:\\coding\\AV6\\Node\\packages\\Av6-node-package","prismaClientPath":"C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\@prisma\\client","prismaGeneratedPath":"C:\\coding\\AV6\\Node\\packages\\Av6-node-package\\node_modules\\.prisma\\client","prismaClientExists":true,"prismaGeneratedExists":false},"sessionId":"debug-session","runId":"run1","hypothesisId":"A"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import winston from 'winston';
|
|
2
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
|
-
import { Readable } from 'stream';
|
|
4
1
|
import { JsonValue } from '@prisma/client/runtime/library';
|
|
5
|
-
import
|
|
2
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
6
3
|
import { AxiosResponse } from 'axios';
|
|
4
|
+
import ExcelJs from 'exceljs';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
import winston from 'winston';
|
|
7
7
|
import * as PrismaNamespace from '@prisma/client';
|
|
8
8
|
import { PrismaClient, Prisma } from '@prisma/client';
|
|
9
9
|
|
|
@@ -31,7 +31,7 @@ declare enum ErrorMessageType {
|
|
|
31
31
|
|
|
32
32
|
type Presence = "required" | "optional" | "forbidden";
|
|
33
33
|
type Op = "create" | "update";
|
|
34
|
-
type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "object" | "array" | "json";
|
|
34
|
+
type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "object" | "array" | "json" | "file";
|
|
35
35
|
type SourcePath = `body.${string}` | `vars.${string}` | `ctx.${string}`;
|
|
36
36
|
interface FieldRules {
|
|
37
37
|
min?: number;
|
|
@@ -46,6 +46,8 @@ interface FieldRules {
|
|
|
46
46
|
precisionFrom?: "ctx.decimalPrecision";
|
|
47
47
|
minDate?: "today" | "now";
|
|
48
48
|
minDateFieldRef?: string;
|
|
49
|
+
fileKind?: "image" | "document";
|
|
50
|
+
allowedExt?: string[];
|
|
49
51
|
when?: {
|
|
50
52
|
ref: string;
|
|
51
53
|
is: string | number | boolean | (string | number | boolean)[];
|
|
@@ -72,7 +74,13 @@ interface FieldConfig {
|
|
|
72
74
|
rules?: FieldRules;
|
|
73
75
|
default?: unknown;
|
|
74
76
|
allowNull?: boolean;
|
|
77
|
+
allowEmptyString?: boolean;
|
|
75
78
|
messages?: Record<string, string>;
|
|
79
|
+
upload?: {
|
|
80
|
+
mode: "single";
|
|
81
|
+
attr: string;
|
|
82
|
+
folder?: string;
|
|
83
|
+
};
|
|
76
84
|
}
|
|
77
85
|
type RelationStrategy = "create" | "replace" | "upsert";
|
|
78
86
|
interface RelationWriteConfig {
|
|
@@ -419,6 +427,8 @@ interface Mapper {
|
|
|
419
427
|
interface Config {
|
|
420
428
|
REDIS_PREFIX: string;
|
|
421
429
|
CACHE_KEY_NAME: string;
|
|
430
|
+
MASTER_CACHE_KEY_NAME: string;
|
|
431
|
+
MASTER_KEY_MODELS: string[];
|
|
422
432
|
}
|
|
423
433
|
type Store = {
|
|
424
434
|
user?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import winston from 'winston';
|
|
2
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
|
-
import { Readable } from 'stream';
|
|
4
1
|
import { JsonValue } from '@prisma/client/runtime/library';
|
|
5
|
-
import
|
|
2
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
6
3
|
import { AxiosResponse } from 'axios';
|
|
4
|
+
import ExcelJs from 'exceljs';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
import winston from 'winston';
|
|
7
7
|
import * as PrismaNamespace from '@prisma/client';
|
|
8
8
|
import { PrismaClient, Prisma } from '@prisma/client';
|
|
9
9
|
|
|
@@ -31,7 +31,7 @@ declare enum ErrorMessageType {
|
|
|
31
31
|
|
|
32
32
|
type Presence = "required" | "optional" | "forbidden";
|
|
33
33
|
type Op = "create" | "update";
|
|
34
|
-
type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "object" | "array" | "json";
|
|
34
|
+
type FieldType = "string" | "number" | "boolean" | "date" | "enum" | "object" | "array" | "json" | "file";
|
|
35
35
|
type SourcePath = `body.${string}` | `vars.${string}` | `ctx.${string}`;
|
|
36
36
|
interface FieldRules {
|
|
37
37
|
min?: number;
|
|
@@ -46,6 +46,8 @@ interface FieldRules {
|
|
|
46
46
|
precisionFrom?: "ctx.decimalPrecision";
|
|
47
47
|
minDate?: "today" | "now";
|
|
48
48
|
minDateFieldRef?: string;
|
|
49
|
+
fileKind?: "image" | "document";
|
|
50
|
+
allowedExt?: string[];
|
|
49
51
|
when?: {
|
|
50
52
|
ref: string;
|
|
51
53
|
is: string | number | boolean | (string | number | boolean)[];
|
|
@@ -72,7 +74,13 @@ interface FieldConfig {
|
|
|
72
74
|
rules?: FieldRules;
|
|
73
75
|
default?: unknown;
|
|
74
76
|
allowNull?: boolean;
|
|
77
|
+
allowEmptyString?: boolean;
|
|
75
78
|
messages?: Record<string, string>;
|
|
79
|
+
upload?: {
|
|
80
|
+
mode: "single";
|
|
81
|
+
attr: string;
|
|
82
|
+
folder?: string;
|
|
83
|
+
};
|
|
76
84
|
}
|
|
77
85
|
type RelationStrategy = "create" | "replace" | "upsert";
|
|
78
86
|
interface RelationWriteConfig {
|
|
@@ -419,6 +427,8 @@ interface Mapper {
|
|
|
419
427
|
interface Config {
|
|
420
428
|
REDIS_PREFIX: string;
|
|
421
429
|
CACHE_KEY_NAME: string;
|
|
430
|
+
MASTER_CACHE_KEY_NAME: string;
|
|
431
|
+
MASTER_KEY_MODELS: string[];
|
|
422
432
|
}
|
|
423
433
|
type Store = {
|
|
424
434
|
user?: {
|
package/dist/index.js
CHANGED
|
@@ -1057,6 +1057,129 @@ var commonCreateUpdateRepository = (serviceDeps) => {
|
|
|
1057
1057
|
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1058
1058
|
var import_joi = __toESM(require("joi"));
|
|
1059
1059
|
var import_dayjs = __toESM(require("dayjs"));
|
|
1060
|
+
|
|
1061
|
+
// src/utils/helper.utils.ts
|
|
1062
|
+
function customOmit(obj, keys) {
|
|
1063
|
+
const rest = { ...obj };
|
|
1064
|
+
const omitted = {};
|
|
1065
|
+
for (const key of keys) {
|
|
1066
|
+
if (key in obj) {
|
|
1067
|
+
omitted[key] = obj[key];
|
|
1068
|
+
delete rest[key];
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return { rest, omitted };
|
|
1072
|
+
}
|
|
1073
|
+
function getDynamicValue(obj, accessorKey) {
|
|
1074
|
+
if (!accessorKey || obj == null || typeof obj !== "object") {
|
|
1075
|
+
return null;
|
|
1076
|
+
}
|
|
1077
|
+
const keys = accessorKey.split(".");
|
|
1078
|
+
let result = obj;
|
|
1079
|
+
for (const key of keys) {
|
|
1080
|
+
if (result == null || typeof result !== "object" || !(key in result)) {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
result = result[key];
|
|
1084
|
+
}
|
|
1085
|
+
return result === void 0 ? null : result;
|
|
1086
|
+
}
|
|
1087
|
+
function objectTo2DArray(obj, maxCols) {
|
|
1088
|
+
if (maxCols < 2) {
|
|
1089
|
+
throw new Error("maxCols must be at least 2");
|
|
1090
|
+
}
|
|
1091
|
+
const rows = [];
|
|
1092
|
+
let currentRow = [];
|
|
1093
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1094
|
+
const pair = [key, value];
|
|
1095
|
+
if (currentRow.length + pair.length > maxCols) {
|
|
1096
|
+
if (currentRow.length > 0) {
|
|
1097
|
+
rows.push(currentRow);
|
|
1098
|
+
}
|
|
1099
|
+
currentRow = [];
|
|
1100
|
+
}
|
|
1101
|
+
currentRow.push(...pair);
|
|
1102
|
+
}
|
|
1103
|
+
if (currentRow.length > 0) {
|
|
1104
|
+
rows.push(currentRow);
|
|
1105
|
+
}
|
|
1106
|
+
return rows;
|
|
1107
|
+
}
|
|
1108
|
+
function toNumberOrNull(value) {
|
|
1109
|
+
if (typeof value === "number") {
|
|
1110
|
+
return value;
|
|
1111
|
+
}
|
|
1112
|
+
const converted = Number(value);
|
|
1113
|
+
return isNaN(converted) ? null : converted;
|
|
1114
|
+
}
|
|
1115
|
+
var getPattern = {
|
|
1116
|
+
stringBaseNum: /^[1-9][0-9]*$/,
|
|
1117
|
+
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
1118
|
+
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
1119
|
+
namePattern: /^[A-Za-z\s]+$/,
|
|
1120
|
+
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
1121
|
+
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
1122
|
+
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
1123
|
+
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
1124
|
+
// phonePattern:
|
|
1125
|
+
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
1126
|
+
phonePattern: /^\d{9}$/,
|
|
1127
|
+
postalCodePattern: /^[0-9]{5}$/,
|
|
1128
|
+
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
1129
|
+
numericPattern: /^[0-9]+$/,
|
|
1130
|
+
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
1131
|
+
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
1132
|
+
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
1133
|
+
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
1134
|
+
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
1135
|
+
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
1136
|
+
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
1137
|
+
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
1138
|
+
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
1139
|
+
binaryPattern: /^[01]+$/,
|
|
1140
|
+
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
1141
|
+
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
1142
|
+
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
1143
|
+
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
1144
|
+
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
1145
|
+
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
1146
|
+
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
1147
|
+
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
1148
|
+
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
1149
|
+
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
1150
|
+
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
1151
|
+
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
1152
|
+
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
1153
|
+
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
1154
|
+
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
1155
|
+
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
1156
|
+
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
1157
|
+
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
1158
|
+
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
1159
|
+
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
1160
|
+
audioPattern: /\.(mp3|wav)$/i,
|
|
1161
|
+
pdfPattern: /\.(pdf)$/i,
|
|
1162
|
+
docPattern: /\.(doc|docx)$/i,
|
|
1163
|
+
xlsPattern: /\.(xls|xlsx)$/i,
|
|
1164
|
+
pptPattern: /\.(ppt|pptx)$/i,
|
|
1165
|
+
zipPattern: /\.(zip)$/i,
|
|
1166
|
+
rarPattern: /\.(rar)$/i,
|
|
1167
|
+
tarPattern: /\.(tar)$/i,
|
|
1168
|
+
gzipPattern: /\.(gz|gzip)$/i,
|
|
1169
|
+
bz2Pattern: /\.(bz2)$/i,
|
|
1170
|
+
isoPattern: /\.(iso)$/i,
|
|
1171
|
+
txtPattern: /\.(txt)$/i,
|
|
1172
|
+
documentPattern: /\.(pdf|doc|docx|xls|xlsx|ppt|pptx|txt)$/i
|
|
1173
|
+
};
|
|
1174
|
+
var interpolate = (template, vars) => {
|
|
1175
|
+
return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, key) => {
|
|
1176
|
+
key = key.trim();
|
|
1177
|
+
return key in vars ? String(vars[key]) : "";
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
|
|
1181
|
+
|
|
1182
|
+
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1060
1183
|
function applyNumberCompare(schema, op, ref) {
|
|
1061
1184
|
const r = import_joi.default.ref(ref);
|
|
1062
1185
|
switch (op) {
|
|
@@ -1141,11 +1264,24 @@ var buildScalar = (f, ctx, op) => {
|
|
|
1141
1264
|
case "array":
|
|
1142
1265
|
s = import_joi.default.array();
|
|
1143
1266
|
break;
|
|
1267
|
+
case "file": {
|
|
1268
|
+
let j = import_joi.default.string();
|
|
1269
|
+
if (rules.trim) j = j.trim();
|
|
1270
|
+
const kind = rules.fileKind ?? "image";
|
|
1271
|
+
if (kind === "image") {
|
|
1272
|
+
j = j.pattern(getPattern.imagePattern);
|
|
1273
|
+
} else {
|
|
1274
|
+
j = j.pattern(getPattern.documentPattern);
|
|
1275
|
+
}
|
|
1276
|
+
s = j;
|
|
1277
|
+
break;
|
|
1278
|
+
}
|
|
1144
1279
|
case "json":
|
|
1145
1280
|
default:
|
|
1146
1281
|
s = import_joi.default.any();
|
|
1147
1282
|
}
|
|
1148
1283
|
if (f.allowNull) s = s.allow(null);
|
|
1284
|
+
if (f.allowEmptyString) s = s.allow("");
|
|
1149
1285
|
if (f.default !== void 0) s = s.default(f.default);
|
|
1150
1286
|
if (rules.when?.ref) {
|
|
1151
1287
|
const isVal = Array.isArray(rules.when.is) ? rules.when.is : [rules.when.is];
|
|
@@ -1196,126 +1332,6 @@ var buildJoiSchemaForOp = (cfg, op, ctx) => {
|
|
|
1196
1332
|
});
|
|
1197
1333
|
};
|
|
1198
1334
|
|
|
1199
|
-
// src/utils/helper.utils.ts
|
|
1200
|
-
function customOmit(obj, keys) {
|
|
1201
|
-
const rest = { ...obj };
|
|
1202
|
-
const omitted = {};
|
|
1203
|
-
for (const key of keys) {
|
|
1204
|
-
if (key in obj) {
|
|
1205
|
-
omitted[key] = obj[key];
|
|
1206
|
-
delete rest[key];
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
return { rest, omitted };
|
|
1210
|
-
}
|
|
1211
|
-
function getDynamicValue(obj, accessorKey) {
|
|
1212
|
-
if (!accessorKey || obj == null || typeof obj !== "object") {
|
|
1213
|
-
return null;
|
|
1214
|
-
}
|
|
1215
|
-
const keys = accessorKey.split(".");
|
|
1216
|
-
let result = obj;
|
|
1217
|
-
for (const key of keys) {
|
|
1218
|
-
if (result == null || typeof result !== "object" || !(key in result)) {
|
|
1219
|
-
return null;
|
|
1220
|
-
}
|
|
1221
|
-
result = result[key];
|
|
1222
|
-
}
|
|
1223
|
-
return result === void 0 ? null : result;
|
|
1224
|
-
}
|
|
1225
|
-
function objectTo2DArray(obj, maxCols) {
|
|
1226
|
-
if (maxCols < 2) {
|
|
1227
|
-
throw new Error("maxCols must be at least 2");
|
|
1228
|
-
}
|
|
1229
|
-
const rows = [];
|
|
1230
|
-
let currentRow = [];
|
|
1231
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
1232
|
-
const pair = [key, value];
|
|
1233
|
-
if (currentRow.length + pair.length > maxCols) {
|
|
1234
|
-
if (currentRow.length > 0) {
|
|
1235
|
-
rows.push(currentRow);
|
|
1236
|
-
}
|
|
1237
|
-
currentRow = [];
|
|
1238
|
-
}
|
|
1239
|
-
currentRow.push(...pair);
|
|
1240
|
-
}
|
|
1241
|
-
if (currentRow.length > 0) {
|
|
1242
|
-
rows.push(currentRow);
|
|
1243
|
-
}
|
|
1244
|
-
return rows;
|
|
1245
|
-
}
|
|
1246
|
-
function toNumberOrNull(value) {
|
|
1247
|
-
if (typeof value === "number") {
|
|
1248
|
-
return value;
|
|
1249
|
-
}
|
|
1250
|
-
const converted = Number(value);
|
|
1251
|
-
return isNaN(converted) ? null : converted;
|
|
1252
|
-
}
|
|
1253
|
-
var getPattern = {
|
|
1254
|
-
stringBaseNum: /^[1-9][0-9]*$/,
|
|
1255
|
-
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
1256
|
-
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
1257
|
-
namePattern: /^[A-Za-z\s]+$/,
|
|
1258
|
-
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
1259
|
-
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
1260
|
-
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
1261
|
-
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
1262
|
-
// phonePattern:
|
|
1263
|
-
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
1264
|
-
phonePattern: /^\d{9}$/,
|
|
1265
|
-
postalCodePattern: /^[0-9]{5}$/,
|
|
1266
|
-
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
1267
|
-
numericPattern: /^[0-9]+$/,
|
|
1268
|
-
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
1269
|
-
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
1270
|
-
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
1271
|
-
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
1272
|
-
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
1273
|
-
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
1274
|
-
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
1275
|
-
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
1276
|
-
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
1277
|
-
binaryPattern: /^[01]+$/,
|
|
1278
|
-
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
1279
|
-
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
1280
|
-
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
1281
|
-
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
1282
|
-
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
1283
|
-
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
1284
|
-
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
1285
|
-
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
1286
|
-
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
1287
|
-
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
1288
|
-
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
1289
|
-
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
1290
|
-
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
1291
|
-
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
1292
|
-
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
1293
|
-
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
1294
|
-
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
1295
|
-
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
1296
|
-
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
1297
|
-
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
1298
|
-
audioPattern: /\.(mp3|wav)$/i,
|
|
1299
|
-
pdfPattern: /\.(pdf)$/i,
|
|
1300
|
-
docPattern: /\.(doc|docx)$/i,
|
|
1301
|
-
xlsPattern: /\.(xls|xlsx)$/i,
|
|
1302
|
-
pptPattern: /\.(ppt|pptx)$/i,
|
|
1303
|
-
zipPattern: /\.(zip)$/i,
|
|
1304
|
-
rarPattern: /\.(rar)$/i,
|
|
1305
|
-
tarPattern: /\.(tar)$/i,
|
|
1306
|
-
gzipPattern: /\.(gz|gzip)$/i,
|
|
1307
|
-
bz2Pattern: /\.(bz2)$/i,
|
|
1308
|
-
isoPattern: /\.(iso)$/i,
|
|
1309
|
-
txtPattern: /\.(txt)$/i
|
|
1310
|
-
};
|
|
1311
|
-
var interpolate = (template, vars) => {
|
|
1312
|
-
return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, key) => {
|
|
1313
|
-
key = key.trim();
|
|
1314
|
-
return key in vars ? String(vars[key]) : "";
|
|
1315
|
-
});
|
|
1316
|
-
};
|
|
1317
|
-
var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
|
|
1318
|
-
|
|
1319
1335
|
// src/services/common.service.ts
|
|
1320
1336
|
var import_axios = __toESM(require("axios"));
|
|
1321
1337
|
var import_exceljs = __toESM(require("exceljs"));
|
|
@@ -1326,7 +1342,7 @@ var commonService = (serviceDeps) => {
|
|
|
1326
1342
|
const logger = serviceDeps.logger;
|
|
1327
1343
|
const dtoMapping = serviceDeps.mapper.dtoMapping;
|
|
1328
1344
|
const validationMapping = serviceDeps.mapper.validationMapping;
|
|
1329
|
-
const { REDIS_PREFIX, CACHE_KEY_NAME } = serviceDeps.config;
|
|
1345
|
+
const { REDIS_PREFIX, CACHE_KEY_NAME, MASTER_CACHE_KEY_NAME, MASTER_KEY_MODELS } = serviceDeps.config;
|
|
1330
1346
|
const commonRepositoryFactory = commonRepository(serviceDeps);
|
|
1331
1347
|
const commonCreateUpdateRepositoryFactory = commonCreateUpdateRepository(serviceDeps);
|
|
1332
1348
|
const requestStorage = serviceDeps.requestStorage;
|
|
@@ -1439,7 +1455,7 @@ var commonService = (serviceDeps) => {
|
|
|
1439
1455
|
let commonData;
|
|
1440
1456
|
if (shortCodeData.isCacheable && fetchParams.shortCode !== "UIN_CONFIG" && !fetchParams.includes) {
|
|
1441
1457
|
commonData = await getCacheById(
|
|
1442
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1458
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1443
1459
|
fetchParams.id
|
|
1444
1460
|
);
|
|
1445
1461
|
if (commonData) {
|
|
@@ -1535,7 +1551,10 @@ var commonService = (serviceDeps) => {
|
|
|
1535
1551
|
const shortCodeData = deleteParams.shortCodeData;
|
|
1536
1552
|
await commonRepositoryFactory.commonDelete(deleteParams);
|
|
1537
1553
|
if (shortCodeData.isCacheable) {
|
|
1538
|
-
await deleteCache(
|
|
1554
|
+
await deleteCache(
|
|
1555
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1556
|
+
deleteParams.id
|
|
1557
|
+
);
|
|
1539
1558
|
}
|
|
1540
1559
|
logger.info("exiting::delete::service");
|
|
1541
1560
|
},
|
|
@@ -1545,7 +1564,7 @@ var commonService = (serviceDeps) => {
|
|
|
1545
1564
|
const updatedData = await commonRepositoryFactory.commonUpdateStatus(updateStatusParams);
|
|
1546
1565
|
if (shortCodeData.isCacheable) {
|
|
1547
1566
|
await updateCache(
|
|
1548
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1567
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1549
1568
|
updateStatusParams.id,
|
|
1550
1569
|
updatedData
|
|
1551
1570
|
);
|
|
@@ -1559,7 +1578,7 @@ var commonService = (serviceDeps) => {
|
|
|
1559
1578
|
const lockResult = await commonRepositoryFactory.commonlockUnlock({ ...lockUnlockParams, shortCodeData });
|
|
1560
1579
|
if (shortCodeData.isCacheable) {
|
|
1561
1580
|
await updateCache(
|
|
1562
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1581
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1563
1582
|
lockUnlockParams.id,
|
|
1564
1583
|
lockResult
|
|
1565
1584
|
);
|
|
@@ -1593,7 +1612,7 @@ var commonService = (serviceDeps) => {
|
|
|
1593
1612
|
});
|
|
1594
1613
|
if (shortCodeData.isCacheable) {
|
|
1595
1614
|
await addToCache(
|
|
1596
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1615
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1597
1616
|
createResult[cfg.primaryKey],
|
|
1598
1617
|
createResult
|
|
1599
1618
|
);
|
|
@@ -1641,7 +1660,7 @@ var commonService = (serviceDeps) => {
|
|
|
1641
1660
|
});
|
|
1642
1661
|
if (shortCodeData.isCacheable) {
|
|
1643
1662
|
await updateCache(
|
|
1644
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1663
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1645
1664
|
updateResult.id,
|
|
1646
1665
|
updateResult
|
|
1647
1666
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -1007,6 +1007,129 @@ var commonCreateUpdateRepository = (serviceDeps) => {
|
|
|
1007
1007
|
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1008
1008
|
import Joi from "joi";
|
|
1009
1009
|
import dayjs from "dayjs";
|
|
1010
|
+
|
|
1011
|
+
// src/utils/helper.utils.ts
|
|
1012
|
+
function customOmit(obj, keys) {
|
|
1013
|
+
const rest = { ...obj };
|
|
1014
|
+
const omitted = {};
|
|
1015
|
+
for (const key of keys) {
|
|
1016
|
+
if (key in obj) {
|
|
1017
|
+
omitted[key] = obj[key];
|
|
1018
|
+
delete rest[key];
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return { rest, omitted };
|
|
1022
|
+
}
|
|
1023
|
+
function getDynamicValue(obj, accessorKey) {
|
|
1024
|
+
if (!accessorKey || obj == null || typeof obj !== "object") {
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
const keys = accessorKey.split(".");
|
|
1028
|
+
let result = obj;
|
|
1029
|
+
for (const key of keys) {
|
|
1030
|
+
if (result == null || typeof result !== "object" || !(key in result)) {
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
result = result[key];
|
|
1034
|
+
}
|
|
1035
|
+
return result === void 0 ? null : result;
|
|
1036
|
+
}
|
|
1037
|
+
function objectTo2DArray(obj, maxCols) {
|
|
1038
|
+
if (maxCols < 2) {
|
|
1039
|
+
throw new Error("maxCols must be at least 2");
|
|
1040
|
+
}
|
|
1041
|
+
const rows = [];
|
|
1042
|
+
let currentRow = [];
|
|
1043
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1044
|
+
const pair = [key, value];
|
|
1045
|
+
if (currentRow.length + pair.length > maxCols) {
|
|
1046
|
+
if (currentRow.length > 0) {
|
|
1047
|
+
rows.push(currentRow);
|
|
1048
|
+
}
|
|
1049
|
+
currentRow = [];
|
|
1050
|
+
}
|
|
1051
|
+
currentRow.push(...pair);
|
|
1052
|
+
}
|
|
1053
|
+
if (currentRow.length > 0) {
|
|
1054
|
+
rows.push(currentRow);
|
|
1055
|
+
}
|
|
1056
|
+
return rows;
|
|
1057
|
+
}
|
|
1058
|
+
function toNumberOrNull(value) {
|
|
1059
|
+
if (typeof value === "number") {
|
|
1060
|
+
return value;
|
|
1061
|
+
}
|
|
1062
|
+
const converted = Number(value);
|
|
1063
|
+
return isNaN(converted) ? null : converted;
|
|
1064
|
+
}
|
|
1065
|
+
var getPattern = {
|
|
1066
|
+
stringBaseNum: /^[1-9][0-9]*$/,
|
|
1067
|
+
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
1068
|
+
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
1069
|
+
namePattern: /^[A-Za-z\s]+$/,
|
|
1070
|
+
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
1071
|
+
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
1072
|
+
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
1073
|
+
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
1074
|
+
// phonePattern:
|
|
1075
|
+
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
1076
|
+
phonePattern: /^\d{9}$/,
|
|
1077
|
+
postalCodePattern: /^[0-9]{5}$/,
|
|
1078
|
+
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
1079
|
+
numericPattern: /^[0-9]+$/,
|
|
1080
|
+
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
1081
|
+
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
1082
|
+
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
1083
|
+
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
1084
|
+
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
1085
|
+
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
1086
|
+
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
1087
|
+
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
1088
|
+
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
1089
|
+
binaryPattern: /^[01]+$/,
|
|
1090
|
+
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
1091
|
+
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
1092
|
+
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
1093
|
+
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
1094
|
+
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
1095
|
+
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
1096
|
+
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
1097
|
+
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
1098
|
+
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
1099
|
+
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
1100
|
+
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
1101
|
+
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
1102
|
+
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
1103
|
+
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
1104
|
+
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
1105
|
+
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
1106
|
+
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
1107
|
+
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
1108
|
+
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
1109
|
+
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
1110
|
+
audioPattern: /\.(mp3|wav)$/i,
|
|
1111
|
+
pdfPattern: /\.(pdf)$/i,
|
|
1112
|
+
docPattern: /\.(doc|docx)$/i,
|
|
1113
|
+
xlsPattern: /\.(xls|xlsx)$/i,
|
|
1114
|
+
pptPattern: /\.(ppt|pptx)$/i,
|
|
1115
|
+
zipPattern: /\.(zip)$/i,
|
|
1116
|
+
rarPattern: /\.(rar)$/i,
|
|
1117
|
+
tarPattern: /\.(tar)$/i,
|
|
1118
|
+
gzipPattern: /\.(gz|gzip)$/i,
|
|
1119
|
+
bz2Pattern: /\.(bz2)$/i,
|
|
1120
|
+
isoPattern: /\.(iso)$/i,
|
|
1121
|
+
txtPattern: /\.(txt)$/i,
|
|
1122
|
+
documentPattern: /\.(pdf|doc|docx|xls|xlsx|ppt|pptx|txt)$/i
|
|
1123
|
+
};
|
|
1124
|
+
var interpolate = (template, vars) => {
|
|
1125
|
+
return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, key) => {
|
|
1126
|
+
key = key.trim();
|
|
1127
|
+
return key in vars ? String(vars[key]) : "";
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
|
|
1131
|
+
|
|
1132
|
+
// src/utils/dynamicJoiBuilder.utils.ts
|
|
1010
1133
|
function applyNumberCompare(schema, op, ref) {
|
|
1011
1134
|
const r = Joi.ref(ref);
|
|
1012
1135
|
switch (op) {
|
|
@@ -1091,11 +1214,24 @@ var buildScalar = (f, ctx, op) => {
|
|
|
1091
1214
|
case "array":
|
|
1092
1215
|
s = Joi.array();
|
|
1093
1216
|
break;
|
|
1217
|
+
case "file": {
|
|
1218
|
+
let j = Joi.string();
|
|
1219
|
+
if (rules.trim) j = j.trim();
|
|
1220
|
+
const kind = rules.fileKind ?? "image";
|
|
1221
|
+
if (kind === "image") {
|
|
1222
|
+
j = j.pattern(getPattern.imagePattern);
|
|
1223
|
+
} else {
|
|
1224
|
+
j = j.pattern(getPattern.documentPattern);
|
|
1225
|
+
}
|
|
1226
|
+
s = j;
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1094
1229
|
case "json":
|
|
1095
1230
|
default:
|
|
1096
1231
|
s = Joi.any();
|
|
1097
1232
|
}
|
|
1098
1233
|
if (f.allowNull) s = s.allow(null);
|
|
1234
|
+
if (f.allowEmptyString) s = s.allow("");
|
|
1099
1235
|
if (f.default !== void 0) s = s.default(f.default);
|
|
1100
1236
|
if (rules.when?.ref) {
|
|
1101
1237
|
const isVal = Array.isArray(rules.when.is) ? rules.when.is : [rules.when.is];
|
|
@@ -1146,126 +1282,6 @@ var buildJoiSchemaForOp = (cfg, op, ctx) => {
|
|
|
1146
1282
|
});
|
|
1147
1283
|
};
|
|
1148
1284
|
|
|
1149
|
-
// src/utils/helper.utils.ts
|
|
1150
|
-
function customOmit(obj, keys) {
|
|
1151
|
-
const rest = { ...obj };
|
|
1152
|
-
const omitted = {};
|
|
1153
|
-
for (const key of keys) {
|
|
1154
|
-
if (key in obj) {
|
|
1155
|
-
omitted[key] = obj[key];
|
|
1156
|
-
delete rest[key];
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
return { rest, omitted };
|
|
1160
|
-
}
|
|
1161
|
-
function getDynamicValue(obj, accessorKey) {
|
|
1162
|
-
if (!accessorKey || obj == null || typeof obj !== "object") {
|
|
1163
|
-
return null;
|
|
1164
|
-
}
|
|
1165
|
-
const keys = accessorKey.split(".");
|
|
1166
|
-
let result = obj;
|
|
1167
|
-
for (const key of keys) {
|
|
1168
|
-
if (result == null || typeof result !== "object" || !(key in result)) {
|
|
1169
|
-
return null;
|
|
1170
|
-
}
|
|
1171
|
-
result = result[key];
|
|
1172
|
-
}
|
|
1173
|
-
return result === void 0 ? null : result;
|
|
1174
|
-
}
|
|
1175
|
-
function objectTo2DArray(obj, maxCols) {
|
|
1176
|
-
if (maxCols < 2) {
|
|
1177
|
-
throw new Error("maxCols must be at least 2");
|
|
1178
|
-
}
|
|
1179
|
-
const rows = [];
|
|
1180
|
-
let currentRow = [];
|
|
1181
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
1182
|
-
const pair = [key, value];
|
|
1183
|
-
if (currentRow.length + pair.length > maxCols) {
|
|
1184
|
-
if (currentRow.length > 0) {
|
|
1185
|
-
rows.push(currentRow);
|
|
1186
|
-
}
|
|
1187
|
-
currentRow = [];
|
|
1188
|
-
}
|
|
1189
|
-
currentRow.push(...pair);
|
|
1190
|
-
}
|
|
1191
|
-
if (currentRow.length > 0) {
|
|
1192
|
-
rows.push(currentRow);
|
|
1193
|
-
}
|
|
1194
|
-
return rows;
|
|
1195
|
-
}
|
|
1196
|
-
function toNumberOrNull(value) {
|
|
1197
|
-
if (typeof value === "number") {
|
|
1198
|
-
return value;
|
|
1199
|
-
}
|
|
1200
|
-
const converted = Number(value);
|
|
1201
|
-
return isNaN(converted) ? null : converted;
|
|
1202
|
-
}
|
|
1203
|
-
var getPattern = {
|
|
1204
|
-
stringBaseNum: /^[1-9][0-9]*$/,
|
|
1205
|
-
licenseTitle: /^(?=.{3,100}$)[A-Za-z0-9][A-Za-z0-9\s\-/&,.()]*$/,
|
|
1206
|
-
categoryName: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};'":\\|,.<>/?]).{3,30}$/,
|
|
1207
|
-
namePattern: /^[A-Za-z\s]+$/,
|
|
1208
|
-
skuPattern: /^[A-Z0-9_-]+$/i,
|
|
1209
|
-
SlNoPattern: /^[A-Za-z0-9_-]+$/,
|
|
1210
|
-
nameWithNumPattern: /^[A-Za-z0-9\s]+$/,
|
|
1211
|
-
emailPattern: /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/,
|
|
1212
|
-
// phonePattern:
|
|
1213
|
-
// /^(?:\+?(\d{1,3})[\s.-]?)?(?:\(?(\d{3})\)?[\s.-]?)?(\d{3})[\s.-]?(\d{4})(?:\s*(?:x|ext)\s*(\d+))?$/,
|
|
1214
|
-
phonePattern: /^\d{9}$/,
|
|
1215
|
-
postalCodePattern: /^[0-9]{5}$/,
|
|
1216
|
-
alphanumericPattern: /^[a-zA-Z0-9]+$/,
|
|
1217
|
-
numericPattern: /^[0-9]+$/,
|
|
1218
|
-
datePattern: /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/,
|
|
1219
|
-
timePattern: /^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/,
|
|
1220
|
-
uuidPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
1221
|
-
passwordPattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/,
|
|
1222
|
-
jsonPattern: /^(\[.+?\]|\{.+?\})$/,
|
|
1223
|
-
ipPattern: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
|
|
1224
|
-
macAddressPattern: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
|
|
1225
|
-
hexColorPattern: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/,
|
|
1226
|
-
hexPattern: /^[0-9A-Fa-f]+$/,
|
|
1227
|
-
binaryPattern: /^[01]+$/,
|
|
1228
|
-
base64Pattern: /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/,
|
|
1229
|
-
alphanumericDashPattern: /^[a-zA-Z0-9-]+$/,
|
|
1230
|
-
alphanumericDotPattern: /^[a-zA-Z0-9.]+$/,
|
|
1231
|
-
alphanumericUnderscorePattern: /^[a-zA-Z0-9_]+$/,
|
|
1232
|
-
alphanumericPlusPattern: /^[a-zA-Z0-9+]+$/,
|
|
1233
|
-
alphanumericSlashPattern: /^[a-zA-Z0-9/]+$/,
|
|
1234
|
-
alphanumericColonPattern: /^[a-zA-Z0-9:]+$/,
|
|
1235
|
-
alphanumericQuestionMarkPattern: /^[a-zA-Z0-9?]+$/,
|
|
1236
|
-
alphanumericAtPattern: /^[a-zA-Z0-9@]+$/,
|
|
1237
|
-
alphanumericHashPattern: /^[a-zA-Z0-9#]+$/,
|
|
1238
|
-
alphanumericDollarPattern: /^[a-zA-Z0-9$]+$/,
|
|
1239
|
-
alphanumericPercentPattern: /^[a-zA-Z0-9%]+$/,
|
|
1240
|
-
alphanumericAmpersandPattern: /^[a-zA-Z0-9&]+$/,
|
|
1241
|
-
alphanumericVerticalBarPattern: /^[a-zA-Z0-9|]+$/,
|
|
1242
|
-
alphanumericTildePattern: /^[a-zA-Z0-9~]+$/,
|
|
1243
|
-
alphanumericExclamationPattern: /^[a-zA-Z0-9!]+$/,
|
|
1244
|
-
alphanumericAndPattern: /^[a-zA-Z0-9&]+$/,
|
|
1245
|
-
alphanumericAsteriskPattern: /^[a-zA-Z0-9*]+$/,
|
|
1246
|
-
imagePattern: /^.*\.(jpe?g|png|gif)$/i,
|
|
1247
|
-
videoPattern: /\.(mp4|webm|ogg)$/i,
|
|
1248
|
-
audioPattern: /\.(mp3|wav)$/i,
|
|
1249
|
-
pdfPattern: /\.(pdf)$/i,
|
|
1250
|
-
docPattern: /\.(doc|docx)$/i,
|
|
1251
|
-
xlsPattern: /\.(xls|xlsx)$/i,
|
|
1252
|
-
pptPattern: /\.(ppt|pptx)$/i,
|
|
1253
|
-
zipPattern: /\.(zip)$/i,
|
|
1254
|
-
rarPattern: /\.(rar)$/i,
|
|
1255
|
-
tarPattern: /\.(tar)$/i,
|
|
1256
|
-
gzipPattern: /\.(gz|gzip)$/i,
|
|
1257
|
-
bz2Pattern: /\.(bz2)$/i,
|
|
1258
|
-
isoPattern: /\.(iso)$/i,
|
|
1259
|
-
txtPattern: /\.(txt)$/i
|
|
1260
|
-
};
|
|
1261
|
-
var interpolate = (template, vars) => {
|
|
1262
|
-
return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, key) => {
|
|
1263
|
-
key = key.trim();
|
|
1264
|
-
return key in vars ? String(vars[key]) : "";
|
|
1265
|
-
});
|
|
1266
|
-
};
|
|
1267
|
-
var fromTimestampToSqlDatetime = (date) => date.replace("T", " ").replace("Z", "");
|
|
1268
|
-
|
|
1269
1285
|
// src/services/common.service.ts
|
|
1270
1286
|
import axios from "axios";
|
|
1271
1287
|
import ExcelJs from "exceljs";
|
|
@@ -1276,7 +1292,7 @@ var commonService = (serviceDeps) => {
|
|
|
1276
1292
|
const logger = serviceDeps.logger;
|
|
1277
1293
|
const dtoMapping = serviceDeps.mapper.dtoMapping;
|
|
1278
1294
|
const validationMapping = serviceDeps.mapper.validationMapping;
|
|
1279
|
-
const { REDIS_PREFIX, CACHE_KEY_NAME } = serviceDeps.config;
|
|
1295
|
+
const { REDIS_PREFIX, CACHE_KEY_NAME, MASTER_CACHE_KEY_NAME, MASTER_KEY_MODELS } = serviceDeps.config;
|
|
1280
1296
|
const commonRepositoryFactory = commonRepository(serviceDeps);
|
|
1281
1297
|
const commonCreateUpdateRepositoryFactory = commonCreateUpdateRepository(serviceDeps);
|
|
1282
1298
|
const requestStorage = serviceDeps.requestStorage;
|
|
@@ -1389,7 +1405,7 @@ var commonService = (serviceDeps) => {
|
|
|
1389
1405
|
let commonData;
|
|
1390
1406
|
if (shortCodeData.isCacheable && fetchParams.shortCode !== "UIN_CONFIG" && !fetchParams.includes) {
|
|
1391
1407
|
commonData = await getCacheById(
|
|
1392
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1408
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1393
1409
|
fetchParams.id
|
|
1394
1410
|
);
|
|
1395
1411
|
if (commonData) {
|
|
@@ -1485,7 +1501,10 @@ var commonService = (serviceDeps) => {
|
|
|
1485
1501
|
const shortCodeData = deleteParams.shortCodeData;
|
|
1486
1502
|
await commonRepositoryFactory.commonDelete(deleteParams);
|
|
1487
1503
|
if (shortCodeData.isCacheable) {
|
|
1488
|
-
await deleteCache(
|
|
1504
|
+
await deleteCache(
|
|
1505
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1506
|
+
deleteParams.id
|
|
1507
|
+
);
|
|
1489
1508
|
}
|
|
1490
1509
|
logger.info("exiting::delete::service");
|
|
1491
1510
|
},
|
|
@@ -1495,7 +1514,7 @@ var commonService = (serviceDeps) => {
|
|
|
1495
1514
|
const updatedData = await commonRepositoryFactory.commonUpdateStatus(updateStatusParams);
|
|
1496
1515
|
if (shortCodeData.isCacheable) {
|
|
1497
1516
|
await updateCache(
|
|
1498
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1517
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1499
1518
|
updateStatusParams.id,
|
|
1500
1519
|
updatedData
|
|
1501
1520
|
);
|
|
@@ -1509,7 +1528,7 @@ var commonService = (serviceDeps) => {
|
|
|
1509
1528
|
const lockResult = await commonRepositoryFactory.commonlockUnlock({ ...lockUnlockParams, shortCodeData });
|
|
1510
1529
|
if (shortCodeData.isCacheable) {
|
|
1511
1530
|
await updateCache(
|
|
1512
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1531
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1513
1532
|
lockUnlockParams.id,
|
|
1514
1533
|
lockResult
|
|
1515
1534
|
);
|
|
@@ -1543,7 +1562,7 @@ var commonService = (serviceDeps) => {
|
|
|
1543
1562
|
});
|
|
1544
1563
|
if (shortCodeData.isCacheable) {
|
|
1545
1564
|
await addToCache(
|
|
1546
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1565
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1547
1566
|
createResult[cfg.primaryKey],
|
|
1548
1567
|
createResult
|
|
1549
1568
|
);
|
|
@@ -1591,7 +1610,7 @@ var commonService = (serviceDeps) => {
|
|
|
1591
1610
|
});
|
|
1592
1611
|
if (shortCodeData.isCacheable) {
|
|
1593
1612
|
await updateCache(
|
|
1594
|
-
`${REDIS_PREFIX}${CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1613
|
+
`${REDIS_PREFIX}${MASTER_KEY_MODELS.includes(shortCodeData.tableName) ? MASTER_CACHE_KEY_NAME : CACHE_KEY_NAME}:${shortCodeData.tableName}:all`,
|
|
1595
1614
|
updateResult.id,
|
|
1596
1615
|
updateResult
|
|
1597
1616
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "av6-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,18 +9,20 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "npm run format && tsup",
|
|
12
|
+
"p:gen": "prisma generate",
|
|
12
13
|
"format": "prettier --write **/*.ts"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
16
|
+
"@prisma/client": "^6.19.0",
|
|
15
17
|
"@types/nodemailer": "^7.0.3",
|
|
16
18
|
"tsup": "^8.5.0",
|
|
17
19
|
"typescript": "^5.9.2"
|
|
18
20
|
},
|
|
19
21
|
"peerDependencies": {
|
|
22
|
+
"@prisma/client": "^6.19.0",
|
|
20
23
|
"winston": "^3.17.0"
|
|
21
24
|
},
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@prisma/client": "^6.19.0",
|
|
24
26
|
"axios": "^1.11.0",
|
|
25
27
|
"exceljs": "^4.4.0",
|
|
26
28
|
"handlebars": "^4.7.8",
|