woodsportal-client-sdk 1.1.5-dev.0 → 2.0.705

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/README.md +199 -77
  3. package/dist/adapters/angular/index.d.ts +88 -5
  4. package/dist/adapters/angular/index.js +12 -7
  5. package/dist/adapters/angular/index.js.map +1 -1
  6. package/dist/adapters/native/index.d.ts +3 -0
  7. package/dist/adapters/native/index.js +11 -0
  8. package/dist/adapters/native/index.js.map +1 -0
  9. package/dist/adapters/react/index.d.ts +88 -5
  10. package/dist/adapters/react/index.js +9 -16
  11. package/dist/adapters/react/index.js.map +1 -1
  12. package/dist/adapters/vue/index.d.ts +88 -5
  13. package/dist/adapters/vue/index.js +12 -7
  14. package/dist/adapters/vue/index.js.map +1 -1
  15. package/dist/auth-error-codes-D7CXVBEN.js +3 -0
  16. package/dist/auth-error-codes-D7CXVBEN.js.map +1 -0
  17. package/dist/auth-interceptor-policy-K46P4VM4.js +6 -0
  18. package/dist/auth-interceptor-policy-K46P4VM4.js.map +1 -0
  19. package/dist/auth-utils-JGNW73IJ.js +7 -0
  20. package/dist/{auth-utils-A4WPJMPK.js.map → auth-utils-JGNW73IJ.js.map} +1 -1
  21. package/dist/chunk-2OLIVT2F.js +343 -0
  22. package/dist/chunk-2OLIVT2F.js.map +1 -0
  23. package/dist/chunk-32ERSTFY.js +354 -0
  24. package/dist/chunk-32ERSTFY.js.map +1 -0
  25. package/dist/{chunk-Y5MRAAGK.js → chunk-AYTO6ND7.js} +3 -3
  26. package/dist/chunk-AYTO6ND7.js.map +1 -0
  27. package/dist/chunk-BXHEEGBF.js +2747 -0
  28. package/dist/chunk-BXHEEGBF.js.map +1 -0
  29. package/dist/chunk-COHBSTHF.js +82 -0
  30. package/dist/chunk-COHBSTHF.js.map +1 -0
  31. package/dist/chunk-CUVU6DCT.js +3 -0
  32. package/dist/chunk-CUVU6DCT.js.map +1 -0
  33. package/dist/chunk-D5GHE2CO.js +172 -0
  34. package/dist/chunk-D5GHE2CO.js.map +1 -0
  35. package/dist/chunk-DB6W3CJT.js +73 -0
  36. package/dist/chunk-DB6W3CJT.js.map +1 -0
  37. package/dist/chunk-ITBMRGCP.js +16 -0
  38. package/dist/chunk-ITBMRGCP.js.map +1 -0
  39. package/dist/chunk-JRT5XSVY.js +161 -0
  40. package/dist/chunk-JRT5XSVY.js.map +1 -0
  41. package/dist/chunk-JSXP2F2H.js +1849 -0
  42. package/dist/chunk-JSXP2F2H.js.map +1 -0
  43. package/dist/chunk-KGNMN7B3.js +173 -0
  44. package/dist/chunk-KGNMN7B3.js.map +1 -0
  45. package/dist/chunk-MLBZ5FQA.js +1305 -0
  46. package/dist/chunk-MLBZ5FQA.js.map +1 -0
  47. package/dist/chunk-OH7VT6MX.js +22 -0
  48. package/dist/chunk-OH7VT6MX.js.map +1 -0
  49. package/dist/chunk-VDMDWMMX.js +519 -0
  50. package/dist/chunk-VDMDWMMX.js.map +1 -0
  51. package/dist/chunk-XDYXEYDM.js +1081 -0
  52. package/dist/chunk-XDYXEYDM.js.map +1 -0
  53. package/dist/crmCacheRefresh-B9sAQzI7.d.ts +292 -0
  54. package/dist/cross-tab-session-FCAQTXUB.js +11 -0
  55. package/dist/cross-tab-session-FCAQTXUB.js.map +1 -0
  56. package/dist/entries/auth.d.ts +96 -0
  57. package/dist/entries/auth.js +19 -0
  58. package/dist/entries/auth.js.map +1 -0
  59. package/dist/entries/crm.d.ts +239 -0
  60. package/dist/entries/crm.js +33 -0
  61. package/dist/entries/crm.js.map +1 -0
  62. package/dist/index-CWYPrDBp.d.ts +56 -0
  63. package/dist/index.d.ts +642 -394
  64. package/dist/index.js +96 -1698
  65. package/dist/index.js.map +1 -1
  66. package/dist/route-guard-contract-CSJMmfDA.d.ts +856 -0
  67. package/dist/storage-migration-CWOS6CNV.js +4 -0
  68. package/dist/storage-migration-CWOS6CNV.js.map +1 -0
  69. package/dist/use-file-BcO5l-Zf.d.ts +29 -0
  70. package/dist/use-sync-BQfzHacf.d.ts +66 -0
  71. package/package.json +155 -110
  72. package/dist/auth-utils-A4WPJMPK.js +0 -4
  73. package/dist/chunk-J7MDPY5P.js +0 -54
  74. package/dist/chunk-J7MDPY5P.js.map +0 -1
  75. package/dist/chunk-NB7AINV4.js +0 -35
  76. package/dist/chunk-NB7AINV4.js.map +0 -1
  77. package/dist/chunk-RDCT25UV.js +0 -1066
  78. package/dist/chunk-RDCT25UV.js.map +0 -1
  79. package/dist/chunk-Y5MRAAGK.js.map +0 -1
  80. package/dist/chunk-YLZA5S7A.js +0 -102
  81. package/dist/chunk-YLZA5S7A.js.map +0 -1
  82. package/dist/use-sync-LbURBOs_.d.ts +0 -29
