@zenify-omni/chat-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/api/campaign.js +19 -0
- package/api/chat.js +518 -0
- package/api/chatroom.js +254 -0
- package/api/contact.js +45 -0
- package/api/crm-organization.js +101 -0
- package/api/customer.js +143 -0
- package/api/facebook-labels.js +11 -0
- package/api/field.js +11 -0
- package/api/file.js +17 -0
- package/api/filter.js +50 -0
- package/api/group.js +11 -0
- package/api/iam.js +23 -0
- package/api/index.js +54 -0
- package/api/orgTree.js +45 -0
- package/api/post.js +111 -0
- package/api/queue.js +15 -0
- package/api/report.js +422 -0
- package/api/send.js +21 -0
- package/api/session-event.js +30 -0
- package/api/session.js +249 -0
- package/api/settings/assign-task.js +10 -0
- package/api/settings/channel.js +136 -0
- package/api/settings/chat-layout.js +37 -0
- package/api/settings/chat-timeout.js +10 -0
- package/api/settings/common.js +32 -0
- package/api/settings/config.js +19 -0
- package/api/settings/index.js +24 -0
- package/api/settings/ivr.js +25 -0
- package/api/settings/queue-v3.js +56 -0
- package/api/settings/queue.js +48 -0
- package/api/settings/routing.js +32 -0
- package/api/settings/service.js +31 -0
- package/api/settings.js +567 -0
- package/api/shipping.js +19 -0
- package/api/shopee.js +21 -0
- package/api/smart-qc/index.js +4 -0
- package/api/smart-qc/keyword.js +10 -0
- package/api/tag.js +11 -0
- package/api/user.js +177 -0
- package/client.js +391 -0
- package/config/env.js +76 -0
- package/constants/advance-filter.js +358 -0
- package/constants/auto-assign-tag.js +13 -0
- package/constants/chat-message.js +423 -0
- package/constants/chat-room-tag.js +7 -0
- package/constants/chat-source.js +68 -0
- package/constants/chatbot.js +58 -0
- package/constants/common.js +4 -0
- package/constants/crm-organization.js +75 -0
- package/constants/distribute.js +8 -0
- package/constants/distribution-log.js +14 -0
- package/constants/events.js +27 -0
- package/constants/file-upload.js +86 -0
- package/constants/lead.js +111 -0
- package/constants/mask-data-config.js +16 -0
- package/constants/month.js +78 -0
- package/constants/quick-filter.js +49 -0
- package/constants/regex.js +34 -0
- package/constants/setting.js +62 -0
- package/constants/shipping.js +12 -0
- package/constants/social.js +21 -0
- package/constants/sortable-fields.js +146 -0
- package/constants/tenant_config.js +154 -0
- package/constants/use-query-key.js +470 -0
- package/constants/user.js +293 -0
- package/exceptions/axios-error.js +24 -0
- package/exceptions/https-error.js +28 -0
- package/exceptions/validator-error.js +20 -0
- package/lib/avatar-color.js +31 -0
- package/lib/i18n/index.js +85 -0
- package/lib/i18n/language-store.js +74 -0
- package/lib/i18n/locales/en/campaign.json +3 -0
- package/lib/i18n/locales/en/chat.json +656 -0
- package/lib/i18n/locales/en/common.json +1846 -0
- package/lib/i18n/locales/en/customer.json +20 -0
- package/lib/i18n/locales/en/lead.json +5 -0
- package/lib/i18n/locales/en/lumi.json +4 -0
- package/lib/i18n/locales/en/notification.json +107 -0
- package/lib/i18n/locales/en/org.json +4 -0
- package/lib/i18n/locales/en/posts.json +8 -0
- package/lib/i18n/locales/en/settings.json +39 -0
- package/lib/i18n/locales/vi/campaign.json +3 -0
- package/lib/i18n/locales/vi/chat.json +660 -0
- package/lib/i18n/locales/vi/common.json +1846 -0
- package/lib/i18n/locales/vi/customer.json +20 -0
- package/lib/i18n/locales/vi/lead.json +5 -0
- package/lib/i18n/locales/vi/lumi.json +4 -0
- package/lib/i18n/locales/vi/notification.json +107 -0
- package/lib/i18n/locales/vi/org.json +4 -0
- package/lib/i18n/locales/vi/posts.json +8 -0
- package/lib/i18n/locales/vi/settings.json +39 -0
- package/lib/i18n/server-label.js +33 -0
- package/lib/phone.js +70 -0
- package/lib/user-avatar.js +21 -0
- package/package.json +45 -0
- package/socket/index.js +30 -0
- package/transport-registry.js +77 -0
- package/utils/access-detail.js +119 -0
- package/utils/auth.js +205 -0
- package/utils/chunk-reload-guard.js +4 -0
- package/utils/concurrency-limiter.js +30 -0
- package/utils/crm-organization.js +0 -0
- package/utils/currency.js +14 -0
- package/utils/customers.js +42 -0
- package/utils/data.js +178 -0
- package/utils/date.js +144 -0
- package/utils/debounced-invalidate.js +15 -0
- package/utils/emoticon.js +134 -0
- package/utils/export.js +7 -0
- package/utils/field-layout.js +33 -0
- package/utils/filter-adapters.js +9 -0
- package/utils/filter.js +18 -0
- package/utils/formatters.js +6 -0
- package/utils/image-compression.js +169 -0
- package/utils/leads.js +13 -0
- package/utils/microlink.js +20 -0
- package/utils/org-tree.js +108 -0
- package/utils/request.js +461 -0
- package/utils/session-end.js +19 -0
- package/utils/string.js +154 -0
- package/utils/table-display-config.js +80 -0
- package/utils/validation.js +49 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const OVERRIDE_CONFIG_KEYS = {
|
|
2
|
+
ticket: "ticket_table_view_overrides",
|
|
3
|
+
lead: "lead_table_view_overrides",
|
|
4
|
+
customer: "contact_table_view_overrides",
|
|
5
|
+
deal: "deal_table_view_overrides",
|
|
6
|
+
task: "task_table_view_overrides"
|
|
7
|
+
};
|
|
8
|
+
const DEFAULT_VIEW_KEY = "default";
|
|
9
|
+
function parseColumnList(value) {
|
|
10
|
+
const normalize = (columns) => {
|
|
11
|
+
if (!Array.isArray(columns)) return null;
|
|
12
|
+
if (columns.every((column) => typeof column === "string")) return columns;
|
|
13
|
+
return columns.filter((column) => column?.display).map((column) => column.field).filter(Boolean);
|
|
14
|
+
};
|
|
15
|
+
if (Array.isArray(value)) return normalize(value);
|
|
16
|
+
if (typeof value !== "string" || !value) return null;
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(value);
|
|
19
|
+
if (Array.isArray(parsed)) return normalize(parsed);
|
|
20
|
+
if (Array.isArray(parsed?.columns)) return normalize(parsed.columns);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const getTableDisplayOverrideKey = (tableKey) => OVERRIDE_CONFIG_KEYS[tableKey];
|
|
27
|
+
function parseTableDisplayOverrides(value) {
|
|
28
|
+
if (!value) return {};
|
|
29
|
+
let parsed = value;
|
|
30
|
+
if (typeof value === "string") {
|
|
31
|
+
try {
|
|
32
|
+
parsed = JSON.parse(value);
|
|
33
|
+
} catch {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(parsed)) return { [DEFAULT_VIEW_KEY]: { columns: parsed } };
|
|
38
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
39
|
+
}
|
|
40
|
+
function getTableDisplayConfig({
|
|
41
|
+
overrides,
|
|
42
|
+
viewId,
|
|
43
|
+
defaultColumns,
|
|
44
|
+
legacyColumns,
|
|
45
|
+
smartView
|
|
46
|
+
}) {
|
|
47
|
+
const viewKey = viewId || DEFAULT_VIEW_KEY;
|
|
48
|
+
const saved = parseTableDisplayOverrides(overrides)[viewKey] || parseTableDisplayOverrides(legacyColumns)[viewKey] || {};
|
|
49
|
+
const savedColumns = parseColumnList(saved.columns);
|
|
50
|
+
const smartViewColumns = parseColumnList(smartView?.columns);
|
|
51
|
+
const legacyColumnList = parseColumnList(legacyColumns);
|
|
52
|
+
return {
|
|
53
|
+
columns: savedColumns?.length > 0 ? savedColumns : smartViewColumns?.length > 0 ? smartViewColumns : legacyColumnList || defaultColumns,
|
|
54
|
+
sortBy: saved.sortBy ?? smartView?.sort_by ?? null
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function updateTableDisplayOverride({
|
|
58
|
+
overrides,
|
|
59
|
+
viewId,
|
|
60
|
+
columns,
|
|
61
|
+
sortBy
|
|
62
|
+
}) {
|
|
63
|
+
const viewKey = viewId || DEFAULT_VIEW_KEY;
|
|
64
|
+
const current = parseTableDisplayOverrides(overrides);
|
|
65
|
+
const previous = current[viewKey] || {};
|
|
66
|
+
return JSON.stringify({
|
|
67
|
+
...current,
|
|
68
|
+
[viewKey]: {
|
|
69
|
+
...previous,
|
|
70
|
+
...columns !== void 0 && { columns },
|
|
71
|
+
...sortBy !== void 0 && { sortBy }
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
getTableDisplayConfig,
|
|
77
|
+
getTableDisplayOverrideKey,
|
|
78
|
+
parseTableDisplayOverrides,
|
|
79
|
+
updateTableDisplayOverride
|
|
80
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import i18n from "../lib/i18n/index.js";
|
|
2
|
+
import { isEmpty, isNil } from "lodash-es";
|
|
3
|
+
import { isDate } from "date-fns";
|
|
4
|
+
import {
|
|
5
|
+
EMAIL_REGEX,
|
|
6
|
+
PHONE_NUMBER_REGEX,
|
|
7
|
+
PHONE_NUMBER_REGEX_DEFAULT
|
|
8
|
+
} from "../constants/regex.js";
|
|
9
|
+
const emailRegex = EMAIL_REGEX;
|
|
10
|
+
const phoneRegex = PHONE_NUMBER_REGEX;
|
|
11
|
+
const phoneRegexDefault = PHONE_NUMBER_REGEX_DEFAULT;
|
|
12
|
+
const isEmptyValue = (value) => {
|
|
13
|
+
if (isDate(value)) return false;
|
|
14
|
+
if (typeof value === "number") return Number.isNaN(value);
|
|
15
|
+
if (typeof value === "boolean") return false;
|
|
16
|
+
if (typeof value === "string") return value.trim() === "";
|
|
17
|
+
if (typeof value === "object") return isEmpty(value);
|
|
18
|
+
return isNil(value);
|
|
19
|
+
};
|
|
20
|
+
const validateDynamicField = (field, value) => {
|
|
21
|
+
if (!field.required) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (isEmptyValue(value)) {
|
|
25
|
+
return i18n.t("common:message.fieldRequired", {
|
|
26
|
+
field: field.title,
|
|
27
|
+
defaultValue: "{field} kh\xF4ng \u0111\u01B0\u1EE3c b\u1ECF tr\u1ED1ng"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
const validateDynamicFields = (formData, dynamicFields) => {
|
|
33
|
+
const validationErrors = {};
|
|
34
|
+
if (dynamicFields && dynamicFields.length > 0) {
|
|
35
|
+
dynamicFields.forEach((field) => {
|
|
36
|
+
const fieldValue = formData[field.key];
|
|
37
|
+
const error = validateDynamicField(field, fieldValue);
|
|
38
|
+
if (error) {
|
|
39
|
+
validationErrors[field.key] = error;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return validationErrors;
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
isEmptyValue,
|
|
47
|
+
validateDynamicField,
|
|
48
|
+
validateDynamicFields
|
|
49
|
+
};
|