storemw-core-api 1.0.57 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -21,7 +21,9 @@ app.use(express_1.default.urlencoded({ limit: '15mb', extended: true }));
21
21
  // Initial Prisma
22
22
  app.use(request_1.initialPrisma);
23
23
  // Protected Routes
24
- app.use(request_1.validateAuthorization); // Validate the Authorization
24
+ app.use((0, request_1.validateAuthorization)({
25
+ excludedRoutes: []
26
+ })); // Validate the Authorization
25
27
  app.use(["/auth"], routes_1.authRoutes);
26
28
  app.use(["/user"], routes_1.userRoutes);
27
29
  app.use(["/users"], routes_1.usersRoutes);
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,gDAAwB;AAExB,qCAyBiB;AACjB,mDAA0G;AAC1G,iDAAoD;AAEpD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAEtB,gBAAgB;AAChB,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAO,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEzE,8BAA8B;AAC9B,GAAG,CAAC,GAAG,CAAC,sBAAY,CAAC,CAAC;AAEtB,wCAAwC;AACxC,GAAG,CAAC,GAAG,CAAC,wBAAc,CAAC,CAAC;AAExB,aAAa;AACb,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACzC,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAE/D,iBAAiB;AACjB,GAAG,CAAC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ACxC,GAAG,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,EAAE,6BAAoB,CAAC,CAAA;AACnD,GAAG,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,8BAAqB,CAAC,CAAA;AACrD,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,sBAAa,CAAC,CAAA;AACpC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,uBAAc,CAAC,CAAA;AACtC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,uBAAc,CAAC,CAAA;AACtC,GAAG,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,EAAE,yBAAgB,CAAC,CAAA;AAE1C,uBAAuB;AACvB,GAAG,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAA;AAErB,kBAAe,GAAG,CAAC","sourcesContent":["import express from \"express\"\nimport path from \"path\";\n\nimport {\n // fileRoutes,\n // filesRoutes,\n // ocrRoutes,\n authRoutes,\n userRoutes,\n usersRoutes,\n businessRoutes,\n businessesRoutes,\n accountRoutes,\n accountsRoutes,\n fileRoutes,\n filesRoutes,\n userBranchRoutes,\n userBranchesRoutes,\n documentRoutes,\n documentsRoutes,\n itemRoutes,\n itemsRoutes,\n regionRoutes,\n regionsRoutes,\n locationRoutes,\n locationsRoutes,\n injectionFieldRoutes,\n injectionFieldsRoutes\n} from \"@/routes\"\nimport { initialPrisma, validateHeader, validateAuthorization, validateCors } from \"@/middlewares/request\"\nimport { errorHandler } from \"./middlewares/common\";\n\nconst app = express();\n\n// Static Routes\napp.use('/public', express.static(path.join(__dirname, '..', 'public')));\n\n// Enable CORS for all origins\napp.use(validateCors);\n\n// Register global check headers handler\napp.use(validateHeader);\n\n// Middleware\napp.use(express.json({ limit: '15mb' }));\napp.use(express.urlencoded({ limit: '15mb', extended: true }));\n\n// Initial Prisma\napp.use(initialPrisma)\n\n// Protected Routes\napp.use(validateAuthorization); // Validate the Authorization\n\napp.use([\"/auth\"], authRoutes)\napp.use([\"/user\"], userRoutes)\napp.use([\"/users\"], usersRoutes)\napp.use([\"/user_branch\"], userBranchRoutes)\napp.use([\"/user_branches\"], userBranchesRoutes)\napp.use([\"/document\"], documentRoutes)\napp.use([\"/documents\"], documentsRoutes)\napp.use([\"/item\"], itemRoutes)\napp.use([\"/items\"], itemsRoutes)\napp.use([\"/file\"], fileRoutes)\napp.use([\"/files\"], filesRoutes)\napp.use([\"/region\"], regionRoutes)\napp.use([\"/regions\"], regionsRoutes)\napp.use([\"/location\"], locationRoutes)\napp.use([\"/locations\"], locationsRoutes)\napp.use([\"/injection_field\"], injectionFieldRoutes)\napp.use([\"/injection_fields\"], injectionFieldsRoutes)\napp.use([\"/account\"], accountRoutes)\napp.use([\"/accounts\"], accountsRoutes)\napp.use([\"/business\"], businessRoutes)\napp.use([\"/businesses\"], businessesRoutes)\n\n// Global error handler\napp.use(errorHandler)\n\nexport default app;"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,gDAAwB;AAExB,qCAyBiB;AACjB,mDAA0G;AAC1G,iDAAoD;AAEpD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAEtB,gBAAgB;AAChB,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAO,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEzE,8BAA8B;AAC9B,GAAG,CAAC,GAAG,CAAC,sBAAY,CAAC,CAAC;AAEtB,wCAAwC;AACxC,GAAG,CAAC,GAAG,CAAC,wBAAc,CAAC,CAAC;AAExB,aAAa;AACb,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACzC,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,U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AAa,CAAC,CAAA;AACpC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,uBAAc,CAAC,CAAA;AACtC,GAAG,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,wBAAe,CAAC,CAAA;AACxC,GAAG,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,EAAE,6BAAoB,CAAC,CAAA;AACnD,GAAG,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,8BAAqB,CAAC,CAAA;AACrD,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,sBAAa,CAAC,CAAA;AACpC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,uBAAc,CAAC,CAAA;AACtC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,uBAAc,CAAC,CAAA;AACtC,GAAG,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,EAAE,yBAAgB,CAAC,CAAA;AAE1C,uBAAuB;AACvB,GAAG,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAA;AAErB,kBAAe,GAAG,CAAC","sourcesContent":["import express from \"express\"\nimport path from \"path\";\n\nimport {\n // fileRoutes,\n // filesRoutes,\n // ocrRoutes,\n authRoutes,\n userRoutes,\n usersRoutes,\n businessRoutes,\n businessesRoutes,\n accountRoutes,\n accountsRoutes,\n fileRoutes,\n filesRoutes,\n userBranchRoutes,\n userBranchesRoutes,\n documentRoutes,\n documentsRoutes,\n itemRoutes,\n itemsRoutes,\n regionRoutes,\n regionsRoutes,\n locationRoutes,\n locationsRoutes,\n injectionFieldRoutes,\n injectionFieldsRoutes\n} from \"@/routes\"\nimport { initialPrisma, validateHeader, validateAuthorization, validateCors } from \"@/middlewares/request\"\nimport { errorHandler } from \"./middlewares/common\";\n\nconst app = express();\n\n// Static Routes\napp.use('/public', express.static(path.join(__dirname, '..', 'public')));\n\n// Enable CORS for all origins\napp.use(validateCors);\n\n// Register global check headers handler\napp.use(validateHeader);\n\n// Middleware\napp.use(express.json({ limit: '15mb' }));\napp.use(express.urlencoded({ limit: '15mb', extended: true }));\n\n// Initial Prisma\napp.use(initialPrisma)\n\n// Protected Routes\napp.use(validateAuthorization({\n excludedRoutes: []\n})); // Validate the Authorization\n\napp.use([\"/auth\"], authRoutes)\napp.use([\"/user\"], userRoutes)\napp.use([\"/users\"], usersRoutes)\napp.use([\"/user_branch\"], userBranchRoutes)\napp.use([\"/user_branches\"], userBranchesRoutes)\napp.use([\"/document\"], documentRoutes)\napp.use([\"/documents\"], documentsRoutes)\napp.use([\"/item\"], itemRoutes)\napp.use([\"/items\"], itemsRoutes)\napp.use([\"/file\"], fileRoutes)\napp.use([\"/files\"], filesRoutes)\napp.use([\"/region\"], regionRoutes)\napp.use([\"/regions\"], regionsRoutes)\napp.use([\"/location\"], locationRoutes)\napp.use([\"/locations\"], locationsRoutes)\napp.use([\"/injection_field\"], injectionFieldRoutes)\napp.use([\"/injection_fields\"], injectionFieldsRoutes)\napp.use([\"/account\"], accountRoutes)\napp.use([\"/accounts\"], accountsRoutes)\napp.use([\"/business\"], businessRoutes)\napp.use([\"/businesses\"], businessesRoutes)\n\n// Global error handler\napp.use(errorHandler)\n\nexport default app;"]}
@@ -1,4 +1,7 @@
1
1
  import { Request, Response, NextFunction } from "express";
