woodsportal-client-sdk 1.1.4-dev.4 → 1.1.4-dev.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +48 -2
- package/dist/adapters/angular/index.d.ts +29 -0
- package/dist/adapters/angular/index.js +34 -0
- package/dist/adapters/angular/index.js.map +1 -0
- package/dist/adapters/react/index.d.ts +29 -0
- package/dist/adapters/react/index.js +18 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/vue/index.d.ts +29 -0
- package/dist/adapters/vue/index.js +25 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/auth-utils-A4WPJMPK.js +4 -0
- package/dist/auth-utils-A4WPJMPK.js.map +1 -0
- package/dist/chunk-HRLJLCAZ.js +1118 -0
- package/dist/chunk-HRLJLCAZ.js.map +1 -0
- package/dist/chunk-NB7AINV4.js +35 -0
- package/dist/chunk-NB7AINV4.js.map +1 -0
- package/dist/chunk-ULV2IIW6.js +15 -0
- package/dist/chunk-ULV2IIW6.js.map +1 -0
- package/dist/chunk-Y5MRAAGK.js +10 -0
- package/dist/chunk-Y5MRAAGK.js.map +1 -0
- package/dist/chunk-YLZA5S7A.js +102 -0
- package/dist/chunk-YLZA5S7A.js.map +1 -0
- package/dist/index.d.ts +106 -2
- package/dist/index.js +368 -851
- package/dist/index.js.map +1 -1
- package/dist/use-sync-LbURBOs_.d.ts +29 -0
- package/package.json +44 -8
package/dist/index.js
CHANGED
|
@@ -1,189 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getParamDetails, useUpdateLink, useTable, getRouteDetails, actions, actions2, actions3, getParam, decodeToBase64, generatePath, getPath, getRouteMenu, breadcrumbStage, isMessingParentLastItem, isMessingParent, generateUrl, resetAllStore } from './chunk-HRLJLCAZ.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';
|
|
2
4
|
import axios from 'axios';
|
|
3
|
-
import pako from 'pako';
|
|
4
|
-
import { Base64 } from 'js-base64';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/utils/constants.ts
|
|
17
|
-
var LOGIN_DETAILS, REFRESH_TOKEN, PORTAL, SUBSCRIPTION_TYPE, HUBSPOT_DATA, HUB_ID, DEV_PORTAL_ID, PORTAL_ID;
|
|
18
|
-
var init_constants = __esm({
|
|
19
|
-
"src/utils/constants.ts"() {
|
|
20
|
-
LOGIN_DETAILS = "loginDetails";
|
|
21
|
-
REFRESH_TOKEN = "refreshToken";
|
|
22
|
-
PORTAL = "portal";
|
|
23
|
-
SUBSCRIPTION_TYPE = "ssubscriptionType";
|
|
24
|
-
HUBSPOT_DATA = "hubSpotData";
|
|
25
|
-
HUB_ID = "hubId";
|
|
26
|
-
DEV_PORTAL_ID = "devPortalId";
|
|
27
|
-
PORTAL_ID = "portalId";
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
var setCookie, getCookie, removeAllCookie, isCookieExpired;
|
|
31
|
-
var init_cookie = __esm({
|
|
32
|
-
"src/utils/cookie.ts"() {
|
|
33
|
-
setCookie = (key, value, expire) => {
|
|
34
|
-
return Cookies.set(key, value, {
|
|
35
|
-
expires: expire,
|
|
36
|
-
sameSite: "none",
|
|
37
|
-
secure: true
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
getCookie = (key) => {
|
|
41
|
-
return Cookies.get(key);
|
|
42
|
-
};
|
|
43
|
-
removeAllCookie = () => {
|
|
44
|
-
Object.keys(Cookies.get()).forEach((cookieName) => {
|
|
45
|
-
Cookies.remove(cookieName);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
isCookieExpired = (key) => {
|
|
49
|
-
const value = Cookies.get(key);
|
|
50
|
-
try {
|
|
51
|
-
const { expiresAt } = JSON.parse(value);
|
|
52
|
-
return Date.now() > expiresAt ? true : false;
|
|
53
|
-
} catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
6
|
+
// src/client/index.ts
|
|
7
|
+
var client_exports = {};
|
|
8
|
+
__export(client_exports, {
|
|
9
|
+
Client: () => Client
|
|
58
10
|
});
|
|
59
11
|
|
|
60
|
-
// src/
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
setSubscriptionType: () => setSubscriptionType
|
|
72
|
-
});
|
|
73
|
-
function setRefreshToken(token, expiresAt) {
|
|
74
|
-
return new Promise((resolve) => {
|
|
75
|
-
setCookie(REFRESH_TOKEN, JSON.stringify(token), expiresAt);
|
|
76
|
-
resolve();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function setAccessToken(token, expiresIn) {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
storAccessToken(token, expiresIn);
|
|
82
|
-
resolve();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function getProfile() {
|
|
86
|
-
return JSON.parse(getCookie(LOGIN_DETAILS || null) || null);
|
|
87
|
-
}
|
|
88
|
-
function getRefreshToken() {
|
|
89
|
-
return JSON.parse(getCookie(REFRESH_TOKEN || null) || null);
|
|
90
|
-
}
|
|
91
|
-
function getPortal() {
|
|
92
|
-
return JSON.parse(getCookie(PORTAL || null) || null);
|
|
93
|
-
}
|
|
94
|
-
function getSubscriptionType() {
|
|
95
|
-
return JSON.parse(getCookie(SUBSCRIPTION_TYPE || null) || null);
|
|
96
|
-
}
|
|
97
|
-
var setLoggedInDetails, setPortal, setSubscriptionType;
|
|
98
|
-
var init_auth_utils = __esm({
|
|
99
|
-
"src/clint/auth-utils.ts"() {
|
|
100
|
-
init_constants();
|
|
101
|
-
init_cookie();
|
|
102
|
-
init_token_store();
|
|
103
|
-
setLoggedInDetails = async (data) => {
|
|
104
|
-
return new Promise((resolve) => {
|
|
105
|
-
setCookie(LOGIN_DETAILS, JSON.stringify(data));
|
|
106
|
-
resolve();
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
setPortal = async (data) => {
|
|
110
|
-
return new Promise((resolve) => {
|
|
111
|
-
setCookie(PORTAL, JSON.stringify(data));
|
|
112
|
-
resolve();
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
setSubscriptionType = async (data) => {
|
|
116
|
-
return new Promise((resolve) => {
|
|
117
|
-
setCookie(SUBSCRIPTION_TYPE, JSON.stringify(data));
|
|
118
|
-
resolve();
|
|
119
|
-
});
|
|
120
|
-
};
|
|
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);
|
|
121
23
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return accessToken;
|
|
127
|
-
}
|
|
128
|
-
function storAccessToken(token, expiresIn) {
|
|
129
|
-
accessToken = token;
|
|
130
|
-
if (expiresIn) {
|
|
131
|
-
tokenExpiresAt = Date.now() + expiresIn * 1e3;
|
|
132
|
-
} else {
|
|
133
|
-
tokenExpiresAt = null;
|
|
24
|
+
};
|
|
25
|
+
function resolveStore() {
|
|
26
|
+
if (typeof globalThis === "undefined") {
|
|
27
|
+
return memoryStore;
|
|
134
28
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
tokenExpiresAt = null;
|
|
139
|
-
}
|
|
140
|
-
function isExpiresAccessToken() {
|
|
141
|
-
if (!tokenExpiresAt) return true;
|
|
142
|
-
return Date.now() >= tokenExpiresAt;
|
|
143
|
-
}
|
|
144
|
-
function setRefreshCallback(callback) {
|
|
145
|
-
refreshCallback = callback;
|
|
146
|
-
}
|
|
147
|
-
async function ensureValidRefresh() {
|
|
148
|
-
if (isExpiresAccessToken() && refreshCallback) {
|
|
149
|
-
const { getRefreshToken: getRefreshToken2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
150
|
-
const refreshToken = getRefreshToken2();
|
|
151
|
-
if (refreshToken) {
|
|
152
|
-
await refreshCallback(refreshToken);
|
|
153
|
-
}
|
|
29
|
+
const ls = globalThis.localStorage;
|
|
30
|
+
if (!ls || typeof ls.getItem !== "function") {
|
|
31
|
+
return memoryStore;
|
|
154
32
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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;
|
|
159
40
|
}
|
|
160
|
-
return true;
|
|
161
41
|
}
|
|
162
|
-
var accessToken, tokenExpiresAt, refreshCallback;
|
|
163
|
-
var init_token_store = __esm({
|
|
164
|
-
"src/clint/token-store.ts"() {
|
|
165
|
-
init_cookie();
|
|
166
|
-
init_constants();
|
|
167
|
-
accessToken = null;
|
|
168
|
-
tokenExpiresAt = null;
|
|
169
|
-
refreshCallback = null;
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// src/utils/config.ts
|
|
174
|
-
init_constants();
|
|
175
|
-
|
|
176
|
-
// src/utils/localStoraget.ts
|
|
177
42
|
var storage = {
|
|
178
43
|
set: (key, value) => {
|
|
179
|
-
|
|
44
|
+
resolveStore().setItem(key, JSON.stringify(value));
|
|
180
45
|
},
|
|
181
46
|
get: (key) => {
|
|
182
|
-
const item =
|
|
47
|
+
const item = resolveStore().getItem(key);
|
|
183
48
|
return item ? JSON.parse(item) : null;
|
|
184
49
|
},
|
|
185
50
|
remove: (key) => {
|
|
186
|
-
|
|
51
|
+
resolveStore().removeItem(key);
|
|
187
52
|
}
|
|
188
53
|
};
|
|
189
54
|
|
|
@@ -200,6 +65,10 @@ var config = {
|
|
|
200
65
|
get portalId() {
|
|
201
66
|
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
202
67
|
return hubSpotData?.[PORTAL_ID] || "";
|
|
68
|
+
},
|
|
69
|
+
get devApiUrl() {
|
|
70
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
71
|
+
return hubSpotData?.[DEV_API_URL] || "";
|
|
203
72
|
}
|
|
204
73
|
};
|
|
205
74
|
var setConfig = {
|
|
@@ -238,7 +107,7 @@ function replaceParams(template, values) {
|
|
|
238
107
|
);
|
|
239
108
|
}
|
|
240
109
|
|
|
241
|
-
// src/
|
|
110
|
+
// src/client/api-endpoints.ts
|
|
242
111
|
var API_ENDPOINTS = {
|
|
243
112
|
// Auth
|
|
244
113
|
PRE_LOGIN: "/api/auth/pre-login",
|
|
@@ -250,6 +119,7 @@ var API_ENDPOINTS = {
|
|
|
250
119
|
VERIFY_EMAIL: "/api/auth/verify-email",
|
|
251
120
|
REGISTER_EXISTING_USER: "/api/auth/existing-user-register",
|
|
252
121
|
RESEND_EMAIL: "/api/auth/resend-email",
|
|
122
|
+
VERIFY_EMAIL_RESEND: "/api/auth/verify-email/resend",
|
|
253
123
|
LOGOUT: "/api/auth/logout",
|
|
254
124
|
// SSO
|
|
255
125
|
SSO_DETAILS: "/api/auth/sso/active",
|
|
@@ -260,51 +130,69 @@ var API_ENDPOINTS = {
|
|
|
260
130
|
PROFILE: "/api/${hubId}/${portalId}/profiles",
|
|
261
131
|
CHANGE_PASSWORD: "/api/auth/change-password",
|
|
262
132
|
// Pipeline
|
|
263
|
-
PIPELINES: "api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
133
|
+
PIPELINES: "/api/${hubId}/${portalId}/hubspot-object-pipelines/${hubspotObjectTypeId}",
|
|
264
134
|
// Stage
|
|
265
|
-
STAGES: "api/${hubId}/${portalId}/hubspot-object-pipelines/${objectTypeId}/${pipelineId}/stages",
|
|
266
|
-
//
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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"
|
|
293
178
|
};
|
|
294
|
-
init_token_store();
|
|
295
179
|
|
|
296
|
-
// src/
|
|
180
|
+
// src/client/config.ts
|
|
297
181
|
var config2 = {
|
|
298
|
-
baseURL: "
|
|
182
|
+
baseURL: ""
|
|
299
183
|
};
|
|
300
184
|
|
|
301
|
-
// src/
|
|
302
|
-
init_auth_utils();
|
|
185
|
+
// src/client/http-clint.ts
|
|
303
186
|
var axiosInstance = null;
|
|
304
187
|
var config3 = {};
|
|
305
188
|
function initializeHttpClient(clientConfig) {
|
|
306
189
|
config3 = clientConfig;
|
|
307
|
-
const baseURL =
|
|
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
|
+
}
|
|
308
196
|
const timeout = config3.timeout ?? 5e4;
|
|
309
197
|
axiosInstance = axios.create({
|
|
310
198
|
baseURL,
|
|
@@ -360,9 +248,9 @@ var HttpClient = class {
|
|
|
360
248
|
const response = await getAxiosInstance().put(url2, data);
|
|
361
249
|
return response.data;
|
|
362
250
|
}
|
|
363
|
-
static async delete(url2) {
|
|
251
|
+
static async delete(url2, config4) {
|
|
364
252
|
await ensureValidRefresh();
|
|
365
|
-
const response = await getAxiosInstance().delete(url2);
|
|
253
|
+
const response = await getAxiosInstance().delete(url2, config4);
|
|
366
254
|
return response.data;
|
|
367
255
|
}
|
|
368
256
|
static formatSearchParams(params) {
|
|
@@ -451,357 +339,38 @@ var setProfileData = (data) => {
|
|
|
451
339
|
var getProfileData = () => {
|
|
452
340
|
return PROFILE;
|
|
453
341
|
};
|
|
454
|
-
function convertToBase64(obj) {
|
|
455
|
-
try {
|
|
456
|
-
if (!obj) return "";
|
|
457
|
-
const json = JSON.stringify(obj);
|
|
458
|
-
const compressed = pako.deflate(json);
|
|
459
|
-
const base64 = Base64.fromUint8Array(compressed, true);
|
|
460
|
-
return base64;
|
|
461
|
-
} catch (error) {
|
|
462
|
-
console.error("Failed to encode object:", error);
|
|
463
|
-
return "";
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
function decodeToBase64(encoded) {
|
|
467
|
-
try {
|
|
468
|
-
if (!encoded) return null;
|
|
469
|
-
const uint8Array = Base64.toUint8Array(encoded);
|
|
470
|
-
const decompressed = pako.inflate(uint8Array, { to: "string" });
|
|
471
|
-
return JSON.parse(decompressed);
|
|
472
|
-
} catch (error) {
|
|
473
|
-
console.error("Failed to decode object:", error);
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
342
|
|
|
478
|
-
// src/
|
|
479
|
-
|
|
480
|
-
if (
|
|
481
|
-
return
|
|
482
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
483
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
484
|
-
const mappedKey = keyMap2[key] || key;
|
|
485
|
-
acc[mappedKey] = mapKeysDeep(value, keyMap2);
|
|
486
|
-
return acc;
|
|
487
|
-
}, {});
|
|
488
|
-
}
|
|
489
|
-
return obj;
|
|
490
|
-
}
|
|
491
|
-
function isMessingParent(breadcrumbs) {
|
|
492
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
493
|
-
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
494
|
-
let lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
495
|
-
return lastItem?.o_r_id && (!lastItem2?.o_r_id && lastItem2?.o_t_id) && lastItem3?.o_r_id ? true : false;
|
|
496
|
-
}
|
|
497
|
-
function isMessingParentLastItem(breadcrumbs) {
|
|
498
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
499
|
-
let lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
500
|
-
return !lastItem?.o_t_id && (lastItem2?.o_r_id && lastItem2?.o_t_id) ? false : true;
|
|
501
|
-
}
|
|
502
|
-
function breadcrumbStage(breadcrumbItems) {
|
|
503
|
-
let breadcrumbType = "child";
|
|
504
|
-
if (breadcrumbItems.length === 1) {
|
|
505
|
-
breadcrumbType = "root";
|
|
506
|
-
} else if (breadcrumbItems.length === 2) {
|
|
507
|
-
breadcrumbType = "root_details";
|
|
343
|
+
// src/client/index.ts
|
|
344
|
+
var recordWriteContext = (paramsObject) => {
|
|
345
|
+
if (!paramsObject) {
|
|
346
|
+
return void 0;
|
|
508
347
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
};
|
|
521
|
-
function getTotalParentLength(data) {
|
|
522
|
-
return data.filter(
|
|
523
|
-
(item) => (item.pt || item.o_t_id) && !item.o_r_id
|
|
524
|
-
).length;
|
|
525
|
-
}
|
|
526
|
-
var generatePath = (breadcrumbs, breadcrumb, index) => {
|
|
527
|
-
const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
|
|
528
|
-
if (index === 0) {
|
|
529
|
-
return {
|
|
530
|
-
name: breadcrumb?.n,
|
|
531
|
-
path: `/${breadcrumb?.pt || breadcrumb?.o_t_id}?b=${bc}`
|
|
532
|
-
};
|
|
533
|
-
} else if (index === 1) {
|
|
534
|
-
if (breadcrumb?.isHome) {
|
|
535
|
-
return {
|
|
536
|
-
name: breadcrumb?.n,
|
|
537
|
-
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
return {
|
|
541
|
-
name: breadcrumb?.n,
|
|
542
|
-
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
543
|
-
};
|
|
544
|
-
} else {
|
|
545
|
-
if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
|
|
546
|
-
return {
|
|
547
|
-
name: breadcrumb?.n,
|
|
548
|
-
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
549
|
-
};
|
|
550
|
-
} else {
|
|
551
|
-
return {
|
|
552
|
-
name: breadcrumb?.n,
|
|
553
|
-
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
// src/breadcrumb/key-map.ts
|
|
560
|
-
var keyMap = {
|
|
561
|
-
dp: "defPermissions",
|
|
562
|
-
n: "name",
|
|
563
|
-
sort: "sort",
|
|
564
|
-
o_t_id: "objectTypeId",
|
|
565
|
-
s: "search",
|
|
566
|
-
fPn: "filterPropertyName",
|
|
567
|
-
fO: "filterOperator",
|
|
568
|
-
fV: "filterValue",
|
|
569
|
-
c: "cache",
|
|
570
|
-
isPC: "isPrimaryCompany",
|
|
571
|
-
v: "view",
|
|
572
|
-
l: "limit",
|
|
573
|
-
pt: "path",
|
|
574
|
-
p: "page",
|
|
575
|
-
a: "after",
|
|
576
|
-
aPip: "activePipeline",
|
|
577
|
-
aT: "activeTab",
|
|
578
|
-
cT: "create",
|
|
579
|
-
dP: "display",
|
|
580
|
-
dL: "display_label",
|
|
581
|
-
pId: "pipeline_id"
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// src/utils/param.ts
|
|
585
|
-
function getParam(paramName) {
|
|
586
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
587
|
-
const hash = globalThis.location.hash || "";
|
|
588
|
-
if (!hash.startsWith("#/")) return null;
|
|
589
|
-
const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
|
|
590
|
-
const queryString = hashWithoutHash.split("?")[1];
|
|
591
|
-
if (!queryString) return null;
|
|
592
|
-
const params = new URLSearchParams(queryString);
|
|
593
|
-
return params.get(paramName);
|
|
594
|
-
}
|
|
595
|
-
function getPath() {
|
|
596
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
597
|
-
const hash = globalThis.location.hash || "";
|
|
598
|
-
if (!hash.startsWith("#/")) return null;
|
|
599
|
-
return hash.slice(1).split("?")[0];
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// src/breadcrumb/param.ts
|
|
603
|
-
var getRouteMenu = (path) => {
|
|
604
|
-
const apiRoutes = globalThis?.apiRoutes || [];
|
|
605
|
-
return apiRoutes.find((menu) => menu?.path === path);
|
|
606
|
-
};
|
|
607
|
-
var getRouteDetails = () => {
|
|
608
|
-
const search = getParam("b");
|
|
609
|
-
const breadcrumbs = decodeToBase64(search) || [];
|
|
610
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
611
|
-
const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
|
|
612
|
-
return { routeDetails: mapped };
|
|
613
|
-
};
|
|
614
|
-
var getParamDetails = (props, isDetailsPage = false) => {
|
|
615
|
-
const search = getParam("b");
|
|
616
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
617
|
-
if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
|
|
618
|
-
breadcrumbs = breadcrumbs.slice(1);
|
|
619
|
-
}
|
|
620
|
-
let mediatorObjectTypeId = "";
|
|
621
|
-
let mediatorObjectRecordId = "";
|
|
622
|
-
let parentObjectTypeId = "";
|
|
623
|
-
let parentObjectRecordId = "";
|
|
624
|
-
let lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
625
|
-
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
626
|
-
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
627
|
-
if (isDetailsPage === true && lastItem && "prm" in lastItem) {
|
|
628
|
-
delete lastItem.prm;
|
|
629
|
-
}
|
|
630
|
-
if (breadcrumbs.length > 1) {
|
|
631
|
-
if (props?.type === "ticket" || props?.type === "association") {
|
|
632
|
-
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
633
|
-
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
634
|
-
parentObjectTypeId = lastItem?.o_t_id || "";
|
|
635
|
-
parentObjectRecordId = lastItem?.o_r_id || "";
|
|
636
|
-
} else {
|
|
637
|
-
if (breadcrumbs.length > 2) {
|
|
638
|
-
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
639
|
-
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
640
|
-
}
|
|
641
|
-
if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
642
|
-
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
643
|
-
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
644
|
-
}
|
|
645
|
-
if (lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
646
|
-
parentObjectTypeId = lastItem3?.o_t_id || "";
|
|
647
|
-
parentObjectRecordId = lastItem3?.o_r_id || "";
|
|
648
|
-
}
|
|
649
|
-
if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
|
|
650
|
-
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
651
|
-
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
652
|
-
}
|
|
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);
|
|
653
359
|
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
|
|
657
|
-
paramsObject["isPrimaryCompany"] = true;
|
|
658
|
-
}
|
|
659
|
-
if (parentObjectTypeId && parentObjectRecordId) {
|
|
660
|
-
paramsObject["parentObjectTypeId"] = parentObjectTypeId;
|
|
661
|
-
paramsObject["parentObjectRecordId"] = parentObjectRecordId;
|
|
662
|
-
}
|
|
663
|
-
if (mediatorObjectTypeId && mediatorObjectRecordId) {
|
|
664
|
-
paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
|
|
665
|
-
paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
|
|
666
|
-
}
|
|
667
|
-
const mappedLastItemParam = Object.fromEntries(
|
|
668
|
-
Object.entries(lastItem?.prm || {}).map(([key, value]) => [
|
|
669
|
-
keyMap[key] || key,
|
|
670
|
-
// use mapped name if exists, else keep original
|
|
671
|
-
value
|
|
672
|
-
])
|
|
673
|
-
);
|
|
674
|
-
let queryString = null;
|
|
675
|
-
if (props?.type === "association") {
|
|
676
|
-
queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
|
|
677
|
-
} else {
|
|
678
|
-
queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
|
|
679
|
-
}
|
|
680
|
-
let params = queryString ? `?${queryString}` : "";
|
|
681
|
-
const totalParentLength = getTotalParentLength(breadcrumbs);
|
|
682
|
-
let parentAccessLabel = false;
|
|
683
|
-
if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
|
|
684
|
-
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
|
|
685
|
-
breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
|
|
686
|
-
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
|
|
687
|
-
parentAccessLabel = true;
|
|
688
|
-
}
|
|
689
|
-
return {
|
|
690
|
-
breadcrumbs,
|
|
691
|
-
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
692
|
-
paramsObject,
|
|
693
|
-
params,
|
|
694
|
-
parentAccessLabel
|
|
695
|
-
};
|
|
360
|
+
});
|
|
361
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
696
362
|
};
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
var useUpdateLink = () => {
|
|
703
|
-
const updateLink = async (props, displayName = "prm") => {
|
|
704
|
-
const search = getParam("b");
|
|
705
|
-
const pathname = getPath();
|
|
706
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
707
|
-
if (breadcrumbs.length < 1) {
|
|
708
|
-
const routeMenu = getRouteMenu(pathname);
|
|
709
|
-
breadcrumbs = [
|
|
710
|
-
{
|
|
711
|
-
n: routeMenu?.title,
|
|
712
|
-
pt: routeMenu?.path
|
|
713
|
-
}
|
|
714
|
-
];
|
|
715
|
-
}
|
|
716
|
-
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
717
|
-
let udatedBreadcrumb = null;
|
|
718
|
-
if (displayName) {
|
|
719
|
-
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
720
|
-
udatedBreadcrumb = await setDeep(lastBreadcrumb, displayName, {
|
|
721
|
-
...ex,
|
|
722
|
-
...props
|
|
723
|
-
});
|
|
724
|
-
} else {
|
|
725
|
-
udatedBreadcrumb = Object.assign(lastBreadcrumb, props);
|
|
726
|
-
}
|
|
727
|
-
breadcrumbs[breadcrumbs.length - 1] = udatedBreadcrumb;
|
|
728
|
-
const newBase64 = convertToBase64(breadcrumbs);
|
|
729
|
-
updateBParam(newBase64);
|
|
730
|
-
};
|
|
731
|
-
function setDeep(obj, path, value) {
|
|
732
|
-
const keys = path.split(".");
|
|
733
|
-
let curr = obj;
|
|
734
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
735
|
-
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
736
|
-
curr[keys[i]] = {};
|
|
737
|
-
}
|
|
738
|
-
curr = curr[keys[i]];
|
|
739
|
-
}
|
|
740
|
-
curr[keys[keys.length - 1]] = value;
|
|
741
|
-
return curr;
|
|
742
|
-
}
|
|
743
|
-
function getDeep(obj, path) {
|
|
744
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
363
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
364
|
+
const base = { ...payload || {} };
|
|
365
|
+
const context = recordWriteContext(paramsObject);
|
|
366
|
+
if (context) {
|
|
367
|
+
base.context = context;
|
|
745
368
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
749
|
-
if (breadcrumbs.length < 1) return null;
|
|
750
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
751
|
-
const getDeep2 = (obj, path) => {
|
|
752
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
753
|
-
};
|
|
754
|
-
const expandKeys = (obj) => {
|
|
755
|
-
return Object.fromEntries(
|
|
756
|
-
Object.entries(obj).map(([key, value]) => [
|
|
757
|
-
keyMap[key] || key,
|
|
758
|
-
// map if exists, else keep original
|
|
759
|
-
value
|
|
760
|
-
])
|
|
761
|
-
);
|
|
762
|
-
};
|
|
763
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
764
|
-
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
765
|
-
return output;
|
|
766
|
-
};
|
|
767
|
-
const filterParams = (displayName = "prm") => {
|
|
768
|
-
const search = getParam("b");
|
|
769
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
770
|
-
if (breadcrumbs.length < 1) return null;
|
|
771
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
772
|
-
const getDeep2 = (obj, path) => {
|
|
773
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
774
|
-
};
|
|
775
|
-
const expandKeys = (obj) => {
|
|
776
|
-
return Object.fromEntries(
|
|
777
|
-
Object.entries(obj).map(([key, value]) => [
|
|
778
|
-
keyMap[key] || key,
|
|
779
|
-
// map if exists, else keep original
|
|
780
|
-
value
|
|
781
|
-
])
|
|
782
|
-
);
|
|
783
|
-
};
|
|
784
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
785
|
-
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
786
|
-
return output;
|
|
787
|
-
};
|
|
788
|
-
return { updateLink, getLinkParams, filterParams };
|
|
789
|
-
};
|
|
790
|
-
var updateBParam = (newValue) => {
|
|
791
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
792
|
-
const hash = globalThis.location.hash || "";
|
|
793
|
-
if (!hash.startsWith("#/")) return;
|
|
794
|
-
const withoutHash = hash.slice(2);
|
|
795
|
-
const [path, queryString] = withoutHash.split("?");
|
|
796
|
-
const params = new URLSearchParams(queryString || "");
|
|
797
|
-
params.set("b", newValue);
|
|
798
|
-
const newHash = `#/${path}?${params.toString()}`;
|
|
799
|
-
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
800
|
-
globalThis.history.replaceState(null, "", newHash);
|
|
369
|
+
if (options && Object.keys(options).length > 0) {
|
|
370
|
+
base.options = options;
|
|
801
371
|
}
|
|
372
|
+
return base;
|
|
802
373
|
};
|
|
803
|
-
|
|
804
|
-
// src/clint/index.ts
|
|
805
374
|
var Client = {
|
|
806
375
|
authentication: {
|
|
807
376
|
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
@@ -821,8 +390,8 @@ var Client = {
|
|
|
821
390
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
822
391
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
823
392
|
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
824
|
-
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data),
|
|
825
|
-
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.
|
|
393
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
394
|
+
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
|
|
826
395
|
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
827
396
|
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
828
397
|
},
|
|
@@ -851,17 +420,16 @@ var Client = {
|
|
|
851
420
|
apiParams.parentObjectTypeId = "0-2";
|
|
852
421
|
}
|
|
853
422
|
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
854
|
-
apiParams.cache = payload?.
|
|
423
|
+
apiParams.cache = payload?.cache;
|
|
855
424
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
856
425
|
return HttpClient.get(apiUrl);
|
|
857
426
|
}
|
|
858
427
|
},
|
|
859
428
|
stage: {
|
|
860
429
|
list: (props = null) => {
|
|
861
|
-
const portalId = config.devPortalId;
|
|
862
430
|
const params = {
|
|
863
|
-
hubId: config.hubId,
|
|
864
|
-
portalId,
|
|
431
|
+
// hubId: config.hubId,
|
|
432
|
+
// portalId: portalId,
|
|
865
433
|
objectTypeId: props?.params?.objectTypeId,
|
|
866
434
|
pipelineId: props?.params?.pipelineId
|
|
867
435
|
};
|
|
@@ -871,6 +439,7 @@ var Client = {
|
|
|
871
439
|
},
|
|
872
440
|
object: {
|
|
873
441
|
list: async (payload = null, param = null) => {
|
|
442
|
+
param.cache = payload.cache;
|
|
874
443
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
875
444
|
const { updateLink, getLinkParams } = useUpdateLink();
|
|
876
445
|
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
@@ -917,54 +486,89 @@ var Client = {
|
|
|
917
486
|
}
|
|
918
487
|
if (payload?.isHome) {
|
|
919
488
|
let parentObjectTypeId = "";
|
|
920
|
-
if (userData?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
921
|
-
parentObjectTypeId = userData?.info?.objectTypeId;
|
|
922
|
-
} else if (userData?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
489
|
+
if (userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
490
|
+
parentObjectTypeId = userData?.data?.info?.objectTypeId;
|
|
491
|
+
} else if (userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
923
492
|
parentObjectTypeId = "0-2";
|
|
924
493
|
}
|
|
925
494
|
param.parentObjectTypeId = parentObjectTypeId;
|
|
926
495
|
}
|
|
927
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
|
+
}
|
|
928
507
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
929
508
|
return HttpClient.get(apiUrl);
|
|
930
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
|
+
},
|
|
931
517
|
form: (payload = null) => {
|
|
932
518
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
933
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
519
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
934
520
|
return HttpClient.get(apiUrl);
|
|
935
521
|
},
|
|
936
522
|
objectFormOptions: (payload = null) => {
|
|
937
|
-
const params = {
|
|
523
|
+
const params = {
|
|
524
|
+
formId: payload?.formId,
|
|
525
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
526
|
+
};
|
|
938
527
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
939
528
|
return HttpClient.get(apiUrl);
|
|
940
529
|
},
|
|
941
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
|
+
});
|
|
942
538
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE, params, queryParams });
|
|
946
|
-
return HttpClient.post(apiUrl, payload);
|
|
539
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
540
|
+
return HttpClient.post(apiUrl, body);
|
|
947
541
|
},
|
|
948
542
|
createExisting: (props = null) => {
|
|
949
|
-
const
|
|
950
|
-
const
|
|
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
|
+
};
|
|
951
551
|
const payload = props.payload;
|
|
952
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
552
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
953
553
|
return HttpClient.post(apiUrl, payload);
|
|
954
554
|
},
|
|
955
555
|
removeExisting: (props = null) => {
|
|
956
|
-
const
|
|
957
|
-
const
|
|
958
|
-
const
|
|
959
|
-
const
|
|
960
|
-
|
|
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 });
|
|
961
566
|
},
|
|
962
567
|
details: (props = null) => {
|
|
963
568
|
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
964
|
-
const portalId = config.devPortalId;
|
|
965
569
|
const params = {
|
|
966
|
-
hubId: config.hubId,
|
|
967
|
-
portalId,
|
|
570
|
+
// hubId: config.hubId,
|
|
571
|
+
// portalId: portalId,
|
|
968
572
|
objectId: props?.params?.objectId,
|
|
969
573
|
id: props?.params?.id
|
|
970
574
|
};
|
|
@@ -977,24 +581,29 @@ var Client = {
|
|
|
977
581
|
return HttpClient.get(apiUrl);
|
|
978
582
|
},
|
|
979
583
|
update: (props = null) => {
|
|
980
|
-
const portalId = getPortal()?.portalId;
|
|
981
584
|
const params = {
|
|
982
|
-
hubId: config.hubId,
|
|
983
|
-
portalId,
|
|
984
585
|
objectId: props?.params?.objectId,
|
|
985
586
|
id: props?.params?.id
|
|
986
587
|
};
|
|
987
|
-
const {
|
|
988
|
-
const
|
|
989
|
-
|
|
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);
|
|
990
600
|
}
|
|
991
601
|
},
|
|
992
602
|
note: {
|
|
993
603
|
list: (props = null) => {
|
|
994
|
-
const portalId = getPortal()?.portalId;
|
|
995
604
|
const params = {
|
|
996
|
-
hubId: config.hubId,
|
|
997
|
-
portalId,
|
|
605
|
+
// hubId: config.hubId,
|
|
606
|
+
// portalId: portalId,
|
|
998
607
|
objectId: props?.params?.objectId,
|
|
999
608
|
id: props?.params?.id
|
|
1000
609
|
};
|
|
@@ -1009,10 +618,9 @@ var Client = {
|
|
|
1009
618
|
return HttpClient.post(apiUrl, payload);
|
|
1010
619
|
},
|
|
1011
620
|
update: (props = null) => {
|
|
1012
|
-
const portalId = getPortal()?.portalId;
|
|
1013
621
|
const params = {
|
|
1014
|
-
hubId: config.hubId,
|
|
1015
|
-
portalId,
|
|
622
|
+
// hubId: config.hubId,
|
|
623
|
+
// portalId: portalId,
|
|
1016
624
|
objectId: props?.params?.objectId,
|
|
1017
625
|
id: props?.params?.id,
|
|
1018
626
|
note_id: props?.params?.note_id
|
|
@@ -1050,10 +658,9 @@ var Client = {
|
|
|
1050
658
|
},
|
|
1051
659
|
email: {
|
|
1052
660
|
list: (props = null) => {
|
|
1053
|
-
const portalId = getPortal()?.portalId;
|
|
1054
661
|
const params = {
|
|
1055
|
-
hubId: config.hubId,
|
|
1056
|
-
portalId,
|
|
662
|
+
// hubId: config.hubId,
|
|
663
|
+
// portalId: portalId,
|
|
1057
664
|
objectId: props?.params?.objectId,
|
|
1058
665
|
id: props?.params?.id
|
|
1059
666
|
};
|
|
@@ -1068,13 +675,12 @@ var Client = {
|
|
|
1068
675
|
return HttpClient.post(apiUrl, payload);
|
|
1069
676
|
},
|
|
1070
677
|
update: (props = null) => {
|
|
1071
|
-
const portalId = getPortal()?.portalId;
|
|
1072
678
|
const params = {
|
|
1073
|
-
hubId: config.hubId,
|
|
1074
|
-
portalId,
|
|
679
|
+
// hubId: config.hubId,
|
|
680
|
+
// portalId: portalId,
|
|
1075
681
|
objectId: props?.params?.objectId,
|
|
1076
682
|
id: props?.params?.id,
|
|
1077
|
-
|
|
683
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
1078
684
|
};
|
|
1079
685
|
const { paramsObject: queryParams } = getParamDetails();
|
|
1080
686
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
@@ -1107,12 +713,24 @@ var Client = {
|
|
|
1107
713
|
});
|
|
1108
714
|
}
|
|
1109
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
|
+
},
|
|
1110
729
|
file: {
|
|
1111
730
|
list: (props = null) => {
|
|
1112
|
-
const portalId = getPortal()?.portalId;
|
|
1113
731
|
const params = {
|
|
1114
|
-
hubId: config.hubId,
|
|
1115
|
-
portalId,
|
|
732
|
+
// hubId: config.hubId,
|
|
733
|
+
// portalId: portalId,
|
|
1116
734
|
objectId: props?.params?.objectId,
|
|
1117
735
|
id: props?.params?.id
|
|
1118
736
|
};
|
|
@@ -1120,10 +738,9 @@ var Client = {
|
|
|
1120
738
|
return HttpClient.get(apiUrl);
|
|
1121
739
|
},
|
|
1122
740
|
details: (props = null) => {
|
|
1123
|
-
const portalId = getPortal()?.portalId;
|
|
1124
741
|
const params = {
|
|
1125
|
-
hubId: config.hubId,
|
|
1126
|
-
portalId,
|
|
742
|
+
// hubId: config.hubId,
|
|
743
|
+
// portalId: portalId,
|
|
1127
744
|
objectId: props?.params?.objectId,
|
|
1128
745
|
id: props?.params?.id,
|
|
1129
746
|
rowId: props?.params?.rowId
|
|
@@ -1153,6 +770,25 @@ var Client = {
|
|
|
1153
770
|
}
|
|
1154
771
|
}
|
|
1155
772
|
};
|
|
773
|
+
function logError(context, error) {
|
|
774
|
+
if (axios.isAxiosError(error)) {
|
|
775
|
+
resetAllStore();
|
|
776
|
+
console.error(context, {
|
|
777
|
+
message: error.message,
|
|
778
|
+
status: error.response?.status,
|
|
779
|
+
statusText: error.response?.statusText,
|
|
780
|
+
data: error.response?.data,
|
|
781
|
+
url: error.config?.url,
|
|
782
|
+
method: error.config?.method
|
|
783
|
+
});
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (error instanceof Error) {
|
|
787
|
+
console.error(context, error.message, error);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
console.error(context, error);
|
|
791
|
+
}
|
|
1156
792
|
|
|
1157
793
|
// src/mutation/createMutation.ts
|
|
1158
794
|
function createMutation(mutationFn, options) {
|
|
@@ -1173,6 +809,7 @@ function createMutation(mutationFn, options) {
|
|
|
1173
809
|
return response;
|
|
1174
810
|
} catch (error) {
|
|
1175
811
|
options?.onError?.(error, payload);
|
|
812
|
+
logError("[mutation]", error);
|
|
1176
813
|
throw error;
|
|
1177
814
|
} finally {
|
|
1178
815
|
inFlight -= 1;
|
|
@@ -1186,9 +823,6 @@ function createMutation(mutationFn, options) {
|
|
|
1186
823
|
}
|
|
1187
824
|
|
|
1188
825
|
// src/apis/authentication.ts
|
|
1189
|
-
init_auth_utils();
|
|
1190
|
-
init_cookie();
|
|
1191
|
-
init_token_store();
|
|
1192
826
|
function preLogin(options) {
|
|
1193
827
|
const { mutate, isLoading } = createMutation(
|
|
1194
828
|
async (payload) => {
|
|
@@ -1442,242 +1076,6 @@ function changePassword(options) {
|
|
|
1442
1076
|
};
|
|
1443
1077
|
}
|
|
1444
1078
|
|
|
1445
|
-
// src/store/index.ts
|
|
1446
|
-
function createStore(initializer) {
|
|
1447
|
-
let state;
|
|
1448
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1449
|
-
const get = () => state;
|
|
1450
|
-
const set = (partial) => {
|
|
1451
|
-
const prevState = state;
|
|
1452
|
-
const partialState = typeof partial === "function" ? partial(state) : partial;
|
|
1453
|
-
state = {
|
|
1454
|
-
...state,
|
|
1455
|
-
...partialState
|
|
1456
|
-
};
|
|
1457
|
-
listeners.forEach(
|
|
1458
|
-
(listener) => listener(state, prevState)
|
|
1459
|
-
);
|
|
1460
|
-
};
|
|
1461
|
-
const subscribe = (listener) => {
|
|
1462
|
-
listeners.add(listener);
|
|
1463
|
-
return () => listeners.delete(listener);
|
|
1464
|
-
};
|
|
1465
|
-
state = initializer(set, get);
|
|
1466
|
-
return {
|
|
1467
|
-
getState: get,
|
|
1468
|
-
setState: set,
|
|
1469
|
-
subscribe
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
// src/utils/getCookieData.ts
|
|
1474
|
-
init_cookie();
|
|
1475
|
-
var getAuthSubscriptionType = () => {
|
|
1476
|
-
return getCookie("subscriptionType");
|
|
1477
|
-
};
|
|
1478
|
-
|
|
1479
|
-
// src/store/use-table.ts
|
|
1480
|
-
var pageLimit = 10;
|
|
1481
|
-
var tableStore = createStore((set, get) => ({
|
|
1482
|
-
// ==============================
|
|
1483
|
-
// STATE
|
|
1484
|
-
// ==============================
|
|
1485
|
-
tableUniqueId: null,
|
|
1486
|
-
gridData: [],
|
|
1487
|
-
sort: "-hs_createdate",
|
|
1488
|
-
limit: 10,
|
|
1489
|
-
after: "",
|
|
1490
|
-
page: 1,
|
|
1491
|
-
totalItems: 1,
|
|
1492
|
-
numOfPages: 1,
|
|
1493
|
-
currentPage: 1,
|
|
1494
|
-
search: "",
|
|
1495
|
-
filterPropertyName: "hs_pipeline",
|
|
1496
|
-
filterOperator: "eq",
|
|
1497
|
-
filterValue: "",
|
|
1498
|
-
isPrimaryCompany: null,
|
|
1499
|
-
view: null,
|
|
1500
|
-
selectedPipeline: "",
|
|
1501
|
-
tableParam: {},
|
|
1502
|
-
tableDefPermissions: {},
|
|
1503
|
-
// ==============================
|
|
1504
|
-
// BASIC SETTERS
|
|
1505
|
-
// ==============================
|
|
1506
|
-
setTableUniqueId: (v) => set({ tableUniqueId: v }),
|
|
1507
|
-
setSort: (v) => set({ sort: v }),
|
|
1508
|
-
setLimit: (v) => set({ limit: v }),
|
|
1509
|
-
setAfter: (v) => set({ after: v }),
|
|
1510
|
-
setPage: (v) => set({ page: v }),
|
|
1511
|
-
setTotalItems: (v) => set({ totalItems: v }),
|
|
1512
|
-
setNumOfPages: (v) => set({ numOfPages: v }),
|
|
1513
|
-
setCurrentPage: (v) => set({ currentPage: v }),
|
|
1514
|
-
setSearch: (v) => set({ search: v }),
|
|
1515
|
-
setFilterPropertyName: (v) => set({ filterPropertyName: v }),
|
|
1516
|
-
setFilterOperator: (v) => set({ filterOperator: v }),
|
|
1517
|
-
setFilterValue: (v) => set({ filterValue: v }),
|
|
1518
|
-
setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
|
|
1519
|
-
// ==============================
|
|
1520
|
-
// VIEW
|
|
1521
|
-
// ==============================
|
|
1522
|
-
setView: (mView) => {
|
|
1523
|
-
set({
|
|
1524
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1525
|
-
view: mView
|
|
1526
|
-
});
|
|
1527
|
-
},
|
|
1528
|
-
// ==============================
|
|
1529
|
-
// PIPELINE
|
|
1530
|
-
// ==============================
|
|
1531
|
-
changePipeline: (mView) => {
|
|
1532
|
-
set({
|
|
1533
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1534
|
-
selectedPipeline: mView || ""
|
|
1535
|
-
});
|
|
1536
|
-
},
|
|
1537
|
-
setSelectedPipeline: (pipelines, pipeLineId) => {
|
|
1538
|
-
let filterValue = "";
|
|
1539
|
-
if (pipeLineId) {
|
|
1540
|
-
const pipelineSingle = pipelines.find(
|
|
1541
|
-
(pipeline) => pipeline.pipelineId === pipeLineId
|
|
1542
|
-
);
|
|
1543
|
-
filterValue = pipelineSingle?.pipelineId || "";
|
|
1544
|
-
}
|
|
1545
|
-
set({
|
|
1546
|
-
filterPropertyName: "hs_pipeline",
|
|
1547
|
-
filterOperator: "eq",
|
|
1548
|
-
filterValue,
|
|
1549
|
-
selectedPipeline: filterValue
|
|
1550
|
-
});
|
|
1551
|
-
},
|
|
1552
|
-
// ==============================
|
|
1553
|
-
// RESET
|
|
1554
|
-
// ==============================
|
|
1555
|
-
resetTableParam: () => {
|
|
1556
|
-
set({
|
|
1557
|
-
sort: "-hs_createdate",
|
|
1558
|
-
limit: pageLimit,
|
|
1559
|
-
after: "",
|
|
1560
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1561
|
-
totalItems: 1,
|
|
1562
|
-
numOfPages: 1,
|
|
1563
|
-
currentPage: 1,
|
|
1564
|
-
search: "",
|
|
1565
|
-
filterPropertyName: "hs_pipeline",
|
|
1566
|
-
filterOperator: "eq",
|
|
1567
|
-
filterValue: "",
|
|
1568
|
-
isPrimaryCompany: null,
|
|
1569
|
-
selectedPipeline: ""
|
|
1570
|
-
});
|
|
1571
|
-
},
|
|
1572
|
-
// ==============================
|
|
1573
|
-
// PARAM BUILDER
|
|
1574
|
-
// ==============================
|
|
1575
|
-
getTableParam: (companyAsMediator, currentPageOverride) => {
|
|
1576
|
-
const state = get();
|
|
1577
|
-
const baseParams = {
|
|
1578
|
-
sort: state.sort,
|
|
1579
|
-
search: state.search,
|
|
1580
|
-
filterPropertyName: state.filterPropertyName,
|
|
1581
|
-
filterOperator: state.filterOperator,
|
|
1582
|
-
filterValue: state.selectedPipeline,
|
|
1583
|
-
cache: true,
|
|
1584
|
-
isPrimaryCompany: companyAsMediator || false,
|
|
1585
|
-
view: state.view
|
|
1586
|
-
};
|
|
1587
|
-
if (getAuthSubscriptionType() === "FREE") {
|
|
1588
|
-
return {
|
|
1589
|
-
...baseParams,
|
|
1590
|
-
after: state.page
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
return {
|
|
1594
|
-
...baseParams,
|
|
1595
|
-
limit: state.limit,
|
|
1596
|
-
page: currentPageOverride || state.page,
|
|
1597
|
-
...state.after && {
|
|
1598
|
-
after: state.after
|
|
1599
|
-
}
|
|
1600
|
-
};
|
|
1601
|
-
},
|
|
1602
|
-
// ==============================
|
|
1603
|
-
// GRID DATA
|
|
1604
|
-
// ==============================
|
|
1605
|
-
setGridData: async (type, deals) => {
|
|
1606
|
-
if (type === "reset") {
|
|
1607
|
-
set({ gridData: [] });
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
if (type === "directly") {
|
|
1611
|
-
set({ gridData: deals });
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
const finalData = await deals.map(
|
|
1615
|
-
(deal) => {
|
|
1616
|
-
const cards = deal?.data?.results?.rows?.map(
|
|
1617
|
-
(row) => ({
|
|
1618
|
-
id: row?.hs_object_id,
|
|
1619
|
-
...row,
|
|
1620
|
-
hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
|
|
1621
|
-
})
|
|
1622
|
-
) || [];
|
|
1623
|
-
return {
|
|
1624
|
-
id: deal.id,
|
|
1625
|
-
name: deal.label,
|
|
1626
|
-
count: deal?.data?.total,
|
|
1627
|
-
...deal,
|
|
1628
|
-
cards
|
|
1629
|
-
};
|
|
1630
|
-
}
|
|
1631
|
-
);
|
|
1632
|
-
await set({ gridData: finalData });
|
|
1633
|
-
return finalData;
|
|
1634
|
-
},
|
|
1635
|
-
// ==============================
|
|
1636
|
-
// DEFAULT PIPELINE
|
|
1637
|
-
// ==============================
|
|
1638
|
-
setDefaultPipeline(data, hubspotObjectTypeId) {
|
|
1639
|
-
if (!data) {
|
|
1640
|
-
set({ selectedPipeline: "" });
|
|
1641
|
-
return "";
|
|
1642
|
-
}
|
|
1643
|
-
const { updateLink, filterParams } = useUpdateLink();
|
|
1644
|
-
const params = filterParams();
|
|
1645
|
-
const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5"];
|
|
1646
|
-
const state = get();
|
|
1647
|
-
const view = state.view;
|
|
1648
|
-
const selectedPipeline = state.selectedPipeline;
|
|
1649
|
-
let defaultPipelineId = "";
|
|
1650
|
-
let mFilterValue = "";
|
|
1651
|
-
const defaultPipeline = data?.data?.[0];
|
|
1652
|
-
if (excludedIds.includes(hubspotObjectTypeId)) {
|
|
1653
|
-
defaultPipelineId = defaultPipeline?.pipelineId || "";
|
|
1654
|
-
}
|
|
1655
|
-
if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
|
|
1656
|
-
mFilterValue = params.filterValue;
|
|
1657
|
-
} else {
|
|
1658
|
-
if (view === "BOARD" && !selectedPipeline) {
|
|
1659
|
-
mFilterValue = defaultPipelineId;
|
|
1660
|
-
updateLink({
|
|
1661
|
-
fV: defaultPipelineId
|
|
1662
|
-
});
|
|
1663
|
-
} else if (!excludedIds.includes(hubspotObjectTypeId)) {
|
|
1664
|
-
mFilterValue = selectedPipeline || null;
|
|
1665
|
-
} else {
|
|
1666
|
-
mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
set({ selectedPipeline: mFilterValue });
|
|
1670
|
-
return mFilterValue;
|
|
1671
|
-
}
|
|
1672
|
-
}));
|
|
1673
|
-
function useTable() {
|
|
1674
|
-
const tableState = tableStore.getState();
|
|
1675
|
-
return {
|
|
1676
|
-
...tableState,
|
|
1677
|
-
...{ listeners: { subscribe: tableStore.subscribe } }
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
1079
|
// src/apis/pipeline.ts
|
|
1682
1080
|
function list(options) {
|
|
1683
1081
|
const {
|
|
@@ -1716,13 +1114,14 @@ function list2(options) {
|
|
|
1716
1114
|
|
|
1717
1115
|
// src/apis/object.ts
|
|
1718
1116
|
function list3(options) {
|
|
1719
|
-
const {
|
|
1720
|
-
|
|
1721
|
-
} = useTable();
|
|
1117
|
+
const { getTableParam } = useTable();
|
|
1118
|
+
const { setObjectsData, setTableData } = actions;
|
|
1722
1119
|
const { mutate, isLoading } = createMutation(
|
|
1723
1120
|
async (payload) => {
|
|
1724
1121
|
const param = await getTableParam(payload?.companyAsMediator);
|
|
1725
1122
|
const response = await Client.object.list(payload, param);
|
|
1123
|
+
await setObjectsData(response);
|
|
1124
|
+
await setTableData(response, payload);
|
|
1726
1125
|
return response;
|
|
1727
1126
|
},
|
|
1728
1127
|
options
|
|
@@ -1733,6 +1132,20 @@ function list3(options) {
|
|
|
1733
1132
|
isLoading
|
|
1734
1133
|
};
|
|
1735
1134
|
}
|
|
1135
|
+
function sideBarList(options) {
|
|
1136
|
+
const { mutate, isLoading } = createMutation(
|
|
1137
|
+
async (payload) => {
|
|
1138
|
+
const response = await Client.object.sideBarList(payload);
|
|
1139
|
+
return response;
|
|
1140
|
+
},
|
|
1141
|
+
options
|
|
1142
|
+
);
|
|
1143
|
+
return {
|
|
1144
|
+
mutate,
|
|
1145
|
+
getSideBarObjects: mutate,
|
|
1146
|
+
isLoading
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1736
1149
|
function form(options) {
|
|
1737
1150
|
const { mutate, isLoading } = createMutation(
|
|
1738
1151
|
async (payload) => {
|
|
@@ -1762,9 +1175,16 @@ function objectFormOptions(options) {
|
|
|
1762
1175
|
};
|
|
1763
1176
|
}
|
|
1764
1177
|
function create(options) {
|
|
1178
|
+
const { setTablePrependData } = actions;
|
|
1765
1179
|
const { mutate, isLoading } = createMutation(
|
|
1766
1180
|
async (props) => {
|
|
1181
|
+
if (props?.componentName != "association") await setTablePrependData("loading", props);
|
|
1767
1182
|
const response = await Client.object.create(props);
|
|
1183
|
+
console.log(
|
|
1184
|
+
"props",
|
|
1185
|
+
props
|
|
1186
|
+
);
|
|
1187
|
+
if (props?.componentName != "association") await setTablePrependData(response, props);
|
|
1768
1188
|
return response;
|
|
1769
1189
|
},
|
|
1770
1190
|
options
|
|
@@ -1834,9 +1254,11 @@ function update(options) {
|
|
|
1834
1254
|
|
|
1835
1255
|
// src/apis/note.ts
|
|
1836
1256
|
function list4(options) {
|
|
1257
|
+
const { setNotes } = actions2;
|
|
1837
1258
|
const { mutate, isLoading } = createMutation(
|
|
1838
1259
|
async (payload) => {
|
|
1839
1260
|
const response = await Client.note.list(payload);
|
|
1261
|
+
setNotes(response, payload);
|
|
1840
1262
|
return response;
|
|
1841
1263
|
},
|
|
1842
1264
|
options
|
|
@@ -1848,9 +1270,12 @@ function list4(options) {
|
|
|
1848
1270
|
};
|
|
1849
1271
|
}
|
|
1850
1272
|
function create2(options) {
|
|
1273
|
+
const { setPrependNote } = actions2;
|
|
1851
1274
|
const { mutate, isLoading } = createMutation(
|
|
1852
1275
|
async (props) => {
|
|
1276
|
+
await setPrependNote("loading");
|
|
1853
1277
|
const response = await Client.note.create(props);
|
|
1278
|
+
await setPrependNote(response);
|
|
1854
1279
|
return response;
|
|
1855
1280
|
},
|
|
1856
1281
|
options
|
|
@@ -1862,9 +1287,11 @@ function create2(options) {
|
|
|
1862
1287
|
};
|
|
1863
1288
|
}
|
|
1864
1289
|
function update2(options) {
|
|
1290
|
+
const { updatePrependNote } = actions2;
|
|
1865
1291
|
const { mutate, isLoading } = createMutation(
|
|
1866
1292
|
async (payload) => {
|
|
1867
1293
|
const response = await Client.note.update(payload);
|
|
1294
|
+
updatePrependNote(response);
|
|
1868
1295
|
return response;
|
|
1869
1296
|
},
|
|
1870
1297
|
options
|
|
@@ -1878,9 +1305,11 @@ function update2(options) {
|
|
|
1878
1305
|
|
|
1879
1306
|
// src/apis/email.ts
|
|
1880
1307
|
function list5(options) {
|
|
1308
|
+
const { setEmails } = actions3;
|
|
1881
1309
|
const { mutate, isLoading } = createMutation(
|
|
1882
1310
|
async (payload) => {
|
|
1883
1311
|
const response = await Client.email.list(payload);
|
|
1312
|
+
setEmails(response, payload);
|
|
1884
1313
|
return response;
|
|
1885
1314
|
},
|
|
1886
1315
|
options
|
|
@@ -1892,9 +1321,12 @@ function list5(options) {
|
|
|
1892
1321
|
};
|
|
1893
1322
|
}
|
|
1894
1323
|
function create3(options) {
|
|
1324
|
+
const { setPrependEmail } = actions3;
|
|
1895
1325
|
const { mutate, isLoading } = createMutation(
|
|
1896
1326
|
async (props) => {
|
|
1327
|
+
await setPrependEmail("loading");
|
|
1897
1328
|
const response = await Client.email.create(props);
|
|
1329
|
+
await setPrependEmail(response);
|
|
1898
1330
|
return response;
|
|
1899
1331
|
},
|
|
1900
1332
|
options
|
|
@@ -1906,9 +1338,11 @@ function create3(options) {
|
|
|
1906
1338
|
};
|
|
1907
1339
|
}
|
|
1908
1340
|
function update3(options) {
|
|
1341
|
+
const { updatePrependEmail } = actions3;
|
|
1909
1342
|
const { mutate, isLoading } = createMutation(
|
|
1910
1343
|
async (payload) => {
|
|
1911
1344
|
const response = await Client.email.update(payload);
|
|
1345
|
+
updatePrependEmail(response);
|
|
1912
1346
|
return response;
|
|
1913
1347
|
},
|
|
1914
1348
|
options
|
|
@@ -1924,7 +1358,6 @@ function update3(options) {
|
|
|
1924
1358
|
function imageUpload(options) {
|
|
1925
1359
|
const { mutate, isLoading } = createMutation(
|
|
1926
1360
|
async (payload) => {
|
|
1927
|
-
console.log("payload", payload);
|
|
1928
1361
|
const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
|
|
1929
1362
|
return response;
|
|
1930
1363
|
},
|
|
@@ -2009,10 +1442,31 @@ function addFile(options) {
|
|
|
2009
1442
|
};
|
|
2010
1443
|
}
|
|
2011
1444
|
|
|
2012
|
-
// src/
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
1445
|
+
// src/apis/cache.ts
|
|
1446
|
+
function purge(options) {
|
|
1447
|
+
const { mutate, isLoading } = createMutation(
|
|
1448
|
+
async (payload) => {
|
|
1449
|
+
const safePayload = payload ?? {};
|
|
1450
|
+
const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
|
|
1451
|
+
const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
1452
|
+
const { idempotencyKey: _ignored, ...body } = safePayload;
|
|
1453
|
+
return Client.cache.purge(body, headers);
|
|
1454
|
+
},
|
|
1455
|
+
options
|
|
1456
|
+
);
|
|
1457
|
+
return { mutate, purgeCache: mutate, isLoading };
|
|
1458
|
+
}
|
|
1459
|
+
function purgeStatus(purgeJobId, options) {
|
|
1460
|
+
const { mutate, isLoading } = createMutation(
|
|
1461
|
+
async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
|
|
1462
|
+
options
|
|
1463
|
+
);
|
|
1464
|
+
return {
|
|
1465
|
+
mutate,
|
|
1466
|
+
getPurgeStatus: () => mutate(purgeJobId),
|
|
1467
|
+
isLoading
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
2016
1470
|
|
|
2017
1471
|
// src/breadcrumb/breadcrumbs.ts
|
|
2018
1472
|
var getBreadcrumbs = () => {
|
|
@@ -2220,6 +1674,66 @@ var buildChildRoute = (props, breadcrumbItems) => {
|
|
|
2220
1674
|
return generateUrl(props, breadcrumbs);
|
|
2221
1675
|
};
|
|
2222
1676
|
|
|
1677
|
+
// src/utils/datetime.ts
|
|
1678
|
+
var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
|
|
1679
|
+
function getCurrentTimeZone() {
|
|
1680
|
+
try {
|
|
1681
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
|
|
1682
|
+
} catch {
|
|
1683
|
+
return DEFAULT_HUBSPOT_TIMEZONE;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
function normalizeToTimestamp(value) {
|
|
1687
|
+
if (value == null || value === "") return null;
|
|
1688
|
+
if (typeof value === "number") {
|
|
1689
|
+
return value > 1e11 ? value : null;
|
|
1690
|
+
}
|
|
1691
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
1692
|
+
const n = Number(value);
|
|
1693
|
+
return n > 1e11 ? n : null;
|
|
1694
|
+
}
|
|
1695
|
+
if (typeof value === "string" || value instanceof Date) {
|
|
1696
|
+
const date = new Date(value);
|
|
1697
|
+
return Number.isNaN(date.getTime()) ? null : date.getTime();
|
|
1698
|
+
}
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
|
|
1702
|
+
const raw = new Intl.DateTimeFormat("en-US", {
|
|
1703
|
+
timeZone,
|
|
1704
|
+
timeZoneName: "longOffset"
|
|
1705
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
|
|
1706
|
+
if (!raw) return "";
|
|
1707
|
+
return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
|
|
1708
|
+
}
|
|
1709
|
+
function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1710
|
+
const ms = normalizeToTimestamp(timestamp);
|
|
1711
|
+
if (ms == null) return null;
|
|
1712
|
+
const date = new Date(ms);
|
|
1713
|
+
const datePart = new Intl.DateTimeFormat("en-US", {
|
|
1714
|
+
timeZone,
|
|
1715
|
+
month: "long",
|
|
1716
|
+
day: "numeric",
|
|
1717
|
+
year: "numeric"
|
|
1718
|
+
}).format(date);
|
|
1719
|
+
const timePart = new Intl.DateTimeFormat("en-US", {
|
|
1720
|
+
timeZone,
|
|
1721
|
+
hour: "numeric",
|
|
1722
|
+
minute: "2-digit",
|
|
1723
|
+
hour12: true
|
|
1724
|
+
}).format(date);
|
|
1725
|
+
const gmtOffset = formatGmtOffset(timeZone, date);
|
|
1726
|
+
return {
|
|
1727
|
+
date: datePart,
|
|
1728
|
+
time: timePart,
|
|
1729
|
+
gmtOffset,
|
|
1730
|
+
formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1734
|
+
return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
|
|
1735
|
+
}
|
|
1736
|
+
|
|
2223
1737
|
// src/index.ts
|
|
2224
1738
|
var api = {
|
|
2225
1739
|
preLogin,
|
|
@@ -2241,6 +1755,7 @@ var api = {
|
|
|
2241
1755
|
pipelines: list,
|
|
2242
1756
|
stages: list2,
|
|
2243
1757
|
objects: list3,
|
|
1758
|
+
sideBarObjects: sideBarList,
|
|
2244
1759
|
objectsForm: form,
|
|
2245
1760
|
createObject: create,
|
|
2246
1761
|
createExistingObject: createExisting,
|
|
@@ -2260,6 +1775,8 @@ var api = {
|
|
|
2260
1775
|
file: details2,
|
|
2261
1776
|
addFolder,
|
|
2262
1777
|
addFile,
|
|
1778
|
+
purgeCache: purge,
|
|
1779
|
+
cachePurgeStatus: purgeStatus,
|
|
2263
1780
|
getRefreshToken,
|
|
2264
1781
|
getAuthRefreshToken,
|
|
2265
1782
|
isCookieExpired,
|
|
@@ -2285,6 +1802,6 @@ var routeParam = {
|
|
|
2285
1802
|
getParamDetails
|
|
2286
1803
|
};
|
|
2287
1804
|
|
|
2288
|
-
export { api, breadcrumbsDetails, getFieldErrors, getFormErrors, initializeHttpClient, routeParam, store, url };
|
|
1805
|
+
export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url };
|
|
2289
1806
|
//# sourceMappingURL=index.js.map
|
|
2290
1807
|
//# sourceMappingURL=index.js.map
|