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

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