2
+ interface ValidateAuthOptions {
3
+ excludedRoutes?: string[];
4
+ }
2
5
  export type AuthorizeRequest = Request & {
3
6
  accountId: number;
4
7
  actionUserId: number;
@@ -9,4 +12,5 @@ export type AuthorizeRequest = Request & {
9
12
  isOperator: boolean;
10
13
  };
11
14
  };
12
- export declare const validateAuthorization: (req: Request, res: Response, next: NextFunction) => void;
15
+ export declare const validateAuthorization: (options?: ValidateAuthOptions) => (req: Request, res: Response, next: NextFunction) => void;
16
+ export {};
@@ -8,62 +8,70 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
8
  // import { storeJwtInMemory } from "../../utils";
9
9
  const config_1 = require("../../configs/config");
10
10
  const utils_1 = require("../../utils");
11
- const excludedRoutes = [
11
+ const defaultExcludedRoutes = [
12
+ '/auth/token',
12
13
  // '/api/tools/generatesignature',
13
14
  // '/api/tools/generatetoken',
14
- '/auth/token'
15
- ]; // List of excluded routes
16
- const validateAuthorization = (req, res, next) => {
17
- if (excludedRoutes.includes(req.path)) {
18
- return next(); // Skip middleware for excluded routes
19
- }
20
- const authSecretKey = config_1.config.AUTH_SECRET_KEY;
21
- const authHeader = req.headers.authorization;
22
- // console.log('in core - authSecretKey', authSecretKey)
23
- // console.log('in core - authHeader', authHeader)
24
- // Extract token from "Bearer <token>"
25
- const token = authHeader && authHeader.split(" ")[1];
26
- try {
27
- if (!token) {
28
- (0, utils_1.sendError)(res, "UNAUTHORIZED", "Invalid authorization token", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
29
- return;
15
+ // add more defaults if needed
16
+ ];
17
+ const validateAuthorization = (options = {}) => {
18
+ // Merge default excluded routes with any custom ones
19
+ const excludedRoutes = [
20
+ ...defaultExcludedRoutes,
21
+ ...(options.excludedRoutes || [])
22
+ ];
23
+ return (req, res, next) => {
24
+ if (excludedRoutes.includes(req.path)) {
25
+ return next(); // Skip middleware for excluded routes
30
26
  }
31
- const jwtData = jsonwebtoken_1.default.verify(token, authSecretKey); // Verify JWT token
32
- // for old format
33
- let accountId = jwtData?.account?.id ?? 0;
34
- let actionUserId = jwtData?.user?.id ?? 0;
35
- let userType = jwtData?.user?.user_type ?? "";
36
- // for new format
37
- if (jwtData?.account?.account_id)
38
- accountId = jwtData?.account?.account_id;
39
- if (jwtData?.user?.user_id)
40
- actionUserId = jwtData?.user?.user_id;
41
- // only check if not operator token
42
- if (userType === "operator") {
43
- accountId = 0; // always 0 for operator login
27
+ const authSecretKey = config_1.config.AUTH_SECRET_KEY;
28
+ const authHeader = req.headers.authorization;
29
+ // console.log('in core - authSecretKey', authSecretKey)
30
+ // console.log('in core - authHeader', authHeader)
31
+ // Extract token from "Bearer <token>"
32
+ const token = authHeader && authHeader.split(" ")[1];
33
+ try {
34
+ if (!token) {
35
+ (0, utils_1.sendError)(res, "UNAUTHORIZED", "Invalid authorization token", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
36
+ return;
37
+ }
38
+ const jwtData = jsonwebtoken_1.default.verify(token, authSecretKey); // Verify JWT token
39
+ // for old format
40
+ let accountId = jwtData?.account?.id ?? 0;
41
+ let actionUserId = jwtData?.user?.id ?? 0;
42
+ let userType = jwtData?.user?.user_type ?? "";
43
+ // for new format
44
+ if (jwtData?.account?.account_id)
45
+ accountId = jwtData?.account?.account_id;
46
+ if (jwtData?.user?.user_id)
47
+ actionUserId = jwtData?.user?.user_id;
48
+ // only check if not operator token
49
+ if (userType === "operator") {
50
+ accountId = 0; // always 0 for operator login
51
+ }
52
+ else {
53
+ if (accountId === 0)
54
+ throw (0, utils_1.sendError)(res, "UNAUTHORIZED", "Missing accountId in authorization", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
55
+ }
56
+ if (actionUserId === 0)
57
+ throw (0, utils_1.sendError)(res, "UNAUTHORIZED", "Missing actionUserId in authorization", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
58
+ req.accountId = Number(accountId);
59
+ req.actionUserId = Number(actionUserId);
60
+ req.auth = {
61
+ accountId: Number(accountId),
62
+ actionUserId: Number(actionUserId),
63
+ authToken: token,
64
+ isOperator: Boolean(userType === "operator")
65
+ };
66
+ // storeJwtInMemory(jwtData)
67
+ // req.jwtUser = jwtData; // Attach decoded payload to request
68
+ next(); // Proceed to the next middleware
44
69
  }
45
- else {
46
- if (accountId === 0)
47
- throw (0, utils_1.sendError)(res, "UNAUTHORIZED", "Missing accountId in authorization", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
70
+ catch (error) {
71
+ (0, utils_1.sendError)(res, "UNAUTHORIZED", "Invalid or expired token", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
72
+ return;
48
73
  }
49
- if (actionUserId === 0)
50
- throw (0, utils_1.sendError)(res, "UNAUTHORIZED", "Missing actionUserId in authorization", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
51
- req.accountId = Number(accountId);
52
- req.actionUserId = Number(actionUserId);
53
- req.auth = {
54
- accountId: Number(accountId),
55
- actionUserId: Number(actionUserId),
56
- authToken: token,
57
- isOperator: Boolean(userType === "operator")
58
- };
59
- // storeJwtInMemory(jwtData)
60
- // req.jwtUser = jwtData; // Attach decoded payload to request
61
- next(); // Proceed to the next middleware
62
- }
63
- catch (error) {
64
- (0, utils_1.sendError)(res, "UNAUTHORIZED", "Invalid or expired token", "", "", utils_1.HTTP_STATUS.UNAUTHORIZED);
65
- return;
66
- }
74
+ };
67
75
  };
68
76
  exports.validateAuthorization = validateAuthorization;
69
77
  //# sourceMappingURL=validateAuthorization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateAuthorization.js","sourceRoot":"","sources":["../../../src/middlewares/request/validateAuthorization.ts"],"names":[],"mappings":";;;;;;AAEA,gEAA+C;AAE/C,8CAA8C;AAE9C,6CAA0C;AAC1C,mCAAiD;AAIjD,MAAM,cAAc,GAAG;IACnB,kCAAkC;IAClC,8BAA8B;IAC9B,aAAa;CAChB,CAAC,CAAC,0BAA0B;AAkBtB,MAAM,qBAAqB,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;IAE3F,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,EAAE,CAAC,CAAC,sCAAsC;IACzD,CAAC;IAED,MAAM,aAAa,GAAG,eAAM,CAAC,eAAe,CAAA;IAE5C,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;IAE7C,wDAAwD;IACxD,kDAAkD;IAElD,sCAAsC;IACtC,MAAM,KAAK,GAAG,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI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vD,GAAwB,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAE7D,GAAwB,CAAC,IAAI,GAAG;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;YAClC,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC;SAC/C,CAAA;QACD,4BAA4B;QAC5B,8DAA8D;QAE9D,IAAI,EAAE,CAAC,CAAC,iCAAiC;IAE7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEb,IAAA,iBAAS,EACL,GAAG,EACH,cAAc,EACd,0BAA0B,EAC1B,EAAE,EACF,EAAE,EACF,mBAAW,CAAC,YAAY,CAC3B,CAAC;QAEF,OAAM;IACV,CAAC;AAEL,CAAC,CAAC;AA/EW,QAAA,qBAAqB,yBA+EhC","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport jwt, { JwtPayload } from \"jsonwebtoken\";\n\n// import { storeJwtInMemory } from \"@/utils\";\n\nimport { config } from \"@/configs/config\";\nimport { sendError, HTTP_STATUS } from \"@/utils\";\n\nimport { AuthType } from \"@/services\";\n\nconst excludedRoutes = [\n // '/api/tools/generatesignature',\n // '/api/tools/generatetoken',\n '/auth/token'\n]; // List of excluded routes\n\ninterface AuthJwtPayload extends JwtPayload {\n user?: { id: number, user_id: number, user_type: AuthType };\n account?: { id: number, account_id: number };\n}\n\nexport type AuthorizeRequest = Request & {\n accountId: number\n actionUserId: number,\n auth: {\n accountId: number,\n actionUserId: number,\n authToken: string,\n isOperator: boolean\n }\n}\n\nexport const validateAuthorization = (req: Request, res: Response, next: NextFunction): void => {\n\n if (excludedRoutes.includes(req.path)) {\n return next(); // Skip middleware for excluded routes\n }\n\n const authSecretKey = config.AUTH_SECRET_KEY\n\n const authHeader = req.headers.authorization;\n\n // console.log('in core - authSecretKey', authSecretKey)\n // console.log('in core - authHeader', authHeader)\n\n // Extract token from \"Bearer <token>\"\n const token = authHeader && authHeader.split(\" \")[1];\n\n try {\n\n if (!token) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid authorization token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n const jwtData = jwt.verify(token, authSecretKey) as AuthJwtPayload; // Verify JWT token\n\n // for old format\n let accountId = jwtData?.account?.id ?? 0\n let actionUserId = jwtData?.user?.id ?? 0\n let userType = jwtData?.user?.user_type ?? \"\"\n\n // for new format \n if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n // only check if not operator token\n if (userType === \"operator\") {\n accountId = 0; // always 0 for operator login\n } else {\n if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n (req as AuthorizeRequest).accountId = Number(accountId);\n (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n (req as AuthorizeRequest).auth = {\n accountId: Number(accountId),\n actionUserId: Number(actionUserId),\n authToken: token,\n isOperator: Boolean(userType === \"operator\")\n }\n // storeJwtInMemory(jwtData)\n // req.jwtUser = jwtData; // Attach decoded payload to request\n\n next(); // Proceed to the next middleware\n\n } catch (error) {\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n};"]}
1
+ {"version":3,"file":"validateAuthorization.js","sourceRoot":"","sources":["../../../src/middlewares/request/validateAuthorization.ts"],"names":[],"mappings":";;;;;;AAEA,gEAA+C;AAE/C,8CAA8C;AAE9C,6CAA0C;AAC1C,mCAAiD;AAIjD,MAAM,qBAAqB,GAAG;IAC1B,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AC;IAEL,CAAC,CAAA;AAEL,CAAC,CAAC;AAzFW,QAAA,qBAAqB,yBAyFhC","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport jwt, { JwtPayload } from \"jsonwebtoken\";\n\n// import { storeJwtInMemory } from \"@/utils\";\n\nimport { config } from \"@/configs/config\";\nimport { sendError, HTTP_STATUS } from \"@/utils\";\n\nimport { AuthType } from \"@/services\";\n\nconst defaultExcludedRoutes = [\n '/auth/token',\n // '/api/tools/generatesignature',\n // '/api/tools/generatetoken',\n // add more defaults if needed\n];\n\n// const excludedRoutes = [\n// '/auth/token'\n// ]; // List of excluded routes\n\ninterface ValidateAuthOptions {\n excludedRoutes?: string[];\n}\n\ninterface AuthJwtPayload extends JwtPayload {\n user?: { id: number, user_id: number, user_type: AuthType };\n account?: { id: number, account_id: number };\n}\n\nexport type AuthorizeRequest = Request & {\n accountId: number\n actionUserId: number,\n auth: {\n accountId: number,\n actionUserId: number,\n authToken: string,\n isOperator: boolean\n }\n}\n\nexport const validateAuthorization = (options: ValidateAuthOptions = {}) => {\n\n // Merge default excluded routes with any custom ones\n const excludedRoutes = [\n ...defaultExcludedRoutes,\n ...(options.excludedRoutes || [])\n ];\n\n return (req: Request, res: Response, next: NextFunction): void => {\n\n if (excludedRoutes.includes(req.path)) {\n return next(); // Skip middleware for excluded routes\n }\n\n const authSecretKey = config.AUTH_SECRET_KEY\n\n const authHeader = req.headers.authorization;\n\n // console.log('in core - authSecretKey', authSecretKey)\n // console.log('in core - authHeader', authHeader)\n\n // Extract token from \"Bearer <token>\"\n const token = authHeader && authHeader.split(\" \")[1];\n\n try {\n\n if (!token) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid authorization token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n const jwtData = jwt.verify(token, authSecretKey) as AuthJwtPayload; // Verify JWT token\n\n // for old format\n let accountId = jwtData?.account?.id ?? 0\n let actionUserId = jwtData?.user?.id ?? 0\n let userType = jwtData?.user?.user_type ?? \"\"\n\n // for new format \n if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n // only check if not operator token\n if (userType === \"operator\") {\n accountId = 0; // always 0 for operator login\n } else {\n if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n (req as AuthorizeRequest).accountId = Number(accountId);\n (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n (req as AuthorizeRequest).auth = {\n accountId: Number(accountId),\n actionUserId: Number(actionUserId),\n authToken: token,\n isOperator: Boolean(userType === \"operator\")\n }\n // storeJwtInMemory(jwtData)\n // req.jwtUser = jwtData; // Attach decoded payload to request\n\n next(); // Proceed to the next middleware\n\n } catch (error) {\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n }\n\n};"]}
@@ -15,7 +15,10 @@ const compressImageBuffer = async (buffer, mimeType, options = {}) => {
15
15
  if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {
16
16
  return { compressFormat: '', buffer, sizeBytes: buffer.byteLength };
17
17
  }
18
- let pipeline = (0, utils_1.sharp)(buffer);
18
+ // let pipeline = sharp(buffer);
19
+ let pipeline = (0, utils_1.sharp)(buffer)
20
+ .rotate(); // ✅ auto-orients based on EXIF
21
+ // .resize({ width: maxWidth }); // safe to chain directly
19
22
  if (maxWidth) {
20
23
  pipeline = pipeline.resize({ width: maxWidth });
21
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCompression.js","sourceRoot":"","sources":["../../../src/services/file/ImageCompression.ts"],"names":[],"mappings":";;;AAAA,mCA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AAC,OAAO,CAAC;QACvC,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,gBAAgB,CAAC,UAAU;KACzC,CAAC;AAEN,CAAC,CAAC;AAtDW,QAAA,mBAAmB,uBAsD9B","sourcesContent":["import { sharp } from \"@/utils\";\n\nexport type FileImageCompressionOptions = {\n maxWidth?: number;\n quality?: number;\n}\n\nexport const compressImageBuffer = async (\n buffer: Buffer,\n mimeType: string,\n options: FileImageCompressionOptions = {}\n): Promise<{\n compressFormat: string;\n buffer: Buffer;\n sizeBytes: number;\n}> => {\n\n const { maxWidth = 1024, quality = 80 } = options;\n\n const SUPPORTED_IMAGE_MIMES = [\n \"image/jpeg\",\n \"image/png\",\n \"image/webp\",\n \"image/tiff\",\n \"image/bmp\",\n ];\n\n // Skip unsupported images\n if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {\n return { compressFormat: '', buffer, sizeBytes: buffer.byteLength };\n }\n\n let pipeline = sharp(buffer);\n\n if (maxWidth) {\n pipeline = pipeline.resize({ width: maxWidth });\n }\n\n let compressedBuffer: Buffer;\n\n switch (mimeType) {\n case \"image/png\":\n compressedBuffer = await pipeline.png({ quality }).toBuffer();\n break;\n case \"image/webp\":\n compressedBuffer = await pipeline.webp({ quality }).toBuffer();\n break;\n case \"image/jpeg\":\n case \"image/tiff\":\n case \"image/bmp\":\n default:\n compressedBuffer = await pipeline.jpeg({ quality }).toBuffer();\n break;\n }\n\n return {\n compressFormat: JSON.stringify(options),\n buffer: compressedBuffer,\n sizeBytes: compressedBuffer.byteLength\n };\n\n};"]}
1
+ {"version":3,"file":"ImageCompression.js","sourceRoot":"","sources":["../../../src/services/file/ImageCompression.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAOzB,MAAM,mBAAmB,GAAG,KAAK,EACpC,MAAc,EACd,QAAgB,EAChB,UAAuC,EAAE,EAK1C,EAAE;IAED,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO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C;AAzDW,QAAA,mBAAmB,uBAyD9B","sourcesContent":["import { sharp } from \"@/utils\";\n\nexport type FileImageCompressionOptions = {\n maxWidth?: number;\n quality?: number;\n}\n\nexport const compressImageBuffer = async (\n buffer: Buffer,\n mimeType: string,\n options: FileImageCompressionOptions = {}\n): Promise<{\n compressFormat: string;\n buffer: Buffer;\n sizeBytes: number;\n}> => {\n\n const { maxWidth = 1024, quality = 80 } = options;\n\n const SUPPORTED_IMAGE_MIMES = [\n \"image/jpeg\",\n \"image/png\",\n \"image/webp\",\n \"image/tiff\",\n \"image/bmp\",\n ];\n\n // Skip unsupported images\n if (!SUPPORTED_IMAGE_MIMES.includes(mimeType)) {\n return { compressFormat: '', buffer, sizeBytes: buffer.byteLength };\n }\n\n // let pipeline = sharp(buffer);\n let pipeline = sharp(buffer)\n .rotate() // ✅ auto-orients based on EXIF\n // .resize({ width: maxWidth }); // safe to chain directly\n\n if (maxWidth) {\n pipeline = pipeline.resize({ width: maxWidth });\n }\n\n let compressedBuffer: Buffer;\n\n switch (mimeType) {\n case \"image/png\":\n compressedBuffer = await pipeline.png({ quality }).toBuffer();\n break;\n case \"image/webp\":\n compressedBuffer = await pipeline.webp({ quality }).toBuffer();\n break;\n case \"image/jpeg\":\n case \"image/tiff\":\n case \"image/bmp\":\n default:\n compressedBuffer = await pipeline.jpeg({ quality }).toBuffer();\n break;\n }\n\n return {\n compressFormat: JSON.stringify(options),\n buffer: compressedBuffer,\n sizeBytes: compressedBuffer.byteLength\n };\n\n};"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",
@@ -10,24 +10,24 @@ datasource db {
10
10
  }
11
11
 
12
12
  model accounts {
13
- account_id BigInt @id(map: "cl_accounts_pkey") @default(autoincrement())
14
- name String @db.VarChar(128)
15
- createdatetime DateTime? @db.Timestamp(6)
16
- createuserid BigInt @default(0)
17
- updatedatetime DateTime? @db.Timestamp(6)
18
- updateuserid BigInt @default(0)
19
- isdelete Boolean? @default(false)
20
- istrash Boolean? @default(false)
21
- accountid BigInt @default(0)
22
- business_id BigInt?
23
- status Boolean @default(false)
24
- owner_user_id BigInt @default(0)
25
- account_code String? @db.VarChar(128)
26
- areas areas[]
27
- branches branches[]
28
- businesses_businesses_accountidToaccounts businesses[] @relation("businesses_accountidToaccounts")
29
- countries countries[]
30
- states states[]
13
+ account_id BigInt @id(map: "cl_accounts_pkey") @default(autoincrement())
14
+ name String @db.VarChar(128)
15
+ createdatetime DateTime? @db.Timestamp(6)
16
+ createuserid BigInt @default(0)
17
+ updatedatetime DateTime? @db.Timestamp(6)
18
+ updateuserid BigInt @default(0)
19
+ isdelete Boolean? @default(false)
20
+ istrash Boolean? @default(false)
21
+ accountid BigInt @default(0)
22
+ business_id BigInt?
23
+ status Boolean @default(false)
24
+ owner_user_id BigInt @default(0)
25
+ account_code String? @db.VarChar(128)
26
+ areas areas[]
27
+ branches branches[]
28
+ businesses businesses[]
29
+ countries countries[]
30
+ states states[]
31
31
 
32
32
  @@schema("public")
33
33
  }
@@ -47,29 +47,29 @@ model administrators {
47
47
  }
48
48
 
49
49
  model businesses {
50
- business_id BigInt @id(map: "cl_businesses_pkey") @default(autoincrement())
51
- company_name String? @db.VarChar(256)
52
- registration_number String? @db.VarChar(256)
53
- website String? @db.VarChar(256)
54
- email String? @db.VarChar(256)
55
- company_contact String? @db.VarChar(256)
56
- address_1 String? @db.VarChar(256)
57
- address_2 String? @db.VarChar(256)
58
- state_id BigInt? @default(0)
59
- area_id BigInt? @default(0)
60
- country_id BigInt? @default(0)
61
- postcode String? @db.VarChar(64)
62
- createdatetime DateTime? @db.Timestamp(6)
63
- createuserid BigInt @default(0)
64
- updatedatetime DateTime? @db.Timestamp(6)
65
- updateuserid BigInt @default(0)
66
- isdelete Boolean? @default(false)
67
- istrash Boolean? @default(false)
68
- accountid BigInt @default(0)
69
- status Boolean @default(true)
70
- accounts_businesses_accountidToaccounts accounts @relation("businesses_accountidToaccounts", fields: [accountid], references: [account_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_accounts_fk")
71
- users_businesses_createuseridTousers users @relation("businesses_createuseridTousers", fields: [createuserid], references: [user_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_users_createuserid_fk")
72
- users_businesses_updateuseridTousers users @relation("businesses_updateuseridTousers", fields: [updateuserid], references: [user_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_users_updateuserid_fk")
50
+ business_id BigInt @id(map: "cl_businesses_pkey") @default(autoincrement())
51
+ company_name String? @db.VarChar(256)
52
+ registration_number String? @db.VarChar(256)
53
+ website String? @db.VarChar(256)
54
+ email String? @db.VarChar(256)
55
+ company_contact String? @db.VarChar(256)
56
+ address_1 String? @db.VarChar(256)
57
+ address_2 String? @db.VarChar(256)
58
+ state_id BigInt? @default(0)
59
+ area_id BigInt? @default(0)
60
+ country_id BigInt? @default(0)
61
+ postcode String? @db.VarChar(64)
62
+ createdatetime DateTime? @db.Timestamp(6)
63
+ createuserid BigInt @default(0)
64
+ updatedatetime DateTime? @db.Timestamp(6)
65
+ updateuserid BigInt @default(0)
66
+ isdelete Boolean? @default(false)
67
+ istrash Boolean? @default(false)
68
+ accountid BigInt @default(0)
69
+ status Boolean @default(true)
70
+ accounts accounts @relation(fields: [accountid], references: [account_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_accounts_fk")
71
+ users_businesses_createuseridTousers users @relation("businesses_createuseridTousers", fields: [createuserid], references: [user_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_users_createuserid_fk")
72
+ users_businesses_updateuseridTousers users @relation("businesses_updateuseridTousers", fields: [updateuserid], references: [user_id], onDelete: SetNull, onUpdate: NoAction, map: "businesses_users_updateuserid_fk")
73
73
 
74
74
  @@schema("public")
75
75
  }
@@ -454,49 +454,6 @@ model document_amounts {
454
454
  @@schema("public")
455
455
  }
456
456
 
457
- model document_amounts_unuse {
458
- document_amount_id BigInt @id(map: "cl_document_amount_pkey") @default(autoincrement())
459
- document_id BigInt @default(0)
460
- type String @db.VarChar(32)
461
- display_name String? @db.VarChar(32)
462
- description String? @db.VarChar(256)
463
- amount Decimal @default(0.0000) @db.Decimal(20, 4)
464
- ax_createdatetime DateTime? @db.Timestamp(6)
465
- ax_createuserid BigInt @default(0)
466
- ax_updatedatetime DateTime? @db.Timestamp(6)
467
- ax_updateuserid BigInt @default(0)
468
- ax_isdelete Boolean? @default(false)
469
- ax_istrash Boolean? @default(false)
470
- ax_accountid BigInt @default(0)
471
-
472
- @@index([document_amount_id], map: "idx_document_amounts_document_amount_id")
473
- @@index([document_id], map: "idx_document_amounts_document_id")
474
- @@index([type], map: "idx_document_amounts_type")
475
- @@schema("public")
476
- }
477
-
478
- model document_injection_field_items_unuse {
479
- document_injection_field_item_id BigInt @id(map: "cl_document_injection_field_items_pkey") @default(autoincrement())
480
- document_injection_field_id BigInt @default(autoincrement())
481
- field_name String? @db.VarChar(200)
482
- field_value String? @db.VarChar(256)
483
- field_id BigInt @default(0)
484
- field_text String?
485
- field_numeric Decimal @default(0.0000) @db.Decimal(20, 4)
486
- field_timestamp BigInt?
487
- field_date DateTime? @db.Date
488
- field_date_time DateTime? @db.Timestamp(6)
489
- ax_createdatetime DateTime? @db.Timestamp(6)
490
- ax_createuserid BigInt @default(0)
491
- ax_updatedatetime DateTime? @db.Timestamp(6)
492
- ax_updateuserid BigInt @default(0)
493
- ax_isdelete Boolean? @default(false)
494
- ax_istrash Boolean? @default(false)
495
- ax_accountid BigInt @default(0)
496
-
497
- @@schema("public")
498
- }
499
-
500
457
  model document_injection_fields {
501
458
  document_injection_field_id BigInt @id(map: "cl_document_injection_fields_pkey") @default(autoincrement())
502
459
  field_module String? @db.VarChar(200)
@@ -560,27 +517,27 @@ model document_injection_fields {
560
517
  @@index([document_id, doc_cs_is_adhoc], map: "idx_inj_fields_cash_sales_doc_cs_is_adhoc")
561
518
  @@index([document_item_id, doci_cs_existing_mp_quantity], map: "idx_inj_fields_cash_sales_doci_cs_existing_mp_quantity")
562
519
  @@index([document_item_id, doci_cs_is_bulk], map: "idx_inj_fields_cash_sales_doci_cs_is_bulk")
563
- @@index([document_id, doc_do_aaaa], map: "idx_inj_fields_delivery_doc_do_aaaa")
564
520
  @@index([document_id, doc_do_is_adhoc], map: "idx_inj_fields_delivery_doc_do_is_adhoc")
565
- @@index([document_id, doc_do_pack_item_qty], map: "idx_inj_fields_delivery_doc_do_pack_item_qty")
566
- @@index([document_id, doc_do_pack_qty2_bk_39], map: "idx_inj_fields_delivery_doc_do_pack_qty2")
567
- @@index([document_id, doc_do_remark_id], map: "idx_inj_fields_delivery_doc_do_remark_id")
568
- @@index([document_id, doc_do_remark_ids], map: "idx_inj_fields_delivery_doc_do_remark_ids")
569
521
  @@index([document_item_id, doci_do_existing_mp_quantity], map: "idx_inj_fields_delivery_doci_do_existing_mp_quantity")
570
522
  @@index([document_item_id, doci_do_is_bulk], map: "idx_inj_fields_delivery_doci_do_is_bulk")
571
- @@index([document_item_id, doci_do_pack_item_qty], map: "idx_inj_fields_delivery_doci_do_pack_item_qty")
572
523
  @@index([document_item_id, doci_ir_batch_no], map: "idx_inj_fields_item_receive_doci_ir_batch_no")
573
524
  @@index([document_item_id, doci_ir_expiry_date], map: "idx_inj_fields_item_receive_doci_ir_expiry_date")
574
525
  @@index([document_item_id, doci_ir_production_date], map: "idx_inj_fields_item_receive_doci_ir_production_date")
575
- @@index([document_id, doc_pr_is_adhoc], map: "idx_inj_fields_purchase_return_doc_pr_is_adhoc")
576
- @@index([document_item_id, doci_pr_existing_mp_quantity], map: "idx_inj_fields_purchase_return_doci_pr_existing_mp_quantity")
577
- @@index([document_item_id, doci_pr_is_bulk], map: "idx_inj_fields_purchase_return_doci_pr_is_bulk")
578
526
  @@index([document_id, doc_rdo_is_adhoc], map: "idx_inj_fields_replacement_delivery_doc_rdo_is_adhoc")
579
527
  @@index([document_item_id, doci_rdo_existing_mp_quantity], map: "idx_inj_fields_replacement_delivery_doci_rdo_existing_mp_quanti")
580
528
  @@index([document_item_id, doci_rdo_is_bulk], map: "idx_inj_fields_replacement_delivery_doci_rdo_is_bulk")
581
529
  @@index([document_id, doc_scn_is_adhoc], map: "idx_inj_fields_sales_credit_note_doc_scn_is_adhoc")
582
530
  @@index([document_item_id, doci_scn_existing_mp_quantity], map: "idx_inj_fields_sales_credit_note_doci_scn_existing_mp_quantity")
583
531
  @@index([document_item_id, doci_scn_is_bulk], map: "idx_inj_fields_sales_credit_note_doci_scn_is_bulk")
532
+ @@index([document_id, doc_do_aaaa], map: "idx_inj_fields_delivery_doc_do_aaaa")
533
+ @@index([document_id, doc_do_pack_item_qty], map: "idx_inj_fields_delivery_doc_do_pack_item_qty")
534
+ @@index([document_id, doc_do_pack_qty2_bk_39], map: "idx_inj_fields_delivery_doc_do_pack_qty2")
535
+ @@index([document_id, doc_do_remark_id], map: "idx_inj_fields_delivery_doc_do_remark_id")
536
+ @@index([document_id, doc_do_remark_ids], map: "idx_inj_fields_delivery_doc_do_remark_ids")
537
+ @@index([document_item_id, doci_do_pack_item_qty], map: "idx_inj_fields_delivery_doci_do_pack_item_qty")
538
+ @@index([document_id, doc_pr_is_adhoc], map: "idx_inj_fields_purchase_return_doc_pr_is_adhoc")
539
+ @@index([document_item_id, doci_pr_existing_mp_quantity], map: "idx_inj_fields_purchase_return_doci_pr_existing_mp_quantity")
540
+ @@index([document_item_id, doci_pr_is_bulk], map: "idx_inj_fields_purchase_return_doci_pr_is_bulk")
584
541
  @@index([document_id, doc_sdn_is_adhoc], map: "idx_inj_fields_sales_debit_note_doc_sdn_is_adhoc")
585
542
  @@index([document_item_id, doci_sdn_existing_mp_quantity], map: "idx_inj_fields_sales_debit_note_doci_sdn_existing_mp_quantity")
586
543
  @@index([document_item_id, doci_sdn_is_bulk], map: "idx_inj_fields_sales_debit_note_doci_sdn_is_bulk")
@@ -590,38 +547,6 @@ model document_injection_fields {
590
547
  @@schema("public")
591
548
  }
592
549
 
593
- model document_injection_props_unuse {
594
- document_injection_props_id BigInt @id(map: "cl_document_injection_props_pkey") @default(autoincrement())
595
- props_module String? @db.VarChar(200)
596
- props_ref String? @db.VarChar(200)
597
- is_multiple Int? @default(0) @db.SmallInt
598
- document_id BigInt @default(0)
599
- document_item_id BigInt @default(0)
600
- document_doc_id BigInt @default(0)
601
- type String? @db.VarChar(200)
602
- props_field String? @db.VarChar(200)
603
- props_value String? @db.VarChar(256)
604
- props_id BigInt? @default(0)
605
- props_text String?
606
- props_numeric Decimal? @default(0.0000) @db.Decimal(20, 4)
607
- ax_createdatetime DateTime? @db.Timestamp(6)
608
- ax_createuserid BigInt @default(0)
609
- ax_updatedatetime DateTime? @db.Timestamp(6)
610
- ax_updateuserid BigInt @default(0)
611
- ax_isdelete Boolean? @default(false)
612
- ax_istrash Boolean? @default(false)
613
- ax_accountid BigInt @default(0)
614
- props_date DateTime? @db.Date
615
- props_date_time DateTime? @db.Timestamp(6)
616
- props_timestamp BigInt?
617
- props_integer BigInt?
618
- has_multiple_inline Int? @default(0) @db.SmallInt
619
-
620
- @@index([document_id, props_module, props_ref, document_item_id, type, ax_isdelete], map: "idx_document_injection_props_doc_id_type_ref_module")
621
- @@index([type], map: "idx_document_injection_props_type")
622
- @@schema("public")
623
- }
624
-
625
550
  model document_items {
626
551
  document_item_id BigInt @id(map: "cl_document_items_pkey") @default(autoincrement())
627
552
  document_id BigInt @default(0)
@@ -648,22 +573,6 @@ model document_items {
648
573
  @@schema("public")
649
574
  }
650
575
 
651
- model document_locations {
652
- document_location_id BigInt @id @default(autoincrement())
653
- createdatetime DateTime? @db.Timestamptz(6)
654
- createuserid BigInt @default(0)
655
- updatedatetime DateTime? @db.Timestamptz(6)
656
- updateuserid BigInt @default(0)
657
- isdelete Boolean? @default(false)
658
- istrash Boolean? @default(false)
659
- accountid BigInt @default(0)
660
- document_id BigInt @default(0)
661
- type String @db.VarChar(32)
662
- location_id BigInt @default(0)
663
-
664
- @@schema("public")
665
- }
666
-
667
576
  model document_payments {
668
577
  document_payment_id BigInt @id(map: "cl_document_payments_pkey") @default(autoincrement())
669
578
  payment_type String? @db.VarChar(128)
@@ -721,27 +630,6 @@ model document_profiles {
721
630
  @@schema("public")
722
631
  }
723
632
 
724
- model document_totals {
725
- document_total_id BigInt @id(map: "cl_document_adjustments_pkey") @default(autoincrement())
726
- total_type String? @db.VarChar(128)
727
- operation String? @db.VarChar(128)
728
- document_id BigInt @default(0)
729
- refer_id BigInt? @default(0)
730
- description String?
731
- total_amount Decimal? @default(0.00) @db.Decimal(10, 2)
732
- total_percentage Decimal? @default(0.00) @db.Decimal(10, 2)
733
- createdatetime DateTime? @db.Timestamp(6)
734
- createuserid BigInt @default(0)
735
- updatedatetime DateTime? @db.Timestamp(6)
736
- updateuserid BigInt @default(0)
737
- isdelete Boolean? @default(false)
738
- istrash Boolean? @default(false)
739
- accountid BigInt @default(0)
740
- type String? @db.VarChar
741
-
742
- @@schema("public")
743
- }
744
-
745
633
  model documents {
746
634
  document_id BigInt @id(map: "cl_documents_pkey") @default(autoincrement())
747
635
  doc_number String? @db.VarChar(32)
@@ -890,6 +778,11 @@ model item_injection_fields {
890
778
  removed_itm_ct_samplefield String?
891
779
  itm_ct_enable String?
892
780
 
781
+ @@index([brand_id], map: "idx_item_injection_fields_brand_id")
782
+ @@index([category_id], map: "idx_item_injection_fields_category_id")
783
+ @@index([item_id], map: "idx_item_injection_fields_item_id")
784
+ @@index([product_id], map: "idx_item_injection_fields_product_id")
785
+ @@index([uom_id], map: "idx_item_injection_fields_uom_id")
893
786
  @@index([item_id, itm_itm_customer_marking], map: "idx_inj_fields_item_itm_itm_customer_marking")
894
787
  @@index([item_id, itm_itm_inttest08], map: "idx_inj_fields_item_itm_itm_inttest08")
895
788
  @@index([item_id, itm_itm_inttest12345], map: "idx_inj_fields_item_itm_itm_inttest12345")
@@ -905,11 +798,6 @@ model item_injection_fields {
905
798
  @@index([product_id, itm_prt_pack_qty2], map: "idx_inj_fields_product_itm_prt_pack_qty2")
906
799
  @@index([product_id, itm_prt_rtdsfsdf_bk_37], map: "idx_inj_fields_product_itm_prt_rtdsfsdf")
907
800
  @@index([product_id, yes_bk_38], map: "idx_inj_fields_product_itm_prt_yes")
908
- @@index([brand_id], map: "idx_item_injection_fields_brand_id")
909
- @@index([category_id], map: "idx_item_injection_fields_category_id")
910
- @@index([item_id], map: "idx_item_injection_fields_item_id")
911
- @@index([product_id], map: "idx_item_injection_fields_product_id")
912
- @@index([uom_id], map: "idx_item_injection_fields_uom_id")
913
801
  @@schema("public")
914
802
  }
915
803
 
@@ -984,8 +872,8 @@ model logistic_injection_fields {
984
872
  accountid BigInt @default(0)
985
873
  lgt_tpt_repo_t3e2s2 Decimal? @default(0) @db.Decimal(20, 4)
986
874
 
987
- @@index([logistic_id, lgt_tpt_repo_t3e2s2], map: "idx_inj_fields_transporter_lgt_tpt_repo_t3e2s2")
988
875
  @@index([logistic_id], map: "idx_logistic_injection_fields_logistic_id")
876
+ @@index([logistic_id, lgt_tpt_repo_t3e2s2], map: "idx_inj_fields_transporter_lgt_tpt_repo_t3e2s2")
989
877
  @@schema("public")
990
878
  }
991
879
 
@@ -1033,13 +921,13 @@ model repository_injection_fields {
1033
921
  repo_itme_pk_pk_cont_item Decimal? @default(0) @db.Decimal(20, 4)
1034
922
  repo_itme_cont_pk_cont_item Decimal? @default(0) @db.Decimal(20, 4)
1035
923
 
924
+ @@index([repository_id], map: "idx_repository_injection_fields_repository_id")
925
+ @@index([repository_item_id], map: "idx_repository_injection_fields_repository_item_id")
1036
926
  @@index([repository_id, cont_repo_tes], map: "idx_inj_fields_container__cont_repo_tes")
1037
927
  @@index([repository_id, repo_cont_repo_t3es], map: "idx_inj_fields_container_repo_cont_repo_t3es")
1038
928
  @@index([repository_item_id, repo_itme_cont_pk_cont_item], map: "idx_inj_fields_container_repo_itme_cont_pk_cont_item")
1039
929
  @@index([repository_item_id, repo_itme_pk_pk_cont_item], map: "idx_inj_fields_package_repo_itme_pk_pk_cont_item")
1040
930
  @@index([repository_id, repo_pk_pk_cont], map: "idx_inj_fields_package_repo_pk_pk_cont")
1041
- @@index([repository_id], map: "idx_repository_injection_fields_repository_id")
1042
- @@index([repository_item_id], map: "idx_repository_injection_fields_repository_item_id")
1043
931
  @@schema("public")
1044
932
  }
1045
933
 
@@ -1115,6 +1003,9 @@ model user_injection_fields {
1115
1003
  usr_ret_enable String?
1116
1004
  usr_admin_is_oku Int?
1117
1005
 
1006
+ @@index([branch_id], map: "idx_user_injection_fields_branch_id")
1007
+ @@index([member_id], map: "idx_user_injection_fields_member_id")
1008
+ @@index([user_id], map: "idx_user_injection_fields_user_id")
1118
1009
  @@index([branch_id, br_cust_branch3_qty], map: "idx_inj_fields_customer_br_cust_branch3_qty")
1119
1010
  @@index([branch_id, br_cust_branch_qty], map: "idx_inj_fields_customer_br_cust_branch_qty")
1120
1011
  @@index([branch_id, br_cust_customer_branch_marking], map: "idx_inj_fields_customer_br_cust_customer_branch_marking")
@@ -1127,9 +1018,6 @@ model user_injection_fields {
1127
1018
  @@index([user_id, usr_cust_source_client_remid], map: "idx_inj_fields_customer_usr_cust_source_client_remid")
1128
1019
  @@index([user_id, usr_cust_source_profile_type], map: "idx_inj_fields_customer_usr_cust_source_profile_type")
1129
1020
  @@index([user_id, usr_mb_member_test], map: "idx_inj_fields_member_usr_mb_member_test")
1130
- @@index([branch_id], map: "idx_user_injection_fields_branch_id")
1131
- @@index([member_id], map: "idx_user_injection_fields_member_id")
1132
- @@index([user_id], map: "idx_user_injection_fields_user_id")
1133
1021
  @@schema("public")
1134
1022
  }
1135
1023
 
@@ -1148,50 +1036,20 @@ model workers {
1148
1036
  @@schema("public")
1149
1037
  }
1150
1038
 
1151
- /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
1152
- model document_documents {
1153
- document_document_id BigInt @id(map: "cl_document_docs_pkey") @default(autoincrement())
1154
- main_document_id BigInt @default(0)
1155
- document_id BigInt @default(0)
1156
- document_number String? @db.VarChar(32)
1157
- document_date DateTime? @db.Date
1158
- document_type String? @db.VarChar(32)
1159
- document_remark String? @db.VarChar(256)
1160
- createdatetime DateTime? @db.Timestamp(6)
1161
- createuserid BigInt @default(0)
1162
- updatedatetime DateTime? @db.Timestamp(6)
1163
- updateuserid BigInt @default(0)
1164
- isdelete Boolean? @default(false)
1165
- istrash Boolean? @default(false)
1166
- accountid BigInt @default(0)
1167
- reference1_id BigInt? @default(0)
1168
- reference1_label String? @db.VarChar(256)
1169
- reference2_id BigInt? @default(0)
1170
- reference2_label String? @db.VarChar(256)
1171
- location_id BigInt @default(0)
1172
- main_document_type String? @db.VarChar(128)
1173
-
1174
- @@index([document_document_id, document_type], map: "cl_document_docs_document_id_doc_type_index")
1175
- @@index([document_id], map: "ids_document_docs_doc_id")
1176
- @@index([main_document_id, document_id, isdelete], map: "ids_document_docs_document_id_doc_id_isdelete")
1177
- @@schema("public")
1178
- }
1179
-
1180
- model number_date_sequences {
1181
- number_date_sequence_id BigInt @id @default(autoincrement())
1182
- createdatetime DateTime? @db.Timestamptz(6)
1183
- createuserid BigInt @default(0)
1184
- updatedatetime DateTime? @db.Timestamptz(6)
1185
- updateuserid BigInt @default(0)
1186
- isdelete Boolean? @default(false)
1187
- istrash Boolean? @default(false)
1188
- accountid BigInt @default(0)
1189
- field_ref String? @db.VarChar(128)
1190
- field_module String? @db.VarChar(128)
1191
- year_label String? @db.VarChar(10)
1192
- month_label String? @db.VarChar(255)
1193
- day_label String? @db.VarChar(255)
1194
- increment_no Int? @default(0)
1039
+ model document_props {
1040
+ document_prop_id BigInt @id(map: "document_status_pkey") @default(autoincrement())
1041
+ createdatetime DateTime? @db.Timestamptz(6)
1042
+ createuserid BigInt @default(0)
1043
+ updatedatetime DateTime? @db.Timestamptz(6)
1044
+ updateuserid BigInt @default(0)
1045
+ isdelete Boolean? @default(false)
1046
+ istrash Boolean? @default(false)
1047
+ accountid BigInt @default(0)
1048
+ document_id BigInt @default(0)
1049
+ document_item_id BigInt @default(0)
1050
+ document_doc_id BigInt @default(0)
1051
+ type String @db.VarChar(32)
1052
+ document_status Int @default(0) @db.SmallInt
1195
1053
 
1196
1054
  @@schema("public")
1197
1055
  }
@@ -2661,6 +2519,27 @@ model custom_brands {
2661
2519
  @@schema("public")
2662
2520
  }
2663
2521
 
2522
+ model document_amounts_unuse {
2523
+ document_amount_id BigInt @id(map: "cl_document_amount_pkey") @default(autoincrement())
2524
+ document_id BigInt @default(0)
2525
+ type String @db.VarChar(32)
2526
+ display_name String? @db.VarChar(32)
2527
+ description String? @db.VarChar(256)
2528
+ amount Decimal @default(0.0000) @db.Decimal(20, 4)
2529
+ ax_createdatetime DateTime? @db.Timestamp(6)
2530
+ ax_createuserid BigInt @default(0)
2531
+ ax_updatedatetime DateTime? @db.Timestamp(6)
2532
+ ax_updateuserid BigInt @default(0)
2533
+ ax_isdelete Boolean? @default(false)
2534
+ ax_istrash Boolean? @default(false)
2535
+ ax_accountid BigInt @default(0)
2536
+
2537
+ @@index([document_amount_id], map: "idx_document_amounts_document_amount_id")
2538
+ @@index([document_id], map: "idx_document_amounts_document_id")
2539
+ @@index([type], map: "idx_document_amounts_type")
2540
+ @@schema("public")
2541
+ }
2542
+
2664
2543
  model document_dependencies_unuse {
2665
2544
  document_dependency_id BigInt @id(map: "cl_document_dependancies_pkey") @default(autoincrement())
2666
2545
  document_id BigInt @default(0)
@@ -2682,6 +2561,105 @@ model document_dependencies_unuse {
2682
2561
  @@schema("public")
2683
2562
  }
2684
2563
 
2564
+ /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
2565
+ model document_documents {
2566
+ document_document_id BigInt @id(map: "cl_document_docs_pkey") @default(autoincrement())
2567
+ main_document_id BigInt @default(0)
2568
+ document_id BigInt @default(0)
2569
+ document_number String? @db.VarChar(32)
2570
+ document_date DateTime? @db.Date
2571
+ document_type String? @db.VarChar(32)
2572
+ document_remark String? @db.VarChar(256)
2573
+ createdatetime DateTime? @db.Timestamp(6)
2574
+ createuserid BigInt @default(0)
2575
+ updatedatetime DateTime? @db.Timestamp(6)
2576
+ updateuserid BigInt @default(0)
2577
+ isdelete Boolean? @default(false)
2578
+ istrash Boolean? @default(false)
2579
+ accountid BigInt @default(0)
2580
+ reference1_id BigInt? @default(0)
2581
+ reference1_label String? @db.VarChar(256)
2582
+ reference2_id BigInt? @default(0)
2583
+ reference2_label String? @db.VarChar(256)
2584
+ location_id BigInt @default(0)
2585
+ main_document_type String? @db.VarChar(128)
2586
+
2587
+ @@index([document_document_id, document_type], map: "cl_document_docs_document_id_doc_type_index")
2588
+ @@index([document_id], map: "ids_document_docs_doc_id")
2589
+ @@index([main_document_id, document_id, isdelete], map: "ids_document_docs_document_id_doc_id_isdelete")
2590
+ @@schema("public")
2591
+ }
2592
+
2593
+ model document_injection_field_items_unuse {
2594
+ document_injection_field_item_id BigInt @id(map: "cl_document_injection_field_items_pkey") @default(autoincrement())
2595
+ document_injection_field_id BigInt @default(autoincrement())
2596
+ field_name String? @db.VarChar(200)
2597
+ field_value String? @db.VarChar(256)
2598
+ field_id BigInt @default(0)
2599
+ field_text String?
2600
+ field_numeric Decimal @default(0.0000) @db.Decimal(20, 4)
2601
+ field_timestamp BigInt?
2602
+ field_date DateTime? @db.Date
2603
+ field_date_time DateTime? @db.Timestamp(6)
2604
+ ax_createdatetime DateTime? @db.Timestamp(6)
2605
+ ax_createuserid BigInt @default(0)
2606
+ ax_updatedatetime DateTime? @db.Timestamp(6)
2607
+ ax_updateuserid BigInt @default(0)
2608
+ ax_isdelete Boolean? @default(false)
2609
+ ax_istrash Boolean? @default(false)
2610
+ ax_accountid BigInt @default(0)
2611
+
2612
+ @@schema("public")
2613
+ }
2614
+
2615
+ model document_injection_props_unuse {
2616
+ document_injection_props_id BigInt @id(map: "cl_document_injection_props_pkey") @default(autoincrement())
2617
+ props_module String? @db.VarChar(200)
2618
+ props_ref String? @db.VarChar(200)
2619
+ is_multiple Int? @default(0) @db.SmallInt
2620
+ document_id BigInt @default(0)
2621
+ document_item_id BigInt @default(0)
2622
+ document_doc_id BigInt @default(0)
2623
+ type String? @db.VarChar(200)
2624
+ props_field String? @db.VarChar(200)
2625
+ props_value String? @db.VarChar(256)
2626
+ props_id BigInt? @default(0)
2627
+ props_text String?
2628
+ props_numeric Decimal? @default(0.0000) @db.Decimal(20, 4)
2629
+ ax_createdatetime DateTime? @db.Timestamp(6)
2630
+ ax_createuserid BigInt @default(0)
2631
+ ax_updatedatetime DateTime? @db.Timestamp(6)
2632
+ ax_updateuserid BigInt @default(0)
2633
+ ax_isdelete Boolean? @default(false)
2634
+ ax_istrash Boolean? @default(false)
2635
+ ax_accountid BigInt @default(0)
2636
+ props_date DateTime? @db.Date
2637
+ props_date_time DateTime? @db.Timestamp(6)
2638
+ props_timestamp BigInt?
2639
+ props_integer BigInt?
2640
+ has_multiple_inline Int? @default(0) @db.SmallInt
2641
+
2642
+ @@index([document_id, props_module, props_ref, document_item_id, type, ax_isdelete], map: "idx_document_injection_props_doc_id_type_ref_module")
2643
+ @@index([type], map: "idx_document_injection_props_type")
2644
+ @@schema("public")
2645
+ }
2646
+
2647
+ model document_locations {
2648
+ document_location_id BigInt @id @default(autoincrement())
2649
+ createdatetime DateTime? @db.Timestamptz(6)
2650
+ createuserid BigInt @default(0)
2651
+ updatedatetime DateTime? @db.Timestamptz(6)
2652
+ updateuserid BigInt @default(0)
2653
+ isdelete Boolean? @default(false)
2654
+ istrash Boolean? @default(false)
2655
+ accountid BigInt @default(0)
2656
+ document_id BigInt @default(0)
2657
+ type String @db.VarChar(32)
2658
+ location_id BigInt @default(0)
2659
+
2660
+ @@schema("public")
2661
+ }
2662
+
2685
2663
  model document_numbers_unuse {
2686
2664
  document_number_id BigInt @id(map: "cl_doc_numbers_pkey") @default(autoincrement())
2687
2665
  year_lbl String? @db.VarChar(10)
@@ -2699,24 +2677,6 @@ model document_numbers_unuse {
2699
2677
  @@schema("public")
2700
2678
  }
2701
2679
 
2702
- model document_props {
2703
- document_prop_id BigInt @id(map: "document_status_pkey") @default(autoincrement())
2704
- createdatetime DateTime? @db.Timestamptz(6)
2705
- createuserid BigInt @default(0)
2706
- updatedatetime DateTime? @db.Timestamptz(6)
2707
- updateuserid BigInt @default(0)
2708
- isdelete Boolean? @default(false)
2709
- istrash Boolean? @default(false)
2710
- accountid BigInt @default(0)
2711
- document_id BigInt @default(0)
2712
- document_item_id BigInt @default(0)
2713
- document_doc_id BigInt @default(0)
2714
- type String @db.VarChar(32)
2715
- document_status Int @default(0) @db.SmallInt
2716
-
2717
- @@schema("public")
2718
- }
2719
-
2720
2680
  model document_props_unuse {
2721
2681
  document_props_id BigInt @id(map: "cl_document_props_pkey") @default(autoincrement())
2722
2682
  document_id BigInt @default(0)
@@ -2761,6 +2721,46 @@ model document_status_unuse {
2761
2721
  @@schema("public")
2762
2722
  }
2763
2723
 
2724
+ model document_totals {
2725
+ document_total_id BigInt @id(map: "cl_document_adjustments_pkey") @default(autoincrement())
2726
+ total_type String? @db.VarChar(128)
2727
+ operation String? @db.VarChar(128)
2728
+ document_id BigInt @default(0)
2729
+ refer_id BigInt? @default(0)
2730
+ description String?
2731
+ total_amount Decimal? @default(0.00) @db.Decimal(10, 2)
2732
+ total_percentage Decimal? @default(0.00) @db.Decimal(10, 2)
2733
+ createdatetime DateTime? @db.Timestamp(6)
2734
+ createuserid BigInt @default(0)
2735
+ updatedatetime DateTime? @db.Timestamp(6)
2736
+ updateuserid BigInt @default(0)
2737
+ isdelete Boolean? @default(false)
2738
+ istrash Boolean? @default(false)
2739
+ accountid BigInt @default(0)
2740
+ type String? @db.VarChar
2741
+
2742
+ @@schema("public")
2743
+ }
2744
+
2745
+ model number_date_sequences {
2746
+ number_date_sequence_id BigInt @id @default(autoincrement())
2747
+ createdatetime DateTime? @db.Timestamptz(6)
2748
+ createuserid BigInt @default(0)
2749
+ updatedatetime DateTime? @db.Timestamptz(6)
2750
+ updateuserid BigInt @default(0)
2751
+ isdelete Boolean? @default(false)
2752
+ istrash Boolean? @default(false)
2753
+ accountid BigInt @default(0)
2754
+ field_ref String? @db.VarChar(128)
2755
+ field_module String? @db.VarChar(128)
2756
+ year_label String? @db.VarChar(10)
2757
+ month_label String? @db.VarChar(255)
2758
+ day_label String? @db.VarChar(255)
2759
+ increment_no Int? @default(0)
2760
+
2761
+ @@schema("public")
2762
+ }
2763
+
2764
2764
  model operators {
2765
2765
  operator_id BigInt @id @default(autoincrement())
2766
2766
  createdatetime DateTime? @db.Timestamptz(6)