woodsportal-client-sdk 1.1.4-dev.51 → 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,1835 +1,4 @@
1
- import { getParamDetails, useUpdateLink, useTable, getRouteDetails, actions, actions6, actions3, actions4, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl, resetAllStore, actions2 } from './chunk-B4J3MT7F.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 } = actions;
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 } = actions6;
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 { mutate, isLoading } = createMutation(
1166
- async (payload) => {
1167
- const response = await Client.object.form(payload);
1168
- return response;
1169
- },
1170
- options
1171
- );
1172
- return {
1173
- mutate,
1174
- getObjectsForm: mutate,
1175
- isLoading
1176
- };
1177
- }
1178
- function objectFormOptions(options) {
1179
- const { mutate, isLoading } = createMutation(
1180
- async (payload) => {
1181
- const response = await Client.object.objectFormOptions(payload);
1182
- return response;
1183
- },
1184
- options
1185
- );
1186
- return {
1187
- mutate,
1188
- objectFormOptions: mutate,
1189
- isLoading
1190
- };
1191
- }
1192
- function create(options) {
1193
- const { setTablePrependData } = actions;
1194
- const { setMultiObjectPrependData } = actions6;
1195
- const { mutate, isLoading } = createMutation(
1196
- async (props) => {
1197
- if (props?.componentName === "sidebarTable") await setMultiObjectPrependData("loading", props);
1198
- if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData("loading", props);
1199
- const response = await Client.object.create(props);
1200
- if (props?.componentName === "sidebarTable") await setMultiObjectPrependData(response, props);
1201
- if (props?.componentName != "association" && props?.componentName != "sidebarTable") await setTablePrependData(response, props);
1202
- return response;
1203
- },
1204
- options
1205
- );
1206
- return {
1207
- mutate,
1208
- createObject: mutate,
1209
- isLoading
1210
- };
1211
- }
1212
- function createExisting(options) {
1213
- const { mutate, isLoading } = createMutation(
1214
- async (props) => {
1215
- const response = await Client.object.createExisting(props);
1216
- return response;
1217
- },
1218
- options
1219
- );
1220
- return {
1221
- mutate,
1222
- createExistingObject: mutate,
1223
- isLoading
1224
- };
1225
- }
1226
- function removeExisting(options) {
1227
- const { mutate, isLoading } = createMutation(
1228
- async (props) => {
1229
- const response = await Client.object.removeExisting(props);
1230
- return response;
1231
- },
1232
- options
1233
- );
1234
- return {
1235
- mutate,
1236
- removeExisting: mutate,
1237
- isLoading
1238
- };
1239
- }
1240
- function details(options) {
1241
- const { mutate, isLoading } = createMutation(
1242
- async (payload) => {
1243
- const response = await Client.object.details(payload);
1244
- return response;
1245
- },
1246
- options
1247
- );
1248
- return {
1249
- mutate,
1250
- getObjectsDetails: mutate,
1251
- isLoading
1252
- };
1253
- }
1254
- function update(options) {
1255
- const { mutate, isLoading } = createMutation(
1256
- async (payload) => {
1257
- const response = await Client.object.update(payload);
1258
- return response;
1259
- },
1260
- options
1261
- );
1262
- return {
1263
- mutate,
1264
- updateObjectsDetails: mutate,
1265
- isLoading
1266
- };
1267
- }
1268
-
1269
- // src/apis/note.ts
1270
- function list4(options) {
1271
- const { setNotes } = actions3;
1272
- const { mutate, isLoading } = createMutation(
1273
- async (payload) => {
1274
- const response = await Client.note.list(payload);
1275
- setNotes(response, payload);
1276
- return response;
1277
- },
1278
- options
1279
- );
1280
- return {
1281
- mutate,
1282
- getNotes: mutate,
1283
- isLoading
1284
- };
1285
- }
1286
- function create2(options) {
1287
- const { setPrependNote } = actions3;
1288
- const { mutate, isLoading } = createMutation(
1289
- async (props) => {
1290
- await setPrependNote("loading");
1291
- const response = await Client.note.create(props);
1292
- await setPrependNote(response);
1293
- return response;
1294
- },
1295
- options
1296
- );
1297
- return {
1298
- mutate,
1299
- createNote: mutate,
1300
- isLoading
1301
- };
1302
- }
1303
- function update2(options) {
1304
- const { updatePrependNote } = actions3;
1305
- const { mutate, isLoading } = createMutation(
1306
- async (payload) => {
1307
- const response = await Client.note.update(payload);
1308
- return updatePrependNote(response);
1309
- },
1310
- options
1311
- );
1312
- return {
1313
- mutate,
1314
- updateNote: mutate,
1315
- isLoading
1316
- };
1317
- }
1318
-
1319
- // src/apis/email.ts
1320
- function list5(options) {
1321
- const { setEmails } = actions4;
1322
- const { mutate, isLoading } = createMutation(
1323
- async (payload) => {
1324
- const response = await Client.email.list(payload);
1325
- setEmails(response, payload);
1326
- return response;
1327
- },
1328
- options
1329
- );
1330
- return {
1331
- mutate,
1332
- getEmails: mutate,
1333
- isLoading
1334
- };
1335
- }
1336
- function create3(options) {
1337
- const { setPrependEmail } = actions4;
1338
- const { mutate, isLoading } = createMutation(
1339
- async (props) => {
1340
- await setPrependEmail("loading");
1341
- const response = await Client.email.create(props);
1342
- await setPrependEmail(response);
1343
- return response;
1344
- },
1345
- options
1346
- );
1347
- return {
1348
- mutate,
1349
- createEmail: mutate,
1350
- isLoading
1351
- };
1352
- }
1353
- function update3(options) {
1354
- const { updatePrependEmail } = actions4;
1355
- const { mutate, isLoading } = createMutation(
1356
- async (payload) => {
1357
- const response = await Client.email.update(payload);
1358
- return updatePrependEmail(response);
1359
- },
1360
- options
1361
- );
1362
- return {
1363
- mutate,
1364
- updateEmail: mutate,
1365
- isLoading
1366
- };
1367
- }
1368
-
1369
- // src/apis/uploader.ts
1370
- function imageUpload(options) {
1371
- const { mutate, isLoading } = createMutation(
1372
- async (payload) => {
1373
- const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
1374
- return response;
1375
- },
1376
- options
1377
- );
1378
- return {
1379
- mutate,
1380
- imageUpload: mutate,
1381
- isLoading
1382
- };
1383
- }
1384
- function attachmentUpload(options) {
1385
- const { mutate, isLoading } = createMutation(
1386
- async (payload) => {
1387
- const response = payload?.type === "email" ? await Client.email.attachment(payload) : await Client.note.attachment(payload);
1388
- actions2.setAttachment(response);
1389
- return response;
1390
- },
1391
- options
1392
- );
1393
- return {
1394
- mutate,
1395
- attachmentUpload: mutate,
1396
- isLoading
1397
- };
1398
- }
1399
-
1400
- // src/apis/file.ts
1401
- function list6(options) {
1402
- const { mutate, isLoading } = createMutation(
1403
- async (payload) => {
1404
- const response = await Client.file.list(payload);
1405
- return response;
1406
- },
1407
- options
1408
- );
1409
- return {
1410
- mutate,
1411
- getFiles: mutate,
1412
- isLoading
1413
- };
1414
- }
1415
- function details2(options) {
1416
- const { mutate, isLoading } = createMutation(
1417
- async (payload) => {
1418
- const response = await Client.file.details(payload);
1419
- return response;
1420
- },
1421
- options
1422
- );
1423
- return {
1424
- mutate,
1425
- getFile: mutate,
1426
- isLoading
1427
- };
1428
- }
1429
- function addFolder(options) {
1430
- const { mutate, isLoading } = createMutation(
1431
- async (props) => {
1432
- const response = await Client.file.addFolder(props);
1433
- return response;
1434
- },
1435
- options
1436
- );
1437
- return {
1438
- mutate,
1439
- addFolder: mutate,
1440
- isLoading
1441
- };
1442
- }
1443
- function addFile(options) {
1444
- const { mutate, isLoading } = createMutation(
1445
- async (props) => {
1446
- const response = await Client.file.addFile(props);
1447
- return response;
1448
- },
1449
- options
1450
- );
1451
- return {
1452
- mutate,
1453
- addFile: mutate,
1454
- isLoading
1455
- };
1456
- }
1457
- function download(options) {
1458
- const { mutate, isLoading } = createMutation(
1459
- async (payload) => {
1460
- const response = await Client.file.download(payload);
1461
- return response;
1462
- },
1463
- options
1464
- );
1465
- return {
1466
- mutate,
1467
- downloadFile: mutate,
1468
- isLoading
1469
- };
1470
- }
1471
-
1472
- // src/apis/cache.ts
1473
- function purge(options) {
1474
- const { mutate, isLoading } = createMutation(
1475
- async (payload) => {
1476
- const safePayload = payload ?? {};
1477
- const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
1478
- const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
1479
- const { idempotencyKey: _ignored, ...body } = safePayload;
1480
- return Client.cache.purge(body, headers);
1481
- },
1482
- options
1483
- );
1484
- return { mutate, purgeCache: mutate, isLoading };
1485
- }
1486
- function purgeStatus(purgeJobId, options) {
1487
- const { mutate, isLoading } = createMutation(
1488
- async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
1489
- options
1490
- );
1491
- return {
1492
- mutate,
1493
- getPurgeStatus: () => mutate(purgeJobId),
1494
- isLoading
1495
- };
1496
- }
1497
-
1498
- // src/breadcrumb/breadcrumbs.ts
1499
- var getBreadcrumbs = () => {
1500
- const search = getParam("b");
1501
- let breadcrumbs = decodeToBase64(search) || [];
1502
- if (!breadcrumbs && breadcrumbs.length < 1) return [];
1503
- const updated = breadcrumbs.map((breadcrumb, index) => {
1504
- return generatePath(breadcrumbs, breadcrumb, index);
1505
- });
1506
- if (updated.length < 1) {
1507
- const pathname = getPath();
1508
- const routeMenu = getRouteMenu(pathname);
1509
- return [
1510
- {
1511
- name: routeMenu?.title,
1512
- path: routeMenu?.path
1513
- }
1514
- ];
1515
- }
1516
- return updated;
1517
- };
1518
- var getTableTitle = (componentName, title, ticketTableTitle) => {
1519
- const search = getParam("b");
1520
- let breadcrumbs = decodeToBase64(search) || [];
1521
- if (breadcrumbs.length < 1) {
1522
- const pathname = getPath();
1523
- const routeMenu = getRouteMenu(pathname);
1524
- breadcrumbs = [
1525
- {
1526
- n: routeMenu?.title,
1527
- pt: routeMenu?.path
1528
- }
1529
- ];
1530
- }
1531
- let associatedtableTitleSingular = "";
1532
- let tableTitle = "";
1533
- let singularTableTitle = "";
1534
- if (breadcrumbs && breadcrumbs.length > 0) {
1535
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
1536
- const last = lastItem ? generatePath(breadcrumbs, lastItem, breadcrumbs.length - 1) : null;
1537
- const previousItem = breadcrumbs[breadcrumbs.length - 2];
1538
- const previous = previousItem ? generatePath(breadcrumbs, previousItem, breadcrumbs.length - 2) : null;
1539
- const singularLastName = last?.name;
1540
- associatedtableTitleSingular = singularLastName;
1541
- if (componentName != "ticket") {
1542
- tableTitle = previous?.name ? { last, previous } : { last };
1543
- singularTableTitle = previous?.name ? `${singularLastName} with ${previous?.name}` : singularLastName;
1544
- } else {
1545
- const ticketTableTitleSingular = ticketTableTitle.endsWith("s") ? ticketTableTitle.slice(0, -1) : ticketTableTitle;
1546
- tableTitle = { last: { name: title } };
1547
- singularTableTitle = previous?.name ? `${ticketTableTitleSingular} with ${singularLastName} ` : ticketTableTitleSingular;
1548
- }
1549
- }
1550
- return { associatedtableTitleSingular, tableTitle, singularTableTitle };
1551
- };
1552
- var getFormTitle = (type, title, activeTab) => {
1553
- const search = getParam("b");
1554
- let breadcrumbs = decodeToBase64(search) || [];
1555
- if (breadcrumbs.length < 1) {
1556
- const pathname = getPath();
1557
- const routeMenu = getRouteMenu(pathname);
1558
- breadcrumbs = [
1559
- {
1560
- n: routeMenu?.title,
1561
- pt: routeMenu?.path
1562
- }
1563
- ];
1564
- }
1565
- let objectName = "";
1566
- let puralObjectName = "";
1567
- let dialogTitle = "";
1568
- if (breadcrumbs && breadcrumbs?.length > 0) {
1569
- const last = breadcrumbs[breadcrumbs?.length - 1];
1570
- const lastName = last?.n;
1571
- const mTitle = title;
1572
- if (type === "association" && breadcrumbs && breadcrumbs?.length > 0) {
1573
- objectName = title;
1574
- puralObjectName = title;
1575
- dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle} for ${nameTrancate(lastName)}` : `Associate an Existing ${mTitle} with ${nameTrancate(lastName)}`}`;
1576
- } else {
1577
- const singularLastName = typeof lastName === "string" && lastName?.endsWith("s") ? lastName.slice(0, -1) : lastName;
1578
- objectName = singularLastName;
1579
- puralObjectName = lastName;
1580
- dialogTitle = `${activeTab == "addNew" ? `Create a new ${mTitle?.includes("with") ? nameTrancate(mTitle?.replace("with", "for")) : nameTrancate(mTitle)}` : `Associate an Existing ${nameTrancate(mTitle)}`}`;
1581
- }
1582
- }
1583
- return { objectName, puralObjectName, dialogTitle };
1584
- };
1585
- var nameTrancate = (name) => {
1586
- return name?.length > 30 ? `${name?.slice(0, 30) + "..."}` : name;
1587
- };
1588
-
1589
- // src/breadcrumb/generate-url.ts
1590
- var useMakeLink = () => {
1591
- const search = getParam("b");
1592
- const makeLink = (props) => {
1593
- if (!search || "isPC" in props) {
1594
- return buildParentRoute(props);
1595
- } else {
1596
- const breadcrumbItems = decodeToBase64(search) || [];
1597
- return buildChildRoute(props, breadcrumbItems);
1598
- }
1599
- };
1600
- return { makeLink };
1601
- };
1602
- var buildParentRoute = (props) => {
1603
- const pathname = getPath();
1604
- const routeMenu = getRouteMenu(pathname);
1605
- const breadcrumbItems = [
1606
- {
1607
- n: routeMenu?.title,
1608
- o_t_id: routeMenu?.path,
1609
- isHome: props?.isHome || false
1610
- }
1611
- ];
1612
- return buildChildRoute(props, breadcrumbItems);
1613
- };
1614
- var buildChildRoute = (props, breadcrumbItems) => {
1615
- let breadcrumbs = [...breadcrumbItems];
1616
- let breadcrumbType = breadcrumbStage(breadcrumbItems);
1617
- if (props?.isHome && isMessingParentLastItem(breadcrumbItems)) {
1618
- const parent = {
1619
- n: props?.title || "",
1620
- o_t_id: props?.objectTypeId,
1621
- "pt": `/association/${props?.objectTypeId}`,
1622
- isHome: props?.isHome || false,
1623
- "prm": {
1624
- "sort": "-hs_createdate",
1625
- "s": "",
1626
- "fPn": "hs_pipeline",
1627
- "fO": "eq",
1628
- "fV": "",
1629
- "c": true,
1630
- "isPC": props?.isPC,
1631
- "v": "LIST",
1632
- "l": "10",
1633
- "p": 1
1634
- }
1635
- };
1636
- breadcrumbs.push(parent);
1637
- const newCrumb = {
1638
- n: props?.name,
1639
- o_t_id: props?.objectTypeId,
1640
- o_r_id: props?.recordId
1641
- };
1642
- breadcrumbs.push(newCrumb);
1643
- } else if (breadcrumbType === "root") {
1644
- const newCrumb = {
1645
- n: props?.name,
1646
- o_t_id: props?.objectTypeId,
1647
- o_r_id: props?.recordId
1648
- };
1649
- if (props?.isPC) {
1650
- newCrumb.prm = {
1651
- isPC: props?.isPC
1652
- };
1653
- }
1654
- breadcrumbs.push(newCrumb);
1655
- } else {
1656
- const lastItem = breadcrumbs[breadcrumbs.length - 1];
1657
- if (props?.objectTypeId != "0-5" && breadcrumbs.length > 2 && // check for only association ticket object
1658
- (!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
1659
- (props?.isHome && !isMessingParentLastItem(breadcrumbItems))) {
1660
- const newCrumb = {
1661
- n: props?.name,
1662
- o_t_id: props?.objectTypeId,
1663
- o_r_id: props?.recordId
1664
- };
1665
- if (props?.isPC) {
1666
- newCrumb.prm = {
1667
- isPC: props?.isPC
1668
- };
1669
- }
1670
- breadcrumbs.push(newCrumb);
1671
- } else {
1672
- const lastItem2 = breadcrumbs[breadcrumbs.length - 1];
1673
- const parent = {
1674
- n: props?.associationLabel || props?.name,
1675
- o_t_id: props?.objectTypeId
1676
- };
1677
- if (props?.tableParam) {
1678
- parent.prm = props?.tableParam;
1679
- }
1680
- if (props?.defPermissions) {
1681
- parent.dp = props?.defPermissions;
1682
- }
1683
- if (lastItem2?.o_t_id && lastItem2?.o_r_id) {
1684
- breadcrumbs.push(parent);
1685
- }
1686
- if (props?.recordId) {
1687
- const newCrumb = {
1688
- n: props?.name,
1689
- o_t_id: props?.objectTypeId,
1690
- o_r_id: props?.recordId
1691
- };
1692
- if (props?.isPC) {
1693
- newCrumb.prm = {
1694
- isPC: props?.isPC
1695
- };
1696
- }
1697
- breadcrumbs.push(newCrumb);
1698
- }
1699
- }
1700
- }
1701
- return generateUrl(props, breadcrumbs);
1702
- };
1703
-
1704
- // src/utils/datetime.ts
1705
- var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
1706
- function getCurrentTimeZone() {
1707
- try {
1708
- return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
1709
- } catch {
1710
- return DEFAULT_HUBSPOT_TIMEZONE;
1711
- }
1712
- }
1713
- function normalizeToTimestamp(value) {
1714
- if (value == null || value === "") return null;
1715
- if (typeof value === "number") {
1716
- return value > 1e11 ? value : null;
1717
- }
1718
- if (typeof value === "string" && /^\d+$/.test(value)) {
1719
- const n = Number(value);
1720
- return n > 1e11 ? n : null;
1721
- }
1722
- if (typeof value === "string" || value instanceof Date) {
1723
- const date = new Date(value);
1724
- return Number.isNaN(date.getTime()) ? null : date.getTime();
1725
- }
1726
- return null;
1727
- }
1728
- function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
1729
- const raw = new Intl.DateTimeFormat("en-US", {
1730
- timeZone,
1731
- timeZoneName: "longOffset"
1732
- }).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
1733
- if (!raw) return "";
1734
- return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
1735
- }
1736
- function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
1737
- const ms = normalizeToTimestamp(timestamp);
1738
- if (ms == null) return null;
1739
- const date = new Date(ms);
1740
- const datePart = new Intl.DateTimeFormat("en-US", {
1741
- timeZone,
1742
- month: "long",
1743
- day: "numeric",
1744
- year: "numeric"
1745
- }).format(date);
1746
- const timePart = new Intl.DateTimeFormat("en-US", {
1747
- timeZone,
1748
- hour: "numeric",
1749
- minute: "2-digit",
1750
- hour12: true
1751
- }).format(date);
1752
- const gmtOffset = formatGmtOffset(timeZone, date);
1753
- return {
1754
- date: datePart,
1755
- time: timePart,
1756
- gmtOffset,
1757
- formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
1758
- };
1759
- }
1760
- function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
1761
- return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
1762
- }
1763
-
1764
- // src/index.ts
1765
- var api = {
1766
- preLogin,
1767
- login,
1768
- verifyEmail,
1769
- resetPasswordVerifyToken,
1770
- resetPassword,
1771
- registerExistingUser,
1772
- verifyEmailResend,
1773
- resendEmail,
1774
- getSsoDetails,
1775
- generateSsoUrl,
1776
- ssoCallback,
1777
- forgetPassword,
1778
- logout,
1779
- me,
1780
- profile,
1781
- changePassword,
1782
- pipelines: list,
1783
- stages: list2,
1784
- objects: list3,
1785
- sideBarObjects: sideBarList,
1786
- objectsForm: form,
1787
- createObject: create,
1788
- createExistingObject: createExisting,
1789
- removeExistingObject: removeExisting,
1790
- objectsDetails: details,
1791
- updateObjectsDetails: update,
1792
- objectFormOptions,
1793
- notes: list4,
1794
- createNote: create2,
1795
- updateNote: update2,
1796
- emails: list5,
1797
- createEmail: create3,
1798
- updateEmail: update3,
1799
- imageUpload,
1800
- attachmentUpload,
1801
- files: list6,
1802
- file: details2,
1803
- fileDownload: download,
1804
- addFolder,
1805
- addFile,
1806
- purgeCache: purge,
1807
- cachePurgeStatus: purgeStatus,
1808
- getRefreshToken,
1809
- getAuthRefreshToken,
1810
- isCookieExpired,
1811
- isExpiresAccessToken,
1812
- isAuthenticateApp,
1813
- getAccessToken
1814
- };
1815
- var store = {
1816
- storage,
1817
- useTable
1818
- };
1819
- var breadcrumbsDetails = {
1820
- getBreadcrumbs,
1821
- getTableTitle,
1822
- getFormTitle
1823
- };
1824
- var url = {
1825
- useMakeLink,
1826
- useUpdateLink
1827
- };
1828
- var routeParam = {
1829
- getRouteDetails,
1830
- getParamDetails
1831
- };
1832
-
1833
- 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';
1834
3
  //# sourceMappingURL=index.js.map
1835
4
  //# sourceMappingURL=index.js.map