woodsportal-client-sdk 1.1.4-dev.4 → 1.1.4-dev.41
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 +113 -2
- package/dist/index.js +393 -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,70 @@ 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
|
+
FILE_DOWNLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files/${rowId}/download",
|
|
177
|
+
FILES_CREATE_FOLDER: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/folders",
|
|
178
|
+
FILES_UPLOAD: "/api/${hubId}/${portalId}/hubspot-object-data/${objectId}/records/${id}/files"
|
|
293
179
|
};
|
|
294
|
-
init_token_store();
|
|
295
180
|
|
|
296
|
-
// src/
|
|
181
|
+
// src/client/config.ts
|
|
297
182
|
var config2 = {
|
|
298
|
-
baseURL: "
|
|
183
|
+
baseURL: ""
|
|
299
184
|
};
|
|
300
185
|
|
|
301
|
-
// src/
|
|
302
|
-
init_auth_utils();
|
|
186
|
+
// src/client/http-clint.ts
|
|
303
187
|
var axiosInstance = null;
|
|
304
188
|
var config3 = {};
|
|
305
189
|
function initializeHttpClient(clientConfig) {
|
|
306
190
|
config3 = clientConfig;
|
|
307
|
-
const baseURL =
|
|
191
|
+
const baseURL = config?.devApiUrl || config3.baseURL;
|
|
192
|
+
if (!baseURL) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
"WoodsPortal SDK HTTP client is not configured. Call initializeHttpClient({ baseURL }) at app startup."
|
|
195
|
+
);
|
|
196
|
+
}
|
|
308
197
|
const timeout = config3.timeout ?? 5e4;
|
|
309
198
|
axiosInstance = axios.create({
|
|
310
199
|
baseURL,
|
|
@@ -360,9 +249,9 @@ var HttpClient = class {
|
|
|
360
249
|
const response = await getAxiosInstance().put(url2, data);
|
|
361
250
|
return response.data;
|
|
362
251
|
}
|
|
363
|
-
static async delete(url2) {
|
|
252
|
+
static async delete(url2, config4) {
|
|
364
253
|
await ensureValidRefresh();
|
|
365
|
-
const response = await getAxiosInstance().delete(url2);
|
|
254
|
+
const response = await getAxiosInstance().delete(url2, config4);
|
|
366
255
|
return response.data;
|
|
367
256
|
}
|
|
368
257
|
static formatSearchParams(params) {
|
|
@@ -451,357 +340,38 @@ var setProfileData = (data) => {
|
|
|
451
340
|
var getProfileData = () => {
|
|
452
341
|
return PROFILE;
|
|
453
342
|
};
|
|
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
|
-
|
|
478
|
-
// src/breadcrumb/url-utils.ts
|
|
479
|
-
function mapKeysDeep(obj, keyMap2) {
|
|
480
|
-
if (Array.isArray(obj)) {
|
|
481
|
-
return obj.map((item) => mapKeysDeep(item, keyMap2));
|
|
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";
|
|
508
|
-
}
|
|
509
|
-
return breadcrumbType;
|
|
510
|
-
}
|
|
511
|
-
var generateUrl = (props, breadcrumbs) => {
|
|
512
|
-
const newBase64 = convertToBase64(breadcrumbs);
|
|
513
|
-
let url2 = "";
|
|
514
|
-
if (props?.objectTypeId && props?.recordId) {
|
|
515
|
-
url2 = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
|
|
516
|
-
} else {
|
|
517
|
-
url2 = `/association/${props?.objectTypeId}?b=${newBase64}`;
|
|
518
|
-
}
|
|
519
|
-
return url2;
|
|
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
343
|
|
|
602
|
-
// src/
|
|
603
|
-
var
|
|
604
|
-
|
|
605
|
-
|
|
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);
|
|
344
|
+
// src/client/index.ts
|
|
345
|
+
var recordWriteContext = (paramsObject) => {
|
|
346
|
+
if (!paramsObject) {
|
|
347
|
+
return void 0;
|
|
619
348
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
-
}
|
|
349
|
+
const context = {};
|
|
350
|
+
const keys = [
|
|
351
|
+
"parentObjectTypeId",
|
|
352
|
+
"parentObjectRecordId",
|
|
353
|
+
"mediatorObjectTypeId",
|
|
354
|
+
"mediatorObjectRecordId"
|
|
355
|
+
];
|
|
356
|
+
keys.forEach((key) => {
|
|
357
|
+
const value = paramsObject[key];
|
|
358
|
+
if (value !== void 0 && value !== null && String(value).length > 0) {
|
|
359
|
+
context[key] = String(value);
|
|
653
360
|
}
|
|
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
|
-
};
|
|
361
|
+
});
|
|
362
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
696
363
|
};
|
|
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;
|
|
364
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
365
|
+
const base = { ...payload || {} };
|
|
366
|
+
const context = recordWriteContext(paramsObject);
|
|
367
|
+
if (context) {
|
|
368
|
+
base.context = context;
|
|
742
369
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
const getLinkParams = (displayName = "prm") => {
|
|
747
|
-
const search = getParam("b");
|
|
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);
|
|
370
|
+
if (options && Object.keys(options).length > 0) {
|
|
371
|
+
base.options = options;
|
|
801
372
|
}
|
|
373
|
+
return base;
|
|
802
374
|
};
|
|
803
|
-
|
|
804
|
-
// src/clint/index.ts
|
|
805
375
|
var Client = {
|
|
806
376
|
authentication: {
|
|
807
377
|
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
@@ -821,8 +391,8 @@ var Client = {
|
|
|
821
391
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
822
392
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
823
393
|
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.
|
|
394
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
395
|
+
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.VERIFY_EMAIL_RESEND, data),
|
|
826
396
|
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
827
397
|
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
828
398
|
},
|
|
@@ -851,17 +421,16 @@ var Client = {
|
|
|
851
421
|
apiParams.parentObjectTypeId = "0-2";
|
|
852
422
|
}
|
|
853
423
|
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
854
|
-
apiParams.cache = payload?.
|
|
424
|
+
apiParams.cache = payload?.cache;
|
|
855
425
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
856
426
|
return HttpClient.get(apiUrl);
|
|
857
427
|
}
|
|
858
428
|
},
|
|
859
429
|
stage: {
|
|
860
430
|
list: (props = null) => {
|
|
861
|
-
const portalId = config.devPortalId;
|
|
862
431
|
const params = {
|
|
863
|
-
hubId: config.hubId,
|
|
864
|
-
portalId,
|
|
432
|
+
// hubId: config.hubId,
|
|
433
|
+
// portalId: portalId,
|
|
865
434
|
objectTypeId: props?.params?.objectTypeId,
|
|
866
435
|
pipelineId: props?.params?.pipelineId
|
|
867
436
|
};
|
|
@@ -871,6 +440,7 @@ var Client = {
|
|
|
871
440
|
},
|
|
872
441
|
object: {
|
|
873
442
|
list: async (payload = null, param = null) => {
|
|
443
|
+
param.cache = payload.cache;
|
|
874
444
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
875
445
|
const { updateLink, getLinkParams } = useUpdateLink();
|
|
876
446
|
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
@@ -917,54 +487,89 @@ var Client = {
|
|
|
917
487
|
}
|
|
918
488
|
if (payload?.isHome) {
|
|
919
489
|
let parentObjectTypeId = "";
|
|
920
|
-
if (userData?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
921
|
-
parentObjectTypeId = userData?.info?.objectTypeId;
|
|
922
|
-
} else if (userData?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
490
|
+
if (userData?.data?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
491
|
+
parentObjectTypeId = userData?.data?.info?.objectTypeId;
|
|
492
|
+
} else if (userData?.data?.info?.objectTypeId && param?.isPrimaryCompany) {
|
|
923
493
|
parentObjectTypeId = "0-2";
|
|
924
494
|
}
|
|
925
495
|
param.parentObjectTypeId = parentObjectTypeId;
|
|
926
496
|
}
|
|
927
497
|
param.parentAccessLabel = parentAccessLabel;
|
|
498
|
+
const {
|
|
499
|
+
stageId,
|
|
500
|
+
nextPage
|
|
501
|
+
} = useTable();
|
|
502
|
+
if (stageId) {
|
|
503
|
+
param.stageId = stageId;
|
|
504
|
+
}
|
|
505
|
+
if (param?.view === "BOARD") {
|
|
506
|
+
param.page = nextPage;
|
|
507
|
+
}
|
|
928
508
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
929
509
|
return HttpClient.get(apiUrl);
|
|
930
510
|
},
|
|
511
|
+
sideBarList: async (payload = null) => {
|
|
512
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
513
|
+
const params = { hubspotObjectTypeId };
|
|
514
|
+
const queryParams = payload.param;
|
|
515
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
|
|
516
|
+
return HttpClient.get(apiUrl);
|
|
517
|
+
},
|
|
931
518
|
form: (payload = null) => {
|
|
932
519
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
933
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
520
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
934
521
|
return HttpClient.get(apiUrl);
|
|
935
522
|
},
|
|
936
523
|
objectFormOptions: (payload = null) => {
|
|
937
|
-
const params = {
|
|
524
|
+
const params = {
|
|
525
|
+
formId: payload?.formId,
|
|
526
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
527
|
+
};
|
|
938
528
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
939
529
|
return HttpClient.get(apiUrl);
|
|
940
530
|
},
|
|
941
531
|
create: (props = null) => {
|
|
532
|
+
const { getParamDetails: getParamDetailsForCreate } = routeParam;
|
|
533
|
+
const { paramsObject } = getParamDetailsForCreate({ type: props?.componentName });
|
|
534
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
535
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, {
|
|
536
|
+
cardParentMerge,
|
|
537
|
+
addAnother: props?.params?.addAnother
|
|
538
|
+
});
|
|
942
539
|
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);
|
|
540
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
541
|
+
return HttpClient.post(apiUrl, body);
|
|
947
542
|
},
|
|
948
543
|
createExisting: (props = null) => {
|
|
949
|
-
const
|
|
950
|
-
const
|
|
544
|
+
const { getLinkParams } = useUpdateLink();
|
|
545
|
+
const fParams = getLinkParams();
|
|
546
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
547
|
+
const params = {
|
|
548
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
549
|
+
fromRecordId: props?.fromRecordId,
|
|
550
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
551
|
+
};
|
|
951
552
|
const payload = props.payload;
|
|
952
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
553
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
953
554
|
return HttpClient.post(apiUrl, payload);
|
|
954
555
|
},
|
|
955
556
|
removeExisting: (props = null) => {
|
|
956
|
-
const
|
|
957
|
-
const
|
|
958
|
-
const
|
|
959
|
-
const
|
|
960
|
-
|
|
557
|
+
const { getParamDetails: getParamDetailsForRemove } = routeParam;
|
|
558
|
+
const { paramsObject } = getParamDetailsForRemove({ type: props?.componentName });
|
|
559
|
+
const body = mergeRecordWriteBody(props?.payload, paramsObject, void 0);
|
|
560
|
+
const params = {
|
|
561
|
+
fromObjectTypeId: props?.fromObjectTypeId ?? props?.hubspotObjectTypeId,
|
|
562
|
+
fromRecordId: props?.fromRecordId,
|
|
563
|
+
toObjectTypeId: props?.toObjectTypeId
|
|
564
|
+
};
|
|
565
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_DISASSOCIATE, params });
|
|
566
|
+
return HttpClient.delete(apiUrl, { data: body });
|
|
961
567
|
},
|
|
962
568
|
details: (props = null) => {
|
|
963
569
|
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
964
|
-
const portalId = config.devPortalId;
|
|
965
570
|
const params = {
|
|
966
|
-
hubId: config.hubId,
|
|
967
|
-
portalId,
|
|
571
|
+
// hubId: config.hubId,
|
|
572
|
+
// portalId: portalId,
|
|
968
573
|
objectId: props?.params?.objectId,
|
|
969
574
|
id: props?.params?.id
|
|
970
575
|
};
|
|
@@ -977,24 +582,29 @@ var Client = {
|
|
|
977
582
|
return HttpClient.get(apiUrl);
|
|
978
583
|
},
|
|
979
584
|
update: (props = null) => {
|
|
980
|
-
const portalId = getPortal()?.portalId;
|
|
981
585
|
const params = {
|
|
982
|
-
hubId: config.hubId,
|
|
983
|
-
portalId,
|
|
984
586
|
objectId: props?.params?.objectId,
|
|
985
587
|
id: props?.params?.id
|
|
986
588
|
};
|
|
987
|
-
const {
|
|
988
|
-
const
|
|
989
|
-
|
|
589
|
+
const { getParamDetails: getParamDetailsForUpdate } = routeParam;
|
|
590
|
+
const { paramsObject } = getParamDetailsForUpdate({ type: props?.componentName });
|
|
591
|
+
const cardParentMerge = props?.componentName === "association" ? true : false;
|
|
592
|
+
const rawPayload = props?.payload || {};
|
|
593
|
+
const properties = rawPayload.properties ?? rawPayload.propertyPayload ?? rawPayload;
|
|
594
|
+
const body = mergeRecordWriteBody(
|
|
595
|
+
{ properties },
|
|
596
|
+
paramsObject,
|
|
597
|
+
{ cardParentMerge }
|
|
598
|
+
);
|
|
599
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_UPDATE, params });
|
|
600
|
+
return HttpClient.put(apiUrl, body);
|
|
990
601
|
}
|
|
991
602
|
},
|
|
992
603
|
note: {
|
|
993
604
|
list: (props = null) => {
|
|
994
|
-
const portalId = getPortal()?.portalId;
|
|
995
605
|
const params = {
|
|
996
|
-
hubId: config.hubId,
|
|
997
|
-
portalId,
|
|
606
|
+
// hubId: config.hubId,
|
|
607
|
+
// portalId: portalId,
|
|
998
608
|
objectId: props?.params?.objectId,
|
|
999
609
|
id: props?.params?.id
|
|
1000
610
|
};
|
|
@@ -1009,10 +619,9 @@ var Client = {
|
|
|
1009
619
|
return HttpClient.post(apiUrl, payload);
|
|
1010
620
|
},
|
|
1011
621
|
update: (props = null) => {
|
|
1012
|
-
const portalId = getPortal()?.portalId;
|
|
1013
622
|
const params = {
|
|
1014
|
-
hubId: config.hubId,
|
|
1015
|
-
portalId,
|
|
623
|
+
// hubId: config.hubId,
|
|
624
|
+
// portalId: portalId,
|
|
1016
625
|
objectId: props?.params?.objectId,
|
|
1017
626
|
id: props?.params?.id,
|
|
1018
627
|
note_id: props?.params?.note_id
|
|
@@ -1050,10 +659,9 @@ var Client = {
|
|
|
1050
659
|
},
|
|
1051
660
|
email: {
|
|
1052
661
|
list: (props = null) => {
|
|
1053
|
-
const portalId = getPortal()?.portalId;
|
|
1054
662
|
const params = {
|
|
1055
|
-
hubId: config.hubId,
|
|
1056
|
-
portalId,
|
|
663
|
+
// hubId: config.hubId,
|
|
664
|
+
// portalId: portalId,
|
|
1057
665
|
objectId: props?.params?.objectId,
|
|
1058
666
|
id: props?.params?.id
|
|
1059
667
|
};
|
|
@@ -1068,13 +676,12 @@ var Client = {
|
|
|
1068
676
|
return HttpClient.post(apiUrl, payload);
|
|
1069
677
|
},
|
|
1070
678
|
update: (props = null) => {
|
|
1071
|
-
const portalId = getPortal()?.portalId;
|
|
1072
679
|
const params = {
|
|
1073
|
-
hubId: config.hubId,
|
|
1074
|
-
portalId,
|
|
680
|
+
// hubId: config.hubId,
|
|
681
|
+
// portalId: portalId,
|
|
1075
682
|
objectId: props?.params?.objectId,
|
|
1076
683
|
id: props?.params?.id,
|
|
1077
|
-
|
|
684
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
1078
685
|
};
|
|
1079
686
|
const { paramsObject: queryParams } = getParamDetails();
|
|
1080
687
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
@@ -1107,12 +714,24 @@ var Client = {
|
|
|
1107
714
|
});
|
|
1108
715
|
}
|
|
1109
716
|
},
|
|
717
|
+
cache: {
|
|
718
|
+
purge: (body, headers) => {
|
|
719
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.CACHE_PURGE });
|
|
720
|
+
return HttpClient.post(apiUrl, body, headers ? { headers } : void 0);
|
|
721
|
+
},
|
|
722
|
+
purgeStatus: (purgeJobId) => {
|
|
723
|
+
const apiUrl = generateApiUrl({
|
|
724
|
+
route: API_ENDPOINTS.CACHE_PURGE_STATUS,
|
|
725
|
+
params: { purgeJobId }
|
|
726
|
+
});
|
|
727
|
+
return HttpClient.get(apiUrl);
|
|
728
|
+
}
|
|
729
|
+
},
|
|
1110
730
|
file: {
|
|
1111
731
|
list: (props = null) => {
|
|
1112
|
-
const portalId = getPortal()?.portalId;
|
|
1113
732
|
const params = {
|
|
1114
|
-
hubId: config.hubId,
|
|
1115
|
-
portalId,
|
|
733
|
+
// hubId: config.hubId,
|
|
734
|
+
// portalId: portalId,
|
|
1116
735
|
objectId: props?.params?.objectId,
|
|
1117
736
|
id: props?.params?.id
|
|
1118
737
|
};
|
|
@@ -1120,10 +739,9 @@ var Client = {
|
|
|
1120
739
|
return HttpClient.get(apiUrl);
|
|
1121
740
|
},
|
|
1122
741
|
details: (props = null) => {
|
|
1123
|
-
const portalId = getPortal()?.portalId;
|
|
1124
742
|
const params = {
|
|
1125
|
-
hubId: config.hubId,
|
|
1126
|
-
portalId,
|
|
743
|
+
// hubId: config.hubId,
|
|
744
|
+
// portalId: portalId,
|
|
1127
745
|
objectId: props?.params?.objectId,
|
|
1128
746
|
id: props?.params?.id,
|
|
1129
747
|
rowId: props?.params?.rowId
|
|
@@ -1131,6 +749,15 @@ var Client = {
|
|
|
1131
749
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
1132
750
|
return HttpClient.get(apiUrl);
|
|
1133
751
|
},
|
|
752
|
+
download: (props = null) => {
|
|
753
|
+
const params = {
|
|
754
|
+
objectId: props?.params?.objectId,
|
|
755
|
+
id: props?.params?.id,
|
|
756
|
+
rowId: props?.params?.rowId
|
|
757
|
+
};
|
|
758
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE_DOWNLOAD, params, queryParams: props?.queryParams });
|
|
759
|
+
return HttpClient.post(apiUrl, {});
|
|
760
|
+
},
|
|
1134
761
|
addFolder: (props = null) => {
|
|
1135
762
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1136
763
|
const queryParams = props.queryParams;
|
|
@@ -1153,6 +780,25 @@ var Client = {
|
|
|
1153
780
|
}
|
|
1154
781
|
}
|
|
1155
782
|
};
|
|
783
|
+
function logError(context, error) {
|
|
784
|
+
if (axios.isAxiosError(error)) {
|
|
785
|
+
resetAllStore();
|
|
786
|
+
console.error(context, {
|
|
787
|
+
message: error.message,
|
|
788
|
+
status: error.response?.status,
|
|
789
|
+
statusText: error.response?.statusText,
|
|
790
|
+
data: error.response?.data,
|
|
791
|
+
url: error.config?.url,
|
|
792
|
+
method: error.config?.method
|
|
793
|
+
});
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (error instanceof Error) {
|
|
797
|
+
console.error(context, error.message, error);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
console.error(context, error);
|
|
801
|
+
}
|
|
1156
802
|
|
|
1157
803
|
// src/mutation/createMutation.ts
|
|
1158
804
|
function createMutation(mutationFn, options) {
|
|
@@ -1173,6 +819,7 @@ function createMutation(mutationFn, options) {
|
|
|
1173
819
|
return response;
|
|
1174
820
|
} catch (error) {
|
|
1175
821
|
options?.onError?.(error, payload);
|
|
822
|
+
logError("[mutation]", error);
|
|
1176
823
|
throw error;
|
|
1177
824
|
} finally {
|
|
1178
825
|
inFlight -= 1;
|
|
@@ -1186,9 +833,6 @@ function createMutation(mutationFn, options) {
|
|
|
1186
833
|
}
|
|
1187
834
|
|
|
1188
835
|
// src/apis/authentication.ts
|
|
1189
|
-
init_auth_utils();
|
|
1190
|
-
init_cookie();
|
|
1191
|
-
init_token_store();
|
|
1192
836
|
function preLogin(options) {
|
|
1193
837
|
const { mutate, isLoading } = createMutation(
|
|
1194
838
|
async (payload) => {
|
|
@@ -1442,242 +1086,6 @@ function changePassword(options) {
|
|
|
1442
1086
|
};
|
|
1443
1087
|
}
|
|
1444
1088
|
|
|
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
1089
|
// src/apis/pipeline.ts
|
|
1682
1090
|
function list(options) {
|
|
1683
1091
|
const {
|
|
@@ -1716,13 +1124,14 @@ function list2(options) {
|
|
|
1716
1124
|
|
|
1717
1125
|
// src/apis/object.ts
|
|
1718
1126
|
function list3(options) {
|
|
1719
|
-
const {
|
|
1720
|
-
|
|
1721
|
-
} = useTable();
|
|
1127
|
+
const { getTableParam } = useTable();
|
|
1128
|
+
const { setObjectsData, setTableData } = actions;
|
|
1722
1129
|
const { mutate, isLoading } = createMutation(
|
|
1723
1130
|
async (payload) => {
|
|
1724
1131
|
const param = await getTableParam(payload?.companyAsMediator);
|
|
1725
1132
|
const response = await Client.object.list(payload, param);
|
|
1133
|
+
await setObjectsData(response);
|
|
1134
|
+
await setTableData(response, payload);
|
|
1726
1135
|
return response;
|
|
1727
1136
|
},
|
|
1728
1137
|
options
|
|
@@ -1733,6 +1142,20 @@ function list3(options) {
|
|
|
1733
1142
|
isLoading
|
|
1734
1143
|
};
|
|
1735
1144
|
}
|
|
1145
|
+
function sideBarList(options) {
|
|
1146
|
+
const { mutate, isLoading } = createMutation(
|
|
1147
|
+
async (payload) => {
|
|
1148
|
+
const response = await Client.object.sideBarList(payload);
|
|
1149
|
+
return response;
|
|
1150
|
+
},
|
|
1151
|
+
options
|
|
1152
|
+
);
|
|
1153
|
+
return {
|
|
1154
|
+
mutate,
|
|
1155
|
+
getSideBarObjects: mutate,
|
|
1156
|
+
isLoading
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1736
1159
|
function form(options) {
|
|
1737
1160
|
const { mutate, isLoading } = createMutation(
|
|
1738
1161
|
async (payload) => {
|
|
@@ -1762,9 +1185,16 @@ function objectFormOptions(options) {
|
|
|
1762
1185
|
};
|
|
1763
1186
|
}
|
|
1764
1187
|
function create(options) {
|
|
1188
|
+
const { setTablePrependData } = actions;
|
|
1765
1189
|
const { mutate, isLoading } = createMutation(
|
|
1766
1190
|
async (props) => {
|
|
1191
|
+
if (props?.componentName != "association") await setTablePrependData("loading", props);
|
|
1767
1192
|
const response = await Client.object.create(props);
|
|
1193
|
+
console.log(
|
|
1194
|
+
"props",
|
|
1195
|
+
props
|
|
1196
|
+
);
|
|
1197
|
+
if (props?.componentName != "association") await setTablePrependData(response, props);
|
|
1768
1198
|
return response;
|
|
1769
1199
|
},
|
|
1770
1200
|
options
|
|
@@ -1834,9 +1264,11 @@ function update(options) {
|
|
|
1834
1264
|
|
|
1835
1265
|
// src/apis/note.ts
|
|
1836
1266
|
function list4(options) {
|
|
1267
|
+
const { setNotes } = actions2;
|
|
1837
1268
|
const { mutate, isLoading } = createMutation(
|
|
1838
1269
|
async (payload) => {
|
|
1839
1270
|
const response = await Client.note.list(payload);
|
|
1271
|
+
setNotes(response, payload);
|
|
1840
1272
|
return response;
|
|
1841
1273
|
},
|
|
1842
1274
|
options
|
|
@@ -1848,9 +1280,12 @@ function list4(options) {
|
|
|
1848
1280
|
};
|
|
1849
1281
|
}
|
|
1850
1282
|
function create2(options) {
|
|
1283
|
+
const { setPrependNote } = actions2;
|
|
1851
1284
|
const { mutate, isLoading } = createMutation(
|
|
1852
1285
|
async (props) => {
|
|
1286
|
+
await setPrependNote("loading");
|
|
1853
1287
|
const response = await Client.note.create(props);
|
|
1288
|
+
await setPrependNote(response);
|
|
1854
1289
|
return response;
|
|
1855
1290
|
},
|
|
1856
1291
|
options
|
|
@@ -1862,9 +1297,11 @@ function create2(options) {
|
|
|
1862
1297
|
};
|
|
1863
1298
|
}
|
|
1864
1299
|
function update2(options) {
|
|
1300
|
+
const { updatePrependNote } = actions2;
|
|
1865
1301
|
const { mutate, isLoading } = createMutation(
|
|
1866
1302
|
async (payload) => {
|
|
1867
1303
|
const response = await Client.note.update(payload);
|
|
1304
|
+
updatePrependNote(response);
|
|
1868
1305
|
return response;
|
|
1869
1306
|
},
|
|
1870
1307
|
options
|
|
@@ -1878,9 +1315,11 @@ function update2(options) {
|
|
|
1878
1315
|
|
|
1879
1316
|
// src/apis/email.ts
|
|
1880
1317
|
function list5(options) {
|
|
1318
|
+
const { setEmails } = actions3;
|
|
1881
1319
|
const { mutate, isLoading } = createMutation(
|
|
1882
1320
|
async (payload) => {
|
|
1883
1321
|
const response = await Client.email.list(payload);
|
|
1322
|
+
setEmails(response, payload);
|
|
1884
1323
|
return response;
|
|
1885
1324
|
},
|
|
1886
1325
|
options
|
|
@@ -1892,9 +1331,12 @@ function list5(options) {
|
|
|
1892
1331
|
};
|
|
1893
1332
|
}
|
|
1894
1333
|
function create3(options) {
|
|
1334
|
+
const { setPrependEmail } = actions3;
|
|
1895
1335
|
const { mutate, isLoading } = createMutation(
|
|
1896
1336
|
async (props) => {
|
|
1337
|
+
await setPrependEmail("loading");
|
|
1897
1338
|
const response = await Client.email.create(props);
|
|
1339
|
+
await setPrependEmail(response);
|
|
1898
1340
|
return response;
|
|
1899
1341
|
},
|
|
1900
1342
|
options
|
|
@@ -1906,9 +1348,11 @@ function create3(options) {
|
|
|
1906
1348
|
};
|
|
1907
1349
|
}
|
|
1908
1350
|
function update3(options) {
|
|
1351
|
+
const { updatePrependEmail } = actions3;
|
|
1909
1352
|
const { mutate, isLoading } = createMutation(
|
|
1910
1353
|
async (payload) => {
|
|
1911
1354
|
const response = await Client.email.update(payload);
|
|
1355
|
+
updatePrependEmail(response);
|
|
1912
1356
|
return response;
|
|
1913
1357
|
},
|
|
1914
1358
|
options
|
|
@@ -1924,7 +1368,6 @@ function update3(options) {
|
|
|
1924
1368
|
function imageUpload(options) {
|
|
1925
1369
|
const { mutate, isLoading } = createMutation(
|
|
1926
1370
|
async (payload) => {
|
|
1927
|
-
console.log("payload", payload);
|
|
1928
1371
|
const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
|
|
1929
1372
|
return response;
|
|
1930
1373
|
},
|
|
@@ -2008,11 +1451,46 @@ function addFile(options) {
|
|
|
2008
1451
|
isLoading
|
|
2009
1452
|
};
|
|
2010
1453
|
}
|
|
1454
|
+
function download(options) {
|
|
1455
|
+
const { mutate, isLoading } = createMutation(
|
|
1456
|
+
async (payload) => {
|
|
1457
|
+
const response = await Client.file.download(payload);
|
|
1458
|
+
return response;
|
|
1459
|
+
},
|
|
1460
|
+
options
|
|
1461
|
+
);
|
|
1462
|
+
return {
|
|
1463
|
+
mutate,
|
|
1464
|
+
downloadFile: mutate,
|
|
1465
|
+
isLoading
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
2011
1468
|
|
|
2012
|
-
// src/
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
1469
|
+
// src/apis/cache.ts
|
|
1470
|
+
function purge(options) {
|
|
1471
|
+
const { mutate, isLoading } = createMutation(
|
|
1472
|
+
async (payload) => {
|
|
1473
|
+
const safePayload = payload ?? {};
|
|
1474
|
+
const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
|
|
1475
|
+
const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
1476
|
+
const { idempotencyKey: _ignored, ...body } = safePayload;
|
|
1477
|
+
return Client.cache.purge(body, headers);
|
|
1478
|
+
},
|
|
1479
|
+
options
|
|
1480
|
+
);
|
|
1481
|
+
return { mutate, purgeCache: mutate, isLoading };
|
|
1482
|
+
}
|
|
1483
|
+
function purgeStatus(purgeJobId, options) {
|
|
1484
|
+
const { mutate, isLoading } = createMutation(
|
|
1485
|
+
async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
|
|
1486
|
+
options
|
|
1487
|
+
);
|
|
1488
|
+
return {
|
|
1489
|
+
mutate,
|
|
1490
|
+
getPurgeStatus: () => mutate(purgeJobId),
|
|
1491
|
+
isLoading
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
2016
1494
|
|
|
2017
1495
|
// src/breadcrumb/breadcrumbs.ts
|
|
2018
1496
|
var getBreadcrumbs = () => {
|
|
@@ -2220,6 +1698,66 @@ var buildChildRoute = (props, breadcrumbItems) => {
|
|
|
2220
1698
|
return generateUrl(props, breadcrumbs);
|
|
2221
1699
|
};
|
|
2222
1700
|
|
|
1701
|
+
// src/utils/datetime.ts
|
|
1702
|
+
var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
|
|
1703
|
+
function getCurrentTimeZone() {
|
|
1704
|
+
try {
|
|
1705
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
|
|
1706
|
+
} catch {
|
|
1707
|
+
return DEFAULT_HUBSPOT_TIMEZONE;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
function normalizeToTimestamp(value) {
|
|
1711
|
+
if (value == null || value === "") return null;
|
|
1712
|
+
if (typeof value === "number") {
|
|
1713
|
+
return value > 1e11 ? value : null;
|
|
1714
|
+
}
|
|
1715
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
1716
|
+
const n = Number(value);
|
|
1717
|
+
return n > 1e11 ? n : null;
|
|
1718
|
+
}
|
|
1719
|
+
if (typeof value === "string" || value instanceof Date) {
|
|
1720
|
+
const date = new Date(value);
|
|
1721
|
+
return Number.isNaN(date.getTime()) ? null : date.getTime();
|
|
1722
|
+
}
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
|
|
1726
|
+
const raw = new Intl.DateTimeFormat("en-US", {
|
|
1727
|
+
timeZone,
|
|
1728
|
+
timeZoneName: "longOffset"
|
|
1729
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
|
|
1730
|
+
if (!raw) return "";
|
|
1731
|
+
return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
|
|
1732
|
+
}
|
|
1733
|
+
function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1734
|
+
const ms = normalizeToTimestamp(timestamp);
|
|
1735
|
+
if (ms == null) return null;
|
|
1736
|
+
const date = new Date(ms);
|
|
1737
|
+
const datePart = new Intl.DateTimeFormat("en-US", {
|
|
1738
|
+
timeZone,
|
|
1739
|
+
month: "long",
|
|
1740
|
+
day: "numeric",
|
|
1741
|
+
year: "numeric"
|
|
1742
|
+
}).format(date);
|
|
1743
|
+
const timePart = new Intl.DateTimeFormat("en-US", {
|
|
1744
|
+
timeZone,
|
|
1745
|
+
hour: "numeric",
|
|
1746
|
+
minute: "2-digit",
|
|
1747
|
+
hour12: true
|
|
1748
|
+
}).format(date);
|
|
1749
|
+
const gmtOffset = formatGmtOffset(timeZone, date);
|
|
1750
|
+
return {
|
|
1751
|
+
date: datePart,
|
|
1752
|
+
time: timePart,
|
|
1753
|
+
gmtOffset,
|
|
1754
|
+
formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1758
|
+
return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
|
|
1759
|
+
}
|
|
1760
|
+
|
|
2223
1761
|
// src/index.ts
|
|
2224
1762
|
var api = {
|
|
2225
1763
|
preLogin,
|
|
@@ -2241,6 +1779,7 @@ var api = {
|
|
|
2241
1779
|
pipelines: list,
|
|
2242
1780
|
stages: list2,
|
|
2243
1781
|
objects: list3,
|
|
1782
|
+
sideBarObjects: sideBarList,
|
|
2244
1783
|
objectsForm: form,
|
|
2245
1784
|
createObject: create,
|
|
2246
1785
|
createExistingObject: createExisting,
|
|
@@ -2258,8 +1797,11 @@ var api = {
|
|
|
2258
1797
|
attachmentUpload,
|
|
2259
1798
|
files: list6,
|
|
2260
1799
|
file: details2,
|
|
1800
|
+
fileDownload: download,
|
|
2261
1801
|
addFolder,
|
|
2262
1802
|
addFile,
|
|
1803
|
+
purgeCache: purge,
|
|
1804
|
+
cachePurgeStatus: purgeStatus,
|
|
2263
1805
|
getRefreshToken,
|
|
2264
1806
|
getAuthRefreshToken,
|
|
2265
1807
|
isCookieExpired,
|
|
@@ -2285,6 +1827,6 @@ var routeParam = {
|
|
|
2285
1827
|
getParamDetails
|
|
2286
1828
|
};
|
|
2287
1829
|
|
|
2288
|
-
export { api, breadcrumbsDetails, getFieldErrors, getFormErrors, initializeHttpClient, routeParam, store, url };
|
|
1830
|
+
export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url };
|
|
2289
1831
|
//# sourceMappingURL=index.js.map
|
|
2290
1832
|
//# sourceMappingURL=index.js.map
|