woodsportal-client-sdk 1.1.5-dev.0 → 4.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +171 -77
- package/dist/adapters/angular/index.d.ts +58 -5
- package/dist/adapters/angular/index.js +8 -7
- package/dist/adapters/angular/index.js.map +1 -1
- package/dist/adapters/react/index.d.ts +58 -5
- package/dist/adapters/react/index.js +7 -6
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +58 -5
- package/dist/adapters/vue/index.js +8 -7
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/auth-utils-VT7HSLMA.js +3 -0
- package/dist/{auth-utils-A4WPJMPK.js.map → auth-utils-VT7HSLMA.js.map} +1 -1
- package/dist/authentication-BfYhAeMs.d.ts +463 -0
- package/dist/cache-purge-G5WkHckd.d.ts +236 -0
- package/dist/chunk-3FUHGFAQ.js +167 -0
- package/dist/chunk-3FUHGFAQ.js.map +1 -0
- package/dist/chunk-4ZV3MQIB.js +2000 -0
- package/dist/chunk-4ZV3MQIB.js.map +1 -0
- package/dist/{chunk-Y5MRAAGK.js → chunk-AYTO6ND7.js} +3 -3
- package/dist/chunk-AYTO6ND7.js.map +1 -0
- package/dist/chunk-G2KECOVQ.js +504 -0
- package/dist/chunk-G2KECOVQ.js.map +1 -0
- package/dist/chunk-H57IQHVF.js +20 -0
- package/dist/chunk-H57IQHVF.js.map +1 -0
- package/dist/chunk-KBXI2JBA.js +1200 -0
- package/dist/chunk-KBXI2JBA.js.map +1 -0
- package/dist/chunk-KCZFT6OM.js +416 -0
- package/dist/chunk-KCZFT6OM.js.map +1 -0
- package/dist/chunk-SSS4DNXP.js +304 -0
- package/dist/chunk-SSS4DNXP.js.map +1 -0
- package/dist/entries/auth.d.ts +68 -0
- package/dist/entries/auth.js +13 -0
- package/dist/entries/auth.js.map +1 -0
- package/dist/entries/crm.d.ts +208 -0
- package/dist/entries/crm.js +24 -0
- package/dist/entries/crm.js.map +1 -0
- package/dist/index-CCwMopD8.d.ts +38 -0
- package/dist/index.d.ts +405 -406
- package/dist/index.js +23 -1720
- package/dist/index.js.map +1 -1
- package/dist/use-sync-DpazhM4d.d.ts +60 -0
- package/dist/use-uploader-2F1zc7Cl.d.ts +23 -0
- package/package.json +53 -8
- package/dist/auth-utils-A4WPJMPK.js +0 -4
- package/dist/chunk-J7MDPY5P.js +0 -54
- package/dist/chunk-J7MDPY5P.js.map +0 -1
- package/dist/chunk-NB7AINV4.js +0 -35
- package/dist/chunk-NB7AINV4.js.map +0 -1
- package/dist/chunk-RDCT25UV.js +0 -1066
- package/dist/chunk-RDCT25UV.js.map +0 -1
- package/dist/chunk-Y5MRAAGK.js.map +0 -1
- package/dist/chunk-YLZA5S7A.js +0 -102
- package/dist/chunk-YLZA5S7A.js.map +0 -1
- package/dist/use-sync-LbURBOs_.d.ts +0 -29
|
@@ -0,0 +1,2000 @@
|
|
|
1
|
+
import { createStore, getParamDetails, getRouteDetails, updateLink, configureLogger, isHttpTracingEnabled, logger, sanitizeAxiosErrorData, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, ticketHubspotObjectTypeId, tableStore, actions2, userStore, emailStore, actions5, noteStore, actions4 as actions4$1, resetAllStore, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-KBXI2JBA.js';
|
|
2
|
+
import { HUBSPOT_DATA, DEV_API_URL, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, configureStorageKeys, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, ensureValidRefresh } from './chunk-3FUHGFAQ.js';
|
|
3
|
+
import axios2 from 'axios';
|
|
4
|
+
|
|
5
|
+
// src/main/core/utils/localStorage.ts
|
|
6
|
+
var memory = /* @__PURE__ */ new Map();
|
|
7
|
+
var memoryStore = {
|
|
8
|
+
getItem(key) {
|
|
9
|
+
return memory.has(key) ? memory.get(key) : null;
|
|
10
|
+
},
|
|
11
|
+
setItem(key, value) {
|
|
12
|
+
memory.set(key, value);
|
|
13
|
+
},
|
|
14
|
+
removeItem(key) {
|
|
15
|
+
memory.delete(key);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function resolveStore() {
|
|
19
|
+
if (typeof globalThis === "undefined") {
|
|
20
|
+
return memoryStore;
|
|
21
|
+
}
|
|
22
|
+
const ls = globalThis.localStorage;
|
|
23
|
+
if (!ls || typeof ls.getItem !== "function") {
|
|
24
|
+
return memoryStore;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const probeKey = "__woodsportal_client_sdk_ls_probe__";
|
|
28
|
+
ls.setItem(probeKey, "1");
|
|
29
|
+
ls.removeItem(probeKey);
|
|
30
|
+
return ls;
|
|
31
|
+
} catch {
|
|
32
|
+
return memoryStore;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var storage = {
|
|
36
|
+
set: (key, value) => {
|
|
37
|
+
resolveStore().setItem(key, JSON.stringify(value));
|
|
38
|
+
},
|
|
39
|
+
get: (key) => {
|
|
40
|
+
const item = resolveStore().getItem(key);
|
|
41
|
+
return item ? JSON.parse(item) : null;
|
|
42
|
+
},
|
|
43
|
+
remove: (key) => {
|
|
44
|
+
resolveStore().removeItem(key);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/main/core/utils/hub-context.ts
|
|
49
|
+
var config = {
|
|
50
|
+
get hubId() {
|
|
51
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
52
|
+
return hubSpotData?.[HUB_ID] || "";
|
|
53
|
+
},
|
|
54
|
+
get devPortalId() {
|
|
55
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
56
|
+
return hubSpotData?.[DEV_PORTAL_ID] || "";
|
|
57
|
+
},
|
|
58
|
+
get portalId() {
|
|
59
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
60
|
+
return hubSpotData?.[PORTAL_ID] || "";
|
|
61
|
+
},
|
|
62
|
+
get devApiUrl() {
|
|
63
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
64
|
+
return hubSpotData?.[DEV_API_URL] || "";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var setConfig = {
|
|
68
|
+
setDevPortalId(portalId) {
|
|
69
|
+
const existing = storage.get(HUBSPOT_DATA) || {};
|
|
70
|
+
storage.set(HUBSPOT_DATA, {
|
|
71
|
+
...existing,
|
|
72
|
+
[PORTAL_ID]: portalId
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var SERVICE_UNAVAILABLE_MESSAGE = "Service temporarily unavailable. Please try again in a few minutes.";
|
|
77
|
+
var SERVICE_UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
78
|
+
function classifyHttpError(error) {
|
|
79
|
+
if (!axios2.isAxiosError(error)) {
|
|
80
|
+
return "unknown";
|
|
81
|
+
}
|
|
82
|
+
const status = error.response?.status;
|
|
83
|
+
if (status != null) {
|
|
84
|
+
if (SERVICE_UNAVAILABLE_STATUSES.has(status)) return "service_unavailable";
|
|
85
|
+
if (status === 401 || status === 403) return "auth";
|
|
86
|
+
if (status >= 400 && status < 500) return "client";
|
|
87
|
+
if (status >= 500) return "server";
|
|
88
|
+
}
|
|
89
|
+
if (error.code === "ECONNABORTED" || error.message.toLowerCase().includes("timeout")) {
|
|
90
|
+
return "timeout";
|
|
91
|
+
}
|
|
92
|
+
if (error.code === "ERR_NETWORK" || error.message === "Network Error") {
|
|
93
|
+
return "service_unavailable";
|
|
94
|
+
}
|
|
95
|
+
return "network";
|
|
96
|
+
}
|
|
97
|
+
function isServiceUnavailableError(error) {
|
|
98
|
+
return classifyHttpError(error) === "service_unavailable";
|
|
99
|
+
}
|
|
100
|
+
function getHttpErrorMessage(error) {
|
|
101
|
+
const kind = classifyHttpError(error);
|
|
102
|
+
switch (kind) {
|
|
103
|
+
case "service_unavailable":
|
|
104
|
+
return SERVICE_UNAVAILABLE_MESSAGE;
|
|
105
|
+
case "timeout":
|
|
106
|
+
return "The request timed out. Please check your connection and try again.";
|
|
107
|
+
case "auth":
|
|
108
|
+
return "Your session has expired. Please sign in again.";
|
|
109
|
+
case "network":
|
|
110
|
+
return "Unable to reach the server. Please check your connection and try again.";
|
|
111
|
+
case "client":
|
|
112
|
+
case "server":
|
|
113
|
+
case "unknown": {
|
|
114
|
+
if (axios2.isAxiosError(error)) {
|
|
115
|
+
const payload = error.response?.data;
|
|
116
|
+
const apiMessage = payload?.errorMessage ?? payload?.message;
|
|
117
|
+
if (typeof apiMessage === "string" && apiMessage.trim() !== "") {
|
|
118
|
+
return apiMessage;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return "Something went wrong. Please try again.";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/main/core/http/api-endpoints.ts
|
|
127
|
+
var API_ENDPOINTS = {
|
|
128
|
+
// Auth
|
|
129
|
+
PRE_LOGIN: "/api/auth/pre-login",
|
|
130
|
+
LOGIN: "/api/auth/login",
|
|
131
|
+
AUTH_REFRESH: "/api/auth/refresh",
|
|
132
|
+
FORGET_PASSWORD: "/api/auth/forget-password",
|
|
133
|
+
RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
|
|
134
|
+
RESET_PASSWORD: "/api/auth/reset-password",
|
|
135
|
+
VERIFY_EMAIL: "/api/auth/verify-email",
|
|
136
|
+
REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
|
|
137
|
+
RESEND_EMAIL: "/api/auth/resend-email",
|
|
138
|
+
VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
|
|
139
|
+
LOGOUT: "/api/auth/logout",
|
|
140
|
+
VERIFY_OTP: "/api/auth/verify-otp",
|
|
141
|
+
CLIENT_SESSION: "/api/auth/client-session",
|
|
142
|
+
// Auth MFA (client lane)
|
|
143
|
+
MFA_PENDING_OTP_SEND: "/api/auth/mfa/pending/otp/send",
|
|
144
|
+
MFA_PENDING_PASSKEY_OPTIONS: "/api/auth/mfa/pending/passkey/authenticate/options",
|
|
145
|
+
MFA_PENDING_PASSKEY_VERIFY: "/api/auth/mfa/pending/passkey/authenticate/verify",
|
|
146
|
+
MFA_STATUS: "/api/auth/mfa/status",
|
|
147
|
+
MFA_PREFERENCES: "/api/auth/mfa/preferences",
|
|
148
|
+
MFA_PHONE_VERIFY_START: "/api/auth/mfa/phone/verify/start",
|
|
149
|
+
MFA_PHONE_VERIFY_CONFIRM: "/api/auth/mfa/phone/verify/confirm",
|
|
150
|
+
MFA_TOTP_ENROLL_START: "/api/auth/mfa/totp/enroll/start",
|
|
151
|
+
MFA_TOTP_ENROLL_VERIFY: "/api/auth/mfa/totp/enroll/verify",
|
|
152
|
+
MFA_TOTP_DISABLE: "/api/auth/mfa/totp/disable",
|
|
153
|
+
MFA_WEBAUTHN_REGISTER_OPTIONS: "/api/auth/mfa/webauthn/register/options",
|
|
154
|
+
MFA_WEBAUTHN_REGISTER_VERIFY: "/api/auth/mfa/webauthn/register/verify",
|
|
155
|
+
MFA_WEBAUTHN_AUTH_OPTIONS: "/api/auth/mfa/webauthn/authenticate/options",
|
|
156
|
+
MFA_WEBAUTHN_AUTH_VERIFY: "/api/auth/mfa/webauthn/authenticate/verify",
|
|
157
|
+
MFA_WEBAUTHN_CREDENTIALS: "/api/auth/mfa/webauthn/credentials",
|
|
158
|
+
MFA_WEBAUTHN_CREDENTIAL_DELETE: "/api/auth/mfa/webauthn/credentials/${credentialRecordId}",
|
|
159
|
+
PASSKEY_LOGIN_OPTIONS: "/api/auth/passkey/login/options",
|
|
160
|
+
PASSKEY_LOGIN_VERIFY: "/api/auth/passkey/login/verify",
|
|
161
|
+
// Auth Security (client lane)
|
|
162
|
+
SECURITY_OVERVIEW: "/api/auth/security/overview",
|
|
163
|
+
SECURITY_LOGIN_ACTIVITY: "/api/auth/security/login-activity",
|
|
164
|
+
SECURITY_SESSIONS: "/api/auth/security/sessions",
|
|
165
|
+
SECURITY_SESSION_REVOKE: "/api/auth/security/sessions/${familyId}/revoke",
|
|
166
|
+
SECURITY_SESSIONS_REVOKE_OTHERS: "/api/auth/security/sessions/revoke-others",
|
|
167
|
+
// SSO
|
|
168
|
+
SSO_DETAILS: "/api/auth/sso/active",
|
|
169
|
+
SSO_URL: "/api/auth/sso/authorize",
|
|
170
|
+
SSO_CALLBACK: "/api/auth/sso/callback",
|
|
171
|
+
// User
|
|
172
|
+
ME: "/api/${hubId}/${portalId}/auth/me?include=crmProfile",
|
|
173
|
+
PROFILE: "/api/${hubId}/${portalId}/profiles",
|
|
174
|
+
PROFILE_UPDATE: "/api/${hubId}/${portalId}/profiles",
|
|
175
|
+
CHANGE_PASSWORD: "/api/auth/change-password",
|
|
176
|
+
// Pipeline
|
|
177
|
+
PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
178
|
+
// Stage
|
|
179
|
+
STAGES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
|
|
180
|
+
// Cache purge (replaces cache=false refresh; requires features.cache-purge-api-enabled on API)
|
|
181
|
+
CACHE_PURGE: "/api/${hubId}/${portalId}/cache-purge-jobs",
|
|
182
|
+
CACHE_PURGE_STATUS: "/api/${hubId}/${portalId}/cache-purge-jobs/${purgeJobId}",
|
|
183
|
+
/** @deprecated Use CACHE_PURGE */
|
|
184
|
+
CACHE_PURGE_LEGACY: "/api/${hubId}/${portalId}/cache/purge",
|
|
185
|
+
/** @deprecated Use CACHE_PURGE_STATUS */
|
|
186
|
+
CACHE_PURGE_STATUS_LEGACY: "/api/${hubId}/${portalId}/cache/purge/${purgeJobId}",
|
|
187
|
+
// Object (read on hubspot-object-data; form layout on hubspot-object-forms)
|
|
188
|
+
OBJECTS: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
|
|
189
|
+
OBJECTS_FORM: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
|
|
190
|
+
OBJECTS_FORM_OPTIONS: "/api/${hubId}/${portalId}/hubspot-object-forms/${formId}/${objectTypeId}",
|
|
191
|
+
RECORDS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
|
|
192
|
+
RECORDS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
|
|
193
|
+
RECORDS_ASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
|
|
194
|
+
RECORDS_DISASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
|
|
195
|
+
/** @deprecated Use RECORDS_CREATE */
|
|
196
|
+
OBJECTS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
|
|
197
|
+
/** @deprecated Use RECORDS_ASSOCIATE */
|
|
198
|
+
OBJECTS_CREATE_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-forms/:fromObjectTypeId/:fromRecordId/associations/:toObjectTypeId",
|
|
199
|
+
OBJECTS_DETAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
|
|
200
|
+
/** @deprecated Use RECORDS_UPDATE */
|
|
201
|
+
OBJECTS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/records/${id}",
|
|
202
|
+
OBJECTS_DETAILS_UPDATE_LEGACY: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/properties/${id}",
|
|
203
|
+
// Notes (nested under CRM record)
|
|
204
|
+
NOTES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
|
|
205
|
+
NOTES_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
|
|
206
|
+
NOTES_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/${note_id}",
|
|
207
|
+
NOTES_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/images",
|
|
208
|
+
NOTES_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments",
|
|
209
|
+
NOTES_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments/${note_id}",
|
|
210
|
+
// Email (nested under CRM record)
|
|
211
|
+
EMAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
|
|
212
|
+
EMAILS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
|
|
213
|
+
EMAILS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/${email_id}",
|
|
214
|
+
EMAILS_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/images",
|
|
215
|
+
EMAILS_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments",
|
|
216
|
+
EMAILS_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments/${email_id}",
|
|
217
|
+
// File manager (nested under CRM record)
|
|
218
|
+
FILES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files",
|
|
219
|
+
FILE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}",
|
|
220
|
+
FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
|
|
221
|
+
FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
|
|
222
|
+
FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// src/main/core/http/http-config.ts
|
|
226
|
+
var config2 = {
|
|
227
|
+
baseURL: ""
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// src/main/core/utils/generateApiUrl.ts
|
|
231
|
+
var generateApiUrl = ({ route, params = {}, queryParams = "" }) => {
|
|
232
|
+
const defaultParams = {
|
|
233
|
+
hubId: config.hubId,
|
|
234
|
+
portalId: config.portalId
|
|
235
|
+
};
|
|
236
|
+
params = { ...defaultParams, ...params };
|
|
237
|
+
const url = replaceParams(route, params);
|
|
238
|
+
let queryString = "";
|
|
239
|
+
if (queryParams && typeof queryParams === "object") {
|
|
240
|
+
const cleanedParams = Object.entries(queryParams).filter(([_, value]) => value !== null && value !== void 0).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
|
|
241
|
+
queryString = new URLSearchParams(cleanedParams).toString();
|
|
242
|
+
}
|
|
243
|
+
return queryString ? `${url}?${queryString}` : url;
|
|
244
|
+
};
|
|
245
|
+
function replaceParams(template, values) {
|
|
246
|
+
return template.replace(/\$\{(\w+)\}/g, (_, key) => key in values ? String(values[key]) : `\${${key}}`);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/main/core/logging/log-http.ts
|
|
250
|
+
var SENSITIVE_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
251
|
+
"token",
|
|
252
|
+
"refreshtoken",
|
|
253
|
+
"accesstoken",
|
|
254
|
+
"password",
|
|
255
|
+
"secret",
|
|
256
|
+
"authorization",
|
|
257
|
+
"otp",
|
|
258
|
+
"code",
|
|
259
|
+
"api_key",
|
|
260
|
+
"apikey"
|
|
261
|
+
]);
|
|
262
|
+
function isSensitiveQueryKey(key) {
|
|
263
|
+
const normalized = key.toLowerCase();
|
|
264
|
+
return SENSITIVE_QUERY_KEYS.has(normalized) || normalized.includes("password") || normalized.includes("token");
|
|
265
|
+
}
|
|
266
|
+
function sanitizeHttpUrl(url) {
|
|
267
|
+
if (url == null || url === "") {
|
|
268
|
+
return url;
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const base = typeof window !== "undefined" ? window.location.origin : "http://localhost";
|
|
272
|
+
const parsed = url.startsWith("http") ? new URL(url) : new URL(url, base);
|
|
273
|
+
for (const key of [...parsed.searchParams.keys()]) {
|
|
274
|
+
if (isSensitiveQueryKey(key)) {
|
|
275
|
+
parsed.searchParams.set(key, "[redacted]");
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return url.startsWith("http") ? parsed.toString() : `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
279
|
+
} catch {
|
|
280
|
+
return url;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var SDK_HTTP_TIMING_KEY = "__woodsportalSdkRequestStartMs";
|
|
284
|
+
function markHttpRequestStart(config4) {
|
|
285
|
+
config4[SDK_HTTP_TIMING_KEY] = Date.now();
|
|
286
|
+
}
|
|
287
|
+
function getHttpRequestDurationMs(config4) {
|
|
288
|
+
const start = config4[SDK_HTTP_TIMING_KEY];
|
|
289
|
+
return typeof start === "number" ? Date.now() - start : void 0;
|
|
290
|
+
}
|
|
291
|
+
function getHttpMethod(config4) {
|
|
292
|
+
return config4.method?.toUpperCase();
|
|
293
|
+
}
|
|
294
|
+
function getHttpUrl(config4) {
|
|
295
|
+
return sanitizeHttpUrl(config4.url);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/main/core/http/http-client.ts
|
|
299
|
+
var axiosInstance = null;
|
|
300
|
+
var config3 = {};
|
|
301
|
+
function notifyServiceUnavailable(error) {
|
|
302
|
+
if (!isServiceUnavailableError(error)) return;
|
|
303
|
+
config3.onServiceUnavailable?.(error);
|
|
304
|
+
}
|
|
305
|
+
function initializeHttpClient(clientConfig) {
|
|
306
|
+
config3 = clientConfig;
|
|
307
|
+
if (clientConfig.logger != null) {
|
|
308
|
+
configureLogger(clientConfig.logger);
|
|
309
|
+
}
|
|
310
|
+
if (clientConfig.storageKeys != null) {
|
|
311
|
+
configureStorageKeys(clientConfig.storageKeys);
|
|
312
|
+
}
|
|
313
|
+
const baseURL = config?.devApiUrl || config3.baseURL;
|
|
314
|
+
if (!baseURL) {
|
|
315
|
+
throw new Error("WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup.");
|
|
316
|
+
}
|
|
317
|
+
const timeout = config3.timeout ?? 5e4;
|
|
318
|
+
axiosInstance = axios2.create({
|
|
319
|
+
baseURL,
|
|
320
|
+
timeout,
|
|
321
|
+
headers: {
|
|
322
|
+
"Content-Type": "application/json",
|
|
323
|
+
...config3.headers
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
setRefreshCallback(getAuthRefreshToken);
|
|
327
|
+
axiosInstance.interceptors.request.use((requestConfig) => {
|
|
328
|
+
markHttpRequestStart(requestConfig);
|
|
329
|
+
if (isHttpTracingEnabled()) {
|
|
330
|
+
logger.debug("http", "request start", {
|
|
331
|
+
method: getHttpMethod(requestConfig),
|
|
332
|
+
url: getHttpUrl(requestConfig),
|
|
333
|
+
phase: "start"
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
const token = getAccessToken();
|
|
337
|
+
if (token) {
|
|
338
|
+
requestConfig.headers.set("Authorization", `Bearer ${token}`);
|
|
339
|
+
}
|
|
340
|
+
return requestConfig;
|
|
341
|
+
});
|
|
342
|
+
axiosInstance.interceptors.response.use(
|
|
343
|
+
(response) => {
|
|
344
|
+
if (isHttpTracingEnabled()) {
|
|
345
|
+
logger.debug("http", "request complete", {
|
|
346
|
+
method: getHttpMethod(response.config),
|
|
347
|
+
url: getHttpUrl(response.config),
|
|
348
|
+
status: response.status,
|
|
349
|
+
durationMs: getHttpRequestDurationMs(response.config),
|
|
350
|
+
phase: "complete"
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return response;
|
|
354
|
+
},
|
|
355
|
+
(error) => {
|
|
356
|
+
if (axios2.isAxiosError(error) && error.config) {
|
|
357
|
+
const status = error.response?.status;
|
|
358
|
+
if (isHttpTracingEnabled()) {
|
|
359
|
+
logger.debug("http", "request failed", {
|
|
360
|
+
method: getHttpMethod(error.config),
|
|
361
|
+
url: getHttpUrl(error.config),
|
|
362
|
+
status,
|
|
363
|
+
durationMs: getHttpRequestDurationMs(error.config),
|
|
364
|
+
phase: "complete"
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
if (status != null && status >= 400 && status !== 401) {
|
|
368
|
+
logger.warn("http", "HTTP error response", {
|
|
369
|
+
method: getHttpMethod(error.config),
|
|
370
|
+
url: sanitizeHttpUrl(error.config.url),
|
|
371
|
+
status,
|
|
372
|
+
statusText: error.response?.statusText,
|
|
373
|
+
data: sanitizeAxiosErrorData(error.response?.data)
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
notifyServiceUnavailable(error);
|
|
377
|
+
}
|
|
378
|
+
if (error.response && error.response.status === 401) {
|
|
379
|
+
const shouldHandleAuthError = config3.skipCurrentPublicPath?.() ?? false;
|
|
380
|
+
if (shouldHandleAuthError) {
|
|
381
|
+
const payload = error.response.data ?? {};
|
|
382
|
+
const data = {
|
|
383
|
+
errorCode: payload.errorCode,
|
|
384
|
+
errorMessage: payload.errorMessage ?? payload.message,
|
|
385
|
+
detailedMessage: payload.detailedMessage,
|
|
386
|
+
correlationId: payload.correlationId,
|
|
387
|
+
ts: Date.now()
|
|
388
|
+
};
|
|
389
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
390
|
+
sessionStorage.setItem("authError", JSON.stringify(data));
|
|
391
|
+
}
|
|
392
|
+
if (config3.routes?.unauthorized && typeof window !== "undefined") {
|
|
393
|
+
window.location.replace(`#${config3.routes.unauthorized}`);
|
|
394
|
+
}
|
|
395
|
+
void config3.onLogout?.();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return Promise.reject(error);
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
logger.info("http", "HTTP client initialized", { baseURL });
|
|
402
|
+
}
|
|
403
|
+
function getAxiosInstance() {
|
|
404
|
+
if (!axiosInstance) {
|
|
405
|
+
initializeHttpClient({
|
|
406
|
+
baseURL: config2.baseURL,
|
|
407
|
+
timeout: 5e4
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
return axiosInstance;
|
|
411
|
+
}
|
|
412
|
+
function formatBooleanSearchParam(key, value) {
|
|
413
|
+
return value ? `${key}:1` : `${key}:`;
|
|
414
|
+
}
|
|
415
|
+
var HttpClient = class {
|
|
416
|
+
static async get(url, params, options) {
|
|
417
|
+
await ensureValidRefresh();
|
|
418
|
+
const response = await getAxiosInstance().get(url, { params, ...options || {} });
|
|
419
|
+
return response.data;
|
|
420
|
+
}
|
|
421
|
+
static async post(url, data, options) {
|
|
422
|
+
await ensureValidRefresh();
|
|
423
|
+
const response = await getAxiosInstance().post(url, data, options);
|
|
424
|
+
return response.data;
|
|
425
|
+
}
|
|
426
|
+
static async put(url, data) {
|
|
427
|
+
await ensureValidRefresh();
|
|
428
|
+
const response = await getAxiosInstance().put(url, data);
|
|
429
|
+
return response.data;
|
|
430
|
+
}
|
|
431
|
+
static async delete(url, config4) {
|
|
432
|
+
await ensureValidRefresh();
|
|
433
|
+
const response = await getAxiosInstance().delete(url, config4);
|
|
434
|
+
return response.data;
|
|
435
|
+
}
|
|
436
|
+
static formatSearchParams(params) {
|
|
437
|
+
return Object.entries(params).filter(([, value]) => Boolean(value)).map(
|
|
438
|
+
([k, v]) => ["type", "categories", "tags", "author", "manufacturer", "shops", "refund_reason"].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
|
|
439
|
+
).join(";");
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
var AuthHttpClient = class {
|
|
443
|
+
static async get(url, params) {
|
|
444
|
+
const response = await getAxiosInstance().get(url, { params });
|
|
445
|
+
return response.data;
|
|
446
|
+
}
|
|
447
|
+
static async post(url, data, options) {
|
|
448
|
+
const response = await getAxiosInstance().post(url, data, options);
|
|
449
|
+
return response.data;
|
|
450
|
+
}
|
|
451
|
+
static async put(url, data, options) {
|
|
452
|
+
const response = await getAxiosInstance().put(url, data, options);
|
|
453
|
+
return response.data;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
function getFormErrors(error) {
|
|
457
|
+
if (axios2.isAxiosError(error)) {
|
|
458
|
+
return error.response?.data?.message ?? null;
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
function getFieldErrors(error) {
|
|
463
|
+
if (axios2.isAxiosError(error)) {
|
|
464
|
+
return error.response?.data?.errors ?? null;
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
async function getAuthRefreshToken(refreshToken) {
|
|
469
|
+
if (refreshToken == null || refreshToken.trim() === "") {
|
|
470
|
+
return { token: null, success: false };
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
const headers = {};
|
|
474
|
+
if (config.devPortalId) {
|
|
475
|
+
headers["X-Dev-Portal-Id"] = config.devPortalId;
|
|
476
|
+
}
|
|
477
|
+
const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
|
|
478
|
+
const response = await getAxiosInstance().post(api_url, { refreshToken }, { headers });
|
|
479
|
+
const maybeData = response?.data?.data || response?.data;
|
|
480
|
+
const tokenData = maybeData?.tokenData || maybeData || {};
|
|
481
|
+
const newRefreshToken = tokenData?.refreshToken;
|
|
482
|
+
const token = tokenData?.token;
|
|
483
|
+
const expiresIn = tokenData?.expiresIn;
|
|
484
|
+
const rExpiresIn = tokenData?.refreshExpiresIn;
|
|
485
|
+
const rExpiresAt = tokenData?.refreshExpiresAt;
|
|
486
|
+
if (typeof newRefreshToken === "string") {
|
|
487
|
+
let rExpires = 0;
|
|
488
|
+
if (typeof rExpiresIn === "number") {
|
|
489
|
+
rExpires = Date.now() + rExpiresIn * 1e3;
|
|
490
|
+
} else if (typeof rExpiresAt === "number") {
|
|
491
|
+
rExpires = rExpiresAt * 1e3;
|
|
492
|
+
}
|
|
493
|
+
setRefreshToken(newRefreshToken, rExpires);
|
|
494
|
+
}
|
|
495
|
+
if (typeof token === "string") {
|
|
496
|
+
setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
|
|
497
|
+
return { token, success: true };
|
|
498
|
+
}
|
|
499
|
+
return { token: null, success: false };
|
|
500
|
+
} catch (error) {
|
|
501
|
+
notifyServiceUnavailable(error);
|
|
502
|
+
logger.error("auth", error, { operation: "token refresh" });
|
|
503
|
+
return { token: null, success: false };
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// src/main/features/navigation/breadcrumbs.ts
|
|
508
|
+
var getBreadcrumbs = () => {
|
|
509
|
+
const search = getParam("b");
|
|
510
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
511
|
+
if (!breadcrumbs && breadcrumbs.length < 1) return [];
|
|
512
|
+
const updated = breadcrumbs.map((breadcrumb, index) => {
|
|
513
|
+
return generatePath(breadcrumbs, breadcrumb, index);
|
|
514
|
+
});
|
|
515
|
+
if (updated.length < 1) {
|
|
516
|
+
const pathname = getPath();
|
|
517
|
+
const routeMenu = getRouteMenu(pathname);
|
|
518
|
+
return [
|
|
519
|
+
{
|
|
520
|
+
name: routeMenu?.title,
|
|
521
|
+
path: routeMenu?.path
|
|
522
|
+
}
|
|
523
|
+
];
|
|
524
|
+
}
|
|
525
|
+
return updated;
|
|
526
|
+
};
|
|
527
|
+
var getTableTitle = (componentName, title, ticketTableTitle) => {
|
|
528
|
+
const search = getParam("b");
|
|
529
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
530
|
+
if (breadcrumbs.length < 1) {
|
|
531
|
+
const pathname = getPath();
|
|
532
|
+
const routeMenu = getRouteMenu(pathname);
|
|
533
|
+
breadcrumbs = [
|
|
534
|
+
{
|
|
535
|
+
n: routeMenu?.title,
|
|
536
|
+
pt: routeMenu?.path
|
|
537
|
+
}
|
|
538
|
+
];
|
|
539
|
+
}
|
|
540
|
+
let associatedtableTitleSingular = "";
|
|
541
|
+
let tableTitle = "";
|
|
542
|
+
let singularTableTitle = "";
|
|
543
|
+
if (breadcrumbs && breadcrumbs.length > 0) {
|
|
544
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
545
|
+
const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
|
|
546
|
+
const previousItem = breadcrumbs[breadcrumbs.length - 2];
|
|
547
|
+
const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
|
|
548
|
+
const singularLastName = last?.name;
|
|
549
|
+
associatedtableTitleSingular = singularLastName;
|
|
550
|
+
if (componentName != "ticket") {
|
|
551
|
+
tableTitle = previous?.name ? { last, previous } : { last };
|
|
552
|
+
singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
|
|
553
|
+
} else {
|
|
554
|
+
const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
|
|
555
|
+
tableTitle = { last: { name: title } };
|
|
556
|
+
singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return { associatedtableTitleSingular, tableTitle, singularTableTitle };
|
|
560
|
+
};
|
|
561
|
+
var getFormTitle = (type, title, activeTab) => {
|
|
562
|
+
const search = getParam("b");
|
|
563
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
564
|
+
if (breadcrumbs.length < 1) {
|
|
565
|
+
const pathname = getPath();
|
|
566
|
+
const routeMenu = getRouteMenu(pathname);
|
|
567
|
+
breadcrumbs = [
|
|
568
|
+
{
|
|
569
|
+
n: routeMenu?.title,
|
|
570
|
+
pt: routeMenu?.path
|
|
571
|
+
}
|
|
572
|
+
];
|
|
573
|
+
}
|
|
574
|
+
let objectName = "";
|
|
575
|
+
let puralObjectName = "";
|
|
576
|
+
let dialogTitle = "";
|
|
577
|
+
if (breadcrumbs && breadcrumbs?.length > 0) {
|
|
578
|
+
const last = breadcrumbs[breadcrumbs?.length - 1];
|
|
579
|
+
const lastName = last?.n;
|
|
580
|
+
const mTitle = title;
|
|
581
|
+
if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
|
|
582
|
+
objectName = title;
|
|
583
|
+
puralObjectName = title;
|
|
584
|
+
dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
|
|
585
|
+
} else {
|
|
586
|
+
const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
|
|
587
|
+
objectName = singularLastName;
|
|
588
|
+
puralObjectName = lastName;
|
|
589
|
+
dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return { objectName, puralObjectName, dialogTitle };
|
|
593
|
+
};
|
|
594
|
+
var nameTrancate = (name) => {
|
|
595
|
+
return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/main/features/navigation/generate-url.ts
|
|
599
|
+
var makeLink = () => {
|
|
600
|
+
const search = getParam("b");
|
|
601
|
+
const makeLink2 = (props) => {
|
|
602
|
+
if (!search || "isPC" in props) {
|
|
603
|
+
return buildParentRoute(props);
|
|
604
|
+
} else {
|
|
605
|
+
const breadcrumbItems = decodeToBase64(search) || [];
|
|
606
|
+
return buildChildRoute(props, breadcrumbItems);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
return { makeLink: makeLink2 };
|
|
610
|
+
};
|
|
611
|
+
var buildParentRoute = (props) => {
|
|
612
|
+
const pathname = getPath();
|
|
613
|
+
const routeMenu = getRouteMenu(pathname);
|
|
614
|
+
const breadcrumbItems = [
|
|
615
|
+
{
|
|
616
|
+
n: routeMenu?.title,
|
|
617
|
+
o_t_id: routeMenu?.path,
|
|
618
|
+
isHome: props?.isHome || false
|
|
619
|
+
}
|
|
620
|
+
];
|
|
621
|
+
return buildChildRoute(props, breadcrumbItems);
|
|
622
|
+
};
|
|
623
|
+
var buildChildRoute = (props, breadcrumbItems) => {
|
|
624
|
+
const breadcrumbs = [...breadcrumbItems];
|
|
625
|
+
const breadcrumbType = breadcrumbStage(breadcrumbItems);
|
|
626
|
+
if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
|
|
627
|
+
const parent = {
|
|
628
|
+
n: props?.title || "",
|
|
629
|
+
o_t_id: props?.objectTypeId,
|
|
630
|
+
pt: `/association/${props?.objectTypeId}`,
|
|
631
|
+
isHome: props?.isHome || false,
|
|
632
|
+
prm: {
|
|
633
|
+
sort: "-hs_createdate",
|
|
634
|
+
s: "",
|
|
635
|
+
fPn: "hs_pipeline",
|
|
636
|
+
fO: "eq",
|
|
637
|
+
fV: "",
|
|
638
|
+
c: true,
|
|
639
|
+
isPC: props?.isPC,
|
|
640
|
+
v: "LIST",
|
|
641
|
+
l: "10",
|
|
642
|
+
p: 1
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
breadcrumbs.push(parent);
|
|
646
|
+
const newCrumb = {
|
|
647
|
+
n: props?.name,
|
|
648
|
+
o_t_id: props?.objectTypeId,
|
|
649
|
+
o_r_id: props?.recordId
|
|
650
|
+
};
|
|
651
|
+
breadcrumbs.push(newCrumb);
|
|
652
|
+
} else if (breadcrumbType === "root") {
|
|
653
|
+
const newCrumb = {
|
|
654
|
+
n: props?.name,
|
|
655
|
+
o_t_id: props?.objectTypeId,
|
|
656
|
+
o_r_id: props?.recordId
|
|
657
|
+
};
|
|
658
|
+
if (props?.isPC) {
|
|
659
|
+
newCrumb.prm = {
|
|
660
|
+
isPC: props?.isPC
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
breadcrumbs.push(newCrumb);
|
|
664
|
+
} else {
|
|
665
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
666
|
+
if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
|
|
667
|
+
!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
|
|
668
|
+
props?.isHome && !isMessingParentLastItem(breadcrumbItems)) {
|
|
669
|
+
const newCrumb = {
|
|
670
|
+
n: props?.name,
|
|
671
|
+
o_t_id: props?.objectTypeId,
|
|
672
|
+
o_r_id: props?.recordId
|
|
673
|
+
};
|
|
674
|
+
if (props?.isPC) {
|
|
675
|
+
newCrumb.prm = {
|
|
676
|
+
isPC: props?.isPC
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
breadcrumbs.push(newCrumb);
|
|
680
|
+
} else {
|
|
681
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
|
|
682
|
+
const parent = {
|
|
683
|
+
n: props?.associationLabel || props?.name,
|
|
684
|
+
o_t_id: props?.objectTypeId
|
|
685
|
+
};
|
|
686
|
+
if (props?.tableParam) {
|
|
687
|
+
parent.prm = props?.tableParam;
|
|
688
|
+
}
|
|
689
|
+
if (props?.defPermissions) {
|
|
690
|
+
parent.dp = props?.defPermissions;
|
|
691
|
+
}
|
|
692
|
+
if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
|
|
693
|
+
breadcrumbs.push(parent);
|
|
694
|
+
}
|
|
695
|
+
if (props?.recordId) {
|
|
696
|
+
const newCrumb = {
|
|
697
|
+
n: props?.name,
|
|
698
|
+
o_t_id: props?.objectTypeId,
|
|
699
|
+
o_r_id: props?.recordId
|
|
700
|
+
};
|
|
701
|
+
if (props?.isPC) {
|
|
702
|
+
newCrumb.prm = {
|
|
703
|
+
isPC: props?.isPC
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
breadcrumbs.push(newCrumb);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return generateUrl(props, breadcrumbs);
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// src/main/api/navigation-api.ts
|
|
714
|
+
var navigationApi = {
|
|
715
|
+
url: {
|
|
716
|
+
makeLink,
|
|
717
|
+
updateLink
|
|
718
|
+
},
|
|
719
|
+
route: {
|
|
720
|
+
getDetails: getRouteDetails,
|
|
721
|
+
getParamDetails
|
|
722
|
+
},
|
|
723
|
+
breadcrumbs: {
|
|
724
|
+
getList: getBreadcrumbs,
|
|
725
|
+
getTableTitle,
|
|
726
|
+
getFormTitle
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// src/main/core/utils/cache/builders.ts
|
|
731
|
+
function buildCrmListPurgeTarget(objectTypeId, listQuery, recordIds) {
|
|
732
|
+
const target = {
|
|
733
|
+
domain: "crm_object_data",
|
|
734
|
+
objectTypeId,
|
|
735
|
+
views: ["list"],
|
|
736
|
+
listQuery: listQuery ?? { page: 1, limit: 10, view: "LIST" }
|
|
737
|
+
};
|
|
738
|
+
if (recordIds?.length) {
|
|
739
|
+
target.recordIds = recordIds;
|
|
740
|
+
}
|
|
741
|
+
return target;
|
|
742
|
+
}
|
|
743
|
+
function buildCrmSinglePurgeTarget(objectTypeId, recordIds, listQuery) {
|
|
744
|
+
return {
|
|
745
|
+
domain: "crm_object_data",
|
|
746
|
+
objectTypeId,
|
|
747
|
+
views: ["single"],
|
|
748
|
+
recordIds,
|
|
749
|
+
listQuery
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function buildEngagementPurgeTarget(objectTypeId, recordIds, views, options) {
|
|
753
|
+
if (!recordIds.length) {
|
|
754
|
+
throw new Error("recordIds is required for engagement purge views");
|
|
755
|
+
}
|
|
756
|
+
const target = {
|
|
757
|
+
domain: "crm_object_data",
|
|
758
|
+
objectTypeId,
|
|
759
|
+
recordIds,
|
|
760
|
+
views,
|
|
761
|
+
fileIds: options?.fileIds,
|
|
762
|
+
listQuery: options?.listQuery ?? { page: 1, limit: 10 }
|
|
763
|
+
};
|
|
764
|
+
if (options?.engagementItemIds?.length) {
|
|
765
|
+
target.engagementItemIds = options.engagementItemIds;
|
|
766
|
+
}
|
|
767
|
+
return target;
|
|
768
|
+
}
|
|
769
|
+
function buildUserSessionPurgeTarget() {
|
|
770
|
+
return { domain: "user_session" };
|
|
771
|
+
}
|
|
772
|
+
function buildPortalConfigPurgeTarget(objectTypeIds) {
|
|
773
|
+
return {
|
|
774
|
+
domain: "portal_object_config",
|
|
775
|
+
objectTypeIds
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function mergePurgeTargets(...targets) {
|
|
779
|
+
return targets;
|
|
780
|
+
}
|
|
781
|
+
function buildCachePurgeRequest(targets, options) {
|
|
782
|
+
const request = {
|
|
783
|
+
mode: options?.mode ?? "soft",
|
|
784
|
+
warm: options?.warm ?? true,
|
|
785
|
+
includeContactAccess: options?.includeContactAccess ?? true,
|
|
786
|
+
includeShortOnHard: options?.includeShortOnHard ?? false,
|
|
787
|
+
confirmPortalWide: options?.confirmPortalWide ?? false,
|
|
788
|
+
targets
|
|
789
|
+
};
|
|
790
|
+
if (options?.postCrmWrite) {
|
|
791
|
+
request.postCrmWrite = true;
|
|
792
|
+
}
|
|
793
|
+
if (options?.warmListDelayMs != null) {
|
|
794
|
+
request.warmListDelayMs = options.warmListDelayMs;
|
|
795
|
+
}
|
|
796
|
+
return request;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// src/main/core/http/auth-headers.ts
|
|
800
|
+
function devPortalHeaders() {
|
|
801
|
+
if (!config?.devPortalId) {
|
|
802
|
+
return void 0;
|
|
803
|
+
}
|
|
804
|
+
return { "X-Dev-Portal-Id": config.devPortalId };
|
|
805
|
+
}
|
|
806
|
+
function mergeRequestOptions(token, extraHeaders) {
|
|
807
|
+
const bearerToken = token || getAccessToken();
|
|
808
|
+
const headers = { ...extraHeaders };
|
|
809
|
+
if (bearerToken) {
|
|
810
|
+
headers.Authorization = `Bearer ${bearerToken}`;
|
|
811
|
+
}
|
|
812
|
+
const devHeaders = devPortalHeaders();
|
|
813
|
+
if (devHeaders) {
|
|
814
|
+
Object.assign(headers, devHeaders);
|
|
815
|
+
}
|
|
816
|
+
return Object.keys(headers).length > 0 ? { headers } : void 0;
|
|
817
|
+
}
|
|
818
|
+
function hubIdQuery() {
|
|
819
|
+
return config.hubId ? { hubId: config.hubId } : null;
|
|
820
|
+
}
|
|
821
|
+
function portalIdQuery(portalId) {
|
|
822
|
+
const id = portalId ?? config.portalId ?? config.devPortalId;
|
|
823
|
+
if (id === null || id === void 0 || id === "") {
|
|
824
|
+
return void 0;
|
|
825
|
+
}
|
|
826
|
+
return { portalId: String(id) };
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// src/main/features/auth/client/mfa-client.ts
|
|
830
|
+
var mfaPortalQuery = (portalId) => portalIdQuery(portalId) ?? null;
|
|
831
|
+
var mfaClient = {
|
|
832
|
+
verifyOtp: (data) => AuthHttpClient.post(generateApiUrl({ route: API_ENDPOINTS.VERIFY_OTP, queryParams: hubIdQuery() }), data, mergeRequestOptions(data.token)),
|
|
833
|
+
sendPendingOtp: (data) => AuthHttpClient.post(API_ENDPOINTS.MFA_PENDING_OTP_SEND, data, mergeRequestOptions(data.token)),
|
|
834
|
+
pendingPasskeyOptions: (data) => AuthHttpClient.post(API_ENDPOINTS.MFA_PENDING_PASSKEY_OPTIONS, data, mergeRequestOptions(data.token)),
|
|
835
|
+
pendingPasskeyVerify: (data) => AuthHttpClient.post(
|
|
836
|
+
generateApiUrl({ route: API_ENDPOINTS.MFA_PENDING_PASSKEY_VERIFY, queryParams: hubIdQuery() }),
|
|
837
|
+
data,
|
|
838
|
+
mergeRequestOptions(data.token)
|
|
839
|
+
),
|
|
840
|
+
getStatus: (query) => HttpClient.get(
|
|
841
|
+
generateApiUrl({
|
|
842
|
+
route: API_ENDPOINTS.MFA_STATUS,
|
|
843
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
844
|
+
})
|
|
845
|
+
),
|
|
846
|
+
setPreferences: (data, query) => HttpClient.put(
|
|
847
|
+
generateApiUrl({
|
|
848
|
+
route: API_ENDPOINTS.MFA_PREFERENCES,
|
|
849
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
850
|
+
}),
|
|
851
|
+
data
|
|
852
|
+
),
|
|
853
|
+
startPhoneVerify: (data) => HttpClient.post(API_ENDPOINTS.MFA_PHONE_VERIFY_START, data),
|
|
854
|
+
confirmPhoneVerify: (data) => HttpClient.post(API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM, data),
|
|
855
|
+
totpEnrollStart: (query) => HttpClient.post(
|
|
856
|
+
generateApiUrl({
|
|
857
|
+
route: API_ENDPOINTS.MFA_TOTP_ENROLL_START,
|
|
858
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
859
|
+
}),
|
|
860
|
+
null
|
|
861
|
+
),
|
|
862
|
+
totpEnrollVerify: (data) => HttpClient.post(
|
|
863
|
+
generateApiUrl({
|
|
864
|
+
route: API_ENDPOINTS.MFA_TOTP_ENROLL_VERIFY,
|
|
865
|
+
queryParams: mfaPortalQuery(data.portalId)
|
|
866
|
+
}),
|
|
867
|
+
data
|
|
868
|
+
),
|
|
869
|
+
totpDisable: (data) => HttpClient.post(API_ENDPOINTS.MFA_TOTP_DISABLE, data),
|
|
870
|
+
webauthnRegisterOptions: (query) => HttpClient.post(
|
|
871
|
+
generateApiUrl({
|
|
872
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
|
|
873
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
874
|
+
}),
|
|
875
|
+
null,
|
|
876
|
+
mergeRequestOptions(void 0)
|
|
877
|
+
),
|
|
878
|
+
webauthnRegisterVerify: (data) => HttpClient.post(
|
|
879
|
+
generateApiUrl({
|
|
880
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_VERIFY,
|
|
881
|
+
queryParams: mfaPortalQuery(data.portalId)
|
|
882
|
+
}),
|
|
883
|
+
data
|
|
884
|
+
),
|
|
885
|
+
webauthnAuthOptions: (query) => HttpClient.post(
|
|
886
|
+
generateApiUrl({
|
|
887
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_AUTH_OPTIONS,
|
|
888
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
889
|
+
}),
|
|
890
|
+
null
|
|
891
|
+
),
|
|
892
|
+
webauthnAuthVerify: (data) => HttpClient.post(
|
|
893
|
+
generateApiUrl({
|
|
894
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_AUTH_VERIFY,
|
|
895
|
+
queryParams: mfaPortalQuery(data.portalId)
|
|
896
|
+
}),
|
|
897
|
+
data
|
|
898
|
+
),
|
|
899
|
+
listWebauthnCredentials: (query) => HttpClient.get(
|
|
900
|
+
generateApiUrl({
|
|
901
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIALS,
|
|
902
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
903
|
+
})
|
|
904
|
+
),
|
|
905
|
+
deleteWebauthnCredential: (credentialRecordId, query) => HttpClient.delete(
|
|
906
|
+
generateApiUrl({
|
|
907
|
+
route: API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIAL_DELETE,
|
|
908
|
+
params: { credentialRecordId: String(credentialRecordId) },
|
|
909
|
+
queryParams: mfaPortalQuery(query?.portalId)
|
|
910
|
+
})
|
|
911
|
+
),
|
|
912
|
+
passkeyLoginOptions: (data) => AuthHttpClient.post(
|
|
913
|
+
generateApiUrl({ route: API_ENDPOINTS.PASSKEY_LOGIN_OPTIONS, queryParams: hubIdQuery() }),
|
|
914
|
+
data,
|
|
915
|
+
mergeRequestOptions(void 0)
|
|
916
|
+
),
|
|
917
|
+
passkeyLoginVerify: (data) => AuthHttpClient.post(
|
|
918
|
+
generateApiUrl({ route: API_ENDPOINTS.PASSKEY_LOGIN_VERIFY, queryParams: hubIdQuery() }),
|
|
919
|
+
data,
|
|
920
|
+
mergeRequestOptions(void 0)
|
|
921
|
+
)
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
// src/main/state/crm/use-file.ts
|
|
925
|
+
var fileStore = createStore({
|
|
926
|
+
queryParams: null
|
|
927
|
+
});
|
|
928
|
+
var actions4 = {
|
|
929
|
+
/** Called from Client.file.list — feeds purgeEngagementCaches (view: files). */
|
|
930
|
+
setListQueryParams(params) {
|
|
931
|
+
fileStore.setState({
|
|
932
|
+
queryParams: params
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
// src/main/core/utils/cache/crmCacheRefresh.ts
|
|
938
|
+
async function purgeCrmObjectDataCache(options) {
|
|
939
|
+
const result = await purgeCrmListCache(options);
|
|
940
|
+
return result.ok;
|
|
941
|
+
}
|
|
942
|
+
async function purgeCrmListCacheAfterCrmWrite(options) {
|
|
943
|
+
return purgeCrmListCache({
|
|
944
|
+
...options,
|
|
945
|
+
postCrmWrite: true
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
async function purgeCrmDetailAndListAfterCrmWrite(options) {
|
|
949
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
950
|
+
if (!objectTypeId || !options.recordIds?.length) {
|
|
951
|
+
return {
|
|
952
|
+
ok: false,
|
|
953
|
+
errorCode: "VALIDATION",
|
|
954
|
+
message: "objectTypeId and recordIds are required"
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
return purgeCrmCombined({
|
|
958
|
+
...options,
|
|
959
|
+
postCrmWrite: true,
|
|
960
|
+
targets: mergePurgeTargets(
|
|
961
|
+
buildCrmListPurgeTarget(objectTypeId, options.listQuery, options.recordIds),
|
|
962
|
+
buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery)
|
|
963
|
+
)
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
async function purgeCrmListCache(options) {
|
|
967
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
968
|
+
if (!objectTypeId) {
|
|
969
|
+
return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
|
|
970
|
+
}
|
|
971
|
+
const target = buildCrmListPurgeTarget(objectTypeId, options.listQuery, options.recordIds);
|
|
972
|
+
const request = buildCachePurgeRequest([target], {
|
|
973
|
+
mode: options.mode,
|
|
974
|
+
warm: options.warm,
|
|
975
|
+
postCrmWrite: options.postCrmWrite,
|
|
976
|
+
warmListDelayMs: options.warmListDelayMs
|
|
977
|
+
});
|
|
978
|
+
return createCachePurgeJob(request, {
|
|
979
|
+
idempotencyKey: options.idempotencyKey,
|
|
980
|
+
waitForWarm: options.waitForWarm
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
async function purgeCrmRecordCache(options) {
|
|
984
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
985
|
+
if (!objectTypeId || !options.recordIds?.length) {
|
|
986
|
+
return {
|
|
987
|
+
ok: false,
|
|
988
|
+
errorCode: "VALIDATION",
|
|
989
|
+
message: "objectTypeId and recordIds are required"
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
const target = buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery);
|
|
993
|
+
const request = buildCachePurgeRequest([target], {
|
|
994
|
+
mode: options.mode,
|
|
995
|
+
warm: options.warm,
|
|
996
|
+
postCrmWrite: options.postCrmWrite,
|
|
997
|
+
warmListDelayMs: options.warmListDelayMs
|
|
998
|
+
});
|
|
999
|
+
return createCachePurgeJob(request, {
|
|
1000
|
+
idempotencyKey: options.idempotencyKey,
|
|
1001
|
+
waitForWarm: options.waitForWarm
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
async function purgeEngagementCaches(options) {
|
|
1005
|
+
return purgeEngagementCachesInternal(options);
|
|
1006
|
+
}
|
|
1007
|
+
async function purgeEngagementCachesAfterCrmWrite(options) {
|
|
1008
|
+
return purgeEngagementCachesInternal({
|
|
1009
|
+
...options,
|
|
1010
|
+
postCrmWrite: true
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
async function purgeEngagementCachesInternal(options) {
|
|
1014
|
+
const objectTypeId = options.objectTypeId?.trim();
|
|
1015
|
+
if (!objectTypeId || !options.recordIds?.length || !options.views?.length) {
|
|
1016
|
+
return {
|
|
1017
|
+
ok: false,
|
|
1018
|
+
errorCode: "VALIDATION",
|
|
1019
|
+
message: "objectTypeId, recordIds, and views are required"
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
const target = buildEngagementPurgeTarget(objectTypeId, options.recordIds, options.views, {
|
|
1023
|
+
fileIds: options.fileIds,
|
|
1024
|
+
listQuery: options.listQuery,
|
|
1025
|
+
engagementItemIds: options.engagementItemIds
|
|
1026
|
+
});
|
|
1027
|
+
const request = buildCachePurgeRequest([target], {
|
|
1028
|
+
mode: options.mode,
|
|
1029
|
+
warm: options.warm,
|
|
1030
|
+
postCrmWrite: options.postCrmWrite,
|
|
1031
|
+
warmListDelayMs: options.warmListDelayMs
|
|
1032
|
+
});
|
|
1033
|
+
return createCachePurgeJob(request, {
|
|
1034
|
+
idempotencyKey: options.idempotencyKey,
|
|
1035
|
+
waitForWarm: options.waitForWarm
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
async function purgeCrmCombined(options) {
|
|
1039
|
+
const request = buildCachePurgeRequest(options.targets, {
|
|
1040
|
+
mode: options.mode,
|
|
1041
|
+
warm: options.warm,
|
|
1042
|
+
postCrmWrite: options.postCrmWrite,
|
|
1043
|
+
warmListDelayMs: options.warmListDelayMs
|
|
1044
|
+
});
|
|
1045
|
+
return createCachePurgeJob(request, {
|
|
1046
|
+
idempotencyKey: options.idempotencyKey,
|
|
1047
|
+
waitForWarm: options.waitForWarm
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/main/core/utils/cache/extractHubspotRecordIdFromWriteResponse.ts
|
|
1052
|
+
function extractHubspotRecordIdFromWriteResponse(response) {
|
|
1053
|
+
if (response == null || typeof response !== "object") {
|
|
1054
|
+
return void 0;
|
|
1055
|
+
}
|
|
1056
|
+
const root = response;
|
|
1057
|
+
const data = root.data;
|
|
1058
|
+
if (data != null && typeof data === "object") {
|
|
1059
|
+
const fromData = idFromRecordPayload(data);
|
|
1060
|
+
if (fromData) {
|
|
1061
|
+
return fromData;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
return idFromRecordPayload(root);
|
|
1065
|
+
}
|
|
1066
|
+
function idFromRecordPayload(payload) {
|
|
1067
|
+
const id = payload.id;
|
|
1068
|
+
if (id !== void 0 && id !== null && String(id).length > 0) {
|
|
1069
|
+
return String(id);
|
|
1070
|
+
}
|
|
1071
|
+
const hsObjectId = payload.hs_object_id;
|
|
1072
|
+
if (hsObjectId !== void 0 && hsObjectId !== null && String(hsObjectId).length > 0) {
|
|
1073
|
+
return String(hsObjectId);
|
|
1074
|
+
}
|
|
1075
|
+
return void 0;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// src/main/core/utils/cache/extractEngagementItemIdFromWriteResponse.ts
|
|
1079
|
+
function extractEngagementItemIdFromWriteResponse(response) {
|
|
1080
|
+
if (response == null || typeof response !== "object") {
|
|
1081
|
+
return void 0;
|
|
1082
|
+
}
|
|
1083
|
+
const root = response;
|
|
1084
|
+
const candidates = [];
|
|
1085
|
+
const data = root.data;
|
|
1086
|
+
if (data != null && typeof data === "object") {
|
|
1087
|
+
const dataObj = data;
|
|
1088
|
+
candidates.push(dataObj);
|
|
1089
|
+
const nested = dataObj.response;
|
|
1090
|
+
if (nested != null && typeof nested === "object") {
|
|
1091
|
+
candidates.push(nested);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
const topResponse = root.response;
|
|
1095
|
+
if (topResponse != null && typeof topResponse === "object") {
|
|
1096
|
+
candidates.push(topResponse);
|
|
1097
|
+
}
|
|
1098
|
+
candidates.push(root);
|
|
1099
|
+
for (const payload of candidates) {
|
|
1100
|
+
const id = engagementIdFromPayload(payload);
|
|
1101
|
+
if (id) {
|
|
1102
|
+
return id;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return void 0;
|
|
1106
|
+
}
|
|
1107
|
+
function engagementIdFromPayload(payload) {
|
|
1108
|
+
const fromHs = fieldValue(payload.hs_object_id);
|
|
1109
|
+
if (fromHs) {
|
|
1110
|
+
return fromHs;
|
|
1111
|
+
}
|
|
1112
|
+
const fromId = fieldValue(payload.id);
|
|
1113
|
+
if (fromId) {
|
|
1114
|
+
return fromId;
|
|
1115
|
+
}
|
|
1116
|
+
return void 0;
|
|
1117
|
+
}
|
|
1118
|
+
function fieldValue(raw) {
|
|
1119
|
+
if (raw == null) {
|
|
1120
|
+
return void 0;
|
|
1121
|
+
}
|
|
1122
|
+
if (typeof raw === "object") {
|
|
1123
|
+
const value = raw.value;
|
|
1124
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
1125
|
+
return String(value);
|
|
1126
|
+
}
|
|
1127
|
+
return void 0;
|
|
1128
|
+
}
|
|
1129
|
+
const s = String(raw);
|
|
1130
|
+
return s.length > 0 ? s : void 0;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
|
|
1134
|
+
var LIST_QUERY_KEYS = [
|
|
1135
|
+
"sort",
|
|
1136
|
+
"search",
|
|
1137
|
+
"filterPropertyName",
|
|
1138
|
+
"filterOperator",
|
|
1139
|
+
"filterValue",
|
|
1140
|
+
"page",
|
|
1141
|
+
"limit",
|
|
1142
|
+
"view",
|
|
1143
|
+
"mediatorObjectTypeId",
|
|
1144
|
+
"mediatorObjectRecordId",
|
|
1145
|
+
"parentObjectTypeId",
|
|
1146
|
+
"parentObjectRecordId",
|
|
1147
|
+
"stageId",
|
|
1148
|
+
"after"
|
|
1149
|
+
];
|
|
1150
|
+
function toCachePurgeListQuery(raw) {
|
|
1151
|
+
if (!raw || typeof raw !== "object") {
|
|
1152
|
+
return { page: 1, limit: 10, view: "LIST" };
|
|
1153
|
+
}
|
|
1154
|
+
const q = {};
|
|
1155
|
+
for (const key of LIST_QUERY_KEYS) {
|
|
1156
|
+
const value = raw[key];
|
|
1157
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
1158
|
+
q[key] = String(value);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (raw.page !== void 0 && raw.page !== null) {
|
|
1162
|
+
const page = Number(raw.page);
|
|
1163
|
+
if (!Number.isNaN(page) && page > 0) {
|
|
1164
|
+
q.page = page;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
if (raw.limit !== void 0 && raw.limit !== null) {
|
|
1168
|
+
const limit = Number(raw.limit);
|
|
1169
|
+
if (!Number.isNaN(limit) && limit > 0) {
|
|
1170
|
+
q.limit = limit;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
const isPc = raw.isPrimaryCompany ?? raw.isPC;
|
|
1174
|
+
if (isPc !== void 0 && isPc !== null) {
|
|
1175
|
+
q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
|
|
1176
|
+
}
|
|
1177
|
+
const view = raw.view;
|
|
1178
|
+
if (typeof view === "string") {
|
|
1179
|
+
q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
|
|
1180
|
+
}
|
|
1181
|
+
if (Object.keys(q).length === 0) {
|
|
1182
|
+
return { page: 1, limit: 10, view: "LIST" };
|
|
1183
|
+
}
|
|
1184
|
+
if (q.page === void 0) {
|
|
1185
|
+
q.page = 1;
|
|
1186
|
+
}
|
|
1187
|
+
if (q.limit === void 0) {
|
|
1188
|
+
q.limit = 10;
|
|
1189
|
+
}
|
|
1190
|
+
if (q.view === void 0) {
|
|
1191
|
+
q.view = "LIST";
|
|
1192
|
+
}
|
|
1193
|
+
return q;
|
|
1194
|
+
}
|
|
1195
|
+
function resolveCrmListPurgeQuery(options) {
|
|
1196
|
+
let raw;
|
|
1197
|
+
if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
|
|
1198
|
+
raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
|
|
1199
|
+
} else {
|
|
1200
|
+
raw = options.tableQueryParams ?? null;
|
|
1201
|
+
}
|
|
1202
|
+
const base = toCachePurgeListQuery(raw ?? void 0);
|
|
1203
|
+
if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
|
|
1204
|
+
return base;
|
|
1205
|
+
}
|
|
1206
|
+
return {
|
|
1207
|
+
...base,
|
|
1208
|
+
...options.writeContext
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// src/main/core/http/client-context.ts
|
|
1213
|
+
function getParamDetails2(...args) {
|
|
1214
|
+
return navigationApi.route.getParamDetails(...args);
|
|
1215
|
+
}
|
|
1216
|
+
var recordWriteContext = (paramsObject) => {
|
|
1217
|
+
if (!paramsObject) {
|
|
1218
|
+
return void 0;
|
|
1219
|
+
}
|
|
1220
|
+
const context = {};
|
|
1221
|
+
const keys = ["parentObjectTypeId", "parentObjectRecordId", "mediatorObjectTypeId", "mediatorObjectRecordId"];
|
|
1222
|
+
keys.forEach((key) => {
|
|
1223
|
+
const value = paramsObject[key];
|
|
1224
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
1225
|
+
context[key] = String(value);
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
1229
|
+
};
|
|
1230
|
+
var triggerPostWriteListPurge = (props) => {
|
|
1231
|
+
const objectTypeId = props.hubspotObjectTypeId;
|
|
1232
|
+
if (!objectTypeId) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const { queryParams, multiObjectsQueryParams } = tableStore.getState();
|
|
1236
|
+
const listQuery = resolveCrmListPurgeQuery({
|
|
1237
|
+
componentName: props.componentName,
|
|
1238
|
+
hubspotObjectTypeId: objectTypeId,
|
|
1239
|
+
tableQueryParams: queryParams,
|
|
1240
|
+
multiObjectsQueryParams,
|
|
1241
|
+
writeContext: recordWriteContext(props.paramsObject)
|
|
1242
|
+
});
|
|
1243
|
+
const recordIds = props.recordId ? [String(props.recordId)] : void 0;
|
|
1244
|
+
purgeCrmListCacheAfterCrmWrite({
|
|
1245
|
+
objectTypeId: String(objectTypeId),
|
|
1246
|
+
listQuery,
|
|
1247
|
+
recordIds
|
|
1248
|
+
});
|
|
1249
|
+
};
|
|
1250
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
1251
|
+
const base = { ...payload || {} };
|
|
1252
|
+
const context = recordWriteContext(paramsObject);
|
|
1253
|
+
if (context) {
|
|
1254
|
+
base.context = context;
|
|
1255
|
+
}
|
|
1256
|
+
if (options && Object.keys(options).length > 0) {
|
|
1257
|
+
base.options = options;
|
|
1258
|
+
}
|
|
1259
|
+
return base;
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
// src/main/features/auth/client/authentication-client.ts
|
|
1263
|
+
var authenticationClient = {
|
|
1264
|
+
authentication: {
|
|
1265
|
+
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
1266
|
+
login: (data) => {
|
|
1267
|
+
const queryParams = config.hubId ? { hubId: config.hubId } : null;
|
|
1268
|
+
return AuthHttpClient.post(
|
|
1269
|
+
generateApiUrl({ route: API_ENDPOINTS.LOGIN, queryParams }),
|
|
1270
|
+
data,
|
|
1271
|
+
config?.devPortalId && {
|
|
1272
|
+
headers: {
|
|
1273
|
+
"X-Dev-Portal-Id": config.devPortalId
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
);
|
|
1277
|
+
},
|
|
1278
|
+
verifyOtp: (data) => mfaClient.verifyOtp(data),
|
|
1279
|
+
verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
|
|
1280
|
+
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
1281
|
+
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
1282
|
+
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
1283
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
1284
|
+
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
|
|
1285
|
+
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
1286
|
+
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null),
|
|
1287
|
+
clientSession: (payload) => AuthHttpClient.post(
|
|
1288
|
+
API_ENDPOINTS.CLIENT_SESSION,
|
|
1289
|
+
{ refreshToken: payload.refreshToken ?? payload.accessToken },
|
|
1290
|
+
{
|
|
1291
|
+
headers: {
|
|
1292
|
+
Authorization: `Bearer ${payload.accessToken}`
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
},
|
|
1297
|
+
sso: {
|
|
1298
|
+
getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
|
|
1299
|
+
generateSsoUrl: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_URL, queryParams: payload?.queryParams })),
|
|
1300
|
+
ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
|
|
1301
|
+
},
|
|
1302
|
+
user: {
|
|
1303
|
+
me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
|
|
1304
|
+
profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
|
|
1305
|
+
profileUpdate: (props) => HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), props?.payload || {}),
|
|
1306
|
+
changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// src/main/features/crm/client/crm-client.ts
|
|
1311
|
+
var crmClient = {
|
|
1312
|
+
pipeline: {
|
|
1313
|
+
list: (payload = null, param = null) => {
|
|
1314
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
1315
|
+
const { paramsObject } = getParamDetails2({ type: payload?.componentName });
|
|
1316
|
+
const userData = userStore.getState().profile;
|
|
1317
|
+
const apiParams = {};
|
|
1318
|
+
if (paramsObject?.parentObjectTypeId) {
|
|
1319
|
+
apiParams.parentObjectTypeId = paramsObject?.parentObjectTypeId;
|
|
1320
|
+
} else if (payload?.isHome && userData?.crmProfile?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
1321
|
+
apiParams.parentObjectTypeId = userData?.crmProfile?.info?.objectTypeId;
|
|
1322
|
+
} else if (payload?.isHome && userData?.crmProfile?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
1323
|
+
apiParams.parentObjectTypeId = "0-2";
|
|
1324
|
+
}
|
|
1325
|
+
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
1326
|
+
apiParams.cache = payload?.cache;
|
|
1327
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
1328
|
+
return HttpClient.get(apiUrl);
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
stage: {
|
|
1332
|
+
list: (props = null) => {
|
|
1333
|
+
const params = {
|
|
1334
|
+
// hubId: config.hubId,
|
|
1335
|
+
// portalId: portalId,
|
|
1336
|
+
objectTypeId: props?.params?.objectTypeId,
|
|
1337
|
+
pipelineId: props?.params?.pipelineId
|
|
1338
|
+
};
|
|
1339
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
|
|
1340
|
+
return HttpClient.get(apiUrl);
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1343
|
+
object: {
|
|
1344
|
+
list: async (payload = null, param = null) => {
|
|
1345
|
+
const { setObjectsQueryParams } = actions2;
|
|
1346
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
1347
|
+
const { updateLink: updateLink2, getLinkParams } = updateLink();
|
|
1348
|
+
const { paramsObject, parentAccessLabel } = getParamDetails2({ type: payload?.componentName });
|
|
1349
|
+
const userData = userStore.getState().profile;
|
|
1350
|
+
const pipeline = payload?.variables?.pipeline;
|
|
1351
|
+
const mPipelines = payload?.variables?.mPipelines;
|
|
1352
|
+
const mSelectedPipeline = pipeline !== void 0 ? pipeline : payload?.selectedPipeline;
|
|
1353
|
+
if (mSelectedPipeline) {
|
|
1354
|
+
param.filterValue = mSelectedPipeline;
|
|
1355
|
+
} else if (payload?.specPipeLine && payload?.pipeLineId) {
|
|
1356
|
+
param.filterValue = payload?.pipeLineId;
|
|
1357
|
+
} else if (payload?.hubspotObjectTypeId != "0-3" || payload?.hubspotObjectTypeId != "0-5") {
|
|
1358
|
+
param.filterValue = "";
|
|
1359
|
+
}
|
|
1360
|
+
const fParams = getLinkParams();
|
|
1361
|
+
param = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : param, ...paramsObject };
|
|
1362
|
+
if (!payload?.isFristTimeLoadData || !fParams) {
|
|
1363
|
+
await updateLink2({
|
|
1364
|
+
sort: param?.sort,
|
|
1365
|
+
s: param?.search,
|
|
1366
|
+
fPn: param?.filterPropertyName,
|
|
1367
|
+
fO: param?.filterOperator,
|
|
1368
|
+
fV: param?.filterValue,
|
|
1369
|
+
// "c": param?.cache,
|
|
1370
|
+
isPC: param?.isPrimaryCompany,
|
|
1371
|
+
v: param?.view,
|
|
1372
|
+
l: param?.limit,
|
|
1373
|
+
p: param?.page,
|
|
1374
|
+
a: param?.after
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
|
|
1378
|
+
param.filterValue = "";
|
|
1379
|
+
await updateLink2({
|
|
1380
|
+
fV: param?.filterValue
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
|
|
1384
|
+
param.filterValue = mPipelines[0].pipelineId;
|
|
1385
|
+
await updateLink2({
|
|
1386
|
+
fV: param?.filterValue
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
if (payload?.isHome || payload?.hubspotObjectTypeId === "0-5" && payload?.componentName === "object") {
|
|
1390
|
+
let parentObjectTypeId = "";
|
|
1391
|
+
if (userData?.crmProfile?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
1392
|
+
parentObjectTypeId = userData?.crmProfile?.info?.objectTypeId;
|
|
1393
|
+
} else if (userData?.crmProfile?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
1394
|
+
parentObjectTypeId = "0-2";
|
|
1395
|
+
}
|
|
1396
|
+
param.parentObjectTypeId = parentObjectTypeId;
|
|
1397
|
+
}
|
|
1398
|
+
param.parentAccessLabel = parentAccessLabel;
|
|
1399
|
+
setObjectsQueryParams(param);
|
|
1400
|
+
param.cache = payload?.cache;
|
|
1401
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
1402
|
+
return HttpClient.get(apiUrl);
|
|
1403
|
+
},
|
|
1404
|
+
sideBarList: async (payload = null) => {
|
|
1405
|
+
const { setMultiObjectsQueryParams } = actions2;
|
|
1406
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
1407
|
+
const params = { hubspotObjectTypeId };
|
|
1408
|
+
const queryParams = payload.param;
|
|
1409
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
|
|
1410
|
+
setMultiObjectsQueryParams(hubspotObjectTypeId, queryParams ?? {});
|
|
1411
|
+
return HttpClient.get(apiUrl);
|
|
1412
|
+
},
|
|
1413
|
+
form: (payload = null) => {
|
|
1414
|
+
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
1415
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
1416
|
+
return HttpClient.get(apiUrl);
|
|
1417
|
+
},
|
|
1418
|
+
objectFormOptions: (payload = null) => {
|
|
1419
|
+
const params = {
|
|
1420
|
+
formId: payload?.formId,
|
|
1421
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
1422
|
+
};
|
|
1423
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
1424
|
+
return HttpClient.get(apiUrl);
|
|
1425
|
+
},
|
|
1426
|
+
create: async (props = null) => {
|
|
1427
|
+
const { paramsObject } = getParamDetails2({ type: props?.componentName });
|
|
1428
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
1429
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, {
|
|
1430
|
+
cardParentMerge,
|
|
1431
|
+
addAnother: props?.params?.addAnother
|
|
1432
|
+
});
|
|
1433
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
1434
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
1435
|
+
const response = await HttpClient.post(apiUrl, body);
|
|
1436
|
+
triggerPostWriteListPurge({
|
|
1437
|
+
hubspotObjectTypeId: props?.hubspotObjectTypeId,
|
|
1438
|
+
componentName: props?.componentName,
|
|
1439
|
+
paramsObject,
|
|
1440
|
+
recordId: extractHubspotRecordIdFromWriteResponse(response)
|
|
1441
|
+
});
|
|
1442
|
+
return response;
|
|
1443
|
+
},
|
|
1444
|
+
createExisting: async (props = null) => {
|
|
1445
|
+
const { paramsObject } = getParamDetails2({ type: props?.componentName });
|
|
1446
|
+
const { getLinkParams } = updateLink();
|
|
1447
|
+
const fParams = getLinkParams();
|
|
1448
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
1449
|
+
const params = {
|
|
1450
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
1451
|
+
fromRecordId: props?.fromRecordId,
|
|
1452
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
1453
|
+
};
|
|
1454
|
+
const payload = props.payload;
|
|
1455
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
1456
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
1457
|
+
const objectTypeId = props?.toObjectTypeId ?? props?.hubspotObjectTypeId;
|
|
1458
|
+
const recordId = extractHubspotRecordIdFromWriteResponse(response) ?? (props?.fromRecordId != null ? String(props.fromRecordId) : void 0);
|
|
1459
|
+
triggerPostWriteListPurge({
|
|
1460
|
+
hubspotObjectTypeId: objectTypeId,
|
|
1461
|
+
componentName: props?.componentName,
|
|
1462
|
+
paramsObject,
|
|
1463
|
+
recordId
|
|
1464
|
+
});
|
|
1465
|
+
return response;
|
|
1466
|
+
},
|
|
1467
|
+
removeExisting: async (props = null) => {
|
|
1468
|
+
const { paramsObject } = getParamDetails2({ type: props?.componentName });
|
|
1469
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
|
|
1470
|
+
const params = {
|
|
1471
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
1472
|
+
fromRecordId: props?.fromRecordId,
|
|
1473
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
1474
|
+
};
|
|
1475
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
|
|
1476
|
+
const response = await HttpClient.delete(apiUrl, { data: body });
|
|
1477
|
+
const objectTypeId = props?.toObjectTypeId ?? props?.hubspotObjectTypeId;
|
|
1478
|
+
if (objectTypeId) {
|
|
1479
|
+
const { queryParams, multiObjectsQueryParams } = tableStore.getState();
|
|
1480
|
+
const listQuery = resolveCrmListPurgeQuery({
|
|
1481
|
+
componentName: props?.componentName,
|
|
1482
|
+
hubspotObjectTypeId: objectTypeId,
|
|
1483
|
+
tableQueryParams: queryParams,
|
|
1484
|
+
multiObjectsQueryParams,
|
|
1485
|
+
writeContext: recordWriteContext(paramsObject)
|
|
1486
|
+
});
|
|
1487
|
+
purgeCrmListCache({
|
|
1488
|
+
objectTypeId: String(objectTypeId),
|
|
1489
|
+
listQuery
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
return response;
|
|
1493
|
+
},
|
|
1494
|
+
details: (props = null) => {
|
|
1495
|
+
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails2("", true);
|
|
1496
|
+
const hubspotObjectTypeId = ticketHubspotObjectTypeId();
|
|
1497
|
+
const params = {
|
|
1498
|
+
// hubId: config.hubId,
|
|
1499
|
+
// portalId: portalId,
|
|
1500
|
+
objectId: props?.params?.objectId,
|
|
1501
|
+
id: props?.params?.id
|
|
1502
|
+
};
|
|
1503
|
+
const queryParams = {
|
|
1504
|
+
parentAccessLabel,
|
|
1505
|
+
...props?.queryParams,
|
|
1506
|
+
...urlParam
|
|
1507
|
+
};
|
|
1508
|
+
if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
|
|
1509
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
|
|
1510
|
+
return HttpClient.get(apiUrl);
|
|
1511
|
+
},
|
|
1512
|
+
update: async (props = null) => {
|
|
1513
|
+
const hubspotObjectTypeId = ticketHubspotObjectTypeId();
|
|
1514
|
+
const params = {
|
|
1515
|
+
objectId: props?.params?.objectId,
|
|
1516
|
+
id: props?.params?.id
|
|
1517
|
+
};
|
|
1518
|
+
const { paramsObject } = getParamDetails2({ type: props?.componentName });
|
|
1519
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
1520
|
+
const rawPayload = props?.payload || {};
|
|
1521
|
+
const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
|
|
1522
|
+
const body = mergeRecordWriteBody({ properties }, paramsObject, { cardParentMerge });
|
|
1523
|
+
const queryParams = {};
|
|
1524
|
+
if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
|
|
1525
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params, queryParams });
|
|
1526
|
+
const { queryParams: tableQueryParams, multiObjectsQueryParams } = tableStore.getState();
|
|
1527
|
+
const writeContext = recordWriteContext(paramsObject);
|
|
1528
|
+
const listQuery = resolveCrmListPurgeQuery({
|
|
1529
|
+
componentName: props?.componentName,
|
|
1530
|
+
hubspotObjectTypeId: props?.hubspotObjectTypeId ?? props?.params?.objectId,
|
|
1531
|
+
tableQueryParams,
|
|
1532
|
+
multiObjectsQueryParams,
|
|
1533
|
+
writeContext
|
|
1534
|
+
});
|
|
1535
|
+
const response = await HttpClient.put(apiUrl, body);
|
|
1536
|
+
const objectTypeId = props?.hubspotObjectTypeId ?? props?.params?.objectId;
|
|
1537
|
+
const recordId = props?.params?.id;
|
|
1538
|
+
if (objectTypeId && recordId) {
|
|
1539
|
+
purgeCrmDetailAndListAfterCrmWrite({
|
|
1540
|
+
objectTypeId: String(objectTypeId),
|
|
1541
|
+
recordIds: [String(recordId)],
|
|
1542
|
+
listQuery
|
|
1543
|
+
});
|
|
1544
|
+
} else if (objectTypeId) {
|
|
1545
|
+
triggerPostWriteListPurge({
|
|
1546
|
+
hubspotObjectTypeId: objectTypeId,
|
|
1547
|
+
componentName: props?.componentName,
|
|
1548
|
+
paramsObject
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
return response;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
// src/main/features/crm/client/engagement-client.ts
|
|
1557
|
+
var engagementClient = {
|
|
1558
|
+
note: {
|
|
1559
|
+
list: (props = null) => {
|
|
1560
|
+
const { setListQueryParams } = actions4$1;
|
|
1561
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
1562
|
+
const params = {
|
|
1563
|
+
// hubId: config.hubId,
|
|
1564
|
+
// portalId: portalId,
|
|
1565
|
+
objectId: props?.params?.objectId,
|
|
1566
|
+
id: props?.params?.id
|
|
1567
|
+
};
|
|
1568
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
|
|
1569
|
+
return HttpClient.get(apiUrl);
|
|
1570
|
+
},
|
|
1571
|
+
create: async (props = null) => {
|
|
1572
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1573
|
+
const queryParams = props.queryParams;
|
|
1574
|
+
const payload = props.payload;
|
|
1575
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
|
|
1576
|
+
const listQuery = toCachePurgeListQuery(noteStore.getState().queryParams ?? {});
|
|
1577
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
1578
|
+
const recordId = props?.params?.id;
|
|
1579
|
+
const objectTypeId = props?.params?.objectId;
|
|
1580
|
+
if (recordId && objectTypeId) {
|
|
1581
|
+
const engagementItemId = extractEngagementItemIdFromWriteResponse(response);
|
|
1582
|
+
purgeEngagementCachesAfterCrmWrite({
|
|
1583
|
+
objectTypeId,
|
|
1584
|
+
recordIds: [String(recordId)],
|
|
1585
|
+
views: ["notes"],
|
|
1586
|
+
listQuery,
|
|
1587
|
+
engagementItemIds: engagementItemId ? [engagementItemId] : void 0
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
return response;
|
|
1591
|
+
},
|
|
1592
|
+
update: async (props = null) => {
|
|
1593
|
+
const params = {
|
|
1594
|
+
// hubId: config.hubId,
|
|
1595
|
+
// portalId: portalId,
|
|
1596
|
+
objectId: props?.params?.objectId,
|
|
1597
|
+
id: props?.params?.id,
|
|
1598
|
+
note_id: props?.params?.note_id
|
|
1599
|
+
};
|
|
1600
|
+
const { paramsObject: queryParams } = getParamDetails2();
|
|
1601
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
|
|
1602
|
+
const listQuery = toCachePurgeListQuery(noteStore.getState().queryParams ?? {});
|
|
1603
|
+
const response = await HttpClient.put(apiUrl, props.payload);
|
|
1604
|
+
const recordId = props?.params?.id;
|
|
1605
|
+
const objectTypeId = props?.params?.objectId;
|
|
1606
|
+
const noteId = props?.params?.note_id;
|
|
1607
|
+
if (recordId && objectTypeId) {
|
|
1608
|
+
const engagementItemId = extractEngagementItemIdFromWriteResponse(response) ?? (noteId != null && String(noteId).length > 0 ? String(noteId) : void 0);
|
|
1609
|
+
purgeEngagementCachesAfterCrmWrite({
|
|
1610
|
+
objectTypeId,
|
|
1611
|
+
recordIds: [String(recordId)],
|
|
1612
|
+
views: ["notes"],
|
|
1613
|
+
listQuery,
|
|
1614
|
+
engagementItemIds: engagementItemId ? [engagementItemId] : void 0
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
return response;
|
|
1618
|
+
},
|
|
1619
|
+
image: (props = null) => {
|
|
1620
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1621
|
+
const queryParams = props.queryParams;
|
|
1622
|
+
const payload = props.payload;
|
|
1623
|
+
const axiosConfig = props.config || {};
|
|
1624
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
|
|
1625
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1626
|
+
headers: {
|
|
1627
|
+
"Content-Type": "multipart/form-data"
|
|
1628
|
+
},
|
|
1629
|
+
...axiosConfig
|
|
1630
|
+
});
|
|
1631
|
+
},
|
|
1632
|
+
attachment: (props = null) => {
|
|
1633
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1634
|
+
const queryParams = props.queryParams;
|
|
1635
|
+
const payload = props.payload;
|
|
1636
|
+
const axiosConfig = props.config || {};
|
|
1637
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
|
|
1638
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1639
|
+
headers: {
|
|
1640
|
+
"Content-Type": "multipart/form-data"
|
|
1641
|
+
},
|
|
1642
|
+
...axiosConfig
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
email: {
|
|
1647
|
+
list: (props = null) => {
|
|
1648
|
+
const { setListQueryParams } = actions5;
|
|
1649
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
1650
|
+
const params = {
|
|
1651
|
+
// hubId: config.hubId,
|
|
1652
|
+
// portalId: portalId,
|
|
1653
|
+
objectId: props?.params?.objectId,
|
|
1654
|
+
id: props?.params?.id
|
|
1655
|
+
};
|
|
1656
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
|
|
1657
|
+
return HttpClient.get(apiUrl);
|
|
1658
|
+
},
|
|
1659
|
+
create: async (props = null) => {
|
|
1660
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1661
|
+
const queryParams = props.queryParams;
|
|
1662
|
+
const payload = props.payload;
|
|
1663
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
|
|
1664
|
+
const listQuery = toCachePurgeListQuery(emailStore.getState().queryParams ?? {});
|
|
1665
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
1666
|
+
const recordId = props?.params?.id;
|
|
1667
|
+
const objectTypeId = props?.params?.objectId;
|
|
1668
|
+
if (recordId && objectTypeId) {
|
|
1669
|
+
const engagementItemId = extractEngagementItemIdFromWriteResponse(response);
|
|
1670
|
+
purgeEngagementCachesAfterCrmWrite({
|
|
1671
|
+
objectTypeId,
|
|
1672
|
+
recordIds: [String(recordId)],
|
|
1673
|
+
views: ["emails"],
|
|
1674
|
+
listQuery,
|
|
1675
|
+
engagementItemIds: engagementItemId ? [engagementItemId] : void 0
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
return response;
|
|
1679
|
+
},
|
|
1680
|
+
update: async (props = null) => {
|
|
1681
|
+
const params = {
|
|
1682
|
+
// hubId: config.hubId,
|
|
1683
|
+
// portalId: portalId,
|
|
1684
|
+
objectId: props?.params?.objectId,
|
|
1685
|
+
id: props?.params?.id,
|
|
1686
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
1687
|
+
};
|
|
1688
|
+
const { paramsObject: queryParams } = getParamDetails2();
|
|
1689
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
1690
|
+
const listQuery = toCachePurgeListQuery(emailStore.getState().queryParams ?? {});
|
|
1691
|
+
const response = await HttpClient.put(apiUrl, props.payload);
|
|
1692
|
+
const recordId = props?.params?.id;
|
|
1693
|
+
const objectTypeId = props?.params?.objectId;
|
|
1694
|
+
const emailId = props?.params?.email_id ?? props?.params?.note_id;
|
|
1695
|
+
if (recordId && objectTypeId) {
|
|
1696
|
+
const engagementItemId = extractEngagementItemIdFromWriteResponse(response) ?? (emailId != null && String(emailId).length > 0 ? String(emailId) : void 0);
|
|
1697
|
+
purgeEngagementCachesAfterCrmWrite({
|
|
1698
|
+
objectTypeId,
|
|
1699
|
+
recordIds: [String(recordId)],
|
|
1700
|
+
views: ["emails"],
|
|
1701
|
+
listQuery,
|
|
1702
|
+
engagementItemIds: engagementItemId ? [engagementItemId] : void 0
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
return response;
|
|
1706
|
+
},
|
|
1707
|
+
image: (props = null) => {
|
|
1708
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1709
|
+
const queryParams = props.queryParams;
|
|
1710
|
+
const payload = props.payload;
|
|
1711
|
+
const axiosConfig = props.config || {};
|
|
1712
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
|
|
1713
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1714
|
+
headers: {
|
|
1715
|
+
"Content-Type": "multipart/form-data"
|
|
1716
|
+
},
|
|
1717
|
+
...axiosConfig
|
|
1718
|
+
});
|
|
1719
|
+
},
|
|
1720
|
+
attachment: (props = null) => {
|
|
1721
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1722
|
+
const queryParams = props.queryParams;
|
|
1723
|
+
const payload = props.payload;
|
|
1724
|
+
const axiosConfig = props.config || {};
|
|
1725
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
|
|
1726
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1727
|
+
headers: {
|
|
1728
|
+
"Content-Type": "multipart/form-data"
|
|
1729
|
+
},
|
|
1730
|
+
...axiosConfig
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1734
|
+
file: {
|
|
1735
|
+
list: (props = null) => {
|
|
1736
|
+
const { setListQueryParams } = actions4;
|
|
1737
|
+
setListQueryParams(props?.queryParams ?? {});
|
|
1738
|
+
const params = {
|
|
1739
|
+
// hubId: config.hubId,
|
|
1740
|
+
// portalId: portalId,
|
|
1741
|
+
objectId: props?.params?.objectId,
|
|
1742
|
+
id: props?.params?.id
|
|
1743
|
+
};
|
|
1744
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
|
|
1745
|
+
return HttpClient.get(apiUrl);
|
|
1746
|
+
},
|
|
1747
|
+
details: (props = null) => {
|
|
1748
|
+
const params = {
|
|
1749
|
+
// hubId: config.hubId,
|
|
1750
|
+
// portalId: portalId,
|
|
1751
|
+
objectId: props?.params?.objectId,
|
|
1752
|
+
id: props?.params?.id,
|
|
1753
|
+
rowId: props?.params?.rowId
|
|
1754
|
+
};
|
|
1755
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
1756
|
+
return HttpClient.get(apiUrl);
|
|
1757
|
+
},
|
|
1758
|
+
download: (props = null) => {
|
|
1759
|
+
const params = {
|
|
1760
|
+
objectId: props?.params?.objectId,
|
|
1761
|
+
id: props?.params?.id,
|
|
1762
|
+
rowId: props?.params?.rowId
|
|
1763
|
+
};
|
|
1764
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
|
|
1765
|
+
return HttpClient.post(apiUrl, {});
|
|
1766
|
+
},
|
|
1767
|
+
addFolder: async (props = null) => {
|
|
1768
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1769
|
+
const queryParams = props.queryParams;
|
|
1770
|
+
const payload = props.payload;
|
|
1771
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
|
|
1772
|
+
const listQuery = fileStore.getState().queryParams ?? {};
|
|
1773
|
+
const response = await HttpClient.post(apiUrl, payload);
|
|
1774
|
+
const recordId = props?.params?.id;
|
|
1775
|
+
const objectTypeId = props?.params?.objectId;
|
|
1776
|
+
if (recordId && objectTypeId) {
|
|
1777
|
+
purgeEngagementCaches({
|
|
1778
|
+
objectTypeId,
|
|
1779
|
+
recordIds: [String(recordId)],
|
|
1780
|
+
views: ["files"],
|
|
1781
|
+
listQuery
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
return response;
|
|
1785
|
+
},
|
|
1786
|
+
addFile: async (props = null) => {
|
|
1787
|
+
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1788
|
+
const queryParams = props.queryParams;
|
|
1789
|
+
const payload = props.payload;
|
|
1790
|
+
const axiosConfig = props.config || {};
|
|
1791
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
|
|
1792
|
+
const listQuery = fileStore.getState().queryParams ?? {};
|
|
1793
|
+
const response = await HttpClient.post(apiUrl, payload, {
|
|
1794
|
+
headers: {
|
|
1795
|
+
"Content-Type": "multipart/form-data"
|
|
1796
|
+
},
|
|
1797
|
+
...axiosConfig
|
|
1798
|
+
});
|
|
1799
|
+
const recordId = props?.params?.id;
|
|
1800
|
+
const objectTypeId = props?.params?.objectId;
|
|
1801
|
+
if (recordId && objectTypeId) {
|
|
1802
|
+
purgeEngagementCaches({
|
|
1803
|
+
objectTypeId,
|
|
1804
|
+
recordIds: [String(recordId)],
|
|
1805
|
+
views: ["files"],
|
|
1806
|
+
listQuery
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
return response;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1814
|
+
// src/main/features/crm/client/cache-client.ts
|
|
1815
|
+
var cacheClient = {
|
|
1816
|
+
purge: (body, headers) => {
|
|
1817
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
|
|
1818
|
+
return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
|
|
1819
|
+
},
|
|
1820
|
+
purgeStatus: (purgeJobId) => {
|
|
1821
|
+
const apiUrl = generateApiUrl({
|
|
1822
|
+
route: API_ENDPOINTS.CACHE_PURGE_STATUS,
|
|
1823
|
+
params: { purgeJobId }
|
|
1824
|
+
});
|
|
1825
|
+
return HttpClient.get(apiUrl);
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
// src/main/features/auth/client/security-client.ts
|
|
1830
|
+
var refreshTokenHeaders = (refreshToken) => {
|
|
1831
|
+
if (!refreshToken) {
|
|
1832
|
+
return void 0;
|
|
1833
|
+
}
|
|
1834
|
+
return { "X-Refresh-Token": refreshToken };
|
|
1835
|
+
};
|
|
1836
|
+
var securityClient = {
|
|
1837
|
+
getOverview: (query) => HttpClient.get(
|
|
1838
|
+
generateApiUrl({
|
|
1839
|
+
route: API_ENDPOINTS.SECURITY_OVERVIEW,
|
|
1840
|
+
queryParams: portalIdQuery(query?.portalId)
|
|
1841
|
+
})
|
|
1842
|
+
),
|
|
1843
|
+
getLoginActivity: (query) => HttpClient.get(
|
|
1844
|
+
generateApiUrl({
|
|
1845
|
+
route: API_ENDPOINTS.SECURITY_LOGIN_ACTIVITY,
|
|
1846
|
+
queryParams: query ?? {}
|
|
1847
|
+
})
|
|
1848
|
+
),
|
|
1849
|
+
getSessions: (query) => HttpClient.get(
|
|
1850
|
+
generateApiUrl({
|
|
1851
|
+
route: API_ENDPOINTS.SECURITY_SESSIONS,
|
|
1852
|
+
queryParams: query?.currentFamilyId ? { currentFamilyId: query.currentFamilyId } : void 0
|
|
1853
|
+
}),
|
|
1854
|
+
void 0,
|
|
1855
|
+
mergeRequestOptions(void 0, refreshTokenHeaders(query?.refreshToken))
|
|
1856
|
+
),
|
|
1857
|
+
revokeSession: (payload) => HttpClient.post(
|
|
1858
|
+
generateApiUrl({
|
|
1859
|
+
route: API_ENDPOINTS.SECURITY_SESSION_REVOKE,
|
|
1860
|
+
params: { familyId: payload.familyId }
|
|
1861
|
+
}),
|
|
1862
|
+
null,
|
|
1863
|
+
mergeRequestOptions(void 0, refreshTokenHeaders(payload.refreshToken))
|
|
1864
|
+
),
|
|
1865
|
+
revokeOtherSessions: (refreshToken) => HttpClient.post(API_ENDPOINTS.SECURITY_SESSIONS_REVOKE_OTHERS, null, mergeRequestOptions(void 0, refreshTokenHeaders(refreshToken)))
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
// src/main/core/http/client-assembler.ts
|
|
1869
|
+
var Client = {
|
|
1870
|
+
...authenticationClient,
|
|
1871
|
+
...crmClient,
|
|
1872
|
+
...engagementClient,
|
|
1873
|
+
cache: cacheClient,
|
|
1874
|
+
mfa: mfaClient,
|
|
1875
|
+
security: securityClient
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
// src/main/core/utils/cache/createCachePurgeJob.ts
|
|
1879
|
+
function randomIdempotencyKey() {
|
|
1880
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
1881
|
+
return crypto.randomUUID();
|
|
1882
|
+
}
|
|
1883
|
+
return `purge-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1884
|
+
}
|
|
1885
|
+
function mapErrorCode(status, message) {
|
|
1886
|
+
if (status === 400 || status === 422) {
|
|
1887
|
+
return "VALIDATION";
|
|
1888
|
+
}
|
|
1889
|
+
if (status === 429) {
|
|
1890
|
+
return "RATE_LIMITED";
|
|
1891
|
+
}
|
|
1892
|
+
if (message?.toLowerCase().includes("disabled")) {
|
|
1893
|
+
return "PURGE_API_DISABLED";
|
|
1894
|
+
}
|
|
1895
|
+
return status ? "UNKNOWN" : "NETWORK";
|
|
1896
|
+
}
|
|
1897
|
+
function sleep(ms) {
|
|
1898
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1899
|
+
}
|
|
1900
|
+
async function createCachePurgeJob(request, options = {}) {
|
|
1901
|
+
const idempotencyKey = options.idempotencyKey ?? randomIdempotencyKey();
|
|
1902
|
+
try {
|
|
1903
|
+
const headers = { "Idempotency-Key": idempotencyKey };
|
|
1904
|
+
const response = await Client.cache.purge(request, headers);
|
|
1905
|
+
const data = response?.data;
|
|
1906
|
+
const purgeJobId = data?.purgeJobId;
|
|
1907
|
+
let status = data?.status;
|
|
1908
|
+
if (options.waitForWarm && purgeJobId && request.warm !== false) {
|
|
1909
|
+
const timeout = options.pollTimeoutMs ?? 3e4;
|
|
1910
|
+
const interval = options.pollIntervalMs ?? 500;
|
|
1911
|
+
const deadline = Date.now() + timeout;
|
|
1912
|
+
while (Date.now() < deadline) {
|
|
1913
|
+
const statusRes = await Client.cache.purgeStatus(purgeJobId);
|
|
1914
|
+
const job = statusRes?.data;
|
|
1915
|
+
const jobStatus = job?.status;
|
|
1916
|
+
if (jobStatus === "completed") {
|
|
1917
|
+
status = "completed";
|
|
1918
|
+
break;
|
|
1919
|
+
}
|
|
1920
|
+
if (jobStatus === "failed") {
|
|
1921
|
+
return {
|
|
1922
|
+
ok: false,
|
|
1923
|
+
purgeJobId,
|
|
1924
|
+
status: "failed",
|
|
1925
|
+
errorCode: "WARM_FAILED",
|
|
1926
|
+
message: "Cache warm job failed"
|
|
1927
|
+
};
|
|
1928
|
+
}
|
|
1929
|
+
await sleep(interval);
|
|
1930
|
+
}
|
|
1931
|
+
if (status !== "completed") {
|
|
1932
|
+
return {
|
|
1933
|
+
ok: false,
|
|
1934
|
+
purgeJobId,
|
|
1935
|
+
status: status ?? "warming",
|
|
1936
|
+
errorCode: "WARM_FAILED",
|
|
1937
|
+
message: "Timed out waiting for cache warm job"
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return {
|
|
1942
|
+
ok: true,
|
|
1943
|
+
purgeJobId,
|
|
1944
|
+
status,
|
|
1945
|
+
evicted: data?.evicted,
|
|
1946
|
+
warnings: data?.warnings
|
|
1947
|
+
};
|
|
1948
|
+
} catch (err) {
|
|
1949
|
+
const axiosErr = err;
|
|
1950
|
+
const status = axiosErr.response?.status;
|
|
1951
|
+
const message = axiosErr.response?.data?.message ?? (err instanceof Error ? err.message : "Cache purge request failed");
|
|
1952
|
+
return {
|
|
1953
|
+
ok: false,
|
|
1954
|
+
errorCode: mapErrorCode(status, message),
|
|
1955
|
+
message
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
function logError(context, error) {
|
|
1960
|
+
if (axios2.isAxiosError(error) && error.response?.status === 401) {
|
|
1961
|
+
resetAllStore();
|
|
1962
|
+
}
|
|
1963
|
+
logger.error(context, error);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
// src/main/core/mutation/createMutation.ts
|
|
1967
|
+
function createMutation(mutationFn, options) {
|
|
1968
|
+
let inFlight = 0;
|
|
1969
|
+
let lastReportedLoading = null;
|
|
1970
|
+
const syncLoading = () => {
|
|
1971
|
+
const active = inFlight > 0;
|
|
1972
|
+
if (lastReportedLoading === active) return;
|
|
1973
|
+
lastReportedLoading = active;
|
|
1974
|
+
options?.onLoadingChange?.(active);
|
|
1975
|
+
};
|
|
1976
|
+
const mutate = async (payload) => {
|
|
1977
|
+
inFlight += 1;
|
|
1978
|
+
syncLoading();
|
|
1979
|
+
try {
|
|
1980
|
+
const response = await mutationFn(payload);
|
|
1981
|
+
await options?.onSuccess?.(response, payload);
|
|
1982
|
+
return response;
|
|
1983
|
+
} catch (error) {
|
|
1984
|
+
options?.onError?.(error, payload);
|
|
1985
|
+
logError("[mutation]", error);
|
|
1986
|
+
throw error;
|
|
1987
|
+
} finally {
|
|
1988
|
+
inFlight -= 1;
|
|
1989
|
+
syncLoading();
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
return {
|
|
1993
|
+
mutate,
|
|
1994
|
+
isLoading: () => inFlight > 0
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
export { Client, SERVICE_UNAVAILABLE_MESSAGE, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, classifyHttpError, config, createCachePurgeJob, createMutation, extractEngagementItemIdFromWriteResponse, extractHubspotRecordIdFromWriteResponse, getAuthRefreshToken, getFieldErrors, getFormErrors, getHttpErrorMessage, initializeHttpClient, isServiceUnavailableError, mergePurgeTargets, navigationApi, purgeCrmCombined, purgeCrmDetailAndListAfterCrmWrite, purgeCrmListCache, purgeCrmListCacheAfterCrmWrite, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, purgeEngagementCachesAfterCrmWrite, resolveCrmListPurgeQuery, setConfig, storage, toCachePurgeListQuery };
|
|
1999
|
+
//# sourceMappingURL=chunk-4ZV3MQIB.js.map
|
|
2000
|
+
//# sourceMappingURL=chunk-4ZV3MQIB.js.map
|