woodsportal-client-sdk 1.1.4-dev.6 → 1.1.4-dev.60
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 +64 -2
- package/dist/adapters/angular/index.d.ts +42 -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 +42 -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 +42 -0
- package/dist/adapters/vue/index.js +25 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/auth-utils-TZSW6BVD.js +3 -0
- package/dist/auth-utils-TZSW6BVD.js.map +1 -0
- package/dist/chunk-2SYUOWTT.js +139 -0
- package/dist/chunk-2SYUOWTT.js.map +1 -0
- package/dist/chunk-AZ7K37OU.js +17 -0
- package/dist/chunk-AZ7K37OU.js.map +1 -0
- package/dist/chunk-IVNXDHLP.js +3641 -0
- package/dist/chunk-IVNXDHLP.js.map +1 -0
- package/dist/chunk-Y5MRAAGK.js +10 -0
- package/dist/chunk-Y5MRAAGK.js.map +1 -0
- package/dist/index.d.ts +209 -2
- package/dist/index.js +2 -2278
- package/dist/index.js.map +1 -1
- package/dist/use-uploader-DOpqLu77.d.ts +55 -0
- package/package.json +45 -8
|
@@ -0,0 +1,3641 @@
|
|
|
1
|
+
import { __export, ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, isCookieExpired, getRefreshToken, DEV_API_URL, getCookie, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken, removeAllCookie } from './chunk-2SYUOWTT.js';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import pako from 'pako';
|
|
4
|
+
import { Base64 } from 'js-base64';
|
|
5
|
+
|
|
6
|
+
// src/client/index.ts
|
|
7
|
+
var client_exports = {};
|
|
8
|
+
__export(client_exports, {
|
|
9
|
+
Client: () => Client
|
|
10
|
+
});
|
|
11
|
+
|
|
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);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function resolveStore() {
|
|
26
|
+
if (typeof globalThis === "undefined") {
|
|
27
|
+
return memoryStore;
|
|
28
|
+
}
|
|
29
|
+
const ls = globalThis.localStorage;
|
|
30
|
+
if (!ls || typeof ls.getItem !== "function") {
|
|
31
|
+
return memoryStore;
|
|
32
|
+
}
|
|
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;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var storage = {
|
|
43
|
+
set: (key, value) => {
|
|
44
|
+
resolveStore().setItem(key, JSON.stringify(value));
|
|
45
|
+
},
|
|
46
|
+
get: (key) => {
|
|
47
|
+
const item = resolveStore().getItem(key);
|
|
48
|
+
return item ? JSON.parse(item) : null;
|
|
49
|
+
},
|
|
50
|
+
remove: (key) => {
|
|
51
|
+
resolveStore().removeItem(key);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/utils/config.ts
|
|
56
|
+
var config = {
|
|
57
|
+
get hubId() {
|
|
58
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
59
|
+
return hubSpotData?.[HUB_ID] || "";
|
|
60
|
+
},
|
|
61
|
+
get devPortalId() {
|
|
62
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
63
|
+
return hubSpotData?.[DEV_PORTAL_ID] || "";
|
|
64
|
+
},
|
|
65
|
+
get portalId() {
|
|
66
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
67
|
+
return hubSpotData?.[PORTAL_ID] || "";
|
|
68
|
+
},
|
|
69
|
+
get devApiUrl() {
|
|
70
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
71
|
+
return hubSpotData?.[DEV_API_URL] || "";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var setConfig = {
|
|
75
|
+
setDevPortalId(portalId) {
|
|
76
|
+
const existing = storage.get(HUBSPOT_DATA) || {};
|
|
77
|
+
storage.set(HUBSPOT_DATA, {
|
|
78
|
+
...existing,
|
|
79
|
+
[PORTAL_ID]: portalId
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/utils/generateApiUrl.ts
|
|
85
|
+
var generateApiUrl = ({
|
|
86
|
+
route,
|
|
87
|
+
params = {},
|
|
88
|
+
queryParams = ""
|
|
89
|
+
}) => {
|
|
90
|
+
const defaultParams = {
|
|
91
|
+
hubId: config.hubId,
|
|
92
|
+
portalId: config.portalId
|
|
93
|
+
};
|
|
94
|
+
params = { ...defaultParams, ...params };
|
|
95
|
+
const url2 = replaceParams(route, params);
|
|
96
|
+
let queryString = "";
|
|
97
|
+
if (queryParams && typeof queryParams === "object") {
|
|
98
|
+
const cleanedParams = Object.entries(queryParams).filter(([_, value]) => value !== null && value !== void 0).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
|
|
99
|
+
queryString = new URLSearchParams(cleanedParams).toString();
|
|
100
|
+
}
|
|
101
|
+
return queryString ? `${url2}?${queryString}` : url2;
|
|
102
|
+
};
|
|
103
|
+
function replaceParams(template, values) {
|
|
104
|
+
return template.replace(
|
|
105
|
+
/\$\{(\w+)\}/g,
|
|
106
|
+
(_, key) => key in values ? String(values[key]) : `\${${key}}`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/client/api-endpoints.ts
|
|
111
|
+
var API_ENDPOINTS = {
|
|
112
|
+
// Auth
|
|
113
|
+
PRE_LOGIN: "/api/auth/pre-login",
|
|
114
|
+
LOGIN: "/api/auth/login",
|
|
115
|
+
AUTH_REFRESH: "/api/auth/refresh",
|
|
116
|
+
FORGET_PASSWORD: "/api/auth/forget-password",
|
|
117
|
+
RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
|
|
118
|
+
RESET_PASSWORD: "/api/auth/reset-password",
|
|
119
|
+
VERIFY_EMAIL: "/api/auth/verify-email",
|
|
120
|
+
REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
|
|
121
|
+
RESEND_EMAIL: "/api/auth/resend-email",
|
|
122
|
+
VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
|
|
123
|
+
LOGOUT: "/api/auth/logout",
|
|
124
|
+
// SSO
|
|
125
|
+
SSO_DETAILS: "/api/auth/sso/active",
|
|
126
|
+
SSO_URL: "/api/auth/sso/authorize",
|
|
127
|
+
SSO_CALLBACK: "/api/auth/sso/callback",
|
|
128
|
+
// User
|
|
129
|
+
ME: "/api/auth/me",
|
|
130
|
+
PROFILE: "/api/${hubId}/${portalId}/profiles",
|
|
131
|
+
CHANGE_PASSWORD: "/api/auth/change-password",
|
|
132
|
+
// Pipeline
|
|
133
|
+
PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
134
|
+
// Stage
|
|
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
|
+
FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
|
|
177
|
+
FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
|
|
178
|
+
FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/client/config.ts
|
|
182
|
+
var config2 = {
|
|
183
|
+
baseURL: ""
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/client/http-clint.ts
|
|
187
|
+
var axiosInstance = null;
|
|
188
|
+
var config3 = {};
|
|
189
|
+
function initializeHttpClient(clientConfig) {
|
|
190
|
+
config3 = clientConfig;
|
|
191
|
+
const baseURL = config?.devApiUrl || config3.baseURL;
|
|
192
|
+
if (!baseURL) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
"WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup."
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const timeout = config3.timeout ?? 5e4;
|
|
198
|
+
axiosInstance = axios.create({
|
|
199
|
+
baseURL,
|
|
200
|
+
timeout,
|
|
201
|
+
headers: {
|
|
202
|
+
"Content-Type": "application/json",
|
|
203
|
+
...config3.headers
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
setRefreshCallback(getAuthRefreshToken);
|
|
207
|
+
axiosInstance.interceptors.request.use((config4) => {
|
|
208
|
+
const token = getAccessToken();
|
|
209
|
+
if (token) {
|
|
210
|
+
config4.headers.set("Authorization", `Bearer ${token}`);
|
|
211
|
+
}
|
|
212
|
+
return config4;
|
|
213
|
+
});
|
|
214
|
+
axiosInstance.interceptors.response.use(
|
|
215
|
+
(response) => response,
|
|
216
|
+
(error) => {
|
|
217
|
+
if (error.response && error.response.status === 401) {
|
|
218
|
+
config3.skipCurrentPublicPath?.() ?? false;
|
|
219
|
+
}
|
|
220
|
+
return Promise.reject(error);
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function getAxiosInstance() {
|
|
225
|
+
if (!axiosInstance) {
|
|
226
|
+
initializeHttpClient({
|
|
227
|
+
baseURL: config2.baseURL,
|
|
228
|
+
timeout: 5e4
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return axiosInstance;
|
|
232
|
+
}
|
|
233
|
+
function formatBooleanSearchParam(key, value) {
|
|
234
|
+
return value ? `${key}:1` : `${key}:`;
|
|
235
|
+
}
|
|
236
|
+
var HttpClient = class {
|
|
237
|
+
static async get(url2, params) {
|
|
238
|
+
await ensureValidRefresh();
|
|
239
|
+
const response = await getAxiosInstance().get(url2, { params });
|
|
240
|
+
return response.data;
|
|
241
|
+
}
|
|
242
|
+
static async post(url2, data, options) {
|
|
243
|
+
await ensureValidRefresh();
|
|
244
|
+
const response = await getAxiosInstance().post(url2, data, options);
|
|
245
|
+
return response.data;
|
|
246
|
+
}
|
|
247
|
+
static async put(url2, data) {
|
|
248
|
+
await ensureValidRefresh();
|
|
249
|
+
const response = await getAxiosInstance().put(url2, data);
|
|
250
|
+
return response.data;
|
|
251
|
+
}
|
|
252
|
+
static async delete(url2, config4) {
|
|
253
|
+
await ensureValidRefresh();
|
|
254
|
+
const response = await getAxiosInstance().delete(url2, config4);
|
|
255
|
+
return response.data;
|
|
256
|
+
}
|
|
257
|
+
static formatSearchParams(params) {
|
|
258
|
+
return Object.entries(params).filter(([, value]) => Boolean(value)).map(
|
|
259
|
+
([k, v]) => [
|
|
260
|
+
"type",
|
|
261
|
+
"categories",
|
|
262
|
+
"tags",
|
|
263
|
+
"author",
|
|
264
|
+
"manufacturer",
|
|
265
|
+
"shops",
|
|
266
|
+
"refund_reason"
|
|
267
|
+
].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
|
|
268
|
+
).join(";");
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var AuthHttpClient = class {
|
|
272
|
+
static async get(url2, params) {
|
|
273
|
+
const response = await getAxiosInstance().get(url2, { params });
|
|
274
|
+
return response.data;
|
|
275
|
+
}
|
|
276
|
+
static async post(url2, data, options) {
|
|
277
|
+
const response = await getAxiosInstance().post(url2, data, options);
|
|
278
|
+
return response.data;
|
|
279
|
+
}
|
|
280
|
+
static async put(url2, data, options) {
|
|
281
|
+
const response = await getAxiosInstance().put(url2, data, options);
|
|
282
|
+
return response.data;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
function getFormErrors(error) {
|
|
286
|
+
if (axios.isAxiosError(error)) {
|
|
287
|
+
return error.response?.data?.message ?? null;
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
function getFieldErrors(error) {
|
|
292
|
+
if (axios.isAxiosError(error)) {
|
|
293
|
+
return error.response?.data?.errors ?? null;
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
async function getAuthRefreshToken(refreshToken) {
|
|
298
|
+
if (refreshToken == null || refreshToken.trim() === "") {
|
|
299
|
+
return { token: null, success: false };
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const headers = {};
|
|
303
|
+
if (config.devPortalId) {
|
|
304
|
+
headers["X-Dev-Portal-Id"] = config.devPortalId;
|
|
305
|
+
}
|
|
306
|
+
const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
|
|
307
|
+
const response = await getAxiosInstance().post(
|
|
308
|
+
api_url,
|
|
309
|
+
{ refreshToken },
|
|
310
|
+
{ headers }
|
|
311
|
+
);
|
|
312
|
+
const maybeData = response?.data?.data || response?.data;
|
|
313
|
+
const tokenData = maybeData?.tokenData || maybeData || {};
|
|
314
|
+
const newRefreshToken = tokenData?.refreshToken;
|
|
315
|
+
const token = tokenData?.token;
|
|
316
|
+
const expiresIn = tokenData?.expiresIn;
|
|
317
|
+
const rExpiresIn = tokenData?.refreshExpiresIn;
|
|
318
|
+
const rExpiresAt = tokenData?.refreshExpiresAt;
|
|
319
|
+
if (typeof newRefreshToken === "string") {
|
|
320
|
+
let rExpires = 0;
|
|
321
|
+
if (typeof rExpiresIn === "number") {
|
|
322
|
+
rExpires = Date.now() + rExpiresIn * 1e3;
|
|
323
|
+
} else if (typeof rExpiresAt === "number") {
|
|
324
|
+
rExpires = rExpiresAt * 1e3;
|
|
325
|
+
}
|
|
326
|
+
setRefreshToken(newRefreshToken, rExpires);
|
|
327
|
+
}
|
|
328
|
+
if (typeof token === "string") {
|
|
329
|
+
setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
|
|
330
|
+
return { token, success: true };
|
|
331
|
+
}
|
|
332
|
+
return { token: null, success: false };
|
|
333
|
+
} catch {
|
|
334
|
+
return { token: null, success: false };
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// src/data/user.ts
|
|
339
|
+
var PROFILE = null;
|
|
340
|
+
var setProfileData = (data) => {
|
|
341
|
+
PROFILE = data;
|
|
342
|
+
};
|
|
343
|
+
var getProfileData = () => {
|
|
344
|
+
return PROFILE;
|
|
345
|
+
};
|
|
346
|
+
function convertToBase64(obj) {
|
|
347
|
+
try {
|
|
348
|
+
if (!obj) return "";
|
|
349
|
+
const json = JSON.stringify(obj);
|
|
350
|
+
const compressed = pako.deflate(json);
|
|
351
|
+
const base64 = Base64.fromUint8Array(compressed, true);
|
|
352
|
+
return base64;
|
|
353
|
+
} catch (error) {
|
|
354
|
+
console.error("Failed to encode object:", error);
|
|
355
|
+
return "";
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function decodeToBase64(encoded) {
|
|
359
|
+
try {
|
|
360
|
+
if (!encoded) return null;
|
|
361
|
+
const uint8Array = Base64.toUint8Array(encoded);
|
|
362
|
+
const decompressed = pako.inflate(uint8Array, { to: "string" });
|
|
363
|
+
return JSON.parse(decompressed);
|
|
364
|
+
} catch (error) {
|
|
365
|
+
console.error("Failed to decode object:", error);
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/breadcrumb/url-utils.ts
|
|
371
|
+
function mapKeysDeep(obj, keyMap2) {
|
|
372
|
+
if (Array.isArray(obj)) {
|
|
373
|
+
return obj.map((item) => mapKeysDeep(item, keyMap2));
|
|
374
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
375
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
376
|
+
const mappedKey = keyMap2[key] || key;
|
|
377
|
+
acc[mappedKey] = mapKeysDeep(value, keyMap2);
|
|
378
|
+
return acc;
|
|
379
|
+
}, {});
|
|
380
|
+
}
|
|
381
|
+
return obj;
|
|
382
|
+
}
|
|
383
|
+
function isMessingParent(breadcrumbs) {
|
|
384
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
385
|
+
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
386
|
+
let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
387
|
+
return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
|
|
388
|
+
}
|
|
389
|
+
function isMessingParentLastItem(breadcrumbs) {
|
|
390
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
391
|
+
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
392
|
+
return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
|
|
393
|
+
}
|
|
394
|
+
function breadcrumbStage(breadcrumbItems) {
|
|
395
|
+
let breadcrumbType = "child";
|
|
396
|
+
if (breadcrumbItems.length === 1) {
|
|
397
|
+
breadcrumbType = "root";
|
|
398
|
+
} else if (breadcrumbItems.length === 2) {
|
|
399
|
+
breadcrumbType = "root_details";
|
|
400
|
+
}
|
|
401
|
+
return breadcrumbType;
|
|
402
|
+
}
|
|
403
|
+
var generateUrl = (props, breadcrumbs) => {
|
|
404
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
405
|
+
let url2 = "";
|
|
406
|
+
if (props?.objectTypeId && props?.recordId) {
|
|
407
|
+
url2 = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
|
|
408
|
+
} else {
|
|
409
|
+
url2 = `/association/${props?.objectTypeId}?b=${newBase64}`;
|
|
410
|
+
}
|
|
411
|
+
return url2;
|
|
412
|
+
};
|
|
413
|
+
function getTotalParentLength(data) {
|
|
414
|
+
return data.filter(
|
|
415
|
+
(item) => (item.pt || item.o_t_id) && !item.o_r_id
|
|
416
|
+
).length;
|
|
417
|
+
}
|
|
418
|
+
var generatePath = (breadcrumbs, breadcrumb, index) => {
|
|
419
|
+
const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
|
|
420
|
+
if (index === 0) {
|
|
421
|
+
const pathBase = breadcrumb?.pt || `/${breadcrumb?.o_t_id}`;
|
|
422
|
+
const normalizedPath = pathBase.startsWith("/") ? pathBase : `/${pathBase}`;
|
|
423
|
+
return {
|
|
424
|
+
name: breadcrumb?.n,
|
|
425
|
+
path: `${normalizedPath}?b=${bc}`
|
|
426
|
+
};
|
|
427
|
+
} else if (index === 1) {
|
|
428
|
+
if (breadcrumb?.isHome) {
|
|
429
|
+
return {
|
|
430
|
+
name: breadcrumb?.n,
|
|
431
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return {
|
|
435
|
+
name: breadcrumb?.n,
|
|
436
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
437
|
+
};
|
|
438
|
+
} else {
|
|
439
|
+
if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
|
|
440
|
+
return {
|
|
441
|
+
name: breadcrumb?.n,
|
|
442
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
443
|
+
};
|
|
444
|
+
} else {
|
|
445
|
+
return {
|
|
446
|
+
name: breadcrumb?.n,
|
|
447
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
// src/breadcrumb/key-map.ts
|
|
454
|
+
var keyMap = {
|
|
455
|
+
dp: "defPermissions",
|
|
456
|
+
n: "name",
|
|
457
|
+
sort: "sort",
|
|
458
|
+
o_t_id: "objectTypeId",
|
|
459
|
+
s: "search",
|
|
460
|
+
fPn: "filterPropertyName",
|
|
461
|
+
fO: "filterOperator",
|
|
462
|
+
fV: "filterValue",
|
|
463
|
+
c: "cache",
|
|
464
|
+
isPC: "isPrimaryCompany",
|
|
465
|
+
v: "view",
|
|
466
|
+
l: "limit",
|
|
467
|
+
pt: "path",
|
|
468
|
+
p: "page",
|
|
469
|
+
a: "after",
|
|
470
|
+
aPip: "activePipeline",
|
|
471
|
+
aT: "activeTab",
|
|
472
|
+
cT: "create",
|
|
473
|
+
dP: "display",
|
|
474
|
+
dL: "display_label",
|
|
475
|
+
pId: "pipeline_id"
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// src/utils/url.ts
|
|
479
|
+
var ticketHubspotObjectTypeId = () => {
|
|
480
|
+
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
481
|
+
const paramDetails = getParamDetails2();
|
|
482
|
+
if (
|
|
483
|
+
// this hubspotObjectTypeId only for main contact ticket object type
|
|
484
|
+
paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5"
|
|
485
|
+
) {
|
|
486
|
+
return "0-1";
|
|
487
|
+
}
|
|
488
|
+
if (
|
|
489
|
+
// this hubspotObjectTypeId only for main company ticket object type
|
|
490
|
+
paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5-c"
|
|
491
|
+
) {
|
|
492
|
+
return "0-2";
|
|
493
|
+
}
|
|
494
|
+
return "";
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// src/utils/param.ts
|
|
498
|
+
function getParam(paramName) {
|
|
499
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
500
|
+
const hash = globalThis.location.hash || "";
|
|
501
|
+
if (!hash.startsWith("#/")) return null;
|
|
502
|
+
const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
|
|
503
|
+
const queryString = hashWithoutHash.split("?")[1];
|
|
504
|
+
if (!queryString) return null;
|
|
505
|
+
const params = new URLSearchParams(queryString);
|
|
506
|
+
return params.get(paramName);
|
|
507
|
+
}
|
|
508
|
+
function getPath() {
|
|
509
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
510
|
+
const hash = globalThis.location.hash || "";
|
|
511
|
+
if (!hash.startsWith("#/")) return null;
|
|
512
|
+
return hash.slice(1).split("?")[0];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// src/breadcrumb/param.ts
|
|
516
|
+
var getRouteMenu = (path) => {
|
|
517
|
+
const apiRoutes = globalThis?.apiRoutes || [];
|
|
518
|
+
return apiRoutes.find((menu) => menu?.path === path);
|
|
519
|
+
};
|
|
520
|
+
var getRouteDetails = () => {
|
|
521
|
+
const search = getParam("b");
|
|
522
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
523
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
524
|
+
const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
|
|
525
|
+
return { routeDetails: mapped };
|
|
526
|
+
};
|
|
527
|
+
var getParamDetails = (props, isDetailsPage = false) => {
|
|
528
|
+
const search = getParam("b");
|
|
529
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
530
|
+
if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
|
|
531
|
+
breadcrumbs = breadcrumbs.slice(1);
|
|
532
|
+
}
|
|
533
|
+
let mediatorObjectTypeId = "";
|
|
534
|
+
let mediatorObjectRecordId = "";
|
|
535
|
+
let parentObjectTypeId = "";
|
|
536
|
+
let parentObjectRecordId = "";
|
|
537
|
+
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
538
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
539
|
+
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
540
|
+
if (isDetailsPage === true && lastItem && "prm" in lastItem) {
|
|
541
|
+
delete lastItem.prm;
|
|
542
|
+
}
|
|
543
|
+
if (breadcrumbs.length > 1) {
|
|
544
|
+
if (props?.type === "ticket" || props?.type === "association") {
|
|
545
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
546
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
547
|
+
parentObjectTypeId = lastItem?.o_t_id || "";
|
|
548
|
+
parentObjectRecordId = lastItem?.o_r_id || "";
|
|
549
|
+
} else {
|
|
550
|
+
if (breadcrumbs.length > 2) {
|
|
551
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
552
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
553
|
+
}
|
|
554
|
+
if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
555
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
556
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
557
|
+
}
|
|
558
|
+
if (lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
559
|
+
parentObjectTypeId = lastItem3?.o_t_id || "";
|
|
560
|
+
parentObjectRecordId = lastItem3?.o_r_id || "";
|
|
561
|
+
}
|
|
562
|
+
if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
|
|
563
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
564
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
let paramsObject = {};
|
|
569
|
+
if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
|
|
570
|
+
paramsObject["isPrimaryCompany"] = true;
|
|
571
|
+
}
|
|
572
|
+
if (parentObjectTypeId && parentObjectRecordId) {
|
|
573
|
+
paramsObject["parentObjectTypeId"] = parentObjectTypeId;
|
|
574
|
+
paramsObject["parentObjectRecordId"] = parentObjectRecordId;
|
|
575
|
+
}
|
|
576
|
+
if (mediatorObjectTypeId && mediatorObjectRecordId) {
|
|
577
|
+
paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
|
|
578
|
+
paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
|
|
579
|
+
}
|
|
580
|
+
const mappedLastItemParam = Object.fromEntries(
|
|
581
|
+
Object.entries(lastItem?.prm || {}).map(([key, value]) => [
|
|
582
|
+
keyMap[key] || key,
|
|
583
|
+
// use mapped name if exists, else keep original
|
|
584
|
+
value
|
|
585
|
+
])
|
|
586
|
+
);
|
|
587
|
+
let queryString = null;
|
|
588
|
+
if (props?.type === "association") {
|
|
589
|
+
queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
|
|
590
|
+
} else {
|
|
591
|
+
queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
|
|
592
|
+
}
|
|
593
|
+
let params = queryString ? `?${queryString}` : "";
|
|
594
|
+
const totalParentLength = getTotalParentLength(breadcrumbs);
|
|
595
|
+
let parentAccessLabel = false;
|
|
596
|
+
if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
|
|
597
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
|
|
598
|
+
breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
|
|
599
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
|
|
600
|
+
parentAccessLabel = true;
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
breadcrumbs,
|
|
604
|
+
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
605
|
+
paramsObject,
|
|
606
|
+
params,
|
|
607
|
+
parentAccessLabel
|
|
608
|
+
};
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// src/store/index.ts
|
|
612
|
+
function createStore(initializer) {
|
|
613
|
+
let state;
|
|
614
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
615
|
+
const get = () => state;
|
|
616
|
+
const set = (partial) => {
|
|
617
|
+
const prevState = state;
|
|
618
|
+
const partialState = typeof partial === "function" ? partial(state) : partial;
|
|
619
|
+
state = {
|
|
620
|
+
...state,
|
|
621
|
+
...partialState
|
|
622
|
+
};
|
|
623
|
+
listeners.forEach(
|
|
624
|
+
(listener) => listener(state, prevState)
|
|
625
|
+
);
|
|
626
|
+
};
|
|
627
|
+
const subscribe = (listener) => {
|
|
628
|
+
listeners.add(listener);
|
|
629
|
+
return () => listeners.delete(listener);
|
|
630
|
+
};
|
|
631
|
+
state = initializer(set, get);
|
|
632
|
+
return {
|
|
633
|
+
getState: get,
|
|
634
|
+
setState: set,
|
|
635
|
+
subscribe
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/utils/getCookieData.ts
|
|
640
|
+
var getAuthSubscriptionType = () => {
|
|
641
|
+
return getCookie("subscriptionType");
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// src/breadcrumb/url.ts
|
|
645
|
+
var useUpdateLink = () => {
|
|
646
|
+
const updateLink = async (props, displayName = "prm") => {
|
|
647
|
+
const search = getParam("b");
|
|
648
|
+
const pathname = getPath();
|
|
649
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
650
|
+
if (breadcrumbs.length < 1) {
|
|
651
|
+
const routeMenu = getRouteMenu(pathname);
|
|
652
|
+
breadcrumbs = [
|
|
653
|
+
{
|
|
654
|
+
n: routeMenu?.title,
|
|
655
|
+
pt: routeMenu?.path
|
|
656
|
+
}
|
|
657
|
+
];
|
|
658
|
+
}
|
|
659
|
+
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
660
|
+
if (displayName) {
|
|
661
|
+
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
662
|
+
await setDeep(lastBreadcrumb, displayName, {
|
|
663
|
+
...ex,
|
|
664
|
+
...props
|
|
665
|
+
});
|
|
666
|
+
} else {
|
|
667
|
+
await Object.assign(lastBreadcrumb, props);
|
|
668
|
+
}
|
|
669
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
670
|
+
updateBParam(newBase64);
|
|
671
|
+
};
|
|
672
|
+
function setDeep(obj, path, value) {
|
|
673
|
+
const keys = path.split(".");
|
|
674
|
+
let curr = obj;
|
|
675
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
676
|
+
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
677
|
+
curr[keys[i]] = {};
|
|
678
|
+
}
|
|
679
|
+
curr = curr[keys[i]];
|
|
680
|
+
}
|
|
681
|
+
curr[keys[keys.length - 1]] = value;
|
|
682
|
+
return curr;
|
|
683
|
+
}
|
|
684
|
+
function getDeep(obj, path) {
|
|
685
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
686
|
+
}
|
|
687
|
+
const getLinkParams = (displayName = "prm") => {
|
|
688
|
+
const search = getParam("b");
|
|
689
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
690
|
+
if (breadcrumbs.length < 1) return null;
|
|
691
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
692
|
+
const getDeep2 = (obj, path) => {
|
|
693
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
694
|
+
};
|
|
695
|
+
const expandKeys = (obj) => {
|
|
696
|
+
return Object.fromEntries(
|
|
697
|
+
Object.entries(obj).map(([key, value]) => [
|
|
698
|
+
keyMap[key] || key,
|
|
699
|
+
// map if exists, else keep original
|
|
700
|
+
value
|
|
701
|
+
])
|
|
702
|
+
);
|
|
703
|
+
};
|
|
704
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
705
|
+
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
706
|
+
return output;
|
|
707
|
+
};
|
|
708
|
+
const filterParams = (displayName = "prm") => {
|
|
709
|
+
const search = getParam("b");
|
|
710
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
711
|
+
if (breadcrumbs.length < 1) return null;
|
|
712
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
713
|
+
const getDeep2 = (obj, path) => {
|
|
714
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
715
|
+
};
|
|
716
|
+
const expandKeys = (obj) => {
|
|
717
|
+
return Object.fromEntries(
|
|
718
|
+
Object.entries(obj).map(([key, value]) => [
|
|
719
|
+
keyMap[key] || key,
|
|
720
|
+
// map if exists, else keep original
|
|
721
|
+
value
|
|
722
|
+
])
|
|
723
|
+
);
|
|
724
|
+
};
|
|
725
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
726
|
+
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
727
|
+
return output;
|
|
728
|
+
};
|
|
729
|
+
return { updateLink, getLinkParams, filterParams };
|
|
730
|
+
};
|
|
731
|
+
var updateBParam = (newValue) => {
|
|
732
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
733
|
+
const hash = globalThis.location.hash || "";
|
|
734
|
+
if (!hash.startsWith("#/")) return;
|
|
735
|
+
const withoutHash = hash.slice(2);
|
|
736
|
+
const [path, queryString] = withoutHash.split("?");
|
|
737
|
+
const params = new URLSearchParams(queryString || "");
|
|
738
|
+
params.set("b", newValue);
|
|
739
|
+
const newHash = `#/${path}?${params.toString()}`;
|
|
740
|
+
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
741
|
+
globalThis.history.replaceState(null, "", newHash);
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// src/store/use-table.ts
|
|
746
|
+
var pageLimit = 10;
|
|
747
|
+
var tableStore = createStore((set, get) => ({
|
|
748
|
+
// ==============================
|
|
749
|
+
// STATE
|
|
750
|
+
// ==============================
|
|
751
|
+
tableUniqueId: null,
|
|
752
|
+
gridData: [],
|
|
753
|
+
sort: "-hs_createdate",
|
|
754
|
+
limit: 10,
|
|
755
|
+
after: "",
|
|
756
|
+
page: 1,
|
|
757
|
+
nextPage: 1,
|
|
758
|
+
stageId: "",
|
|
759
|
+
totalItems: 1,
|
|
760
|
+
numOfPages: 1,
|
|
761
|
+
currentPage: 1,
|
|
762
|
+
search: "",
|
|
763
|
+
filterPropertyName: "hs_pipeline",
|
|
764
|
+
filterOperator: "eq",
|
|
765
|
+
filterValue: "",
|
|
766
|
+
isPrimaryCompany: null,
|
|
767
|
+
view: null,
|
|
768
|
+
selectedPipeline: "",
|
|
769
|
+
tableParam: {},
|
|
770
|
+
tableDefPermissions: {},
|
|
771
|
+
tableData: [],
|
|
772
|
+
tablePrependData: [],
|
|
773
|
+
// ==============================
|
|
774
|
+
// BASIC SETTERS
|
|
775
|
+
// ==============================
|
|
776
|
+
setTableUniqueId: (v) => set({ tableUniqueId: v }),
|
|
777
|
+
setSort: (v) => set({ sort: v }),
|
|
778
|
+
setLimit: (v) => set({ limit: v }),
|
|
779
|
+
setAfter: (v) => set({ after: v }),
|
|
780
|
+
setPage: (v) => set({ page: v }),
|
|
781
|
+
setNextPage: (v) => set({ nextPage: v }),
|
|
782
|
+
setStageId: (v) => set({ stageId: v }),
|
|
783
|
+
setTotalItems: (v) => set({ totalItems: v }),
|
|
784
|
+
setNumOfPages: (v) => set({ numOfPages: v }),
|
|
785
|
+
setCurrentPage: (v) => set({ currentPage: v }),
|
|
786
|
+
setSearch: (v) => set({ search: v }),
|
|
787
|
+
setFilterPropertyName: (v) => set({ filterPropertyName: v }),
|
|
788
|
+
setFilterOperator: (v) => set({ filterOperator: v }),
|
|
789
|
+
setFilterValue: (v) => set({ filterValue: v }),
|
|
790
|
+
setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
|
|
791
|
+
// ==============================
|
|
792
|
+
// VIEW
|
|
793
|
+
// ==============================
|
|
794
|
+
setView: (mView) => {
|
|
795
|
+
set({
|
|
796
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
797
|
+
view: mView
|
|
798
|
+
});
|
|
799
|
+
},
|
|
800
|
+
// ==============================
|
|
801
|
+
// PIPELINE
|
|
802
|
+
// ==============================
|
|
803
|
+
changePipeline: (mView) => {
|
|
804
|
+
set({
|
|
805
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
806
|
+
selectedPipeline: mView || ""
|
|
807
|
+
});
|
|
808
|
+
},
|
|
809
|
+
setSelectedPipeline: (pipelines, pipeLineId) => {
|
|
810
|
+
let filterValue = "";
|
|
811
|
+
if (pipeLineId) {
|
|
812
|
+
const pipelineSingle = pipelines.find(
|
|
813
|
+
(pipeline) => pipeline.pipelineId === pipeLineId
|
|
814
|
+
);
|
|
815
|
+
filterValue = pipelineSingle?.pipelineId || "";
|
|
816
|
+
}
|
|
817
|
+
set({
|
|
818
|
+
filterPropertyName: "hs_pipeline",
|
|
819
|
+
filterOperator: "eq",
|
|
820
|
+
filterValue,
|
|
821
|
+
selectedPipeline: filterValue
|
|
822
|
+
});
|
|
823
|
+
},
|
|
824
|
+
// ==============================
|
|
825
|
+
// RESET
|
|
826
|
+
// ==============================
|
|
827
|
+
resetTableParam: () => {
|
|
828
|
+
set({
|
|
829
|
+
sort: "-hs_createdate",
|
|
830
|
+
limit: pageLimit,
|
|
831
|
+
after: "",
|
|
832
|
+
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
833
|
+
totalItems: 1,
|
|
834
|
+
numOfPages: 1,
|
|
835
|
+
currentPage: 1,
|
|
836
|
+
search: "",
|
|
837
|
+
filterPropertyName: "hs_pipeline",
|
|
838
|
+
filterOperator: "eq",
|
|
839
|
+
filterValue: "",
|
|
840
|
+
isPrimaryCompany: null,
|
|
841
|
+
selectedPipeline: ""
|
|
842
|
+
});
|
|
843
|
+
},
|
|
844
|
+
// ==============================
|
|
845
|
+
// PARAM BUILDER
|
|
846
|
+
// ==============================
|
|
847
|
+
getTableParam: (companyAsMediator, currentPageOverride) => {
|
|
848
|
+
const state = get();
|
|
849
|
+
const baseParams = {
|
|
850
|
+
sort: state.sort,
|
|
851
|
+
search: state.search,
|
|
852
|
+
filterPropertyName: state.filterPropertyName,
|
|
853
|
+
filterOperator: state.filterOperator,
|
|
854
|
+
filterValue: state.selectedPipeline,
|
|
855
|
+
cache: true,
|
|
856
|
+
isPrimaryCompany: companyAsMediator || false,
|
|
857
|
+
view: state.view
|
|
858
|
+
};
|
|
859
|
+
if (getAuthSubscriptionType() === "FREE") {
|
|
860
|
+
return {
|
|
861
|
+
...baseParams,
|
|
862
|
+
after: state.page
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
return {
|
|
866
|
+
...baseParams,
|
|
867
|
+
limit: state.limit,
|
|
868
|
+
page: currentPageOverride || state.page,
|
|
869
|
+
...state.after && {
|
|
870
|
+
after: state.after
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
},
|
|
874
|
+
// ==============================
|
|
875
|
+
// GRID DATA
|
|
876
|
+
// ==============================
|
|
877
|
+
setGridData: async (type, deals) => {
|
|
878
|
+
if (type === "reset") {
|
|
879
|
+
await set({ gridData: [] });
|
|
880
|
+
return [];
|
|
881
|
+
}
|
|
882
|
+
if (type === "directly") {
|
|
883
|
+
await set({ gridData: deals });
|
|
884
|
+
return deals;
|
|
885
|
+
}
|
|
886
|
+
const finalData = await deals.map(
|
|
887
|
+
(deal) => {
|
|
888
|
+
const cards = deal?.data?.results?.rows?.map(
|
|
889
|
+
(row) => ({
|
|
890
|
+
id: row?.hs_object_id,
|
|
891
|
+
...row,
|
|
892
|
+
hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
|
|
893
|
+
})
|
|
894
|
+
) || [];
|
|
895
|
+
return {
|
|
896
|
+
id: deal.id,
|
|
897
|
+
name: deal.label,
|
|
898
|
+
count: deal?.data?.total,
|
|
899
|
+
...deal,
|
|
900
|
+
cards
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
);
|
|
904
|
+
await set({ gridData: finalData });
|
|
905
|
+
return finalData;
|
|
906
|
+
},
|
|
907
|
+
// ==============================
|
|
908
|
+
// DEFAULT PIPELINE
|
|
909
|
+
// ==============================
|
|
910
|
+
setDefaultPipeline(data, hubspotObjectTypeId) {
|
|
911
|
+
if (!data) {
|
|
912
|
+
set({ selectedPipeline: "" });
|
|
913
|
+
return "";
|
|
914
|
+
}
|
|
915
|
+
const { updateLink, filterParams } = useUpdateLink();
|
|
916
|
+
const params = filterParams();
|
|
917
|
+
const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5", "home"];
|
|
918
|
+
const state = get();
|
|
919
|
+
const view = state.view;
|
|
920
|
+
const selectedPipeline = state.selectedPipeline;
|
|
921
|
+
let defaultPipelineId = "";
|
|
922
|
+
let mFilterValue = "";
|
|
923
|
+
const defaultPipeline = data?.data?.[0];
|
|
924
|
+
if (excludedIds.includes(hubspotObjectTypeId)) {
|
|
925
|
+
defaultPipelineId = defaultPipeline?.pipelineId || "";
|
|
926
|
+
}
|
|
927
|
+
if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
|
|
928
|
+
mFilterValue = params.filterValue;
|
|
929
|
+
} else {
|
|
930
|
+
if (view === "BOARD" && !selectedPipeline) {
|
|
931
|
+
mFilterValue = defaultPipelineId;
|
|
932
|
+
updateLink({
|
|
933
|
+
fV: defaultPipelineId
|
|
934
|
+
});
|
|
935
|
+
} else if (!excludedIds.includes(hubspotObjectTypeId)) {
|
|
936
|
+
mFilterValue = selectedPipeline || null;
|
|
937
|
+
} else {
|
|
938
|
+
mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
set({ selectedPipeline: mFilterValue });
|
|
942
|
+
return mFilterValue;
|
|
943
|
+
},
|
|
944
|
+
setTableData: (response) => {
|
|
945
|
+
set({
|
|
946
|
+
tableData: response
|
|
947
|
+
});
|
|
948
|
+
},
|
|
949
|
+
setTablePrependData: async (response) => {
|
|
950
|
+
const state = get();
|
|
951
|
+
let rows = [];
|
|
952
|
+
if (response === "loading") {
|
|
953
|
+
const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
|
|
954
|
+
if (!item.hidden) {
|
|
955
|
+
acc[item.key] = "loading";
|
|
956
|
+
}
|
|
957
|
+
return acc;
|
|
958
|
+
}, {});
|
|
959
|
+
rows = [row, ...state.tablePrependData];
|
|
960
|
+
} else {
|
|
961
|
+
const data = response?.data;
|
|
962
|
+
if (!data) {
|
|
963
|
+
set({
|
|
964
|
+
tablePrependData: []
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
const row = await Object.fromEntries(
|
|
968
|
+
Object.entries(data).map(([key, value]) => [
|
|
969
|
+
key,
|
|
970
|
+
value?.value ?? value
|
|
971
|
+
])
|
|
972
|
+
);
|
|
973
|
+
rows = [...state.tablePrependData];
|
|
974
|
+
if (rows.length > 0) {
|
|
975
|
+
rows[0] = row;
|
|
976
|
+
} else {
|
|
977
|
+
rows.push(row);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
set({
|
|
981
|
+
tablePrependData: rows
|
|
982
|
+
});
|
|
983
|
+
return rows;
|
|
984
|
+
}
|
|
985
|
+
}));
|
|
986
|
+
function useTable() {
|
|
987
|
+
const tableState = tableStore.getState();
|
|
988
|
+
return {
|
|
989
|
+
...tableState,
|
|
990
|
+
...{ listeners: { subscribe: tableStore.subscribe } }
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/store2/store.ts
|
|
995
|
+
function createStore2(initialState) {
|
|
996
|
+
let state = initialState;
|
|
997
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
998
|
+
return {
|
|
999
|
+
getState() {
|
|
1000
|
+
return state;
|
|
1001
|
+
},
|
|
1002
|
+
setState(partial) {
|
|
1003
|
+
state = {
|
|
1004
|
+
...state,
|
|
1005
|
+
...partial
|
|
1006
|
+
};
|
|
1007
|
+
listeners.forEach(
|
|
1008
|
+
(listener) => listener(state)
|
|
1009
|
+
);
|
|
1010
|
+
},
|
|
1011
|
+
subscribe(listener) {
|
|
1012
|
+
listeners.add(listener);
|
|
1013
|
+
return () => listeners.delete(listener);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// src/store2/use-form.ts
|
|
1019
|
+
var formStore = createStore2({
|
|
1020
|
+
form: null
|
|
1021
|
+
});
|
|
1022
|
+
var actions = {
|
|
1023
|
+
setFormData(response) {
|
|
1024
|
+
formStore.setState({
|
|
1025
|
+
form: response
|
|
1026
|
+
});
|
|
1027
|
+
}};
|
|
1028
|
+
|
|
1029
|
+
// src/store2/use-table.ts
|
|
1030
|
+
var tableStore2 = createStore2({
|
|
1031
|
+
queryParams: null,
|
|
1032
|
+
multiObjectsQueryParams: {},
|
|
1033
|
+
objectsData: null,
|
|
1034
|
+
tableData: [],
|
|
1035
|
+
tablePrependData: [],
|
|
1036
|
+
hubspotObjectTypeId: "",
|
|
1037
|
+
selectedPipeline: "",
|
|
1038
|
+
viewType: ""
|
|
1039
|
+
});
|
|
1040
|
+
var actions2 = {
|
|
1041
|
+
/** Called from Client.object.list — feeds purgeCrmListCache / purgeCrmRecordCache. */
|
|
1042
|
+
setObjectsQueryParams(params) {
|
|
1043
|
+
tableStore2.setState({
|
|
1044
|
+
queryParams: params
|
|
1045
|
+
});
|
|
1046
|
+
},
|
|
1047
|
+
/** Called from Client.object.sideBarList — feeds purgeCrmListCache for sidebarTable writes. */
|
|
1048
|
+
setMultiObjectsQueryParams(hubspotObjectTypeId, params) {
|
|
1049
|
+
if (!hubspotObjectTypeId) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
const state = tableStore2.getState();
|
|
1053
|
+
tableStore2.setState({
|
|
1054
|
+
multiObjectsQueryParams: {
|
|
1055
|
+
...state.multiObjectsQueryParams,
|
|
1056
|
+
[String(hubspotObjectTypeId)]: params
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
},
|
|
1060
|
+
async setObjectsData(response) {
|
|
1061
|
+
const state = tableStore2.getState();
|
|
1062
|
+
if (response?.info?.viewType == "LIST") {
|
|
1063
|
+
tableStore2.setState({
|
|
1064
|
+
objectsData: response
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
if (response?.info?.viewType == "BOARD") {
|
|
1068
|
+
const {
|
|
1069
|
+
stageId
|
|
1070
|
+
} = useTable();
|
|
1071
|
+
if (stageId) {
|
|
1072
|
+
const boardData = { ...state.objectsData };
|
|
1073
|
+
const updatedBoardData = await {
|
|
1074
|
+
...boardData,
|
|
1075
|
+
data: {
|
|
1076
|
+
...boardData.data,
|
|
1077
|
+
results: boardData.data.results.map(
|
|
1078
|
+
(item) => String(item.id) === String(stageId) ? {
|
|
1079
|
+
...item,
|
|
1080
|
+
data: {
|
|
1081
|
+
...item.data,
|
|
1082
|
+
results: {
|
|
1083
|
+
...item.data.results,
|
|
1084
|
+
rows: [
|
|
1085
|
+
...item?.data?.results?.rows ?? [],
|
|
1086
|
+
// keep existing rows
|
|
1087
|
+
...response?.data?.results?.rows ?? []
|
|
1088
|
+
// prepend new rows
|
|
1089
|
+
]
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
} : item
|
|
1093
|
+
)
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
tableStore2.setState({
|
|
1097
|
+
objectsData: updatedBoardData
|
|
1098
|
+
});
|
|
1099
|
+
} else {
|
|
1100
|
+
tableStore2.setState({
|
|
1101
|
+
objectsData: response
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
setTableData(response, payload) {
|
|
1107
|
+
const state = tableStore2.getState();
|
|
1108
|
+
const viewType = response?.info?.viewType;
|
|
1109
|
+
let newTablePrependData;
|
|
1110
|
+
if (viewType === "BOARD") {
|
|
1111
|
+
const stages = response?.data?.results ?? [];
|
|
1112
|
+
newTablePrependData = state.tablePrependData.map((prependStage) => {
|
|
1113
|
+
const matchingStage = stages.find(
|
|
1114
|
+
(stage) => String(stage.id) === String(prependStage.id)
|
|
1115
|
+
);
|
|
1116
|
+
const rows = matchingStage?.data?.results?.rows ?? [];
|
|
1117
|
+
const rowIds = new Set(
|
|
1118
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
1119
|
+
);
|
|
1120
|
+
const filteredRows = (prependStage?.data?.results?.rows ?? []).filter((item) => {
|
|
1121
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
1122
|
+
if (itemId == null || itemId === "") return true;
|
|
1123
|
+
return !rowIds.has(String(itemId));
|
|
1124
|
+
});
|
|
1125
|
+
return {
|
|
1126
|
+
...prependStage,
|
|
1127
|
+
data: {
|
|
1128
|
+
...prependStage.data,
|
|
1129
|
+
results: {
|
|
1130
|
+
...prependStage.data?.results,
|
|
1131
|
+
rows: filteredRows
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
});
|
|
1136
|
+
} else {
|
|
1137
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
1138
|
+
const rowIds = new Set(
|
|
1139
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
1140
|
+
);
|
|
1141
|
+
newTablePrependData = state.tablePrependData.filter((item) => {
|
|
1142
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
1143
|
+
if (itemId == null || itemId === "") return true;
|
|
1144
|
+
return !rowIds.has(String(itemId));
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
1148
|
+
const selectedPipeline = payload?.selectedPipeline;
|
|
1149
|
+
if (response?.data?.total < 1 || payload?.componentName) {
|
|
1150
|
+
newTablePrependData = [];
|
|
1151
|
+
}
|
|
1152
|
+
if (state.viewType && state.viewType != viewType) {
|
|
1153
|
+
newTablePrependData = [];
|
|
1154
|
+
}
|
|
1155
|
+
if (state.hubspotObjectTypeId && state.hubspotObjectTypeId != hubspotObjectTypeId) {
|
|
1156
|
+
newTablePrependData = [];
|
|
1157
|
+
}
|
|
1158
|
+
if (state.selectedPipeline && state.selectedPipeline != selectedPipeline) {
|
|
1159
|
+
newTablePrependData = [];
|
|
1160
|
+
}
|
|
1161
|
+
if (payload.isFristTimeLoadData) {
|
|
1162
|
+
newTablePrependData = [];
|
|
1163
|
+
}
|
|
1164
|
+
tableStore2.setState({
|
|
1165
|
+
tableData: response,
|
|
1166
|
+
tablePrependData: newTablePrependData || [],
|
|
1167
|
+
hubspotObjectTypeId,
|
|
1168
|
+
viewType
|
|
1169
|
+
});
|
|
1170
|
+
},
|
|
1171
|
+
modifiedObjectsData(results) {
|
|
1172
|
+
const state = tableStore2.getState();
|
|
1173
|
+
const tablePrependData = state.tablePrependData;
|
|
1174
|
+
const modifiedData = results.map((result) => {
|
|
1175
|
+
const matchedPrepend = tablePrependData.find(
|
|
1176
|
+
(item) => String(item?.id) === String(result?.id)
|
|
1177
|
+
);
|
|
1178
|
+
if (!matchedPrepend) {
|
|
1179
|
+
return result;
|
|
1180
|
+
}
|
|
1181
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
1182
|
+
const prependCards = prependRows.map((row) => ({
|
|
1183
|
+
id: row.hs_object_id,
|
|
1184
|
+
...row
|
|
1185
|
+
}));
|
|
1186
|
+
return {
|
|
1187
|
+
...result,
|
|
1188
|
+
// prepend in results.rows
|
|
1189
|
+
data: {
|
|
1190
|
+
...result.data,
|
|
1191
|
+
results: {
|
|
1192
|
+
...result.data.results,
|
|
1193
|
+
rows: [
|
|
1194
|
+
...prependRows,
|
|
1195
|
+
...result?.data?.results?.rows ?? []
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
// prepend in cards
|
|
1200
|
+
cards: [
|
|
1201
|
+
...prependCards,
|
|
1202
|
+
...result?.cards ?? []
|
|
1203
|
+
]
|
|
1204
|
+
};
|
|
1205
|
+
});
|
|
1206
|
+
tableStore2.setState({
|
|
1207
|
+
objectsData: modifiedData
|
|
1208
|
+
});
|
|
1209
|
+
},
|
|
1210
|
+
clearTablePrependData() {
|
|
1211
|
+
tableStore2.setState({
|
|
1212
|
+
tablePrependData: []
|
|
1213
|
+
});
|
|
1214
|
+
},
|
|
1215
|
+
async setTablePrependData(response, props) {
|
|
1216
|
+
const state = tableStore2.getState();
|
|
1217
|
+
const formState = formStore.getState();
|
|
1218
|
+
let rows = [];
|
|
1219
|
+
if (state.tableData?.info?.viewType == "BOARD") {
|
|
1220
|
+
if (response === "loading") {
|
|
1221
|
+
const responseData = state.tableData?.data?.results ?? [];
|
|
1222
|
+
const pipelineStage = props?.payload?.propertyPayload?.hs_pipeline_stage || props?.payload?.propertyPayload?.dealstage || formState?.form?.data?.pipelineDefaults?.defaultStage?.id;
|
|
1223
|
+
rows = responseData.map(
|
|
1224
|
+
({ id, data }) => {
|
|
1225
|
+
const matchedPrepend = state.tablePrependData.find(
|
|
1226
|
+
(item) => String(item.id) === String(id)
|
|
1227
|
+
);
|
|
1228
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
1229
|
+
const newRow = String(id) === String(pipelineStage) ? [
|
|
1230
|
+
(data?.results?.columns ?? []).reduce(
|
|
1231
|
+
(obj, column) => {
|
|
1232
|
+
obj[column.key] = "loading";
|
|
1233
|
+
return obj;
|
|
1234
|
+
},
|
|
1235
|
+
{}
|
|
1236
|
+
)
|
|
1237
|
+
] : [];
|
|
1238
|
+
return {
|
|
1239
|
+
id,
|
|
1240
|
+
data: {
|
|
1241
|
+
results: {
|
|
1242
|
+
columns: data?.results?.columns ?? [],
|
|
1243
|
+
// prepend loading row + prepend rows
|
|
1244
|
+
rows: [
|
|
1245
|
+
...newRow,
|
|
1246
|
+
...prependRows
|
|
1247
|
+
]
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
);
|
|
1253
|
+
} else {
|
|
1254
|
+
const data = response?.data;
|
|
1255
|
+
const hs_pipeline_stage = data?.hs_pipeline_stage?.value?.value || data?.dealstage?.value?.value;
|
|
1256
|
+
if (!data) {
|
|
1257
|
+
tableStore2.setState({
|
|
1258
|
+
tablePrependData: []
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
rows = state?.tablePrependData.map((row) => {
|
|
1262
|
+
const matchedPrepend = state.tablePrependData.find(
|
|
1263
|
+
(item) => String(item.id) === String(row.id)
|
|
1264
|
+
);
|
|
1265
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
1266
|
+
if (String(row.id) === String(hs_pipeline_stage)) {
|
|
1267
|
+
const updatedRow = (row?.data?.results?.columns ?? []).reduce(
|
|
1268
|
+
(obj, column) => {
|
|
1269
|
+
const key = column.key;
|
|
1270
|
+
obj[key] = data?.[key]?.value ?? data?.[key] ?? "";
|
|
1271
|
+
return obj;
|
|
1272
|
+
},
|
|
1273
|
+
{}
|
|
1274
|
+
);
|
|
1275
|
+
prependRows[0] = updatedRow;
|
|
1276
|
+
return {
|
|
1277
|
+
...row,
|
|
1278
|
+
data: {
|
|
1279
|
+
...row.data,
|
|
1280
|
+
results: {
|
|
1281
|
+
...row.data.results,
|
|
1282
|
+
rows: prependRows
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
return row;
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
} else if (state.tableData?.info?.viewType == "LIST") {
|
|
1291
|
+
if (response === "loading") {
|
|
1292
|
+
const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
|
|
1293
|
+
if (!item.hidden) {
|
|
1294
|
+
acc[item.key] = "loading";
|
|
1295
|
+
}
|
|
1296
|
+
return acc;
|
|
1297
|
+
}, {});
|
|
1298
|
+
rows = [row, ...state.tablePrependData];
|
|
1299
|
+
} else if (response?.data) {
|
|
1300
|
+
const data = response?.data;
|
|
1301
|
+
if (!data) {
|
|
1302
|
+
tableStore2.setState({
|
|
1303
|
+
tablePrependData: []
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
const row = await Object.fromEntries(
|
|
1307
|
+
Object.entries(data).map(([key, value]) => [
|
|
1308
|
+
key,
|
|
1309
|
+
value?.value ?? value
|
|
1310
|
+
])
|
|
1311
|
+
);
|
|
1312
|
+
rows = [...state.tablePrependData];
|
|
1313
|
+
if (rows.length > 0) {
|
|
1314
|
+
rows[0] = row;
|
|
1315
|
+
} else {
|
|
1316
|
+
rows.push(row);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
tableStore2.setState({
|
|
1321
|
+
tablePrependData: rows
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
// src/store2/use-uploader.ts
|
|
1327
|
+
var uploaderStore = createStore2({
|
|
1328
|
+
attachments: []
|
|
1329
|
+
});
|
|
1330
|
+
function toAttachmentSummary(attachment) {
|
|
1331
|
+
return {
|
|
1332
|
+
createdAt: attachment.createdAt,
|
|
1333
|
+
id: attachment.id,
|
|
1334
|
+
name: attachment.name,
|
|
1335
|
+
size: attachment.size,
|
|
1336
|
+
type: attachment.type,
|
|
1337
|
+
updatedAt: attachment.updatedAt
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
function resolveAttachmentsFromIds(attachmentIds, storedAttachments) {
|
|
1341
|
+
const raw = typeof attachmentIds === "object" && attachmentIds !== null && "value" in attachmentIds ? attachmentIds.value : attachmentIds;
|
|
1342
|
+
const ids = String(raw ?? "").split(";").map((id) => id.trim()).filter(Boolean);
|
|
1343
|
+
return ids.map((id) => storedAttachments.find((a) => String(a.id) === id)).filter((a) => a != null).map(toAttachmentSummary);
|
|
1344
|
+
}
|
|
1345
|
+
var actions3 = {
|
|
1346
|
+
setAttachment(response) {
|
|
1347
|
+
const data = response?.data;
|
|
1348
|
+
if (!data?.id) return;
|
|
1349
|
+
const state = uploaderStore.getState();
|
|
1350
|
+
const id = String(data.id);
|
|
1351
|
+
const existing = state.attachments;
|
|
1352
|
+
const index = existing.findIndex((item) => String(item.id) === id);
|
|
1353
|
+
const attachments = index >= 0 ? existing.map((item, i) => i === index ? data : item) : [...existing, data];
|
|
1354
|
+
uploaderStore.setState({ attachments });
|
|
1355
|
+
},
|
|
1356
|
+
clearAttachments() {
|
|
1357
|
+
uploaderStore.setState({ attachments: [] });
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
// src/store2/use-note.ts
|
|
1362
|
+
var noteStore = createStore2({
|
|
1363
|
+
notes: [],
|
|
1364
|
+
prependNotes: [],
|
|
1365
|
+
id: "",
|
|
1366
|
+
queryParams: null
|
|
1367
|
+
});
|
|
1368
|
+
var actions4 = {
|
|
1369
|
+
/** Called from Client.note.list — feeds purgeEngagementCaches (view: notes). */
|
|
1370
|
+
setListQueryParams(params) {
|
|
1371
|
+
noteStore.setState({
|
|
1372
|
+
queryParams: params
|
|
1373
|
+
});
|
|
1374
|
+
},
|
|
1375
|
+
setNotes(response, payload) {
|
|
1376
|
+
const state = noteStore.getState();
|
|
1377
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
1378
|
+
const rowIds = new Set(
|
|
1379
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
1380
|
+
);
|
|
1381
|
+
let newPrependNotes = state.prependNotes.filter((item) => {
|
|
1382
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
1383
|
+
if (itemId == null || itemId === "") return true;
|
|
1384
|
+
return !rowIds.has(String(itemId));
|
|
1385
|
+
});
|
|
1386
|
+
const id = payload?.params?.id;
|
|
1387
|
+
if (state.id && state.id != id) {
|
|
1388
|
+
newPrependNotes = [];
|
|
1389
|
+
}
|
|
1390
|
+
noteStore.setState({
|
|
1391
|
+
notes: response,
|
|
1392
|
+
prependNotes: newPrependNotes,
|
|
1393
|
+
id
|
|
1394
|
+
});
|
|
1395
|
+
},
|
|
1396
|
+
async setPrependNote(response) {
|
|
1397
|
+
const state = noteStore.getState();
|
|
1398
|
+
let rows = [];
|
|
1399
|
+
if (response === "loading") {
|
|
1400
|
+
const row = await state.notes?.data?.results?.columns.reduce((acc, item) => {
|
|
1401
|
+
if (!item.hidden) {
|
|
1402
|
+
acc[item.key] = "loading";
|
|
1403
|
+
}
|
|
1404
|
+
return acc;
|
|
1405
|
+
}, {});
|
|
1406
|
+
rows = [row, ...state.prependNotes];
|
|
1407
|
+
} else if (response?.data) {
|
|
1408
|
+
const data = response?.data;
|
|
1409
|
+
if (!data) {
|
|
1410
|
+
noteStore.setState({
|
|
1411
|
+
prependNotes: []
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
1415
|
+
const row = Object.fromEntries(
|
|
1416
|
+
Object.entries(data).map(([key, value]) => {
|
|
1417
|
+
if (key === "hs_attachment_ids") {
|
|
1418
|
+
return [
|
|
1419
|
+
key,
|
|
1420
|
+
resolveAttachmentsFromIds(value, storedAttachments)
|
|
1421
|
+
];
|
|
1422
|
+
}
|
|
1423
|
+
return [key, value?.value ?? value];
|
|
1424
|
+
})
|
|
1425
|
+
);
|
|
1426
|
+
rows = [...state.prependNotes];
|
|
1427
|
+
if (rows.length > 0) {
|
|
1428
|
+
rows[0] = row;
|
|
1429
|
+
} else {
|
|
1430
|
+
rows.push(row);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
noteStore.setState({
|
|
1434
|
+
prependNotes: rows
|
|
1435
|
+
});
|
|
1436
|
+
},
|
|
1437
|
+
clearPrependNotes() {
|
|
1438
|
+
noteStore.setState({
|
|
1439
|
+
prependNotes: []
|
|
1440
|
+
});
|
|
1441
|
+
actions3.clearAttachments();
|
|
1442
|
+
},
|
|
1443
|
+
async updatePrependNote(response) {
|
|
1444
|
+
const responseData = { ...response };
|
|
1445
|
+
const state = noteStore.getState();
|
|
1446
|
+
const prependNotes = state.prependNotes || [];
|
|
1447
|
+
const note = response.data || null;
|
|
1448
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
1449
|
+
const notes = prependNotes.map(
|
|
1450
|
+
(item) => item?.hs_object_id === note?.hs_object_id?.value ? {
|
|
1451
|
+
...item,
|
|
1452
|
+
...Object.fromEntries(
|
|
1453
|
+
Object.entries(note).map(([key, value]) => {
|
|
1454
|
+
if (key === "hs_attachment_ids") {
|
|
1455
|
+
return [
|
|
1456
|
+
key,
|
|
1457
|
+
resolveAttachmentsFromIds(value, storedAttachments)
|
|
1458
|
+
];
|
|
1459
|
+
}
|
|
1460
|
+
return [key, value?.value ?? value];
|
|
1461
|
+
})
|
|
1462
|
+
)
|
|
1463
|
+
} : item
|
|
1464
|
+
);
|
|
1465
|
+
noteStore.setState({
|
|
1466
|
+
prependNotes: notes
|
|
1467
|
+
});
|
|
1468
|
+
if (responseData?.data?.hs_attachment_ids != null) {
|
|
1469
|
+
const noteObjectId = note?.hs_object_id?.value;
|
|
1470
|
+
const rows = state.notes?.data?.results?.rows ?? [];
|
|
1471
|
+
const matchingRow = rows.find(
|
|
1472
|
+
(row) => String(row.hs_object_id) === String(noteObjectId)
|
|
1473
|
+
);
|
|
1474
|
+
const originalPrependItem = prependNotes.find(
|
|
1475
|
+
(item) => String(item?.hs_object_id) === String(noteObjectId)
|
|
1476
|
+
);
|
|
1477
|
+
const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
|
|
1478
|
+
const newAttachments = resolveAttachmentsFromIds(
|
|
1479
|
+
responseData.data.hs_attachment_ids,
|
|
1480
|
+
storedAttachments
|
|
1481
|
+
);
|
|
1482
|
+
const mergedAttachments = [
|
|
1483
|
+
...existingAttachments,
|
|
1484
|
+
...newAttachments.filter(
|
|
1485
|
+
(attachment) => !existingAttachments.some(
|
|
1486
|
+
(existing) => String(existing.id) === String(attachment.id)
|
|
1487
|
+
)
|
|
1488
|
+
)
|
|
1489
|
+
];
|
|
1490
|
+
const stateUpdates = {};
|
|
1491
|
+
if (matchingRow && state.notes?.data?.results) {
|
|
1492
|
+
stateUpdates.notes = {
|
|
1493
|
+
...state.notes,
|
|
1494
|
+
data: {
|
|
1495
|
+
...state.notes.data,
|
|
1496
|
+
results: {
|
|
1497
|
+
...state.notes.data.results,
|
|
1498
|
+
rows: rows.map(
|
|
1499
|
+
(row) => String(row.hs_object_id) === String(noteObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
|
|
1500
|
+
)
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
if (originalPrependItem) {
|
|
1506
|
+
stateUpdates.prependNotes = prependNotes.map(
|
|
1507
|
+
(item) => String(item?.hs_object_id) === String(noteObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
if (Object.keys(stateUpdates).length > 0) {
|
|
1511
|
+
noteStore.setState(stateUpdates);
|
|
1512
|
+
}
|
|
1513
|
+
responseData.data.hs_attachment_ids = mergedAttachments;
|
|
1514
|
+
}
|
|
1515
|
+
return responseData;
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
// src/store2/use-email.ts
|
|
1520
|
+
var emailStore = createStore2({
|
|
1521
|
+
emails: [],
|
|
1522
|
+
prependEmails: [],
|
|
1523
|
+
id: "",
|
|
1524
|
+
queryParams: null
|
|
1525
|
+
});
|
|
1526
|
+
var actions5 = {
|
|
1527
|
+
/** Called from Client.email.list — feeds purgeEngagementCaches (view: emails). */
|
|
1528
|
+
setListQueryParams(params) {
|
|
1529
|
+
emailStore.setState({
|
|
1530
|
+
queryParams: params
|
|
1531
|
+
});
|
|
1532
|
+
},
|
|
1533
|
+
setEmails(response, payload) {
|
|
1534
|
+
const state = emailStore.getState();
|
|
1535
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
1536
|
+
const rowIds = new Set(
|
|
1537
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
1538
|
+
);
|
|
1539
|
+
let newPrependEmails = state.prependEmails.filter((item) => {
|
|
1540
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
1541
|
+
if (itemId == null || itemId === "") return true;
|
|
1542
|
+
return !rowIds.has(String(itemId));
|
|
1543
|
+
});
|
|
1544
|
+
const id = payload?.params?.id;
|
|
1545
|
+
if (state.id && state.id != id) {
|
|
1546
|
+
newPrependEmails = [];
|
|
1547
|
+
}
|
|
1548
|
+
emailStore.setState({
|
|
1549
|
+
emails: response,
|
|
1550
|
+
prependEmails: newPrependEmails,
|
|
1551
|
+
id
|
|
1552
|
+
});
|
|
1553
|
+
},
|
|
1554
|
+
async setPrependEmail(response) {
|
|
1555
|
+
const state = emailStore.getState();
|
|
1556
|
+
let rows = [];
|
|
1557
|
+
if (response === "loading") {
|
|
1558
|
+
const row = await state.emails?.data?.results?.columns.reduce((acc, item) => {
|
|
1559
|
+
if (!item.hidden) {
|
|
1560
|
+
acc[item.key] = "loading";
|
|
1561
|
+
}
|
|
1562
|
+
return acc;
|
|
1563
|
+
}, {});
|
|
1564
|
+
rows = [row, ...state.prependEmails];
|
|
1565
|
+
} else if (response?.data) {
|
|
1566
|
+
const data = response?.data;
|
|
1567
|
+
if (!data) {
|
|
1568
|
+
emailStore.setState({
|
|
1569
|
+
prependEmails: []
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
1573
|
+
const row = Object.fromEntries(
|
|
1574
|
+
Object.entries(data).map(([key, value]) => {
|
|
1575
|
+
if (key === "hs_attachment_ids") {
|
|
1576
|
+
return [
|
|
1577
|
+
key,
|
|
1578
|
+
resolveAttachmentsFromIds(value, storedAttachments)
|
|
1579
|
+
];
|
|
1580
|
+
}
|
|
1581
|
+
return [key, value?.value ?? value];
|
|
1582
|
+
})
|
|
1583
|
+
);
|
|
1584
|
+
rows = [...state.prependEmails];
|
|
1585
|
+
if (rows.length > 0) {
|
|
1586
|
+
rows[0] = row;
|
|
1587
|
+
} else {
|
|
1588
|
+
rows.push(row);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
emailStore.setState({
|
|
1592
|
+
prependEmails: rows
|
|
1593
|
+
});
|
|
1594
|
+
},
|
|
1595
|
+
clearPrependEmails() {
|
|
1596
|
+
emailStore.setState({
|
|
1597
|
+
prependEmails: []
|
|
1598
|
+
});
|
|
1599
|
+
actions3.clearAttachments();
|
|
1600
|
+
},
|
|
1601
|
+
async updatePrependEmail(response) {
|
|
1602
|
+
const responseData = { ...response };
|
|
1603
|
+
const state = emailStore.getState();
|
|
1604
|
+
const prependEmails = state.prependEmails || [];
|
|
1605
|
+
const email = response.data || null;
|
|
1606
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
1607
|
+
const emails = prependEmails.map(
|
|
1608
|
+
(item) => item?.hs_object_id === email?.hs_object_id?.value ? {
|
|
1609
|
+
...item,
|
|
1610
|
+
...Object.fromEntries(
|
|
1611
|
+
Object.entries(email).map(([key, value]) => {
|
|
1612
|
+
if (key === "hs_attachment_ids") {
|
|
1613
|
+
return [
|
|
1614
|
+
key,
|
|
1615
|
+
resolveAttachmentsFromIds(value, storedAttachments)
|
|
1616
|
+
];
|
|
1617
|
+
}
|
|
1618
|
+
return [key, value?.value ?? value];
|
|
1619
|
+
})
|
|
1620
|
+
)
|
|
1621
|
+
} : item
|
|
1622
|
+
);
|
|
1623
|
+
emailStore.setState({
|
|
1624
|
+
prependEmails: emails
|
|
1625
|
+
});
|
|
1626
|
+
if (responseData?.data?.hs_attachment_ids != null) {
|
|
1627
|
+
const emailObjectId = email?.hs_object_id?.value;
|
|
1628
|
+
const rows = state.emails?.data?.results?.rows ?? [];
|
|
1629
|
+
const matchingRow = rows.find(
|
|
1630
|
+
(row) => String(row.hs_object_id) === String(emailObjectId)
|
|
1631
|
+
);
|
|
1632
|
+
const originalPrependItem = prependEmails.find(
|
|
1633
|
+
(item) => String(item?.hs_object_id) === String(emailObjectId)
|
|
1634
|
+
);
|
|
1635
|
+
const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
|
|
1636
|
+
const newAttachments = resolveAttachmentsFromIds(
|
|
1637
|
+
responseData.data.hs_attachment_ids,
|
|
1638
|
+
storedAttachments
|
|
1639
|
+
);
|
|
1640
|
+
const mergedAttachments = [
|
|
1641
|
+
...existingAttachments,
|
|
1642
|
+
...newAttachments.filter(
|
|
1643
|
+
(attachment) => !existingAttachments.some(
|
|
1644
|
+
(existing) => String(existing.id) === String(attachment.id)
|
|
1645
|
+
)
|
|
1646
|
+
)
|
|
1647
|
+
];
|
|
1648
|
+
const stateUpdates = {};
|
|
1649
|
+
if (matchingRow && state.emails?.data?.results) {
|
|
1650
|
+
stateUpdates.emails = {
|
|
1651
|
+
...state.emails,
|
|
1652
|
+
data: {
|
|
1653
|
+
...state.emails.data,
|
|
1654
|
+
results: {
|
|
1655
|
+
...state.emails.data.results,
|
|
1656
|
+
rows: rows.map(
|
|
1657
|
+
(row) => String(row.hs_object_id) === String(emailObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
|
|
1658
|
+
)
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
if (originalPrependItem) {
|
|
1664
|
+
stateUpdates.prependEmails = prependEmails.map(
|
|
1665
|
+
(item) => String(item?.hs_object_id) === String(emailObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
|
|
1666
|
+
);
|
|
1667
|
+
}
|
|
1668
|
+
if (Object.keys(stateUpdates).length > 0) {
|
|
1669
|
+
emailStore.setState(stateUpdates);
|
|
1670
|
+
}
|
|
1671
|
+
responseData.data.hs_attachment_ids = mergedAttachments;
|
|
1672
|
+
}
|
|
1673
|
+
return responseData;
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
// src/store2/use-file.ts
|
|
1678
|
+
var fileStore = createStore2({
|
|
1679
|
+
queryParams: null
|
|
1680
|
+
});
|
|
1681
|
+
var actions6 = {
|
|
1682
|
+
/** Called from Client.file.list — feeds purgeEngagementCaches (view: files). */
|
|
1683
|
+
setListQueryParams(params) {
|
|
1684
|
+
fileStore.setState({
|
|
1685
|
+
queryParams: params
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
// src/utils/cache/builders.ts
|
|
1691
|
+
function buildCrmListPurgeTarget(objectTypeId, listQuery) {
|
|
1692
|
+
return {
|
|
1693
|
+
domain: "crm_object_data",
|
|
1694
|
+
objectTypeId,
|
|
1695
|
+
views: ["list"],
|
|
1696
|
+
listQuery: listQuery ?? { page: 1, limit: 10, view: "LIST" }
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
function buildCrmSinglePurgeTarget(objectTypeId, recordIds, listQuery) {
|
|
1700
|
+
return {
|
|
1701
|
+
domain: "crm_object_data",
|
|
1702
|
+
objectTypeId,
|
|
1703
|
+
views: ["single"],
|
|
1704
|
+
recordIds,
|
|
1705
|
+
listQuery
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
function buildEngagementPurgeTarget(objectTypeId, recordIds, views, options) {
|
|
1709
|
+
if (!recordIds.length) {
|
|
1710
|
+
throw new Error("recordIds is required for engagement purge views");
|
|
1711
|
+
}
|
|
1712
|
+
return {
|
|
1713
|
+
domain: "crm_object_data",
|
|
1714
|
+
objectTypeId,
|
|
1715
|
+
recordIds,
|
|
1716
|
+
views,
|
|
1717
|
+
fileIds: options?.fileIds,
|
|
1718
|
+
listQuery: options?.listQuery ?? { page: 1, limit: 10 }
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function buildUserSessionPurgeTarget() {
|
|
1722
|
+
return { domain: "user_session" };
|
|
1723
|
+
}
|
|
1724
|
+
function buildPortalConfigPurgeTarget(objectTypeIds) {
|
|
1725
|
+
return {
|
|
1726
|
+
domain: "portal_object_config",
|
|
1727
|
+
objectTypeIds
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
function mergePurgeTargets(...targets) {
|
|
1731
|
+
return targets;
|
|
1732
|
+
}
|
|
1733
|
+
function buildCachePurgeRequest(targets, options) {
|
|
1734
|
+
return {
|
|
1735
|
+
mode: options?.mode ?? "soft",
|
|
1736
|
+
warm: options?.warm ?? true,
|
|
1737
|
+
includeContactAccess: options?.includeContactAccess ?? true,
|
|
1738
|
+
includeShortOnHard: options?.includeShortOnHard ?? false,
|
|
1739
|
+
confirmPortalWide: options?.confirmPortalWide ?? false,
|
|
1740
|
+
targets
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// src/utils/cache/createCachePurgeJob.ts
|
|
1745
|
+
function randomIdempotencyKey() {
|
|
1746
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
1747
|
+
return crypto.randomUUID();
|
|
1748
|
+
}
|
|
1749
|
+
return `purge-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1750
|
+
}
|
|
1751
|
+
function mapErrorCode(status, message) {
|
|
1752
|
+
if (status === 400 || status === 422) {
|
|
1753
|
+
return "VALIDATION";
|
|
1754
|
+
}
|
|
1755
|
+
if (status === 429) {
|
|
1756
|
+
return "RATE_LIMITED";
|
|
1757
|
+
}
|
|
1758
|
+
if (message?.toLowerCase().includes("disabled")) {
|
|
1759
|
+
return "PURGE_API_DISABLED";
|
|
1760
|
+
}
|
|
1761
|
+
return status ? "UNKNOWN" : "NETWORK";
|
|
1762
|
+
}
|
|
1763
|
+
function sleep(ms) {
|
|
1764
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1765
|
+
}
|
|
1766
|
+
async function createCachePurgeJob(request, options = {}) {
|
|
1767
|
+
const idempotencyKey = options.idempotencyKey ?? randomIdempotencyKey();
|
|
1768
|
+
try {
|
|
1769
|
+
const headers = { "Idempotency-Key": idempotencyKey };
|
|
1770
|
+
const response = await Client.cache.purge(
|
|
1771
|
+
request,
|
|
1772
|
+
headers
|
|
1773
|
+
);
|
|
1774
|
+
const data = response?.data;
|
|
1775
|
+
const purgeJobId = data?.purgeJobId;
|
|
1776
|
+
let status = data?.status;
|
|
1777
|
+
if (options.waitForWarm && purgeJobId && request.warm !== false) {
|
|
1778
|
+
const timeout = options.pollTimeoutMs ?? 3e4;
|
|
1779
|
+
const interval = options.pollIntervalMs ?? 500;
|
|
1780
|
+
const deadline = Date.now() + timeout;
|
|
1781
|
+
while (Date.now() < deadline) {
|
|
1782
|
+
const statusRes = await Client.cache.purgeStatus(purgeJobId);
|
|
1783
|
+
const job = statusRes?.data;
|
|
1784
|
+
const jobStatus = job?.status;
|
|
1785
|
+
if (jobStatus === "completed") {
|
|
1786
|
+
status = "completed";
|
|
1787
|
+
break;
|
|
1788
|
+
}
|
|
1789
|
+
if (jobStatus === "failed") {
|
|
1790
|
+
return {
|
|
1791
|
+
ok: false,
|
|
1792
|
+
purgeJobId,
|
|
1793
|
+
status: "failed",
|
|
1794
|
+
errorCode: "WARM_FAILED",
|
|
1795
|
+
message: "Cache warm job failed"
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
await sleep(interval);
|
|
1799
|
+
}
|
|
1800
|
+
if (status !== "completed") {
|
|
1801
|
+
return {
|
|
1802
|
+
ok: false,
|
|
1803
|
+
purgeJobId,
|
|
1804
|
+
status: status ?? "warming",
|
|
1805
|
+
errorCode: "WARM_FAILED",
|
|
1806
|
+
message: "Timed out waiting for cache warm job"
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return {
|
|
1811
|
+
ok: true,
|
|
1812
|
+
purgeJobId,
|
|
1813
|
+
status,
|
|
1814
|
+
evicted: data?.evicted,
|
|
1815
|
+
warnings: data?.warnings
|
|
1816
|
+
};
|
|
1817
|
+
} catch (err) {
|
|
1818
|
+
const axiosErr = err;
|
|
1819
|
+
const status = axiosErr.response?.status;
|
|
1820
|
+
const message = axiosErr.response?.data?.message ?? (err instanceof Error ? err.message : "Cache purge request failed");
|
|
1821
|
+
return {
|
|
1822
|
+
ok: false,
|
|
1823
|
+
errorCode: mapErrorCode(status, message),
|
|
1824
|
+
message
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// src/utils/cache/crmCacheRefresh.ts
|
|
1830
|
+
async function purgeCrmObjectDataCache(options) {
|
|
1831
|
+
const result = await purgeCrmListCache(options);
|
|
1832
|
+
return result.ok;
|
|
1833
|
+
}
|
|
1834
|
+
async function purgeCrmListCache(options) {
|
|
1835
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
1836
|
+
if (!objectTypeId) {
|
|
1837
|
+
return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
|
|
1838
|
+
}
|
|
1839
|
+
const target = buildCrmListPurgeTarget(objectTypeId, options.listQuery);
|
|
1840
|
+
const request = buildCachePurgeRequest([target], {
|
|
1841
|
+
mode: options.mode,
|
|
1842
|
+
warm: options.warm
|
|
1843
|
+
});
|
|
1844
|
+
return createCachePurgeJob(request, {
|
|
1845
|
+
idempotencyKey: options.idempotencyKey,
|
|
1846
|
+
waitForWarm: options.waitForWarm
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
async function purgeCrmRecordCache(options) {
|
|
1850
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
1851
|
+
if (!objectTypeId || !options.recordIds?.length) {
|
|
1852
|
+
return {
|
|
1853
|
+
ok: false,
|
|
1854
|
+
errorCode: "VALIDATION",
|
|
1855
|
+
message: "objectTypeId and recordIds are required"
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
const target = buildCrmSinglePurgeTarget(
|
|
1859
|
+
objectTypeId,
|
|
1860
|
+
options.recordIds,
|
|
1861
|
+
options.listQuery
|
|
1862
|
+
);
|
|
1863
|
+
const request = buildCachePurgeRequest([target], {
|
|
1864
|
+
mode: options.mode,
|
|
1865
|
+
warm: options.warm
|
|
1866
|
+
});
|
|
1867
|
+
return createCachePurgeJob(request, {
|
|
1868
|
+
idempotencyKey: options.idempotencyKey,
|
|
1869
|
+
waitForWarm: options.waitForWarm
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
async function purgeEngagementCaches(options) {
|
|
1873
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
1874
|
+
if (!objectTypeId || !options.recordIds?.length || !options.views?.length) {
|
|
1875
|
+
return {
|
|
1876
|
+
ok: false,
|
|
1877
|
+
errorCode: "VALIDATION",
|
|
1878
|
+
message: "objectTypeId, recordIds, and views are required"
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
const target = buildEngagementPurgeTarget(
|
|
1882
|
+
objectTypeId,
|
|
1883
|
+
options.recordIds,
|
|
1884
|
+
options.views,
|
|
1885
|
+
{ fileIds: options.fileIds, listQuery: options.listQuery }
|
|
1886
|
+
);
|
|
1887
|
+
const request = buildCachePurgeRequest([target], {
|
|
1888
|
+
mode: options.mode,
|
|
1889
|
+
warm: options.warm
|
|
1890
|
+
});
|
|
1891
|
+
return createCachePurgeJob(request, {
|
|
1892
|
+
idempotencyKey: options.idempotencyKey,
|
|
1893
|
+
waitForWarm: options.waitForWarm
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
async function purgeCrmCombined(options) {
|
|
1897
|
+
const request = buildCachePurgeRequest(options.targets, {
|
|
1898
|
+
mode: options.mode,
|
|
1899
|
+
warm: options.warm
|
|
1900
|
+
});
|
|
1901
|
+
return createCachePurgeJob(request, {
|
|
1902
|
+
idempotencyKey: options.idempotencyKey,
|
|
1903
|
+
waitForWarm: options.waitForWarm
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
// src/client/index.ts
|
|
1908
|
+
var recordWriteContext = (paramsObject) => {
|
|
1909
|
+
if (!paramsObject) {
|
|
1910
|
+
return void 0;
|
|
1911
|
+
}
|
|
1912
|
+
const context = {};
|
|
1913
|
+
const keys = [
|
|
1914
|
+
"parentObjectTypeId",
|
|
1915
|
+
"parentObjectRecordId",
|
|
1916
|
+
"mediatorObjectTypeId",
|
|
1917
|
+
"mediatorObjectRecordId"
|
|
1918
|
+
];
|
|
1919
|
+
keys.forEach((key) => {
|
|
1920
|
+
const value = paramsObject[key];
|
|
1921
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
1922
|
+
context[key] = String(value);
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
1926
|
+
};
|
|
1927
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
1928
|
+
const base = { ...payload || {} };
|
|
1929
|
+
const context = recordWriteContext(paramsObject);
|
|
1930
|
+
if (context) {
|
|
1931
|
+
base.context = context;
|
|
1932
|
+
}
|
|
1933
|
+
if (options && Object.keys(options).length > 0) {
|
|
1934
|
+
base.options = options;
|
|
1935
|
+
}
|
|
1936
|
+
return base;
|
|
1937
|
+
};
|
|
1938
|
+
var Client = {
|
|
1939
|
+
authentication: {
|
|
1940
|
+
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
1941
|
+
login: (data) => {
|
|
1942
|
+
const queryParams = config.hubId ? { hubId: config.hubId } : null;
|
|
1943
|
+
return AuthHttpClient.post(
|
|
1944
|
+
generateApiUrl({ route: API_ENDPOINTS.LOGIN, queryParams }),
|
|
1945
|
+
data,
|
|
1946
|
+
config?.devPortalId && {
|
|
1947
|
+
headers: {
|
|
1948
|
+
"X-Dev-Portal-Id": config.devPortalId
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
);
|
|
1952
|
+
},
|
|
1953
|
+
verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
|
|
1954
|
+
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
1955
|
+
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
1956
|
+
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
1957
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
1958
|
+
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
|
|
1959
|
+
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
1960
|
+
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
1961
|
+
},
|
|
1962
|
+
sso: {
|
|
1963
|
+
getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
|
|
1964
|
+
generateSsoUrl: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_URL, queryParams: payload?.queryParams })),
|
|
1965
|
+
ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
|
|
1966
|
+
},
|
|
1967
|
+
user: {
|
|
1968
|
+
me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
|
|
1969
|
+
profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
|
|
1970
|
+
changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
|
|
1971
|
+
},
|
|
1972
|
+
pipeline: {
|
|
1973
|
+
list: (payload = null, param = null) => {
|
|
1974
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
1975
|
+
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
1976
|
+
const { paramsObject } = getParamDetails2({ type: payload?.componentName });
|
|
1977
|
+
const userData = getProfileData();
|
|
1978
|
+
const apiParams = {};
|
|
1979
|
+
if (paramsObject?.parentObjectTypeId) {
|
|
1980
|
+
apiParams.parentObjectTypeId = paramsObject?.parentObjectTypeId;
|
|
1981
|
+
} else if (payload?.isHome && userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
1982
|
+
apiParams.parentObjectTypeId = userData?.data?.info?.objectTypeId;
|
|
1983
|
+
} else if (payload?.isHome && userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
1984
|
+
apiParams.parentObjectTypeId = "0-2";
|
|
1985
|
+
}
|
|
1986
|
+
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
1987
|
+
apiParams.cache = payload?.cache;
|
|
1988
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
1989
|
+
return HttpClient.get(apiUrl);
|
|
1990
|
+
}
|
|
1991
|
+
},
|
|
1992
|
+
stage: {
|
|
1993
|
+
list: (props = null) => {
|
|
1994
|
+
const params = {
|
|
1995
|
+
// hubId: config.hubId,
|
|
1996
|
+
// portalId: portalId,
|
|
1997
|
+
objectTypeId: props?.params?.objectTypeId,
|
|
1998
|
+
pipelineId: props?.params?.pipelineId
|
|
1999
|
+
};
|
|
2000
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
|
|
2001
|
+
return HttpClient.get(apiUrl);
|
|
2002
|
+
}
|
|
2003
|
+
},
|
|
2004
|
+
object: {
|
|
2005
|
+
list: async (payload = null, param = null) => {
|
|
2006
|
+
const { setObjectsQueryParams } = actions2;
|
|
2007
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
2008
|
+
const { updateLink, getLinkParams } = useUpdateLink();
|
|
2009
|
+
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
2010
|
+
const { paramsObject, parentAccessLabel } = getParamDetails2({ type: payload?.componentName });
|
|
2011
|
+
const userData = getProfileData();
|
|
2012
|
+
const pipeline = payload?.variables?.pipeline;
|
|
2013
|
+
const mPipelines = payload?.variables?.mPipelines;
|
|
2014
|
+
const mSelectedPipeline = pipeline !== void 0 ? pipeline : payload?.selectedPipeline;
|
|
2015
|
+
if (mSelectedPipeline) {
|
|
2016
|
+
param.filterValue = mSelectedPipeline;
|
|
2017
|
+
} else if (payload?.specPipeLine && payload?.pipeLineId) {
|
|
2018
|
+
param.filterValue = payload?.pipeLineId;
|
|
2019
|
+
} else if (payload?.hubspotObjectTypeId != "0-3" || payload?.hubspotObjectTypeId != "0-5") {
|
|
2020
|
+
param.filterValue = "";
|
|
2021
|
+
}
|
|
2022
|
+
const fParams = getLinkParams();
|
|
2023
|
+
param = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : param, ...paramsObject };
|
|
2024
|
+
if (!payload?.isFristTimeLoadData || !fParams) {
|
|
2025
|
+
await updateLink({
|
|
2026
|
+
"sort": param?.sort,
|
|
2027
|
+
"s": param?.search,
|
|
2028
|
+
"fPn": param?.filterPropertyName,
|
|
2029
|
+
"fO": param?.filterOperator,
|
|
2030
|
+
"fV": param?.filterValue,
|
|
2031
|
+
// "c": param?.cache,
|
|
2032
|
+
"isPC": param?.isPrimaryCompany,
|
|
2033
|
+
"v": param?.view,
|
|
2034
|
+
"l": param?.limit,
|
|
2035
|
+
"p": param?.page,
|
|
2036
|
+
"a": param?.after
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
|
|
2040
|
+
param.filterValue = "";
|
|
2041
|
+
await updateLink({
|
|
2042
|
+
"fV": param?.filterValue
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
|
|
2046
|
+
param.filterValue = mPipelines[0].pipelineId;
|
|
2047
|
+
await updateLink({
|
|
2048
|
+
"fV": param?.filterValue
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
if (payload?.isHome || payload?.hubspotObjectTypeId === "0-5" && payload?.componentName === "object") {
|
|
2052
|
+
let parentObjectTypeId = "";
|
|
2053
|
+
if (userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
2054
|
+
parentObjectTypeId = userData?.data?.info?.objectTypeId;
|
|
2055
|
+
} else if (userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
2056
|
+
parentObjectTypeId = "0-2";
|
|
2057
|
+
}
|
|
2058
|
+
param.parentObjectTypeId = parentObjectTypeId;
|
|
2059
|
+
}
|
|
2060
|
+
param.parentAccessLabel = parentAccessLabel;
|
|
2061
|
+
const {
|
|
2062
|
+
stageId,
|
|
2063
|
+
nextPage
|
|
2064
|
+
} = useTable();
|
|
2065
|
+
if (stageId) {
|
|
2066
|
+
param.stageId = stageId;
|
|
2067
|
+
}
|
|
2068
|
+
if (param?.view === "BOARD") {
|
|
2069
|
+
param.page = nextPage;
|
|
2070
|
+
}
|
|
2071
|
+
setObjectsQueryParams(param);
|
|
2072
|
+
param.cache = payload?.cache;
|
|
2073
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
2074
|
+
return HttpClient.get(apiUrl);
|
|
2075
|
+
},
|
|
2076
|
+
sideBarList: async (payload = null) => {
|
|
2077
|
+
const { setMultiObjectsQueryParams } = actions2;
|
|
2078
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
2079
|
+
const params = { hubspotObjectTypeId };
|
|
2080
|
+
const queryParams = payload.param;
|
|
2081
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
|
|
2082
|
+
setMultiObjectsQueryParams(hubspotObjectTypeId, queryParams ?? {});
|
|
2083
|
+
return HttpClient.get(apiUrl);
|
|
2084
|
+
},
|
|
2085
|
+
form: (payload = null) => {
|
|
2086
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
2087
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
2088
|
+
return HttpClient.get(apiUrl);
|
|
2089
|
+
},
|
|
2090
|
+
objectFormOptions: (payload = null) => {
|
|
2091
|
+
const params = {
|
|
2092
|
+
formId: payload?.formId,
|
|
2093
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
2094
|
+
};
|
|
2095
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
2096
|
+
return HttpClient.get(apiUrl);
|
|
2097
|
+
},
|
|
2098
|
+
create: async (props = null) => {
|
|
2099
|
+
const { getParamDetails: getParamDetailsForCreate } = routeParam;
|
|
2100
|
+
const { paramsObject } = getParamDetailsForCreate({ type: props?.componentName });
|
|
2101
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
2102
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, {
|
|
2103
|
+
cardParentMerge,
|
|
2104
|
+
addAnother: props?.params?.addAnother
|
|
2105
|
+
});
|
|
2106
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
2107
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
2108
|
+
const response = await HttpClient.post(apiUrl, body);
|
|
2109
|
+
const { queryParams, multiObjectsQueryParams } = tableStore2.getState();
|
|
2110
|
+
const listQuery = props?.componentName === "association" ? {} : props?.componentName === "sidebarTable" ? multiObjectsQueryParams?.[String(props?.hubspotObjectTypeId)] ?? {} : queryParams ?? {};
|
|
2111
|
+
const objectTypeId = props?.hubspotObjectTypeId;
|
|
2112
|
+
if (objectTypeId) {
|
|
2113
|
+
purgeCrmListCache({ objectTypeId, listQuery });
|
|
2114
|
+
}
|
|
2115
|
+
return response;
|
|
2116
|
+
},
|
|
2117
|
+
createExisting: (props = null) => {
|
|
2118
|
+
const { getLinkParams } = useUpdateLink();
|
|
2119
|
+
const fParams = getLinkParams();
|
|
2120
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
2121
|
+
const params = {
|
|
2122
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
2123
|
+
fromRecordId: props?.fromRecordId,
|
|
2124
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
2125
|
+
};
|
|
2126
|
+
const payload = props.payload;
|
|
2127
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
2128
|
+
return HttpClient.post(apiUrl, payload);
|
|
2129
|
+
},
|
|
2130
|
+
removeExisting: (props = null) => {
|
|
2131
|
+
const { getParamDetails: getParamDetailsForRemove } = routeParam;
|
|
2132
|
+
const { paramsObject } = getParamDetailsForRemove({ type: props?.componentName });
|
|
2133
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
|
|
2134
|
+
const params = {
|
|
2135
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
2136
|
+
fromRecordId: props?.fromRecordId,
|
|
2137
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
2138
|
+
};
|
|
2139
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
|
|
2140
|
+
return HttpClient.delete(apiUrl, { data: body });
|
|
2141
|
+
},
|
|
2142
|
+
details: (props = null) => {
|
|
2143
|
+
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
2144
|
+
const hubspotObjectTypeId = ticketHubspotObjectTypeId();
|
|
2145
|
+
const params = {
|
|
2146
|
+
// hubId: config.hubId,
|
|
2147
|
+
// portalId: portalId,
|
|
2148
|
+
objectId: props?.params?.objectId,
|
|
2149
|
+
id: props?.params?.id
|
|
2150
|
+
};
|
|
2151
|
+
const queryParams = {
|
|
2152
|
+
parentAccessLabel,
|
|
2153
|
+
...props?.queryParams,
|
|
2154
|
+
...urlParam
|
|
2155
|
+
};
|
|
2156
|
+
if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
|
|
2157
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
|
|
2158
|
+
return HttpClient.get(apiUrl);
|
|
2159
|
+
},
|
|
2160
|
+
update: async (props = null) => {
|
|
2161
|
+
const hubspotObjectTypeId = ticketHubspotObjectTypeId();
|
|
2162
|
+
const params = {
|
|
2163
|
+
objectId: props?.params?.objectId,
|
|
2164
|
+
id: props?.params?.id
|
|
2165
|
+
};
|
|
2166
|
+
const { getParamDetails: getParamDetailsForUpdate } = routeParam;
|
|
2167
|
+
const { paramsObject } = getParamDetailsForUpdate({ type: props?.componentName });
|
|
2168
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
2169
|
+
const rawPayload = props?.payload || {};
|
|
2170
|
+
const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
|
|
2171
|
+
const body = mergeRecordWriteBody(
|
|
2172
|
+
{ properties },
|
|
2173
|
+
paramsObject,
|
|
2174
|
+
{ cardParentMerge }
|
|
2175
|
+
);
|
|
2176
|
+
const queryParams = {};
|
|
2177
|
+
if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
|
|
2178
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params, queryParams });
|
|
2179
|
+
const { queryParams: tableQueryParams, multiObjectsQueryParams } = tableStore2.getState();
|
|
2180
|
+
const listQuery = props?.componentName === "sidebarTable" ? multiObjectsQueryParams?.[String(props?.hubspotObjectTypeId)] ?? {} : tableQueryParams ?? {};
|
|
2181
|
+
const response = await HttpClient.put(apiUrl, body);
|
|
2182
|
+
const objectTypeId = props?.hubspotObjectTypeId ?? props?.params?.objectId;
|
|
2183
|
+
const recordId = props?.params?.id;
|
|
2184
|
+
if (objectTypeId && recordId) {
|
|
2185
|
+
purgeCrmRecordCache({
|
|
2186
|
+
objectTypeId: String(objectTypeId),
|
|
2187
|
+
recordIds: [String(recordId)],
|
|
2188
|
+
listQuery
|
|
2189
|
+
});
|
|
2190
|
+
} else if (objectTypeId) {
|
|
2191
|
+
purgeCrmListCache({ objectTypeId: String(objectTypeId), listQuery });
|
|
2192
|
+
}
|
|
2193
|
+
return response;
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2196
|
+
note: {
|
|
2197
|
+
list: (props = null) => {
|
|
2198
|
+
const { setListQueryParams } = actions4;
|
|
2199
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
2200
|
+
const params = {
|
|
2201
|
+
// hubId: config.hubId,
|
|
2202
|
+
// portalId: portalId,
|
|
2203
|
+
objectId: props?.params?.objectId,
|
|
2204
|
+
id: props?.params?.id
|
|
2205
|
+
};
|
|
2206
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
|
|
2207
|
+
return HttpClient.get(apiUrl);
|
|
2208
|
+
},
|
|
2209
|
+
create: async (props = null) => {
|
|
2210
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2211
|
+
const queryParams = props.queryParams;
|
|
2212
|
+
const payload = props.payload;
|
|
2213
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
|
|
2214
|
+
const listQuery = noteStore.getState().queryParams ?? {};
|
|
2215
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
2216
|
+
const recordId = props?.params?.id;
|
|
2217
|
+
const objectTypeId = props?.params?.objectId;
|
|
2218
|
+
if (recordId && objectTypeId) {
|
|
2219
|
+
purgeEngagementCaches({
|
|
2220
|
+
objectTypeId,
|
|
2221
|
+
recordIds: [String(recordId)],
|
|
2222
|
+
views: ["notes"],
|
|
2223
|
+
listQuery
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
return response;
|
|
2227
|
+
},
|
|
2228
|
+
update: async (props = null) => {
|
|
2229
|
+
const params = {
|
|
2230
|
+
// hubId: config.hubId,
|
|
2231
|
+
// portalId: portalId,
|
|
2232
|
+
objectId: props?.params?.objectId,
|
|
2233
|
+
id: props?.params?.id,
|
|
2234
|
+
note_id: props?.params?.note_id
|
|
2235
|
+
};
|
|
2236
|
+
const { paramsObject: queryParams } = getParamDetails();
|
|
2237
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
|
|
2238
|
+
const listQuery = noteStore.getState().queryParams ?? {};
|
|
2239
|
+
const response = await HttpClient.put(apiUrl, props.payload);
|
|
2240
|
+
const recordId = props?.params?.id;
|
|
2241
|
+
const objectTypeId = props?.params?.objectId;
|
|
2242
|
+
if (recordId && objectTypeId) {
|
|
2243
|
+
purgeEngagementCaches({
|
|
2244
|
+
objectTypeId,
|
|
2245
|
+
recordIds: [String(recordId)],
|
|
2246
|
+
views: ["notes"],
|
|
2247
|
+
listQuery
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
return response;
|
|
2251
|
+
},
|
|
2252
|
+
image: (props = null) => {
|
|
2253
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2254
|
+
const queryParams = props.queryParams;
|
|
2255
|
+
const payload = props.payload;
|
|
2256
|
+
const axiosConfig = props.config || {};
|
|
2257
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
|
|
2258
|
+
return HttpClient.post(apiUrl, payload, {
|
|
2259
|
+
headers: {
|
|
2260
|
+
"Content-Type": "multipart/form-data"
|
|
2261
|
+
},
|
|
2262
|
+
...axiosConfig
|
|
2263
|
+
});
|
|
2264
|
+
},
|
|
2265
|
+
attachment: (props = null) => {
|
|
2266
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2267
|
+
const queryParams = props.queryParams;
|
|
2268
|
+
const payload = props.payload;
|
|
2269
|
+
const axiosConfig = props.config || {};
|
|
2270
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
|
|
2271
|
+
return HttpClient.post(apiUrl, payload, {
|
|
2272
|
+
headers: {
|
|
2273
|
+
"Content-Type": "multipart/form-data"
|
|
2274
|
+
},
|
|
2275
|
+
...axiosConfig
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
},
|
|
2279
|
+
email: {
|
|
2280
|
+
list: (props = null) => {
|
|
2281
|
+
const { setListQueryParams } = actions5;
|
|
2282
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
2283
|
+
const params = {
|
|
2284
|
+
// hubId: config.hubId,
|
|
2285
|
+
// portalId: portalId,
|
|
2286
|
+
objectId: props?.params?.objectId,
|
|
2287
|
+
id: props?.params?.id
|
|
2288
|
+
};
|
|
2289
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
|
|
2290
|
+
return HttpClient.get(apiUrl);
|
|
2291
|
+
},
|
|
2292
|
+
create: async (props = null) => {
|
|
2293
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2294
|
+
const queryParams = props.queryParams;
|
|
2295
|
+
const payload = props.payload;
|
|
2296
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
|
|
2297
|
+
const listQuery = emailStore.getState().queryParams ?? {};
|
|
2298
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
2299
|
+
const recordId = props?.params?.id;
|
|
2300
|
+
const objectTypeId = props?.params?.objectId;
|
|
2301
|
+
if (recordId && objectTypeId) {
|
|
2302
|
+
purgeEngagementCaches({
|
|
2303
|
+
objectTypeId,
|
|
2304
|
+
recordIds: [String(recordId)],
|
|
2305
|
+
views: ["emails"],
|
|
2306
|
+
listQuery
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
return response;
|
|
2310
|
+
},
|
|
2311
|
+
update: async (props = null) => {
|
|
2312
|
+
const params = {
|
|
2313
|
+
// hubId: config.hubId,
|
|
2314
|
+
// portalId: portalId,
|
|
2315
|
+
objectId: props?.params?.objectId,
|
|
2316
|
+
id: props?.params?.id,
|
|
2317
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
2318
|
+
};
|
|
2319
|
+
const { paramsObject: queryParams } = getParamDetails();
|
|
2320
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
2321
|
+
const listQuery = emailStore.getState().queryParams ?? {};
|
|
2322
|
+
const response = await HttpClient.put(apiUrl, props.payload);
|
|
2323
|
+
const recordId = props?.params?.id;
|
|
2324
|
+
const objectTypeId = props?.params?.objectId;
|
|
2325
|
+
if (recordId && objectTypeId) {
|
|
2326
|
+
purgeEngagementCaches({
|
|
2327
|
+
objectTypeId,
|
|
2328
|
+
recordIds: [String(recordId)],
|
|
2329
|
+
views: ["emails"],
|
|
2330
|
+
listQuery
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
return response;
|
|
2334
|
+
},
|
|
2335
|
+
image: (props = null) => {
|
|
2336
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2337
|
+
const queryParams = props.queryParams;
|
|
2338
|
+
const payload = props.payload;
|
|
2339
|
+
const axiosConfig = props.config || {};
|
|
2340
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
|
|
2341
|
+
return HttpClient.post(apiUrl, payload, {
|
|
2342
|
+
headers: {
|
|
2343
|
+
"Content-Type": "multipart/form-data"
|
|
2344
|
+
},
|
|
2345
|
+
...axiosConfig
|
|
2346
|
+
});
|
|
2347
|
+
},
|
|
2348
|
+
attachment: (props = null) => {
|
|
2349
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2350
|
+
const queryParams = props.queryParams;
|
|
2351
|
+
const payload = props.payload;
|
|
2352
|
+
const axiosConfig = props.config || {};
|
|
2353
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
|
|
2354
|
+
return HttpClient.post(apiUrl, payload, {
|
|
2355
|
+
headers: {
|
|
2356
|
+
"Content-Type": "multipart/form-data"
|
|
2357
|
+
},
|
|
2358
|
+
...axiosConfig
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
},
|
|
2362
|
+
cache: {
|
|
2363
|
+
purge: (body, headers) => {
|
|
2364
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
|
|
2365
|
+
return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
|
|
2366
|
+
},
|
|
2367
|
+
purgeStatus: (purgeJobId) => {
|
|
2368
|
+
const apiUrl = generateApiUrl({
|
|
2369
|
+
route: API_ENDPOINTS.CACHE_PURGE_STATUS,
|
|
2370
|
+
params: { purgeJobId }
|
|
2371
|
+
});
|
|
2372
|
+
return HttpClient.get(apiUrl);
|
|
2373
|
+
}
|
|
2374
|
+
},
|
|
2375
|
+
file: {
|
|
2376
|
+
list: (props = null) => {
|
|
2377
|
+
const { setListQueryParams } = actions6;
|
|
2378
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
2379
|
+
const params = {
|
|
2380
|
+
// hubId: config.hubId,
|
|
2381
|
+
// portalId: portalId,
|
|
2382
|
+
objectId: props?.params?.objectId,
|
|
2383
|
+
id: props?.params?.id
|
|
2384
|
+
};
|
|
2385
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
|
|
2386
|
+
return HttpClient.get(apiUrl);
|
|
2387
|
+
},
|
|
2388
|
+
details: (props = null) => {
|
|
2389
|
+
const params = {
|
|
2390
|
+
// hubId: config.hubId,
|
|
2391
|
+
// portalId: portalId,
|
|
2392
|
+
objectId: props?.params?.objectId,
|
|
2393
|
+
id: props?.params?.id,
|
|
2394
|
+
rowId: props?.params?.rowId
|
|
2395
|
+
};
|
|
2396
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
2397
|
+
return HttpClient.get(apiUrl);
|
|
2398
|
+
},
|
|
2399
|
+
download: (props = null) => {
|
|
2400
|
+
const params = {
|
|
2401
|
+
objectId: props?.params?.objectId,
|
|
2402
|
+
id: props?.params?.id,
|
|
2403
|
+
rowId: props?.params?.rowId
|
|
2404
|
+
};
|
|
2405
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
|
|
2406
|
+
return HttpClient.post(apiUrl, {});
|
|
2407
|
+
},
|
|
2408
|
+
addFolder: async (props = null) => {
|
|
2409
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2410
|
+
const queryParams = props.queryParams;
|
|
2411
|
+
const payload = props.payload;
|
|
2412
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
|
|
2413
|
+
const listQuery = fileStore.getState().queryParams ?? {};
|
|
2414
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
2415
|
+
const recordId = props?.params?.id;
|
|
2416
|
+
const objectTypeId = props?.params?.objectId;
|
|
2417
|
+
if (recordId && objectTypeId) {
|
|
2418
|
+
purgeEngagementCaches({
|
|
2419
|
+
objectTypeId,
|
|
2420
|
+
recordIds: [String(recordId)],
|
|
2421
|
+
views: ["files"],
|
|
2422
|
+
listQuery
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
return response;
|
|
2426
|
+
},
|
|
2427
|
+
addFile: async (props = null) => {
|
|
2428
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
2429
|
+
const queryParams = props.queryParams;
|
|
2430
|
+
const payload = props.payload;
|
|
2431
|
+
const axiosConfig = props.config || {};
|
|
2432
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
|
|
2433
|
+
const listQuery = fileStore.getState().queryParams ?? {};
|
|
2434
|
+
const response = await HttpClient.post(apiUrl, payload, {
|
|
2435
|
+
headers: {
|
|
2436
|
+
"Content-Type": "multipart/form-data"
|
|
2437
|
+
},
|
|
2438
|
+
...axiosConfig
|
|
2439
|
+
});
|
|
2440
|
+
const recordId = props?.params?.id;
|
|
2441
|
+
const objectTypeId = props?.params?.objectId;
|
|
2442
|
+
if (recordId && objectTypeId) {
|
|
2443
|
+
purgeEngagementCaches({
|
|
2444
|
+
objectTypeId,
|
|
2445
|
+
recordIds: [String(recordId)],
|
|
2446
|
+
views: ["files"],
|
|
2447
|
+
listQuery
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
return response;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
|
|
2455
|
+
// src/store2/use-sync.ts
|
|
2456
|
+
var syncStore = createStore2({
|
|
2457
|
+
apiSync: false,
|
|
2458
|
+
sync: false,
|
|
2459
|
+
isSyncLoading: false,
|
|
2460
|
+
isSyncDisable: false
|
|
2461
|
+
});
|
|
2462
|
+
var actions7 = {
|
|
2463
|
+
setIsSyncLoading(status) {
|
|
2464
|
+
syncStore.setState({
|
|
2465
|
+
isSyncLoading: status,
|
|
2466
|
+
sync: status
|
|
2467
|
+
});
|
|
2468
|
+
},
|
|
2469
|
+
setSync(status) {
|
|
2470
|
+
resetAllStore();
|
|
2471
|
+
syncStore.setState({
|
|
2472
|
+
isSyncLoading: status,
|
|
2473
|
+
sync: status
|
|
2474
|
+
});
|
|
2475
|
+
},
|
|
2476
|
+
setApiSync(status) {
|
|
2477
|
+
syncStore.setState({
|
|
2478
|
+
isSyncLoading: status,
|
|
2479
|
+
apiSync: status
|
|
2480
|
+
});
|
|
2481
|
+
},
|
|
2482
|
+
setSyncDisable(status) {
|
|
2483
|
+
syncStore.setState({
|
|
2484
|
+
isSyncDisable: status
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
var resetAllStore = () => {
|
|
2489
|
+
actions2.clearTablePrependData();
|
|
2490
|
+
actions4.clearPrependNotes();
|
|
2491
|
+
actions5.clearPrependEmails();
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
// src/utils/logError.ts
|
|
2495
|
+
function logError(context, error) {
|
|
2496
|
+
if (axios.isAxiosError(error)) {
|
|
2497
|
+
resetAllStore();
|
|
2498
|
+
console.error(context, {
|
|
2499
|
+
message: error.message,
|
|
2500
|
+
status: error.response?.status,
|
|
2501
|
+
statusText: error.response?.statusText,
|
|
2502
|
+
data: error.response?.data,
|
|
2503
|
+
url: error.config?.url,
|
|
2504
|
+
method: error.config?.method
|
|
2505
|
+
});
|
|
2506
|
+
return;
|
|
2507
|
+
}
|
|
2508
|
+
if (error instanceof Error) {
|
|
2509
|
+
console.error(context, error.message, error);
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2512
|
+
console.error(context, error);
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// src/mutation/createMutation.ts
|
|
2516
|
+
function createMutation(mutationFn, options) {
|
|
2517
|
+
let inFlight = 0;
|
|
2518
|
+
let lastReportedLoading = null;
|
|
2519
|
+
const syncLoading = () => {
|
|
2520
|
+
const active = inFlight > 0;
|
|
2521
|
+
if (lastReportedLoading === active) return;
|
|
2522
|
+
lastReportedLoading = active;
|
|
2523
|
+
options?.onLoadingChange?.(active);
|
|
2524
|
+
};
|
|
2525
|
+
const mutate = async (payload) => {
|
|
2526
|
+
inFlight += 1;
|
|
2527
|
+
syncLoading();
|
|
2528
|
+
try {
|
|
2529
|
+
const response = await mutationFn(payload);
|
|
2530
|
+
await options?.onSuccess?.(response, payload);
|
|
2531
|
+
return response;
|
|
2532
|
+
} catch (error) {
|
|
2533
|
+
options?.onError?.(error, payload);
|
|
2534
|
+
logError("[mutation]", error);
|
|
2535
|
+
throw error;
|
|
2536
|
+
} finally {
|
|
2537
|
+
inFlight -= 1;
|
|
2538
|
+
syncLoading();
|
|
2539
|
+
}
|
|
2540
|
+
};
|
|
2541
|
+
return {
|
|
2542
|
+
mutate,
|
|
2543
|
+
isLoading: () => inFlight > 0
|
|
2544
|
+
};
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
// src/apis/authentication.ts
|
|
2548
|
+
function preLogin(options) {
|
|
2549
|
+
const { mutate, isLoading } = createMutation(
|
|
2550
|
+
async (payload) => {
|
|
2551
|
+
const response = await Client.authentication.preLogin(payload);
|
|
2552
|
+
return response;
|
|
2553
|
+
},
|
|
2554
|
+
options
|
|
2555
|
+
);
|
|
2556
|
+
return {
|
|
2557
|
+
mutate,
|
|
2558
|
+
login: mutate,
|
|
2559
|
+
isLoading
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
function login(options) {
|
|
2563
|
+
const { mutate, isLoading } = createMutation(
|
|
2564
|
+
async (payload) => {
|
|
2565
|
+
const response = await Client.authentication.login(payload);
|
|
2566
|
+
const tokenData = response?.data?.tokenData || {};
|
|
2567
|
+
const loggedInDetails = response?.data?.loggedInDetails || {};
|
|
2568
|
+
const currentPortal = response?.data?.loggedInDetails?.currentPortal || {};
|
|
2569
|
+
const currentPortalId = currentPortal?.portalId || null;
|
|
2570
|
+
const SubscriptionType = loggedInDetails?.subscriptionType || "BASIC";
|
|
2571
|
+
const token = tokenData?.token;
|
|
2572
|
+
const refreshToken = tokenData?.refreshToken;
|
|
2573
|
+
const expiresIn = tokenData?.expiresIn;
|
|
2574
|
+
const rExpiresIn = tokenData?.refreshExpiresIn;
|
|
2575
|
+
setPortal(currentPortal);
|
|
2576
|
+
setSubscriptionType(SubscriptionType);
|
|
2577
|
+
await setAccessToken(token, expiresIn);
|
|
2578
|
+
await setRefreshToken(refreshToken, rExpiresIn);
|
|
2579
|
+
await setLoggedInDetails(response.data);
|
|
2580
|
+
setConfig.setDevPortalId(currentPortalId);
|
|
2581
|
+
return response;
|
|
2582
|
+
},
|
|
2583
|
+
options
|
|
2584
|
+
);
|
|
2585
|
+
return {
|
|
2586
|
+
mutate,
|
|
2587
|
+
login: mutate,
|
|
2588
|
+
isLoading
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
function verifyEmail(options) {
|
|
2592
|
+
const { mutate, isLoading } = createMutation(
|
|
2593
|
+
async (payload) => {
|
|
2594
|
+
const verifyEmailPayload = payload || {};
|
|
2595
|
+
const token = getParam("token");
|
|
2596
|
+
if (!verifyEmailPayload?.token) verifyEmailPayload.token = token;
|
|
2597
|
+
const response = await Client.authentication.verifyEmail(verifyEmailPayload);
|
|
2598
|
+
return response;
|
|
2599
|
+
},
|
|
2600
|
+
options
|
|
2601
|
+
);
|
|
2602
|
+
return {
|
|
2603
|
+
mutate,
|
|
2604
|
+
verifyEmail: mutate,
|
|
2605
|
+
isLoading
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
function resetPasswordVerifyToken(options) {
|
|
2609
|
+
const { mutate, isLoading } = createMutation(
|
|
2610
|
+
async (payload) => {
|
|
2611
|
+
const resetPasswordVerifyTokenPayload = payload || {};
|
|
2612
|
+
const token = getParam("token");
|
|
2613
|
+
if (!resetPasswordVerifyTokenPayload?.token) resetPasswordVerifyTokenPayload.token = token;
|
|
2614
|
+
const response = await Client.authentication.resetPasswordVerifyToken(resetPasswordVerifyTokenPayload);
|
|
2615
|
+
return response;
|
|
2616
|
+
},
|
|
2617
|
+
options
|
|
2618
|
+
);
|
|
2619
|
+
return {
|
|
2620
|
+
mutate,
|
|
2621
|
+
resetPasswordVerifyToken: mutate,
|
|
2622
|
+
isLoading
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
function resetPassword(options) {
|
|
2626
|
+
const { mutate, isLoading } = createMutation(
|
|
2627
|
+
async (payload) => {
|
|
2628
|
+
const response = await Client.authentication.resetPassword(payload);
|
|
2629
|
+
return response;
|
|
2630
|
+
},
|
|
2631
|
+
options
|
|
2632
|
+
);
|
|
2633
|
+
return {
|
|
2634
|
+
mutate,
|
|
2635
|
+
resetPassword: mutate,
|
|
2636
|
+
isLoading
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
function forgetPassword(options) {
|
|
2640
|
+
const { mutate, isLoading } = createMutation(
|
|
2641
|
+
async (payload) => {
|
|
2642
|
+
const response = await Client.authentication.forgetPassword(payload);
|
|
2643
|
+
return response;
|
|
2644
|
+
},
|
|
2645
|
+
options
|
|
2646
|
+
);
|
|
2647
|
+
return {
|
|
2648
|
+
mutate,
|
|
2649
|
+
forgetPassword: mutate,
|
|
2650
|
+
isLoading
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
function logout(options) {
|
|
2654
|
+
const { mutate, isLoading } = createMutation(
|
|
2655
|
+
async () => {
|
|
2656
|
+
const response = await Client.authentication.logout();
|
|
2657
|
+
clearAccessToken();
|
|
2658
|
+
removeAllCookie();
|
|
2659
|
+
return response;
|
|
2660
|
+
},
|
|
2661
|
+
options
|
|
2662
|
+
);
|
|
2663
|
+
return {
|
|
2664
|
+
mutate,
|
|
2665
|
+
logout: mutate,
|
|
2666
|
+
isLoading
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
function registerExistingUser(options) {
|
|
2670
|
+
const { mutate, isLoading } = createMutation(
|
|
2671
|
+
async (payload) => {
|
|
2672
|
+
const response = await Client.authentication.registerExistingUser(payload);
|
|
2673
|
+
return response;
|
|
2674
|
+
},
|
|
2675
|
+
options
|
|
2676
|
+
);
|
|
2677
|
+
return {
|
|
2678
|
+
mutate,
|
|
2679
|
+
registerExistingUser: mutate,
|
|
2680
|
+
isLoading
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
function verifyEmailResend(options) {
|
|
2684
|
+
const { mutate, isLoading } = createMutation(
|
|
2685
|
+
async (payload) => {
|
|
2686
|
+
const response = await Client.authentication.verifyEmailResend(payload);
|
|
2687
|
+
return response;
|
|
2688
|
+
},
|
|
2689
|
+
options
|
|
2690
|
+
);
|
|
2691
|
+
return {
|
|
2692
|
+
mutate,
|
|
2693
|
+
verifyEmailResend: mutate,
|
|
2694
|
+
isLoading
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
function resendEmail(options) {
|
|
2698
|
+
const { mutate, isLoading } = createMutation(
|
|
2699
|
+
async (payload) => {
|
|
2700
|
+
const response = await Client.authentication.resendEmail(payload);
|
|
2701
|
+
return response;
|
|
2702
|
+
},
|
|
2703
|
+
options
|
|
2704
|
+
);
|
|
2705
|
+
return {
|
|
2706
|
+
mutate,
|
|
2707
|
+
resendEmail: mutate,
|
|
2708
|
+
isLoading
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
// src/apis/sso.ts
|
|
2713
|
+
function getSsoDetails(options) {
|
|
2714
|
+
const { mutate, isLoading } = createMutation(
|
|
2715
|
+
async () => {
|
|
2716
|
+
const response = await Client.sso.getSsoDetails();
|
|
2717
|
+
return response;
|
|
2718
|
+
},
|
|
2719
|
+
options
|
|
2720
|
+
);
|
|
2721
|
+
return {
|
|
2722
|
+
mutate,
|
|
2723
|
+
getSsoDetails: mutate,
|
|
2724
|
+
isLoading
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2727
|
+
function generateSsoUrl(options) {
|
|
2728
|
+
const { mutate, isLoading } = createMutation(
|
|
2729
|
+
async (payload) => {
|
|
2730
|
+
const response = await Client.sso.generateSsoUrl(payload);
|
|
2731
|
+
return response;
|
|
2732
|
+
},
|
|
2733
|
+
options
|
|
2734
|
+
);
|
|
2735
|
+
return {
|
|
2736
|
+
mutate,
|
|
2737
|
+
generateSsoUrl: mutate,
|
|
2738
|
+
isLoading
|
|
2739
|
+
};
|
|
2740
|
+
}
|
|
2741
|
+
function ssoCallback(options) {
|
|
2742
|
+
const { mutate, isLoading } = createMutation(
|
|
2743
|
+
async (payload) => {
|
|
2744
|
+
const response = await Client.sso.ssoCallback(payload);
|
|
2745
|
+
return response;
|
|
2746
|
+
},
|
|
2747
|
+
options
|
|
2748
|
+
);
|
|
2749
|
+
return {
|
|
2750
|
+
mutate,
|
|
2751
|
+
ssoCallback: mutate,
|
|
2752
|
+
isLoading
|
|
2753
|
+
};
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
// src/apis/users.ts
|
|
2757
|
+
function me(options) {
|
|
2758
|
+
const { mutate, isLoading } = createMutation(
|
|
2759
|
+
async () => {
|
|
2760
|
+
const response = await Client.user.me();
|
|
2761
|
+
return response;
|
|
2762
|
+
},
|
|
2763
|
+
options
|
|
2764
|
+
);
|
|
2765
|
+
return {
|
|
2766
|
+
mutate,
|
|
2767
|
+
me: mutate,
|
|
2768
|
+
isLoading
|
|
2769
|
+
};
|
|
2770
|
+
}
|
|
2771
|
+
function profile(options) {
|
|
2772
|
+
const { mutate, isLoading } = createMutation(
|
|
2773
|
+
async (paylaod) => {
|
|
2774
|
+
const response = await Client.user.profile(paylaod);
|
|
2775
|
+
setProfileData(response);
|
|
2776
|
+
return response;
|
|
2777
|
+
},
|
|
2778
|
+
options
|
|
2779
|
+
);
|
|
2780
|
+
return {
|
|
2781
|
+
mutate,
|
|
2782
|
+
profile: mutate,
|
|
2783
|
+
isLoading
|
|
2784
|
+
};
|
|
2785
|
+
}
|
|
2786
|
+
function changePassword(options) {
|
|
2787
|
+
const { mutate, isLoading } = createMutation(
|
|
2788
|
+
async (payload) => {
|
|
2789
|
+
const response = await Client.user.changePassword(payload);
|
|
2790
|
+
return response;
|
|
2791
|
+
},
|
|
2792
|
+
options
|
|
2793
|
+
);
|
|
2794
|
+
return {
|
|
2795
|
+
mutate,
|
|
2796
|
+
changePassword: mutate,
|
|
2797
|
+
isLoading
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
// src/apis/pipeline.ts
|
|
2802
|
+
function list(options) {
|
|
2803
|
+
const {
|
|
2804
|
+
getTableParam
|
|
2805
|
+
} = useTable();
|
|
2806
|
+
const { mutate, isLoading } = createMutation(
|
|
2807
|
+
async (payload) => {
|
|
2808
|
+
const param = await getTableParam(payload?.companyAsMediator);
|
|
2809
|
+
const response = await Client.pipeline.list(payload, param);
|
|
2810
|
+
return response;
|
|
2811
|
+
},
|
|
2812
|
+
options
|
|
2813
|
+
);
|
|
2814
|
+
return {
|
|
2815
|
+
mutate,
|
|
2816
|
+
getPipelines: mutate,
|
|
2817
|
+
isLoading
|
|
2818
|
+
};
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
// src/apis/stage.ts
|
|
2822
|
+
function list2(options) {
|
|
2823
|
+
const { mutate, isLoading } = createMutation(
|
|
2824
|
+
async (payload) => {
|
|
2825
|
+
const response = await Client.stage.list(payload);
|
|
2826
|
+
return response;
|
|
2827
|
+
},
|
|
2828
|
+
options
|
|
2829
|
+
);
|
|
2830
|
+
return {
|
|
2831
|
+
mutate,
|
|
2832
|
+
getStages: mutate,
|
|
2833
|
+
isLoading
|
|
2834
|
+
};
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
// src/store2/use-multi-object.ts
|
|
2838
|
+
var multiObjectStore = createStore2({
|
|
2839
|
+
objects: {},
|
|
2840
|
+
objectsPrependData: {},
|
|
2841
|
+
meta: {}
|
|
2842
|
+
});
|
|
2843
|
+
function getObjectKey(payload) {
|
|
2844
|
+
return String(payload?.hubspotObjectTypeId ?? "");
|
|
2845
|
+
}
|
|
2846
|
+
var actions8 = {
|
|
2847
|
+
setMultiObjectData(response, payload) {
|
|
2848
|
+
const key = getObjectKey(payload);
|
|
2849
|
+
const state = multiObjectStore.getState();
|
|
2850
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
2851
|
+
const rowIds = new Set(
|
|
2852
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
2853
|
+
);
|
|
2854
|
+
let newPrependForKey = (state.objectsPrependData[key] ?? []).filter((item) => {
|
|
2855
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
2856
|
+
if (itemId == null || itemId === "") return true;
|
|
2857
|
+
return !rowIds.has(String(itemId));
|
|
2858
|
+
});
|
|
2859
|
+
const selectedPipeline = payload?.selectedPipeline ?? "";
|
|
2860
|
+
const viewType = response?.info?.viewType ?? "";
|
|
2861
|
+
const prevMeta = state.meta[key];
|
|
2862
|
+
if (response?.data?.total < 1 || payload?.componentName) {
|
|
2863
|
+
newPrependForKey = [];
|
|
2864
|
+
}
|
|
2865
|
+
if (prevMeta?.viewType && prevMeta.viewType !== viewType) {
|
|
2866
|
+
newPrependForKey = [];
|
|
2867
|
+
}
|
|
2868
|
+
if (prevMeta?.selectedPipeline && prevMeta.selectedPipeline !== selectedPipeline) {
|
|
2869
|
+
newPrependForKey = [];
|
|
2870
|
+
}
|
|
2871
|
+
multiObjectStore.setState({
|
|
2872
|
+
objects: { ...state.objects, [key]: response },
|
|
2873
|
+
objectsPrependData: { ...state.objectsPrependData, [key]: newPrependForKey },
|
|
2874
|
+
meta: {
|
|
2875
|
+
...state.meta,
|
|
2876
|
+
[key]: { selectedPipeline, viewType }
|
|
2877
|
+
}
|
|
2878
|
+
});
|
|
2879
|
+
},
|
|
2880
|
+
clearMultiObjectPrependData(hubspotObjectTypeId) {
|
|
2881
|
+
const state = multiObjectStore.getState();
|
|
2882
|
+
if (!hubspotObjectTypeId) {
|
|
2883
|
+
multiObjectStore.setState({ objectsPrependData: {} });
|
|
2884
|
+
return;
|
|
2885
|
+
}
|
|
2886
|
+
const key = String(hubspotObjectTypeId);
|
|
2887
|
+
const { [key]: _, ...rest } = state.objectsPrependData;
|
|
2888
|
+
multiObjectStore.setState({ objectsPrependData: rest });
|
|
2889
|
+
},
|
|
2890
|
+
async setMultiObjectPrependData(response, props) {
|
|
2891
|
+
const key = getObjectKey(props);
|
|
2892
|
+
const state = multiObjectStore.getState();
|
|
2893
|
+
const tableResponse = state.objects[key];
|
|
2894
|
+
let rows = state.objectsPrependData[key] ?? [];
|
|
2895
|
+
if (tableResponse?.data?.total > 1) {
|
|
2896
|
+
if (response === "loading") {
|
|
2897
|
+
const row = tableResponse?.data?.results?.columns.reduce(
|
|
2898
|
+
(acc, item) => {
|
|
2899
|
+
if (!item.hidden) {
|
|
2900
|
+
acc[item.key] = "loading";
|
|
2901
|
+
}
|
|
2902
|
+
return acc;
|
|
2903
|
+
},
|
|
2904
|
+
{}
|
|
2905
|
+
);
|
|
2906
|
+
rows = [row, ...rows];
|
|
2907
|
+
} else if (response?.data) {
|
|
2908
|
+
const data = response?.data;
|
|
2909
|
+
if (!data) {
|
|
2910
|
+
multiObjectStore.setState({
|
|
2911
|
+
objectsPrependData: { ...state.objectsPrependData, [key]: [] }
|
|
2912
|
+
});
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
const row = Object.fromEntries(
|
|
2916
|
+
Object.entries(data).map(([k, value]) => [k, value?.value ?? value])
|
|
2917
|
+
);
|
|
2918
|
+
rows = [...rows];
|
|
2919
|
+
if (rows.length > 0) {
|
|
2920
|
+
rows[0] = row;
|
|
2921
|
+
} else {
|
|
2922
|
+
rows.push(row);
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
multiObjectStore.setState({
|
|
2927
|
+
objectsPrependData: { ...state.objectsPrependData, [key]: rows }
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
};
|
|
2931
|
+
|
|
2932
|
+
// src/apis/object.ts
|
|
2933
|
+
function list3(options) {
|
|
2934
|
+
const { getTableParam } = useTable();
|
|
2935
|
+
const { setObjectsData, setTableData } = actions2;
|
|
2936
|
+
const { mutate, isLoading } = createMutation(
|
|
2937
|
+
async (payload) => {
|
|
2938
|
+
const param = await getTableParam(payload?.companyAsMediator);
|
|
2939
|
+
const response = await Client.object.list(payload, param);
|
|
2940
|
+
await setObjectsData(response);
|
|
2941
|
+
await setTableData(response, payload);
|
|
2942
|
+
return response;
|
|
2943
|
+
},
|
|
2944
|
+
options
|
|
2945
|
+
);
|
|
2946
|
+
return {
|
|
2947
|
+
mutate,
|
|
2948
|
+
getObjects: mutate,
|
|
2949
|
+
isLoading
|
|
2950
|
+
};
|
|
2951
|
+
}
|
|
2952
|
+
function sideBarList(options) {
|
|
2953
|
+
const { setMultiObjectData } = actions8;
|
|
2954
|
+
const { mutate, isLoading } = createMutation(
|
|
2955
|
+
async (payload) => {
|
|
2956
|
+
const response = await Client.object.sideBarList(payload);
|
|
2957
|
+
setMultiObjectData(response, payload);
|
|
2958
|
+
return response;
|
|
2959
|
+
},
|
|
2960
|
+
options
|
|
2961
|
+
);
|
|
2962
|
+
return {
|
|
2963
|
+
mutate,
|
|
2964
|
+
getSideBarObjects: mutate,
|
|
2965
|
+
isLoading
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2968
|
+
function form(options) {
|
|
2969
|
+
const { setFormData } = actions;
|
|
2970
|
+
const { mutate, isLoading } = createMutation(
|
|
2971
|
+
async (payload) => {
|
|
2972
|
+
const response = await Client.object.form(payload);
|
|
2973
|
+
setFormData(response);
|
|
2974
|
+
return response;
|
|
2975
|
+
},
|
|
2976
|
+
options
|
|
2977
|
+
);
|
|
2978
|
+
return {
|
|
2979
|
+
mutate,
|
|
2980
|
+
getObjectsForm: mutate,
|
|
2981
|
+
isLoading
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
function objectFormOptions(options) {
|
|
2985
|
+
const { mutate, isLoading } = createMutation(
|
|
2986
|
+
async (payload) => {
|
|
2987
|
+
const response = await Client.object.objectFormOptions(payload);
|
|
2988
|
+
return response;
|
|
2989
|
+
},
|
|
2990
|
+
options
|
|
2991
|
+
);
|
|
2992
|
+
return {
|
|
2993
|
+
mutate,
|
|
2994
|
+
objectFormOptions: mutate,
|
|
2995
|
+
isLoading
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
function create(options) {
|
|
2999
|
+
const { setTablePrependData } = actions2;
|
|
3000
|
+
const { setMultiObjectPrependData } = actions8;
|
|
3001
|
+
const { mutate, isLoading } = createMutation(
|
|
3002
|
+
async (props) => {
|
|
3003
|
+
if (props?.componentName === "sidebarTable") await setMultiObjectPrependData("loading", props);
|
|
3004
|
+
if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData("loading", props);
|
|
3005
|
+
const response = await Client.object.create(props);
|
|
3006
|
+
if (props?.componentName === "sidebarTable") await setMultiObjectPrependData(response, props);
|
|
3007
|
+
if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData(response, props);
|
|
3008
|
+
return response;
|
|
3009
|
+
},
|
|
3010
|
+
options
|
|
3011
|
+
);
|
|
3012
|
+
return {
|
|
3013
|
+
mutate,
|
|
3014
|
+
createObject: mutate,
|
|
3015
|
+
isLoading
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
function createExisting(options) {
|
|
3019
|
+
const { mutate, isLoading } = createMutation(
|
|
3020
|
+
async (props) => {
|
|
3021
|
+
const response = await Client.object.createExisting(props);
|
|
3022
|
+
return response;
|
|
3023
|
+
},
|
|
3024
|
+
options
|
|
3025
|
+
);
|
|
3026
|
+
return {
|
|
3027
|
+
mutate,
|
|
3028
|
+
createExistingObject: mutate,
|
|
3029
|
+
isLoading
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
function removeExisting(options) {
|
|
3033
|
+
const { mutate, isLoading } = createMutation(
|
|
3034
|
+
async (props) => {
|
|
3035
|
+
const response = await Client.object.removeExisting(props);
|
|
3036
|
+
return response;
|
|
3037
|
+
},
|
|
3038
|
+
options
|
|
3039
|
+
);
|
|
3040
|
+
return {
|
|
3041
|
+
mutate,
|
|
3042
|
+
removeExisting: mutate,
|
|
3043
|
+
isLoading
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
function details(options) {
|
|
3047
|
+
const { mutate, isLoading } = createMutation(
|
|
3048
|
+
async (payload) => {
|
|
3049
|
+
const response = await Client.object.details(payload);
|
|
3050
|
+
return response;
|
|
3051
|
+
},
|
|
3052
|
+
options
|
|
3053
|
+
);
|
|
3054
|
+
return {
|
|
3055
|
+
mutate,
|
|
3056
|
+
getObjectsDetails: mutate,
|
|
3057
|
+
isLoading
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
function update(options) {
|
|
3061
|
+
const { mutate, isLoading } = createMutation(
|
|
3062
|
+
async (payload) => {
|
|
3063
|
+
const response = await Client.object.update(payload);
|
|
3064
|
+
return response;
|
|
3065
|
+
},
|
|
3066
|
+
options
|
|
3067
|
+
);
|
|
3068
|
+
return {
|
|
3069
|
+
mutate,
|
|
3070
|
+
updateObjectsDetails: mutate,
|
|
3071
|
+
isLoading
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// src/apis/note.ts
|
|
3076
|
+
function list4(options) {
|
|
3077
|
+
const { setNotes } = actions4;
|
|
3078
|
+
const { mutate, isLoading } = createMutation(
|
|
3079
|
+
async (payload) => {
|
|
3080
|
+
const response = await Client.note.list(payload);
|
|
3081
|
+
setNotes(response, payload);
|
|
3082
|
+
return response;
|
|
3083
|
+
},
|
|
3084
|
+
options
|
|
3085
|
+
);
|
|
3086
|
+
return {
|
|
3087
|
+
mutate,
|
|
3088
|
+
getNotes: mutate,
|
|
3089
|
+
isLoading
|
|
3090
|
+
};
|
|
3091
|
+
}
|
|
3092
|
+
function create2(options) {
|
|
3093
|
+
const { setPrependNote } = actions4;
|
|
3094
|
+
const { mutate, isLoading } = createMutation(
|
|
3095
|
+
async (props) => {
|
|
3096
|
+
await setPrependNote("loading");
|
|
3097
|
+
const response = await Client.note.create(props);
|
|
3098
|
+
await setPrependNote(response);
|
|
3099
|
+
return response;
|
|
3100
|
+
},
|
|
3101
|
+
options
|
|
3102
|
+
);
|
|
3103
|
+
return {
|
|
3104
|
+
mutate,
|
|
3105
|
+
createNote: mutate,
|
|
3106
|
+
isLoading
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
function update2(options) {
|
|
3110
|
+
const { updatePrependNote } = actions4;
|
|
3111
|
+
const { mutate, isLoading } = createMutation(
|
|
3112
|
+
async (payload) => {
|
|
3113
|
+
const response = await Client.note.update(payload);
|
|
3114
|
+
return updatePrependNote(response);
|
|
3115
|
+
},
|
|
3116
|
+
options
|
|
3117
|
+
);
|
|
3118
|
+
return {
|
|
3119
|
+
mutate,
|
|
3120
|
+
updateNote: mutate,
|
|
3121
|
+
isLoading
|
|
3122
|
+
};
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
// src/apis/email.ts
|
|
3126
|
+
function list5(options) {
|
|
3127
|
+
const { setEmails } = actions5;
|
|
3128
|
+
const { mutate, isLoading } = createMutation(
|
|
3129
|
+
async (payload) => {
|
|
3130
|
+
const response = await Client.email.list(payload);
|
|
3131
|
+
setEmails(response, payload);
|
|
3132
|
+
return response;
|
|
3133
|
+
},
|
|
3134
|
+
options
|
|
3135
|
+
);
|
|
3136
|
+
return {
|
|
3137
|
+
mutate,
|
|
3138
|
+
getEmails: mutate,
|
|
3139
|
+
isLoading
|
|
3140
|
+
};
|
|
3141
|
+
}
|
|
3142
|
+
function create3(options) {
|
|
3143
|
+
const { setPrependEmail } = actions5;
|
|
3144
|
+
const { mutate, isLoading } = createMutation(
|
|
3145
|
+
async (props) => {
|
|
3146
|
+
await setPrependEmail("loading");
|
|
3147
|
+
const response = await Client.email.create(props);
|
|
3148
|
+
await setPrependEmail(response);
|
|
3149
|
+
return response;
|
|
3150
|
+
},
|
|
3151
|
+
options
|
|
3152
|
+
);
|
|
3153
|
+
return {
|
|
3154
|
+
mutate,
|
|
3155
|
+
createEmail: mutate,
|
|
3156
|
+
isLoading
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
function update3(options) {
|
|
3160
|
+
const { updatePrependEmail } = actions5;
|
|
3161
|
+
const { mutate, isLoading } = createMutation(
|
|
3162
|
+
async (payload) => {
|
|
3163
|
+
const response = await Client.email.update(payload);
|
|
3164
|
+
return updatePrependEmail(response);
|
|
3165
|
+
},
|
|
3166
|
+
options
|
|
3167
|
+
);
|
|
3168
|
+
return {
|
|
3169
|
+
mutate,
|
|
3170
|
+
updateEmail: mutate,
|
|
3171
|
+
isLoading
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
|
|
3175
|
+
// src/apis/uploader.ts
|
|
3176
|
+
function imageUpload(options) {
|
|
3177
|
+
const { mutate, isLoading } = createMutation(
|
|
3178
|
+
async (payload) => {
|
|
3179
|
+
const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
|
|
3180
|
+
return response;
|
|
3181
|
+
},
|
|
3182
|
+
options
|
|
3183
|
+
);
|
|
3184
|
+
return {
|
|
3185
|
+
mutate,
|
|
3186
|
+
imageUpload: mutate,
|
|
3187
|
+
isLoading
|
|
3188
|
+
};
|
|
3189
|
+
}
|
|
3190
|
+
function attachmentUpload(options) {
|
|
3191
|
+
const { mutate, isLoading } = createMutation(
|
|
3192
|
+
async (payload) => {
|
|
3193
|
+
const response = payload?.type === "email" ? await Client.email.attachment(payload) : await Client.note.attachment(payload);
|
|
3194
|
+
actions3.setAttachment(response);
|
|
3195
|
+
return response;
|
|
3196
|
+
},
|
|
3197
|
+
options
|
|
3198
|
+
);
|
|
3199
|
+
return {
|
|
3200
|
+
mutate,
|
|
3201
|
+
attachmentUpload: mutate,
|
|
3202
|
+
isLoading
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
// src/apis/file.ts
|
|
3207
|
+
function list6(options) {
|
|
3208
|
+
const { mutate, isLoading } = createMutation(
|
|
3209
|
+
async (payload) => {
|
|
3210
|
+
const response = await Client.file.list(payload);
|
|
3211
|
+
return response;
|
|
3212
|
+
},
|
|
3213
|
+
options
|
|
3214
|
+
);
|
|
3215
|
+
return {
|
|
3216
|
+
mutate,
|
|
3217
|
+
getFiles: mutate,
|
|
3218
|
+
isLoading
|
|
3219
|
+
};
|
|
3220
|
+
}
|
|
3221
|
+
function details2(options) {
|
|
3222
|
+
const { mutate, isLoading } = createMutation(
|
|
3223
|
+
async (payload) => {
|
|
3224
|
+
const response = await Client.file.details(payload);
|
|
3225
|
+
return response;
|
|
3226
|
+
},
|
|
3227
|
+
options
|
|
3228
|
+
);
|
|
3229
|
+
return {
|
|
3230
|
+
mutate,
|
|
3231
|
+
getFile: mutate,
|
|
3232
|
+
isLoading
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
function addFolder(options) {
|
|
3236
|
+
const { mutate, isLoading } = createMutation(
|
|
3237
|
+
async (props) => {
|
|
3238
|
+
const response = await Client.file.addFolder(props);
|
|
3239
|
+
return response;
|
|
3240
|
+
},
|
|
3241
|
+
options
|
|
3242
|
+
);
|
|
3243
|
+
return {
|
|
3244
|
+
mutate,
|
|
3245
|
+
addFolder: mutate,
|
|
3246
|
+
isLoading
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
function addFile(options) {
|
|
3250
|
+
const { mutate, isLoading } = createMutation(
|
|
3251
|
+
async (props) => {
|
|
3252
|
+
const response = await Client.file.addFile(props);
|
|
3253
|
+
return response;
|
|
3254
|
+
},
|
|
3255
|
+
options
|
|
3256
|
+
);
|
|
3257
|
+
return {
|
|
3258
|
+
mutate,
|
|
3259
|
+
addFile: mutate,
|
|
3260
|
+
isLoading
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3263
|
+
function download(options) {
|
|
3264
|
+
const { mutate, isLoading } = createMutation(
|
|
3265
|
+
async (payload) => {
|
|
3266
|
+
const response = await Client.file.download(payload);
|
|
3267
|
+
return response;
|
|
3268
|
+
},
|
|
3269
|
+
options
|
|
3270
|
+
);
|
|
3271
|
+
return {
|
|
3272
|
+
mutate,
|
|
3273
|
+
downloadFile: mutate,
|
|
3274
|
+
isLoading
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
// src/apis/cache.ts
|
|
3279
|
+
function purge(options) {
|
|
3280
|
+
const { mutate, isLoading } = createMutation(
|
|
3281
|
+
async (payload) => {
|
|
3282
|
+
const safePayload = payload ?? {};
|
|
3283
|
+
const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
|
|
3284
|
+
const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
3285
|
+
const { idempotencyKey: _ignored, ...body } = safePayload;
|
|
3286
|
+
return Client.cache.purge(body, headers);
|
|
3287
|
+
},
|
|
3288
|
+
options
|
|
3289
|
+
);
|
|
3290
|
+
return { mutate, purgeCache: mutate, isLoading };
|
|
3291
|
+
}
|
|
3292
|
+
function purgeStatus(purgeJobId, options) {
|
|
3293
|
+
const { mutate, isLoading } = createMutation(
|
|
3294
|
+
async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
|
|
3295
|
+
options
|
|
3296
|
+
);
|
|
3297
|
+
return {
|
|
3298
|
+
mutate,
|
|
3299
|
+
getPurgeStatus: () => mutate(purgeJobId),
|
|
3300
|
+
isLoading
|
|
3301
|
+
};
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
// src/breadcrumb/breadcrumbs.ts
|
|
3305
|
+
var getBreadcrumbs = () => {
|
|
3306
|
+
const search = getParam("b");
|
|
3307
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
3308
|
+
if (!breadcrumbs && breadcrumbs.length < 1) return [];
|
|
3309
|
+
const updated = breadcrumbs.map((breadcrumb, index) => {
|
|
3310
|
+
return generatePath(breadcrumbs, breadcrumb, index);
|
|
3311
|
+
});
|
|
3312
|
+
if (updated.length < 1) {
|
|
3313
|
+
const pathname = getPath();
|
|
3314
|
+
const routeMenu = getRouteMenu(pathname);
|
|
3315
|
+
return [
|
|
3316
|
+
{
|
|
3317
|
+
name: routeMenu?.title,
|
|
3318
|
+
path: routeMenu?.path
|
|
3319
|
+
}
|
|
3320
|
+
];
|
|
3321
|
+
}
|
|
3322
|
+
return updated;
|
|
3323
|
+
};
|
|
3324
|
+
var getTableTitle = (componentName, title, ticketTableTitle) => {
|
|
3325
|
+
const search = getParam("b");
|
|
3326
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
3327
|
+
if (breadcrumbs.length < 1) {
|
|
3328
|
+
const pathname = getPath();
|
|
3329
|
+
const routeMenu = getRouteMenu(pathname);
|
|
3330
|
+
breadcrumbs = [
|
|
3331
|
+
{
|
|
3332
|
+
n: routeMenu?.title,
|
|
3333
|
+
pt: routeMenu?.path
|
|
3334
|
+
}
|
|
3335
|
+
];
|
|
3336
|
+
}
|
|
3337
|
+
let associatedtableTitleSingular = "";
|
|
3338
|
+
let tableTitle = "";
|
|
3339
|
+
let singularTableTitle = "";
|
|
3340
|
+
if (breadcrumbs && breadcrumbs.length > 0) {
|
|
3341
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
3342
|
+
const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
|
|
3343
|
+
const previousItem = breadcrumbs[breadcrumbs.length - 2];
|
|
3344
|
+
const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
|
|
3345
|
+
const singularLastName = last?.name;
|
|
3346
|
+
associatedtableTitleSingular = singularLastName;
|
|
3347
|
+
if (componentName != "ticket") {
|
|
3348
|
+
tableTitle = previous?.name ? { last, previous } : { last };
|
|
3349
|
+
singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
|
|
3350
|
+
} else {
|
|
3351
|
+
const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
|
|
3352
|
+
tableTitle = { last: { name: title } };
|
|
3353
|
+
singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
return { associatedtableTitleSingular, tableTitle, singularTableTitle };
|
|
3357
|
+
};
|
|
3358
|
+
var getFormTitle = (type, title, activeTab) => {
|
|
3359
|
+
const search = getParam("b");
|
|
3360
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
3361
|
+
if (breadcrumbs.length < 1) {
|
|
3362
|
+
const pathname = getPath();
|
|
3363
|
+
const routeMenu = getRouteMenu(pathname);
|
|
3364
|
+
breadcrumbs = [
|
|
3365
|
+
{
|
|
3366
|
+
n: routeMenu?.title,
|
|
3367
|
+
pt: routeMenu?.path
|
|
3368
|
+
}
|
|
3369
|
+
];
|
|
3370
|
+
}
|
|
3371
|
+
let objectName = "";
|
|
3372
|
+
let puralObjectName = "";
|
|
3373
|
+
let dialogTitle = "";
|
|
3374
|
+
if (breadcrumbs && breadcrumbs?.length > 0) {
|
|
3375
|
+
const last = breadcrumbs[breadcrumbs?.length - 1];
|
|
3376
|
+
const lastName = last?.n;
|
|
3377
|
+
const mTitle = title;
|
|
3378
|
+
if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
|
|
3379
|
+
objectName = title;
|
|
3380
|
+
puralObjectName = title;
|
|
3381
|
+
dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
|
|
3382
|
+
} else {
|
|
3383
|
+
const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
|
|
3384
|
+
objectName = singularLastName;
|
|
3385
|
+
puralObjectName = lastName;
|
|
3386
|
+
dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
return { objectName, puralObjectName, dialogTitle };
|
|
3390
|
+
};
|
|
3391
|
+
var nameTrancate = (name) => {
|
|
3392
|
+
return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
|
|
3393
|
+
};
|
|
3394
|
+
|
|
3395
|
+
// src/breadcrumb/generate-url.ts
|
|
3396
|
+
var useMakeLink = () => {
|
|
3397
|
+
const search = getParam("b");
|
|
3398
|
+
const makeLink = (props) => {
|
|
3399
|
+
if (!search || "isPC" in props) {
|
|
3400
|
+
return buildParentRoute(props);
|
|
3401
|
+
} else {
|
|
3402
|
+
const breadcrumbItems = decodeToBase64(search) || [];
|
|
3403
|
+
return buildChildRoute(props, breadcrumbItems);
|
|
3404
|
+
}
|
|
3405
|
+
};
|
|
3406
|
+
return { makeLink };
|
|
3407
|
+
};
|
|
3408
|
+
var buildParentRoute = (props) => {
|
|
3409
|
+
const pathname = getPath();
|
|
3410
|
+
const routeMenu = getRouteMenu(pathname);
|
|
3411
|
+
const breadcrumbItems = [
|
|
3412
|
+
{
|
|
3413
|
+
n: routeMenu?.title,
|
|
3414
|
+
o_t_id: routeMenu?.path,
|
|
3415
|
+
isHome: props?.isHome || false
|
|
3416
|
+
}
|
|
3417
|
+
];
|
|
3418
|
+
return buildChildRoute(props, breadcrumbItems);
|
|
3419
|
+
};
|
|
3420
|
+
var buildChildRoute = (props, breadcrumbItems) => {
|
|
3421
|
+
let breadcrumbs = [...breadcrumbItems];
|
|
3422
|
+
let breadcrumbType = breadcrumbStage(breadcrumbItems);
|
|
3423
|
+
if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
|
|
3424
|
+
const parent = {
|
|
3425
|
+
n: props?.title || "",
|
|
3426
|
+
o_t_id: props?.objectTypeId,
|
|
3427
|
+
"pt": `/association/${props?.objectTypeId}`,
|
|
3428
|
+
isHome: props?.isHome || false,
|
|
3429
|
+
"prm": {
|
|
3430
|
+
"sort": "-hs_createdate",
|
|
3431
|
+
"s": "",
|
|
3432
|
+
"fPn": "hs_pipeline",
|
|
3433
|
+
"fO": "eq",
|
|
3434
|
+
"fV": "",
|
|
3435
|
+
"c": true,
|
|
3436
|
+
"isPC": props?.isPC,
|
|
3437
|
+
"v": "LIST",
|
|
3438
|
+
"l": "10",
|
|
3439
|
+
"p": 1
|
|
3440
|
+
}
|
|
3441
|
+
};
|
|
3442
|
+
breadcrumbs.push(parent);
|
|
3443
|
+
const newCrumb = {
|
|
3444
|
+
n: props?.name,
|
|
3445
|
+
o_t_id: props?.objectTypeId,
|
|
3446
|
+
o_r_id: props?.recordId
|
|
3447
|
+
};
|
|
3448
|
+
breadcrumbs.push(newCrumb);
|
|
3449
|
+
} else if (breadcrumbType === "root") {
|
|
3450
|
+
const newCrumb = {
|
|
3451
|
+
n: props?.name,
|
|
3452
|
+
o_t_id: props?.objectTypeId,
|
|
3453
|
+
o_r_id: props?.recordId
|
|
3454
|
+
};
|
|
3455
|
+
if (props?.isPC) {
|
|
3456
|
+
newCrumb.prm = {
|
|
3457
|
+
isPC: props?.isPC
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
breadcrumbs.push(newCrumb);
|
|
3461
|
+
} else {
|
|
3462
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
3463
|
+
if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
|
|
3464
|
+
(!isMessingParent(breadcrumbItems) && lastItem?.o_t_id === props?.objectTypeId) && // check for all associated object and check isMessingParent for skip parent to child and child to parent association data
|
|
3465
|
+
(props?.isHome && !isMessingParentLastItem(breadcrumbItems))) {
|
|
3466
|
+
const newCrumb = {
|
|
3467
|
+
n: props?.name,
|
|
3468
|
+
o_t_id: props?.objectTypeId,
|
|
3469
|
+
o_r_id: props?.recordId
|
|
3470
|
+
};
|
|
3471
|
+
if (props?.isPC) {
|
|
3472
|
+
newCrumb.prm = {
|
|
3473
|
+
isPC: props?.isPC
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
breadcrumbs.push(newCrumb);
|
|
3477
|
+
} else {
|
|
3478
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
|
|
3479
|
+
const parent = {
|
|
3480
|
+
n: props?.associationLabel || props?.name,
|
|
3481
|
+
o_t_id: props?.objectTypeId
|
|
3482
|
+
};
|
|
3483
|
+
if (props?.tableParam) {
|
|
3484
|
+
parent.prm = props?.tableParam;
|
|
3485
|
+
}
|
|
3486
|
+
if (props?.defPermissions) {
|
|
3487
|
+
parent.dp = props?.defPermissions;
|
|
3488
|
+
}
|
|
3489
|
+
if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
|
|
3490
|
+
breadcrumbs.push(parent);
|
|
3491
|
+
}
|
|
3492
|
+
if (props?.recordId) {
|
|
3493
|
+
const newCrumb = {
|
|
3494
|
+
n: props?.name,
|
|
3495
|
+
o_t_id: props?.objectTypeId,
|
|
3496
|
+
o_r_id: props?.recordId
|
|
3497
|
+
};
|
|
3498
|
+
if (props?.isPC) {
|
|
3499
|
+
newCrumb.prm = {
|
|
3500
|
+
isPC: props?.isPC
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3503
|
+
breadcrumbs.push(newCrumb);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
return generateUrl(props, breadcrumbs);
|
|
3508
|
+
};
|
|
3509
|
+
|
|
3510
|
+
// src/utils/datetime.ts
|
|
3511
|
+
var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
|
|
3512
|
+
function getCurrentTimeZone() {
|
|
3513
|
+
try {
|
|
3514
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
|
|
3515
|
+
} catch {
|
|
3516
|
+
return DEFAULT_HUBSPOT_TIMEZONE;
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
function normalizeToTimestamp(value) {
|
|
3520
|
+
if (value == null || value === "") return null;
|
|
3521
|
+
if (typeof value === "number") {
|
|
3522
|
+
return value > 1e11 ? value : null;
|
|
3523
|
+
}
|
|
3524
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
3525
|
+
const n = Number(value);
|
|
3526
|
+
return n > 1e11 ? n : null;
|
|
3527
|
+
}
|
|
3528
|
+
if (typeof value === "string" || value instanceof Date) {
|
|
3529
|
+
const date = new Date(value);
|
|
3530
|
+
return Number.isNaN(date.getTime()) ? null : date.getTime();
|
|
3531
|
+
}
|
|
3532
|
+
return null;
|
|
3533
|
+
}
|
|
3534
|
+
function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
|
|
3535
|
+
const raw = new Intl.DateTimeFormat("en-US", {
|
|
3536
|
+
timeZone,
|
|
3537
|
+
timeZoneName: "longOffset"
|
|
3538
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
|
|
3539
|
+
if (!raw) return "";
|
|
3540
|
+
return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
|
|
3541
|
+
}
|
|
3542
|
+
function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
|
|
3543
|
+
const ms = normalizeToTimestamp(timestamp);
|
|
3544
|
+
if (ms == null) return null;
|
|
3545
|
+
const date = new Date(ms);
|
|
3546
|
+
const datePart = new Intl.DateTimeFormat("en-US", {
|
|
3547
|
+
timeZone,
|
|
3548
|
+
month: "long",
|
|
3549
|
+
day: "numeric",
|
|
3550
|
+
year: "numeric"
|
|
3551
|
+
}).format(date);
|
|
3552
|
+
const timePart = new Intl.DateTimeFormat("en-US", {
|
|
3553
|
+
timeZone,
|
|
3554
|
+
hour: "numeric",
|
|
3555
|
+
minute: "2-digit",
|
|
3556
|
+
hour12: true
|
|
3557
|
+
}).format(date);
|
|
3558
|
+
const gmtOffset = formatGmtOffset(timeZone, date);
|
|
3559
|
+
return {
|
|
3560
|
+
date: datePart,
|
|
3561
|
+
time: timePart,
|
|
3562
|
+
gmtOffset,
|
|
3563
|
+
formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
|
|
3564
|
+
};
|
|
3565
|
+
}
|
|
3566
|
+
function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
|
|
3567
|
+
return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
// src/index.ts
|
|
3571
|
+
var api = {
|
|
3572
|
+
preLogin,
|
|
3573
|
+
login,
|
|
3574
|
+
verifyEmail,
|
|
3575
|
+
resetPasswordVerifyToken,
|
|
3576
|
+
resetPassword,
|
|
3577
|
+
registerExistingUser,
|
|
3578
|
+
verifyEmailResend,
|
|
3579
|
+
resendEmail,
|
|
3580
|
+
getSsoDetails,
|
|
3581
|
+
generateSsoUrl,
|
|
3582
|
+
ssoCallback,
|
|
3583
|
+
forgetPassword,
|
|
3584
|
+
logout,
|
|
3585
|
+
me,
|
|
3586
|
+
profile,
|
|
3587
|
+
changePassword,
|
|
3588
|
+
pipelines: list,
|
|
3589
|
+
stages: list2,
|
|
3590
|
+
objects: list3,
|
|
3591
|
+
sideBarObjects: sideBarList,
|
|
3592
|
+
objectsForm: form,
|
|
3593
|
+
createObject: create,
|
|
3594
|
+
createExistingObject: createExisting,
|
|
3595
|
+
removeExistingObject: removeExisting,
|
|
3596
|
+
objectsDetails: details,
|
|
3597
|
+
updateObjectsDetails: update,
|
|
3598
|
+
objectFormOptions,
|
|
3599
|
+
notes: list4,
|
|
3600
|
+
createNote: create2,
|
|
3601
|
+
updateNote: update2,
|
|
3602
|
+
emails: list5,
|
|
3603
|
+
createEmail: create3,
|
|
3604
|
+
updateEmail: update3,
|
|
3605
|
+
imageUpload,
|
|
3606
|
+
attachmentUpload,
|
|
3607
|
+
files: list6,
|
|
3608
|
+
file: details2,
|
|
3609
|
+
fileDownload: download,
|
|
3610
|
+
addFolder,
|
|
3611
|
+
addFile,
|
|
3612
|
+
purgeCache: purge,
|
|
3613
|
+
cachePurgeStatus: purgeStatus,
|
|
3614
|
+
getRefreshToken,
|
|
3615
|
+
getAuthRefreshToken,
|
|
3616
|
+
isCookieExpired,
|
|
3617
|
+
isExpiresAccessToken,
|
|
3618
|
+
isAuthenticateApp,
|
|
3619
|
+
getAccessToken
|
|
3620
|
+
};
|
|
3621
|
+
var store = {
|
|
3622
|
+
storage,
|
|
3623
|
+
useTable
|
|
3624
|
+
};
|
|
3625
|
+
var breadcrumbsDetails = {
|
|
3626
|
+
getBreadcrumbs,
|
|
3627
|
+
getTableTitle,
|
|
3628
|
+
getFormTitle
|
|
3629
|
+
};
|
|
3630
|
+
var url = {
|
|
3631
|
+
useMakeLink,
|
|
3632
|
+
useUpdateLink
|
|
3633
|
+
};
|
|
3634
|
+
var routeParam = {
|
|
3635
|
+
getRouteDetails,
|
|
3636
|
+
getParamDetails
|
|
3637
|
+
};
|
|
3638
|
+
|
|
3639
|
+
export { DEFAULT_HUBSPOT_TIMEZONE, actions2 as actions, actions3 as actions2, actions4 as actions3, actions5 as actions4, actions7 as actions5, actions8 as actions6, api, breadcrumbsDetails, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, client_exports, createCachePurgeJob, emailStore, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, mergePurgeTargets, multiObjectStore, normalizeToTimestamp, noteStore, purgeCrmCombined, purgeCrmListCache, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, routeParam, store, syncStore, tableStore2 as tableStore, uploaderStore, url };
|
|
3640
|
+
//# sourceMappingURL=chunk-IVNXDHLP.js.map
|
|
3641
|
+
//# sourceMappingURL=chunk-IVNXDHLP.js.map
|