woodsportal-client-sdk 1.1.4-dev.3 → 1.1.4-dev.31
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/CHANGELOG.md +4 -0
- package/README.md +47 -1
- package/dist/adapters/angular/index.d.ts +27 -0
- package/dist/adapters/angular/index.js +34 -0
- package/dist/adapters/angular/index.js.map +1 -0
- package/dist/adapters/react/index.d.ts +27 -0
- package/dist/adapters/react/index.js +18 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/vue/index.d.ts +27 -0
- package/dist/adapters/vue/index.js +25 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/auth-utils-A4WPJMPK.js +4 -0
- package/dist/auth-utils-A4WPJMPK.js.map +1 -0
- package/dist/chunk-J7MDPY5P.js +54 -0
- package/dist/chunk-J7MDPY5P.js.map +1 -0
- package/dist/chunk-NB7AINV4.js +35 -0
- package/dist/chunk-NB7AINV4.js.map +1 -0
- package/dist/chunk-RDCT25UV.js +1066 -0
- package/dist/chunk-RDCT25UV.js.map +1 -0
- package/dist/chunk-Y5MRAAGK.js +10 -0
- package/dist/chunk-Y5MRAAGK.js.map +1 -0
- package/dist/chunk-YLZA5S7A.js +102 -0
- package/dist/chunk-YLZA5S7A.js.map +1 -0
- package/dist/index.d.ts +106 -2
- package/dist/index.js +404 -835
- package/dist/index.js.map +1 -1
- package/dist/use-sync-LbURBOs_.d.ts +29 -0
- package/package.json +44 -8
package/dist/index.js
CHANGED
|
@@ -1,153 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getParamDetails, useUpdateLink, useTable, getRouteDetails, actions, actions2, actions3, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-RDCT25UV.js';
|
|
2
|
+
import { ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, getRefreshToken, DEV_API_URL, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken } from './chunk-YLZA5S7A.js';
|
|
3
|
+
import { __export, isCookieExpired, removeAllCookie } from './chunk-NB7AINV4.js';
|
|
2
4
|
import axios from 'axios';
|
|
3
|
-
import pako from 'pako';
|
|
4
|
-
import { Base64 } from 'js-base64';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// src/utils/constants.ts
|
|
12
|
-
var LOGIN_DETAILS, REFRESH_TOKEN, PORTAL, SUBSCRIPTION_TYPE, HUBSPOT_DATA, HUB_ID, DEV_PORTAL_ID, PORTAL_ID;
|
|
13
|
-
var init_constants = __esm({
|
|
14
|
-
"src/utils/constants.ts"() {
|
|
15
|
-
LOGIN_DETAILS = "loginDetails";
|
|
16
|
-
REFRESH_TOKEN = "refreshToken";
|
|
17
|
-
PORTAL = "portal";
|
|
18
|
-
SUBSCRIPTION_TYPE = "ssubscriptionType";
|
|
19
|
-
HUBSPOT_DATA = "hubSpotData";
|
|
20
|
-
HUB_ID = "hubId";
|
|
21
|
-
DEV_PORTAL_ID = "devPortalId";
|
|
22
|
-
PORTAL_ID = "portalId";
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var setCookie, getCookie, removeAllCookie, isCookieExpired;
|
|
26
|
-
var init_cookie = __esm({
|
|
27
|
-
"src/utils/cookie.ts"() {
|
|
28
|
-
setCookie = (key, value, expire) => {
|
|
29
|
-
return Cookies.set(key, value, {
|
|
30
|
-
expires: expire,
|
|
31
|
-
sameSite: "none",
|
|
32
|
-
secure: true
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
getCookie = (key) => {
|
|
36
|
-
return Cookies.get(key);
|
|
37
|
-
};
|
|
38
|
-
removeAllCookie = () => {
|
|
39
|
-
Object.keys(Cookies.get()).forEach((cookieName) => {
|
|
40
|
-
Cookies.remove(cookieName);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
isCookieExpired = (key) => {
|
|
44
|
-
const value = Cookies.get(key);
|
|
45
|
-
try {
|
|
46
|
-
const { expiresAt } = JSON.parse(value);
|
|
47
|
-
return Date.now() > expiresAt ? true : false;
|
|
48
|
-
} catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
6
|
+
// src/client/index.ts
|
|
7
|
+
var client_exports = {};
|
|
8
|
+
__export(client_exports, {
|
|
9
|
+
Client: () => Client
|
|
53
10
|
});
|
|
54
11
|
|
|
55
|
-
// src/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
12
|
+
// src/utils/localStoraget.ts
|
|
13
|
+
var memory = /* @__PURE__ */ new Map();
|
|
14
|
+
var memoryStore = {
|
|
15
|
+
getItem(key) {
|
|
16
|
+
return memory.has(key) ? memory.get(key) : null;
|
|
17
|
+
},
|
|
18
|
+
setItem(key, value) {
|
|
19
|
+
memory.set(key, value);
|
|
20
|
+
},
|
|
21
|
+
removeItem(key) {
|
|
22
|
+
memory.delete(key);
|
|
65
23
|
}
|
|
66
|
-
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
function isExpiresAccessToken() {
|
|
72
|
-
if (!tokenExpiresAt) return true;
|
|
73
|
-
return Date.now() >= tokenExpiresAt;
|
|
74
|
-
}
|
|
75
|
-
function isAuthenticateApp() {
|
|
76
|
-
if (isCookieExpired(REFRESH_TOKEN) || isExpiresAccessToken()) {
|
|
77
|
-
return false;
|
|
24
|
+
};
|
|
25
|
+
function resolveStore() {
|
|
26
|
+
if (typeof globalThis === "undefined") {
|
|
27
|
+
return memoryStore;
|
|
78
28
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var init_token_store = __esm({
|
|
83
|
-
"src/clint/token-store.ts"() {
|
|
84
|
-
init_cookie();
|
|
85
|
-
init_constants();
|
|
86
|
-
accessToken = null;
|
|
87
|
-
tokenExpiresAt = null;
|
|
29
|
+
const ls = globalThis.localStorage;
|
|
30
|
+
if (!ls || typeof ls.getItem !== "function") {
|
|
31
|
+
return memoryStore;
|
|
88
32
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function setAccessToken(token, expiresIn) {
|
|
99
|
-
return new Promise((resolve) => {
|
|
100
|
-
storAccessToken(token, expiresIn);
|
|
101
|
-
resolve();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function getRefreshToken() {
|
|
105
|
-
return JSON.parse(getCookie(REFRESH_TOKEN || null) || null);
|
|
106
|
-
}
|
|
107
|
-
function getPortal() {
|
|
108
|
-
return JSON.parse(getCookie(PORTAL || null) || null);
|
|
109
|
-
}
|
|
110
|
-
var setLoggedInDetails, setPortal, setSubscriptionType;
|
|
111
|
-
var init_auth_utils = __esm({
|
|
112
|
-
"src/clint/auth-utils.ts"() {
|
|
113
|
-
init_constants();
|
|
114
|
-
init_cookie();
|
|
115
|
-
init_token_store();
|
|
116
|
-
setLoggedInDetails = async (data) => {
|
|
117
|
-
return new Promise((resolve) => {
|
|
118
|
-
setCookie(LOGIN_DETAILS, JSON.stringify(data));
|
|
119
|
-
resolve();
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
setPortal = async (data) => {
|
|
123
|
-
return new Promise((resolve) => {
|
|
124
|
-
setCookie(PORTAL, JSON.stringify(data));
|
|
125
|
-
resolve();
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
setSubscriptionType = async (data) => {
|
|
129
|
-
return new Promise((resolve) => {
|
|
130
|
-
setCookie(SUBSCRIPTION_TYPE, JSON.stringify(data));
|
|
131
|
-
resolve();
|
|
132
|
-
});
|
|
133
|
-
};
|
|
33
|
+
try {
|
|
34
|
+
const probeKey = "__woodsportal_client_sdk_ls_probe__";
|
|
35
|
+
ls.setItem(probeKey, "1");
|
|
36
|
+
ls.removeItem(probeKey);
|
|
37
|
+
return ls;
|
|
38
|
+
} catch {
|
|
39
|
+
return memoryStore;
|
|
134
40
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/utils/config.ts
|
|
138
|
-
init_constants();
|
|
139
|
-
|
|
140
|
-
// src/utils/localStoraget.ts
|
|
41
|
+
}
|
|
141
42
|
var storage = {
|
|
142
43
|
set: (key, value) => {
|
|
143
|
-
|
|
44
|
+
resolveStore().setItem(key, JSON.stringify(value));
|
|
144
45
|
},
|
|
145
46
|
get: (key) => {
|
|
146
|
-
const item =
|
|
47
|
+
const item = resolveStore().getItem(key);
|
|
147
48
|
return item ? JSON.parse(item) : null;
|
|
148
49
|
},
|
|
149
50
|
remove: (key) => {
|
|
150
|
-
|
|
51
|
+
resolveStore().removeItem(key);
|
|
151
52
|
}
|
|
152
53
|
};
|
|
153
54
|
|
|
@@ -164,6 +65,10 @@ var config = {
|
|
|
164
65
|
get portalId() {
|
|
165
66
|
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
166
67
|
return hubSpotData?.[PORTAL_ID] || "";
|
|
68
|
+
},
|
|
69
|
+
get devApiUrl() {
|
|
70
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
71
|
+
return hubSpotData?.[DEV_API_URL] || "";
|
|
167
72
|
}
|
|
168
73
|
};
|
|
169
74
|
var setConfig = {
|
|
@@ -202,7 +107,7 @@ function replaceParams(template, values) {
|
|
|
202
107
|
);
|
|
203
108
|
}
|
|
204
109
|
|
|
205
|
-
// src/
|
|
110
|
+
// src/client/api-endpoints.ts
|
|
206
111
|
var API_ENDPOINTS = {
|
|
207
112
|
// Auth
|
|
208
113
|
PRE_LOGIN: "/api/auth/pre-login",
|
|
@@ -214,6 +119,7 @@ var API_ENDPOINTS = {
|
|
|
214
119
|
VERIFY_EMAIL: "/api/auth/verify-email",
|
|
215
120
|
REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
|
|
216
121
|
RESEND_EMAIL: "/api/auth/resend-email",
|
|
122
|
+
VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
|
|
217
123
|
LOGOUT: "/api/auth/logout",
|
|
218
124
|
// SSO
|
|
219
125
|
SSO_DETAILS: "/api/auth/sso/active",
|
|
@@ -224,51 +130,64 @@ var API_ENDPOINTS = {
|
|
|
224
130
|
PROFILE: "/api/${hubId}/${portalId}/profiles",
|
|
225
131
|
CHANGE_PASSWORD: "/api/auth/change-password",
|
|
226
132
|
// Pipeline
|
|
227
|
-
PIPELINES: "api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
133
|
+
PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
228
134
|
// Stage
|
|
229
|
-
STAGES: "api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
135
|
+
STAGES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
|
|
136
|
+
// Cache purge (replaces cache=false refresh; requires features.cache-purge-api-enabled on API)
|
|
137
|
+
CACHE_PURGE: "/api/${hubId}/${portalId}/cache-purge-jobs",
|
|
138
|
+
CACHE_PURGE_STATUS: "/api/${hubId}/${portalId}/cache-purge-jobs/${purgeJobId}",
|
|
139
|
+
/** @deprecated Use CACHE_PURGE */
|
|
140
|
+
CACHE_PURGE_LEGACY: "/api/${hubId}/${portalId}/cache/purge",
|
|
141
|
+
/** @deprecated Use CACHE_PURGE_STATUS */
|
|
142
|
+
CACHE_PURGE_STATUS_LEGACY: "/api/${hubId}/${portalId}/cache/purge/${purgeJobId}",
|
|
143
|
+
// Object (read on hubspot-object-data; form layout on hubspot-object-forms)
|
|
144
|
+
OBJECTS: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
|
|
145
|
+
OBJECTS_FORM: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
|
|
146
|
+
OBJECTS_FORM_OPTIONS: "/api/${hubId}/${portalId}/hubspot-object-forms/${formId}/${objectTypeId}",
|
|
147
|
+
RECORDS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
|
|
148
|
+
RECORDS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
|
|
149
|
+
RECORDS_ASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
|
|
150
|
+
RECORDS_DISASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
|
|
151
|
+
/** @deprecated Use RECORDS_CREATE */
|
|
152
|
+
OBJECTS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
|
|
153
|
+
/** @deprecated Use RECORDS_ASSOCIATE */
|
|
154
|
+
OBJECTS_CREATE_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-forms/:fromObjectTypeId/:fromRecordId/associations/:toObjectTypeId",
|
|
155
|
+
OBJECTS_DETAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
|
|
156
|
+
/** @deprecated Use RECORDS_UPDATE */
|
|
157
|
+
OBJECTS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/records/${id}",
|
|
158
|
+
OBJECTS_DETAILS_UPDATE_LEGACY: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/properties/${id}",
|
|
159
|
+
// Notes (nested under CRM record)
|
|
160
|
+
NOTES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
|
|
161
|
+
NOTES_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
|
|
162
|
+
NOTES_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/${note_id}",
|
|
163
|
+
NOTES_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/images",
|
|
164
|
+
NOTES_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments",
|
|
165
|
+
NOTES_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments/${note_id}",
|
|
166
|
+
// Email (nested under CRM record)
|
|
167
|
+
EMAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
|
|
168
|
+
EMAILS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
|
|
169
|
+
EMAILS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/${email_id}",
|
|
170
|
+
EMAILS_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/images",
|
|
171
|
+
EMAILS_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments",
|
|
172
|
+
EMAILS_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments/${email_id}",
|
|
173
|
+
// File manager (nested under CRM record)
|
|
174
|
+
FILES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files",
|
|
175
|
+
FILE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}",
|
|
176
|
+
FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
|
|
177
|
+
FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
|
|
257
178
|
};
|
|
258
|
-
init_token_store();
|
|
259
179
|
|
|
260
|
-
// src/
|
|
180
|
+
// src/client/config.ts
|
|
261
181
|
var config2 = {
|
|
262
182
|
baseURL: "https://api.dev.woodsportal.com"
|
|
263
183
|
};
|
|
264
184
|
|
|
265
|
-
// src/
|
|
266
|
-
init_auth_utils();
|
|
185
|
+
// src/client/http-clint.ts
|
|
267
186
|
var axiosInstance = null;
|
|
268
187
|
var config3 = {};
|
|
269
188
|
function initializeHttpClient(clientConfig) {
|
|
270
189
|
config3 = clientConfig;
|
|
271
|
-
const baseURL =
|
|
190
|
+
const baseURL = config?.devApiUrl || config3.baseURL;
|
|
272
191
|
const timeout = config3.timeout ?? 5e4;
|
|
273
192
|
axiosInstance = axios.create({
|
|
274
193
|
baseURL,
|
|
@@ -278,6 +197,7 @@ function initializeHttpClient(clientConfig) {
|
|
|
278
197
|
...config3.headers
|
|
279
198
|
}
|
|
280
199
|
});
|
|
200
|
+
setRefreshCallback(getAuthRefreshToken);
|
|
281
201
|
axiosInstance.interceptors.request.use((config4) => {
|
|
282
202
|
const token = getAccessToken();
|
|
283
203
|
if (token) {
|
|
@@ -304,6 +224,44 @@ function getAxiosInstance() {
|
|
|
304
224
|
}
|
|
305
225
|
return axiosInstance;
|
|
306
226
|
}
|
|
227
|
+
function formatBooleanSearchParam(key, value) {
|
|
228
|
+
return value ? `${key}:1` : `${key}:`;
|
|
229
|
+
}
|
|
230
|
+
var HttpClient = class {
|
|
231
|
+
static async get(url2, params) {
|
|
232
|
+
await ensureValidRefresh();
|
|
233
|
+
const response = await getAxiosInstance().get(url2, { params });
|
|
234
|
+
return response.data;
|
|
235
|
+
}
|
|
236
|
+
static async post(url2, data, options) {
|
|
237
|
+
await ensureValidRefresh();
|
|
238
|
+
const response = await getAxiosInstance().post(url2, data, options);
|
|
239
|
+
return response.data;
|
|
240
|
+
}
|
|
241
|
+
static async put(url2, data) {
|
|
242
|
+
await ensureValidRefresh();
|
|
243
|
+
const response = await getAxiosInstance().put(url2, data);
|
|
244
|
+
return response.data;
|
|
245
|
+
}
|
|
246
|
+
static async delete(url2, config4) {
|
|
247
|
+
await ensureValidRefresh();
|
|
248
|
+
const response = await getAxiosInstance().delete(url2, config4);
|
|
249
|
+
return response.data;
|
|
250
|
+
}
|
|
251
|
+
static formatSearchParams(params) {
|
|
252
|
+
return Object.entries(params).filter(([, value]) => Boolean(value)).map(
|
|
253
|
+
([k, v]) => [
|
|
254
|
+
"type",
|
|
255
|
+
"categories",
|
|
256
|
+
"tags",
|
|
257
|
+
"author",
|
|
258
|
+
"manufacturer",
|
|
259
|
+
"shops",
|
|
260
|
+
"refund_reason"
|
|
261
|
+
].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
|
|
262
|
+
).join(";");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
307
265
|
var AuthHttpClient = class {
|
|
308
266
|
static async get(url2, params) {
|
|
309
267
|
const response = await getAxiosInstance().get(url2, { params });
|
|
@@ -376,357 +334,38 @@ var setProfileData = (data) => {
|
|
|
376
334
|
var getProfileData = () => {
|
|
377
335
|
return PROFILE;
|
|
378
336
|
};
|
|
379
|
-
function convertToBase64(obj) {
|
|
380
|
-
try {
|
|
381
|
-
if (!obj) return "";
|
|
382
|
-
const json = JSON.stringify(obj);
|
|
383
|
-
const compressed = pako.deflate(json);
|
|
384
|
-
const base64 = Base64.fromUint8Array(compressed, true);
|
|
385
|
-
return base64;
|
|
386
|
-
} catch (error) {
|
|
387
|
-
console.error("Failed to encode object:", error);
|
|
388
|
-
return "";
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
function decodeToBase64(encoded) {
|
|
392
|
-
try {
|
|
393
|
-
if (!encoded) return null;
|
|
394
|
-
const uint8Array = Base64.toUint8Array(encoded);
|
|
395
|
-
const decompressed = pako.inflate(uint8Array, { to: "string" });
|
|
396
|
-
return JSON.parse(decompressed);
|
|
397
|
-
} catch (error) {
|
|
398
|
-
console.error("Failed to decode object:", error);
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
337
|
|
|
403
|
-
// src/
|
|
404
|
-
|
|
405
|
-
if (
|
|
406
|
-
return
|
|
407
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
408
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
409
|
-
const mappedKey = keyMap2[key] || key;
|
|
410
|
-
acc[mappedKey] = mapKeysDeep(value, keyMap2);
|
|
411
|
-
return acc;
|
|
412
|
-
}, {});
|
|
413
|
-
}
|
|
414
|
-
return obj;
|
|
415
|
-
}
|
|
416
|
-
function isMessingParent(breadcrumbs) {
|
|
417
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
418
|
-
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
419
|
-
let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
420
|
-
return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
|
|
421
|
-
}
|
|
422
|
-
function isMessingParentLastItem(breadcrumbs) {
|
|
423
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
424
|
-
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
425
|
-
return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
|
|
426
|
-
}
|
|
427
|
-
function breadcrumbStage(breadcrumbItems) {
|
|
428
|
-
let breadcrumbType = "child";
|
|
429
|
-
if (breadcrumbItems.length === 1) {
|
|
430
|
-
breadcrumbType = "root";
|
|
431
|
-
} else if (breadcrumbItems.length === 2) {
|
|
432
|
-
breadcrumbType = "root_details";
|
|
338
|
+
// src/client/index.ts
|
|
339
|
+
var recordWriteContext = (paramsObject) => {
|
|
340
|
+
if (!paramsObject) {
|
|
341
|
+
return void 0;
|
|
433
342
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
function getTotalParentLength(data) {
|
|
447
|
-
return data.filter(
|
|
448
|
-
(item) => (item.pt || item.o_t_id) && !item.o_r_id
|
|
449
|
-
).length;
|
|
450
|
-
}
|
|
451
|
-
var generatePath = (breadcrumbs, breadcrumb, index) => {
|
|
452
|
-
const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
|
|
453
|
-
if (index === 0) {
|
|
454
|
-
return {
|
|
455
|
-
name: breadcrumb?.n,
|
|
456
|
-
path: `/${breadcrumb?.pt || breadcrumb?.o_t_id}?b=${bc}`
|
|
457
|
-
};
|
|
458
|
-
} else if (index === 1) {
|
|
459
|
-
if (breadcrumb?.isHome) {
|
|
460
|
-
return {
|
|
461
|
-
name: breadcrumb?.n,
|
|
462
|
-
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
return {
|
|
466
|
-
name: breadcrumb?.n,
|
|
467
|
-
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
468
|
-
};
|
|
469
|
-
} else {
|
|
470
|
-
if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
|
|
471
|
-
return {
|
|
472
|
-
name: breadcrumb?.n,
|
|
473
|
-
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
474
|
-
};
|
|
475
|
-
} else {
|
|
476
|
-
return {
|
|
477
|
-
name: breadcrumb?.n,
|
|
478
|
-
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
479
|
-
};
|
|
343
|
+
const context = {};
|
|
344
|
+
const keys = [
|
|
345
|
+
"parentObjectTypeId",
|
|
346
|
+
"parentObjectRecordId",
|
|
347
|
+
"mediatorObjectTypeId",
|
|
348
|
+
"mediatorObjectRecordId"
|
|
349
|
+
];
|
|
350
|
+
keys.forEach((key) => {
|
|
351
|
+
const value = paramsObject[key];
|
|
352
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
353
|
+
context[key] = String(value);
|
|
480
354
|
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
// src/breadcrumb/key-map.ts
|
|
485
|
-
var keyMap = {
|
|
486
|
-
dp: "defPermissions",
|
|
487
|
-
n: "name",
|
|
488
|
-
sort: "sort",
|
|
489
|
-
o_t_id: "objectTypeId",
|
|
490
|
-
s: "search",
|
|
491
|
-
fPn: "filterPropertyName",
|
|
492
|
-
fO: "filterOperator",
|
|
493
|
-
fV: "filterValue",
|
|
494
|
-
c: "cache",
|
|
495
|
-
isPC: "isPrimaryCompany",
|
|
496
|
-
v: "view",
|
|
497
|
-
l: "limit",
|
|
498
|
-
pt: "path",
|
|
499
|
-
p: "page",
|
|
500
|
-
a: "after",
|
|
501
|
-
aPip: "activePipeline",
|
|
502
|
-
aT: "activeTab",
|
|
503
|
-
cT: "create",
|
|
504
|
-
dP: "display",
|
|
505
|
-
dL: "display_label",
|
|
506
|
-
pId: "pipeline_id"
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// src/utils/param.ts
|
|
510
|
-
function getParam(paramName) {
|
|
511
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
512
|
-
const hash = globalThis.location.hash || "";
|
|
513
|
-
if (!hash.startsWith("#/")) return null;
|
|
514
|
-
const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
|
|
515
|
-
const queryString = hashWithoutHash.split("?")[1];
|
|
516
|
-
if (!queryString) return null;
|
|
517
|
-
const params = new URLSearchParams(queryString);
|
|
518
|
-
return params.get(paramName);
|
|
519
|
-
}
|
|
520
|
-
function getPath() {
|
|
521
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
522
|
-
const hash = globalThis.location.hash || "";
|
|
523
|
-
if (!hash.startsWith("#/")) return null;
|
|
524
|
-
return hash.slice(1).split("?")[0];
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// src/breadcrumb/param.ts
|
|
528
|
-
var getRouteMenu = (path) => {
|
|
529
|
-
const apiRoutes = globalThis?.apiRoutes || [];
|
|
530
|
-
return apiRoutes.find((menu) => menu?.path === path);
|
|
531
|
-
};
|
|
532
|
-
var getRouteDetails = () => {
|
|
533
|
-
const search = getParam("b");
|
|
534
|
-
const breadcrumbs = decodeToBase64(search) || [];
|
|
535
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
536
|
-
const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
|
|
537
|
-
return { routeDetails: mapped };
|
|
355
|
+
});
|
|
356
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
538
357
|
};
|
|
539
|
-
var
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
if (
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
let mediatorObjectTypeId = "";
|
|
546
|
-
let mediatorObjectRecordId = "";
|
|
547
|
-
let parentObjectTypeId = "";
|
|
548
|
-
let parentObjectRecordId = "";
|
|
549
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
550
|
-
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
551
|
-
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
552
|
-
if (isDetailsPage === true && lastItem && "prm" in lastItem) {
|
|
553
|
-
delete lastItem.prm;
|
|
554
|
-
}
|
|
555
|
-
if (breadcrumbs.length > 1) {
|
|
556
|
-
if (props?.type === "ticket" || props?.type === "association") {
|
|
557
|
-
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
558
|
-
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
559
|
-
parentObjectTypeId = lastItem?.o_t_id || "";
|
|
560
|
-
parentObjectRecordId = lastItem?.o_r_id || "";
|
|
561
|
-
} else {
|
|
562
|
-
if (breadcrumbs.length > 2) {
|
|
563
|
-
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
564
|
-
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
565
|
-
}
|
|
566
|
-
if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
567
|
-
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
568
|
-
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
569
|
-
}
|
|
570
|
-
if (lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
571
|
-
parentObjectTypeId = lastItem3?.o_t_id || "";
|
|
572
|
-
parentObjectRecordId = lastItem3?.o_r_id || "";
|
|
573
|
-
}
|
|
574
|
-
if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
|
|
575
|
-
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
576
|
-
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
let paramsObject = {};
|
|
581
|
-
if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
|
|
582
|
-
paramsObject["isPrimaryCompany"] = true;
|
|
358
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
359
|
+
const base = { ...payload || {} };
|
|
360
|
+
const context = recordWriteContext(paramsObject);
|
|
361
|
+
if (context) {
|
|
362
|
+
base.context = context;
|
|
583
363
|
}
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
paramsObject["parentObjectRecordId"] = parentObjectRecordId;
|
|
587
|
-
}
|
|
588
|
-
if (mediatorObjectTypeId && mediatorObjectRecordId) {
|
|
589
|
-
paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
|
|
590
|
-
paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
|
|
591
|
-
}
|
|
592
|
-
const mappedLastItemParam = Object.fromEntries(
|
|
593
|
-
Object.entries(lastItem?.prm || {}).map(([key, value]) => [
|
|
594
|
-
keyMap[key] || key,
|
|
595
|
-
// use mapped name if exists, else keep original
|
|
596
|
-
value
|
|
597
|
-
])
|
|
598
|
-
);
|
|
599
|
-
let queryString = null;
|
|
600
|
-
if (props?.type === "association") {
|
|
601
|
-
queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
|
|
602
|
-
} else {
|
|
603
|
-
queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
|
|
364
|
+
if (options && Object.keys(options).length > 0) {
|
|
365
|
+
base.options = options;
|
|
604
366
|
}
|
|
605
|
-
|
|
606
|
-
const totalParentLength = getTotalParentLength(breadcrumbs);
|
|
607
|
-
let parentAccessLabel = false;
|
|
608
|
-
if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
|
|
609
|
-
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
|
|
610
|
-
breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
|
|
611
|
-
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
|
|
612
|
-
parentAccessLabel = true;
|
|
613
|
-
}
|
|
614
|
-
return {
|
|
615
|
-
breadcrumbs,
|
|
616
|
-
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
617
|
-
paramsObject,
|
|
618
|
-
params,
|
|
619
|
-
parentAccessLabel
|
|
620
|
-
};
|
|
367
|
+
return base;
|
|
621
368
|
};
|
|
622
|
-
|
|
623
|
-
// src/clint/index.ts
|
|
624
|
-
init_auth_utils();
|
|
625
|
-
|
|
626
|
-
// src/breadcrumb/url.ts
|
|
627
|
-
var useUpdateLink = () => {
|
|
628
|
-
const updateLink = async (props, displayName = "prm") => {
|
|
629
|
-
const search = getParam("b");
|
|
630
|
-
const pathname = getPath();
|
|
631
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
632
|
-
if (breadcrumbs.length < 1) {
|
|
633
|
-
const routeMenu = getRouteMenu(pathname);
|
|
634
|
-
breadcrumbs = [
|
|
635
|
-
{
|
|
636
|
-
n: routeMenu?.title,
|
|
637
|
-
pt: routeMenu?.path
|
|
638
|
-
}
|
|
639
|
-
];
|
|
640
|
-
}
|
|
641
|
-
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
642
|
-
let udatedBreadcrumb = null;
|
|
643
|
-
if (displayName) {
|
|
644
|
-
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
645
|
-
udatedBreadcrumb = await setDeep(lastBreadcrumb, displayName, {
|
|
646
|
-
...ex,
|
|
647
|
-
...props
|
|
648
|
-
});
|
|
649
|
-
} else {
|
|
650
|
-
udatedBreadcrumb = Object.assign(lastBreadcrumb, props);
|
|
651
|
-
}
|
|
652
|
-
breadcrumbs[breadcrumbs.length - 1] = udatedBreadcrumb;
|
|
653
|
-
const newBase64 = convertToBase64(breadcrumbs);
|
|
654
|
-
updateBParam(newBase64);
|
|
655
|
-
};
|
|
656
|
-
function setDeep(obj, path, value) {
|
|
657
|
-
const keys = path.split(".");
|
|
658
|
-
let curr = obj;
|
|
659
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
660
|
-
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
661
|
-
curr[keys[i]] = {};
|
|
662
|
-
}
|
|
663
|
-
curr = curr[keys[i]];
|
|
664
|
-
}
|
|
665
|
-
curr[keys[keys.length - 1]] = value;
|
|
666
|
-
return curr;
|
|
667
|
-
}
|
|
668
|
-
function getDeep(obj, path) {
|
|
669
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
670
|
-
}
|
|
671
|
-
const getLinkParams = (displayName = "prm") => {
|
|
672
|
-
const search = getParam("b");
|
|
673
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
674
|
-
if (breadcrumbs.length < 1) return null;
|
|
675
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
676
|
-
const getDeep2 = (obj, path) => {
|
|
677
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
678
|
-
};
|
|
679
|
-
const expandKeys = (obj) => {
|
|
680
|
-
return Object.fromEntries(
|
|
681
|
-
Object.entries(obj).map(([key, value]) => [
|
|
682
|
-
keyMap[key] || key,
|
|
683
|
-
// map if exists, else keep original
|
|
684
|
-
value
|
|
685
|
-
])
|
|
686
|
-
);
|
|
687
|
-
};
|
|
688
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
689
|
-
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
690
|
-
return output;
|
|
691
|
-
};
|
|
692
|
-
const filterParams = (displayName = "prm") => {
|
|
693
|
-
const search = getParam("b");
|
|
694
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
695
|
-
if (breadcrumbs.length < 1) return null;
|
|
696
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
697
|
-
const getDeep2 = (obj, path) => {
|
|
698
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
699
|
-
};
|
|
700
|
-
const expandKeys = (obj) => {
|
|
701
|
-
return Object.fromEntries(
|
|
702
|
-
Object.entries(obj).map(([key, value]) => [
|
|
703
|
-
keyMap[key] || key,
|
|
704
|
-
// map if exists, else keep original
|
|
705
|
-
value
|
|
706
|
-
])
|
|
707
|
-
);
|
|
708
|
-
};
|
|
709
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
710
|
-
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
711
|
-
return output;
|
|
712
|
-
};
|
|
713
|
-
return { updateLink, getLinkParams, filterParams };
|
|
714
|
-
};
|
|
715
|
-
var updateBParam = (newValue) => {
|
|
716
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
717
|
-
const hash = globalThis.location.hash || "";
|
|
718
|
-
if (!hash.startsWith("#/")) return;
|
|
719
|
-
const withoutHash = hash.slice(2);
|
|
720
|
-
const [path, queryString] = withoutHash.split("?");
|
|
721
|
-
const params = new URLSearchParams(queryString || "");
|
|
722
|
-
params.set("b", newValue);
|
|
723
|
-
const newHash = `#/${path}?${params.toString()}`;
|
|
724
|
-
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
725
|
-
globalThis.history.replaceState(null, "", newHash);
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
|
|
729
|
-
// src/clint/index.ts
|
|
730
369
|
var Client = {
|
|
731
370
|
authentication: {
|
|
732
371
|
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
@@ -746,10 +385,10 @@ var Client = {
|
|
|
746
385
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
747
386
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
748
387
|
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
749
|
-
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data),
|
|
750
|
-
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.
|
|
388
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
389
|
+
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
|
|
751
390
|
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
752
|
-
logout: () =>
|
|
391
|
+
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
753
392
|
},
|
|
754
393
|
sso: {
|
|
755
394
|
getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
|
|
@@ -757,9 +396,9 @@ var Client = {
|
|
|
757
396
|
ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
|
|
758
397
|
},
|
|
759
398
|
user: {
|
|
760
|
-
me: () =>
|
|
761
|
-
profile: (payload) =>
|
|
762
|
-
changePassword: (data) =>
|
|
399
|
+
me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
|
|
400
|
+
profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
|
|
401
|
+
changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
|
|
763
402
|
},
|
|
764
403
|
pipeline: {
|
|
765
404
|
list: (payload = null, param = null) => {
|
|
@@ -776,26 +415,26 @@ var Client = {
|
|
|
776
415
|
apiParams.parentObjectTypeId = "0-2";
|
|
777
416
|
}
|
|
778
417
|
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
779
|
-
apiParams.cache = payload?.
|
|
418
|
+
apiParams.cache = payload?.cache;
|
|
780
419
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
781
|
-
return
|
|
420
|
+
return HttpClient.get(apiUrl);
|
|
782
421
|
}
|
|
783
422
|
},
|
|
784
423
|
stage: {
|
|
785
424
|
list: (props = null) => {
|
|
786
|
-
const portalId = config.devPortalId;
|
|
787
425
|
const params = {
|
|
788
|
-
hubId: config.hubId,
|
|
789
|
-
portalId,
|
|
426
|
+
// hubId: config.hubId,
|
|
427
|
+
// portalId: portalId,
|
|
790
428
|
objectTypeId: props?.params?.objectTypeId,
|
|
791
429
|
pipelineId: props?.params?.pipelineId
|
|
792
430
|
};
|
|
793
431
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
|
|
794
|
-
return
|
|
432
|
+
return HttpClient.get(apiUrl);
|
|
795
433
|
}
|
|
796
434
|
},
|
|
797
435
|
object: {
|
|
798
436
|
list: async (payload = null, param = null) => {
|
|
437
|
+
param.cache = payload.cache;
|
|
799
438
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
800
439
|
const { updateLink, getLinkParams } = useUpdateLink();
|
|
801
440
|
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
@@ -850,46 +489,81 @@ var Client = {
|
|
|
850
489
|
param.parentObjectTypeId = parentObjectTypeId;
|
|
851
490
|
}
|
|
852
491
|
param.parentAccessLabel = parentAccessLabel;
|
|
492
|
+
const {
|
|
493
|
+
stageId,
|
|
494
|
+
nextPage
|
|
495
|
+
} = useTable();
|
|
496
|
+
if (stageId) {
|
|
497
|
+
param.stageId = stageId;
|
|
498
|
+
}
|
|
499
|
+
if (param?.view === "BOARD") {
|
|
500
|
+
param.page = nextPage;
|
|
501
|
+
}
|
|
853
502
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
854
|
-
return
|
|
503
|
+
return HttpClient.get(apiUrl);
|
|
504
|
+
},
|
|
505
|
+
sideBarList: async (payload = null) => {
|
|
506
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
507
|
+
const params = { hubspotObjectTypeId };
|
|
508
|
+
const queryParams = payload.param;
|
|
509
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
|
|
510
|
+
return HttpClient.get(apiUrl);
|
|
855
511
|
},
|
|
856
512
|
form: (payload = null) => {
|
|
857
513
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
858
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
859
|
-
return
|
|
514
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
515
|
+
return HttpClient.get(apiUrl);
|
|
860
516
|
},
|
|
861
517
|
objectFormOptions: (payload = null) => {
|
|
862
|
-
const params = {
|
|
518
|
+
const params = {
|
|
519
|
+
formId: payload?.formId,
|
|
520
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
521
|
+
};
|
|
863
522
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
864
|
-
return
|
|
523
|
+
return HttpClient.get(apiUrl);
|
|
865
524
|
},
|
|
866
525
|
create: (props = null) => {
|
|
526
|
+
const { getParamDetails: getParamDetailsForCreate } = routeParam;
|
|
527
|
+
const { paramsObject } = getParamDetailsForCreate({ type: props?.componentName });
|
|
528
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
529
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, {
|
|
530
|
+
cardParentMerge,
|
|
531
|
+
addAnother: props?.params?.addAnother
|
|
532
|
+
});
|
|
867
533
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE, params, queryParams });
|
|
871
|
-
return AuthHttpClient.post(apiUrl, payload);
|
|
534
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
535
|
+
return HttpClient.post(apiUrl, body);
|
|
872
536
|
},
|
|
873
537
|
createExisting: (props = null) => {
|
|
874
|
-
const
|
|
875
|
-
const
|
|
538
|
+
const { getLinkParams } = useUpdateLink();
|
|
539
|
+
const fParams = getLinkParams();
|
|
540
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
541
|
+
const params = {
|
|
542
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
543
|
+
fromRecordId: props?.fromRecordId,
|
|
544
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
545
|
+
};
|
|
876
546
|
const payload = props.payload;
|
|
877
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
878
|
-
return
|
|
547
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
548
|
+
return HttpClient.post(apiUrl, payload);
|
|
879
549
|
},
|
|
880
550
|
removeExisting: (props = null) => {
|
|
881
|
-
const
|
|
882
|
-
const
|
|
883
|
-
const
|
|
884
|
-
const
|
|
885
|
-
|
|
551
|
+
const { getParamDetails: getParamDetailsForRemove } = routeParam;
|
|
552
|
+
const { paramsObject } = getParamDetailsForRemove({ type: props?.componentName });
|
|
553
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
|
|
554
|
+
const params = {
|
|
555
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
556
|
+
fromRecordId: props?.fromRecordId,
|
|
557
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
558
|
+
};
|
|
559
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
|
|
560
|
+
return HttpClient.delete(apiUrl, { data: body });
|
|
886
561
|
},
|
|
887
562
|
details: (props = null) => {
|
|
888
563
|
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
889
|
-
const portalId = config.devPortalId;
|
|
890
564
|
const params = {
|
|
891
|
-
hubId: config.hubId,
|
|
892
|
-
portalId,
|
|
565
|
+
// hubId: config.hubId,
|
|
566
|
+
// portalId: portalId,
|
|
893
567
|
objectId: props?.params?.objectId,
|
|
894
568
|
id: props?.params?.id
|
|
895
569
|
};
|
|
@@ -899,52 +573,56 @@ var Client = {
|
|
|
899
573
|
...urlParam
|
|
900
574
|
};
|
|
901
575
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
|
|
902
|
-
return
|
|
576
|
+
return HttpClient.get(apiUrl);
|
|
903
577
|
},
|
|
904
578
|
update: (props = null) => {
|
|
905
|
-
const portalId = getPortal()?.portalId;
|
|
906
579
|
const params = {
|
|
907
|
-
hubId: config.hubId,
|
|
908
|
-
portalId,
|
|
909
580
|
objectId: props?.params?.objectId,
|
|
910
581
|
id: props?.params?.id
|
|
911
582
|
};
|
|
912
|
-
const {
|
|
913
|
-
const
|
|
914
|
-
|
|
583
|
+
const { getParamDetails: getParamDetailsForUpdate } = routeParam;
|
|
584
|
+
const { paramsObject } = getParamDetailsForUpdate({ type: props?.componentName });
|
|
585
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
586
|
+
const rawPayload = props?.payload || {};
|
|
587
|
+
const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
|
|
588
|
+
const body = mergeRecordWriteBody(
|
|
589
|
+
{ properties },
|
|
590
|
+
paramsObject,
|
|
591
|
+
{ cardParentMerge }
|
|
592
|
+
);
|
|
593
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params });
|
|
594
|
+
return HttpClient.put(apiUrl, body);
|
|
915
595
|
}
|
|
916
596
|
},
|
|
917
597
|
note: {
|
|
918
598
|
list: (props = null) => {
|
|
919
|
-
const portalId = getPortal()?.portalId;
|
|
920
599
|
const params = {
|
|
921
|
-
hubId: config.hubId,
|
|
922
|
-
portalId,
|
|
600
|
+
// hubId: config.hubId,
|
|
601
|
+
// portalId: portalId,
|
|
923
602
|
objectId: props?.params?.objectId,
|
|
924
603
|
id: props?.params?.id
|
|
925
604
|
};
|
|
926
605
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
|
|
927
|
-
return
|
|
606
|
+
return HttpClient.get(apiUrl);
|
|
928
607
|
},
|
|
929
608
|
create: (props = null) => {
|
|
930
609
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
931
610
|
const queryParams = props.queryParams;
|
|
932
611
|
const payload = props.payload;
|
|
933
612
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
|
|
934
|
-
return
|
|
613
|
+
return HttpClient.post(apiUrl, payload);
|
|
935
614
|
},
|
|
936
615
|
update: (props = null) => {
|
|
937
|
-
const portalId = getPortal()?.portalId;
|
|
938
616
|
const params = {
|
|
939
|
-
hubId: config.hubId,
|
|
940
|
-
portalId,
|
|
617
|
+
// hubId: config.hubId,
|
|
618
|
+
// portalId: portalId,
|
|
941
619
|
objectId: props?.params?.objectId,
|
|
942
620
|
id: props?.params?.id,
|
|
943
621
|
note_id: props?.params?.note_id
|
|
944
622
|
};
|
|
945
623
|
const { paramsObject: queryParams } = getParamDetails();
|
|
946
624
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
|
|
947
|
-
return
|
|
625
|
+
return HttpClient.put(apiUrl, props.payload);
|
|
948
626
|
},
|
|
949
627
|
image: (props = null) => {
|
|
950
628
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -952,7 +630,7 @@ var Client = {
|
|
|
952
630
|
const payload = props.payload;
|
|
953
631
|
const axiosConfig = props.config || {};
|
|
954
632
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
|
|
955
|
-
return
|
|
633
|
+
return HttpClient.post(apiUrl, payload, {
|
|
956
634
|
headers: {
|
|
957
635
|
"Content-Type": "multipart/form-data"
|
|
958
636
|
},
|
|
@@ -965,7 +643,7 @@ var Client = {
|
|
|
965
643
|
const payload = props.payload;
|
|
966
644
|
const axiosConfig = props.config || {};
|
|
967
645
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
|
|
968
|
-
return
|
|
646
|
+
return HttpClient.post(apiUrl, payload, {
|
|
969
647
|
headers: {
|
|
970
648
|
"Content-Type": "multipart/form-data"
|
|
971
649
|
},
|
|
@@ -975,35 +653,33 @@ var Client = {
|
|
|
975
653
|
},
|
|
976
654
|
email: {
|
|
977
655
|
list: (props = null) => {
|
|
978
|
-
const portalId = getPortal()?.portalId;
|
|
979
656
|
const params = {
|
|
980
|
-
hubId: config.hubId,
|
|
981
|
-
portalId,
|
|
657
|
+
// hubId: config.hubId,
|
|
658
|
+
// portalId: portalId,
|
|
982
659
|
objectId: props?.params?.objectId,
|
|
983
660
|
id: props?.params?.id
|
|
984
661
|
};
|
|
985
662
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
|
|
986
|
-
return
|
|
663
|
+
return HttpClient.get(apiUrl);
|
|
987
664
|
},
|
|
988
665
|
create: (props = null) => {
|
|
989
666
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
990
667
|
const queryParams = props.queryParams;
|
|
991
668
|
const payload = props.payload;
|
|
992
669
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
|
|
993
|
-
return
|
|
670
|
+
return HttpClient.post(apiUrl, payload);
|
|
994
671
|
},
|
|
995
672
|
update: (props = null) => {
|
|
996
|
-
const portalId = getPortal()?.portalId;
|
|
997
673
|
const params = {
|
|
998
|
-
hubId: config.hubId,
|
|
999
|
-
portalId,
|
|
674
|
+
// hubId: config.hubId,
|
|
675
|
+
// portalId: portalId,
|
|
1000
676
|
objectId: props?.params?.objectId,
|
|
1001
677
|
id: props?.params?.id,
|
|
1002
|
-
|
|
678
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
1003
679
|
};
|
|
1004
680
|
const { paramsObject: queryParams } = getParamDetails();
|
|
1005
681
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
1006
|
-
return
|
|
682
|
+
return HttpClient.put(apiUrl, props.payload);
|
|
1007
683
|
},
|
|
1008
684
|
image: (props = null) => {
|
|
1009
685
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -1011,7 +687,7 @@ var Client = {
|
|
|
1011
687
|
const payload = props.payload;
|
|
1012
688
|
const axiosConfig = props.config || {};
|
|
1013
689
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
|
|
1014
|
-
return
|
|
690
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1015
691
|
headers: {
|
|
1016
692
|
"Content-Type": "multipart/form-data"
|
|
1017
693
|
},
|
|
@@ -1024,7 +700,7 @@ var Client = {
|
|
|
1024
700
|
const payload = props.payload;
|
|
1025
701
|
const axiosConfig = props.config || {};
|
|
1026
702
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
|
|
1027
|
-
return
|
|
703
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1028
704
|
headers: {
|
|
1029
705
|
"Content-Type": "multipart/form-data"
|
|
1030
706
|
},
|
|
@@ -1032,36 +708,49 @@ var Client = {
|
|
|
1032
708
|
});
|
|
1033
709
|
}
|
|
1034
710
|
},
|
|
711
|
+
cache: {
|
|
712
|
+
purge: (body, headers) => {
|
|
713
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
|
|
714
|
+
return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
|
|
715
|
+
},
|
|
716
|
+
purgeStatus: (purgeJobId) => {
|
|
717
|
+
const apiUrl = generateApiUrl({
|
|
718
|
+
route: API_ENDPOINTS.CACHE_PURGE_STATUS,
|
|
719
|
+
params: { purgeJobId }
|
|
720
|
+
});
|
|
721
|
+
return HttpClient.get(apiUrl);
|
|
722
|
+
}
|
|
723
|
+
},
|
|
1035
724
|
file: {
|
|
1036
725
|
list: (props = null) => {
|
|
1037
|
-
const portalId = getPortal()?.portalId;
|
|
1038
726
|
const params = {
|
|
1039
|
-
hubId: config.hubId,
|
|
1040
|
-
portalId,
|
|
727
|
+
// hubId: config.hubId,
|
|
728
|
+
// portalId: portalId,
|
|
1041
729
|
objectId: props?.params?.objectId,
|
|
1042
730
|
id: props?.params?.id
|
|
1043
731
|
};
|
|
732
|
+
console.log("params_0", params);
|
|
1044
733
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
|
|
1045
|
-
return
|
|
734
|
+
return HttpClient.get(apiUrl);
|
|
1046
735
|
},
|
|
1047
736
|
details: (props = null) => {
|
|
1048
|
-
const portalId = getPortal()?.portalId;
|
|
1049
737
|
const params = {
|
|
1050
|
-
hubId: config.hubId,
|
|
1051
|
-
portalId,
|
|
738
|
+
// hubId: config.hubId,
|
|
739
|
+
// portalId: portalId,
|
|
1052
740
|
objectId: props?.params?.objectId,
|
|
1053
741
|
id: props?.params?.id,
|
|
1054
742
|
rowId: props?.params?.rowId
|
|
1055
743
|
};
|
|
744
|
+
console.log("params_1", params);
|
|
1056
745
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
1057
|
-
return
|
|
746
|
+
return HttpClient.get(apiUrl);
|
|
1058
747
|
},
|
|
1059
748
|
addFolder: (props = null) => {
|
|
1060
749
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1061
750
|
const queryParams = props.queryParams;
|
|
1062
751
|
const payload = props.payload;
|
|
1063
752
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
|
|
1064
|
-
return
|
|
753
|
+
return HttpClient.post(apiUrl, payload);
|
|
1065
754
|
},
|
|
1066
755
|
addFile: (props = null) => {
|
|
1067
756
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -1069,7 +758,7 @@ var Client = {
|
|
|
1069
758
|
const payload = props.payload;
|
|
1070
759
|
const axiosConfig = props.config || {};
|
|
1071
760
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
|
|
1072
|
-
return
|
|
761
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1073
762
|
headers: {
|
|
1074
763
|
"Content-Type": "multipart/form-data"
|
|
1075
764
|
},
|
|
@@ -1111,9 +800,6 @@ function createMutation(mutationFn, options) {
|
|
|
1111
800
|
}
|
|
1112
801
|
|
|
1113
802
|
// src/apis/authentication.ts
|
|
1114
|
-
init_auth_utils();
|
|
1115
|
-
init_cookie();
|
|
1116
|
-
init_token_store();
|
|
1117
803
|
function preLogin(options) {
|
|
1118
804
|
const { mutate, isLoading } = createMutation(
|
|
1119
805
|
async (payload) => {
|
|
@@ -1367,242 +1053,6 @@ function changePassword(options) {
|
|
|
1367
1053
|
};
|
|
1368
1054
|
}
|
|
1369
1055
|
|
|
1370
|
-
// src/store/index.ts
|
|
1371
|
-
function createStore(initializer) {
|
|
1372
|
-
let state;
|
|
1373
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1374
|
-
const get = () => state;
|
|
1375
|
-
const set = (partial) => {
|
|
1376
|
-
const prevState = state;
|
|
1377
|
-
const partialState = typeof partial === "function" ? partial(state) : partial;
|
|
1378
|
-
state = {
|
|
1379
|
-
...state,
|
|
1380
|
-
...partialState
|
|
1381
|
-
};
|
|
1382
|
-
listeners.forEach(
|
|
1383
|
-
(listener) => listener(state, prevState)
|
|
1384
|
-
);
|
|
1385
|
-
};
|
|
1386
|
-
const subscribe = (listener) => {
|
|
1387
|
-
listeners.add(listener);
|
|
1388
|
-
return () => listeners.delete(listener);
|
|
1389
|
-
};
|
|
1390
|
-
state = initializer(set, get);
|
|
1391
|
-
return {
|
|
1392
|
-
getState: get,
|
|
1393
|
-
setState: set,
|
|
1394
|
-
subscribe
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
// src/utils/getCookieData.ts
|
|
1399
|
-
init_cookie();
|
|
1400
|
-
var getAuthSubscriptionType = () => {
|
|
1401
|
-
return getCookie("subscriptionType");
|
|
1402
|
-
};
|
|
1403
|
-
|
|
1404
|
-
// src/store/use-table.ts
|
|
1405
|
-
var pageLimit = 10;
|
|
1406
|
-
var tableStore = createStore((set, get) => ({
|
|
1407
|
-
// ==============================
|
|
1408
|
-
// STATE
|
|
1409
|
-
// ==============================
|
|
1410
|
-
tableUniqueId: null,
|
|
1411
|
-
gridData: [],
|
|
1412
|
-
sort: "-hs_createdate",
|
|
1413
|
-
limit: 10,
|
|
1414
|
-
after: "",
|
|
1415
|
-
page: 1,
|
|
1416
|
-
totalItems: 1,
|
|
1417
|
-
numOfPages: 1,
|
|
1418
|
-
currentPage: 1,
|
|
1419
|
-
search: "",
|
|
1420
|
-
filterPropertyName: "hs_pipeline",
|
|
1421
|
-
filterOperator: "eq",
|
|
1422
|
-
filterValue: "",
|
|
1423
|
-
isPrimaryCompany: null,
|
|
1424
|
-
view: null,
|
|
1425
|
-
selectedPipeline: "",
|
|
1426
|
-
tableParam: {},
|
|
1427
|
-
tableDefPermissions: {},
|
|
1428
|
-
// ==============================
|
|
1429
|
-
// BASIC SETTERS
|
|
1430
|
-
// ==============================
|
|
1431
|
-
setTableUniqueId: (v) => set({ tableUniqueId: v }),
|
|
1432
|
-
setSort: (v) => set({ sort: v }),
|
|
1433
|
-
setLimit: (v) => set({ limit: v }),
|
|
1434
|
-
setAfter: (v) => set({ after: v }),
|
|
1435
|
-
setPage: (v) => set({ page: v }),
|
|
1436
|
-
setTotalItems: (v) => set({ totalItems: v }),
|
|
1437
|
-
setNumOfPages: (v) => set({ numOfPages: v }),
|
|
1438
|
-
setCurrentPage: (v) => set({ currentPage: v }),
|
|
1439
|
-
setSearch: (v) => set({ search: v }),
|
|
1440
|
-
setFilterPropertyName: (v) => set({ filterPropertyName: v }),
|
|
1441
|
-
setFilterOperator: (v) => set({ filterOperator: v }),
|
|
1442
|
-
setFilterValue: (v) => set({ filterValue: v }),
|
|
1443
|
-
setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
|
|
1444
|
-
// ==============================
|
|
1445
|
-
// VIEW
|
|
1446
|
-
// ==============================
|
|
1447
|
-
setView: (mView) => {
|
|
1448
|
-
set({
|
|
1449
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1450
|
-
view: mView
|
|
1451
|
-
});
|
|
1452
|
-
},
|
|
1453
|
-
// ==============================
|
|
1454
|
-
// PIPELINE
|
|
1455
|
-
// ==============================
|
|
1456
|
-
changePipeline: (mView) => {
|
|
1457
|
-
set({
|
|
1458
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1459
|
-
selectedPipeline: mView || ""
|
|
1460
|
-
});
|
|
1461
|
-
},
|
|
1462
|
-
setSelectedPipeline: (pipelines, pipeLineId) => {
|
|
1463
|
-
let filterValue = "";
|
|
1464
|
-
if (pipeLineId) {
|
|
1465
|
-
const pipelineSingle = pipelines.find(
|
|
1466
|
-
(pipeline) => pipeline.pipelineId === pipeLineId
|
|
1467
|
-
);
|
|
1468
|
-
filterValue = pipelineSingle?.pipelineId || "";
|
|
1469
|
-
}
|
|
1470
|
-
set({
|
|
1471
|
-
filterPropertyName: "hs_pipeline",
|
|
1472
|
-
filterOperator: "eq",
|
|
1473
|
-
filterValue,
|
|
1474
|
-
selectedPipeline: filterValue
|
|
1475
|
-
});
|
|
1476
|
-
},
|
|
1477
|
-
// ==============================
|
|
1478
|
-
// RESET
|
|
1479
|
-
// ==============================
|
|
1480
|
-
resetTableParam: () => {
|
|
1481
|
-
set({
|
|
1482
|
-
sort: "-hs_createdate",
|
|
1483
|
-
limit: pageLimit,
|
|
1484
|
-
after: "",
|
|
1485
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1486
|
-
totalItems: 1,
|
|
1487
|
-
numOfPages: 1,
|
|
1488
|
-
currentPage: 1,
|
|
1489
|
-
search: "",
|
|
1490
|
-
filterPropertyName: "hs_pipeline",
|
|
1491
|
-
filterOperator: "eq",
|
|
1492
|
-
filterValue: "",
|
|
1493
|
-
isPrimaryCompany: null,
|
|
1494
|
-
selectedPipeline: ""
|
|
1495
|
-
});
|
|
1496
|
-
},
|
|
1497
|
-
// ==============================
|
|
1498
|
-
// PARAM BUILDER
|
|
1499
|
-
// ==============================
|
|
1500
|
-
getTableParam: (companyAsMediator, currentPageOverride) => {
|
|
1501
|
-
const state = get();
|
|
1502
|
-
const baseParams = {
|
|
1503
|
-
sort: state.sort,
|
|
1504
|
-
search: state.search,
|
|
1505
|
-
filterPropertyName: state.filterPropertyName,
|
|
1506
|
-
filterOperator: state.filterOperator,
|
|
1507
|
-
filterValue: state.selectedPipeline,
|
|
1508
|
-
cache: true,
|
|
1509
|
-
isPrimaryCompany: companyAsMediator || false,
|
|
1510
|
-
view: state.view
|
|
1511
|
-
};
|
|
1512
|
-
if (getAuthSubscriptionType() === "FREE") {
|
|
1513
|
-
return {
|
|
1514
|
-
...baseParams,
|
|
1515
|
-
after: state.page
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
return {
|
|
1519
|
-
...baseParams,
|
|
1520
|
-
limit: state.limit,
|
|
1521
|
-
page: currentPageOverride || state.page,
|
|
1522
|
-
...state.after && {
|
|
1523
|
-
after: state.after
|
|
1524
|
-
}
|
|
1525
|
-
};
|
|
1526
|
-
},
|
|
1527
|
-
// ==============================
|
|
1528
|
-
// GRID DATA
|
|
1529
|
-
// ==============================
|
|
1530
|
-
setGridData: async (type, deals) => {
|
|
1531
|
-
if (type === "reset") {
|
|
1532
|
-
set({ gridData: [] });
|
|
1533
|
-
return;
|
|
1534
|
-
}
|
|
1535
|
-
if (type === "directly") {
|
|
1536
|
-
set({ gridData: deals });
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
const finalData = await deals.map(
|
|
1540
|
-
(deal) => {
|
|
1541
|
-
const cards = deal?.data?.results?.rows?.map(
|
|
1542
|
-
(row) => ({
|
|
1543
|
-
id: row?.hs_object_id,
|
|
1544
|
-
...row,
|
|
1545
|
-
hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
|
|
1546
|
-
})
|
|
1547
|
-
) || [];
|
|
1548
|
-
return {
|
|
1549
|
-
id: deal.id,
|
|
1550
|
-
name: deal.label,
|
|
1551
|
-
count: deal?.data?.total,
|
|
1552
|
-
...deal,
|
|
1553
|
-
cards
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
);
|
|
1557
|
-
await set({ gridData: finalData });
|
|
1558
|
-
return finalData;
|
|
1559
|
-
},
|
|
1560
|
-
// ==============================
|
|
1561
|
-
// DEFAULT PIPELINE
|
|
1562
|
-
// ==============================
|
|
1563
|
-
setDefaultPipeline(data, hubspotObjectTypeId) {
|
|
1564
|
-
if (!data) {
|
|
1565
|
-
set({ selectedPipeline: "" });
|
|
1566
|
-
return "";
|
|
1567
|
-
}
|
|
1568
|
-
const { updateLink, filterParams } = useUpdateLink();
|
|
1569
|
-
const params = filterParams();
|
|
1570
|
-
const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5"];
|
|
1571
|
-
const state = get();
|
|
1572
|
-
const view = state.view;
|
|
1573
|
-
const selectedPipeline = state.selectedPipeline;
|
|
1574
|
-
let defaultPipelineId = "";
|
|
1575
|
-
let mFilterValue = "";
|
|
1576
|
-
const defaultPipeline = data?.data?.[0];
|
|
1577
|
-
if (excludedIds.includes(hubspotObjectTypeId)) {
|
|
1578
|
-
defaultPipelineId = defaultPipeline?.pipelineId || "";
|
|
1579
|
-
}
|
|
1580
|
-
if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
|
|
1581
|
-
mFilterValue = params.filterValue;
|
|
1582
|
-
} else {
|
|
1583
|
-
if (view === "BOARD" && !selectedPipeline) {
|
|
1584
|
-
mFilterValue = defaultPipelineId;
|
|
1585
|
-
updateLink({
|
|
1586
|
-
fV: defaultPipelineId
|
|
1587
|
-
});
|
|
1588
|
-
} else if (!excludedIds.includes(hubspotObjectTypeId)) {
|
|
1589
|
-
mFilterValue = selectedPipeline || null;
|
|
1590
|
-
} else {
|
|
1591
|
-
mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
set({ selectedPipeline: mFilterValue });
|
|
1595
|
-
return mFilterValue;
|
|
1596
|
-
}
|
|
1597
|
-
}));
|
|
1598
|
-
function useTable() {
|
|
1599
|
-
const tableState = tableStore.getState();
|
|
1600
|
-
return {
|
|
1601
|
-
...tableState,
|
|
1602
|
-
...{ listeners: { subscribe: tableStore.subscribe } }
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
1056
|
// src/apis/pipeline.ts
|
|
1607
1057
|
function list(options) {
|
|
1608
1058
|
const {
|
|
@@ -1641,13 +1091,14 @@ function list2(options) {
|
|
|
1641
1091
|
|
|
1642
1092
|
// src/apis/object.ts
|
|
1643
1093
|
function list3(options) {
|
|
1644
|
-
const {
|
|
1645
|
-
|
|
1646
|
-
} = useTable();
|
|
1094
|
+
const { getTableParam } = useTable();
|
|
1095
|
+
const { setObjectsData, setTableData } = actions;
|
|
1647
1096
|
const { mutate, isLoading } = createMutation(
|
|
1648
1097
|
async (payload) => {
|
|
1649
1098
|
const param = await getTableParam(payload?.companyAsMediator);
|
|
1650
1099
|
const response = await Client.object.list(payload, param);
|
|
1100
|
+
await setObjectsData(response);
|
|
1101
|
+
await setTableData(response, payload);
|
|
1651
1102
|
return response;
|
|
1652
1103
|
},
|
|
1653
1104
|
options
|
|
@@ -1658,6 +1109,20 @@ function list3(options) {
|
|
|
1658
1109
|
isLoading
|
|
1659
1110
|
};
|
|
1660
1111
|
}
|
|
1112
|
+
function sideBarList(options) {
|
|
1113
|
+
const { mutate, isLoading } = createMutation(
|
|
1114
|
+
async (payload) => {
|
|
1115
|
+
const response = await Client.object.sideBarList(payload);
|
|
1116
|
+
return response;
|
|
1117
|
+
},
|
|
1118
|
+
options
|
|
1119
|
+
);
|
|
1120
|
+
return {
|
|
1121
|
+
mutate,
|
|
1122
|
+
getSideBarObjects: mutate,
|
|
1123
|
+
isLoading
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1661
1126
|
function form(options) {
|
|
1662
1127
|
const { mutate, isLoading } = createMutation(
|
|
1663
1128
|
async (payload) => {
|
|
@@ -1687,9 +1152,16 @@ function objectFormOptions(options) {
|
|
|
1687
1152
|
};
|
|
1688
1153
|
}
|
|
1689
1154
|
function create(options) {
|
|
1155
|
+
const { setTablePrependData } = actions;
|
|
1690
1156
|
const { mutate, isLoading } = createMutation(
|
|
1691
1157
|
async (props) => {
|
|
1158
|
+
if (props?.componentName != "association") await setTablePrependData("loading", props);
|
|
1692
1159
|
const response = await Client.object.create(props);
|
|
1160
|
+
console.log(
|
|
1161
|
+
"props",
|
|
1162
|
+
props
|
|
1163
|
+
);
|
|
1164
|
+
if (props?.componentName != "association") await setTablePrependData(response, props);
|
|
1693
1165
|
return response;
|
|
1694
1166
|
},
|
|
1695
1167
|
options
|
|
@@ -1759,9 +1231,11 @@ function update(options) {
|
|
|
1759
1231
|
|
|
1760
1232
|
// src/apis/note.ts
|
|
1761
1233
|
function list4(options) {
|
|
1234
|
+
const { setNotes } = actions2;
|
|
1762
1235
|
const { mutate, isLoading } = createMutation(
|
|
1763
1236
|
async (payload) => {
|
|
1764
1237
|
const response = await Client.note.list(payload);
|
|
1238
|
+
setNotes(response, payload);
|
|
1765
1239
|
return response;
|
|
1766
1240
|
},
|
|
1767
1241
|
options
|
|
@@ -1773,9 +1247,12 @@ function list4(options) {
|
|
|
1773
1247
|
};
|
|
1774
1248
|
}
|
|
1775
1249
|
function create2(options) {
|
|
1250
|
+
const { setPrependNote } = actions2;
|
|
1776
1251
|
const { mutate, isLoading } = createMutation(
|
|
1777
1252
|
async (props) => {
|
|
1253
|
+
await setPrependNote("loading");
|
|
1778
1254
|
const response = await Client.note.create(props);
|
|
1255
|
+
await setPrependNote(response);
|
|
1779
1256
|
return response;
|
|
1780
1257
|
},
|
|
1781
1258
|
options
|
|
@@ -1787,9 +1264,11 @@ function create2(options) {
|
|
|
1787
1264
|
};
|
|
1788
1265
|
}
|
|
1789
1266
|
function update2(options) {
|
|
1267
|
+
const { updatePrependNote } = actions2;
|
|
1790
1268
|
const { mutate, isLoading } = createMutation(
|
|
1791
1269
|
async (payload) => {
|
|
1792
1270
|
const response = await Client.note.update(payload);
|
|
1271
|
+
updatePrependNote(response);
|
|
1793
1272
|
return response;
|
|
1794
1273
|
},
|
|
1795
1274
|
options
|
|
@@ -1803,9 +1282,11 @@ function update2(options) {
|
|
|
1803
1282
|
|
|
1804
1283
|
// src/apis/email.ts
|
|
1805
1284
|
function list5(options) {
|
|
1285
|
+
const { setEmails } = actions3;
|
|
1806
1286
|
const { mutate, isLoading } = createMutation(
|
|
1807
1287
|
async (payload) => {
|
|
1808
1288
|
const response = await Client.email.list(payload);
|
|
1289
|
+
setEmails(response, payload);
|
|
1809
1290
|
return response;
|
|
1810
1291
|
},
|
|
1811
1292
|
options
|
|
@@ -1817,9 +1298,12 @@ function list5(options) {
|
|
|
1817
1298
|
};
|
|
1818
1299
|
}
|
|
1819
1300
|
function create3(options) {
|
|
1301
|
+
const { setPrependEmail } = actions3;
|
|
1820
1302
|
const { mutate, isLoading } = createMutation(
|
|
1821
1303
|
async (props) => {
|
|
1304
|
+
await setPrependEmail("loading");
|
|
1822
1305
|
const response = await Client.email.create(props);
|
|
1306
|
+
await setPrependEmail(response);
|
|
1823
1307
|
return response;
|
|
1824
1308
|
},
|
|
1825
1309
|
options
|
|
@@ -1831,9 +1315,11 @@ function create3(options) {
|
|
|
1831
1315
|
};
|
|
1832
1316
|
}
|
|
1833
1317
|
function update3(options) {
|
|
1318
|
+
const { updatePrependEmail } = actions3;
|
|
1834
1319
|
const { mutate, isLoading } = createMutation(
|
|
1835
1320
|
async (payload) => {
|
|
1836
1321
|
const response = await Client.email.update(payload);
|
|
1322
|
+
updatePrependEmail(response);
|
|
1837
1323
|
return response;
|
|
1838
1324
|
},
|
|
1839
1325
|
options
|
|
@@ -1849,7 +1335,6 @@ function update3(options) {
|
|
|
1849
1335
|
function imageUpload(options) {
|
|
1850
1336
|
const { mutate, isLoading } = createMutation(
|
|
1851
1337
|
async (payload) => {
|
|
1852
|
-
console.log("payload", payload);
|
|
1853
1338
|
const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
|
|
1854
1339
|
return response;
|
|
1855
1340
|
},
|
|
@@ -1934,10 +1419,31 @@ function addFile(options) {
|
|
|
1934
1419
|
};
|
|
1935
1420
|
}
|
|
1936
1421
|
|
|
1937
|
-
// src/
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1422
|
+
// src/apis/cache.ts
|
|
1423
|
+
function purge(options) {
|
|
1424
|
+
const { mutate, isLoading } = createMutation(
|
|
1425
|
+
async (payload) => {
|
|
1426
|
+
const safePayload = payload ?? {};
|
|
1427
|
+
const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
|
|
1428
|
+
const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
1429
|
+
const { idempotencyKey: _ignored, ...body } = safePayload;
|
|
1430
|
+
return Client.cache.purge(body, headers);
|
|
1431
|
+
},
|
|
1432
|
+
options
|
|
1433
|
+
);
|
|
1434
|
+
return { mutate, purgeCache: mutate, isLoading };
|
|
1435
|
+
}
|
|
1436
|
+
function purgeStatus(purgeJobId, options) {
|
|
1437
|
+
const { mutate, isLoading } = createMutation(
|
|
1438
|
+
async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
|
|
1439
|
+
options
|
|
1440
|
+
);
|
|
1441
|
+
return {
|
|
1442
|
+
mutate,
|
|
1443
|
+
getPurgeStatus: () => mutate(purgeJobId),
|
|
1444
|
+
isLoading
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1941
1447
|
|
|
1942
1448
|
// src/breadcrumb/breadcrumbs.ts
|
|
1943
1449
|
var getBreadcrumbs = () => {
|
|
@@ -2145,6 +1651,66 @@ var buildChildRoute = (props, breadcrumbItems) => {
|
|
|
2145
1651
|
return generateUrl(props, breadcrumbs);
|
|
2146
1652
|
};
|
|
2147
1653
|
|
|
1654
|
+
// src/utils/datetime.ts
|
|
1655
|
+
var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
|
|
1656
|
+
function getCurrentTimeZone() {
|
|
1657
|
+
try {
|
|
1658
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
|
|
1659
|
+
} catch {
|
|
1660
|
+
return DEFAULT_HUBSPOT_TIMEZONE;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function normalizeToTimestamp(value) {
|
|
1664
|
+
if (value == null || value === "") return null;
|
|
1665
|
+
if (typeof value === "number") {
|
|
1666
|
+
return value > 1e11 ? value : null;
|
|
1667
|
+
}
|
|
1668
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
1669
|
+
const n = Number(value);
|
|
1670
|
+
return n > 1e11 ? n : null;
|
|
1671
|
+
}
|
|
1672
|
+
if (typeof value === "string" || value instanceof Date) {
|
|
1673
|
+
const date = new Date(value);
|
|
1674
|
+
return Number.isNaN(date.getTime()) ? null : date.getTime();
|
|
1675
|
+
}
|
|
1676
|
+
return null;
|
|
1677
|
+
}
|
|
1678
|
+
function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
|
|
1679
|
+
const raw = new Intl.DateTimeFormat("en-US", {
|
|
1680
|
+
timeZone,
|
|
1681
|
+
timeZoneName: "longOffset"
|
|
1682
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
|
|
1683
|
+
if (!raw) return "";
|
|
1684
|
+
return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
|
|
1685
|
+
}
|
|
1686
|
+
function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1687
|
+
const ms = normalizeToTimestamp(timestamp);
|
|
1688
|
+
if (ms == null) return null;
|
|
1689
|
+
const date = new Date(ms);
|
|
1690
|
+
const datePart = new Intl.DateTimeFormat("en-US", {
|
|
1691
|
+
timeZone,
|
|
1692
|
+
month: "long",
|
|
1693
|
+
day: "numeric",
|
|
1694
|
+
year: "numeric"
|
|
1695
|
+
}).format(date);
|
|
1696
|
+
const timePart = new Intl.DateTimeFormat("en-US", {
|
|
1697
|
+
timeZone,
|
|
1698
|
+
hour: "numeric",
|
|
1699
|
+
minute: "2-digit",
|
|
1700
|
+
hour12: true
|
|
1701
|
+
}).format(date);
|
|
1702
|
+
const gmtOffset = formatGmtOffset(timeZone, date);
|
|
1703
|
+
return {
|
|
1704
|
+
date: datePart,
|
|
1705
|
+
time: timePart,
|
|
1706
|
+
gmtOffset,
|
|
1707
|
+
formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1711
|
+
return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
|
|
1712
|
+
}
|
|
1713
|
+
|
|
2148
1714
|
// src/index.ts
|
|
2149
1715
|
var api = {
|
|
2150
1716
|
preLogin,
|
|
@@ -2166,6 +1732,7 @@ var api = {
|
|
|
2166
1732
|
pipelines: list,
|
|
2167
1733
|
stages: list2,
|
|
2168
1734
|
objects: list3,
|
|
1735
|
+
sideBarObjects: sideBarList,
|
|
2169
1736
|
objectsForm: form,
|
|
2170
1737
|
createObject: create,
|
|
2171
1738
|
createExistingObject: createExisting,
|
|
@@ -2185,6 +1752,8 @@ var api = {
|
|
|
2185
1752
|
file: details2,
|
|
2186
1753
|
addFolder,
|
|
2187
1754
|
addFile,
|
|
1755
|
+
purgeCache: purge,
|
|
1756
|
+
cachePurgeStatus: purgeStatus,
|
|
2188
1757
|
getRefreshToken,
|
|
2189
1758
|
getAuthRefreshToken,
|
|
2190
1759
|
isCookieExpired,
|
|
@@ -2210,6 +1779,6 @@ var routeParam = {
|
|
|
2210
1779
|
getParamDetails
|
|
2211
1780
|
};
|
|
2212
1781
|
|
|
2213
|
-
export { api, breadcrumbsDetails, getFieldErrors, getFormErrors, initializeHttpClient, routeParam, store, url };
|
|
1782
|
+
export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url };
|
|
2214
1783
|
//# sourceMappingURL=index.js.map
|
|
2215
1784
|
//# sourceMappingURL=index.js.map
|