woodsportal-client-sdk 1.1.4-dev.8 → 1.1.5-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +48 -2
- package/dist/adapters/angular/index.d.ts +27 -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 +27 -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 +27 -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-J7MDPY5P.js +54 -0
- package/dist/chunk-J7MDPY5P.js.map +1 -0
- package/dist/chunk-NB7AINV4.js +35 -0
- package/dist/chunk-NB7AINV4.js.map +1 -0
- package/dist/chunk-RDCT25UV.js +1066 -0
- package/dist/chunk-RDCT25UV.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 +100 -2
- package/dist/index.js +308 -822
- 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 } from './chunk-RDCT25UV.js';
|
|
2
|
+
import { ensureValidRefresh, HUBSPOT_DATA, PORTAL_ID, DEV_PORTAL_ID, HUB_ID, setRefreshCallback, getAccessToken, setRefreshToken, setAccessToken, isAuthenticateApp, isExpiresAccessToken, getRefreshToken, DEV_API_URL, setPortal, setSubscriptionType, setLoggedInDetails, clearAccessToken } from './chunk-YLZA5S7A.js';
|
|
3
|
+
import { __export, isCookieExpired, removeAllCookie } from './chunk-NB7AINV4.js';
|
|
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,352 +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
|
-
}, {});
|
|
343
|
+
// src/client/index.ts
|
|
344
|
+
var recordWriteContext = (paramsObject) => {
|
|
345
|
+
if (!paramsObject) {
|
|
346
|
+
return void 0;
|
|
488
347
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
};
|
|
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);
|
|
555
359
|
}
|
|
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 };
|
|
360
|
+
});
|
|
361
|
+
return Object.keys(context).length > 0 ? context : void 0;
|
|
613
362
|
};
|
|
614
|
-
var
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
if (
|
|
618
|
-
|
|
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
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
let paramsObject = {};
|
|
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();
|
|
363
|
+
var mergeRecordWriteBody = (payload, paramsObject, options) => {
|
|
364
|
+
const base = { ...payload || {} };
|
|
365
|
+
const context = recordWriteContext(paramsObject);
|
|
366
|
+
if (context) {
|
|
367
|
+
base.context = context;
|
|
679
368
|
}
|
|
680
|
-
|
|
681
|
-
|
|
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;
|
|
369
|
+
if (options && Object.keys(options).length > 0) {
|
|
370
|
+
base.options = options;
|
|
688
371
|
}
|
|
689
|
-
return
|
|
690
|
-
breadcrumbs,
|
|
691
|
-
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
692
|
-
paramsObject,
|
|
693
|
-
params,
|
|
694
|
-
parentAccessLabel
|
|
695
|
-
};
|
|
372
|
+
return base;
|
|
696
373
|
};
|
|
697
|
-
|
|
698
|
-
// src/breadcrumb/url.ts
|
|
699
|
-
var useUpdateLink = () => {
|
|
700
|
-
const updateLink = async (props, displayName = "prm") => {
|
|
701
|
-
const search = getParam("b");
|
|
702
|
-
const pathname = getPath();
|
|
703
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
704
|
-
if (breadcrumbs.length < 1) {
|
|
705
|
-
const routeMenu = getRouteMenu(pathname);
|
|
706
|
-
breadcrumbs = [
|
|
707
|
-
{
|
|
708
|
-
n: routeMenu?.title,
|
|
709
|
-
pt: routeMenu?.path
|
|
710
|
-
}
|
|
711
|
-
];
|
|
712
|
-
}
|
|
713
|
-
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
714
|
-
if (displayName) {
|
|
715
|
-
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
716
|
-
await setDeep(lastBreadcrumb, displayName, {
|
|
717
|
-
...ex,
|
|
718
|
-
...props
|
|
719
|
-
});
|
|
720
|
-
} else {
|
|
721
|
-
await Object.assign(lastBreadcrumb, props);
|
|
722
|
-
}
|
|
723
|
-
const newBase64 = convertToBase64(breadcrumbs);
|
|
724
|
-
updateBParam(newBase64);
|
|
725
|
-
};
|
|
726
|
-
function setDeep(obj, path, value) {
|
|
727
|
-
const keys = path.split(".");
|
|
728
|
-
let curr = obj;
|
|
729
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
730
|
-
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
731
|
-
curr[keys[i]] = {};
|
|
732
|
-
}
|
|
733
|
-
curr = curr[keys[i]];
|
|
734
|
-
}
|
|
735
|
-
curr[keys[keys.length - 1]] = value;
|
|
736
|
-
return curr;
|
|
737
|
-
}
|
|
738
|
-
function getDeep(obj, path) {
|
|
739
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
740
|
-
}
|
|
741
|
-
const getLinkParams = (displayName = "prm") => {
|
|
742
|
-
const search = getParam("b");
|
|
743
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
744
|
-
if (breadcrumbs.length < 1) return null;
|
|
745
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
746
|
-
const getDeep2 = (obj, path) => {
|
|
747
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
748
|
-
};
|
|
749
|
-
const expandKeys = (obj) => {
|
|
750
|
-
return Object.fromEntries(
|
|
751
|
-
Object.entries(obj).map(([key, value]) => [
|
|
752
|
-
keyMap[key] || key,
|
|
753
|
-
// map if exists, else keep original
|
|
754
|
-
value
|
|
755
|
-
])
|
|
756
|
-
);
|
|
757
|
-
};
|
|
758
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
759
|
-
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
760
|
-
return output;
|
|
761
|
-
};
|
|
762
|
-
const filterParams = (displayName = "prm") => {
|
|
763
|
-
const search = getParam("b");
|
|
764
|
-
let breadcrumbs = decodeToBase64(search) || [];
|
|
765
|
-
if (breadcrumbs.length < 1) return null;
|
|
766
|
-
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
767
|
-
const getDeep2 = (obj, path) => {
|
|
768
|
-
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
769
|
-
};
|
|
770
|
-
const expandKeys = (obj) => {
|
|
771
|
-
return Object.fromEntries(
|
|
772
|
-
Object.entries(obj).map(([key, value]) => [
|
|
773
|
-
keyMap[key] || key,
|
|
774
|
-
// map if exists, else keep original
|
|
775
|
-
value
|
|
776
|
-
])
|
|
777
|
-
);
|
|
778
|
-
};
|
|
779
|
-
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
780
|
-
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
781
|
-
return output;
|
|
782
|
-
};
|
|
783
|
-
return { updateLink, getLinkParams, filterParams };
|
|
784
|
-
};
|
|
785
|
-
var updateBParam = (newValue) => {
|
|
786
|
-
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
787
|
-
const hash = globalThis.location.hash || "";
|
|
788
|
-
if (!hash.startsWith("#/")) return;
|
|
789
|
-
const withoutHash = hash.slice(2);
|
|
790
|
-
const [path, queryString] = withoutHash.split("?");
|
|
791
|
-
const params = new URLSearchParams(queryString || "");
|
|
792
|
-
params.set("b", newValue);
|
|
793
|
-
const newHash = `#/${path}?${params.toString()}`;
|
|
794
|
-
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
795
|
-
globalThis.history.replaceState(null, "", newHash);
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
// src/clint/index.ts
|
|
800
374
|
var Client = {
|
|
801
375
|
authentication: {
|
|
802
376
|
preLogin: (data) => AuthHttpClient.post(API_ENDPOINTS.PRE_LOGIN, data),
|
|
@@ -816,8 +390,8 @@ var Client = {
|
|
|
816
390
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
817
391
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
818
392
|
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
819
|
-
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data),
|
|
820
|
-
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),
|
|
821
395
|
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
822
396
|
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
823
397
|
},
|
|
@@ -847,7 +421,6 @@ var Client = {
|
|
|
847
421
|
}
|
|
848
422
|
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
849
423
|
apiParams.cache = payload?.cache;
|
|
850
|
-
console.log("payload", payload);
|
|
851
424
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
852
425
|
return HttpClient.get(apiUrl);
|
|
853
426
|
}
|
|
@@ -913,14 +486,24 @@ var Client = {
|
|
|
913
486
|
}
|
|
914
487
|
if (payload?.isHome) {
|
|
915
488
|
let parentObjectTypeId = "";
|
|
916
|
-
if (userData?.info?.objectTypeId && !param?.isPrimaryCompany) {
|
|
917
|
-
parentObjectTypeId = userData?.info?.objectTypeId;
|
|
918
|
-
} 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) {
|
|
919
492
|
parentObjectTypeId = "0-2";
|
|
920
493
|
}
|
|
921
494
|
param.parentObjectTypeId = parentObjectTypeId;
|
|
922
495
|
}
|
|
923
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
|
+
}
|
|
924
507
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
925
508
|
return HttpClient.get(apiUrl);
|
|
926
509
|
},
|
|
@@ -933,34 +516,53 @@ var Client = {
|
|
|
933
516
|
},
|
|
934
517
|
form: (payload = null) => {
|
|
935
518
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
936
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
519
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM, params, queryParams: payload?.params });
|
|
937
520
|
return HttpClient.get(apiUrl);
|
|
938
521
|
},
|
|
939
522
|
objectFormOptions: (payload = null) => {
|
|
940
|
-
const params = {
|
|
523
|
+
const params = {
|
|
524
|
+
formId: payload?.formId,
|
|
525
|
+
objectTypeId: payload?.objectTypeId ?? payload?.hubspotObjectTypeId
|
|
526
|
+
};
|
|
941
527
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
942
528
|
return HttpClient.get(apiUrl);
|
|
943
529
|
},
|
|
944
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
|
+
});
|
|
945
538
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE, params, queryParams });
|
|
949
|
-
return HttpClient.post(apiUrl, payload);
|
|
539
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_CREATE, params, queryParams: props?.params });
|
|
540
|
+
return HttpClient.post(apiUrl, body);
|
|
950
541
|
},
|
|
951
542
|
createExisting: (props = null) => {
|
|
952
|
-
const
|
|
953
|
-
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
|
+
};
|
|
954
551
|
const payload = props.payload;
|
|
955
|
-
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.
|
|
552
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.RECORDS_ASSOCIATE, params, queryParams });
|
|
956
553
|
return HttpClient.post(apiUrl, payload);
|
|
957
554
|
},
|
|
958
555
|
removeExisting: (props = null) => {
|
|
959
|
-
const
|
|
960
|
-
const
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
|
|
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 });
|
|
964
566
|
},
|
|
965
567
|
details: (props = null) => {
|
|
966
568
|
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
@@ -980,14 +582,21 @@ var Client = {
|
|
|
980
582
|
},
|
|
981
583
|
update: (props = null) => {
|
|
982
584
|
const params = {
|
|
983
|
-
// hubId: config.hubId,
|
|
984
|
-
// portalId: portalId,
|
|
985
585
|
objectId: props?.params?.objectId,
|
|
986
586
|
id: props?.params?.id
|
|
987
587
|
};
|
|
988
|
-
const {
|
|
989
|
-
const
|
|
990
|
-
|
|
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);
|
|
991
600
|
}
|
|
992
601
|
},
|
|
993
602
|
note: {
|
|
@@ -1071,7 +680,7 @@ var Client = {
|
|
|
1071
680
|
// portalId: portalId,
|
|
1072
681
|
objectId: props?.params?.objectId,
|
|
1073
682
|
id: props?.params?.id,
|
|
1074
|
-
|
|
683
|
+
email_id: props?.params?.email_id ?? props?.params?.note_id
|
|
1075
684
|
};
|
|
1076
685
|
const { paramsObject: queryParams } = getParamDetails();
|
|
1077
686
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
@@ -1104,6 +713,19 @@ var Client = {
|
|
|
1104
713
|
});
|
|
1105
714
|
}
|
|
1106
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
|
+
},
|
|
1107
729
|
file: {
|
|
1108
730
|
list: (props = null) => {
|
|
1109
731
|
const params = {
|
|
@@ -1112,7 +734,6 @@ var Client = {
|
|
|
1112
734
|
objectId: props?.params?.objectId,
|
|
1113
735
|
id: props?.params?.id
|
|
1114
736
|
};
|
|
1115
|
-
console.log("params_0", params);
|
|
1116
737
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
|
|
1117
738
|
return HttpClient.get(apiUrl);
|
|
1118
739
|
},
|
|
@@ -1124,7 +745,6 @@ var Client = {
|
|
|
1124
745
|
id: props?.params?.id,
|
|
1125
746
|
rowId: props?.params?.rowId
|
|
1126
747
|
};
|
|
1127
|
-
console.log("params_1", params);
|
|
1128
748
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
1129
749
|
return HttpClient.get(apiUrl);
|
|
1130
750
|
},
|
|
@@ -1183,9 +803,6 @@ function createMutation(mutationFn, options) {
|
|
|
1183
803
|
}
|
|
1184
804
|
|
|
1185
805
|
// src/apis/authentication.ts
|
|
1186
|
-
init_auth_utils();
|
|
1187
|
-
init_cookie();
|
|
1188
|
-
init_token_store();
|
|
1189
806
|
function preLogin(options) {
|
|
1190
807
|
const { mutate, isLoading } = createMutation(
|
|
1191
808
|
async (payload) => {
|
|
@@ -1439,242 +1056,6 @@ function changePassword(options) {
|
|
|
1439
1056
|
};
|
|
1440
1057
|
}
|
|
1441
1058
|
|
|
1442
|
-
// src/store/index.ts
|
|
1443
|
-
function createStore(initializer) {
|
|
1444
|
-
let state;
|
|
1445
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1446
|
-
const get = () => state;
|
|
1447
|
-
const set = (partial) => {
|
|
1448
|
-
const prevState = state;
|
|
1449
|
-
const partialState = typeof partial === "function" ? partial(state) : partial;
|
|
1450
|
-
state = {
|
|
1451
|
-
...state,
|
|
1452
|
-
...partialState
|
|
1453
|
-
};
|
|
1454
|
-
listeners.forEach(
|
|
1455
|
-
(listener) => listener(state, prevState)
|
|
1456
|
-
);
|
|
1457
|
-
};
|
|
1458
|
-
const subscribe = (listener) => {
|
|
1459
|
-
listeners.add(listener);
|
|
1460
|
-
return () => listeners.delete(listener);
|
|
1461
|
-
};
|
|
1462
|
-
state = initializer(set, get);
|
|
1463
|
-
return {
|
|
1464
|
-
getState: get,
|
|
1465
|
-
setState: set,
|
|
1466
|
-
subscribe
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
// src/utils/getCookieData.ts
|
|
1471
|
-
init_cookie();
|
|
1472
|
-
var getAuthSubscriptionType = () => {
|
|
1473
|
-
return getCookie("subscriptionType");
|
|
1474
|
-
};
|
|
1475
|
-
|
|
1476
|
-
// src/store/use-table.ts
|
|
1477
|
-
var pageLimit = 10;
|
|
1478
|
-
var tableStore = createStore((set, get) => ({
|
|
1479
|
-
// ==============================
|
|
1480
|
-
// STATE
|
|
1481
|
-
// ==============================
|
|
1482
|
-
tableUniqueId: null,
|
|
1483
|
-
gridData: [],
|
|
1484
|
-
sort: "-hs_createdate",
|
|
1485
|
-
limit: 10,
|
|
1486
|
-
after: "",
|
|
1487
|
-
page: 1,
|
|
1488
|
-
totalItems: 1,
|
|
1489
|
-
numOfPages: 1,
|
|
1490
|
-
currentPage: 1,
|
|
1491
|
-
search: "",
|
|
1492
|
-
filterPropertyName: "hs_pipeline",
|
|
1493
|
-
filterOperator: "eq",
|
|
1494
|
-
filterValue: "",
|
|
1495
|
-
isPrimaryCompany: null,
|
|
1496
|
-
view: null,
|
|
1497
|
-
selectedPipeline: "",
|
|
1498
|
-
tableParam: {},
|
|
1499
|
-
tableDefPermissions: {},
|
|
1500
|
-
// ==============================
|
|
1501
|
-
// BASIC SETTERS
|
|
1502
|
-
// ==============================
|
|
1503
|
-
setTableUniqueId: (v) => set({ tableUniqueId: v }),
|
|
1504
|
-
setSort: (v) => set({ sort: v }),
|
|
1505
|
-
setLimit: (v) => set({ limit: v }),
|
|
1506
|
-
setAfter: (v) => set({ after: v }),
|
|
1507
|
-
setPage: (v) => set({ page: v }),
|
|
1508
|
-
setTotalItems: (v) => set({ totalItems: v }),
|
|
1509
|
-
setNumOfPages: (v) => set({ numOfPages: v }),
|
|
1510
|
-
setCurrentPage: (v) => set({ currentPage: v }),
|
|
1511
|
-
setSearch: (v) => set({ search: v }),
|
|
1512
|
-
setFilterPropertyName: (v) => set({ filterPropertyName: v }),
|
|
1513
|
-
setFilterOperator: (v) => set({ filterOperator: v }),
|
|
1514
|
-
setFilterValue: (v) => set({ filterValue: v }),
|
|
1515
|
-
setIsPrimaryCompany: (v) => set({ isPrimaryCompany: v }),
|
|
1516
|
-
// ==============================
|
|
1517
|
-
// VIEW
|
|
1518
|
-
// ==============================
|
|
1519
|
-
setView: (mView) => {
|
|
1520
|
-
set({
|
|
1521
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1522
|
-
view: mView
|
|
1523
|
-
});
|
|
1524
|
-
},
|
|
1525
|
-
// ==============================
|
|
1526
|
-
// PIPELINE
|
|
1527
|
-
// ==============================
|
|
1528
|
-
changePipeline: (mView) => {
|
|
1529
|
-
set({
|
|
1530
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1531
|
-
selectedPipeline: mView || ""
|
|
1532
|
-
});
|
|
1533
|
-
},
|
|
1534
|
-
setSelectedPipeline: (pipelines, pipeLineId) => {
|
|
1535
|
-
let filterValue = "";
|
|
1536
|
-
if (pipeLineId) {
|
|
1537
|
-
const pipelineSingle = pipelines.find(
|
|
1538
|
-
(pipeline) => pipeline.pipelineId === pipeLineId
|
|
1539
|
-
);
|
|
1540
|
-
filterValue = pipelineSingle?.pipelineId || "";
|
|
1541
|
-
}
|
|
1542
|
-
set({
|
|
1543
|
-
filterPropertyName: "hs_pipeline",
|
|
1544
|
-
filterOperator: "eq",
|
|
1545
|
-
filterValue,
|
|
1546
|
-
selectedPipeline: filterValue
|
|
1547
|
-
});
|
|
1548
|
-
},
|
|
1549
|
-
// ==============================
|
|
1550
|
-
// RESET
|
|
1551
|
-
// ==============================
|
|
1552
|
-
resetTableParam: () => {
|
|
1553
|
-
set({
|
|
1554
|
-
sort: "-hs_createdate",
|
|
1555
|
-
limit: pageLimit,
|
|
1556
|
-
after: "",
|
|
1557
|
-
page: getAuthSubscriptionType() === "FREE" ? "" : 1,
|
|
1558
|
-
totalItems: 1,
|
|
1559
|
-
numOfPages: 1,
|
|
1560
|
-
currentPage: 1,
|
|
1561
|
-
search: "",
|
|
1562
|
-
filterPropertyName: "hs_pipeline",
|
|
1563
|
-
filterOperator: "eq",
|
|
1564
|
-
filterValue: "",
|
|
1565
|
-
isPrimaryCompany: null,
|
|
1566
|
-
selectedPipeline: ""
|
|
1567
|
-
});
|
|
1568
|
-
},
|
|
1569
|
-
// ==============================
|
|
1570
|
-
// PARAM BUILDER
|
|
1571
|
-
// ==============================
|
|
1572
|
-
getTableParam: (companyAsMediator, currentPageOverride) => {
|
|
1573
|
-
const state = get();
|
|
1574
|
-
const baseParams = {
|
|
1575
|
-
sort: state.sort,
|
|
1576
|
-
search: state.search,
|
|
1577
|
-
filterPropertyName: state.filterPropertyName,
|
|
1578
|
-
filterOperator: state.filterOperator,
|
|
1579
|
-
filterValue: state.selectedPipeline,
|
|
1580
|
-
cache: true,
|
|
1581
|
-
isPrimaryCompany: companyAsMediator || false,
|
|
1582
|
-
view: state.view
|
|
1583
|
-
};
|
|
1584
|
-
if (getAuthSubscriptionType() === "FREE") {
|
|
1585
|
-
return {
|
|
1586
|
-
...baseParams,
|
|
1587
|
-
after: state.page
|
|
1588
|
-
};
|
|
1589
|
-
}
|
|
1590
|
-
return {
|
|
1591
|
-
...baseParams,
|
|
1592
|
-
limit: state.limit,
|
|
1593
|
-
page: currentPageOverride || state.page,
|
|
1594
|
-
...state.after && {
|
|
1595
|
-
after: state.after
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
},
|
|
1599
|
-
// ==============================
|
|
1600
|
-
// GRID DATA
|
|
1601
|
-
// ==============================
|
|
1602
|
-
setGridData: async (type, deals) => {
|
|
1603
|
-
if (type === "reset") {
|
|
1604
|
-
set({ gridData: [] });
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
if (type === "directly") {
|
|
1608
|
-
set({ gridData: deals });
|
|
1609
|
-
return;
|
|
1610
|
-
}
|
|
1611
|
-
const finalData = await deals.map(
|
|
1612
|
-
(deal) => {
|
|
1613
|
-
const cards = deal?.data?.results?.rows?.map(
|
|
1614
|
-
(row) => ({
|
|
1615
|
-
id: row?.hs_object_id,
|
|
1616
|
-
...row,
|
|
1617
|
-
hubspotObjectTypeId: type === "deals" ? "0-3" : "0-5"
|
|
1618
|
-
})
|
|
1619
|
-
) || [];
|
|
1620
|
-
return {
|
|
1621
|
-
id: deal.id,
|
|
1622
|
-
name: deal.label,
|
|
1623
|
-
count: deal?.data?.total,
|
|
1624
|
-
...deal,
|
|
1625
|
-
cards
|
|
1626
|
-
};
|
|
1627
|
-
}
|
|
1628
|
-
);
|
|
1629
|
-
await set({ gridData: finalData });
|
|
1630
|
-
return finalData;
|
|
1631
|
-
},
|
|
1632
|
-
// ==============================
|
|
1633
|
-
// DEFAULT PIPELINE
|
|
1634
|
-
// ==============================
|
|
1635
|
-
setDefaultPipeline(data, hubspotObjectTypeId) {
|
|
1636
|
-
if (!data) {
|
|
1637
|
-
set({ selectedPipeline: "" });
|
|
1638
|
-
return "";
|
|
1639
|
-
}
|
|
1640
|
-
const { updateLink, filterParams } = useUpdateLink();
|
|
1641
|
-
const params = filterParams();
|
|
1642
|
-
const excludedIds = ["0-1", "0-2", "0-3", "0-4", "0-5"];
|
|
1643
|
-
const state = get();
|
|
1644
|
-
const view = state.view;
|
|
1645
|
-
const selectedPipeline = state.selectedPipeline;
|
|
1646
|
-
let defaultPipelineId = "";
|
|
1647
|
-
let mFilterValue = "";
|
|
1648
|
-
const defaultPipeline = data?.data?.[0];
|
|
1649
|
-
if (excludedIds.includes(hubspotObjectTypeId)) {
|
|
1650
|
-
defaultPipelineId = defaultPipeline?.pipelineId || "";
|
|
1651
|
-
}
|
|
1652
|
-
if (params && params?.filterPropertyName === "hs_pipeline" && params?.filterValue) {
|
|
1653
|
-
mFilterValue = params.filterValue;
|
|
1654
|
-
} else {
|
|
1655
|
-
if (view === "BOARD" && !selectedPipeline) {
|
|
1656
|
-
mFilterValue = defaultPipelineId;
|
|
1657
|
-
updateLink({
|
|
1658
|
-
fV: defaultPipelineId
|
|
1659
|
-
});
|
|
1660
|
-
} else if (!excludedIds.includes(hubspotObjectTypeId)) {
|
|
1661
|
-
mFilterValue = selectedPipeline || null;
|
|
1662
|
-
} else {
|
|
1663
|
-
mFilterValue = data.data.length === 1 ? defaultPipelineId : selectedPipeline;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
set({ selectedPipeline: mFilterValue });
|
|
1667
|
-
return mFilterValue;
|
|
1668
|
-
}
|
|
1669
|
-
}));
|
|
1670
|
-
function useTable() {
|
|
1671
|
-
const tableState = tableStore.getState();
|
|
1672
|
-
return {
|
|
1673
|
-
...tableState,
|
|
1674
|
-
...{ listeners: { subscribe: tableStore.subscribe } }
|
|
1675
|
-
};
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
1059
|
// src/apis/pipeline.ts
|
|
1679
1060
|
function list(options) {
|
|
1680
1061
|
const {
|
|
@@ -1713,13 +1094,14 @@ function list2(options) {
|
|
|
1713
1094
|
|
|
1714
1095
|
// src/apis/object.ts
|
|
1715
1096
|
function list3(options) {
|
|
1716
|
-
const {
|
|
1717
|
-
|
|
1718
|
-
} = useTable();
|
|
1097
|
+
const { getTableParam } = useTable();
|
|
1098
|
+
const { setObjectsData, setTableData } = actions;
|
|
1719
1099
|
const { mutate, isLoading } = createMutation(
|
|
1720
1100
|
async (payload) => {
|
|
1721
1101
|
const param = await getTableParam(payload?.companyAsMediator);
|
|
1722
1102
|
const response = await Client.object.list(payload, param);
|
|
1103
|
+
await setObjectsData(response);
|
|
1104
|
+
await setTableData(response, payload);
|
|
1723
1105
|
return response;
|
|
1724
1106
|
},
|
|
1725
1107
|
options
|
|
@@ -1773,9 +1155,16 @@ function objectFormOptions(options) {
|
|
|
1773
1155
|
};
|
|
1774
1156
|
}
|
|
1775
1157
|
function create(options) {
|
|
1158
|
+
const { setTablePrependData } = actions;
|
|
1776
1159
|
const { mutate, isLoading } = createMutation(
|
|
1777
1160
|
async (props) => {
|
|
1161
|
+
if (props?.componentName != "association") await setTablePrependData("loading", props);
|
|
1778
1162
|
const response = await Client.object.create(props);
|
|
1163
|
+
console.log(
|
|
1164
|
+
"props",
|
|
1165
|
+
props
|
|
1166
|
+
);
|
|
1167
|
+
if (props?.componentName != "association") await setTablePrependData(response, props);
|
|
1779
1168
|
return response;
|
|
1780
1169
|
},
|
|
1781
1170
|
options
|
|
@@ -1845,9 +1234,11 @@ function update(options) {
|
|
|
1845
1234
|
|
|
1846
1235
|
// src/apis/note.ts
|
|
1847
1236
|
function list4(options) {
|
|
1237
|
+
const { setNotes } = actions2;
|
|
1848
1238
|
const { mutate, isLoading } = createMutation(
|
|
1849
1239
|
async (payload) => {
|
|
1850
1240
|
const response = await Client.note.list(payload);
|
|
1241
|
+
setNotes(response, payload);
|
|
1851
1242
|
return response;
|
|
1852
1243
|
},
|
|
1853
1244
|
options
|
|
@@ -1859,9 +1250,12 @@ function list4(options) {
|
|
|
1859
1250
|
};
|
|
1860
1251
|
}
|
|
1861
1252
|
function create2(options) {
|
|
1253
|
+
const { setPrependNote } = actions2;
|
|
1862
1254
|
const { mutate, isLoading } = createMutation(
|
|
1863
1255
|
async (props) => {
|
|
1256
|
+
await setPrependNote("loading");
|
|
1864
1257
|
const response = await Client.note.create(props);
|
|
1258
|
+
await setPrependNote(response);
|
|
1865
1259
|
return response;
|
|
1866
1260
|
},
|
|
1867
1261
|
options
|
|
@@ -1873,9 +1267,11 @@ function create2(options) {
|
|
|
1873
1267
|
};
|
|
1874
1268
|
}
|
|
1875
1269
|
function update2(options) {
|
|
1270
|
+
const { updatePrependNote } = actions2;
|
|
1876
1271
|
const { mutate, isLoading } = createMutation(
|
|
1877
1272
|
async (payload) => {
|
|
1878
1273
|
const response = await Client.note.update(payload);
|
|
1274
|
+
updatePrependNote(response);
|
|
1879
1275
|
return response;
|
|
1880
1276
|
},
|
|
1881
1277
|
options
|
|
@@ -1889,9 +1285,11 @@ function update2(options) {
|
|
|
1889
1285
|
|
|
1890
1286
|
// src/apis/email.ts
|
|
1891
1287
|
function list5(options) {
|
|
1288
|
+
const { setEmails } = actions3;
|
|
1892
1289
|
const { mutate, isLoading } = createMutation(
|
|
1893
1290
|
async (payload) => {
|
|
1894
1291
|
const response = await Client.email.list(payload);
|
|
1292
|
+
setEmails(response, payload);
|
|
1895
1293
|
return response;
|
|
1896
1294
|
},
|
|
1897
1295
|
options
|
|
@@ -1903,9 +1301,12 @@ function list5(options) {
|
|
|
1903
1301
|
};
|
|
1904
1302
|
}
|
|
1905
1303
|
function create3(options) {
|
|
1304
|
+
const { setPrependEmail } = actions3;
|
|
1906
1305
|
const { mutate, isLoading } = createMutation(
|
|
1907
1306
|
async (props) => {
|
|
1307
|
+
await setPrependEmail("loading");
|
|
1908
1308
|
const response = await Client.email.create(props);
|
|
1309
|
+
await setPrependEmail(response);
|
|
1909
1310
|
return response;
|
|
1910
1311
|
},
|
|
1911
1312
|
options
|
|
@@ -1917,9 +1318,11 @@ function create3(options) {
|
|
|
1917
1318
|
};
|
|
1918
1319
|
}
|
|
1919
1320
|
function update3(options) {
|
|
1321
|
+
const { updatePrependEmail } = actions3;
|
|
1920
1322
|
const { mutate, isLoading } = createMutation(
|
|
1921
1323
|
async (payload) => {
|
|
1922
1324
|
const response = await Client.email.update(payload);
|
|
1325
|
+
updatePrependEmail(response);
|
|
1923
1326
|
return response;
|
|
1924
1327
|
},
|
|
1925
1328
|
options
|
|
@@ -2019,10 +1422,31 @@ function addFile(options) {
|
|
|
2019
1422
|
};
|
|
2020
1423
|
}
|
|
2021
1424
|
|
|
2022
|
-
// src/
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1425
|
+
// src/apis/cache.ts
|
|
1426
|
+
function purge(options) {
|
|
1427
|
+
const { mutate, isLoading } = createMutation(
|
|
1428
|
+
async (payload) => {
|
|
1429
|
+
const safePayload = payload ?? {};
|
|
1430
|
+
const idempotencyKey = typeof safePayload.idempotencyKey === "string" ? safePayload.idempotencyKey : void 0;
|
|
1431
|
+
const headers = idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0;
|
|
1432
|
+
const { idempotencyKey: _ignored, ...body } = safePayload;
|
|
1433
|
+
return Client.cache.purge(body, headers);
|
|
1434
|
+
},
|
|
1435
|
+
options
|
|
1436
|
+
);
|
|
1437
|
+
return { mutate, purgeCache: mutate, isLoading };
|
|
1438
|
+
}
|
|
1439
|
+
function purgeStatus(purgeJobId, options) {
|
|
1440
|
+
const { mutate, isLoading } = createMutation(
|
|
1441
|
+
async (jobId) => Client.cache.purgeStatus(jobId ?? purgeJobId),
|
|
1442
|
+
options
|
|
1443
|
+
);
|
|
1444
|
+
return {
|
|
1445
|
+
mutate,
|
|
1446
|
+
getPurgeStatus: () => mutate(purgeJobId),
|
|
1447
|
+
isLoading
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
2026
1450
|
|
|
2027
1451
|
// src/breadcrumb/breadcrumbs.ts
|
|
2028
1452
|
var getBreadcrumbs = () => {
|
|
@@ -2230,6 +1654,66 @@ var buildChildRoute = (props, breadcrumbItems) => {
|
|
|
2230
1654
|
return generateUrl(props, breadcrumbs);
|
|
2231
1655
|
};
|
|
2232
1656
|
|
|
1657
|
+
// src/utils/datetime.ts
|
|
1658
|
+
var DEFAULT_HUBSPOT_TIMEZONE = "Asia/Kolkata";
|
|
1659
|
+
function getCurrentTimeZone() {
|
|
1660
|
+
try {
|
|
1661
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || DEFAULT_HUBSPOT_TIMEZONE;
|
|
1662
|
+
} catch {
|
|
1663
|
+
return DEFAULT_HUBSPOT_TIMEZONE;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function normalizeToTimestamp(value) {
|
|
1667
|
+
if (value == null || value === "") return null;
|
|
1668
|
+
if (typeof value === "number") {
|
|
1669
|
+
return value > 1e11 ? value : null;
|
|
1670
|
+
}
|
|
1671
|
+
if (typeof value === "string" && /^\d+$/.test(value)) {
|
|
1672
|
+
const n = Number(value);
|
|
1673
|
+
return n > 1e11 ? n : null;
|
|
1674
|
+
}
|
|
1675
|
+
if (typeof value === "string" || value instanceof Date) {
|
|
1676
|
+
const date = new Date(value);
|
|
1677
|
+
return Number.isNaN(date.getTime()) ? null : date.getTime();
|
|
1678
|
+
}
|
|
1679
|
+
return null;
|
|
1680
|
+
}
|
|
1681
|
+
function formatGmtOffset(timeZone = getCurrentTimeZone(), date = /* @__PURE__ */ new Date()) {
|
|
1682
|
+
const raw = new Intl.DateTimeFormat("en-US", {
|
|
1683
|
+
timeZone,
|
|
1684
|
+
timeZoneName: "longOffset"
|
|
1685
|
+
}).formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
|
|
1686
|
+
if (!raw) return "";
|
|
1687
|
+
return raw.replace(/GMT([+-])0(\d)(?=:)/, "GMT$1$2");
|
|
1688
|
+
}
|
|
1689
|
+
function formatHubSpotActivityDateTimeParts(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1690
|
+
const ms = normalizeToTimestamp(timestamp);
|
|
1691
|
+
if (ms == null) return null;
|
|
1692
|
+
const date = new Date(ms);
|
|
1693
|
+
const datePart = new Intl.DateTimeFormat("en-US", {
|
|
1694
|
+
timeZone,
|
|
1695
|
+
month: "long",
|
|
1696
|
+
day: "numeric",
|
|
1697
|
+
year: "numeric"
|
|
1698
|
+
}).format(date);
|
|
1699
|
+
const timePart = new Intl.DateTimeFormat("en-US", {
|
|
1700
|
+
timeZone,
|
|
1701
|
+
hour: "numeric",
|
|
1702
|
+
minute: "2-digit",
|
|
1703
|
+
hour12: true
|
|
1704
|
+
}).format(date);
|
|
1705
|
+
const gmtOffset = formatGmtOffset(timeZone, date);
|
|
1706
|
+
return {
|
|
1707
|
+
date: datePart,
|
|
1708
|
+
time: timePart,
|
|
1709
|
+
gmtOffset,
|
|
1710
|
+
formatted: `${datePart} at ${timePart} ${gmtOffset}`.trim()
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
function formatHubSpotActivityDateTime(timestamp, timeZone = getCurrentTimeZone()) {
|
|
1714
|
+
return formatHubSpotActivityDateTimeParts(timestamp, timeZone)?.formatted ?? "";
|
|
1715
|
+
}
|
|
1716
|
+
|
|
2233
1717
|
// src/index.ts
|
|
2234
1718
|
var api = {
|
|
2235
1719
|
preLogin,
|
|
@@ -2271,6 +1755,8 @@ var api = {
|
|
|
2271
1755
|
file: details2,
|
|
2272
1756
|
addFolder,
|
|
2273
1757
|
addFile,
|
|
1758
|
+
purgeCache: purge,
|
|
1759
|
+
cachePurgeStatus: purgeStatus,
|
|
2274
1760
|
getRefreshToken,
|
|
2275
1761
|
getAuthRefreshToken,
|
|
2276
1762
|
isCookieExpired,
|
|
@@ -2296,6 +1782,6 @@ var routeParam = {
|
|
|
2296
1782
|
getParamDetails
|
|
2297
1783
|
};
|
|
2298
1784
|
|
|
2299
|
-
export { api, breadcrumbsDetails, getFieldErrors, getFormErrors, initializeHttpClient, routeParam, store, url };
|
|
1785
|
+
export { DEFAULT_HUBSPOT_TIMEZONE, api, breadcrumbsDetails, client_exports as clint, formatGmtOffset, formatHubSpotActivityDateTime, formatHubSpotActivityDateTimeParts, getCurrentTimeZone, getFieldErrors, getFormErrors, initializeHttpClient, normalizeToTimestamp, routeParam, store, url };
|
|
2300
1786
|
//# sourceMappingURL=index.js.map
|
|
2301
1787
|
//# sourceMappingURL=index.js.map
|