@digione/node-custom-api 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/header.d.ts +10 -0
- package/constants/header.js +2 -0
- package/constants/http.d.ts +44 -0
- package/constants/http.js +2 -0
- package/database/index.d.ts +3 -0
- package/database/index.js +34 -0
- package/database/redis.d.ts +15 -0
- package/database/redis.js +68 -0
- package/errors/authError.d.ts +55 -0
- package/errors/authError.js +57 -0
- package/errors/index.d.ts +32 -0
- package/errors/index.js +113 -0
- package/index.d.ts +1 -0
- package/index.js +4 -0
- package/interface/param.d.ts +41 -0
- package/interface/param.js +2 -0
- package/middlewares/accessToken.d.ts +13 -0
- package/middlewares/accessToken.js +200 -0
- package/middlewares/coreSite.d.ts +4 -0
- package/middlewares/coreSite.js +52 -0
- package/middlewares/paramQuery.d.ts +16 -0
- package/middlewares/paramQuery.js +220 -0
- package/middlewares/refSite.d.ts +2 -0
- package/middlewares/refSite.js +58 -0
- package/middlewares/refreshToken.d.ts +2 -0
- package/middlewares/refreshToken.js +56 -0
- package/middlewares/systemSite.d.ts +6 -0
- package/middlewares/systemSite.js +106 -0
- package/middlewares/webSite.d.ts +7 -0
- package/middlewares/webSite.js +109 -0
- package/models/core/city.d.ts +66 -0
- package/models/core/city.js +79 -0
- package/models/core/country.d.ts +35 -0
- package/models/core/country.js +44 -0
- package/models/core/district.d.ts +17 -0
- package/models/core/district.js +23 -0
- package/models/core/domain.d.ts +57 -0
- package/models/core/domain.js +75 -0
- package/models/core/site.d.ts +60 -0
- package/models/core/site.js +70 -0
- package/models/core/state.d.ts +49 -0
- package/models/core/state.js +58 -0
- package/models/core/zipcode.d.ts +5 -0
- package/models/core/zipcode.js +28 -0
- package/models/stream/field.d.ts +60 -0
- package/models/stream/field.js +66 -0
- package/models/stream/field_section.d.ts +33 -0
- package/models/stream/field_section.js +39 -0
- package/models/stream/stream.d.ts +89 -0
- package/models/stream/stream.js +97 -0
- package/models/system/currency.d.ts +5 -0
- package/models/system/currency.js +32 -0
- package/models/system/email_log.d.ts +5 -0
- package/models/system/email_log.js +54 -0
- package/models/system/email_sender.d.ts +22 -0
- package/models/system/email_sender.js +53 -0
- package/models/system/email_template.d.ts +5 -0
- package/models/system/email_template.js +49 -0
- package/models/system/file.d.ts +98 -0
- package/models/system/file.js +111 -0
- package/models/system/folder.d.ts +59 -0
- package/models/system/folder.js +78 -0
- package/models/system/language.d.ts +44 -0
- package/models/system/language.js +50 -0
- package/models/system/metadata.d.ts +5 -0
- package/models/system/metadata.js +24 -0
- package/models/system/module.d.ts +5 -0
- package/models/system/module.js +35 -0
- package/models/system/notification_log.d.ts +25 -0
- package/models/system/notification_log.js +76 -0
- package/models/system/notification_module.d.ts +5 -0
- package/models/system/notification_module.js +35 -0
- package/models/system/notification_setting.d.ts +22 -0
- package/models/system/notification_setting.js +44 -0
- package/models/system/notification_template.d.ts +5 -0
- package/models/system/notification_template.js +49 -0
- package/models/system/notification_type.d.ts +5 -0
- package/models/system/notification_type.js +38 -0
- package/models/system/payment_transaction.d.ts +5 -0
- package/models/system/payment_transaction.js +46 -0
- package/models/system/pdf_page.d.ts +5 -0
- package/models/system/pdf_page.js +39 -0
- package/models/system/pdf_template.d.ts +22 -0
- package/models/system/pdf_template.js +67 -0
- package/models/system/review_template.d.ts +5 -0
- package/models/system/review_template.js +35 -0
- package/models/system/review_vote.d.ts +5 -0
- package/models/system/review_vote.js +36 -0
- package/models/system/session.d.ts +5 -0
- package/models/system/session.js +19 -0
- package/models/system/setting.d.ts +15 -0
- package/models/system/setting.js +22 -0
- package/models/system/site_token.d.ts +25 -0
- package/models/system/site_token.js +31 -0
- package/models/system/sms_log.d.ts +4 -0
- package/models/system/sms_log.js +52 -0
- package/models/system/sms_setting.d.ts +4 -0
- package/models/system/sms_setting.js +39 -0
- package/models/system/sms_template.d.ts +5 -0
- package/models/system/sms_template.js +48 -0
- package/models/system/tax.d.ts +5 -0
- package/models/system/tax.js +33 -0
- package/models/system/website.d.ts +56 -0
- package/models/system/website.js +66 -0
- package/models/system/zone.d.ts +57 -0
- package/models/system/zone.js +141 -0
- package/models/user/access_token.d.ts +37 -0
- package/models/user/access_token.js +46 -0
- package/models/user/address.d.ts +69 -0
- package/models/user/address.js +119 -0
- package/models/user/b2b_group.d.ts +57 -0
- package/models/user/b2b_group.js +63 -0
- package/models/user/group.d.ts +28 -0
- package/models/user/group.js +34 -0
- package/models/user/group_permission.d.ts +4 -0
- package/models/user/group_permission.js +27 -0
- package/models/user/notification_token.d.ts +32 -0
- package/models/user/notification_token.js +39 -0
- package/models/user/organ.d.ts +85 -0
- package/models/user/organ.js +100 -0
- package/models/user/profile.d.ts +31 -0
- package/models/user/profile.js +37 -0
- package/models/user/refresh_token.d.ts +41 -0
- package/models/user/refresh_token.js +51 -0
- package/models/user/team.d.ts +59 -0
- package/models/user/team.js +71 -0
- package/models/user/user.d.ts +79 -0
- package/models/user/user.js +100 -0
- package/models/user/user_organ.d.ts +52 -0
- package/models/user/user_organ.js +87 -0
- package/package.json +59 -0
- package/utils/auth.d.ts +25 -0
- package/utils/auth.js +137 -0
- package/utils/config.d.ts +8 -0
- package/utils/config.js +6 -0
- package/utils/core.d.ts +6 -0
- package/utils/core.js +39 -0
- package/utils/currency.d.ts +16 -0
- package/utils/currency.js +38 -0
- package/utils/db.d.ts +94 -0
- package/utils/db.js +399 -0
- package/utils/file.d.ts +232 -0
- package/utils/file.js +772 -0
- package/utils/helper.d.ts +113 -0
- package/utils/helper.js +508 -0
- package/utils/index.d.ts +10 -0
- package/utils/index.js +13 -0
- package/utils/language.d.ts +18 -0
- package/utils/language.js +48 -0
- package/utils/metadata.d.ts +18 -0
- package/utils/metadata.js +50 -0
- package/utils/session.d.ts +37 -0
- package/utils/session.js +60 -0
- package/utils/setting.d.ts +14 -0
- package/utils/setting.js +70 -0
- package/utils/stream.d.ts +303 -0
- package/utils/stream.js +1893 -0
- package/utils/user.d.ts +61 -0
- package/utils/user.js +282 -0
- package/utils/validator.d.ts +56 -0
- package/utils/validator.js +269 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifySubOrgan = exports.verifyAccess = exports.verifyVendor = exports.organByWeb = exports.site = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const website_1 = require("../models/system/website");
|
|
7
|
+
const organ_1 = require("../models/user/organ");
|
|
8
|
+
const accessToken_1 = require("./accessToken");
|
|
9
|
+
const authError_1 = require("../errors/authError");
|
|
10
|
+
const site = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
let ref = res.locals.ref;
|
|
12
|
+
let web = req.params.web || req.params.web_system;
|
|
13
|
+
if (web && !req.params.web_system_token) {
|
|
14
|
+
let exist = yield website_1.SystemWebSiteModel.schema(ref, "_").count({ where: { id: web, module: "core" } });
|
|
15
|
+
if (!exist) {
|
|
16
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
17
|
+
return res.status(err.code).send(err);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (web)
|
|
21
|
+
res.locals.web_id = web;
|
|
22
|
+
return next();
|
|
23
|
+
});
|
|
24
|
+
exports.site = site;
|
|
25
|
+
const organByWeb = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
let ref = res.locals.ref;
|
|
27
|
+
let web = req.params.web || req.params.web_system;
|
|
28
|
+
if (web && req.params.web_system_token) {
|
|
29
|
+
let query = yield website_1.SystemWebSiteModel.schema(ref, "_").findOne({ where: { id: web, module: "core" }, attributes: ['organ_id'], raw: true });
|
|
30
|
+
if (query && query['organ_id']) {
|
|
31
|
+
res.locals.web_id = web;
|
|
32
|
+
res.locals.organ_id = query['organ_id'];
|
|
33
|
+
res.locals.verify_organ = 1;
|
|
34
|
+
return next();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
38
|
+
return res.status(err.code).send(err);
|
|
39
|
+
});
|
|
40
|
+
exports.organByWeb = organByWeb;
|
|
41
|
+
const verifyVendor = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
return (0, accessToken_1.verifyAccessToken)(req, res, () => {
|
|
43
|
+
let organ_id = res.locals.organ_id;
|
|
44
|
+
let auth_id = res.locals.auth_id;
|
|
45
|
+
return (0, exports.organByWeb)(req, res, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
let parent_id = res.locals.organ_id;
|
|
47
|
+
if (organ_id == parent_id)
|
|
48
|
+
return next();
|
|
49
|
+
let exist = yield organ_1.UserOrganModel.schema(res.locals.ref, "_").count({
|
|
50
|
+
where: { id: organ_id, parent_id }
|
|
51
|
+
});
|
|
52
|
+
if (exist) {
|
|
53
|
+
res.locals.parent_organ_id = res.locals.organ_id;
|
|
54
|
+
res.locals.organ_id = organ_id;
|
|
55
|
+
res.locals.auth_id = auth_id;
|
|
56
|
+
return next();
|
|
57
|
+
}
|
|
58
|
+
let err = new errors_1.CustomError(authError_1.authError.ACCESS_DENINED);
|
|
59
|
+
return res.status(403 /* HTTP.FORBIDDEN */).send(err);
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
exports.verifyVendor = verifyVendor;
|
|
64
|
+
const verifyAccess = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
if (req.params.web_system_token) {
|
|
66
|
+
return (0, accessToken_1.accessToken)(req, res, () => {
|
|
67
|
+
return (0, exports.organByWeb)(req, res, next);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return res.status(403 /* HTTP.FORBIDDEN */).send({
|
|
71
|
+
code: 403 /* HTTP.FORBIDDEN */,
|
|
72
|
+
json: { code: authError_1.authError.ACCESS_DENINED.message }
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
exports.verifyAccess = verifyAccess;
|
|
76
|
+
const verifySubOrgan = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
let body = req.body || {};
|
|
78
|
+
let organ_id = body['organ_id'] || req.query.organ_in;
|
|
79
|
+
organ_id = organ_id || res.locals.related_id;
|
|
80
|
+
if (organ_id) {
|
|
81
|
+
let parent_id = [res.locals.organ_id];
|
|
82
|
+
if (body['organ_id']) {
|
|
83
|
+
req.body['created_by'] = "0";
|
|
84
|
+
}
|
|
85
|
+
if (organ_id == parent_id[0])
|
|
86
|
+
return next();
|
|
87
|
+
if (res.locals.related_id && res.locals.related_id != parent_id[0]) {
|
|
88
|
+
parent_id.push(res.locals.related_id);
|
|
89
|
+
}
|
|
90
|
+
let exist = yield organ_1.UserOrganModel.schema(res.locals.ref, "_").count({
|
|
91
|
+
where: { id: organ_id, parent_id }
|
|
92
|
+
});
|
|
93
|
+
if (exist) {
|
|
94
|
+
res.locals.parent_organ_id = res.locals.organ_id;
|
|
95
|
+
res.locals.organ_id = organ_id;
|
|
96
|
+
res.locals.verify_organ = 1;
|
|
97
|
+
return next();
|
|
98
|
+
}
|
|
99
|
+
return res.status(403 /* HTTP.FORBIDDEN */).send({
|
|
100
|
+
code: 403 /* HTTP.FORBIDDEN */,
|
|
101
|
+
json: { code: authError_1.authError.ACCESS_DENINED.message }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return next();
|
|
105
|
+
});
|
|
106
|
+
exports.verifySubOrgan = verifySubOrgan;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
export declare const site: (req: Request, res: Response, next: any) => Promise<any>;
|
|
3
|
+
export declare const themeByWeb: (req: Request, res: Response, next: any) => Promise<any>;
|
|
4
|
+
export declare const configByWeb: (req: Request, res: Response, next: any) => Promise<any>;
|
|
5
|
+
export declare const organByWeb: (req: Request, res: Response, next: any) => Promise<any>;
|
|
6
|
+
export declare const verifyVendor: (req: Request, res: Response, next: any) => Promise<any>;
|
|
7
|
+
export declare const verifyVendorOrganWeb: (req: Request, res: Response, next: any) => Promise<any>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyVendorOrganWeb = exports.verifyVendor = exports.organByWeb = exports.configByWeb = exports.themeByWeb = exports.site = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const website_1 = require("../models/system/website");
|
|
7
|
+
const organ_1 = require("../models/user/organ");
|
|
8
|
+
const accessToken_1 = require("../middlewares/accessToken");
|
|
9
|
+
const authError_1 = require("../errors/authError");
|
|
10
|
+
const site = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
let ref = res.locals.ref;
|
|
12
|
+
let web = req.params.web;
|
|
13
|
+
if (web && !req.params.web_token) {
|
|
14
|
+
let exist = yield website_1.SystemWebSiteModel.schema(ref, "_").count({ where: { id: web, module: "site" } });
|
|
15
|
+
if (!exist) {
|
|
16
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
17
|
+
return res.status(err.code).send(err);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (web)
|
|
21
|
+
res.locals.web_id = web;
|
|
22
|
+
return next();
|
|
23
|
+
});
|
|
24
|
+
exports.site = site;
|
|
25
|
+
const themeByWeb = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
let ref = res.locals.ref;
|
|
27
|
+
let web = req.params.web;
|
|
28
|
+
if (web) {
|
|
29
|
+
let query = yield website_1.SystemWebSiteModel.schema(ref, "_").findOne({ where: { id: web, module: "site" }, attributes: ['organ_id', 'theme_id'], raw: true });
|
|
30
|
+
if (query) {
|
|
31
|
+
res.locals.web_id = web;
|
|
32
|
+
res.locals.organ_id = query['organ_id'];
|
|
33
|
+
res.locals.verify_organ = 1;
|
|
34
|
+
res.locals.theme_id = query['theme_id'];
|
|
35
|
+
return next();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
39
|
+
return res.status(err.code).send(err);
|
|
40
|
+
});
|
|
41
|
+
exports.themeByWeb = themeByWeb;
|
|
42
|
+
const configByWeb = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
let ref = res.locals.ref;
|
|
44
|
+
let web = req.params.web;
|
|
45
|
+
if (web) {
|
|
46
|
+
let query = yield website_1.SystemWebSiteModel.schema(ref, "_").findOne({ where: { id: web, module: "site" }, attributes: ['created_by', 'organ_id', 'config'], raw: true });
|
|
47
|
+
if (query && query['created_by']) {
|
|
48
|
+
res.locals.web_id = web;
|
|
49
|
+
res.locals.auth_id = query['created_by'];
|
|
50
|
+
res.locals.organ_id = query['organ_id'];
|
|
51
|
+
res.locals.verify_organ = 1;
|
|
52
|
+
let body = req.body || {};
|
|
53
|
+
body['created_by'] = query['created_by'];
|
|
54
|
+
body['data'] = query['config'] || {};
|
|
55
|
+
req.body = body;
|
|
56
|
+
return next();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
60
|
+
return res.status(err.code).send(err);
|
|
61
|
+
});
|
|
62
|
+
exports.configByWeb = configByWeb;
|
|
63
|
+
const organByWeb = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
let ref = res.locals.ref;
|
|
65
|
+
let web = req.params.web;
|
|
66
|
+
if (web) {
|
|
67
|
+
let query = yield website_1.SystemWebSiteModel.schema(ref, "_").findOne({ where: { id: web, module: "site" }, attributes: ['created_by', 'organ_id'], raw: true });
|
|
68
|
+
if (query && query['organ_id']) {
|
|
69
|
+
res.locals.web_id = web;
|
|
70
|
+
res.locals.organ_id = query['organ_id'];
|
|
71
|
+
res.locals.verify_organ = 1;
|
|
72
|
+
return next();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
let err = new errors_1.CustomError(errors_1.generalError.NOT_FOUND);
|
|
76
|
+
return res.status(err.code).send(err);
|
|
77
|
+
});
|
|
78
|
+
exports.organByWeb = organByWeb;
|
|
79
|
+
const verifyVendor = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
return (0, accessToken_1.verifyAccessToken)(req, res, () => {
|
|
81
|
+
let organ_id = res.locals.organ_id;
|
|
82
|
+
let auth_id = res.locals.auth_id;
|
|
83
|
+
return (0, exports.organByWeb)(req, res, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
let exist = (organ_id == res.locals.organ_id) ? 1 : 0;
|
|
85
|
+
if (!exist) {
|
|
86
|
+
exist = yield organ_1.UserOrganModel.schema(res.locals.ref, "_").count({
|
|
87
|
+
where: { id: organ_id, parent_id: res.locals.organ_id }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (exist) {
|
|
91
|
+
res.locals.parent_organ_id = res.locals.organ_id;
|
|
92
|
+
res.locals.organ_id = organ_id;
|
|
93
|
+
res.locals.auth_id = auth_id;
|
|
94
|
+
return next();
|
|
95
|
+
}
|
|
96
|
+
let err = new errors_1.CustomError(authError_1.authError.ACCESS_DENINED);
|
|
97
|
+
return res.status(403 /* HTTP.FORBIDDEN */).send(err);
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
exports.verifyVendor = verifyVendor;
|
|
102
|
+
const verifyVendorOrganWeb = (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
return (0, exports.verifyVendor)(req, res, () => {
|
|
104
|
+
res.locals.organ_id = res.locals.parent_organ_id;
|
|
105
|
+
delete res.locals.parent_organ_id;
|
|
106
|
+
return next();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
exports.verifyVendorOrganWeb = verifyVendorOrganWeb;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as sequelize from "sequelize";
|
|
2
|
+
export declare const CityTable = "cities";
|
|
3
|
+
export declare const CityAttr: {
|
|
4
|
+
id: {
|
|
5
|
+
type: sequelize.IntegerDataType;
|
|
6
|
+
primaryKey: boolean;
|
|
7
|
+
autoIncrement: boolean;
|
|
8
|
+
allowNull: boolean;
|
|
9
|
+
};
|
|
10
|
+
city_name: sequelize.StringDataType;
|
|
11
|
+
state_id: sequelize.IntegerDataType;
|
|
12
|
+
status: sequelize.IntegerDataType;
|
|
13
|
+
ordering: sequelize.IntegerDataType;
|
|
14
|
+
lang_code: sequelize.StringDataType;
|
|
15
|
+
};
|
|
16
|
+
declare const CityModel: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
17
|
+
declare const CityAssociation: {
|
|
18
|
+
state: {
|
|
19
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
20
|
+
alias: string;
|
|
21
|
+
join: (ref: any, { where, attributes, required, zone_country }?: {
|
|
22
|
+
where?: {};
|
|
23
|
+
attributes?: any;
|
|
24
|
+
required?: any;
|
|
25
|
+
zone_country?: boolean;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
where: {};
|
|
28
|
+
required: any;
|
|
29
|
+
attributes: any;
|
|
30
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
31
|
+
as: string;
|
|
32
|
+
include: any[];
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
zone: {
|
|
36
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
37
|
+
alias: string;
|
|
38
|
+
join: (ref: any, { where, attributes, required }?: {
|
|
39
|
+
where?: {};
|
|
40
|
+
attributes?: any;
|
|
41
|
+
required?: any;
|
|
42
|
+
}) => Promise<{
|
|
43
|
+
where: {};
|
|
44
|
+
required: any;
|
|
45
|
+
attributes: any;
|
|
46
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
47
|
+
as: string;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
zone_state: {
|
|
51
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
52
|
+
alias: string;
|
|
53
|
+
join: (ref: any, { where, attributes, required }?: {
|
|
54
|
+
where?: {};
|
|
55
|
+
attributes?: any;
|
|
56
|
+
required?: any;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
where: {};
|
|
59
|
+
required: any;
|
|
60
|
+
attributes: any;
|
|
61
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
62
|
+
as: string;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export { CityModel, CityAssociation };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CityAssociation = exports.CityModel = exports.CityAttr = exports.CityTable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sequelize = require("sequelize");
|
|
6
|
+
const database_1 = require("../../database");
|
|
7
|
+
const state_1 = require("./state");
|
|
8
|
+
const zone_1 = require("../system/zone");
|
|
9
|
+
exports.CityTable = "cities";
|
|
10
|
+
exports.CityAttr = {
|
|
11
|
+
id: {
|
|
12
|
+
type: sequelize.INTEGER({ length: 11 }),
|
|
13
|
+
primaryKey: true,
|
|
14
|
+
autoIncrement: true,
|
|
15
|
+
allowNull: false
|
|
16
|
+
},
|
|
17
|
+
city_name: sequelize.STRING(200),
|
|
18
|
+
state_id: sequelize.INTEGER({ length: 11 }),
|
|
19
|
+
status: sequelize.INTEGER({ length: 11 }),
|
|
20
|
+
ordering: sequelize.INTEGER({ length: 11 }),
|
|
21
|
+
lang_code: sequelize.STRING(20)
|
|
22
|
+
};
|
|
23
|
+
const CityModel = database_1.default.define("City", exports.CityAttr, {
|
|
24
|
+
tableName: exports.CityTable
|
|
25
|
+
});
|
|
26
|
+
exports.CityModel = CityModel;
|
|
27
|
+
const CityAssociation = {
|
|
28
|
+
state: {
|
|
29
|
+
model: state_1.StateModel,
|
|
30
|
+
alias: "state",
|
|
31
|
+
join: (ref, { where = {}, attributes = undefined, required = undefined, zone_country = false } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
let include = [];
|
|
33
|
+
if (zone_country) {
|
|
34
|
+
include.push(yield state_1.StateAssociation.zone_country.join(ref, { required: false, attributes: [] }));
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
where,
|
|
38
|
+
required,
|
|
39
|
+
attributes,
|
|
40
|
+
model: CityAssociation.state.model.schema("core", "_"),
|
|
41
|
+
as: CityAssociation.state.alias,
|
|
42
|
+
include
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
zone: {
|
|
47
|
+
model: zone_1.ZoneCityModel,
|
|
48
|
+
alias: "zone",
|
|
49
|
+
join: (ref, { where = {}, attributes = undefined, required = undefined } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
return {
|
|
51
|
+
where,
|
|
52
|
+
required,
|
|
53
|
+
attributes,
|
|
54
|
+
model: CityAssociation.zone.model.schema(ref, "_"),
|
|
55
|
+
as: CityAssociation.zone.alias
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
zone_state: {
|
|
60
|
+
model: zone_1.ZoneStateModel,
|
|
61
|
+
alias: "zone_state",
|
|
62
|
+
join: (ref, { where = {}, attributes = undefined, required = undefined } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
return {
|
|
64
|
+
where,
|
|
65
|
+
required,
|
|
66
|
+
attributes,
|
|
67
|
+
model: CityAssociation.zone_state.model.schema(ref, "_"),
|
|
68
|
+
as: CityAssociation.zone_state.alias
|
|
69
|
+
};
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.CityAssociation = CityAssociation;
|
|
74
|
+
// state
|
|
75
|
+
CityModel.belongsTo(CityAssociation.state.model, { as: CityAssociation.state.alias, foreignKey: "state_id", targetKey: "id" });
|
|
76
|
+
// zone
|
|
77
|
+
CityModel.hasOne(CityAssociation.zone.model, { as: CityAssociation.zone.alias, foreignKey: "city_id" });
|
|
78
|
+
// zone state
|
|
79
|
+
CityModel.belongsTo(CityAssociation.zone_state.model, { as: CityAssociation.zone_state.alias, foreignKey: "state_id", targetKey: "state_id" });
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as sequelize from "sequelize";
|
|
2
|
+
export declare const CountryTable = "country";
|
|
3
|
+
export declare const CountryAttr: {
|
|
4
|
+
id: {
|
|
5
|
+
type: sequelize.IntegerDataType;
|
|
6
|
+
primaryKey: boolean;
|
|
7
|
+
autoIncrement: boolean;
|
|
8
|
+
allowNull: boolean;
|
|
9
|
+
};
|
|
10
|
+
country_name: sequelize.StringDataType;
|
|
11
|
+
default: sequelize.StringDataType;
|
|
12
|
+
status: sequelize.StringDataType;
|
|
13
|
+
ordering: sequelize.IntegerDataType;
|
|
14
|
+
country_code: sequelize.StringDataType;
|
|
15
|
+
lang_code: sequelize.StringDataType;
|
|
16
|
+
};
|
|
17
|
+
declare const CountryModel: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
18
|
+
declare const CountryAssociation: {
|
|
19
|
+
zone: {
|
|
20
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
21
|
+
alias: string;
|
|
22
|
+
join: (ref: any, { where, attributes, required }?: {
|
|
23
|
+
where?: {};
|
|
24
|
+
attributes?: any;
|
|
25
|
+
required?: any;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
where: {};
|
|
28
|
+
required: any;
|
|
29
|
+
attributes: any;
|
|
30
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
31
|
+
as: string;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export { CountryModel, CountryAssociation };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CountryAssociation = exports.CountryModel = exports.CountryAttr = exports.CountryTable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sequelize = require("sequelize");
|
|
6
|
+
const database_1 = require("../../database");
|
|
7
|
+
const zone_1 = require("../system/zone");
|
|
8
|
+
exports.CountryTable = "country";
|
|
9
|
+
exports.CountryAttr = {
|
|
10
|
+
id: {
|
|
11
|
+
type: sequelize.INTEGER({ length: 11 }),
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
autoIncrement: true,
|
|
14
|
+
allowNull: false
|
|
15
|
+
},
|
|
16
|
+
country_name: sequelize.STRING(200),
|
|
17
|
+
default: sequelize.STRING(20),
|
|
18
|
+
status: sequelize.STRING(20),
|
|
19
|
+
ordering: sequelize.INTEGER({ length: 11 }),
|
|
20
|
+
country_code: sequelize.STRING(20),
|
|
21
|
+
lang_code: sequelize.STRING(20)
|
|
22
|
+
};
|
|
23
|
+
const CountryModel = database_1.default.define("Country", exports.CountryAttr, {
|
|
24
|
+
tableName: exports.CountryTable
|
|
25
|
+
});
|
|
26
|
+
exports.CountryModel = CountryModel;
|
|
27
|
+
const CountryAssociation = {
|
|
28
|
+
zone: {
|
|
29
|
+
model: zone_1.ZoneCountryModel,
|
|
30
|
+
alias: "zone",
|
|
31
|
+
join: (ref, { where = {}, attributes = undefined, required = undefined } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
return {
|
|
33
|
+
where,
|
|
34
|
+
required,
|
|
35
|
+
attributes,
|
|
36
|
+
model: CountryAssociation.zone.model.schema(ref, "_"),
|
|
37
|
+
as: CountryAssociation.zone.alias
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.CountryAssociation = CountryAssociation;
|
|
43
|
+
// zone
|
|
44
|
+
CountryModel.hasOne(CountryAssociation.zone.model, { as: CountryAssociation.zone.alias, foreignKey: "country_id" });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as sequelize from "sequelize";
|
|
2
|
+
export declare const DistrictTable = "districts";
|
|
3
|
+
export declare const DistrictAttr: {
|
|
4
|
+
id: {
|
|
5
|
+
type: sequelize.IntegerDataType;
|
|
6
|
+
primaryKey: boolean;
|
|
7
|
+
autoIncrement: boolean;
|
|
8
|
+
allowNull: boolean;
|
|
9
|
+
};
|
|
10
|
+
district_name: sequelize.StringDataType;
|
|
11
|
+
city_id: sequelize.IntegerDataType;
|
|
12
|
+
status: sequelize.IntegerDataType;
|
|
13
|
+
ordering: sequelize.IntegerDataType;
|
|
14
|
+
lang_code: sequelize.StringDataType;
|
|
15
|
+
};
|
|
16
|
+
declare const DistrictModel: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
17
|
+
export { DistrictModel };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DistrictModel = exports.DistrictAttr = exports.DistrictTable = void 0;
|
|
4
|
+
const sequelize = require("sequelize");
|
|
5
|
+
const database_1 = require("../../database");
|
|
6
|
+
exports.DistrictTable = "districts";
|
|
7
|
+
exports.DistrictAttr = {
|
|
8
|
+
id: {
|
|
9
|
+
type: sequelize.INTEGER({ length: 11 }),
|
|
10
|
+
primaryKey: true,
|
|
11
|
+
autoIncrement: true,
|
|
12
|
+
allowNull: false
|
|
13
|
+
},
|
|
14
|
+
district_name: sequelize.STRING(200),
|
|
15
|
+
city_id: sequelize.INTEGER({ length: 11 }),
|
|
16
|
+
status: sequelize.INTEGER({ length: 11 }),
|
|
17
|
+
ordering: sequelize.INTEGER({ length: 11 }),
|
|
18
|
+
lang_code: sequelize.STRING(20)
|
|
19
|
+
};
|
|
20
|
+
const DistrictModel = database_1.default.define("District", exports.DistrictAttr, {
|
|
21
|
+
tableName: exports.DistrictTable
|
|
22
|
+
});
|
|
23
|
+
exports.DistrictModel = DistrictModel;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as sequelize from "sequelize";
|
|
2
|
+
export declare const CoreDomainAttr: {
|
|
3
|
+
id: {
|
|
4
|
+
type: sequelize.IntegerDataType;
|
|
5
|
+
primaryKey: boolean;
|
|
6
|
+
autoIncrement: boolean;
|
|
7
|
+
allowNull: boolean;
|
|
8
|
+
};
|
|
9
|
+
domain: {
|
|
10
|
+
type: sequelize.StringDataType;
|
|
11
|
+
allowNull: boolean;
|
|
12
|
+
unique: boolean;
|
|
13
|
+
};
|
|
14
|
+
site_id: {
|
|
15
|
+
type: sequelize.IntegerDataType;
|
|
16
|
+
allowNull: boolean;
|
|
17
|
+
};
|
|
18
|
+
type: {
|
|
19
|
+
type: sequelize.EnumDataType<"park" | "redirect" | "site">;
|
|
20
|
+
allowNull: boolean;
|
|
21
|
+
defaultValue: string;
|
|
22
|
+
};
|
|
23
|
+
settings: {
|
|
24
|
+
type: sequelize.StringDataType;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare const CoreDomainModel: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
28
|
+
export declare const CoreDomainAssociation: {
|
|
29
|
+
ref: {
|
|
30
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
31
|
+
alias: string;
|
|
32
|
+
join: (ref: any, { attributes }?: {
|
|
33
|
+
attributes?: any[];
|
|
34
|
+
}) => Promise<{
|
|
35
|
+
attributes: any[];
|
|
36
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
37
|
+
as: string;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare const CoreSiteAssociation: {
|
|
42
|
+
domain: {
|
|
43
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
44
|
+
alias: string;
|
|
45
|
+
join: (ref: any, { attributes, required }?: {
|
|
46
|
+
attributes?: any;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
required: boolean;
|
|
50
|
+
attributes: any;
|
|
51
|
+
model: sequelize.ModelCtor<sequelize.Model<any, any>>;
|
|
52
|
+
as: string;
|
|
53
|
+
}>;
|
|
54
|
+
get: (ref: any, index: any) => Promise<sequelize.Model<any, any>[]>;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export { CoreDomainModel };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoreDomainModel = exports.CoreSiteAssociation = exports.CoreDomainAssociation = exports.CoreDomainAttr = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sequelize = require("sequelize");
|
|
6
|
+
const database_1 = require("../../database");
|
|
7
|
+
const db_1 = require("../../utils/db");
|
|
8
|
+
const site_1 = require("./site");
|
|
9
|
+
exports.CoreDomainAttr = {
|
|
10
|
+
id: {
|
|
11
|
+
type: sequelize.INTEGER({ length: 11 }),
|
|
12
|
+
primaryKey: true,
|
|
13
|
+
autoIncrement: true,
|
|
14
|
+
allowNull: false
|
|
15
|
+
},
|
|
16
|
+
domain: {
|
|
17
|
+
type: sequelize.STRING(100),
|
|
18
|
+
allowNull: false,
|
|
19
|
+
unique: true
|
|
20
|
+
},
|
|
21
|
+
site_id: {
|
|
22
|
+
type: sequelize.INTEGER({ length: 11 }),
|
|
23
|
+
allowNull: false
|
|
24
|
+
},
|
|
25
|
+
type: {
|
|
26
|
+
type: sequelize.ENUM('park', 'redirect', 'site'),
|
|
27
|
+
allowNull: false,
|
|
28
|
+
defaultValue: 'park'
|
|
29
|
+
},
|
|
30
|
+
settings: {
|
|
31
|
+
type: sequelize.STRING(250)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const CoreDomainModel = database_1.default.define("CoreDomain", exports.CoreDomainAttr, {
|
|
35
|
+
tableName: 'domains'
|
|
36
|
+
});
|
|
37
|
+
exports.CoreDomainModel = CoreDomainModel;
|
|
38
|
+
exports.CoreDomainAssociation = {
|
|
39
|
+
ref: {
|
|
40
|
+
model: site_1.CoreSiteModel,
|
|
41
|
+
alias: "ref_row",
|
|
42
|
+
join: (ref, { attributes = [] } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
if (!attributes.length) {
|
|
44
|
+
attributes = yield (0, db_1.getFieldAll)(ref + "_" + site_1.CoreSiteModel.getTableName().toString());
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
attributes,
|
|
48
|
+
model: exports.CoreDomainAssociation.ref.model.schema(ref, "_"),
|
|
49
|
+
as: exports.CoreDomainAssociation.ref.alias
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.CoreSiteAssociation = {
|
|
55
|
+
domain: {
|
|
56
|
+
model: CoreDomainModel,
|
|
57
|
+
alias: "domains",
|
|
58
|
+
join: (ref, { attributes = undefined, required = false } = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
return {
|
|
60
|
+
required,
|
|
61
|
+
attributes,
|
|
62
|
+
model: exports.CoreSiteAssociation.domain.model.schema(ref, "_"),
|
|
63
|
+
as: exports.CoreSiteAssociation.domain.alias
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
get: (ref, index) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
let query = yield exports.CoreSiteAssociation.domain.model.schema(ref, "_").findAll({
|
|
68
|
+
where: { site_id: index }, raw: true, attributes: ['*']
|
|
69
|
+
});
|
|
70
|
+
return query;
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
CoreDomainModel.belongsTo(exports.CoreDomainAssociation.ref.model, { as: exports.CoreDomainAssociation.ref.alias, foreignKey: "site_id", targetKey: "id" });
|
|
75
|
+
site_1.CoreSiteModel.hasMany(exports.CoreSiteAssociation.domain.model, { as: exports.CoreSiteAssociation.domain.alias, foreignKey: "site_id" });
|