@@ -0,0 +1,2747 @@
1
+ import { getParamDetails, getRouteDetails, updateLink, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, tableUiActions, ticketHubspotObjectTypeId, makePreviewParams, tableStore, actions2, userStore, isPipelineBoardObjectTypeId, tableUiStore, fileStore, actions7, emailStore, actions5, noteStore, actions4, resetAllStore, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl } from './chunk-JSXP2F2H.js';
2
+ import { getRuntimeHttpClientApiDate, config, configureLogger, setIframeStorageMode, setRefreshBufferSeconds, setRefreshCallback, hydrateSessionRefreshState, logger, isHttpTracingEnabled, getAccessToken, sanitizeAxiosErrorData, classifyRefreshHttpError, shouldLogoutAfterRefreshFailure, setRefreshToken, storAccessToken, classifyRefreshResponseWithoutToken, storage, HUBSPOT_DATA, setRuntimeHttpClientHubContext, isServiceUnavailableError, refreshSession, ensureValidRefresh, HUB_ID, DEV_PORTAL_ID, PORTAL_ID, DEV_API_URL, isAccessTokenExpired } from './chunk-XDYXEYDM.js';
3
+ import { getClientType, configureStorageKeys } from './chunk-32ERSTFY.js';
4
+ import { AuthErrorCode } from './chunk-COHBSTHF.js';
5
+ import axios from 'axios';
6
+
7
+ // src/main/core/utils/generateApiUrl.ts
8
+ var API_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
9
+ function shouldSkipApiDate(url) {
10
+ if (!url.startsWith("/api/")) return true;
11
+ if (url.startsWith("/api/platform/")) return true;
12
+ if (url.startsWith("/api/public-app/")) return true;
13
+ if (url.startsWith("/api/webhooks/")) return true;
14
+ if (url.startsWith("/api/internal/")) return true;
15
+ return false;
16
+ }
17
+ function alreadyHasApiDate(url) {
18
+ if (url.startsWith("/api/admin/")) {
19
+ return /^\/api\/admin\/\d{4}-\d{2}-\d{2}(?:\/|$)/.test(url);
20
+ }
21
+ return /^\/api\/\d{4}-\d{2}-\d{2}(?:\/|$)/.test(url);
22
+ }
23
+ function applyContractApiDate(url, apiDate) {
24
+ const date = (apiDate ?? "").trim();
25
+ if (!date || !API_DATE_RE.test(date)) return url;
26
+ if (shouldSkipApiDate(url) || alreadyHasApiDate(url)) return url;
27
+ if (url.startsWith("/api/admin/")) {
28
+ return url.replace("/api/admin/", `/api/admin/${date}/`);
29
+ }
30
+ if (url.startsWith("/api/")) {
31
+ return url.replace("/api/", `/api/${date}/`);
32
+ }
33
+ return url;
34
+ }
35
+ function getConfiguredContractApiDate() {
36
+ return (getRuntimeHttpClientApiDate() || "").trim();
37
+ }
38
+ var generateApiUrl = ({ route, params = {}, queryParams = "" }) => {
39
+ const defaultParams = {
40
+ hubId: config.hubId,
41
+ portalId: config.portalId
42
+ };
43
+ params = { ...defaultParams, ...params };
44
+ const url = applyContractApiDate(replaceParams(route, params), getConfiguredContractApiDate());
45
+ let queryString = "";
46
+ if (queryParams && typeof queryParams === "object") {
47
+ const cleanedParams = Object.entries(queryParams).filter(([_, value]) => value !== null && value !== void 0).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
48
+ queryString = new URLSearchParams(cleanedParams).toString();
49
+ }
50
+ return queryString ? `${url}?${queryString}` : url;
51
+ };
52
+ function replaceParams(template, values) {
53
+ return template.replace(/\$\{(\w+)\}/g, (_, key) => key in values ? String(values[key]) : `\${${key}}`);
54
+ }
55
+
56
+ // src/main/core/http/visibility-refresh-scheduler.ts
57
+ var visibilityStop = null;
58
+ function hasBrowserDocument() {
59
+ return typeof document !== "undefined" && document != null;
60
+ }
61
+ function startVisibilityRefreshScheduler(options) {
62
+ if (getClientType() === "mobile") {
63
+ return () => void 0;
64
+ }
65
+ if (typeof window === "undefined" || !hasBrowserDocument()) {
66
+ return () => void 0;
67
+ }
68
+ visibilityStop?.();
69
+ const intervalMs = options.intervalMs ?? 6e4;
70
+ const tick = () => {
71
+ if (document.visibilityState !== "visible") return;
72
+ if (!options.shouldRefresh()) return;
73
+ void options.refresh();
74
+ };
75
+ const onVisibility = () => {
76
+ if (document.visibilityState === "visible") {
77
+ void tick();
78
+ }
79
+ };
80
+ const intervalId = window.setInterval(tick, intervalMs);
81
+ document.addEventListener("visibilitychange", onVisibility);
82
+ window.addEventListener("focus", onVisibility);
83
+ const stop = () => {
84
+ window.clearInterval(intervalId);
85
+ document.removeEventListener("visibilitychange", onVisibility);
86
+ window.removeEventListener("focus", onVisibility);
87
+ if (visibilityStop === stop) {
88
+ visibilityStop = null;
89
+ }
90
+ };
91
+ visibilityStop = stop;
92
+ return stop;
93
+ }
94
+ function stopVisibilityRefreshScheduler() {
95
+ visibilityStop?.();
96
+ }
97
+
98
+ // src/main/core/http/editor-preview-mock.ts
99
+ var editorPreviewMockHandler = null;
100
+ function setEditorPreviewMockHandler(handler) {
101
+ editorPreviewMockHandler = handler;
102
+ }
103
+ function isEditorPreviewMockActive() {
104
+ return editorPreviewMockHandler != null;
105
+ }
106
+ async function resolveEditorPreviewMock(config4) {
107
+ if (!editorPreviewMockHandler) {
108
+ return null;
109
+ }
110
+ return editorPreviewMockHandler(config4);
111
+ }
112
+
113
+ // src/main/core/http/api-endpoints.ts
114
+ var API_ENDPOINTS = {
115
+ // Auth
116
+ PRE_LOGIN: "/api/auth/pre-login",
117
+ LOGIN: "/api/auth/login",
118
+ AUTH_REFRESH: "/api/auth/refresh",
119
+ AUTH_REFRESH_COOKIE: "/api/auth/refresh-cookie",
120
+ FORGET_PASSWORD: "/api/auth/forget-password",
121
+ FORGET_PASSWORD_OTP_VERIFY: "/api/auth/forget-password/otp/verify",
122
+ RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
123
+ RESET_PASSWORD: "/api/auth/reset-password",
124
+ VERIFY_EMAIL: "/api/auth/verify-email",
125
+ REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
126
+ RESEND_EMAIL: "/api/auth/resend-email",
127
+ VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
128
+ LOGOUT: "/api/auth/logout",
129
+ VERIFY_OTP: "/api/auth/verify-otp",
130
+ CLIENT_SESSION: "/api/auth/client-session",
131
+ AUTH_HANDOFF: "/api/auth/handoff",
132
+ SIGN_IN_LINK_SEND: "/api/auth/sign-in-link/send",
133
+ SIGN_IN_LINK_VERIFY: "/api/auth/sign-in-link/verify",
134
+ SIGN_IN_LINK_VALIDATE: "/api/auth/sign-in-link/validate",
135
+ // Auth MFA (client lane)
136
+ MFA_PENDING_OTP_SEND: "/api/auth/mfa/pending/otp/send",
137
+ MFA_PENDING_PASSKEY_OPTIONS: "/api/auth/mfa/pending/passkey/authenticate/options",
138
+ MFA_PENDING_PASSKEY_VERIFY: "/api/auth/mfa/pending/passkey/authenticate/verify",
139
+ MFA_STATUS: "/api/auth/mfa/status",
140
+ MFA_PREFERENCES: "/api/auth/mfa/preferences",
141
+ MFA_PHONE_VERIFY_START: "/api/auth/mfa/phone/verify/start",
142
+ MFA_PHONE_VERIFY_CONFIRM: "/api/auth/mfa/phone/verify/confirm",
143
+ MFA_PHONE_UNVERIFY: "/api/auth/mfa/phone/unverify",
144
+ MFA_BACKUP_CODES_REGENERATE: "/api/auth/mfa/backup-codes/regenerate",
145
+ MFA_OPT_OUT: "/api/auth/mfa/opt-out",
146
+ MFA_TOTP_ENROLL_START: "/api/auth/mfa/totp/enroll/start",
147
+ MFA_TOTP_ENROLL_VERIFY: "/api/auth/mfa/totp/enroll/verify",
148
+ MFA_TOTP_DISABLE: "/api/auth/mfa/totp/disable",
149
+ MFA_WEBAUTHN_REGISTER_OPTIONS: "/api/auth/mfa/webauthn/register/options",
150
+ MFA_WEBAUTHN_REGISTER_VERIFY: "/api/auth/mfa/webauthn/register/verify",
151
+ MFA_WEBAUTHN_AUTH_OPTIONS: "/api/auth/mfa/webauthn/authenticate/options",
152
+ MFA_WEBAUTHN_AUTH_VERIFY: "/api/auth/mfa/webauthn/authenticate/verify",
153
+ MFA_WEBAUTHN_CREDENTIALS: "/api/auth/mfa/webauthn/credentials",
154
+ MFA_WEBAUTHN_CREDENTIAL_DELETE: "/api/auth/mfa/webauthn/credentials/${credentialRecordId}",
155
+ PASSKEY_LOGIN_OPTIONS: "/api/auth/passkey/login/options",
156
+ PASSKEY_LOGIN_VERIFY: "/api/auth/passkey/login/verify",
157
+ // Auth Security (client lane)
158
+ SECURITY_OVERVIEW: "/api/auth/security/overview",
159
+ SECURITY_LOGIN_ACTIVITY: "/api/auth/security/login-activity",
160
+ SECURITY_SESSIONS: "/api/auth/security/sessions",
161
+ SECURITY_SESSION_REVOKE: "/api/auth/security/sessions/${familyId}/revoke",
162
+ SECURITY_SESSIONS_REVOKE_OTHERS: "/api/auth/security/sessions/revoke-others",
163
+ // Login bootstrap (portal MFA policy + SSO providers)
164
+ LOGIN_BOOTSTRAP: "/api/auth/login/bootstrap",
165
+ // SSO
166
+ SSO_DETAILS: "/api/auth/sso/active",
167
+ SSO_URL: "/api/auth/sso/authorize",
168
+ SSO_CALLBACK: "/api/auth/sso/callback",
169
+ // User
170
+ ME: "/api/${hubId}/${portalId}/auth/me?include=crmProfile",
171
+ PROFILE: "/api/${hubId}/${portalId}/profiles",
172
+ PROFILE_UPDATE: "/api/${hubId}/${portalId}/profiles",
173
+ CHANGE_PASSWORD: "/api/auth/change-password",
174
+ // Notification preferences (portal client — same row as admin prefs)
175
+ NOTIFICATION_PREFERENCES: "/api/${hubId}/${portalId}/notification-preferences",
176
+ // Accounts (client lane — hub / portal picker)
177
+ HUBSPOTS: "/api/hubspots",
178
+ PORTALS: "/api/portals",
179
+ // Mobile
180
+ MOBILE_NAVIGATION: "/api/${hubId}/${portalId}/mobile/navigation",
181
+ MOBILE_APP_CONFIG: "/api/${hubId}/${portalId}/mobile/app-config",
182
+ MOBILE_NAVIGATION_IMPORT_WEB_MENU: "/api/${hubId}/${portalId}/mobile/navigation/import-web-menu",
183
+ // Pipeline
184
+ PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
185
+ // Stage
186
+ STAGES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
187
+ // Cache purge (replaces cache=false refresh; requires features.cache-purge-api-enabled on API)
188
+ CACHE_PURGE: "/api/${hubId}/${portalId}/cache-purge-jobs",
189
+ CACHE_PURGE_STATUS: "/api/${hubId}/${portalId}/cache-purge-jobs/${purgeJobId}",
190
+ /** @deprecated Use CACHE_PURGE */
191
+ CACHE_PURGE_LEGACY: "/api/${hubId}/${portalId}/cache/purge",
192
+ /** @deprecated Use CACHE_PURGE_STATUS */
193
+ CACHE_PURGE_STATUS_LEGACY: "/api/${hubId}/${portalId}/cache/purge/${purgeJobId}",
194
+ // Object (read on hubspot-object-data; form layout on hubspot-object-forms)
195
+ OBJECTS: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
196
+ OBJECTS_PUBLIC: "/api/${hubId}/public/hubspot-object-data/${hubspotObjectTypeId}/records",
197
+ OBJECTS_FORM: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
198
+ OBJECTS_FORM_OPTIONS: "/api/${hubId}/${portalId}/hubspot-object-forms/${formId}/${objectTypeId}",
199
+ RECORDS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
200
+ RECORDS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
201
+ RECORDS_ASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
202
+ RECORDS_DISASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
203
+ RECORDS_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/existing-records",
204
+ RECORDS_ADD_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-data/${parentObjectTypeId}/records/${recordId}/associations/${hubspotObjectTypeId}",
205
+ /** @deprecated Use RECORDS_CREATE */
206
+ OBJECTS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
207
+ /** @deprecated Use RECORDS_ASSOCIATE */
208
+ OBJECTS_CREATE_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-forms/:fromObjectTypeId/:fromRecordId/associations/:toObjectTypeId",
209
+ OBJECTS_DETAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
210
+ OBJECTS_DETAILS_PUBLIC: "/api/${hubId}/public/hubspot-object-data/${objectId}/records/${id}",
211
+ /** @deprecated Use RECORDS_UPDATE */
212
+ OBJECTS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/records/${id}",
213
+ OBJECTS_DETAILS_UPDATE_LEGACY: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/properties/${id}",
214
+ // Notes (nested under CRM record)
215
+ NOTES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
216
+ NOTES_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
217
+ NOTES_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/${note_id}",
218
+ NOTES_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/images",
219
+ NOTES_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments",
220
+ NOTES_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments/${note_id}",
221
+ // Email (nested under CRM record)
222
+ EMAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
223
+ EMAILS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
224
+ EMAILS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/${email_id}",
225
+ EMAILS_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/images",
226
+ EMAILS_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments",
227
+ EMAILS_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments/${email_id}",
228
+ // File manager (nested under CRM record)
229
+ FILES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files",
230
+ FILE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}",
231
+ FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
232
+ FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
233
+ FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
234
+ };
235
+
236
+ // src/main/core/http/http-config.ts
237
+ var config2 = {
238
+ baseURL: ""
239
+ };
240
+
241
+ // src/main/core/logging/log-http.ts
242
+ var SENSITIVE_QUERY_KEYS = /* @__PURE__ */ new Set([
243
+ "token",
244
+ "refreshtoken",
245
+ "accesstoken",
246
+ "password",
247
+ "secret",
248
+ "authorization",
249
+ "otp",
250
+ "code",
251
+ "api_key",
252
+ "apikey"
253
+ ]);
254
+ function isSensitiveQueryKey(key) {
255
+ const normalized = key.toLowerCase();
256
+ return SENSITIVE_QUERY_KEYS.has(normalized) || normalized.includes("password") || normalized.includes("token");
257
+ }
258
+ function resolveUrlBase() {
259
+ if (typeof window === "undefined") {
260
+ return "http://localhost";
261
+ }
262
+ try {
263
+ const origin = window.location?.origin;
264
+ if (typeof origin === "string" && origin.length > 0) {
265
+ return origin;
266
+ }
267
+ } catch {
268
+ }
269
+ return "http://localhost";
270
+ }
271
+ function sanitizeHttpUrl(url) {
272
+ if (url == null || url === "") {
273
+ return url;
274
+ }
275
+ try {
276
+ const base = resolveUrlBase();
277
+ const parsed = url.startsWith("http") ? new URL(url) : new URL(url, base);
278
+ for (const key of [...parsed.searchParams.keys()]) {
279
+ if (isSensitiveQueryKey(key)) {
280
+ parsed.searchParams.set(key, "[redacted]");
281
+ }
282
+ }
283
+ return url.startsWith("http") ? parsed.toString() : `${parsed.pathname}${parsed.search}${parsed.hash}`;
284
+ } catch {
285
+ return url;
286
+ }
287
+ }
288
+ var SDK_HTTP_TIMING_KEY = "__woodsportalSdkRequestStartMs";
289
+ function markHttpRequestStart(config4) {
290
+ config4[SDK_HTTP_TIMING_KEY] = Date.now();
291
+ }
292
+ function getHttpRequestDurationMs(config4) {
293
+ const start = config4[SDK_HTTP_TIMING_KEY];
294
+ return typeof start === "number" ? Date.now() - start : void 0;
295
+ }
296
+ function getHttpMethod(config4) {
297
+ return config4.method?.toUpperCase();
298
+ }
299
+ function getHttpUrl(config4) {
300
+ return sanitizeHttpUrl(config4.url);
301
+ }
302
+
303
+ // src/main/core/http/csp-violation-monitor.ts
304
+ var VIOLATION_TTL_MS = 3e4;
305
+ var MAX_RECORDED = 20;
306
+ var violations = [];
307
+ var installed = false;
308
+ function installCspViolationMonitor() {
309
+ if (installed || typeof document === "undefined" || typeof document.addEventListener !== "function") {
310
+ return;
311
+ }
312
+ installed = true;
313
+ document.addEventListener("securitypolicyviolation", (event) => {
314
+ violations.push({
315
+ blockedUri: event.blockedURI ?? "",
316
+ effectiveDirective: event.effectiveDirective ?? event.violatedDirective ?? "",
317
+ at: Date.now()
318
+ });
319
+ if (violations.length > MAX_RECORDED) {
320
+ violations = violations.slice(-MAX_RECORDED);
321
+ }
322
+ });
323
+ }
324
+ function findCspViolationFor(requestUrl) {
325
+ if (!requestUrl) {
326
+ return void 0;
327
+ }
328
+ const now = Date.now();
329
+ violations = violations.filter((violation) => now - violation.at <= VIOLATION_TTL_MS);
330
+ let origin;
331
+ try {
332
+ origin = new URL(requestUrl, typeof location !== "undefined" ? location.href : void 0).origin;
333
+ } catch {
334
+ return void 0;
335
+ }
336
+ return violations.find(
337
+ (violation) => violation.blockedUri === origin || violation.blockedUri.startsWith(`${origin}/`)
338
+ );
339
+ }
340
+
341
+ // src/main/core/http/http-client.ts
342
+ var INVALID_PATH_SEGMENT_PATTERN = /\/(undefined|null|NaN)([/?#]|$)/;
343
+ var axiosInstance = null;
344
+ var config3 = {};
345
+ function hasBrowserLocation() {
346
+ if (typeof window === "undefined") {
347
+ return false;
348
+ }
349
+ try {
350
+ return window.location != null;
351
+ } catch {
352
+ return false;
353
+ }
354
+ }
355
+ function buildAuthPolicy() {
356
+ const routes = config3.routes ?? {};
357
+ const base = config3.authPolicy ?? {};
358
+ return {
359
+ routes: {
360
+ unauthorized: routes.unauthorized ?? "/unauthorized",
361
+ login: routes.login ?? "/login",
362
+ twoFa: routes.twoFa ?? "/login/two-fa",
363
+ resendEmail: routes.resendEmail ?? "/resend-email",
364
+ accountSelect: routes.accountSelect ?? "/account-select",
365
+ ...base.routes
366
+ },
367
+ optionalAuthFailurePaths: base.optionalAuthFailurePaths ?? [
368
+ API_ENDPOINTS.LOGOUT,
369
+ API_ENDPOINTS.MFA_STATUS,
370
+ API_ENDPOINTS.MFA_PREFERENCES,
371
+ API_ENDPOINTS.MFA_TOTP_ENROLL_START,
372
+ API_ENDPOINTS.MFA_TOTP_ENROLL_VERIFY,
373
+ API_ENDPOINTS.MFA_TOTP_DISABLE,
374
+ API_ENDPOINTS.MFA_PHONE_VERIFY_START,
375
+ API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM,
376
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
377
+ API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_VERIFY,
378
+ API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIALS
379
+ ],
380
+ sessionProbePaths: base.sessionProbePaths,
381
+ includeAdminMfaSecurityPrefixes: base.includeAdminMfaSecurityPrefixes ?? true
382
+ };
383
+ }
384
+ function formatUnauthorizedRoute(route) {
385
+ if (route.startsWith("#")) {
386
+ return route;
387
+ }
388
+ if (hasBrowserLocation() && window.location.hash.startsWith("#/")) {
389
+ return `#${route.startsWith("/") ? route : `/${route}`}`;
390
+ }
391
+ return route;
392
+ }
393
+ function isRecoverableSessionExpiredCode(errorCode) {
394
+ return errorCode === AuthErrorCode.TOKEN_EXPIRED || errorCode === AuthErrorCode.TOKEN_INVALID || errorCode === AuthErrorCode.AUTHENTICATION_FAILED || errorCode === AuthErrorCode.MISSING_REFRESH_TOKEN || errorCode === AuthErrorCode.ACCESS_UNAUTHORIZED;
395
+ }
396
+ function formatLoginRouteWithReturn(loginRoute) {
397
+ const loginPath = loginRoute.startsWith("/") ? loginRoute : `/${loginRoute}`;
398
+ if (!hasBrowserLocation()) {
399
+ return formatUnauthorizedRoute(loginPath);
400
+ }
401
+ const returnPath = window.location.hash.replace(/^#/, "") || window.location.pathname;
402
+ if (!returnPath || returnPath.startsWith("/login")) {
403
+ return formatUnauthorizedRoute(loginPath);
404
+ }
405
+ return formatUnauthorizedRoute(`${loginPath}?r=${encodeURIComponent(returnPath)}`);
406
+ }
407
+ function setBearerAuthorization(requestConfig, token) {
408
+ if (!requestConfig.headers) {
409
+ requestConfig.headers = {};
410
+ }
411
+ if (typeof requestConfig.headers.set === "function") {
412
+ requestConfig.headers.set("Authorization", `Bearer ${token}`);
413
+ return;
414
+ }
415
+ requestConfig.headers.Authorization = `Bearer ${token}`;
416
+ }
417
+ async function handleAuthHttpError(error, axiosInstanceRef) {
418
+ if (!error.response || !error.config) {
419
+ return Promise.reject(error);
420
+ }
421
+ const status = error.response.status;
422
+ if (status !== 401 && status !== 403) {
423
+ return Promise.reject(error);
424
+ }
425
+ const shouldHandleOnPublicPath = config3.skipCurrentPublicPath?.() ?? false;
426
+ const allowUnauthorizedHandling = config3.shouldHandleUnauthorized?.() ?? true;
427
+ if (!shouldHandleOnPublicPath || !allowUnauthorizedHandling) {
428
+ return Promise.reject(error);
429
+ }
430
+ const { parseApiErrorPayload } = await import('./auth-error-codes-D7CXVBEN.js');
431
+ const { persistAuthError, resolveAuthErrorAction } = await import('./auth-interceptor-policy-K46P4VM4.js');
432
+ const reqConfig = error.config;
433
+ const payload = parseApiErrorPayload(error.response.data);
434
+ const action = resolveAuthErrorAction({
435
+ status,
436
+ errorCode: payload.errorCode,
437
+ url: reqConfig.url,
438
+ skipGlobalAuthRedirect: reqConfig.skipGlobalAuthRedirect,
439
+ isRetryRequest: reqConfig.__isRetryRequest,
440
+ policy: buildAuthPolicy()
441
+ });
442
+ if (action.kind === "reject") {
443
+ return Promise.reject(error);
444
+ }
445
+ if (action.kind === "refresh_retry") {
446
+ if (isRefreshCallbackInFlight()) {
447
+ return Promise.reject(error);
448
+ }
449
+ try {
450
+ await refreshSession({ force: true });
451
+ } catch {
452
+ }
453
+ const token = getAccessToken();
454
+ if (token) {
455
+ const newConfig = { ...reqConfig, __isRetryRequest: true };
456
+ setBearerAuthorization(newConfig, token);
457
+ return axiosInstanceRef.request(newConfig);
458
+ }
459
+ persistAuthError(payload);
460
+ void config3.onLogout?.();
461
+ const policy = buildAuthPolicy();
462
+ const destination = isRecoverableSessionExpiredCode(payload.errorCode) ? formatLoginRouteWithReturn(policy.routes.login) : formatUnauthorizedRoute(policy.routes.unauthorized);
463
+ if (hasBrowserLocation()) {
464
+ window.location.replace(destination);
465
+ }
466
+ return Promise.reject(error);
467
+ }
468
+ persistAuthError(payload);
469
+ if (action.kind === "logout" || action.kind === "redirect") {
470
+ if (action.clearSession) {
471
+ void config3.onLogout?.();
472
+ }
473
+ if (hasBrowserLocation()) {
474
+ window.location.replace(formatUnauthorizedRoute(action.route));
475
+ }
476
+ }
477
+ return Promise.reject(error);
478
+ }
479
+ function persistHubContextFromClientConfig(clientConfig) {
480
+ const existing = storage.get(HUBSPOT_DATA) || {};
481
+ const next = { ...existing };
482
+ if (clientConfig.hubId != null && String(clientConfig.hubId).trim() !== "") {
483
+ next[HUB_ID] = String(clientConfig.hubId);
484
+ }
485
+ if (clientConfig.devPortalId != null && String(clientConfig.devPortalId).trim() !== "") {
486
+ const portalId = String(clientConfig.devPortalId);
487
+ next[DEV_PORTAL_ID] = portalId;
488
+ next[PORTAL_ID] = portalId;
489
+ } else {
490
+ delete next[DEV_PORTAL_ID];
491
+ }
492
+ if (clientConfig.baseURL) {
493
+ next[DEV_API_URL] = clientConfig.baseURL;
494
+ }
495
+ storage.set(HUBSPOT_DATA, next);
496
+ setRuntimeHttpClientHubContext({
497
+ hubId: clientConfig.hubId != null ? String(clientConfig.hubId) : "",
498
+ devPortalId: clientConfig.devPortalId != null ? String(clientConfig.devPortalId) : "",
499
+ devApiUrl: clientConfig.baseURL ?? "",
500
+ apiDate: clientConfig.apiDate != null ? String(clientConfig.apiDate).trim() : ""
501
+ });
502
+ }
503
+ function notifyServiceUnavailable(error) {
504
+ if (!isServiceUnavailableError(error)) return;
505
+ config3.onServiceUnavailable?.(error);
506
+ }
507
+ function initializeHttpClient(clientConfig) {
508
+ config3 = clientConfig;
509
+ persistHubContextFromClientConfig(clientConfig);
510
+ if (clientConfig.logger != null) {
511
+ configureLogger(clientConfig.logger);
512
+ }
513
+ if (clientConfig.storageKeys != null) {
514
+ configureStorageKeys(clientConfig.storageKeys);
515
+ }
516
+ void import('./storage-migration-CWOS6CNV.js').then(({ migrateLegacyStorageKeys }) => {
517
+ migrateLegacyStorageKeys();
518
+ }).catch(() => {
519
+ });
520
+ void import('./cross-tab-session-FCAQTXUB.js').then(({ installCrossTabSessionListener }) => {
521
+ installCrossTabSessionListener();
522
+ }).catch(() => {
523
+ });
524
+ setIframeStorageMode(clientConfig.storageMode === "iframe");
525
+ if (typeof clientConfig.refreshBufferSeconds === "number") {
526
+ setRefreshBufferSeconds(clientConfig.refreshBufferSeconds);
527
+ }
528
+ if (clientConfig.editorPreviewMockHandler !== void 0) {
529
+ setEditorPreviewMockHandler(clientConfig.editorPreviewMockHandler);
530
+ }
531
+ const baseURL = config?.devApiUrl || config3.baseURL;
532
+ if (!baseURL) {
533
+ throw new Error("WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup.");
534
+ }
535
+ const timeout = config3.timeout ?? 5e4;
536
+ axiosInstance = axios.create({
537
+ baseURL,
538
+ timeout,
539
+ headers: {
540
+ "Content-Type": "application/json",
541
+ ...config3.headers
542
+ }
543
+ });
544
+ installCspViolationMonitor();
545
+ setRefreshCallback(getAuthRefreshToken);
546
+ hydrateSessionRefreshState();
547
+ axiosInstance.interceptors.request.use(async (requestConfig) => {
548
+ const requestUrl = getHttpUrl(requestConfig);
549
+ if (requestUrl && INVALID_PATH_SEGMENT_PATTERN.test(requestUrl)) {
550
+ logger.error("http", "blocked request with unresolved id in path", { url: requestUrl });
551
+ throw new Error(
552
+ `[woodsportal-sdk] Blocked request: URL contains an unresolved id segment: ${requestUrl}`
553
+ );
554
+ }
555
+ const previewMock = await resolveEditorPreviewMock(requestConfig);
556
+ if (previewMock) {
557
+ requestConfig.adapter = () => Promise.resolve({
558
+ data: previewMock.data,
559
+ status: previewMock.status ?? 200,
560
+ statusText: "OK",
561
+ headers: {},
562
+ config: requestConfig
563
+ });
564
+ }
565
+ markHttpRequestStart(requestConfig);
566
+ if (isHttpTracingEnabled()) {
567
+ logger.debug("http", "request start", {
568
+ method: getHttpMethod(requestConfig),
569
+ url: getHttpUrl(requestConfig),
570
+ phase: "start"
571
+ });
572
+ }
573
+ const token = getAccessToken();
574
+ if (token) {
575
+ setBearerAuthorization(requestConfig, token);
576
+ }
577
+ return requestConfig;
578
+ });
579
+ axiosInstance.interceptors.response.use(
580
+ (response) => {
581
+ if (isHttpTracingEnabled()) {
582
+ logger.debug("http", "request complete", {
583
+ method: getHttpMethod(response.config),
584
+ url: getHttpUrl(response.config),
585
+ status: response.status,
586
+ durationMs: getHttpRequestDurationMs(response.config),
587
+ phase: "complete"
588
+ });
589
+ }
590
+ return response;
591
+ },
592
+ (error) => {
593
+ if (axios.isAxiosError(error) && error.config) {
594
+ const status = error.response?.status;
595
+ if (status == null) {
596
+ const violation = findCspViolationFor(getHttpUrl(error.config));
597
+ if (violation) {
598
+ logger.error("http", "request blocked by the embedding page CSP", {
599
+ url: sanitizeHttpUrl(error.config.url),
600
+ violatedDirective: violation.effectiveDirective,
601
+ blockedUri: violation.blockedUri,
602
+ fix: `the embedding page's Content-Security-Policy must include "${violation.effectiveDirective} ${violation.blockedUri}"`
603
+ });
604
+ }
605
+ }
606
+ if (isHttpTracingEnabled()) {
607
+ logger.debug("http", "request failed", {
608
+ method: getHttpMethod(error.config),
609
+ url: getHttpUrl(error.config),
610
+ status,
611
+ durationMs: getHttpRequestDurationMs(error.config),
612
+ phase: "complete"
613
+ });
614
+ }
615
+ if (status != null && status >= 400 && status !== 401 && status !== 403) {
616
+ logger.warn("http", "HTTP error response", {
617
+ method: getHttpMethod(error.config),
618
+ url: sanitizeHttpUrl(error.config.url),
619
+ status,
620
+ statusText: error.response?.statusText,
621
+ data: sanitizeAxiosErrorData(error.response?.data)
622
+ });
623
+ }
624
+ notifyServiceUnavailable(error);
625
+ }
626
+ return handleAuthHttpError(error, axiosInstance);
627
+ }
628
+ );
629
+ stopVisibilityRefreshScheduler();
630
+ startVisibilityRefreshScheduler({
631
+ shouldRefresh: () => !isEditorPreviewMockActive() && isAccessTokenExpired(),
632
+ refresh: async () => {
633
+ try {
634
+ await refreshSession();
635
+ } catch {
636
+ }
637
+ }
638
+ });
639
+ logger.info("http", "HTTP client initialized", { baseURL });
640
+ }
641
+ function getAxiosInstance() {
642
+ if (!axiosInstance) {
643
+ initializeHttpClient({
644
+ baseURL: config2.baseURL,
645
+ timeout: 5e4
646
+ });
647
+ }
648
+ return axiosInstance;
649
+ }
650
+ function formatBooleanSearchParam(key, value) {
651
+ return value ? `${key}:1` : `${key}:`;
652
+ }
653
+ async function maybeEnsureValidRefresh() {
654
+ if (isEditorPreviewMockActive()) {
655
+ return;
656
+ }
657
+ await ensureValidRefresh();
658
+ }
659
+ var HttpClient = class {
660
+ static async get(url, params, options) {
661
+ await maybeEnsureValidRefresh();
662
+ const response = await getAxiosInstance().get(url, { params, ...options || {} });
663
+ return response.data;
664
+ }
665
+ static async post(url, data, options) {
666
+ await maybeEnsureValidRefresh();
667
+ const response = await getAxiosInstance().post(url, data, options);
668
+ return response.data;
669
+ }
670
+ static async put(url, data) {
671
+ await maybeEnsureValidRefresh();
672
+ const response = await getAxiosInstance().put(url, data);
673
+ return response.data;
674
+ }
675
+ static async delete(url, config4) {
676
+ await maybeEnsureValidRefresh();
677
+ const response = await getAxiosInstance().delete(url, config4);
678
+ return response.data;
679
+ }
680
+ static formatSearchParams(params) {
681
+ return Object.entries(params).filter(([, value]) => Boolean(value)).map(
682
+ ([k, v]) => ["type", "categories", "tags", "author", "manufacturer", "shops", "refund_reason"].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
683
+ ).join(";");
684
+ }
685
+ };
686
+ function mergeAuthRequestOptions(options) {
687
+ const devPortalId = config.devPortalId;
688
+ if (!devPortalId && !options?.headers) {
689
+ return options;
690
+ }
691
+ return {
692
+ ...options,
693
+ headers: {
694
+ ...devPortalId ? { "X-Dev-Portal-Id": devPortalId } : {},
695
+ ...options?.headers
696
+ }
697
+ };
698
+ }
699
+ var AuthHttpClient = class {
700
+ static async get(url, params, options) {
701
+ const response = await getAxiosInstance().get(url, { params, ...mergeAuthRequestOptions(options) });
702
+ return response.data;
703
+ }
704
+ static async post(url, data, options) {
705
+ const response = await getAxiosInstance().post(url, data, options);
706
+ return response.data;
707
+ }
708
+ static async put(url, data, options) {
709
+ const response = await getAxiosInstance().put(url, data, options);
710
+ return response.data;
711
+ }
712
+ };
713
+ function getFormErrors(error) {
714
+ if (axios.isAxiosError(error)) {
715
+ return error.response?.data?.message ?? null;
716
+ }
717
+ return null;
718
+ }
719
+ function getFieldErrors(error) {
720
+ if (axios.isAxiosError(error)) {
721
+ return error.response?.data?.errors ?? null;
722
+ }
723
+ return null;
724
+ }
725
+ async function postRefreshCookie(headers) {
726
+ const apiUrl = generateApiUrl({
727
+ route: API_ENDPOINTS.AUTH_REFRESH_COOKIE,
728
+ queryParams: { hubId: config.hubId }
729
+ });
730
+ return getAxiosInstance().post(apiUrl, {}, {
731
+ headers,
732
+ withCredentials: true,
733
+ skipGlobalAuthRedirect: true
734
+ });
735
+ }
736
+ var refreshCallbackInFlight = false;
737
+ function isRefreshCallbackInFlight() {
738
+ return refreshCallbackInFlight;
739
+ }
740
+ function clearSessionAfterRefreshFailure() {
741
+ if (isEditorPreviewMockActive()) {
742
+ return;
743
+ }
744
+ if (config3.shouldHandleUnauthorized?.() === false) {
745
+ return;
746
+ }
747
+ void config3.onLogout?.();
748
+ }
749
+ async function getAuthRefreshToken(refreshToken) {
750
+ refreshCallbackInFlight = true;
751
+ try {
752
+ const hubId = config.hubId;
753
+ if (hubId == null || String(hubId).trim() === "") {
754
+ return { token: null, success: false, failureKind: "missing_context" };
755
+ }
756
+ if (refreshToken == null || refreshToken.trim() === "") {
757
+ return { token: null, success: false, failureKind: "missing_refresh_token" };
758
+ }
759
+ const headers = {};
760
+ if (config.devPortalId) {
761
+ headers["X-Dev-Portal-Id"] = config.devPortalId;
762
+ }
763
+ let response;
764
+ if (config3.useCookieRefresh) {
765
+ try {
766
+ response = await postRefreshCookie(headers);
767
+ } catch {
768
+ const apiUrl = generateApiUrl({
769
+ route: API_ENDPOINTS.AUTH_REFRESH,
770
+ queryParams: { hubId: config.hubId }
771
+ });
772
+ try {
773
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, {
774
+ headers,
775
+ skipGlobalAuthRedirect: true
776
+ });
777
+ } catch (bodyError) {
778
+ const failureKind2 = classifyRefreshHttpError(bodyError);
779
+ if (shouldLogoutAfterRefreshFailure(failureKind2)) {
780
+ clearSessionAfterRefreshFailure();
781
+ }
782
+ if (failureKind2 === "transient") {
783
+ notifyServiceUnavailable(bodyError);
784
+ logger.warn("auth", bodyError instanceof Error ? bodyError.message : "token refresh failed", {
785
+ operation: "token refresh",
786
+ failureKind: failureKind2
787
+ });
788
+ } else {
789
+ logger.error("auth", bodyError instanceof Error ? bodyError.message : "token refresh failed", {
790
+ operation: "token refresh",
791
+ failureKind: failureKind2
792
+ });
793
+ }
794
+ return { token: null, success: false, failureKind: failureKind2, cause: bodyError };
795
+ }
796
+ }
797
+ } else {
798
+ const apiUrl = generateApiUrl({
799
+ route: API_ENDPOINTS.AUTH_REFRESH,
800
+ queryParams: { hubId: config.hubId }
801
+ });
802
+ try {
803
+ response = await getAxiosInstance().post(apiUrl, { refreshToken }, {
804
+ headers,
805
+ skipGlobalAuthRedirect: true
806
+ });
807
+ } catch (error) {
808
+ const failureKind2 = classifyRefreshHttpError(error);
809
+ if (shouldLogoutAfterRefreshFailure(failureKind2)) {
810
+ clearSessionAfterRefreshFailure();
811
+ }
812
+ if (failureKind2 === "transient") {
813
+ notifyServiceUnavailable(error);
814
+ logger.warn("auth", error instanceof Error ? error.message : "token refresh failed", {
815
+ operation: "token refresh",
816
+ failureKind: failureKind2
817
+ });
818
+ } else {
819
+ logger.error("auth", error instanceof Error ? error.message : "token refresh failed", {
820
+ operation: "token refresh",
821
+ failureKind: failureKind2
822
+ });
823
+ }
824
+ return { token: null, success: false, failureKind: failureKind2, cause: error };
825
+ }
826
+ }
827
+ const maybeData = response?.data?.data || response?.data;
828
+ const tokenData = maybeData?.tokenData || maybeData || {};
829
+ const newRefreshToken = tokenData?.refreshToken;
830
+ const token = tokenData?.token;
831
+ const expiresIn = tokenData?.expiresIn;
832
+ const rExpiresIn = tokenData?.refreshExpiresIn;
833
+ const rExpiresAt = tokenData?.refreshExpiresAt;
834
+ if (typeof newRefreshToken === "string") {
835
+ let rExpires = 0;
836
+ if (typeof rExpiresIn === "number") {
837
+ rExpires = Date.now() + rExpiresIn * 1e3;
838
+ } else if (typeof rExpiresAt === "number") {
839
+ rExpires = rExpiresAt * 1e3;
840
+ }
841
+ setRefreshToken(newRefreshToken, rExpires);
842
+ }
843
+ if (typeof token === "string") {
844
+ storAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
845
+ return { token, success: true };
846
+ }
847
+ const failureKind = classifyRefreshResponseWithoutToken(response);
848
+ if (shouldLogoutAfterRefreshFailure(failureKind)) {
849
+ clearSessionAfterRefreshFailure();
850
+ logger.error("auth", "refresh response missing access token", {
851
+ operation: "token refresh",
852
+ failureKind
853
+ });
854
+ } else {
855
+ logger.warn("auth", "refresh response missing access token", {
856
+ operation: "token refresh",
857
+ failureKind
858
+ });
859
+ }
860
+ return { token: null, success: false, failureKind };
861
+ } finally {
862
+ refreshCallbackInFlight = false;
863
+ }
864
+ }
865
+
866
+ // src/main/features/navigation/breadcrumbs.ts
867
+ var getBreadcrumbs = () => {
868
+ const search = getParam("b");
869
+ const breadcrumbs = decodeToBase64(search) || [];
870
+ if (!breadcrumbs && breadcrumbs.length < 1) return [];
871
+ const updated = breadcrumbs.map((breadcrumb, index) => {
872
+ return generatePath(breadcrumbs, breadcrumb, index);
873
+ });
874
+ if (updated.length < 1) {
875
+ const pathname = getPath();
876
+ const routeMenu = getRouteMenu(pathname);
877
+ return [
878
+ {
879
+ name: routeMenu?.title,
880
+ path: routeMenu?.path
881
+ }
882
+ ];
883
+ }
884
+ return updated;
885
+ };
886
+ var getTableTitle = (componentName, title, ticketTableTitle) => {
887
+ const search = getParam("b");
888
+ let breadcrumbs = decodeToBase64(search) || [];
889
+ if (breadcrumbs.length < 1) {
890
+ const pathname = getPath();
891
+ const routeMenu = getRouteMenu(pathname);
892
+ breadcrumbs = [
893
+ {
894
+ n: routeMenu?.title,
895
+ pt: routeMenu?.path
896
+ }
897
+ ];
898
+ }
899
+ let associatedtableTitleSingular = "";
900
+ let tableTitle = "";
901
+ let singularTableTitle = "";
902
+ if (breadcrumbs && breadcrumbs.length > 0) {
903
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
904
+ const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
905
+ const previousItem = breadcrumbs[breadcrumbs.length - 2];
906
+ const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
907
+ const singularLastName = last?.name;
908
+ associatedtableTitleSingular = singularLastName;
909
+ if (componentName != "ticket") {
910
+ tableTitle = previous?.name ? { last, previous } : { last };
911
+ singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
912
+ } else {
913
+ const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
914
+ tableTitle = { last: { name: title } };
915
+ singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
916
+ }
917
+ }
918
+ return { associatedtableTitleSingular, tableTitle, singularTableTitle };
919
+ };
920
+ var getFormTitle = (type, title, activeTab) => {
921
+ const search = getParam("b");
922
+ let breadcrumbs = decodeToBase64(search) || [];
923
+ if (breadcrumbs.length < 1) {
924
+ const pathname = getPath();
925
+ const routeMenu = getRouteMenu(pathname);
926
+ breadcrumbs = [
927
+ {
928
+ n: routeMenu?.title,
929
+ pt: routeMenu?.path
930
+ }
931
+ ];
932
+ }
933
+ let objectName = "";
934
+ let puralObjectName = "";
935
+ let dialogTitle = "";
936
+ if (breadcrumbs && breadcrumbs?.length > 0) {
937
+ const last = breadcrumbs[breadcrumbs?.length - 1];
938
+ const lastName = last?.n;
939
+ const mTitle = title;
940
+ if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
941
+ objectName = title;
942
+ puralObjectName = title;
943
+ dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
944
+ } else {
945
+ const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
946
+ objectName = singularLastName;
947
+ puralObjectName = lastName;
948
+ dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
949
+ }
950
+ }
951
+ return { objectName, puralObjectName, dialogTitle };
952
+ };
953
+ var nameTrancate = (name) => {
954
+ return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
955
+ };
956
+
957
+ // src/main/features/navigation/generate-url.ts
958
+ var makeLink = () => {
959
+ const search = getParam("b");
960
+ const makeLink2 = (props) => {
961
+ if (!search || "isPC" in props) {
962
+ return buildParentRoute(props);
963
+ } else {
964
+ const breadcrumbItems = decodeToBase64(search) || [];
965
+ return buildChildRoute(props, breadcrumbItems);
966
+ }
967
+ };
968
+ return { makeLink: makeLink2 };
969
+ };
970
+ var buildParentRoute = (props) => {
971
+ const pathname = getPath();
972
+ const routeMenu = getRouteMenu(pathname);
973
+ const breadcrumbItems = [
974
+ {
975
+ n: routeMenu?.title,
976
+ o_t_id: routeMenu?.path,
977
+ isHome: props?.isHome || false
978
+ }
979
+ ];
980
+ return buildChildRoute(props, breadcrumbItems);
981
+ };
982
+ var buildChildRoute = (props, breadcrumbItems) => {
983
+ const breadcrumbs = [...breadcrumbItems];
984
+ const breadcrumbType = breadcrumbStage(breadcrumbItems);
985
+ if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
986
+ const parent = {
987
+ n: props?.title || "",
988
+ o_t_id: props?.objectTypeId,
989
+ pt: `/association/${props?.objectTypeId}`,
990
+ isHome: props?.isHome || false,
991
+ prm: {
992
+ sort: "-hs_createdate",
993
+ s: "",
994
+ fPn: "hs_pipeline",
995
+ fO: "eq",
996
+ fV: "",
997
+ c: true,
998
+ isPC: props?.isPC,
999
+ v: "LIST",
1000
+ l: "10",
1001
+ p: 1
1002
+ }
1003
+ };
1004
+ breadcrumbs.push(parent);
1005
+ const newCrumb = {
1006
+ n: props?.name,
1007
+ o_t_id: props?.objectTypeId,
1008
+ o_r_id: props?.recordId
1009
+ };
1010
+ if (props?.nodeId) {
1011
+ newCrumb.n_id = props.nodeId;
1012
+ }
1013
+ breadcrumbs.push(newCrumb);
1014
+ } else if (breadcrumbType === "root") {
1015
+ const newCrumb = {
1016
+ n: props?.name,
1017
+ o_t_id: props?.objectTypeId,
1018
+ o_r_id: props?.recordId
1019
+ };
1020
+ if (props?.nodeId) {
1021
+ newCrumb.n_id = props.nodeId;
1022
+ }
1023
+ if (props?.isPC) {
1024
+ newCrumb.prm = {
1025
+ isPC: props?.isPC
1026
+ };
1027
+ }
1028
+ breadcrumbs.push(newCrumb);
1029
+ } else {
1030
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
1031
+ if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
1032
+ !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
1033
+ props?.isHome && !isMessingParentLastItem(breadcrumbItems)) {
1034
+ const newCrumb = {
1035
+ n: props?.name,
1036
+ o_t_id: props?.objectTypeId,
1037
+ o_r_id: props?.recordId
1038
+ };
1039
+ if (props?.nodeId) {
1040
+ newCrumb.n_id = props.nodeId;
1041
+ }
1042
+ if (props?.isPC) {
1043
+ newCrumb.prm = {
1044
+ isPC: props?.isPC
1045
+ };
1046
+ }
1047
+ breadcrumbs.push(newCrumb);
1048
+ } else {
1049
+ const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
1050
+ const parent = {
1051
+ n: props?.associationLabel || props?.name,
1052
+ o_t_id: props?.objectTypeId
1053
+ };
1054
+ if (props?.tableParam) {
1055
+ parent.prm = props?.tableParam;
1056
+ }
1057
+ if (props?.defPermissions) {
1058
+ parent.dp = props?.defPermissions;
1059
+ }
1060
+ if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
1061
+ breadcrumbs.push(parent);
1062
+ }
1063
+ if (props?.recordId) {
1064
+ const newCrumb = {
1065
+ n: props?.name,
1066
+ o_t_id: props?.objectTypeId,
1067
+ o_r_id: props?.recordId
1068
+ };
1069
+ if (props?.isPC) {
1070
+ newCrumb.prm = {
1071
+ isPC: props?.isPC
1072
+ };
1073
+ }
1074
+ breadcrumbs.push(newCrumb);
1075
+ }
1076
+ }
1077
+ }
1078
+ return generateUrl(props, breadcrumbs);
1079
+ };
1080
+
1081
+ // src/main/api/navigation-api.ts
1082
+ var navigationApi = {
1083
+ url: {
1084
+ makeLink,
1085
+ updateLink
1086
+ },
1087
+ route: {
1088
+ getDetails: getRouteDetails,
1089
+ getParamDetails
1090
+ },
1091
+ breadcrumbs: {
1092
+ getList: getBreadcrumbs,
1093
+ getTableTitle,
1094
+ getFormTitle
1095
+ }
1096
+ };
1097
+
1098
+ // src/main/core/utils/cache/builders.ts
1099
+ function buildCrmListPurgeTarget(objectTypeId, listQuery, recordIds) {
1100
+ const target = {
1101
+ domain: "crm_object_data",
1102
+ objectTypeId,
1103
+ views: ["list"],
1104
+ listQuery: listQuery ?? { page: 1, limit: 10, view: "LIST" }
1105
+ };
1106
+ if (recordIds?.length) {
1107
+ target.recordIds = recordIds;
1108
+ }
1109
+ return target;
1110
+ }
1111
+ function buildCrmSinglePurgeTarget(objectTypeId, recordIds, listQuery) {
1112
+ return {
1113
+ domain: "crm_object_data",
1114
+ objectTypeId,
1115
+ views: ["single"],
1116
+ recordIds,
1117
+ listQuery
1118
+ };
1119
+ }
1120
+ function buildEngagementPurgeTarget(objectTypeId, recordIds, views, options) {
1121
+ if (!recordIds.length) {
1122
+ throw new Error("recordIds is required for engagement purge views");
1123
+ }
1124
+ const target = {
1125
+ domain: "crm_object_data",
1126
+ objectTypeId,
1127
+ recordIds,
1128
+ views,
1129
+ fileIds: options?.fileIds,
1130
+ listQuery: options?.listQuery ?? { page: 1, limit: 10 }
1131
+ };
1132
+ if (options?.engagementItemIds?.length) {
1133
+ target.engagementItemIds = options.engagementItemIds;
1134
+ }
1135
+ return target;
1136
+ }
1137
+ function buildUserSessionPurgeTarget() {
1138
+ return { domain: "user_session" };
1139
+ }
1140
+ function buildPortalConfigPurgeTarget(objectTypeIds) {
1141
+ return {
1142
+ domain: "portal_object_config",
1143
+ objectTypeIds
1144
+ };
1145
+ }
1146
+ function mergePurgeTargets(...targets) {
1147
+ return targets;
1148
+ }
1149
+ function buildCachePurgeRequest(targets, options) {
1150
+ const request = {
1151
+ mode: options?.mode ?? "soft",
1152
+ warm: options?.warm ?? true,
1153
+ includeContactAccess: options?.includeContactAccess ?? true,
1154
+ includeShortOnHard: options?.includeShortOnHard ?? false,
1155
+ confirmPortalWide: options?.confirmPortalWide ?? false,
1156
+ targets
1157
+ };
1158
+ if (options?.postCrmWrite) {
1159
+ request.postCrmWrite = true;
1160
+ }
1161
+ if (options?.warmListDelayMs != null) {
1162
+ request.warmListDelayMs = options.warmListDelayMs;
1163
+ }
1164
+ return request;
1165
+ }
1166
+
1167
+ // src/main/core/http/auth-headers.ts
1168
+ function devPortalHeaders() {
1169
+ if (!config?.devPortalId) {
1170
+ return void 0;
1171
+ }
1172
+ return { "X-Dev-Portal-Id": config.devPortalId };
1173
+ }
1174
+ function mergeRequestOptions(token, extraHeaders) {
1175
+ const bearerToken = token || getAccessToken();
1176
+ const headers = { ...extraHeaders };
1177
+ if (bearerToken) {
1178
+ headers.Authorization = `Bearer ${bearerToken}`;
1179
+ }
1180
+ const devHeaders = devPortalHeaders();
1181
+ if (devHeaders) {
1182
+ Object.assign(headers, devHeaders);
1183
+ }
1184
+ return Object.keys(headers).length > 0 ? { headers } : void 0;
1185
+ }
1186
+ function hubIdQuery() {
1187
+ return config.hubId ? { hubId: config.hubId } : null;
1188
+ }
1189
+ function portalIdQuery(portalId) {
1190
+ const id = portalId ?? config.portalId ?? config.devPortalId;
1191
+ if (id === null || id === void 0 || id === "") {
1192
+ return void 0;
1193
+ }
1194
+ return { portalId: String(id) };
1195
+ }
1196
+
1197
+ // src/main/features/auth/client/mfa-client.ts
1198
+ var mfaPortalQuery = (portalId) => portalIdQuery(portalId) ?? null;
1199
+ var mfaClient = {
1200
+ verifyOtp: (data) => AuthHttpClient.post(generateApiUrl({ route: API_ENDPOINTS.VERIFY_OTP, queryParams: hubIdQuery() }), data, mergeRequestOptions(data.token)),
1201
+ sendPendingOtp: (data) => AuthHttpClient.post(API_ENDPOINTS.MFA_PENDING_OTP_SEND, data, mergeRequestOptions(data.token)),
1202
+ pendingPasskeyOptions: (data) => AuthHttpClient.post(API_ENDPOINTS.MFA_PENDING_PASSKEY_OPTIONS, data, mergeRequestOptions(data.token)),
1203
+ pendingPasskeyVerify: (data) => AuthHttpClient.post(
1204
+ generateApiUrl({ route: API_ENDPOINTS.MFA_PENDING_PASSKEY_VERIFY, queryParams: hubIdQuery() }),
1205
+ data,
1206
+ mergeRequestOptions(data.token)
1207
+ ),
1208
+ getStatus: (query) => HttpClient.get(
1209
+ generateApiUrl({
1210
+ route: API_ENDPOINTS.MFA_STATUS,
1211
+ queryParams: mfaPortalQuery(query?.portalId)
1212
+ })
1213
+ ),
1214
+ setPreferences: (data, query) => HttpClient.put(
1215
+ generateApiUrl({
1216
+ route: API_ENDPOINTS.MFA_PREFERENCES,
1217
+ queryParams: mfaPortalQuery(query?.portalId)
1218
+ }),
1219
+ data
1220
+ ),
1221
+ startPhoneVerify: (data, query) => HttpClient.post(
1222
+ generateApiUrl({
1223
+ route: API_ENDPOINTS.MFA_PHONE_VERIFY_START,
1224
+ queryParams: mfaPortalQuery(query?.portalId)
1225
+ }),
1226
+ data
1227
+ ),
1228
+ confirmPhoneVerify: (data, query) => HttpClient.post(
1229
+ generateApiUrl({
1230
+ route: API_ENDPOINTS.MFA_PHONE_VERIFY_CONFIRM,
1231
+ queryParams: mfaPortalQuery(query?.portalId)
1232
+ }),
1233
+ data
1234
+ ),
1235
+ totpEnrollStart: (query) => HttpClient.post(
1236
+ generateApiUrl({
1237
+ route: API_ENDPOINTS.MFA_TOTP_ENROLL_START,
1238
+ queryParams: mfaPortalQuery(query?.portalId)
1239
+ }),
1240
+ null
1241
+ ),
1242
+ totpEnrollVerify: (data) => HttpClient.post(
1243
+ generateApiUrl({
1244
+ route: API_ENDPOINTS.MFA_TOTP_ENROLL_VERIFY,
1245
+ queryParams: mfaPortalQuery(data.portalId)
1246
+ }),
1247
+ data
1248
+ ),
1249
+ totpDisable: (data, query) => HttpClient.post(
1250
+ generateApiUrl({
1251
+ route: API_ENDPOINTS.MFA_TOTP_DISABLE,
1252
+ queryParams: mfaPortalQuery(query?.portalId)
1253
+ }),
1254
+ data
1255
+ ),
1256
+ phoneUnverify: (data, query) => HttpClient.post(
1257
+ generateApiUrl({
1258
+ route: API_ENDPOINTS.MFA_PHONE_UNVERIFY,
1259
+ queryParams: mfaPortalQuery(query?.portalId)
1260
+ }),
1261
+ data
1262
+ ),
1263
+ backupCodesRegenerate: (data, query) => HttpClient.post(
1264
+ generateApiUrl({
1265
+ route: API_ENDPOINTS.MFA_BACKUP_CODES_REGENERATE,
1266
+ queryParams: mfaPortalQuery(query?.portalId)
1267
+ }),
1268
+ data
1269
+ ),
1270
+ optOut: (data, query) => HttpClient.post(
1271
+ generateApiUrl({
1272
+ route: API_ENDPOINTS.MFA_OPT_OUT,
1273
+ queryParams: mfaPortalQuery(query?.portalId)
1274
+ }),
1275
+ data
1276
+ ),
1277
+ webauthnRegisterOptions: (query) => HttpClient.post(
1278
+ generateApiUrl({
1279
+ route: API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_OPTIONS,
1280
+ queryParams: mfaPortalQuery(query?.portalId)
1281
+ }),
1282
+ null,
1283
+ mergeRequestOptions(void 0)
1284
+ ),
1285
+ webauthnRegisterVerify: (data) => HttpClient.post(
1286
+ generateApiUrl({
1287
+ route: API_ENDPOINTS.MFA_WEBAUTHN_REGISTER_VERIFY,
1288
+ queryParams: mfaPortalQuery(data.portalId)
1289
+ }),
1290
+ data,
1291
+ mergeRequestOptions(void 0)
1292
+ ),
1293
+ webauthnAuthOptions: (query) => HttpClient.post(
1294
+ generateApiUrl({
1295
+ route: API_ENDPOINTS.MFA_WEBAUTHN_AUTH_OPTIONS,
1296
+ queryParams: mfaPortalQuery(query?.portalId)
1297
+ }),
1298
+ null,
1299
+ mergeRequestOptions(void 0)
1300
+ ),
1301
+ webauthnAuthVerify: (data) => HttpClient.post(
1302
+ generateApiUrl({
1303
+ route: API_ENDPOINTS.MFA_WEBAUTHN_AUTH_VERIFY,
1304
+ queryParams: mfaPortalQuery(data.portalId)
1305
+ }),
1306
+ data,
1307
+ mergeRequestOptions(void 0)
1308
+ ),
1309
+ listWebauthnCredentials: (query) => HttpClient.get(
1310
+ generateApiUrl({
1311
+ route: API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIALS,
1312
+ queryParams: mfaPortalQuery(query?.portalId)
1313
+ }),
1314
+ void 0,
1315
+ mergeRequestOptions(void 0)
1316
+ ),
1317
+ deleteWebauthnCredential: (credentialRecordId, query) => HttpClient.delete(
1318
+ generateApiUrl({
1319
+ route: API_ENDPOINTS.MFA_WEBAUTHN_CREDENTIAL_DELETE,
1320
+ params: { credentialRecordId: String(credentialRecordId) },
1321
+ queryParams: mfaPortalQuery(query?.portalId)
1322
+ })
1323
+ ),
1324
+ passkeyLoginOptions: (data) => AuthHttpClient.post(
1325
+ generateApiUrl({ route: API_ENDPOINTS.PASSKEY_LOGIN_OPTIONS, queryParams: hubIdQuery() }),
1326
+ data,
1327
+ mergeRequestOptions(void 0)
1328
+ ),
1329
+ passkeyLoginVerify: (data) => AuthHttpClient.post(
1330
+ generateApiUrl({ route: API_ENDPOINTS.PASSKEY_LOGIN_VERIFY, queryParams: hubIdQuery() }),
1331
+ data,
1332
+ mergeRequestOptions(void 0)
1333
+ )
1334
+ };
1335
+
1336
+ // src/main/features/crm/helpers/normalize-table-list-params.ts
1337
+ function resolveListTableParams(payload) {
1338
+ const param = tableUiActions.getTableParam(payload?.companyAsMediator, payload?.currentPageOverride);
1339
+ if (payload?.tableParams && typeof payload.tableParams === "object") {
1340
+ return { ...param, ...payload.tableParams };
1341
+ }
1342
+ return { ...param };
1343
+ }
1344
+ function applyBoardPaginationToParams(param, tableParams) {
1345
+ const stageId = tableParams.stageId;
1346
+ const page = tableParams.page;
1347
+ if (stageId !== void 0 && stageId !== null && stageId !== "") {
1348
+ param.stageId = stageId;
1349
+ }
1350
+ if (param.view === "BOARD" && page !== void 0) {
1351
+ param.page = page;
1352
+ }
1353
+ return param;
1354
+ }
1355
+ function finalizeBoardListQueryParams(param, _context) {
1356
+ const { stageId, nextPage, view, selectedPipeline, selectedStage } = tableUiStore.getState();
1357
+ if (view) {
1358
+ param.view = view;
1359
+ }
1360
+ if (selectedPipeline !== void 0 && selectedPipeline !== null && String(selectedPipeline) !== "") {
1361
+ param.filterValue = selectedPipeline;
1362
+ }
1363
+ const effectiveView = String(param.view ?? view ?? "");
1364
+ const hadSelectedStageKey = Object.prototype.hasOwnProperty.call(param, "selectedStage");
1365
+ const urlSelectedStage = param.selectedStage;
1366
+ delete param.selectedStage;
1367
+ if (effectiveView === "LIST") {
1368
+ const pipelineValue = param.filterValue;
1369
+ const hasPipeline = pipelineValue !== void 0 && pipelineValue !== null && String(pipelineValue) !== "";
1370
+ const fromStore = selectedStage !== void 0 && selectedStage !== null && String(selectedStage) !== "" ? String(selectedStage) : "";
1371
+ const fromUrl = urlSelectedStage !== void 0 && urlSelectedStage !== null && String(urlSelectedStage) !== "" ? String(urlSelectedStage) : "";
1372
+ const listStage = hadSelectedStageKey ? fromUrl : fromStore;
1373
+ if (listStage && hasPipeline) {
1374
+ param.stageId = listStage;
1375
+ if (!fromStore && fromUrl) {
1376
+ tableUiStore.setState({ selectedStage: fromUrl });
1377
+ }
1378
+ } else {
1379
+ delete param.stageId;
1380
+ }
1381
+ return param;
1382
+ }
1383
+ return applyBoardPaginationToParams(param, {
1384
+ stageId,
1385
+ page: stageId ? nextPage : 1
1386
+ });
1387
+ }
1388
+
1389
+ // src/main/core/utils/cache/resolveCrmListPurgeQuery.ts
1390
+ var LIST_QUERY_KEYS = [
1391
+ "sort",
1392
+ "search",
1393
+ "filterPropertyName",
1394
+ "filterOperator",
1395
+ "filterValue",
1396
+ "page",
1397
+ "limit",
1398
+ "view",
1399
+ "mediatorObjectTypeId",
1400
+ "mediatorObjectRecordId",
1401
+ "parentObjectTypeId",
1402
+ "parentObjectRecordId",
1403
+ "stageId",
1404
+ "after"
1405
+ ];
1406
+ var PURGE_FILTER_KEYS = ["sort", "filterPropertyName", "filterOperator", "filterValue", "view", "page", "limit"];
1407
+ function hasPurgeFilterContext(raw) {
1408
+ if (!raw || typeof raw !== "object") {
1409
+ return false;
1410
+ }
1411
+ return PURGE_FILTER_KEYS.some((key) => {
1412
+ const value = raw[key];
1413
+ return value !== void 0 && value !== null && String(value).length > 0;
1414
+ });
1415
+ }
1416
+ function mergeLiveTableUiState(raw) {
1417
+ const state = tableUiStore.getState();
1418
+ const merged = { ...raw ?? {} };
1419
+ if (!merged.sort && state.sort) {
1420
+ merged.sort = state.sort;
1421
+ }
1422
+ if (!merged.search && state.search) {
1423
+ merged.search = state.search;
1424
+ }
1425
+ if (!merged.filterPropertyName && state.filterPropertyName) {
1426
+ merged.filterPropertyName = state.filterPropertyName;
1427
+ }
1428
+ if (!merged.filterOperator && state.filterOperator) {
1429
+ merged.filterOperator = state.filterOperator;
1430
+ }
1431
+ if (!merged.filterValue && state.selectedPipeline) {
1432
+ merged.filterValue = state.selectedPipeline;
1433
+ }
1434
+ if (merged.limit === void 0 && state.limit) {
1435
+ merged.limit = state.limit;
1436
+ }
1437
+ if (merged.page === void 0 && state.page !== void 0 && state.page !== "") {
1438
+ merged.page = state.page;
1439
+ }
1440
+ if (!merged.view && state.view) {
1441
+ merged.view = state.view;
1442
+ }
1443
+ if (merged.isPrimaryCompany === void 0 && state.isPrimaryCompany !== null) {
1444
+ merged.isPrimaryCompany = state.isPrimaryCompany;
1445
+ }
1446
+ return applyBoardPaginationToParams(merged, {
1447
+ stageId: state.stageId,
1448
+ page: state.stageId ? state.nextPage : 1
1449
+ });
1450
+ }
1451
+ function listQueryCacheKey(q) {
1452
+ return JSON.stringify({
1453
+ ...q,
1454
+ stageId: q.stageId ?? ""
1455
+ });
1456
+ }
1457
+ function toCachePurgeListQuery(raw) {
1458
+ if (!raw || typeof raw !== "object") {
1459
+ return { page: 1, limit: 10, view: "LIST" };
1460
+ }
1461
+ const q = {};
1462
+ for (const key of LIST_QUERY_KEYS) {
1463
+ const value = raw[key];
1464
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1465
+ q[key] = String(value);
1466
+ }
1467
+ }
1468
+ if (raw.page !== void 0 && raw.page !== null) {
1469
+ const page = Number(raw.page);
1470
+ if (!Number.isNaN(page) && page > 0) {
1471
+ q.page = page;
1472
+ }
1473
+ }
1474
+ if (raw.limit !== void 0 && raw.limit !== null) {
1475
+ const limit = Number(raw.limit);
1476
+ if (!Number.isNaN(limit) && limit > 0) {
1477
+ q.limit = limit;
1478
+ }
1479
+ }
1480
+ const isPc = raw.isPrimaryCompany ?? raw.isPC;
1481
+ if (isPc !== void 0 && isPc !== null) {
1482
+ q.isPrimaryCompany = isPc === true || isPc === "true" || isPc === 1 || isPc === "1";
1483
+ }
1484
+ const view = raw.view;
1485
+ if (typeof view === "string") {
1486
+ q.view = view.toUpperCase() === "BOARD" ? "BOARD" : "LIST";
1487
+ }
1488
+ if (Object.keys(q).length === 0) {
1489
+ return { page: 1, limit: 10, view: "LIST" };
1490
+ }
1491
+ if (q.page === void 0) {
1492
+ q.page = 1;
1493
+ }
1494
+ if (q.limit === void 0) {
1495
+ q.limit = 10;
1496
+ }
1497
+ if (q.view === void 0) {
1498
+ q.view = "LIST";
1499
+ }
1500
+ return q;
1501
+ }
1502
+ function expandListPurgeQueriesForCrmWrite(base) {
1503
+ const listQuery = { ...base, view: "LIST" };
1504
+ delete listQuery.stageId;
1505
+ const boardQuery = { ...base, view: "BOARD" };
1506
+ const seen = /* @__PURE__ */ new Set();
1507
+ const expanded = [];
1508
+ for (const query of [listQuery, boardQuery]) {
1509
+ const key = listQueryCacheKey(query);
1510
+ if (seen.has(key)) {
1511
+ continue;
1512
+ }
1513
+ seen.add(key);
1514
+ expanded.push(query);
1515
+ }
1516
+ return expanded;
1517
+ }
1518
+ function applyFilterValueFromPipelineState(query) {
1519
+ if (query.filterValue) {
1520
+ return query;
1521
+ }
1522
+ const { filterPropertyName, filterOperator } = query;
1523
+ if (!filterPropertyName || !filterOperator) {
1524
+ return query;
1525
+ }
1526
+ const selectedPipeline = tableUiStore.getState().selectedPipeline;
1527
+ if (!selectedPipeline) {
1528
+ return query;
1529
+ }
1530
+ return { ...query, filterValue: selectedPipeline };
1531
+ }
1532
+ function resolveCrmListPurgeQuery(options) {
1533
+ let raw;
1534
+ if (options.componentName === "sidebarTable" && options.hubspotObjectTypeId) {
1535
+ raw = options.multiObjectsQueryParams?.[String(options.hubspotObjectTypeId)] ?? null;
1536
+ } else {
1537
+ raw = options.tableQueryParams ?? null;
1538
+ }
1539
+ if (!hasPurgeFilterContext(raw)) {
1540
+ raw = mergeLiveTableUiState(raw);
1541
+ }
1542
+ let base = applyFilterValueFromPipelineState(toCachePurgeListQuery(raw ?? void 0));
1543
+ if (!options.writeContext || Object.keys(options.writeContext).length === 0) {
1544
+ return base;
1545
+ }
1546
+ base = {
1547
+ ...base,
1548
+ ...options.writeContext
1549
+ };
1550
+ return applyFilterValueFromPipelineState(base);
1551
+ }
1552
+
1553
+ // src/main/core/utils/cache/crmCacheRefresh.ts
1554
+ function buildPostWriteListPurgeTargets(objectTypeId, listQuery, recordIds) {
1555
+ const base = listQuery ?? { page: 1, limit: 10, view: "LIST" };
1556
+ return expandListPurgeQueriesForCrmWrite(base).map((query) => buildCrmListPurgeTarget(objectTypeId, query, recordIds));
1557
+ }
1558
+ async function purgeCrmObjectDataCache(options) {
1559
+ const result = await purgeCrmListCache(options);
1560
+ return result.ok;
1561
+ }
1562
+ async function purgeCrmListCacheAfterCrmWrite(options) {
1563
+ const objectTypeId = options.objectTypeId?.trim();
1564
+ if (!objectTypeId) {
1565
+ return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
1566
+ }
1567
+ return purgeCrmCombined({
1568
+ ...options,
1569
+ postCrmWrite: true,
1570
+ targets: buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds)
1571
+ });
1572
+ }
1573
+ async function purgeCrmDetailAndListAfterCrmWrite(options) {
1574
+ const objectTypeId = options.objectTypeId?.trim();
1575
+ if (!objectTypeId || !options.recordIds?.length) {
1576
+ return {
1577
+ ok: false,
1578
+ errorCode: "VALIDATION",
1579
+ message: "objectTypeId and recordIds are required"
1580
+ };
1581
+ }
1582
+ return purgeCrmCombined({
1583
+ ...options,
1584
+ postCrmWrite: true,
1585
+ targets: mergePurgeTargets(
1586
+ ...buildPostWriteListPurgeTargets(objectTypeId, options.listQuery, options.recordIds),
1587
+ buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery)
1588
+ )
1589
+ });
1590
+ }
1591
+ async function purgeCrmListCache(options) {
1592
+ const objectTypeId = options.objectTypeId?.trim();
1593
+ if (!objectTypeId) {
1594
+ return { ok: false, errorCode: "VALIDATION", message: "objectTypeId is required" };
1595
+ }
1596
+ const target = buildCrmListPurgeTarget(objectTypeId, options.listQuery, options.recordIds);
1597
+ const request = buildCachePurgeRequest([target], {
1598
+ mode: options.mode,
1599
+ warm: options.warm,
1600
+ postCrmWrite: options.postCrmWrite,
1601
+ warmListDelayMs: options.warmListDelayMs
1602
+ });
1603
+ return createCachePurgeJob(request, {
1604
+ idempotencyKey: options.idempotencyKey,
1605
+ waitForWarm: options.waitForWarm,
1606
+ pollTimeoutMs: options.pollTimeoutMs,
1607
+ pollIntervalMs: options.pollIntervalMs
1608
+ });
1609
+ }
1610
+ async function purgeCrmRecordCache(options) {
1611
+ const objectTypeId = options.objectTypeId?.trim();
1612
+ if (!objectTypeId || !options.recordIds?.length) {
1613
+ return {
1614
+ ok: false,
1615
+ errorCode: "VALIDATION",
1616
+ message: "objectTypeId and recordIds are required"
1617
+ };
1618
+ }
1619
+ const target = buildCrmSinglePurgeTarget(objectTypeId, options.recordIds, options.listQuery);
1620
+ const request = buildCachePurgeRequest([target], {
1621
+ mode: options.mode,
1622
+ warm: options.warm,
1623
+ postCrmWrite: options.postCrmWrite,
1624
+ warmListDelayMs: options.warmListDelayMs
1625
+ });
1626
+ return createCachePurgeJob(request, {
1627
+ idempotencyKey: options.idempotencyKey,
1628
+ waitForWarm: options.waitForWarm,
1629
+ pollTimeoutMs: options.pollTimeoutMs,
1630
+ pollIntervalMs: options.pollIntervalMs
1631
+ });
1632
+ }
1633
+ async function purgeEngagementCaches(options) {
1634
+ return purgeEngagementCachesInternal(options);
1635
+ }
1636
+ async function purgeEngagementCachesAfterCrmWrite(options) {
1637
+ return purgeEngagementCachesInternal({
1638
+ ...options,
1639
+ postCrmWrite: true
1640
+ });
1641
+ }
1642
+ async function purgeEngagementCachesInternal(options) {
1643
+ const objectTypeId = options.objectTypeId?.trim();
1644
+ if (!objectTypeId || !options.recordIds?.length || !options.views?.length) {
1645
+ return {
1646
+ ok: false,
1647
+ errorCode: "VALIDATION",
1648
+ message: "objectTypeId, recordIds, and views are required"
1649
+ };
1650
+ }
1651
+ const target = buildEngagementPurgeTarget(objectTypeId, options.recordIds, options.views, {
1652
+ fileIds: options.fileIds,
1653
+ listQuery: options.listQuery,
1654
+ engagementItemIds: options.engagementItemIds
1655
+ });
1656
+ const request = buildCachePurgeRequest([target], {
1657
+ mode: options.mode,
1658
+ warm: options.warm,
1659
+ postCrmWrite: options.postCrmWrite,
1660
+ warmListDelayMs: options.warmListDelayMs
1661
+ });
1662
+ return createCachePurgeJob(request, {
1663
+ idempotencyKey: options.idempotencyKey,
1664
+ waitForWarm: options.waitForWarm,
1665
+ pollTimeoutMs: options.pollTimeoutMs,
1666
+ pollIntervalMs: options.pollIntervalMs
1667
+ });
1668
+ }
1669
+ async function purgeCrmAssociationCaches(options) {
1670
+ const parentObjectTypeId = options.parentObjectTypeId?.trim();
1671
+ const parentRecordId = options.parentRecordId?.trim();
1672
+ if (!parentObjectTypeId || !parentRecordId) {
1673
+ return {
1674
+ ok: false,
1675
+ errorCode: "VALIDATION",
1676
+ message: "parentObjectTypeId and parentRecordId are required"
1677
+ };
1678
+ }
1679
+ const childIds = [
1680
+ ...options.childObjectTypeIds ?? [],
1681
+ ...options.objectTypeId ? [options.objectTypeId] : []
1682
+ ].map((id) => String(id).trim()).filter((id, index, all) => id.length > 0 && all.indexOf(id) === index);
1683
+ const parentListQuery = {
1684
+ ...options.listQuery ?? { page: 1, limit: 10, view: "LIST" },
1685
+ parentObjectTypeId,
1686
+ parentObjectRecordId: parentRecordId
1687
+ };
1688
+ const listTargets = childIds.flatMap(
1689
+ (childId) => options.postCrmWrite ? buildPostWriteListPurgeTargets(childId, parentListQuery, options.recordIds) : [buildCrmListPurgeTarget(childId, parentListQuery, options.recordIds)]
1690
+ );
1691
+ const singleTarget = buildCrmSinglePurgeTarget(parentObjectTypeId, [parentRecordId], parentListQuery);
1692
+ const engagementViews = options.engagementViews?.filter(Boolean) ?? [];
1693
+ const engagementTargets = engagementViews.length > 0 ? [
1694
+ buildEngagementPurgeTarget(parentObjectTypeId, [parentRecordId], engagementViews, {
1695
+ listQuery: parentListQuery,
1696
+ fileIds: options.fileIds,
1697
+ engagementItemIds: options.engagementItemIds
1698
+ })
1699
+ ] : [];
1700
+ if (listTargets.length === 0 && engagementTargets.length === 0) {
1701
+ return purgeCrmCombined({
1702
+ ...options,
1703
+ targets: [singleTarget]
1704
+ });
1705
+ }
1706
+ return purgeCrmCombined({
1707
+ ...options,
1708
+ objectTypeId: childIds[0] ?? parentObjectTypeId,
1709
+ targets: mergePurgeTargets(...listTargets, singleTarget, ...engagementTargets)
1710
+ });
1711
+ }
1712
+ async function purgeCrmCombined(options) {
1713
+ const request = buildCachePurgeRequest(options.targets, {
1714
+ mode: options.mode,
1715
+ warm: options.warm,
1716
+ postCrmWrite: options.postCrmWrite,
1717
+ warmListDelayMs: options.warmListDelayMs
1718
+ });
1719
+ return createCachePurgeJob(request, {
1720
+ idempotencyKey: options.idempotencyKey,
1721
+ waitForWarm: options.waitForWarm,
1722
+ pollTimeoutMs: options.pollTimeoutMs,
1723
+ pollIntervalMs: options.pollIntervalMs
1724
+ });
1725
+ }
1726
+
1727
+ // src/main/core/utils/cache/extractHubspotRecordIdFromWriteResponse.ts
1728
+ function extractHubspotRecordIdFromWriteResponse(response) {
1729
+ if (response == null || typeof response !== "object") {
1730
+ return void 0;
1731
+ }
1732
+ const root = response;
1733
+ const data = root.data;
1734
+ if (data != null && typeof data === "object") {
1735
+ const fromData = idFromRecordPayload(data);
1736
+ if (fromData) {
1737
+ return fromData;
1738
+ }
1739
+ }
1740
+ return idFromRecordPayload(root);
1741
+ }
1742
+ function idFromRecordPayload(payload) {
1743
+ const id = payload.id;
1744
+ if (id !== void 0 && id !== null && String(id).length > 0) {
1745
+ return String(id);
1746
+ }
1747
+ const hsObjectId = payload.hs_object_id;
1748
+ if (hsObjectId !== void 0 && hsObjectId !== null && String(hsObjectId).length > 0) {
1749
+ return String(hsObjectId);
1750
+ }
1751
+ return void 0;
1752
+ }
1753
+
1754
+ // src/main/core/utils/cache/extractEngagementItemIdFromWriteResponse.ts
1755
+ function extractEngagementItemIdFromWriteResponse(response) {
1756
+ if (response == null || typeof response !== "object") {
1757
+ return void 0;
1758
+ }
1759
+ const root = response;
1760
+ const candidates = [];
1761
+ const data = root.data;
1762
+ if (data != null && typeof data === "object") {
1763
+ const dataObj = data;
1764
+ candidates.push(dataObj);
1765
+ const nested = dataObj.response;
1766
+ if (nested != null && typeof nested === "object") {
1767
+ candidates.push(nested);
1768
+ }
1769
+ }
1770
+ const topResponse = root.response;
1771
+ if (topResponse != null && typeof topResponse === "object") {
1772
+ candidates.push(topResponse);
1773
+ }
1774
+ candidates.push(root);
1775
+ for (const payload of candidates) {
1776
+ const id = engagementIdFromPayload(payload);
1777
+ if (id) {
1778
+ return id;
1779
+ }
1780
+ }
1781
+ return void 0;
1782
+ }
1783
+ function engagementIdFromPayload(payload) {
1784
+ const fromHs = fieldValue(payload.hs_object_id);
1785
+ if (fromHs) {
1786
+ return fromHs;
1787
+ }
1788
+ const fromId = fieldValue(payload.id);
1789
+ if (fromId) {
1790
+ return fromId;
1791
+ }
1792
+ return void 0;
1793
+ }
1794
+ function fieldValue(raw) {
1795
+ if (raw == null) {
1796
+ return void 0;
1797
+ }
1798
+ if (typeof raw === "object") {
1799
+ const value = raw.value;
1800
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1801
+ return String(value);
1802
+ }
1803
+ return void 0;
1804
+ }
1805
+ const s = String(raw);
1806
+ return s.length > 0 ? s : void 0;
1807
+ }
1808
+
1809
+ // src/main/core/http/client-context.ts
1810
+ function getParamDetails2(...args) {
1811
+ return navigationApi.route.getParamDetails(...args);
1812
+ }
1813
+ var recordWriteContext = (paramsObject) => {
1814
+ if (!paramsObject) {
1815
+ return void 0;
1816
+ }
1817
+ const context = {};
1818
+ const keys = ["parentObjectTypeId", "parentObjectRecordId", "mediatorObjectTypeId", "mediatorObjectRecordId"];
1819
+ keys.forEach((key) => {
1820
+ const value = paramsObject[key];
1821
+ if (value !== void 0 && value !== null && String(value).length > 0) {
1822
+ context[key] = String(value);
1823
+ }
1824
+ });
1825
+ return Object.keys(context).length > 0 ? context : void 0;
1826
+ };
1827
+ var triggerPostWriteListPurge = async (props) => {
1828
+ const objectTypeId = props.hubspotObjectTypeId;
1829
+ if (!objectTypeId) {
1830
+ return;
1831
+ }
1832
+ if (getClientType() === "mobile") {
1833
+ return;
1834
+ }
1835
+ const { queryParams, multiObjectsQueryParams } = tableStore.getState();
1836
+ const writeContext = recordWriteContext(props.paramsObject);
1837
+ const listQuery = resolveCrmListPurgeQuery({
1838
+ componentName: props.componentName,
1839
+ hubspotObjectTypeId: objectTypeId,
1840
+ tableQueryParams: queryParams,
1841
+ multiObjectsQueryParams,
1842
+ writeContext
1843
+ });
1844
+ const recordIds = props.recordId ? [String(props.recordId)] : void 0;
1845
+ const parentObjectTypeId = writeContext?.parentObjectTypeId;
1846
+ const parentRecordId = writeContext?.parentObjectRecordId;
1847
+ try {
1848
+ if (parentObjectTypeId && parentRecordId) {
1849
+ await purgeCrmAssociationCaches({
1850
+ objectTypeId: String(objectTypeId),
1851
+ parentObjectTypeId,
1852
+ parentRecordId,
1853
+ listQuery,
1854
+ recordIds,
1855
+ postCrmWrite: true,
1856
+ waitForWarm: true,
1857
+ pollTimeoutMs: 45e3
1858
+ });
1859
+ return;
1860
+ }
1861
+ await purgeCrmListCacheAfterCrmWrite({
1862
+ objectTypeId: String(objectTypeId),
1863
+ listQuery,
1864
+ recordIds,
1865
+ waitForWarm: true,
1866
+ pollTimeoutMs: 45e3
1867
+ });
1868
+ } catch {
1869
+ }
1870
+ };
1871
+ var mergeRecordWriteBody = (payload, paramsObject, options) => {
1872
+ const base = { ...payload || {} };
1873
+ const context = recordWriteContext(paramsObject);
1874
+ if (context) {
1875
+ base.context = context;
1876
+ }
1877
+ if (options && Object.keys(options).length > 0) {
1878
+ base.options = options;
1879
+ }
1880
+ return base;
1881
+ };
1882
+
1883
+ // src/main/features/auth/client/authentication-client.ts
1884
+ function hubPortalQuery(hubId, portalId) {
1885
+ const queryParams = {};
1886
+ if (hubId != null) {
1887
+ queryParams.hubId = hubId;
1888
+ }
1889
+ const resolvedPortalId = portalId ?? (config?.devPortalId != null && String(config.devPortalId).trim() !== "" ? Number(config.devPortalId) : void 0);
1890
+ if (resolvedPortalId != null && !Number.isNaN(resolvedPortalId)) {
1891
+ queryParams.portalId = resolvedPortalId;
1892
+ }
1893
+ return Object.keys(queryParams).length > 0 ? queryParams : void 0;
1894
+ }
1895
+ var authenticationClient = {
1896
+ authentication: {
1897
+ preLogin: (data) => {
1898
+ const email = data.email ?? data.username;
1899
+ return AuthHttpClient.post(
1900
+ generateApiUrl({ route: API_ENDPOINTS.PRE_LOGIN, queryParams: hubPortalQuery(data.hubId, data.portalId) }),
1901
+ { email }
1902
+ );
1903
+ },
1904
+ login: (data) => {
1905
+ const queryParams = config.hubId ? { hubId: config.hubId } : null;
1906
+ const username = (data.username ?? data.email)?.trim();
1907
+ const body = {
1908
+ username,
1909
+ password: typeof data.password === "string" ? data.password.trim() : data.password,
1910
+ ...data.rememberMe != null ? { rememberMe: data.rememberMe } : {}
1911
+ };
1912
+ return AuthHttpClient.post(
1913
+ generateApiUrl({ route: API_ENDPOINTS.LOGIN, queryParams }),
1914
+ body,
1915
+ config?.devPortalId && {
1916
+ headers: {
1917
+ "X-Dev-Portal-Id": config.devPortalId
1918
+ }
1919
+ }
1920
+ );
1921
+ },
1922
+ verifyOtp: (data) => mfaClient.verifyOtp(data),
1923
+ verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
1924
+ register: (data) => AuthHttpClient.post("/register", data),
1925
+ resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
1926
+ resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, {
1927
+ ...data,
1928
+ token: typeof data.token === "string" ? data.token.trim() : data.token,
1929
+ newPassword: typeof data.newPassword === "string" ? data.newPassword.trim() : data.newPassword,
1930
+ confirmPassword: typeof data.confirmPassword === "string" ? data.confirmPassword.trim() : data.confirmPassword
1931
+ }),
1932
+ forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, {
1933
+ ...data,
1934
+ email: typeof data.email === "string" ? data.email.trim().toLowerCase() : data.email
1935
+ }),
1936
+ verifyForgotPasswordOtp: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD_OTP_VERIFY, data),
1937
+ registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
1938
+ verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
1939
+ resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
1940
+ logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null, {
1941
+ skipGlobalAuthRedirect: true
1942
+ }),
1943
+ clientSession: (payload) => AuthHttpClient.post(
1944
+ API_ENDPOINTS.CLIENT_SESSION,
1945
+ { refreshToken: payload.refreshToken ?? payload.accessToken },
1946
+ {
1947
+ headers: {
1948
+ Authorization: `Bearer ${payload.accessToken}`
1949
+ }
1950
+ }
1951
+ ),
1952
+ handoff: (payload) => AuthHttpClient.post(
1953
+ generateApiUrl({
1954
+ route: API_ENDPOINTS.AUTH_HANDOFF,
1955
+ queryParams: { hubId: payload.hubId }
1956
+ }),
1957
+ { code: payload.code }
1958
+ ),
1959
+ getLoginBootstrap: (payload) => AuthHttpClient.get(
1960
+ generateApiUrl({
1961
+ route: API_ENDPOINTS.LOGIN_BOOTSTRAP,
1962
+ queryParams: hubPortalQuery(payload?.hubId, payload?.portalId)
1963
+ })
1964
+ ),
1965
+ signInLink: {
1966
+ send: (data) => AuthHttpClient.post(
1967
+ generateApiUrl({
1968
+ route: API_ENDPOINTS.SIGN_IN_LINK_SEND,
1969
+ queryParams: hubPortalQuery(data.hubId, data.portalId)
1970
+ }),
1971
+ { email: data.email }
1972
+ ),
1973
+ verify: (data) => AuthHttpClient.post(API_ENDPOINTS.SIGN_IN_LINK_VERIFY, data),
1974
+ validateToken: (token) => AuthHttpClient.get(
1975
+ generateApiUrl({
1976
+ route: API_ENDPOINTS.SIGN_IN_LINK_VALIDATE,
1977
+ queryParams: { token }
1978
+ })
1979
+ )
1980
+ }
1981
+ },
1982
+ sso: {
1983
+ getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
1984
+ generateSsoUrl: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_URL, queryParams: payload?.queryParams })),
1985
+ ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
1986
+ },
1987
+ user: {
1988
+ me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
1989
+ profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
1990
+ profileUpdate: (props) => {
1991
+ const properties = props?.properties ?? props?.payload ?? {};
1992
+ return HttpClient.put(generateApiUrl({ route: API_ENDPOINTS.PROFILE_UPDATE, queryParams: props?.queryParams || {} }), { properties });
1993
+ },
1994
+ changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
1995
+ }
1996
+ };
1997
+
1998
+ // src/main/features/crm/client/crm-client.ts
1999
+ function resolveCrmObjectRouteParams(payload) {
2000
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId ?? payload?.params?.hubspotObjectTypeId;
2001
+ return {
2002
+ ...payload?.params || {},
2003
+ ...hubspotObjectTypeId ? { hubspotObjectTypeId } : {}
2004
+ };
2005
+ }
2006
+ var crmClient = {
2007
+ pipeline: {
2008
+ list: (payload = null, listTableParams = null) => {
2009
+ const params = resolveCrmObjectRouteParams(payload);
2010
+ const queryParams = payload?.queryParams;
2011
+ const { paramsObject } = getParamDetails2({ type: payload?.componentName });
2012
+ const userData = userStore.getState().profile;
2013
+ const apiParams = {};
2014
+ const tableParams = payload?.tableParams && typeof payload.tableParams === "object" ? payload.tableParams : {};
2015
+ const parentObjectTypeId = paramsObject?.parentObjectTypeId ?? listTableParams?.parentObjectTypeId ?? tableParams.parentObjectTypeId;
2016
+ if (parentObjectTypeId) {
2017
+ apiParams.parentObjectTypeId = parentObjectTypeId;
2018
+ } else if (payload?.isHome && userData?.crmProfile?.info?.objectTypeId && !listTableParams?.isPrimaryCompany) {
2019
+ apiParams.parentObjectTypeId = userData?.crmProfile?.info?.objectTypeId;
2020
+ } else if (payload?.isHome && userData?.crmProfile?.info?.objectTypeId && listTableParams?.isPrimaryCompany) {
2021
+ apiParams.parentObjectTypeId = "0-2";
2022
+ }
2023
+ const isPrimaryCompany = listTableParams?.isPrimaryCompany ?? tableParams.isPrimaryCompany ?? paramsObject?.isPrimaryCompany;
2024
+ if (isPrimaryCompany !== void 0 && isPrimaryCompany !== null && isPrimaryCompany !== "") {
2025
+ apiParams.isPrimaryCompany = isPrimaryCompany;
2026
+ }
2027
+ const apiUrl = generateApiUrl({
2028
+ route: API_ENDPOINTS.PIPELINES,
2029
+ params,
2030
+ queryParams: { ...apiParams, ...queryParams }
2031
+ });
2032
+ return HttpClient.get(apiUrl);
2033
+ }
2034
+ },
2035
+ stage: {
2036
+ list: (payload = null) => {
2037
+ const params = resolveCrmObjectRouteParams(payload);
2038
+ const queryParams = payload?.queryParams;
2039
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params, queryParams });
2040
+ return HttpClient.get(apiUrl);
2041
+ }
2042
+ },
2043
+ object: {
2044
+ list: async (payload = null, listTableParams = null) => {
2045
+ const { setObjectsQueryParams } = actions2;
2046
+ const params = resolveCrmObjectRouteParams(payload);
2047
+ const queryParams = payload?.queryParams;
2048
+ const { updateLink: updateLink2, getLinkParams } = updateLink();
2049
+ const tabHubspotObjectTypeId = payload?.hubspotObjectTypeId ?? payload?.params?.hubspotObjectTypeId;
2050
+ const linkParamDisplayName = payload?.viewName === "tabs" && tabHubspotObjectTypeId ? `tabs.${tabHubspotObjectTypeId}.prm` : "prm";
2051
+ const { paramsObject, parentAccessLabel } = getParamDetails2({ type: payload?.componentName, viewName: payload?.viewName });
2052
+ const userData = userStore.getState().profile;
2053
+ const pipeline = payload?.variables?.pipeline;
2054
+ const mPipelines = payload?.variables?.mPipelines;
2055
+ const mSelectedPipeline = pipeline !== void 0 ? pipeline : payload?.selectedPipeline;
2056
+ if (mSelectedPipeline !== void 0 && mSelectedPipeline !== null && String(mSelectedPipeline) !== "") {
2057
+ listTableParams.filterValue = mSelectedPipeline;
2058
+ } else if (payload?.specPipeLine && payload?.pipeLineId != null && String(payload.pipeLineId) !== "") {
2059
+ listTableParams.filterValue = payload?.pipeLineId;
2060
+ } else if (payload?.lockedPipelineId != null && String(payload.lockedPipelineId) !== "") {
2061
+ listTableParams.filterValue = payload.lockedPipelineId;
2062
+ } else if (!isPipelineBoardObjectTypeId(payload?.hubspotObjectTypeId)) {
2063
+ listTableParams.filterValue = "";
2064
+ }
2065
+ const fParams = getLinkParams(linkParamDisplayName);
2066
+ listTableParams = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : listTableParams, ...paramsObject };
2067
+ if (payload?.isHome) {
2068
+ listTableParams.isPrimaryCompany = payload.companyAsMediator === true;
2069
+ }
2070
+ if (!payload?.isFristTimeLoadData || !fParams) {
2071
+ const selectedStage = tableUiStore.getState().selectedStage;
2072
+ await updateLink2(
2073
+ {
2074
+ sort: listTableParams?.sort,
2075
+ s: listTableParams?.search,
2076
+ fPn: listTableParams?.filterPropertyName,
2077
+ fO: listTableParams?.filterOperator,
2078
+ fV: listTableParams?.filterValue,
2079
+ // "c": listTableParams?.cache,
2080
+ isPC: listTableParams?.isPrimaryCompany,
2081
+ v: listTableParams?.view,
2082
+ l: listTableParams?.limit,
2083
+ p: listTableParams?.page,
2084
+ a: listTableParams?.after,
2085
+ stg: listTableParams?.view === "LIST" ? selectedStage || "" : void 0
2086
+ },
2087
+ linkParamDisplayName
2088
+ );
2089
+ }
2090
+ if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
2091
+ listTableParams.filterValue = "";
2092
+ await updateLink2(
2093
+ {
2094
+ fV: listTableParams?.filterValue
2095
+ },
2096
+ linkParamDisplayName
2097
+ );
2098
+ }
2099
+ if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
2100
+ listTableParams.filterValue = mPipelines[0].pipelineId;
2101
+ await updateLink2(
2102
+ {
2103
+ fV: listTableParams?.filterValue
2104
+ },
2105
+ linkParamDisplayName
2106
+ );
2107
+ }
2108
+ if (payload?.isHome || payload?.hubspotObjectTypeId === "0-5" && payload?.componentName === "object") {
2109
+ let parentObjectTypeId = "";
2110
+ if (userData?.crmProfile?.info?.objectTypeId && !listTableParams?.isPrimaryCompany) {
2111
+ parentObjectTypeId = userData?.crmProfile?.info?.objectTypeId;
2112
+ } else if (userData?.crmProfile?.info?.objectTypeId && listTableParams?.isPrimaryCompany) {
2113
+ parentObjectTypeId = "0-2";
2114
+ }
2115
+ listTableParams.parentObjectTypeId = parentObjectTypeId;
2116
+ }
2117
+ listTableParams.parentAccessLabel = parentAccessLabel;
2118
+ finalizeBoardListQueryParams(listTableParams);
2119
+ setObjectsQueryParams(listTableParams);
2120
+ listTableParams = { ...listTableParams, ...queryParams };
2121
+ const route = payload?.public ? API_ENDPOINTS.OBJECTS_PUBLIC : API_ENDPOINTS.OBJECTS;
2122
+ const apiUrl = generateApiUrl({ route, params, queryParams: listTableParams });
2123
+ return HttpClient.get(apiUrl);
2124
+ },
2125
+ existingList: async (payload = null) => {
2126
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
2127
+ const params = { ...{ hubspotObjectTypeId }, ...payload?.params };
2128
+ const { paramsObject } = getParamDetails2({ type: payload?.componentName });
2129
+ const queryParams = { ...{ parentObjectTypeId: paramsObject?.parentObjectTypeId }, ...payload?.queryParams };
2130
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_EXISTING, params, queryParams });
2131
+ return HttpClient.get(apiUrl);
2132
+ },
2133
+ addExistingList: async (payload = null) => {
2134
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
2135
+ const { paramsObject } = getParamDetails2({ type: payload?.componentName });
2136
+ const params = { ...{ hubspotObjectTypeId, parentObjectTypeId: paramsObject?.parentObjectTypeId, recordId: paramsObject?.parentObjectRecordId }, ...payload?.params };
2137
+ const queryParams = payload?.queryParams;
2138
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ADD_EXISTING, params, queryParams });
2139
+ return HttpClient.post(apiUrl, payload?.payload);
2140
+ },
2141
+ sideBarList: async (payload = null) => {
2142
+ const { setMultiObjectsQueryParams } = actions2;
2143
+ const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
2144
+ const params = payload?.params;
2145
+ const queryParams = payload?.queryParams;
2146
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
2147
+ setMultiObjectsQueryParams(hubspotObjectTypeId, queryParams ?? {});
2148
+ return HttpClient.get(apiUrl);
2149
+ },
2150
+ form: (payload = null) => {
2151
+ const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
2152
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
2153
+ return HttpClient.get(apiUrl);
2154
+ },
2155
+ objectFormOptions: (payload = null) => {
2156
+ const params = payload?.params;
2157
+ const queryParams = payload?.queryParams;
2158
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams });
2159
+ return HttpClient.get(apiUrl);
2160
+ },
2161
+ create: async (props = null) => {
2162
+ const params = props?.params;
2163
+ const queryParams = props?.queryParams;
2164
+ const { paramsObject } = getParamDetails2({ type: props?.componentName });
2165
+ const cardParentMerge = props?.componentName === "association" || props?.componentName === "sidebarAssociation" ? true : false;
2166
+ const body = mergeRecordWriteBody(props?.payload, paramsObject, {
2167
+ cardParentMerge,
2168
+ addAnother: props?.params?.addAnother
2169
+ });
2170
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams });
2171
+ const response = await HttpClient.post(apiUrl, body);
2172
+ const writeParams = {
2173
+ ...paramsObject,
2174
+ ...props?.queryParams && typeof props.queryParams === "object" ? props.queryParams : {},
2175
+ ...props?.params && typeof props.params === "object" ? props.params : {}
2176
+ };
2177
+ const purgeArgs = {
2178
+ hubspotObjectTypeId: props?.params?.hubspotObjectTypeId,
2179
+ componentName: props?.componentName,
2180
+ paramsObject: writeParams,
2181
+ recordId: extractHubspotRecordIdFromWriteResponse(response)
2182
+ };
2183
+ if (props?.componentName === "sidebarAssociation") {
2184
+ await triggerPostWriteListPurge(purgeArgs);
2185
+ } else {
2186
+ void triggerPostWriteListPurge(purgeArgs);
2187
+ }
2188
+ return response;
2189
+ },
2190
+ createExisting: async (props = null) => {
2191
+ const { paramsObject } = getParamDetails2({ type: props?.componentName });
2192
+ const { getLinkParams } = updateLink();
2193
+ const fParams = getLinkParams();
2194
+ const queryParams = { ...fParams, ...props?.params };
2195
+ const params = {
2196
+ fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
2197
+ fromRecordId: props?.fromRecordId,
2198
+ toObjectTypeId: props?.toObjectTypeId
2199
+ };
2200
+ const payload = props.payload;
2201
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
2202
+ const response = await HttpClient.post(apiUrl, payload);
2203
+ const objectTypeId = props?.toObjectTypeId ?? props?.hubspotObjectTypeId;
2204
+ const recordId = extractHubspotRecordIdFromWriteResponse(response) ?? (props?.fromRecordId != null ? String(props.fromRecordId) : void 0);
2205
+ triggerPostWriteListPurge({
2206
+ hubspotObjectTypeId: objectTypeId,
2207
+ componentName: props?.componentName,
2208
+ paramsObject,
2209
+ recordId
2210
+ });
2211
+ return response;
2212
+ },
2213
+ removeExisting: async (props = null) => {
2214
+ const { paramsObject } = getParamDetails2({ type: props?.componentName });
2215
+ const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
2216
+ const params = {
2217
+ fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
2218
+ fromRecordId: props?.fromRecordId,
2219
+ toObjectTypeId: props?.toObjectTypeId
2220
+ };
2221
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
2222
+ const response = await HttpClient.delete(apiUrl, { data: body });
2223
+ const objectTypeId = props?.toObjectTypeId ?? props?.hubspotObjectTypeId;
2224
+ if (objectTypeId) {
2225
+ const { queryParams, multiObjectsQueryParams } = tableStore.getState();
2226
+ const listQuery = resolveCrmListPurgeQuery({
2227
+ componentName: props?.componentName,
2228
+ hubspotObjectTypeId: objectTypeId,
2229
+ tableQueryParams: queryParams,
2230
+ multiObjectsQueryParams,
2231
+ writeContext: recordWriteContext(paramsObject)
2232
+ });
2233
+ purgeCrmListCache({
2234
+ objectTypeId: String(objectTypeId),
2235
+ listQuery
2236
+ });
2237
+ }
2238
+ return response;
2239
+ },
2240
+ details: (props = null) => {
2241
+ const isDdetails = props?.queryParams?.preview ? false : true;
2242
+ const { paramsObject: urlParam, parentAccessLabel } = getParamDetails2("", isDdetails);
2243
+ const hubspotObjectTypeId = ticketHubspotObjectTypeId();
2244
+ const previewParams = makePreviewParams(props);
2245
+ let objectId = null;
2246
+ if (props?.queryParams?.preview) {
2247
+ objectId = previewParams?.params?.objectId;
2248
+ } else {
2249
+ objectId = props?.params?.objectId;
2250
+ }
2251
+ const params = {
2252
+ objectId,
2253
+ id: props?.params?.id
2254
+ };
2255
+ let queryParams = {
2256
+ parentAccessLabel,
2257
+ ...props?.queryParams,
2258
+ ...urlParam
2259
+ };
2260
+ if (props?.queryParams?.preview) {
2261
+ queryParams = {
2262
+ parentAccessLabel,
2263
+ ...props?.queryParams,
2264
+ ...previewParams?.queryParams
2265
+ };
2266
+ } else {
2267
+ queryParams = {
2268
+ parentAccessLabel,
2269
+ ...props?.queryParams,
2270
+ ...urlParam
2271
+ };
2272
+ }
2273
+ if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
2274
+ const route = props?.public ? API_ENDPOINTS.OBJECTS_DETAILS_PUBLIC : API_ENDPOINTS.OBJECTS_DETAILS;
2275
+ const apiUrl = generateApiUrl({ route, params, queryParams });
2276
+ return HttpClient.get(apiUrl);
2277
+ },
2278
+ update: async (props = null) => {
2279
+ const hubspotObjectTypeId = ticketHubspotObjectTypeId();
2280
+ const params = props?.params;
2281
+ const queryParams = props?.queryParams ?? {};
2282
+ const { paramsObject } = getParamDetails2({ type: props?.componentName });
2283
+ const cardParentMerge = props?.componentName === "association" ? true : false;
2284
+ const rawPayload = props?.payload || {};
2285
+ const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
2286
+ const body = mergeRecordWriteBody({ properties }, paramsObject, { cardParentMerge });
2287
+ if (hubspotObjectTypeId) queryParams.parentObjectTypeId = hubspotObjectTypeId;
2288
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params, queryParams });
2289
+ if (props?.view === "board") {
2290
+ body.options.view = "board";
2291
+ }
2292
+ const response = await HttpClient.put(apiUrl, body);
2293
+ return response;
2294
+ }
2295
+ }
2296
+ };
2297
+
2298
+ // src/main/features/crm/client/engagement-client.ts
2299
+ var engagementClient = {
2300
+ note: {
2301
+ list: (props = null) => {
2302
+ const { setListQueryParams } = actions4;
2303
+ setListQueryParams(props?.queryParams ?? {});
2304
+ const params = {
2305
+ // hubId: config.hubId,
2306
+ // portalId: portalId,
2307
+ objectId: props?.params?.objectId,
2308
+ id: props?.params?.id
2309
+ };
2310
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
2311
+ return HttpClient.get(apiUrl);
2312
+ },
2313
+ create: async (props = null) => {
2314
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2315
+ const queryParams = props.queryParams;
2316
+ const payload = props.payload;
2317
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
2318
+ const listQuery = toCachePurgeListQuery(noteStore.getState().queryParams ?? {});
2319
+ const response = await HttpClient.post(apiUrl, payload);
2320
+ const recordId = props?.params?.id;
2321
+ const objectTypeId = props?.params?.objectId;
2322
+ if (recordId && objectTypeId) {
2323
+ const engagementItemId = extractEngagementItemIdFromWriteResponse(response);
2324
+ purgeEngagementCachesAfterCrmWrite({
2325
+ objectTypeId,
2326
+ recordIds: [String(recordId)],
2327
+ views: ["notes"],
2328
+ listQuery,
2329
+ engagementItemIds: engagementItemId ? [engagementItemId] : void 0
2330
+ });
2331
+ }
2332
+ return response;
2333
+ },
2334
+ update: async (props = null) => {
2335
+ const params = {
2336
+ // hubId: config.hubId,
2337
+ // portalId: portalId,
2338
+ objectId: props?.params?.objectId,
2339
+ id: props?.params?.id,
2340
+ note_id: props?.params?.note_id
2341
+ };
2342
+ const { paramsObject: queryParams } = getParamDetails2();
2343
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
2344
+ const listQuery = toCachePurgeListQuery(noteStore.getState().queryParams ?? {});
2345
+ const response = await HttpClient.put(apiUrl, props.payload);
2346
+ const recordId = props?.params?.id;
2347
+ const objectTypeId = props?.params?.objectId;
2348
+ const noteId = props?.params?.note_id;
2349
+ if (recordId && objectTypeId) {
2350
+ const engagementItemId = extractEngagementItemIdFromWriteResponse(response) ?? (noteId != null && String(noteId).length > 0 ? String(noteId) : void 0);
2351
+ purgeEngagementCachesAfterCrmWrite({
2352
+ objectTypeId,
2353
+ recordIds: [String(recordId)],
2354
+ views: ["notes"],
2355
+ listQuery,
2356
+ engagementItemIds: engagementItemId ? [engagementItemId] : void 0
2357
+ });
2358
+ }
2359
+ return response;
2360
+ },
2361
+ image: (props = null) => {
2362
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2363
+ const queryParams = props.queryParams;
2364
+ const payload = props.payload;
2365
+ const axiosConfig = props.config || {};
2366
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
2367
+ return HttpClient.post(apiUrl, payload, {
2368
+ headers: {
2369
+ "Content-Type": "multipart/form-data"
2370
+ },
2371
+ ...axiosConfig
2372
+ });
2373
+ },
2374
+ attachment: (props = null) => {
2375
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2376
+ const queryParams = props.queryParams;
2377
+ const payload = props.payload;
2378
+ const axiosConfig = props.config || {};
2379
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
2380
+ return HttpClient.post(apiUrl, payload, {
2381
+ headers: {
2382
+ "Content-Type": "multipart/form-data"
2383
+ },
2384
+ ...axiosConfig
2385
+ });
2386
+ }
2387
+ },
2388
+ email: {
2389
+ list: (props = null) => {
2390
+ const { setListQueryParams } = actions5;
2391
+ setListQueryParams(props?.queryParams ?? {});
2392
+ const params = {
2393
+ // hubId: config.hubId,
2394
+ // portalId: portalId,
2395
+ objectId: props?.params?.objectId,
2396
+ id: props?.params?.id
2397
+ };
2398
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
2399
+ return HttpClient.get(apiUrl);
2400
+ },
2401
+ create: async (props = null) => {
2402
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2403
+ const queryParams = props.queryParams;
2404
+ const payload = props.payload;
2405
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
2406
+ const listQuery = toCachePurgeListQuery(emailStore.getState().queryParams ?? {});
2407
+ const response = await HttpClient.post(apiUrl, payload);
2408
+ const recordId = props?.params?.id;
2409
+ const objectTypeId = props?.params?.objectId;
2410
+ if (recordId && objectTypeId) {
2411
+ const engagementItemId = extractEngagementItemIdFromWriteResponse(response);
2412
+ purgeEngagementCachesAfterCrmWrite({
2413
+ objectTypeId,
2414
+ recordIds: [String(recordId)],
2415
+ views: ["emails"],
2416
+ listQuery,
2417
+ engagementItemIds: engagementItemId ? [engagementItemId] : void 0
2418
+ });
2419
+ }
2420
+ return response;
2421
+ },
2422
+ update: async (props = null) => {
2423
+ const params = {
2424
+ // hubId: config.hubId,
2425
+ // portalId: portalId,
2426
+ objectId: props?.params?.objectId,
2427
+ id: props?.params?.id,
2428
+ email_id: props?.params?.email_id ?? props?.params?.note_id
2429
+ };
2430
+ const { paramsObject: queryParams } = getParamDetails2();
2431
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
2432
+ const listQuery = toCachePurgeListQuery(emailStore.getState().queryParams ?? {});
2433
+ const response = await HttpClient.put(apiUrl, props.payload);
2434
+ const recordId = props?.params?.id;
2435
+ const objectTypeId = props?.params?.objectId;
2436
+ const emailId = props?.params?.email_id ?? props?.params?.note_id;
2437
+ if (recordId && objectTypeId) {
2438
+ const engagementItemId = extractEngagementItemIdFromWriteResponse(response) ?? (emailId != null && String(emailId).length > 0 ? String(emailId) : void 0);
2439
+ purgeEngagementCachesAfterCrmWrite({
2440
+ objectTypeId,
2441
+ recordIds: [String(recordId)],
2442
+ views: ["emails"],
2443
+ listQuery,
2444
+ engagementItemIds: engagementItemId ? [engagementItemId] : void 0
2445
+ });
2446
+ }
2447
+ return response;
2448
+ },
2449
+ image: (props = null) => {
2450
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2451
+ const queryParams = props.queryParams;
2452
+ const payload = props.payload;
2453
+ const axiosConfig = props.config || {};
2454
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
2455
+ return HttpClient.post(apiUrl, payload, {
2456
+ headers: {
2457
+ "Content-Type": "multipart/form-data"
2458
+ },
2459
+ ...axiosConfig
2460
+ });
2461
+ },
2462
+ attachment: (props = null) => {
2463
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2464
+ const queryParams = props.queryParams;
2465
+ const payload = props.payload;
2466
+ const axiosConfig = props.config || {};
2467
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
2468
+ return HttpClient.post(apiUrl, payload, {
2469
+ headers: {
2470
+ "Content-Type": "multipart/form-data"
2471
+ },
2472
+ ...axiosConfig
2473
+ });
2474
+ }
2475
+ },
2476
+ file: {
2477
+ list: (props = null) => {
2478
+ const { setListQueryParams } = actions7;
2479
+ setListQueryParams(props?.queryParams ?? {});
2480
+ const params = {
2481
+ // hubId: config.hubId,
2482
+ // portalId: portalId,
2483
+ objectId: props?.params?.objectId,
2484
+ id: props?.params?.id
2485
+ };
2486
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
2487
+ return HttpClient.get(apiUrl);
2488
+ },
2489
+ details: (props = null) => {
2490
+ const params = {
2491
+ // hubId: config.hubId,
2492
+ // portalId: portalId,
2493
+ objectId: props?.params?.objectId,
2494
+ id: props?.params?.id,
2495
+ rowId: props?.params?.rowId
2496
+ };
2497
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
2498
+ return HttpClient.get(apiUrl);
2499
+ },
2500
+ download: (props = null) => {
2501
+ const params = {
2502
+ objectId: props?.params?.objectId,
2503
+ id: props?.params?.id,
2504
+ rowId: props?.params?.rowId
2505
+ };
2506
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
2507
+ return HttpClient.post(apiUrl, {});
2508
+ },
2509
+ addFolder: async (props = null) => {
2510
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2511
+ const queryParams = props.queryParams;
2512
+ const payload = props.payload;
2513
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
2514
+ const listQuery = fileStore.getState().queryParams ?? {};
2515
+ const response = await HttpClient.post(apiUrl, payload);
2516
+ const recordId = props?.params?.id;
2517
+ const objectTypeId = props?.params?.objectId;
2518
+ if (recordId && objectTypeId) {
2519
+ purgeEngagementCaches({
2520
+ objectTypeId,
2521
+ recordIds: [String(recordId)],
2522
+ views: ["files"],
2523
+ listQuery
2524
+ });
2525
+ }
2526
+ return response;
2527
+ },
2528
+ addFile: async (props = null) => {
2529
+ const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
2530
+ const queryParams = props.queryParams;
2531
+ const payload = props.payload;
2532
+ const axiosConfig = props.config || {};
2533
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
2534
+ const listQuery = fileStore.getState().queryParams ?? {};
2535
+ const response = await HttpClient.post(apiUrl, payload, {
2536
+ headers: {
2537
+ "Content-Type": "multipart/form-data"
2538
+ },
2539
+ ...axiosConfig
2540
+ });
2541
+ const recordId = props?.params?.id;
2542
+ const objectTypeId = props?.params?.objectId;
2543
+ if (recordId && objectTypeId) {
2544
+ purgeEngagementCaches({
2545
+ objectTypeId,
2546
+ recordIds: [String(recordId)],
2547
+ views: ["files"],
2548
+ listQuery
2549
+ });
2550
+ }
2551
+ return response;
2552
+ }
2553
+ }
2554
+ };
2555
+
2556
+ // src/main/features/crm/client/cache-client.ts
2557
+ var cacheClient = {
2558
+ purge: (body, headers) => {
2559
+ const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
2560
+ return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
2561
+ },
2562
+ purgeStatus: (purgeJobId) => {
2563
+ const apiUrl = generateApiUrl({
2564
+ route: API_ENDPOINTS.CACHE_PURGE_STATUS,
2565
+ params: { purgeJobId }
2566
+ });
2567
+ return HttpClient.get(apiUrl);
2568
+ }
2569
+ };
2570
+
2571
+ // src/main/features/auth/client/security-client.ts
2572
+ var refreshTokenHeaders = (refreshToken) => {
2573
+ if (!refreshToken) {
2574
+ return void 0;
2575
+ }
2576
+ return { "X-Refresh-Token": refreshToken };
2577
+ };
2578
+ var securityClient = {
2579
+ getOverview: (query) => HttpClient.get(
2580
+ generateApiUrl({
2581
+ route: API_ENDPOINTS.SECURITY_OVERVIEW,
2582
+ queryParams: portalIdQuery(query?.portalId)
2583
+ })
2584
+ ),
2585
+ getLoginActivity: (query) => HttpClient.get(
2586
+ generateApiUrl({
2587
+ route: API_ENDPOINTS.SECURITY_LOGIN_ACTIVITY,
2588
+ queryParams: query ?? {}
2589
+ })
2590
+ ),
2591
+ getSessions: (query) => HttpClient.get(
2592
+ generateApiUrl({
2593
+ route: API_ENDPOINTS.SECURITY_SESSIONS,
2594
+ queryParams: {
2595
+ page: query?.page,
2596
+ limit: query?.limit,
2597
+ sort: query?.sort,
2598
+ currentFamilyId: query?.currentFamilyId
2599
+ }
2600
+ }),
2601
+ void 0,
2602
+ mergeRequestOptions(void 0, refreshTokenHeaders(query?.refreshToken))
2603
+ ),
2604
+ revokeSession: (payload) => HttpClient.post(
2605
+ generateApiUrl({
2606
+ route: API_ENDPOINTS.SECURITY_SESSION_REVOKE,
2607
+ params: { familyId: payload.familyId }
2608
+ }),
2609
+ null,
2610
+ mergeRequestOptions(void 0, refreshTokenHeaders(payload.refreshToken))
2611
+ ),
2612
+ revokeOtherSessions: (refreshToken) => HttpClient.post(API_ENDPOINTS.SECURITY_SESSIONS_REVOKE_OTHERS, null, mergeRequestOptions(void 0, refreshTokenHeaders(refreshToken)))
2613
+ };
2614
+
2615
+ // src/main/core/http/client-assembler.ts
2616
+ var Client = {
2617
+ ...authenticationClient,
2618
+ ...crmClient,
2619
+ ...engagementClient,
2620
+ cache: cacheClient,
2621
+ mfa: mfaClient,
2622
+ security: securityClient
2623
+ };
2624
+
2625
+ // src/main/core/utils/cache/createCachePurgeJob.ts
2626
+ function randomIdempotencyKey() {
2627
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
2628
+ return crypto.randomUUID();
2629
+ }
2630
+ return `purge-${Date.now()}-${Math.random().toString(36).slice(2)}`;
2631
+ }
2632
+ function mapErrorCode(status, message) {
2633
+ if (status === 400 || status === 422) {
2634
+ return "VALIDATION";
2635
+ }
2636
+ if (status === 429) {
2637
+ return "RATE_LIMITED";
2638
+ }
2639
+ if (message?.toLowerCase().includes("disabled")) {
2640
+ return "PURGE_API_DISABLED";
2641
+ }
2642
+ return status ? "UNKNOWN" : "NETWORK";
2643
+ }
2644
+ function sleep(ms) {
2645
+ return new Promise((resolve) => setTimeout(resolve, ms));
2646
+ }
2647
+ async function createCachePurgeJob(request, options = {}) {
2648
+ const idempotencyKey = options.idempotencyKey ?? randomIdempotencyKey();
2649
+ try {
2650
+ const headers = { "Idempotency-Key": idempotencyKey };
2651
+ const response = await Client.cache.purge(request, headers);
2652
+ const data = response?.data;
2653
+ const purgeJobId = data?.purgeJobId;
2654
+ let status = data?.status;
2655
+ if (options.waitForWarm && purgeJobId && request.warm !== false) {
2656
+ const timeout = options.pollTimeoutMs ?? 3e4;
2657
+ const interval = options.pollIntervalMs ?? 500;
2658
+ const deadline = Date.now() + timeout;
2659
+ while (Date.now() < deadline) {
2660
+ const statusRes = await Client.cache.purgeStatus(purgeJobId);
2661
+ const job = statusRes?.data;
2662
+ const jobStatus = job?.status;
2663
+ if (jobStatus === "completed") {
2664
+ status = "completed";
2665
+ break;
2666
+ }
2667
+ if (jobStatus === "failed") {
2668
+ return {
2669
+ ok: false,
2670
+ purgeJobId,
2671
+ status: "failed",
2672
+ errorCode: "WARM_FAILED",
2673
+ message: "Cache warm job failed"
2674
+ };
2675
+ }
2676
+ await sleep(interval);
2677
+ }
2678
+ if (status !== "completed") {
2679
+ return {
2680
+ ok: false,
2681
+ purgeJobId,
2682
+ status: status ?? "warming",
2683
+ errorCode: "WARM_FAILED",
2684
+ message: "Timed out waiting for cache warm job"
2685
+ };
2686
+ }
2687
+ }
2688
+ return {
2689
+ ok: true,
2690
+ purgeJobId,
2691
+ status,
2692
+ evicted: data?.evicted,
2693
+ warnings: data?.warnings
2694
+ };
2695
+ } catch (err) {
2696
+ const axiosErr = err;
2697
+ const status = axiosErr.response?.status;
2698
+ const message = axiosErr.response?.data?.message ?? (err instanceof Error ? err.message : "Cache purge request failed");
2699
+ return {
2700
+ ok: false,
2701
+ errorCode: mapErrorCode(status, message),
2702
+ message
2703
+ };
2704
+ }
2705
+ }
2706
+ function logError(context, error) {
2707
+ if (axios.isAxiosError(error) && error.response?.status === 401) {
2708
+ resetAllStore();
2709
+ }
2710
+ logger.error(context, error);
2711
+ }
2712
+
2713
+ // src/main/core/mutation/createMutation.ts
2714
+ function createMutation(mutationFn, options) {
2715
+ let inFlight = 0;
2716
+ let lastReportedLoading = null;
2717
+ const syncLoading = () => {
2718
+ const active = inFlight > 0;
2719
+ if (lastReportedLoading === active) return;
2720
+ lastReportedLoading = active;
2721
+ options?.onLoadingChange?.(active);
2722
+ };
2723
+ const mutate = async (payload) => {
2724
+ inFlight += 1;
2725
+ syncLoading();
2726
+ try {
2727
+ const response = await mutationFn(payload);
2728
+ await options?.onSuccess?.(response, payload);
2729
+ return response;
2730
+ } catch (error) {
2731
+ options?.onError?.(error, payload);
2732
+ logError("[mutation]", error);
2733
+ throw error;
2734
+ } finally {
2735
+ inFlight -= 1;
2736
+ syncLoading();
2737
+ }
2738
+ };
2739
+ return {
2740
+ mutate,
2741
+ isLoading: () => inFlight > 0
2742
+ };
2743
+ }
2744
+
2745
+ export { API_ENDPOINTS, Client, HttpClient, applyContractApiDate, buildCachePurgeRequest, buildCrmListPurgeTarget, buildCrmSinglePurgeTarget, buildEngagementPurgeTarget, buildPortalConfigPurgeTarget, buildUserSessionPurgeTarget, createCachePurgeJob, createMutation, extractEngagementItemIdFromWriteResponse, extractHubspotRecordIdFromWriteResponse, generateApiUrl, getAuthRefreshToken, getConfiguredContractApiDate, getFieldErrors, getFormErrors, initializeHttpClient, mergePurgeTargets, navigationApi, purgeCrmAssociationCaches, purgeCrmCombined, purgeCrmDetailAndListAfterCrmWrite, purgeCrmListCache, purgeCrmListCacheAfterCrmWrite, purgeCrmObjectDataCache, purgeCrmRecordCache, purgeEngagementCaches, purgeEngagementCachesAfterCrmWrite, resolveCrmListPurgeQuery, resolveListTableParams, setEditorPreviewMockHandler, startVisibilityRefreshScheduler, stopVisibilityRefreshScheduler, toCachePurgeListQuery };
2746
+ //# sourceMappingURL=chunk-BXHEEGBF.js.map
2747
+ //# sourceMappingURL=chunk-BXHEEGBF.js.map