@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,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LanguageUtil = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sequelize_1 = require("sequelize");
|
|
6
|
+
const language_1 = require("../models/system/language");
|
|
7
|
+
const website_1 = require("../models/system/website");
|
|
8
|
+
class LanguageUtil {
|
|
9
|
+
constructor(ref, option) {
|
|
10
|
+
this.ref = ref;
|
|
11
|
+
this.option = option || {};
|
|
12
|
+
}
|
|
13
|
+
getLangsAll({ where = {} } = {}) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
return yield language_1.SystemLanguageModel.schema(this.ref, "_").findAll({
|
|
16
|
+
attributes: ['id', 'status', ['referent_language', 'lang_code']], where, raw: true
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
getLangsLive({ where = {}, attr_include = [] } = {}) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
let include = [];
|
|
23
|
+
where['status'] = 'yes';
|
|
24
|
+
if (this.option.web_id) {
|
|
25
|
+
include.push({
|
|
26
|
+
required: true,
|
|
27
|
+
attributes: [],
|
|
28
|
+
where: { web_id: this.option.web_id, type: "language" },
|
|
29
|
+
model: website_1.SystemWebSiteRelationModel.schema(this.ref, "_"),
|
|
30
|
+
association: new sequelize_1.HasOne(language_1.SystemLanguageModel, website_1.SystemWebSiteRelationModel, { as: "web", foreignKey: "row_id", constraints: false })
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return yield language_1.SystemLanguageModel.schema(this.ref, "_").findAll({
|
|
34
|
+
attributes: ['id', 'status', ['referent_language', 'lang_code'], ...attr_include], where, include, raw: true
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
existLang(lang_code) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
let exist = yield language_1.SystemLanguageModel.schema(this.ref).count({ where: { lang_code, status: 'yes' } });
|
|
41
|
+
if (exist > 0) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.LanguageUtil = LanguageUtil;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface OptionMetadata {
|
|
2
|
+
organ_id?: string | number;
|
|
3
|
+
[index: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export declare class MetadataUtil {
|
|
6
|
+
ref: string;
|
|
7
|
+
option: OptionMetadata;
|
|
8
|
+
constructor(ref: string, option?: OptionMetadata);
|
|
9
|
+
upsert(row_id: any, module: string, input?: any, { addition, items, autoType, types, str_length, attributes }?: {
|
|
10
|
+
addition?: {};
|
|
11
|
+
items?: {};
|
|
12
|
+
autoType?: boolean;
|
|
13
|
+
types?: string;
|
|
14
|
+
str_length?: number;
|
|
15
|
+
attributes?: string[];
|
|
16
|
+
}): Promise<import("sequelize").Model<any, any>[]>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataUtil = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const metadata_1 = require("../models/system/metadata");
|
|
6
|
+
const helper_1 = require("./helper");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
class MetadataUtil {
|
|
9
|
+
constructor(ref, option) {
|
|
10
|
+
this.ref = ref;
|
|
11
|
+
this.option = option || {};
|
|
12
|
+
}
|
|
13
|
+
upsert(row_id, module, input = {}, { addition = {}, items = {}, autoType = false, types = "name", str_length = 255, attributes = ['row_id', 'module', 'related_id', 'organ_id', 'web_id'] } = {}) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
addition = Object.assign(Object.assign({}, addition), _.pick(input, attributes));
|
|
16
|
+
input = _.omit(input, attributes);
|
|
17
|
+
if (typeof addition['id'] == "undefined") {
|
|
18
|
+
let query = yield metadata_1.MetadataModel.schema(this.ref, "_").findOne({
|
|
19
|
+
where: { row_id, module }, raw: true, attributes: ['id', 'items']
|
|
20
|
+
});
|
|
21
|
+
if (query)
|
|
22
|
+
addition = {};
|
|
23
|
+
addition['id'] = query ? query['id'] : undefined;
|
|
24
|
+
items = query ? (query['items'] || {}) : {};
|
|
25
|
+
}
|
|
26
|
+
Object.keys(input).forEach(key => {
|
|
27
|
+
let value = {}, type = types;
|
|
28
|
+
if (_.isObject(input[key])) {
|
|
29
|
+
let val = {};
|
|
30
|
+
_.each(input[key], (v, k) => { val['value_' + k] = (0, helper_1.stripHtml)(v ? v.substring(0, str_length) : ""); });
|
|
31
|
+
value = val;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
value = { value_en: (0, helper_1.stripHtml)(String(input[key] || "").substring(0, str_length)) };
|
|
35
|
+
}
|
|
36
|
+
if (autoType && !items[key]) {
|
|
37
|
+
let str = key.split(":");
|
|
38
|
+
if (str.length == 1)
|
|
39
|
+
str[1] = types;
|
|
40
|
+
type = str[0];
|
|
41
|
+
str.shift();
|
|
42
|
+
key = str.join(":");
|
|
43
|
+
}
|
|
44
|
+
items[key] = Object.assign({ types: type }, value);
|
|
45
|
+
});
|
|
46
|
+
return yield metadata_1.MetadataModel.schema(this.ref, "_").bulkCreate([Object.assign(Object.assign({ row_id, module }, addition), { items })], { updateOnDuplicate: ['items'] });
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MetadataUtil = MetadataUtil;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface Option {
|
|
2
|
+
auth_id?: string;
|
|
3
|
+
organ_id?: string;
|
|
4
|
+
sid?: string;
|
|
5
|
+
[index: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare class SessionUtil {
|
|
8
|
+
ref: string;
|
|
9
|
+
option: Option;
|
|
10
|
+
constructor(ref: string, option?: Option);
|
|
11
|
+
setSession(key: string, value: any, { index, input }?: {
|
|
12
|
+
index?: any;
|
|
13
|
+
input?: {};
|
|
14
|
+
}): Promise<{
|
|
15
|
+
sid: string;
|
|
16
|
+
session: {};
|
|
17
|
+
}>;
|
|
18
|
+
getSession(index?: string): Promise<{
|
|
19
|
+
sid: string;
|
|
20
|
+
session: {};
|
|
21
|
+
}>;
|
|
22
|
+
getSessionByKey(key: string, { sid, defaultValue }?: {
|
|
23
|
+
sid?: any;
|
|
24
|
+
defaultValue?: {};
|
|
25
|
+
}): Promise<any>;
|
|
26
|
+
setOrderBy(key: string, value: any, { index }?: {
|
|
27
|
+
index?: any;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
success: number;
|
|
30
|
+
}>;
|
|
31
|
+
getOrderBy(key: string, { index }?: {
|
|
32
|
+
index?: any;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
items: any[];
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
package/utils/session.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionUtil = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const session_1 = require("../models/system/session");
|
|
6
|
+
class SessionUtil {
|
|
7
|
+
constructor(ref, option) {
|
|
8
|
+
this.ref = ref;
|
|
9
|
+
this.option = option;
|
|
10
|
+
}
|
|
11
|
+
setSession(key, value, { index = null, input = {} } = {}) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
let { sid, session } = yield this.getSession(index);
|
|
14
|
+
if (sid) {
|
|
15
|
+
session[key] = value;
|
|
16
|
+
yield session_1.SessionModel.schema(this.ref, "_").bulkCreate([Object.assign(Object.assign({ sid }, input), { session: JSON.stringify(session) })], { updateOnDuplicate: ['session'] });
|
|
17
|
+
}
|
|
18
|
+
return { sid, session };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getSession(index) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let sid = (index || this.option.auth_id || this.option.sid), session = {};
|
|
24
|
+
if (sid) {
|
|
25
|
+
let query = yield session_1.SessionModel.schema(this.ref, "_").findOne({ where: { sid }, raw: true, attributes: ['session'] });
|
|
26
|
+
session = (query && query['session']) ? JSON.parse(query['session']) : {};
|
|
27
|
+
}
|
|
28
|
+
return { sid, session };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getSessionByKey(key, { sid = null, defaultValue = {} } = {}) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
let { session } = yield this.getSession(sid);
|
|
34
|
+
return session[key] || defaultValue;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
setOrderBy(key, value, { index = null } = {}) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
let { sid, session } = yield this.getSession(index);
|
|
40
|
+
if (sid) {
|
|
41
|
+
session[key] = session[key] || {};
|
|
42
|
+
session[key][value] = new Date().getTime();
|
|
43
|
+
yield session_1.SessionModel.schema(this.ref, "_").bulkCreate([{ sid, session: JSON.stringify(session) }], { updateOnDuplicate: ['session'] });
|
|
44
|
+
}
|
|
45
|
+
return { success: 1 };
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getOrderBy(key, { index = null } = {}) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
let items = [];
|
|
51
|
+
let { sid, session } = yield this.getSession(index);
|
|
52
|
+
if (sid) {
|
|
53
|
+
let data = session[key] || {};
|
|
54
|
+
items = Object.keys(data).sort((a, b) => data[b] - data[a]).map(k => k);
|
|
55
|
+
}
|
|
56
|
+
return { items };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.SessionUtil = SessionUtil;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class SettingUtil {
|
|
2
|
+
private model;
|
|
3
|
+
ref: string;
|
|
4
|
+
index: string;
|
|
5
|
+
constructor(ref: string);
|
|
6
|
+
getSettingAll(): Promise<{}>;
|
|
7
|
+
findSetting(keys: Array<string>, {}?: {}): Promise<any>;
|
|
8
|
+
update(input: any, { attributes, purge }?: {
|
|
9
|
+
attributes?: any[];
|
|
10
|
+
purge?: boolean;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
success: number;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
package/utils/setting.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettingUtil = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sequelize_1 = require("sequelize");
|
|
6
|
+
const setting_1 = require("../models/system/setting");
|
|
7
|
+
const redis_1 = require("../database/redis");
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
class SettingUtil {
|
|
10
|
+
constructor(ref) {
|
|
11
|
+
this.model = setting_1.SettingModel.getTableName();
|
|
12
|
+
this.ref = ref;
|
|
13
|
+
this.index = ref.toLowerCase() + '_' + this.model;
|
|
14
|
+
}
|
|
15
|
+
getSettingAll() {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return (yield setting_1.SettingModel.schema(this.ref, "_").findAll({
|
|
18
|
+
raw: true, attributes: ['slug', 'value']
|
|
19
|
+
})).reduce((total, item) => {
|
|
20
|
+
total[item['slug']] = item['value'];
|
|
21
|
+
return total;
|
|
22
|
+
}, {});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
findSetting(keys, {} = {}) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (redis_1.redisReady) {
|
|
28
|
+
let setting = yield (0, redis_1.redisGet)(this.index);
|
|
29
|
+
if (!setting) {
|
|
30
|
+
setting = yield this.getSettingAll();
|
|
31
|
+
yield (0, redis_1.redisSet)(this.index, JSON.stringify(setting));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setting = JSON.parse(setting);
|
|
35
|
+
}
|
|
36
|
+
return _.pick(setting, keys);
|
|
37
|
+
}
|
|
38
|
+
return (yield setting_1.SettingModel.schema(this.ref, "_").findAll({
|
|
39
|
+
raw: true, where: { slug: keys }, attributes: ['slug', 'value']
|
|
40
|
+
})).reduce((total, item) => {
|
|
41
|
+
total[item['slug']] = item['value'];
|
|
42
|
+
return total;
|
|
43
|
+
}, {});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
update(input, { attributes = [], purge = false } = {}) {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
let inputs = Object.keys(input).map(slug => ({ slug, value: input[slug] })), replace = false;
|
|
49
|
+
yield setting_1.SettingModel.schema(this.ref, "_").bulkCreate(inputs, { updateOnDuplicate: ['value'] });
|
|
50
|
+
if (attributes.length && purge) {
|
|
51
|
+
replace = true;
|
|
52
|
+
yield setting_1.SettingModel.schema(this.ref, "_").destroy({
|
|
53
|
+
where: { slug: { [sequelize_1.Op.not]: attributes } }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (redis_1.redisReady) {
|
|
57
|
+
let setting = yield (0, redis_1.redisGet)(this.index);
|
|
58
|
+
if (setting) {
|
|
59
|
+
setting = JSON.parse(setting);
|
|
60
|
+
setting = Object.assign(Object.assign({}, setting), input);
|
|
61
|
+
if (replace)
|
|
62
|
+
setting = yield this.getSettingAll();
|
|
63
|
+
yield (0, redis_1.redisSet)(this.index, JSON.stringify(setting));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { success: 1 };
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SettingUtil = SettingUtil;
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { FileUtil, TagFile } from './file';
|
|
3
|
+
import { QueryParamOption } from '../interface/param';
|
|
4
|
+
import { Request } from 'express';
|
|
5
|
+
import * as Joi from 'joi';
|
|
6
|
+
export declare const getValueFunctionRelationship: (key: any, { field_data }?: {
|
|
7
|
+
field_data?: {};
|
|
8
|
+
}) => (value: any, { result, ref, lang_code }?: {
|
|
9
|
+
result?: {};
|
|
10
|
+
ref?: string;
|
|
11
|
+
lang_code?: string;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
export declare const getValueFunctionMultiple: (key: any, { field_data }?: {
|
|
14
|
+
field_data?: {};
|
|
15
|
+
}) => (value: any, { result, ref, lang_code }?: {
|
|
16
|
+
result?: {};
|
|
17
|
+
ref?: string;
|
|
18
|
+
lang_code?: string;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
interface Field {
|
|
21
|
+
is_required: string | 'yes' | 'no';
|
|
22
|
+
is_lang: string | 'yes' | 'no';
|
|
23
|
+
field_name: string;
|
|
24
|
+
field_type: string | 'text' | 'textarea' | 'wysiwyg' | 'choice' | 'integer' | 'decimal';
|
|
25
|
+
field_slug?: string;
|
|
26
|
+
field_data?: any;
|
|
27
|
+
instructions?: string;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
export declare class StreamUtil {
|
|
31
|
+
ref: string;
|
|
32
|
+
option: QueryParamOption;
|
|
33
|
+
folder_parent: string;
|
|
34
|
+
private initColumn;
|
|
35
|
+
private builder;
|
|
36
|
+
private fileUtil;
|
|
37
|
+
private languageUtil;
|
|
38
|
+
constructor(ref?: string, option?: QueryParamOption, fileUtil?: FileUtil);
|
|
39
|
+
findField(slug: string, namespace: string, { index, option, no_lang, field_slug, field_only, field_required, lang, lang_code, is_required, default_value, addition, include, include_only, convert_option, field_option, require, multiple_table, multiple_spread, text, bullets, multiple, relationship, file, image, field_exclude, section }?: {
|
|
40
|
+
index?: string;
|
|
41
|
+
option?: {};
|
|
42
|
+
no_lang?: boolean;
|
|
43
|
+
field_slug?: any[];
|
|
44
|
+
field_only?: boolean;
|
|
45
|
+
field_required?: boolean;
|
|
46
|
+
lang?: any[];
|
|
47
|
+
lang_code?: string;
|
|
48
|
+
is_required?: string;
|
|
49
|
+
default_value?: any;
|
|
50
|
+
addition?: {};
|
|
51
|
+
include?: any;
|
|
52
|
+
include_only?: boolean;
|
|
53
|
+
convert_option?: boolean;
|
|
54
|
+
field_option?: {};
|
|
55
|
+
require?: boolean;
|
|
56
|
+
multiple_table?: boolean;
|
|
57
|
+
multiple_spread?: boolean;
|
|
58
|
+
text?: boolean;
|
|
59
|
+
bullets?: boolean;
|
|
60
|
+
multiple?: boolean;
|
|
61
|
+
relationship?: boolean;
|
|
62
|
+
file?: boolean;
|
|
63
|
+
image?: boolean;
|
|
64
|
+
field_exclude?: any[];
|
|
65
|
+
section?: boolean;
|
|
66
|
+
}): Promise<any>;
|
|
67
|
+
findFieldStatic(data: any, { field_type, field_exclude, field_slug, include, include_only }?: {
|
|
68
|
+
field_type?: any[];
|
|
69
|
+
field_exclude?: any[];
|
|
70
|
+
field_slug?: any[];
|
|
71
|
+
include?: any;
|
|
72
|
+
include_only?: boolean;
|
|
73
|
+
}): any;
|
|
74
|
+
buildStream(slug: string, namespace: string, { query, builder, fetch, attribute, attributes, field_exclude, include }?: {
|
|
75
|
+
query?: boolean;
|
|
76
|
+
builder?: boolean;
|
|
77
|
+
fetch?: boolean;
|
|
78
|
+
attribute?: boolean;
|
|
79
|
+
attributes?: any;
|
|
80
|
+
field_exclude?: any[];
|
|
81
|
+
include?: {};
|
|
82
|
+
}): Promise<{
|
|
83
|
+
stream: any;
|
|
84
|
+
fields: any;
|
|
85
|
+
fetchFn: any;
|
|
86
|
+
attributes: any;
|
|
87
|
+
}>;
|
|
88
|
+
getBuilder(slug: string, namespace: string, { query, index, builder, field_exclude }?: {
|
|
89
|
+
query?: boolean;
|
|
90
|
+
index?: string;
|
|
91
|
+
builder?: boolean;
|
|
92
|
+
field_exclude?: any[];
|
|
93
|
+
}): Promise<any>;
|
|
94
|
+
getValue(slug: string, namespace: string, value: any, { query, transform, spread, spread_all, raw, lang_code }?: {
|
|
95
|
+
query?: boolean;
|
|
96
|
+
transform?: boolean;
|
|
97
|
+
spread?: boolean;
|
|
98
|
+
spread_all?: boolean;
|
|
99
|
+
raw?: boolean;
|
|
100
|
+
lang_code?: any;
|
|
101
|
+
}): Promise<{}>;
|
|
102
|
+
genField(streams: Array<any>, { index, option, slug, id_stream, prefix, multiple_table, multiple_spread, addition, convert_option, field_option, default_value, default_lang, lang_code, no_lang, lang, country, section }?: {
|
|
103
|
+
index?: string;
|
|
104
|
+
option?: {};
|
|
105
|
+
slug?: string;
|
|
106
|
+
id_stream?: string;
|
|
107
|
+
prefix?: string;
|
|
108
|
+
multiple_table?: boolean;
|
|
109
|
+
multiple_spread?: boolean;
|
|
110
|
+
addition?: {};
|
|
111
|
+
convert_option?: boolean;
|
|
112
|
+
field_option?: {};
|
|
113
|
+
default_value?: any;
|
|
114
|
+
default_lang?: string;
|
|
115
|
+
lang_code?: string;
|
|
116
|
+
no_lang?: boolean;
|
|
117
|
+
lang?: any[];
|
|
118
|
+
country?: any;
|
|
119
|
+
section?: boolean;
|
|
120
|
+
}): Promise<any>;
|
|
121
|
+
getFieldAll(slug: string, namespace: string, { where_field }?: {
|
|
122
|
+
where_field?: {};
|
|
123
|
+
}): Promise<any[]>;
|
|
124
|
+
getDataStreamByField(streams: Array<any>, data: any, { is_lang, option, df_lang }?: {
|
|
125
|
+
is_lang?: boolean;
|
|
126
|
+
option?: {};
|
|
127
|
+
df_lang?: string;
|
|
128
|
+
}): Promise<any[]>;
|
|
129
|
+
truncate(slug: string, namespace: string): Promise<true | any[]>;
|
|
130
|
+
remove(slug: string, namespace: string, index: any, { field, where, error }?: {
|
|
131
|
+
field?: string;
|
|
132
|
+
where?: {};
|
|
133
|
+
error?: boolean;
|
|
134
|
+
}): Promise<boolean>;
|
|
135
|
+
upsert(slug: string, namespace: string, input?: any, { id, req, raw_input, attributes, field, where, default_lang, builder }?: {
|
|
136
|
+
id?: string;
|
|
137
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
138
|
+
raw_input?: {};
|
|
139
|
+
attributes?: any[];
|
|
140
|
+
field?: string;
|
|
141
|
+
where?: {};
|
|
142
|
+
default_lang?: string;
|
|
143
|
+
builder?: boolean;
|
|
144
|
+
}): Promise<any>;
|
|
145
|
+
upsertBySlug(slug: string, namespace: string, index: string, { ref, req, parent_slug, input, tags, group }?: {
|
|
146
|
+
ref?: string;
|
|
147
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
148
|
+
parent_slug?: string;
|
|
149
|
+
input?: {};
|
|
150
|
+
tags?: TagFile;
|
|
151
|
+
group?: any;
|
|
152
|
+
}): Promise<{}>;
|
|
153
|
+
findStream(slug: string, namespace: string, { result, lang_code, field_exclude, multiple, relationship, file, image, is_lang, stream, use_param }?: {
|
|
154
|
+
result?: any[];
|
|
155
|
+
lang_code?: string;
|
|
156
|
+
field_exclude?: any[];
|
|
157
|
+
multiple?: boolean;
|
|
158
|
+
relationship?: boolean;
|
|
159
|
+
file?: boolean;
|
|
160
|
+
image?: boolean;
|
|
161
|
+
is_lang?: boolean;
|
|
162
|
+
stream?: any;
|
|
163
|
+
use_param?: boolean;
|
|
164
|
+
}): Promise<any[]>;
|
|
165
|
+
cacheIndex(slug: string, namespace: string, { result, field_filter, field_exclude, multiple, relationship, file, image, stream, use_param }?: {
|
|
166
|
+
result?: any[];
|
|
167
|
+
field_filter?: any[];
|
|
168
|
+
field_exclude?: any[];
|
|
169
|
+
multiple?: boolean;
|
|
170
|
+
relationship?: boolean;
|
|
171
|
+
file?: boolean;
|
|
172
|
+
image?: boolean;
|
|
173
|
+
stream?: any;
|
|
174
|
+
use_param?: boolean;
|
|
175
|
+
}): Promise<Pick<any, any>[]>;
|
|
176
|
+
createCache(slug: string, namespace: string, { result, lang_code, field_exclude, multiple, single, relationship, file, image, stream, use_param }?: {
|
|
177
|
+
result?: any[];
|
|
178
|
+
lang_code?: string;
|
|
179
|
+
field_exclude?: any[];
|
|
180
|
+
multiple?: boolean;
|
|
181
|
+
single?: boolean;
|
|
182
|
+
relationship?: boolean;
|
|
183
|
+
file?: boolean;
|
|
184
|
+
image?: boolean;
|
|
185
|
+
stream?: any;
|
|
186
|
+
use_param?: boolean;
|
|
187
|
+
}): Promise<any[]>;
|
|
188
|
+
cacheQuery(slug: string, namespace: string, { result, lang_code, single, multiple, relationship }: {
|
|
189
|
+
result?: any[];
|
|
190
|
+
lang_code?: string;
|
|
191
|
+
single?: boolean;
|
|
192
|
+
multiple?: boolean;
|
|
193
|
+
relationship?: boolean;
|
|
194
|
+
}): Promise<any[]>;
|
|
195
|
+
getStreamFile(slug: string, namespace: string, { includeAttrFile, items, lang_code, field_slug, where, relationship, image, file, single, limit, offset, order, img_kit }?: {
|
|
196
|
+
includeAttrFile?: any[];
|
|
197
|
+
items?: any[];
|
|
198
|
+
lang_code?: string;
|
|
199
|
+
field_slug?: any[];
|
|
200
|
+
where?: {};
|
|
201
|
+
relationship?: boolean;
|
|
202
|
+
image?: boolean;
|
|
203
|
+
file?: boolean;
|
|
204
|
+
single?: boolean;
|
|
205
|
+
limit?: number;
|
|
206
|
+
offset?: number;
|
|
207
|
+
order?: any[];
|
|
208
|
+
img_kit?: boolean;
|
|
209
|
+
}): Promise<object>;
|
|
210
|
+
getInputByLang(input: any, { separate, attributes_i18n, lang }?: {
|
|
211
|
+
separate?: boolean;
|
|
212
|
+
attributes_i18n?: any[];
|
|
213
|
+
lang?: any[];
|
|
214
|
+
}): Promise<any>;
|
|
215
|
+
getInputByLangIndex(input: any, { lang }?: {
|
|
216
|
+
lang?: any[];
|
|
217
|
+
}): Promise<any[]>;
|
|
218
|
+
checkStream(slug: string, namespace: string): Promise<number>;
|
|
219
|
+
addStream(slug: string, namespace: string, input?: any, { stream, column, checkDuplicate, fields, removePrimary }?: {
|
|
220
|
+
stream?: any;
|
|
221
|
+
column?: {};
|
|
222
|
+
checkDuplicate?: boolean;
|
|
223
|
+
fields?: Field[];
|
|
224
|
+
removePrimary?: boolean;
|
|
225
|
+
}): Promise<any>;
|
|
226
|
+
updateStream(slug: string, namespace: string, input?: any): Promise<[undefined, number] | {
|
|
227
|
+
[x: string]: any;
|
|
228
|
+
}>;
|
|
229
|
+
removeStreamByNamespace(namespace: string): Promise<{
|
|
230
|
+
success: number;
|
|
231
|
+
}>;
|
|
232
|
+
removeStream(slug: string, namespace: string, { stream, error }?: {
|
|
233
|
+
stream?: {};
|
|
234
|
+
error?: boolean;
|
|
235
|
+
}): Promise<boolean>;
|
|
236
|
+
removeStreamManual(slug: any, { error }?: {
|
|
237
|
+
error?: boolean;
|
|
238
|
+
}): Promise<boolean>;
|
|
239
|
+
addStreamFieldMany(slug: string, namespace: string, fields: Array<Field>, { stream, checkDuplicate }?: {
|
|
240
|
+
stream?: {};
|
|
241
|
+
checkDuplicate?: boolean;
|
|
242
|
+
}): Promise<{
|
|
243
|
+
success: number;
|
|
244
|
+
}>;
|
|
245
|
+
addStreamField(slug: string, namespace: string, field_slug: string, { stream, field, opt, changeTable, checkDuplicate, attributes }?: {
|
|
246
|
+
stream?: {};
|
|
247
|
+
field?: Field;
|
|
248
|
+
opt?: {};
|
|
249
|
+
changeTable?: boolean;
|
|
250
|
+
checkDuplicate?: boolean;
|
|
251
|
+
attributes?: any[];
|
|
252
|
+
}): Promise<any>;
|
|
253
|
+
removeStreamFieldMany(slug: string, namespace: string, field_array: Array<any>): Promise<{
|
|
254
|
+
success: number;
|
|
255
|
+
}>;
|
|
256
|
+
removeStreamField(slug: string, namespace: string, field_slug: string, { field_id, stream }?: {
|
|
257
|
+
field_id?: string;
|
|
258
|
+
stream?: {};
|
|
259
|
+
}): Promise<{
|
|
260
|
+
success: number;
|
|
261
|
+
}>;
|
|
262
|
+
inputFieldData(field_type: string, field_data: any): any;
|
|
263
|
+
getValidator(streams: Array<any>, { schema, input, req, isNew, lang, required, stripUnknown }?: {
|
|
264
|
+
schema?: {};
|
|
265
|
+
input?: {};
|
|
266
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
267
|
+
isNew?: boolean;
|
|
268
|
+
lang?: any[];
|
|
269
|
+
required?: boolean;
|
|
270
|
+
stripUnknown?: boolean;
|
|
271
|
+
}): Promise<Joi.ObjectSchema<any>>;
|
|
272
|
+
getValidatorSchema(slug: string, namespace: string, { req, isNew, required, lang, stripUnknown, builder }?: {
|
|
273
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
274
|
+
isNew?: boolean;
|
|
275
|
+
required?: boolean;
|
|
276
|
+
lang?: any[];
|
|
277
|
+
stripUnknown?: boolean;
|
|
278
|
+
builder?: boolean;
|
|
279
|
+
}): Promise<Joi.ObjectSchema<any>>;
|
|
280
|
+
validate(slug: string, namespace: string, input: any, { req, isNew, default_value, lang, stripUnknown, inputLang, inputLangSeparate, prefixMessage, builder, field_exclude }?: {
|
|
281
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
282
|
+
isNew?: boolean;
|
|
283
|
+
default_value?: {};
|
|
284
|
+
lang?: any[];
|
|
285
|
+
stripUnknown?: boolean;
|
|
286
|
+
inputLang?: boolean;
|
|
287
|
+
inputLangSeparate?: boolean;
|
|
288
|
+
prefixMessage?: string;
|
|
289
|
+
builder?: boolean;
|
|
290
|
+
field_exclude?: any[];
|
|
291
|
+
}): Promise<any>;
|
|
292
|
+
validateByField(streams: Array<any>, input: any, { req, isNew, default_value, lang, stripUnknown, inputLang, inputLangSeparate, prefixMessage }?: {
|
|
293
|
+
req?: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
294
|
+
isNew?: boolean;
|
|
295
|
+
default_value?: {};
|
|
296
|
+
lang?: any[];
|
|
297
|
+
stripUnknown?: boolean;
|
|
298
|
+
inputLang?: boolean;
|
|
299
|
+
inputLangSeparate?: boolean;
|
|
300
|
+
prefixMessage?: string;
|
|
301
|
+
}): Promise<any>;
|
|
302
|
+
}
|
|
303
|
+
export {};
|