woodsportal-client-sdk 1.1.4-dev.52 → 1.1.4-dev.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1837 +1,4 @@
1
- import { getParamDetails, useUpdateLink, useTable, getRouteDetails, actions2, actions7, actions, actions4, actions5, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl, resetAllStore, actions3 } from './chunk-UULYOTUL.js';
2
- import { ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, getRefreshToken, DEV_API_URL, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken } from './chunk-A3N3Z2XW.js';
3
- import { __export, isCookieExpired, removeAllCookie } from './chunk-T4ORQSB3.js';
4
- import axios from 'axios';
5
-
6
- // src/client/index.ts
7
- var client_exports = {};
8
- __export(client_exports, {
9
- Client: () => Client
10
- });
11
-
12
- // src/utils/localStoraget.ts
13
- var memory = /* @__PURE__ */ new Map();
14
- var memoryStore = {
15
- getItem(key) {
16
- return memory.has(key) ? memory.get(key) : null;
17
- },
18
- setItem(key, value) {
19
- memory.set(key, value);
20
- },
21
- removeItem(key) {
22
- memory.delete(key);
23
- }
24
- };
25
- function resolveStore() {
26
- if (typeof globalThis === "undefined") {
27
- return memoryStore;
28
- }
29
- const ls = globalThis.localStorage;
30
- if (!ls || typeof ls.getItem !== "function") {
31
- return memoryStore;
32
- }
33
- try {
34
- const probeKey = "__woodsportal_client_sdk_ls_probe__";
35
- ls.setItem(probeKey, "1");
36
- ls.removeItem(probeKey);
37
- return ls;
38
- } catch {
39
- return memoryStore;
40
- }
41
- }
42
- var storage = {
43
- set: (key, value) => {
44
- resolveStore().setItem(key, JSON.stringify(value));
45
- },
46
- get: (key) => {
47
- const item = resolveStore().getItem(key);
48
- return item ? JSON.parse(item) : null;
49
- },
50
- remove: (key) => {
51
- resolveStore().removeItem(key);
52
- }
53
- };
54
-
55
- // src/utils/config.ts
56
- var config = {
57
- get hubId() {
58
- const hubSpotData = storage.get(HUBSPOT_DATA);
59
- return hubSpotData?.[HUB_ID] || "";
60
- },
61
- get devPortalId() {
62
- const hubSpotData = storage.get(HUBSPOT_DATA);
63
- return hubSpotData?.[DEV_PORTAL_ID] || "";
64
- },
65
- get portalId() {
66
- const hubSpotData = storage.get(HUBSPOT_DATA);
67
- return hubSpotData?.[PORTAL_ID] || "";
68
- },
69
- get devApiUrl() {
70
- const hubSpotData = storage.get(HUBSPOT_DATA);
71
- return hubSpotData?.[DEV_API_URL] || "";
72
- }
73
- };
74
- var setConfig = {
75
- setDevPortalId(portalId) {
76
- const existing = storage.get(HUBSPOT_DATA) || {};
77
- storage.set(HUBSPOT_DATA, {
78
- ...existing,
79
- [PORTAL_ID]: portalId
80
- });
81
- }
82
- };
83
-
84
- // src/utils/generateApiUrl.ts
85
- var generateApiUrl = ({
86
- route,
87
- params = {},
88
- queryParams = ""
89
- }) => {
90
- const defaultParams = {
91
- hubId: config.hubId,
92
- portalId: config.portalId
93
- };
94
- params = { ...defaultParams, ...params };
95
- const url2 = replaceParams(route, params);
96
- let queryString = "";
97
- if (queryParams && typeof queryParams === "object") {
98
- const cleanedParams = Object.entries(queryParams).filter(([_, value]) => value !== null && value !== void 0).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
99
- queryString = new URLSearchParams(cleanedParams).toString();
100
- }
101
- return queryString ? `${url2}?${queryString}` : url2;
102
- };
103
- function replaceParams(template, values) {
104
- return template.replace(
105
- /\$\{(\w+)\}/g,
106
- (_, key) => key in values ? String(values[key]) : `\${${key}}`
107
- );
108
- }
109
-
110
- // src/client/api-endpoints.ts
111
- var API_ENDPOINTS = {
112
- // Auth
113
- PRE_LOGIN: "/api/auth/pre-login",
114
- LOGIN: "/api/auth/login",
115
- AUTH_REFRESH: "/api/auth/refresh",
116
- FORGET_PASSWORD: "/api/auth/forget-password",
117
- RESET_PASSWORD_VERIFY_TOKEN: "/api/auth/token/validate",
118
- RESET_PASSWORD: "/api/auth/reset-password",
119
- VERIFY_EMAIL: "/api/auth/verify-email",
120
- REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
121
- RESEND_EMAIL: "/api/auth/resend-email",
122
- VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
123
- LOGOUT: "/api/auth/logout",
124
- // SSO
125
- SSO_DETAILS: "/api/auth/sso/active",
126
- SSO_URL: "/api/auth/sso/authorize",
127
- SSO_CALLBACK: "/api/auth/sso/callback",
128
- // User
129
- ME: "/api/auth/me",
130
- PROFILE: "/api/${hubId}/${portalId}/profiles",
131
- CHANGE_PASSWORD: "/api/auth/change-password",
132
- // Pipeline
133
- PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
134
- // Stage
135
- STAGES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
136
- // Cache purge (replaces cache=false refresh; requires features.cache-purge-api-enabled on API)
137
- CACHE_PURGE: "/api/${hubId}/${portalId}/cache-purge-jobs",
138
- CACHE_PURGE_STATUS: "/api/${hubId}/${portalId}/cache-purge-jobs/${purgeJobId}",
139
- /** @deprecated Use CACHE_PURGE */
140
- CACHE_PURGE_LEGACY: "/api/${hubId}/${portalId}/cache/purge",
141
- /** @deprecated Use CACHE_PURGE_STATUS */
142
- CACHE_PURGE_STATUS_LEGACY: "/api/${hubId}/${portalId}/cache/purge/${purgeJobId}",
143
- // Object (read on hubspot-object-data; form layout on hubspot-object-forms)
144
- OBJECTS: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
145
- OBJECTS_FORM: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
146
- OBJECTS_FORM_OPTIONS: "/api/${hubId}/${portalId}/hubspot-object-forms/${formId}/${objectTypeId}",
147
- RECORDS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${hubspotObjectTypeId}/records",
148
- RECORDS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
149
- RECORDS_ASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
150
- RECORDS_DISASSOCIATE: "/api/${hubId}/${portalId}/hubspot-object-data/${fromObjectTypeId}/records/${fromRecordId}/associations/${toObjectTypeId}",
151
- /** @deprecated Use RECORDS_CREATE */
152
- OBJECTS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${hubspotObjectTypeId}/fields",
153
- /** @deprecated Use RECORDS_ASSOCIATE */
154
- OBJECTS_CREATE_EXISTING: "/api/${hubId}/${portalId}/hubspot-object-forms/:fromObjectTypeId/:fromRecordId/associations/:toObjectTypeId",
155
- OBJECTS_DETAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}",
156
- /** @deprecated Use RECORDS_UPDATE */
157
- OBJECTS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/records/${id}",
158
- OBJECTS_DETAILS_UPDATE_LEGACY: "/api/${hubId}/${portalId}/hubspot-object-forms/${objectId}/properties/${id}",
159
- // Notes (nested under CRM record)
160
- NOTES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
161
- NOTES_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes",
162
- NOTES_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/${note_id}",
163
- NOTES_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/images",
164
- NOTES_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments",
165
- NOTES_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/notes/attachments/${note_id}",
166
- // Email (nested under CRM record)
167
- EMAILS: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
168
- EMAILS_CREATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails",
169
- EMAILS_DETAILS_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/${email_id}",
170
- EMAILS_IMAGE_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/images",
171
- EMAILS_ATTACHMENT_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments",
172
- EMAILS_ATTACHMENT_UPDATE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/emails/attachments/${email_id}",
173
- // File manager (nested under CRM record)
174
- FILES: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files",
175
- FILE: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}",
176
- FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
177
- FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
178
- FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
179
- };
180
-
181
- // src/client/config.ts
182
- var config2 = {
183
- baseURL: ""
184
- };
185
-
186
- // src/client/http-clint.ts
187
- var axiosInstance = null;
188
- var config3 = {};
189
- function initializeHttpClient(clientConfig) {
190
- config3 = clientConfig;
191
- const baseURL = config?.devApiUrl || config3.baseURL;
192
- if (!baseURL) {
193
- throw new Error(
194
- "WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup."
195
- );
196
- }
197
- const timeout = config3.timeout ?? 5e4;
198
- axiosInstance = axios.create({
199
- baseURL,
200
- timeout,
201
- headers: {
202
- "Content-Type": "application/json",
203
- ...config3.headers
204
- }
205
- });
206
- setRefreshCallback(getAuthRefreshToken);
207
- axiosInstance.interceptors.request.use((config4) => {
208
- const token = getAccessToken();
209
- if (token) {
210
- config4.headers.set("Authorization", `Bearer ${token}`);
211
- }
212
- return config4;
213
- });
214
- axiosInstance.interceptors.response.use(
215
- (response) => response,
216
- (error) => {
217
- if (error.response && error.response.status === 401) {
218
- config3.skipCurrentPublicPath?.() ?? false;
219
- }
220
- return Promise.reject(error);
221
- }
222
- );
223
- }
224
- function getAxiosInstance() {
225
- if (!axiosInstance) {
226
- initializeHttpClient({
227
- baseURL: config2.baseURL,
228
- timeout: 5e4
229
- });
230
- }
231
- return axiosInstance;
232
- }
233
- function formatBooleanSearchParam(key, value) {
234
- return value ? `${key}:1` : `${key}:`;
235
- }
236
- var HttpClient = class {
237
- static async get(url2, params) {
238
- await ensureValidRefresh();
239
- const response = await getAxiosInstance().get(url2, { params });
240
- return response.data;
241
- }
242
- static async post(url2, data, options) {
243
- await ensureValidRefresh();
244
- const response = await getAxiosInstance().post(url2, data, options);
245
- return response.data;
246
- }
247
- static async put(url2, data) {
248
- await ensureValidRefresh();
249
- const response = await getAxiosInstance().put(url2, data);
250
- return response.data;
251
- }
252
- static async delete(url2, config4) {
253
- await ensureValidRefresh();
254
- const response = await getAxiosInstance().delete(url2, config4);
255
- return response.data;
256
- }
257
- static formatSearchParams(params) {
258
- return Object.entries(params).filter(([, value]) => Boolean(value)).map(
259
- ([k, v]) => [
260
- "type",
261
- "categories",
262
- "tags",
263
- "author",
264
- "manufacturer",
265
- "shops",
266
- "refund_reason"
267
- ].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
268
- ).join(";");
269
- }
270
- };
271
- var AuthHttpClient = class {
272
- static async get(url2, params) {
273
- const response = await getAxiosInstance().get(url2, { params });
274
- return response.data;
275
- }
276
- static async post(url2, data, options) {
277
- const response = await getAxiosInstance().post(url2, data, options);
278
- return response.data;
279
- }
280
- static async put(url2, data, options) {
281
- const response = await getAxiosInstance().put(url2, data, options);
282
- return response.data;
283
- }
284
- };
285
- function getFormErrors(error) {
286
- if (axios.isAxiosError(error)) {
287
- return error.response?.data?.message ?? null;
288
- }
289
- return null;
290
- }
291
- function getFieldErrors(error) {
292
- if (axios.isAxiosError(error)) {
293
- return error.response?.data?.errors ?? null;
294
- }
295
- return null;
296
- }
297
- async function getAuthRefreshToken(refreshToken) {
298
- if (refreshToken == null || refreshToken.trim() === "") {
299
- return { token: null, success: false };
300
- }
301
- try {
302
- const headers = {};
303
- if (config.devPortalId) {
304
- headers["X-Dev-Portal-Id"] = config.devPortalId;
305
- }
306
- const api_url = generateApiUrl({ route: API_ENDPOINTS.AUTH_REFRESH, queryParams: { hubId: config.hubId } });
307
- const response = await getAxiosInstance().post(
308
- api_url,
309
- { refreshToken },
310
- { headers }
311
- );
312
- const maybeData = response?.data?.data || response?.data;
313
- const tokenData = maybeData?.tokenData || maybeData || {};
314
- const newRefreshToken = tokenData?.refreshToken;
315
- const token = tokenData?.token;
316
- const expiresIn = tokenData?.expiresIn;
317
- const rExpiresIn = tokenData?.refreshExpiresIn;
318
- const rExpiresAt = tokenData?.refreshExpiresAt;
319
- if (typeof newRefreshToken === "string") {
320
- let rExpires = 0;
321
- if (typeof rExpiresIn === "number") {
322
- rExpires = Date.now() + rExpiresIn * 1e3;
323
- } else if (typeof rExpiresAt === "number") {
324
- rExpires = rExpiresAt * 1e3;
325
- }
326
- setRefreshToken(newRefreshToken, rExpires);
327
- }
328
- if (typeof token === "string") {
329
- setAccessToken(token, typeof expiresIn === "number" ? expiresIn : void 0);
330
- return { token, success: true };
331
- }
332
- return { token: null, success: false };
333
- } catch {
334
- return { token: null, success: false };
335
- }
336
- }
337
-
338
- // src/data/user.ts
339
- var PROFILE = null;
340
- var setProfileData = (data) => {
341
- PROFILE = data;
342
- };
343
- var getProfileData = () => {
344
- return PROFILE;
345
- };
346
-
347
- // src/client/index.ts
348
- var recordWriteContext = (paramsObject) => {
349
- if (!paramsObject) {
350
- return void 0;
351
- }
352
- const context = {};
353
- const keys = [
354
- "parentObjectTypeId",
355
- "parentObjectRecordId",
356
- "mediatorObjectTypeId",
357
- "mediatorObjectRecordId"
358
- ];
359
- keys.forEach((key) => {
360
- const value = paramsObject[key];
361
- if (value !== void 0 && value !== null && String(value).length > 0) {
362
- context[key] = String(value);
363
- }
364
- });
365
- return Object.keys(context).length > 0 ? context : void 0;
366
- };
367
- var mergeRecordWriteBody = (payload, paramsObject, options) => {
368
- const base = { ...payload || {} };
369
- const context = recordWriteContext(paramsObject);
370
- if (context) {
371
- base.context = context;
372
- }
373
- if (options && Object.keys(options).length > 0) {
374
- base.options = options;
375
- }
376
- return base;
377
- };
378
- var Client = {
379
- authentication: {
380
- preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
381
- login: (data) => {
382
- const queryParams = config.hubId ? { hubId: config.hubId } : null;
383
- return AuthHttpClient.post(
384
- generateApiUrl({ route: API_ENDPOINTS.LOGIN, queryParams }),
385
- data,
386
- config?.devPortalId && {
387
- headers: {
388
- "X-Dev-Portal-Id": config.devPortalId
389
- }
390
- }
391
- );
392
- },
393
- verifyEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL, data),
394
- resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
395
- resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
396
- forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
397
- registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
398
- verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
399
- resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
400
- logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
401
- },
402
- sso: {
403
- getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
404
- generateSsoUrl: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_URL, queryParams: payload?.queryParams })),
405
- ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
406
- },
407
- user: {
408
- me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
409
- profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
410
- changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
411
- },
412
- pipeline: {
413
- list: (payload = null, param = null) => {
414
- const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
415
- const { getParamDetails: getParamDetails2 } = routeParam;
416
- const { paramsObject } = getParamDetails2({ type: payload?.componentName });
417
- const userData = getProfileData();
418
- const apiParams = {};
419
- if (paramsObject?.parentObjectTypeId) {
420
- apiParams.parentObjectTypeId = paramsObject?.parentObjectTypeId;
421
- } else if (payload?.isHome && userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
422
- apiParams.parentObjectTypeId = userData?.data?.info?.objectTypeId;
423
- } else if (payload?.isHome && userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
424
- apiParams.parentObjectTypeId = "0-2";
425
- }
426
- apiParams.isPrimaryCompany = param?.isPrimaryCompany;
427
- apiParams.cache = payload?.cache;
428
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
429
- return HttpClient.get(apiUrl);
430
- }
431
- },
432
- stage: {
433
- list: (props = null) => {
434
- const params = {
435
- // hubId: config.hubId,
436
- // portalId: portalId,
437
- objectTypeId: props?.params?.objectTypeId,
438
- pipelineId: props?.params?.pipelineId
439
- };
440
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
441
- return HttpClient.get(apiUrl);
442
- }
443
- },
444
- object: {
445
- list: async (payload = null, param = null) => {
446
- param.cache = payload.cache;
447
- const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
448
- const { updateLink, getLinkParams } = useUpdateLink();
449
- const { getParamDetails: getParamDetails2 } = routeParam;
450
- const { paramsObject, parentAccessLabel } = getParamDetails2({ type: payload?.componentName });
451
- const userData = getProfileData();
452
- const pipeline = payload?.variables?.pipeline;
453
- const mPipelines = payload?.variables?.mPipelines;
454
- const mSelectedPipeline = pipeline !== void 0 ? pipeline : payload?.selectedPipeline;
455
- if (mSelectedPipeline) {
456
- param.filterValue = mSelectedPipeline;
457
- } else if (payload?.specPipeLine && payload?.pipeLineId) {
458
- param.filterValue = payload?.pipeLineId;
459
- } else if (payload?.hubspotObjectTypeId != "0-3" || payload?.hubspotObjectTypeId != "0-5") {
460
- param.filterValue = "";
461
- }
462
- const fParams = getLinkParams();
463
- param = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : param, ...paramsObject };
464
- if (!payload?.isFristTimeLoadData || !fParams) {
465
- await updateLink({
466
- "sort": param?.sort,
467
- "s": param?.search,
468
- "fPn": param?.filterPropertyName,
469
- "fO": param?.filterOperator,
470
- "fV": param?.filterValue,
471
- "c": param?.cache,
472
- "isPC": param?.isPrimaryCompany,
473
- "v": param?.view,
474
- "l": param?.limit,
475
- "p": param?.page,
476
- "a": param?.after
477
- });
478
- }
479
- if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
480
- param.filterValue = "";
481
- await updateLink({
482
- "fV": param?.filterValue
483
- });
484
- }
485
- if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
486
- param.filterValue = mPipelines[0].pipelineId;
487
- await updateLink({
488
- "fV": param?.filterValue
489
- });
490
- }
491
- if (payload?.isHome || payload?.hubspotObjectTypeId === "0-5" && payload?.componentName === "object") {
492
- let parentObjectTypeId = "";
493
- if (userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
494
- parentObjectTypeId = userData?.data?.info?.objectTypeId;
495
- } else if (userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
496
- parentObjectTypeId = "0-2";
497
- }
498
- param.parentObjectTypeId = parentObjectTypeId;
499
- }
500
- param.parentAccessLabel = parentAccessLabel;
501
- const {
502
- stageId,
503
- nextPage
504
- } = useTable();
505
- if (stageId) {
506
- param.stageId = stageId;
507
- }
508
- if (param?.view === "BOARD") {
509
- param.page = nextPage;
510
- }
511
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
512
- return HttpClient.get(apiUrl);
513
- },
514
- sideBarList: async (payload = null) => {
515
- const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
516
- const params = { hubspotObjectTypeId };
517
- const queryParams = payload.param;
518
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
519
- return HttpClient.get(apiUrl);
520
- },
521
- form: (payload = null) => {
522
- const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
523
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
524
- return HttpClient.get(apiUrl);
525
- },
526
- objectFormOptions: (payload = null) => {
527
- const params = {
528
- formId: payload?.formId,
529
- objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
530
- };
531
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
532
- return HttpClient.get(apiUrl);
533
- },
534
- create: (props = null) => {
535
- const { getParamDetails: getParamDetailsForCreate } = routeParam;
536
- const { paramsObject } = getParamDetailsForCreate({ type: props?.componentName });
537
- const cardParentMerge = props?.componentName === "association" ? true : false;
538
- const body = mergeRecordWriteBody(props?.payload, paramsObject, {
539
- cardParentMerge,
540
- addAnother: props?.params?.addAnother
541
- });
542
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
543
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
544
- return HttpClient.post(apiUrl, body);
545
- },
546
- createExisting: (props = null) => {
547
- const { getLinkParams } = useUpdateLink();
548
- const fParams = getLinkParams();
549
- const queryParams = { ...fParams, ...props?.params };
550
- const params = {
551
- fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
552
- fromRecordId: props?.fromRecordId,
553
- toObjectTypeId: props?.toObjectTypeId
554
- };
555
- const payload = props.payload;
556
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
557
- return HttpClient.post(apiUrl, payload);
558
- },
559
- removeExisting: (props = null) => {
560
- const { getParamDetails: getParamDetailsForRemove } = routeParam;
561
- const { paramsObject } = getParamDetailsForRemove({ type: props?.componentName });
562
- const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
563
- const params = {
564
- fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
565
- fromRecordId: props?.fromRecordId,
566
- toObjectTypeId: props?.toObjectTypeId
567
- };
568
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
569
- return HttpClient.delete(apiUrl, { data: body });
570
- },
571
- details: (props = null) => {
572
- const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
573
- const params = {
574
- // hubId: config.hubId,
575
- // portalId: portalId,
576
- objectId: props?.params?.objectId,
577
- id: props?.params?.id
578
- };
579
- const queryParams = {
580
- parentAccessLabel,
581
- ...props?.queryParams,
582
- ...urlParam
583
- };
584
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
585
- return HttpClient.get(apiUrl);
586
- },
587
- update: (props = null) => {
588
- const params = {
589
- objectId: props?.params?.objectId,
590
- id: props?.params?.id
591
- };
592
- const { getParamDetails: getParamDetailsForUpdate } = routeParam;
593
- const { paramsObject } = getParamDetailsForUpdate({ type: props?.componentName });
594
- const cardParentMerge = props?.componentName === "association" ? true : false;
595
- const rawPayload = props?.payload || {};
596
- const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
597
- const body = mergeRecordWriteBody(
598
- { properties },
599
- paramsObject,
600
- { cardParentMerge }
601
- );
602
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params });
603
- return HttpClient.put(apiUrl, body);
604
- }
605
- },
606
- note: {
607
- list: (props = null) => {
608
- const params = {
609
- // hubId: config.hubId,
610
- // portalId: portalId,
611
- objectId: props?.params?.objectId,
612
- id: props?.params?.id
613
- };
614
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
615
- return HttpClient.get(apiUrl);
616
- },
617
- create: (props = null) => {
618
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
619
- const queryParams = props.queryParams;
620
- const payload = props.payload;
621
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
622
- return HttpClient.post(apiUrl, payload);
623
- },
624
- update: (props = null) => {
625
- const params = {
626
- // hubId: config.hubId,
627
- // portalId: portalId,
628
- objectId: props?.params?.objectId,
629
- id: props?.params?.id,
630
- note_id: props?.params?.note_id
631
- };
632
- const { paramsObject: queryParams } = getParamDetails();
633
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
634
- return HttpClient.put(apiUrl, props.payload);
635
- },
636
- image: (props = null) => {
637
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
638
- const queryParams = props.queryParams;
639
- const payload = props.payload;
640
- const axiosConfig = props.config || {};
641
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
642
- return HttpClient.post(apiUrl, payload, {
643
- headers: {
644
- "Content-Type": "multipart/form-data"
645
- },
646
- ...axiosConfig
647
- });
648
- },
649
- attachment: (props = null) => {
650
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
651
- const queryParams = props.queryParams;
652
- const payload = props.payload;
653
- const axiosConfig = props.config || {};
654
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
655
- return HttpClient.post(apiUrl, payload, {
656
- headers: {
657
- "Content-Type": "multipart/form-data"
658
- },
659
- ...axiosConfig
660
- });
661
- }
662
- },
663
- email: {
664
- list: (props = null) => {
665
- const params = {
666
- // hubId: config.hubId,
667
- // portalId: portalId,
668
- objectId: props?.params?.objectId,
669
- id: props?.params?.id
670
- };
671
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
672
- return HttpClient.get(apiUrl);
673
- },
674
- create: (props = null) => {
675
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
676
- const queryParams = props.queryParams;
677
- const payload = props.payload;
678
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
679
- return HttpClient.post(apiUrl, payload);
680
- },
681
- update: (props = null) => {
682
- const params = {
683
- // hubId: config.hubId,
684
- // portalId: portalId,
685
- objectId: props?.params?.objectId,
686
- id: props?.params?.id,
687
- email_id: props?.params?.email_id ?? props?.params?.note_id
688
- };
689
- const { paramsObject: queryParams } = getParamDetails();
690
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
691
- return HttpClient.put(apiUrl, props.payload);
692
- },
693
- image: (props = null) => {
694
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
695
- const queryParams = props.queryParams;
696
- const payload = props.payload;
697
- const axiosConfig = props.config || {};
698
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
699
- return HttpClient.post(apiUrl, payload, {
700
- headers: {
701
- "Content-Type": "multipart/form-data"
702
- },
703
- ...axiosConfig
704
- });
705
- },
706
- attachment: (props = null) => {
707
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
708
- const queryParams = props.queryParams;
709
- const payload = props.payload;
710
- const axiosConfig = props.config || {};
711
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
712
- return HttpClient.post(apiUrl, payload, {
713
- headers: {
714
- "Content-Type": "multipart/form-data"
715
- },
716
- ...axiosConfig
717
- });
718
- }
719
- },
720
- cache: {
721
- purge: (body, headers) => {
722
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
723
- return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
724
- },
725
- purgeStatus: (purgeJobId) => {
726
- const apiUrl = generateApiUrl({
727
- route: API_ENDPOINTS.CACHE_PURGE_STATUS,
728
- params: { purgeJobId }
729
- });
730
- return HttpClient.get(apiUrl);
731
- }
732
- },
733
- file: {
734
- list: (props = null) => {
735
- const params = {
736
- // hubId: config.hubId,
737
- // portalId: portalId,
738
- objectId: props?.params?.objectId,
739
- id: props?.params?.id
740
- };
741
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
742
- return HttpClient.get(apiUrl);
743
- },
744
- details: (props = null) => {
745
- const params = {
746
- // hubId: config.hubId,
747
- // portalId: portalId,
748
- objectId: props?.params?.objectId,
749
- id: props?.params?.id,
750
- rowId: props?.params?.rowId
751
- };
752
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
753
- return HttpClient.get(apiUrl);
754
- },
755
- download: (props = null) => {
756
- const params = {
757
- objectId: props?.params?.objectId,
758
- id: props?.params?.id,
759
- rowId: props?.params?.rowId
760
- };
761
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
762
- return HttpClient.post(apiUrl, {});
763
- },
764
- addFolder: (props = null) => {
765
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
766
- const queryParams = props.queryParams;
767
- const payload = props.payload;
768
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
769
- return HttpClient.post(apiUrl, payload);
770
- },
771
- addFile: (props = null) => {
772
- const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
773
- const queryParams = props.queryParams;
774
- const payload = props.payload;
775
- const axiosConfig = props.config || {};
776
- const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
777
- return HttpClient.post(apiUrl, payload, {
778
- headers: {
779
- "Content-Type": "multipart/form-data"
780
- },
781
- ...axiosConfig
782
- });
783
- }
784
- }
785
- };
786
- function logError(context, error) {
787
- if (axios.isAxiosError(error)) {
788
- resetAllStore();
789
- console.error(context, {
790
- message: error.message,
791
- status: error.response?.status,
792
- statusText: error.response?.statusText,
793
- data: error.response?.data,
794
- url: error.config?.url,
795
- method: error.config?.method
796
- });
797
- return;
798
- }
799
- if (error instanceof Error) {
800
- console.error(context, error.message, error);
801
- return;
802
- }
803
- console.error(context, error);
804
- }
805
-
806
- // src/mutation/createMutation.ts
807
- function createMutation(mutationFn, options) {
808
- let inFlight = 0;
809
- let lastReportedLoading = null;
810
- const syncLoading = () => {
811
- const active = inFlight > 0;
812
- if (lastReportedLoading === active) return;
813
- lastReportedLoading = active;
814
- options?.onLoadingChange?.(active);
815
- };
816
- const mutate = async (payload) => {
817
- inFlight += 1;
818
- syncLoading();
819
- try {
820
- const response = await mutationFn(payload);
821
- await options?.onSuccess?.(response, payload);
822
- return response;
823
- } catch (error) {
824
- options?.onError?.(error, payload);
825
- logError("[mutation]", error);
826
- throw error;
827
- } finally {
828
- inFlight -= 1;
829
- syncLoading();
830
- }
831
- };
832
- return {
833
- mutate,
834
- isLoading: () => inFlight > 0
835
- };
836
- }
837
-
838
- // src/apis/authentication.ts
839
- function preLogin(options) {
840
- const { mutate, isLoading } = createMutation(
841
- async (payload) => {
842
- const response = await Client.authentication.preLogin(payload);
843
- return response;
844
- },
845
- options
846
- );
847
- return {
848
- mutate,
849
- login: mutate,
850
- isLoading
851
- };
852
- }
853
- function login(options) {
854
- const { mutate, isLoading } = createMutation(
855
- async (payload) => {
856
- const response = await Client.authentication.login(payload);
857
- const tokenData = response?.data?.tokenData || {};
858
- const loggedInDetails = response?.data?.loggedInDetails || {};
859
- const currentPortal = response?.data?.loggedInDetails?.currentPortal || {};
860
- const currentPortalId = currentPortal?.portalId || null;
861
- const SubscriptionType = loggedInDetails?.subscriptionType || "BASIC";
862
- const token = tokenData?.token;
863
- const refreshToken = tokenData?.refreshToken;
864
- const expiresIn = tokenData?.expiresIn;
865
- const rExpiresIn = tokenData?.refreshExpiresIn;
866
- setPortal(currentPortal);
867
- setSubscriptionType(SubscriptionType);
868
- await setAccessToken(token, expiresIn);
869
- await setRefreshToken(refreshToken, rExpiresIn);
870
- await setLoggedInDetails(response.data);
871
- setConfig.setDevPortalId(currentPortalId);
872
- return response;
873
- },
874
- options
875
- );
876
- return {
877
- mutate,
878
- login: mutate,
879
- isLoading
880
- };
881
- }
882
- function verifyEmail(options) {
883
- const { mutate, isLoading } = createMutation(
884
- async (payload) => {
885
- const verifyEmailPayload = payload || {};
886
- const token = getParam("token");
887
- if (!verifyEmailPayload?.token) verifyEmailPayload.token = token;
888
- const response = await Client.authentication.verifyEmail(verifyEmailPayload);
889
- return response;
890
- },
891
- options
892
- );
893
- return {
894
- mutate,
895
- verifyEmail: mutate,
896
- isLoading
897
- };
898
- }
899
- function resetPasswordVerifyToken(options) {
900
- const { mutate, isLoading } = createMutation(
901
- async (payload) => {
902
- const resetPasswordVerifyTokenPayload = payload || {};
903
- const token = getParam("token");
904
- if (!resetPasswordVerifyTokenPayload?.token) resetPasswordVerifyTokenPayload.token = token;
905
- const response = await Client.authentication.resetPasswordVerifyToken(resetPasswordVerifyTokenPayload);
906
- return response;
907
- },
908
- options
909
- );
910
- return {
911
- mutate,
912
- resetPasswordVerifyToken: mutate,
913
- isLoading
914
- };
915
- }
916
- function resetPassword(options) {
917
- const { mutate, isLoading } = createMutation(
918
- async (payload) => {
919
- const response = await Client.authentication.resetPassword(payload);
920
- return response;
921
- },
922
- options
923
- );
924
- return {
925
- mutate,
926
- resetPassword: mutate,
927
- isLoading
928
- };
929
- }
930
- function forgetPassword(options) {
931
- const { mutate, isLoading } = createMutation(
932
- async (payload) => {
933
- const response = await Client.authentication.forgetPassword(payload);
934
- return response;
935
- },
936
- options
937
- );
938
- return {
939
- mutate,
940
- forgetPassword: mutate,
941
- isLoading
942
- };
943
- }
944
- function logout(options) {
945
- const { mutate, isLoading } = createMutation(
946
- async () => {
947
- const response = await Client.authentication.logout();
948
- clearAccessToken();
949
- removeAllCookie();
950
- return response;
951
- },
952
- options
953
- );
954
- return {
955
- mutate,
956
- logout: mutate,
957
- isLoading
958
- };
959
- }
960
- function registerExistingUser(options) {
961
- const { mutate, isLoading } = createMutation(
962
- async (payload) => {
963
- const response = await Client.authentication.registerExistingUser(payload);
964
- return response;
965
- },
966
- options
967
- );
968
- return {
969
- mutate,
970
- registerExistingUser: mutate,
971
- isLoading
972
- };
973
- }
974
- function verifyEmailResend(options) {
975
- const { mutate, isLoading } = createMutation(
976
- async (payload) => {
977
- const response = await Client.authentication.verifyEmailResend(payload);
978
- return response;
979
- },
980
- options
981
- );
982
- return {
983
- mutate,
984
- verifyEmailResend: mutate,
985
- isLoading
986
- };
987
- }
988
- function resendEmail(options) {
989
- const { mutate, isLoading } = createMutation(
990
- async (payload) => {
991
- const response = await Client.authentication.resendEmail(payload);
992
- return response;
993
- },
994
- options
995
- );
996
- return {
997
- mutate,
998
- resendEmail: mutate,
999
- isLoading
1000
- };
1001
- }
1002
-
1003
- // src/apis/sso.ts
1004
- function getSsoDetails(options) {
1005
- const { mutate, isLoading } = createMutation(
1006
- async () => {
1007
- const response = await Client.sso.getSsoDetails();
1008
- return response;
1009
- },
1010
- options
1011
- );
1012
- return {
1013
- mutate,
1014
- getSsoDetails: mutate,
1015
- isLoading
1016
- };
1017
- }
1018
- function generateSsoUrl(options) {
1019
- const { mutate, isLoading } = createMutation(
1020
- async (payload) => {
1021
- const response = await Client.sso.generateSsoUrl(payload);
1022
- return response;
1023
- },
1024
- options
1025
- );
1026
- return {
1027
- mutate,
1028
- generateSsoUrl: mutate,
1029
- isLoading
1030
- };
1031
- }
1032
- function ssoCallback(options) {
1033
- const { mutate, isLoading } = createMutation(
1034
- async (payload) => {
1035
- const response = await Client.sso.ssoCallback(payload);
1036
- return response;
1037
- },
1038
- options
1039
- );
1040
- return {
1041
- mutate,
1042
- ssoCallback: mutate,
1043
- isLoading
1044
- };
1045
- }
1046
-
1047
- // src/apis/users.ts
1048
- function me(options) {
1049
- const { mutate, isLoading } = createMutation(
1050
- async () => {
1051
- const response = await Client.user.me();
1052
- return response;
1053
- },
1054
- options
1055
- );
1056
- return {
1057
- mutate,
1058
- me: mutate,
1059
- isLoading
1060
- };
1061
- }
1062
- function profile(options) {
1063
- const { mutate, isLoading } = createMutation(
1064
- async (paylaod) => {
1065
- const response = await Client.user.profile(paylaod);
1066
- setProfileData(response);
1067
- return response;
1068
- },
1069
- options
1070
- );
1071
- return {
1072
- mutate,
1073
- profile: mutate,
1074
- isLoading
1075
- };
1076
- }
1077
- function changePassword(options) {
1078
- const { mutate, isLoading } = createMutation(
1079
- async (payload) => {
1080
- const response = await Client.user.changePassword(payload);
1081
- return response;
1082
- },
1083
- options
1084
- );
1085
- return {
1086
- mutate,
1087
- changePassword: mutate,
1088
- isLoading
1089
- };
1090
- }
1091
-
1092
- // src/apis/pipeline.ts
1093
- function list(options) {
1094
- const {
1095
- getTableParam
1096
- } = useTable();
1097
- const { mutate, isLoading } = createMutation(
1098
- async (payload) => {
1099
- const param = await getTableParam(payload?.companyAsMediator);
1100
- const response = await Client.pipeline.list(payload, param);
1101
- return response;
1102
- },
1103
- options
1104
- );
1105
- return {
1106
- mutate,
1107
- getPipelines: mutate,
1108
- isLoading
1109
- };
1110
- }
1111
-
1112
- // src/apis/stage.ts
1113
- function list2(options) {
1114
- const { mutate, isLoading } = createMutation(
1115
- async (payload) => {
1116
- const response = await Client.stage.list(payload);
1117
- return response;
1118
- },
1119
- options
1120
- );
1121
- return {
1122
- mutate,
1123
- getStages: mutate,
1124
- isLoading
1125
- };
1126
- }
1127
-
1128
- // src/apis/object.ts
1129
- function list3(options) {
1130
- const { getTableParam } = useTable();
1131
- const { setObjectsData, setTableData } = actions2;
1132
- const { mutate, isLoading } = createMutation(
1133
- async (payload) => {
1134
- const param = await getTableParam(payload?.companyAsMediator);
1135
- const response = await Client.object.list(payload, param);
1136
- await setObjectsData(response);
1137
- await setTableData(response, payload);
1138
- return response;
1139
- },
1140
- options
1141
- );
1142
- return {
1143
- mutate,
1144
- getObjects: mutate,
1145
- isLoading
1146
- };
1147
- }
1148
- function sideBarList(options) {
1149
- const { setMultiObjectData } = actions7;
1150
- const { mutate, isLoading } = createMutation(
1151
- async (payload) => {
1152
- const response = await Client.object.sideBarList(payload);
1153
- setMultiObjectData(response, payload);
1154
- return response;
1155
- },
1156
- options
1157
- );
1158
- return {
1159
- mutate,
1160
- getSideBarObjects: mutate,
1161
- isLoading
1162
- };
1163
- }
1164
- function form(options) {
1165
- const { setFormData } = actions;
1166
- const { mutate, isLoading } = createMutation(
1167
- async (payload) => {
1168
- const response = await Client.object.form(payload);
1169
- setFormData(response);
1170
- return response;
1171
- },
1172
- options
1173
- );
1174
- return {
1175
- mutate,
1176
- getObjectsForm: mutate,
1177
- isLoading
1178
- };
1179
- }
1180
- function objectFormOptions(options) {
1181
- const { mutate, isLoading } = createMutation(
1182
- async (payload) => {
1183
- const response = await Client.object.objectFormOptions(payload);
1184
- return response;
1185
- },
1186
- options
1187
- );
1188
- return {
1189
- mutate,
1190
- objectFormOptions: mutate,
1191
- isLoading
1192
- };
1193
- }
1194
- function create(options) {
1195
- const { setTablePrependData } = actions2;
1196
- const { setMultiObjectPrependData } = actions7;
1197
- const { mutate, isLoading } = createMutation(
1198
- async (props) => {
1199
- if (props?.componentName === "sidebarTable") await setMultiObjectPrependData("loading", props);
1200
- if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData("loading", props);
1201
- const response = await Client.object.create(props);
1202
- if (props?.componentName === "sidebarTable") await setMultiObjectPrependData(response, props);
1203
- if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData(response, props);
1204
- return response;
1205
- },
1206
- options
1207
- );
1208
- return {
1209
- mutate,
1210
- createObject: mutate,
1211
- isLoading
1212
- };
1213
- }
1214
- function createExisting(options) {
1215
- const { mutate, isLoading } = createMutation(
1216
- async (props) => {
1217
- const response = await Client.object.createExisting(props);
1218
- return response;
1219
- },
1220
- options
1221
- );
1222
- return {
1223
- mutate,
1224
- createExistingObject: mutate,
1225
- isLoading
1226
- };
1227
- }
1228
- function removeExisting(options) {
1229
- const { mutate, isLoading } = createMutation(
1230
- async (props) => {
1231
- const response = await Client.object.removeExisting(props);
1232
- return response;
1233
- },
1234
- options
1235
- );
1236
- return {
1237
- mutate,
1238
- removeExisting: mutate,
1239
- isLoading
1240
- };
1241
- }
1242
- function details(options) {
1243
- const { mutate, isLoading } = createMutation(
1244
- async (payload) => {
1245
- const response = await Client.object.details(payload);
1246
- return response;
1247
- },
1248
- options
1249
- );
1250
- return {
1251
- mutate,
1252
- getObjectsDetails: mutate,
1253
- isLoading
1254
- };
1255
- }
1256
- function update(options) {
1257
- const { mutate, isLoading } = createMutation(
1258
- async (payload) => {
1259
- const response = await Client.object.update(payload);
1260
- return response;
1261
- },
1262
- options
1263
- );
1264
- return {
1265
- mutate,
1266
- updateObjectsDetails: mutate,
1267
- isLoading
1268
- };
1269
- }
1270
-
1271
- // src/apis/note.ts
1272
- function list4(options) {
1273
- const { setNotes } = actions4;
1274
- const { mutate, isLoading } = createMutation(
1275
- async (payload) => {
1276
- const response = await Client.note.list(payload);
1277
- setNotes(response, payload);
1278
- return response;
1279
- },
1280
- options
1281
- );
1282
- return {
1283
- mutate,
1284
- getNotes: mutate,
1285
- isLoading
1286
- };
1287
- }
1288
- function create2(options) {
1289
- const { setPrependNote } = actions4;
1290
- const { mutate, isLoading } = createMutation(
1291
- async (props) => {
1292
- await setPrependNote("loading");
1293
- const response = await Client.note.create(props);
1294
- await setPrependNote(response);
1295
- return response;
1296
- },
1297
- options
1298
- );
1299
- return {
1300
- mutate,
1301
- createNote: mutate,
1302
- isLoading
1303
- };
1304
- }
1305
- function update2(options) {
1306
- const { updatePrependNote } = actions4;
1307
- const { mutate, isLoading } = createMutation(
1308
- async (payload) => {
1309
- const response = await Client.note.update(payload);
1310
- return updatePrependNote(response);
1311
- },
1312
- options
1313
- );
1314
- return {
1315
- mutate,
1316
- updateNote: mutate,
1317
- isLoading
1318
- };
1319
- }
1320
-
1321
- // src/apis/email.ts
1322
- function list5(options) {
1323
- const { setEmails } = actions5;
1324
- const { mutate, isLoading } = createMutation(
1325
- async (payload) => {
1326
- const response = await Client.email.list(payload);
1327
- setEmails(response, payload);
1328
- return response;
1329
- },
1330
- options
1331
- );
1332
- return {
1333
- mutate,
1334
- getEmails: mutate,
1335
- isLoading
1336
- };
1337
- }
1338
- function create3(options) {
1339
- const { setPrependEmail } = actions5;
1340
- const { mutate, isLoading } = createMutation(
1341
- async (props) => {
1342
- await setPrependEmail("loading");
1343
- const response = await Client.email.create(props);
1344
- await setPrependEmail(response);
1345
- return response;
1346
- },
1347
- options
1348
- );
1349
- return {
1350
- mutate,
1351
- createEmail: mutate,
1352
- isLoading
1353
- };
1354
- }
1355
- function update3(options) {
1356
- const { updatePrependEmail } = actions5;
1357
- const { mutate, isLoading } = createMutation(
1358
- async (payload) => {
1359
- const response = await Client.email.update(payload);
1360
- return updatePrependEmail(response);
1361
- },
1362
- options
1363
- );
1364
- return {
1365
- mutate,
1366
- updateEmail: mutate,
1367
- isLoading
1368
- };
1369
- }
1370
-
1371
- // src/apis/uploader.ts
1372
- function imageUpload(options) {
1373
- const { mutate, isLoading } = createMutation(
1374
- async (payload) => {
1375
- const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
1376
- return response;
1377
- },
1378
- options
1379
- );
1380
- return {
1381
- mutate,
1382
- imageUpload: mutate,
1383
- isLoading
1384
- };
1385
- }
1386
- function attachmentUpload(options) {
1387
- const { mutate, isLoading } = createMutation(
1388
- async (payload) => {
1389
- const response = payload?.type === "email" ? await Client.email.attachment(payload) : await Client.note.attachment(payload);
1390
- actions3.setAttachment(response);
1391
- return response;
1392
- },
1393
- options
1394
- );
1395
- return {
1396
- mutate,
1397
- attachmentUpload: mutate,
1398
- isLoading
1399
- };
1400
- }
1401
-
1402
- // src/apis/file.ts
1403
- function list6(options) {
1404
- const { mutate, isLoading } = createMutation(
1405
- async (payload) => {
1406
- const response = await Client.file.list(payload);
1407
- return response;
1408
- },
1409
- options
1410
- );
1411
- return {
1412
- mutate,
1413
- getFiles: mutate,
1414
- isLoading
1415
- };
1416
- }
1417
- function details2(options) {
1418
- const { mutate, isLoading } = createMutation(
1419
- async (payload) => {
1420
- const response = await Client.file.details(payload);
1421
- return response;
1422
- },
1423
- options
1424
- );
1425
- return {
1426
- mutate,
1427
- getFile: mutate,
1428
- isLoading
1429
- };
1430
- }
1431
- function addFolder(options) {
1432
- const { mutate, isLoading } = createMutation(
1433
- async (props) => {
1434
- const response = await Client.file.addFolder(props);
1435
- return response;
1436
- },
1437
- options
1438
- );
1439
- return {
1440
- mutate,
1441
- addFolder: mutate,
1442
- isLoading
1443
- };
1444
- }
1445
- function addFile(options) {
1446
- const { mutate, isLoading } = createMutation(
1447
- async (props) => {
1448
- const response = await Client.file.addFile(props);
1449
- return response;
1450
- },
1451
- options
1452
- );
1453
- return {
1454
- mutate,
1455
- addFile: mutate,
1456
- isLoading
1457
- };
1458
- }
1459
- function download(options) {
1460
- const { mutate, isLoading } = createMutation(
1461
- async (payload) => {
1462
- const response = await Client.file.download(payload);
1463
- return response;
1464
- },
1465
- options
1466
- );
1467
- return {
1468
- mutate,
1469
- downloadFile: mutate,
1470
- isLoading
1471
- };
1472
- }
1473
-
1474
- // src/apis/cache.ts
1475
- function purge(options) {
1476
- const { mutate, isLoading } = createMutation(
1477
- async (payload) => {
1478
- const safePayload = payload ?? {};
1479
- const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
1480
- const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
1481
- const { idempotencyKey: _ignored, ...body } = safePayload;
1482
- return Client.cache.purge(body, headers);
1483
- },
1484
- options
1485
- );
1486
- return { mutate, purgeCache: mutate, isLoading };
1487
- }
1488
- function purgeStatus(purgeJobId, options) {
1489
- const { mutate, isLoading } = createMutation(
1490
- async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
1491
- options
1492
- );
1493
- return {
1494
- mutate,
1495
- getPurgeStatus: () => mutate(purgeJobId),
1496
- isLoading
1497
- };
1498
- }
1499
-
1500
- // src/breadcrumb/breadcrumbs.ts
1501
- var getBreadcrumbs = () => {
1502
- const search = getParam("b");
1503
- let breadcrumbs = decodeToBase64(search) || [];
1504
- if (!breadcrumbs && breadcrumbs.length < 1) return [];
1505
- const updated = breadcrumbs.map((breadcrumb, index) => {
1506
- return generatePath(breadcrumbs, breadcrumb, index);
1507
- });
1508
- if (updated.length < 1) {
1509
- const pathname = getPath();
1510
- const routeMenu = getRouteMenu(pathname);
1511
- return [
1512
- {
1513
- name: routeMenu?.title,
1514
- path: routeMenu?.path
1515
- }
1516
- ];
1517
- }
1518
- return updated;
1519
- };
1520
- var getTableTitle = (componentName, title, ticketTableTitle) => {
1521
- const search = getParam("b");
1522
- let breadcrumbs = decodeToBase64(search) || [];
1523
- if (breadcrumbs.length < 1) {
1524
- const pathname = getPath();
1525
- const routeMenu = getRouteMenu(pathname);
1526
- breadcrumbs = [
1527
- {
1528
- n: routeMenu?.title,
1529
- pt: routeMenu?.path
1530
- }
1531
- ];
1532
- }
1533
- let associatedtableTitleSingular = "";
1534
- let tableTitle = "";
1535
- let singularTableTitle = "";
1536
- if (breadcrumbs && breadcrumbs.length > 0) {
1537
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
1538
- const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
1539
- const previousItem = breadcrumbs[breadcrumbs.length - 2];
1540
- const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
1541
- const singularLastName = last?.name;
1542
- associatedtableTitleSingular = singularLastName;
1543
- if (componentName != "ticket") {
1544
- tableTitle = previous?.name ? { last, previous } : { last };
1545
- singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
1546
- } else {
1547
- const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
1548
- tableTitle = { last: { name: title } };
1549
- singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
1550
- }
1551
- }
1552
- return { associatedtableTitleSingular, tableTitle, singularTableTitle };
1553
- };
1554
- var getFormTitle = (type, title, activeTab) => {
1555
- const search = getParam("b");
1556
- let breadcrumbs = decodeToBase64(search) || [];
1557
- if (breadcrumbs.length < 1) {
1558
- const pathname = getPath();
1559
- const routeMenu = getRouteMenu(pathname);
1560
- breadcrumbs = [
1561
- {
1562
- n: routeMenu?.title,
1563
- pt: routeMenu?.path
1564
- }
1565
- ];
1566
- }
1567
- let objectName = "";
1568
- let puralObjectName = "";
1569
- let dialogTitle = "";
1570
- if (breadcrumbs && breadcrumbs?.length > 0) {
1571
- const last = breadcrumbs[breadcrumbs?.length - 1];
1572
- const lastName = last?.n;
1573
- const mTitle = title;
1574
- if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
1575
- objectName = title;
1576
- puralObjectName = title;
1577
- dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
1578
- } else {
1579
- const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
1580
- objectName = singularLastName;
1581
- puralObjectName = lastName;
1582
- dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
1583
- }
1584
- }
1585
- return { objectName, puralObjectName, dialogTitle };
1586
- };
1587
- var nameTrancate = (name) => {
1588
- return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
1589
- };
1590
-
1591
- // src/breadcrumb/generate-url.ts
1592
- var useMakeLink = () => {
1593
- const search = getParam("b");
1594
- const makeLink = (props) => {
1595
- if (!search || "isPC" in props) {
1596
- return buildParentRoute(props);
1597
- } else {
1598
- const breadcrumbItems = decodeToBase64(search) || [];
1599
- return buildChildRoute(props, breadcrumbItems);
1600
- }
1601
- };
1602
- return { makeLink };
1603
- };
1604
- var buildParentRoute = (props) => {
1605
- const pathname = getPath();
1606
- const routeMenu = getRouteMenu(pathname);
1607
- const breadcrumbItems = [
1608
- {
1609
- n: routeMenu?.title,
1610
- o_t_id: routeMenu?.path,
1611
- isHome: props?.isHome || false
1612
- }
1613
- ];
1614
- return buildChildRoute(props, breadcrumbItems);
1615
- };
1616
- var buildChildRoute = (props, breadcrumbItems) => {
1617
- let breadcrumbs = [...breadcrumbItems];
1618
- let breadcrumbType = breadcrumbStage(breadcrumbItems);
1619
- if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
1620
- const parent = {
1621
- n: props?.title || "",
1622
- o_t_id: props?.objectTypeId,
1623
- "pt": `/association/${props?.objectTypeId}`,
1624
- isHome: props?.isHome || false,
1625
- "prm": {
1626
- "sort": "-hs_createdate",
1627
- "s": "",
1628
- "fPn": "hs_pipeline",
1629
- "fO": "eq",
1630
- "fV": "",
1631
- "c": true,
1632
- "isPC": props?.isPC,
1633
- "v": "LIST",
1634
- "l": "10",
1635
- "p": 1
1636
- }
1637
- };
1638
- breadcrumbs.push(parent);
1639
- const newCrumb = {
1640
- n: props?.name,
1641
- o_t_id: props?.objectTypeId,
1642
- o_r_id: props?.recordId
1643
- };
1644
- breadcrumbs.push(newCrumb);
1645
- } else if (breadcrumbType === "root") {
1646
- const newCrumb = {
1647
- n: props?.name,
1648
- o_t_id: props?.objectTypeId,
1649
- o_r_id: props?.recordId
1650
- };
1651
- if (props?.isPC) {
1652
- newCrumb.prm = {
1653
- isPC: props?.isPC
1654
- };
1655
- }
1656
- breadcrumbs.push(newCrumb);
1657
- } else {
1658
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
1659
- if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
1660
- (!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
1661
- (props?.isHome && !isMessingParentLastItem(breadcrumbItems))) {
1662
- const newCrumb = {
1663
- n: props?.name,
1664
- o_t_id: props?.objectTypeId,
1665
- o_r_id: props?.recordId
1666
- };
1667
- if (props?.isPC) {
1668
- newCrumb.prm = {
1669
- isPC: props?.isPC
1670
- };
1671
- }
1672
- breadcrumbs.push(newCrumb);
1673
- } else {
1674
- const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
1675
- const parent = {
1676
- n: props?.associationLabel || props?.name,
1677
- o_t_id: props?.objectTypeId
1678
- };
1679
- if (props?.tableParam) {
1680
- parent.prm = props?.tableParam;
1681
- }
1682
- if (props?.defPermissions) {
1683
- parent.dp = props?.defPermissions;
1684
- }
1685
- if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
1686
- breadcrumbs.push(parent);
1687
- }
1688
- if (props?.recordId) {
1689
- const newCrumb = {
1690
- n: props?.name,
1691
- o_t_id: props?.objectTypeId,
1692
- o_r_id: props?.recordId
1693
- };
1694
- if (props?.isPC) {
1695
- newCrumb.prm = {
1696
- isPC: props?.isPC
1697
- };
1698
- }
1699
- breadcrumbs.push(newCrumb);
1700
- }
1701
- }
1702
- }
1703
- return generateUrl(props, breadcrumbs);
1704
- };
1705
-
1706
- // src/utils/datetime.ts
1707
- var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
1708
- function getCurrentTimeZone() {
1709
- try {
1710
- return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
1711
- } catch {
1712
- return DEFAULT_HUBSPOT_TIMEZONE;
1713
- }
1714
- }
1715
- function normalizeToTimestamp(value) {
1716
- if (value == null || value === "") return null;
1717
- if (typeof value === "number") {
1718
- return value > 1e11 ? value : null;
1719
- }
1720
- if (typeof value === "string" && /^\d+$/.test(value)) {
1721
- const n = Number(value);
1722
- return n > 1e11 ? n : null;
1723
- }
1724
- if (typeof value === "string" || value instanceof Date) {
1725
- const date = new Date(value);
1726
- return Number.isNaN(date.getTime()) ? null : date.getTime();
1727
- }
1728
- return null;
1729
- }
1730
- function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
1731
- const raw = new Intl.DateTimeFormat("en-US", {
1732
- timeZone,
1733
- timeZoneName: "longOffset"
1734
- }).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
1735
- if (!raw) return "";
1736
- return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
1737
- }
1738
- function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
1739
- const ms = normalizeToTimestamp(timestamp);
1740
- if (ms == null) return null;
1741
- const date = new Date(ms);
1742
- const datePart = new Intl.DateTimeFormat("en-US", {
1743
- timeZone,
1744
- month: "long",
1745
- day: "numeric",
1746
- year: "numeric"
1747
- }).format(date);
1748
- const timePart = new Intl.DateTimeFormat("en-US", {
1749
- timeZone,
1750
- hour: "numeric",
1751
- minute: "2-digit",
1752
- hour12: true
1753
- }).format(date);
1754
- const gmtOffset = formatGmtOffset(timeZone, date);
1755
- return {
1756
- date: datePart,
1757
- time: timePart,
1758
- gmtOffset,
1759
- formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
1760
- };
1761
- }
1762
- function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
1763
- return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
1764
- }
1765
-
1766
- // src/index.ts
1767
- var api = {
1768
- preLogin,
1769
- login,
1770
- verifyEmail,
1771
- resetPasswordVerifyToken,
1772
- resetPassword,
1773
- registerExistingUser,
1774
- verifyEmailResend,
1775
- resendEmail,
1776
- getSsoDetails,
1777
- generateSsoUrl,
1778
- ssoCallback,
1779
- forgetPassword,
1780
- logout,
1781
- me,
1782
- profile,
1783
- changePassword,
1784
- pipelines: list,
1785
- stages: list2,
1786
- objects: list3,
1787
- sideBarObjects: sideBarList,
1788
- objectsForm: form,
1789
- createObject: create,
1790
- createExistingObject: createExisting,
1791
- removeExistingObject: removeExisting,
1792
- objectsDetails: details,
1793
- updateObjectsDetails: update,
1794
- objectFormOptions,
1795
- notes: list4,
1796
- createNote: create2,
1797
- updateNote: update2,
1798
- emails: list5,
1799
- createEmail: create3,
1800
- updateEmail: update3,
1801
- imageUpload,
1802
- attachmentUpload,
1803
- files: list6,
1804
- file: details2,
1805
- fileDownload: download,
1806
- addFolder,
1807
- addFile,
1808
- purgeCache: purge,
1809
- cachePurgeStatus: purgeStatus,
1810
- getRefreshToken,
1811
- getAuthRefreshToken,
1812
- isCookieExpired,
1813
- isExpiresAccessToken,
1814
- isAuthenticateApp,
1815
- getAccessToken
1816
- };
1817
- var store = {
1818
- storage,
1819
- useTable
1820
- };
1821
- var breadcrumbsDetails = {
1822
- getBreadcrumbs,
1823
- getTableTitle,
1824
- getFormTitle
1825
- };
1826
- var url = {
1827
- useMakeLink,
1828
- useUpdateLink
1829
- };
1830
- var routeParam = {
1831
- getRouteDetails,
1832
- getParamDetails
1833
- };
1834
-
1835
- export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url };
1
+ export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url } from './chunk-3WO26LA6.js';
2
+ import './chunk-24HIDVUO.js';
1836
3
  //# sourceMappingURL=index.js.map
1837
4
  //# sourceMappingURL=index.js.map