woodsportal-client-sdk 1.1.4-dev.1 → 1.1.4-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -2
- package/dist/index.js +266 -118
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,13 +3,18 @@ import axios from 'axios';
|
|
|
3
3
|
import pako from 'pako';
|
|
4
4
|
import { Base64 } from 'js-base64';
|
|
5
5
|
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
6
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __esm = (fn, res) => function __init() {
|
|
8
9
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
10
|
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
10
15
|
|
|
11
16
|
// src/utils/constants.ts
|
|
12
|
-
var LOGIN_DETAILS, REFRESH_TOKEN, PORTAL, SUBSCRIPTION_TYPE, HUBSPOT_DATA, HUB_ID, DEV_PORTAL_ID;
|
|
17
|
+
var LOGIN_DETAILS, REFRESH_TOKEN, PORTAL, SUBSCRIPTION_TYPE, HUBSPOT_DATA, HUB_ID, DEV_PORTAL_ID, PORTAL_ID, DEV_API_URL;
|
|
13
18
|
var init_constants = __esm({
|
|
14
19
|
"src/utils/constants.ts"() {
|
|
15
20
|
LOGIN_DETAILS = "loginDetails";
|
|
@@ -19,6 +24,8 @@ var init_constants = __esm({
|
|
|
19
24
|
HUBSPOT_DATA = "hubSpotData";
|
|
20
25
|
HUB_ID = "hubId";
|
|
21
26
|
DEV_PORTAL_ID = "devPortalId";
|
|
27
|
+
PORTAL_ID = "portalId";
|
|
28
|
+
DEV_API_URL = "devApiUrl";
|
|
22
29
|
}
|
|
23
30
|
});
|
|
24
31
|
var setCookie, getCookie, removeAllCookie, isCookieExpired;
|
|
@@ -51,43 +58,19 @@ var init_cookie = __esm({
|
|
|
51
58
|
}
|
|
52
59
|
});
|
|
53
60
|
|
|
54
|
-
// src/clint/token-store.ts
|
|
55
|
-
function getAccessToken() {
|
|
56
|
-
return accessToken;
|
|
57
|
-
}
|
|
58
|
-
function storAccessToken(token, expiresIn) {
|
|
59
|
-
accessToken = token;
|
|
60
|
-
if (expiresIn) {
|
|
61
|
-
tokenExpiresAt = Date.now() + expiresIn * 1e3;
|
|
62
|
-
} else {
|
|
63
|
-
tokenExpiresAt = null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function clearAccessToken() {
|
|
67
|
-
accessToken = null;
|
|
68
|
-
tokenExpiresAt = null;
|
|
69
|
-
}
|
|
70
|
-
function isExpiresAccessToken() {
|
|
71
|
-
if (!tokenExpiresAt) return true;
|
|
72
|
-
return Date.now() >= tokenExpiresAt;
|
|
73
|
-
}
|
|
74
|
-
function isAuthenticateApp() {
|
|
75
|
-
if (isCookieExpired(REFRESH_TOKEN) || isExpiresAccessToken()) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
var accessToken, tokenExpiresAt;
|
|
81
|
-
var init_token_store = __esm({
|
|
82
|
-
"src/clint/token-store.ts"() {
|
|
83
|
-
init_cookie();
|
|
84
|
-
init_constants();
|
|
85
|
-
accessToken = null;
|
|
86
|
-
tokenExpiresAt = null;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
61
|
// src/clint/auth-utils.ts
|
|
62
|
+
var auth_utils_exports = {};
|
|
63
|
+
__export(auth_utils_exports, {
|
|
64
|
+
getPortal: () => getPortal,
|
|
65
|
+
getProfile: () => getProfile,
|
|
66
|
+
getRefreshToken: () => getRefreshToken,
|
|
67
|
+
getSubscriptionType: () => getSubscriptionType,
|
|
68
|
+
setAccessToken: () => setAccessToken,
|
|
69
|
+
setLoggedInDetails: () => setLoggedInDetails,
|
|
70
|
+
setPortal: () => setPortal,
|
|
71
|
+
setRefreshToken: () => setRefreshToken,
|
|
72
|
+
setSubscriptionType: () => setSubscriptionType
|
|
73
|
+
});
|
|
91
74
|
function setRefreshToken(token, expiresAt) {
|
|
92
75
|
return new Promise((resolve) => {
|
|
93
76
|
setCookie(REFRESH_TOKEN, JSON.stringify(token), expiresAt);
|
|
@@ -100,12 +83,18 @@ function setAccessToken(token, expiresIn) {
|
|
|
100
83
|
resolve();
|
|
101
84
|
});
|
|
102
85
|
}
|
|
86
|
+
function getProfile() {
|
|
87
|
+
return JSON.parse(getCookie(LOGIN_DETAILS || null) || null);
|
|
88
|
+
}
|
|
103
89
|
function getRefreshToken() {
|
|
104
90
|
return JSON.parse(getCookie(REFRESH_TOKEN || null) || null);
|
|
105
91
|
}
|
|
106
92
|
function getPortal() {
|
|
107
93
|
return JSON.parse(getCookie(PORTAL || null) || null);
|
|
108
94
|
}
|
|
95
|
+
function getSubscriptionType() {
|
|
96
|
+
return JSON.parse(getCookie(SUBSCRIPTION_TYPE || null) || null);
|
|
97
|
+
}
|
|
109
98
|
var setLoggedInDetails, setPortal, setSubscriptionType;
|
|
110
99
|
var init_auth_utils = __esm({
|
|
111
100
|
"src/clint/auth-utils.ts"() {
|
|
@@ -133,20 +122,98 @@ var init_auth_utils = __esm({
|
|
|
133
122
|
}
|
|
134
123
|
});
|
|
135
124
|
|
|
125
|
+
// src/clint/token-store.ts
|
|
126
|
+
function getAccessToken() {
|
|
127
|
+
return accessToken;
|
|
128
|
+
}
|
|
129
|
+
function storAccessToken(token, expiresIn) {
|
|
130
|
+
accessToken = token;
|
|
131
|
+
if (expiresIn) {
|
|
132
|
+
tokenExpiresAt = Date.now() + expiresIn * 1e3;
|
|
133
|
+
} else {
|
|
134
|
+
tokenExpiresAt = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function clearAccessToken() {
|
|
138
|
+
accessToken = null;
|
|
139
|
+
tokenExpiresAt = null;
|
|
140
|
+
}
|
|
141
|
+
function isExpiresAccessToken() {
|
|
142
|
+
if (!tokenExpiresAt) return true;
|
|
143
|
+
return Date.now() >= tokenExpiresAt;
|
|
144
|
+
}
|
|
145
|
+
function setRefreshCallback(callback) {
|
|
146
|
+
refreshCallback = callback;
|
|
147
|
+
}
|
|
148
|
+
async function ensureValidRefresh() {
|
|
149
|
+
if (isExpiresAccessToken() && refreshCallback) {
|
|
150
|
+
const { getRefreshToken: getRefreshToken2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
151
|
+
const refreshToken = getRefreshToken2();
|
|
152
|
+
if (refreshToken) {
|
|
153
|
+
await refreshCallback(refreshToken);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function isAuthenticateApp() {
|
|
158
|
+
if (isCookieExpired(REFRESH_TOKEN) || isExpiresAccessToken()) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
var accessToken, tokenExpiresAt, refreshCallback;
|
|
164
|
+
var init_token_store = __esm({
|
|
165
|
+
"src/clint/token-store.ts"() {
|
|
166
|
+
init_cookie();
|
|
167
|
+
init_constants();
|
|
168
|
+
accessToken = null;
|
|
169
|
+
tokenExpiresAt = null;
|
|
170
|
+
refreshCallback = null;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
136
174
|
// src/utils/config.ts
|
|
137
175
|
init_constants();
|
|
138
176
|
|
|
139
177
|
// src/utils/localStoraget.ts
|
|
178
|
+
var memory = /* @__PURE__ */ new Map();
|
|
179
|
+
var memoryStore = {
|
|
180
|
+
getItem(key) {
|
|
181
|
+
return memory.has(key) ? memory.get(key) : null;
|
|
182
|
+
},
|
|
183
|
+
setItem(key, value) {
|
|
184
|
+
memory.set(key, value);
|
|
185
|
+
},
|
|
186
|
+
removeItem(key) {
|
|
187
|
+
memory.delete(key);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
function resolveStore() {
|
|
191
|
+
if (typeof globalThis === "undefined") {
|
|
192
|
+
return memoryStore;
|
|
193
|
+
}
|
|
194
|
+
const ls = globalThis.localStorage;
|
|
195
|
+
if (!ls || typeof ls.getItem !== "function") {
|
|
196
|
+
return memoryStore;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
const probeKey = "__woodsportal_client_sdk_ls_probe__";
|
|
200
|
+
ls.setItem(probeKey, "1");
|
|
201
|
+
ls.removeItem(probeKey);
|
|
202
|
+
return ls;
|
|
203
|
+
} catch {
|
|
204
|
+
return memoryStore;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
140
207
|
var storage = {
|
|
141
208
|
set: (key, value) => {
|
|
142
|
-
|
|
209
|
+
resolveStore().setItem(key, JSON.stringify(value));
|
|
143
210
|
},
|
|
144
211
|
get: (key) => {
|
|
145
|
-
const item =
|
|
212
|
+
const item = resolveStore().getItem(key);
|
|
146
213
|
return item ? JSON.parse(item) : null;
|
|
147
214
|
},
|
|
148
215
|
remove: (key) => {
|
|
149
|
-
|
|
216
|
+
resolveStore().removeItem(key);
|
|
150
217
|
}
|
|
151
218
|
};
|
|
152
219
|
|
|
@@ -159,6 +226,23 @@ var config = {
|
|
|
159
226
|
get devPortalId() {
|
|
160
227
|
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
161
228
|
return hubSpotData?.[DEV_PORTAL_ID] || "";
|
|
229
|
+
},
|
|
230
|
+
get portalId() {
|
|
231
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
232
|
+
return hubSpotData?.[PORTAL_ID] || "";
|
|
233
|
+
},
|
|
234
|
+
get devApiUrl() {
|
|
235
|
+
const hubSpotData = storage.get(HUBSPOT_DATA);
|
|
236
|
+
return hubSpotData?.[DEV_API_URL] || "";
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
var setConfig = {
|
|
240
|
+
setDevPortalId(portalId) {
|
|
241
|
+
const existing = storage.get(HUBSPOT_DATA) || {};
|
|
242
|
+
storage.set(HUBSPOT_DATA, {
|
|
243
|
+
...existing,
|
|
244
|
+
[PORTAL_ID]: portalId
|
|
245
|
+
});
|
|
162
246
|
}
|
|
163
247
|
};
|
|
164
248
|
|
|
@@ -170,7 +254,7 @@ var generateApiUrl = ({
|
|
|
170
254
|
}) => {
|
|
171
255
|
const defaultParams = {
|
|
172
256
|
hubId: config.hubId,
|
|
173
|
-
portalId: config.
|
|
257
|
+
portalId: config.portalId
|
|
174
258
|
};
|
|
175
259
|
params = { ...defaultParams, ...params };
|
|
176
260
|
const url2 = replaceParams(route, params);
|
|
@@ -254,7 +338,7 @@ var axiosInstance = null;
|
|
|
254
338
|
var config3 = {};
|
|
255
339
|
function initializeHttpClient(clientConfig) {
|
|
256
340
|
config3 = clientConfig;
|
|
257
|
-
const baseURL =
|
|
341
|
+
const baseURL = config?.devApiUrl || config3.baseURL;
|
|
258
342
|
const timeout = config3.timeout ?? 5e4;
|
|
259
343
|
axiosInstance = axios.create({
|
|
260
344
|
baseURL,
|
|
@@ -264,6 +348,7 @@ function initializeHttpClient(clientConfig) {
|
|
|
264
348
|
...config3.headers
|
|
265
349
|
}
|
|
266
350
|
});
|
|
351
|
+
setRefreshCallback(getAuthRefreshToken);
|
|
267
352
|
axiosInstance.interceptors.request.use((config4) => {
|
|
268
353
|
const token = getAccessToken();
|
|
269
354
|
if (token) {
|
|
@@ -290,6 +375,44 @@ function getAxiosInstance() {
|
|
|
290
375
|
}
|
|
291
376
|
return axiosInstance;
|
|
292
377
|
}
|
|
378
|
+
function formatBooleanSearchParam(key, value) {
|
|
379
|
+
return value ? `${key}:1` : `${key}:`;
|
|
380
|
+
}
|
|
381
|
+
var HttpClient = class {
|
|
382
|
+
static async get(url2, params) {
|
|
383
|
+
await ensureValidRefresh();
|
|
384
|
+
const response = await getAxiosInstance().get(url2, { params });
|
|
385
|
+
return response.data;
|
|
386
|
+
}
|
|
387
|
+
static async post(url2, data, options) {
|
|
388
|
+
await ensureValidRefresh();
|
|
389
|
+
const response = await getAxiosInstance().post(url2, data, options);
|
|
390
|
+
return response.data;
|
|
391
|
+
}
|
|
392
|
+
static async put(url2, data) {
|
|
393
|
+
await ensureValidRefresh();
|
|
394
|
+
const response = await getAxiosInstance().put(url2, data);
|
|
395
|
+
return response.data;
|
|
396
|
+
}
|
|
397
|
+
static async delete(url2) {
|
|
398
|
+
await ensureValidRefresh();
|
|
399
|
+
const response = await getAxiosInstance().delete(url2);
|
|
400
|
+
return response.data;
|
|
401
|
+
}
|
|
402
|
+
static formatSearchParams(params) {
|
|
403
|
+
return Object.entries(params).filter(([, value]) => Boolean(value)).map(
|
|
404
|
+
([k, v]) => [
|
|
405
|
+
"type",
|
|
406
|
+
"categories",
|
|
407
|
+
"tags",
|
|
408
|
+
"author",
|
|
409
|
+
"manufacturer",
|
|
410
|
+
"shops",
|
|
411
|
+
"refund_reason"
|
|
412
|
+
].includes(k) ? `${k}.slug:${v}` : ["is_approved"].includes(k) ? formatBooleanSearchParam(k, v) : `${k}:${v}`
|
|
413
|
+
).join(";");
|
|
414
|
+
}
|
|
415
|
+
};
|
|
293
416
|
var AuthHttpClient = class {
|
|
294
417
|
static async get(url2, params) {
|
|
295
418
|
const response = await getAxiosInstance().get(url2, { params });
|
|
@@ -606,14 +729,11 @@ var getParamDetails = (props, isDetailsPage = false) => {
|
|
|
606
729
|
};
|
|
607
730
|
};
|
|
608
731
|
|
|
609
|
-
// src/clint/index.ts
|
|
610
|
-
init_auth_utils();
|
|
611
|
-
|
|
612
732
|
// src/breadcrumb/url.ts
|
|
613
733
|
var useUpdateLink = () => {
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
734
|
+
const updateLink = async (props, displayName = "prm") => {
|
|
735
|
+
const search = getParam("b");
|
|
736
|
+
const pathname = getPath();
|
|
617
737
|
let breadcrumbs = decodeToBase64(search) || [];
|
|
618
738
|
if (breadcrumbs.length < 1) {
|
|
619
739
|
const routeMenu = getRouteMenu(pathname);
|
|
@@ -626,12 +746,13 @@ var useUpdateLink = () => {
|
|
|
626
746
|
}
|
|
627
747
|
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
628
748
|
if (displayName) {
|
|
629
|
-
|
|
630
|
-
|
|
749
|
+
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
750
|
+
await setDeep(lastBreadcrumb, displayName, {
|
|
751
|
+
...ex,
|
|
631
752
|
...props
|
|
632
753
|
});
|
|
633
754
|
} else {
|
|
634
|
-
Object.assign(lastBreadcrumb, props);
|
|
755
|
+
await Object.assign(lastBreadcrumb, props);
|
|
635
756
|
}
|
|
636
757
|
const newBase64 = convertToBase64(breadcrumbs);
|
|
637
758
|
updateBParam(newBase64);
|
|
@@ -646,11 +767,13 @@ var useUpdateLink = () => {
|
|
|
646
767
|
curr = curr[keys[i]];
|
|
647
768
|
}
|
|
648
769
|
curr[keys[keys.length - 1]] = value;
|
|
770
|
+
return curr;
|
|
649
771
|
}
|
|
650
772
|
function getDeep(obj, path) {
|
|
651
773
|
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
652
774
|
}
|
|
653
775
|
const getLinkParams = (displayName = "prm") => {
|
|
776
|
+
const search = getParam("b");
|
|
654
777
|
let breadcrumbs = decodeToBase64(search) || [];
|
|
655
778
|
if (breadcrumbs.length < 1) return null;
|
|
656
779
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
@@ -671,6 +794,7 @@ var useUpdateLink = () => {
|
|
|
671
794
|
return output;
|
|
672
795
|
};
|
|
673
796
|
const filterParams = (displayName = "prm") => {
|
|
797
|
+
const search = getParam("b");
|
|
674
798
|
let breadcrumbs = decodeToBase64(search) || [];
|
|
675
799
|
if (breadcrumbs.length < 1) return null;
|
|
676
800
|
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
@@ -726,10 +850,10 @@ var Client = {
|
|
|
726
850
|
resetPasswordVerifyToken: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD_VERIFY_TOKEN, data),
|
|
727
851
|
resetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.RESET_PASSWORD, data),
|
|
728
852
|
forgetPassword: (data) => AuthHttpClient.post(API_ENDPOINTS.FORGET_PASSWORD, data),
|
|
729
|
-
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data),
|
|
853
|
+
registerExistingUser: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data?.payload),
|
|
730
854
|
verifyEmailResend: (data) => AuthHttpClient.post(API_ENDPOINTS.REGISTER_EXISTING_USER, data),
|
|
731
855
|
resendEmail: (data) => AuthHttpClient.post(API_ENDPOINTS.RESEND_EMAIL, data),
|
|
732
|
-
logout: () =>
|
|
856
|
+
logout: () => HttpClient.post(API_ENDPOINTS.LOGOUT, null)
|
|
733
857
|
},
|
|
734
858
|
sso: {
|
|
735
859
|
getSsoDetails: () => AuthHttpClient.get(API_ENDPOINTS.SSO_DETAILS),
|
|
@@ -737,9 +861,9 @@ var Client = {
|
|
|
737
861
|
ssoCallback: (payload) => AuthHttpClient.get(generateApiUrl({ route: API_ENDPOINTS.SSO_CALLBACK, queryParams: payload?.queryParams }))
|
|
738
862
|
},
|
|
739
863
|
user: {
|
|
740
|
-
me: () =>
|
|
741
|
-
profile: (payload) =>
|
|
742
|
-
changePassword: (data) =>
|
|
864
|
+
me: () => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.ME })),
|
|
865
|
+
profile: (payload) => HttpClient.get(generateApiUrl({ route: API_ENDPOINTS.PROFILE, queryParams: payload })),
|
|
866
|
+
changePassword: (data) => HttpClient.post(API_ENDPOINTS.CHANGE_PASSWORD, data)
|
|
743
867
|
},
|
|
744
868
|
pipeline: {
|
|
745
869
|
list: (payload = null, param = null) => {
|
|
@@ -756,26 +880,27 @@ var Client = {
|
|
|
756
880
|
apiParams.parentObjectTypeId = "0-2";
|
|
757
881
|
}
|
|
758
882
|
apiParams.isPrimaryCompany = param?.isPrimaryCompany;
|
|
759
|
-
apiParams.cache = payload?.
|
|
883
|
+
apiParams.cache = payload?.cache;
|
|
884
|
+
console.log("payload", payload);
|
|
760
885
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.PIPELINES, params, queryParams: apiParams });
|
|
761
|
-
return
|
|
886
|
+
return HttpClient.get(apiUrl);
|
|
762
887
|
}
|
|
763
888
|
},
|
|
764
889
|
stage: {
|
|
765
890
|
list: (props = null) => {
|
|
766
|
-
const portalId = config.devPortalId;
|
|
767
891
|
const params = {
|
|
768
|
-
hubId: config.hubId,
|
|
769
|
-
portalId,
|
|
892
|
+
// hubId: config.hubId,
|
|
893
|
+
// portalId: portalId,
|
|
770
894
|
objectTypeId: props?.params?.objectTypeId,
|
|
771
895
|
pipelineId: props?.params?.pipelineId
|
|
772
896
|
};
|
|
773
897
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.STAGES, params });
|
|
774
|
-
return
|
|
898
|
+
return HttpClient.get(apiUrl);
|
|
775
899
|
}
|
|
776
900
|
},
|
|
777
901
|
object: {
|
|
778
|
-
list: (payload = null, param = null) => {
|
|
902
|
+
list: async (payload = null, param = null) => {
|
|
903
|
+
param.cache = payload.cache;
|
|
779
904
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
780
905
|
const { updateLink, getLinkParams } = useUpdateLink();
|
|
781
906
|
const { getParamDetails: getParamDetails2 } = routeParam;
|
|
@@ -794,7 +919,7 @@ var Client = {
|
|
|
794
919
|
const fParams = getLinkParams();
|
|
795
920
|
param = { ...payload?.isFristTimeLoadData && fParams && !payload?.isHome ? fParams : param, ...paramsObject };
|
|
796
921
|
if (!payload?.isFristTimeLoadData || !fParams) {
|
|
797
|
-
updateLink({
|
|
922
|
+
await updateLink({
|
|
798
923
|
"sort": param?.sort,
|
|
799
924
|
"s": param?.search,
|
|
800
925
|
"fPn": param?.filterPropertyName,
|
|
@@ -810,13 +935,13 @@ var Client = {
|
|
|
810
935
|
}
|
|
811
936
|
if (mPipelines != void 0 && mPipelines?.length === 0 && !payload?.specPipeLine) {
|
|
812
937
|
param.filterValue = "";
|
|
813
|
-
updateLink({
|
|
938
|
+
await updateLink({
|
|
814
939
|
"fV": param?.filterValue
|
|
815
940
|
});
|
|
816
941
|
}
|
|
817
942
|
if (mPipelines != void 0 && mPipelines?.length === 1 && !payload?.specPipeLine && mSelectedPipeline != null) {
|
|
818
943
|
param.filterValue = mPipelines[0].pipelineId;
|
|
819
|
-
updateLink({
|
|
944
|
+
await updateLink({
|
|
820
945
|
"fV": param?.filterValue
|
|
821
946
|
});
|
|
822
947
|
}
|
|
@@ -831,45 +956,57 @@ var Client = {
|
|
|
831
956
|
}
|
|
832
957
|
param.parentAccessLabel = parentAccessLabel;
|
|
833
958
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams: param });
|
|
834
|
-
return
|
|
959
|
+
return HttpClient.get(apiUrl);
|
|
960
|
+
},
|
|
961
|
+
sideBarList: async (payload = null) => {
|
|
962
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
963
|
+
const params = { hubspotObjectTypeId };
|
|
964
|
+
const queryParams = payload.param;
|
|
965
|
+
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS, params, queryParams });
|
|
966
|
+
return HttpClient.get(apiUrl);
|
|
835
967
|
},
|
|
836
968
|
form: (payload = null) => {
|
|
837
969
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
838
970
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE, params, queryParams: payload?.params });
|
|
839
|
-
return
|
|
971
|
+
return HttpClient.get(apiUrl);
|
|
840
972
|
},
|
|
841
973
|
objectFormOptions: (payload = null) => {
|
|
842
974
|
const params = { hubspotObjectTypeId: payload?.hubspotObjectTypeId };
|
|
843
975
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_FORM_OPTIONS, params, queryParams: payload?.params });
|
|
844
|
-
return
|
|
976
|
+
return HttpClient.get(apiUrl);
|
|
845
977
|
},
|
|
846
978
|
create: (props = null) => {
|
|
979
|
+
const { getLinkParams } = useUpdateLink();
|
|
980
|
+
const fParams = getLinkParams();
|
|
981
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
847
982
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
848
|
-
const queryParams = props.params;
|
|
849
983
|
const payload = props.payload;
|
|
850
984
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE, params, queryParams });
|
|
851
|
-
return
|
|
985
|
+
return HttpClient.post(apiUrl, payload);
|
|
852
986
|
},
|
|
853
987
|
createExisting: (props = null) => {
|
|
988
|
+
const { getLinkParams } = useUpdateLink();
|
|
989
|
+
const fParams = getLinkParams();
|
|
990
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
854
991
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
855
|
-
const queryParams = props.params;
|
|
856
992
|
const payload = props.payload;
|
|
857
993
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_CREATE_EXISTING, params, queryParams });
|
|
858
|
-
return
|
|
994
|
+
return HttpClient.post(apiUrl, payload);
|
|
859
995
|
},
|
|
860
996
|
removeExisting: (props = null) => {
|
|
997
|
+
const { getLinkParams } = useUpdateLink();
|
|
998
|
+
const fParams = getLinkParams();
|
|
999
|
+
const queryParams = { ...fParams, ...props?.params };
|
|
861
1000
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId };
|
|
862
|
-
const queryParams = props.params;
|
|
863
1001
|
const payload = props.payload;
|
|
864
1002
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_REMOVE_EXISTING, params, queryParams });
|
|
865
|
-
return
|
|
1003
|
+
return HttpClient.post(apiUrl, payload);
|
|
866
1004
|
},
|
|
867
1005
|
details: (props = null) => {
|
|
868
1006
|
const { paramsObject: urlParam, parentAccessLabel } = getParamDetails("", true);
|
|
869
|
-
const portalId = config.devPortalId;
|
|
870
1007
|
const params = {
|
|
871
|
-
hubId: config.hubId,
|
|
872
|
-
portalId,
|
|
1008
|
+
// hubId: config.hubId,
|
|
1009
|
+
// portalId: portalId,
|
|
873
1010
|
objectId: props?.params?.objectId,
|
|
874
1011
|
id: props?.params?.id
|
|
875
1012
|
};
|
|
@@ -879,52 +1016,49 @@ var Client = {
|
|
|
879
1016
|
...urlParam
|
|
880
1017
|
};
|
|
881
1018
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS, params, queryParams });
|
|
882
|
-
return
|
|
1019
|
+
return HttpClient.get(apiUrl);
|
|
883
1020
|
},
|
|
884
1021
|
update: (props = null) => {
|
|
885
|
-
const portalId = getPortal()?.portalId;
|
|
886
1022
|
const params = {
|
|
887
|
-
hubId: config.hubId,
|
|
888
|
-
portalId,
|
|
1023
|
+
// hubId: config.hubId,
|
|
1024
|
+
// portalId: portalId,
|
|
889
1025
|
objectId: props?.params?.objectId,
|
|
890
1026
|
id: props?.params?.id
|
|
891
1027
|
};
|
|
892
1028
|
const { paramsObject: queryParams } = getParamDetails();
|
|
893
1029
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.OBJECTS_DETAILS_UPDATE, params, queryParams });
|
|
894
|
-
return
|
|
1030
|
+
return HttpClient.put(apiUrl, props.payload);
|
|
895
1031
|
}
|
|
896
1032
|
},
|
|
897
1033
|
note: {
|
|
898
1034
|
list: (props = null) => {
|
|
899
|
-
const portalId = getPortal()?.portalId;
|
|
900
1035
|
const params = {
|
|
901
|
-
hubId: config.hubId,
|
|
902
|
-
portalId,
|
|
1036
|
+
// hubId: config.hubId,
|
|
1037
|
+
// portalId: portalId,
|
|
903
1038
|
objectId: props?.params?.objectId,
|
|
904
1039
|
id: props?.params?.id
|
|
905
1040
|
};
|
|
906
1041
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES, params, queryParams: props?.queryParams });
|
|
907
|
-
return
|
|
1042
|
+
return HttpClient.get(apiUrl);
|
|
908
1043
|
},
|
|
909
1044
|
create: (props = null) => {
|
|
910
1045
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
911
1046
|
const queryParams = props.queryParams;
|
|
912
1047
|
const payload = props.payload;
|
|
913
1048
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_CREATE, params, queryParams });
|
|
914
|
-
return
|
|
1049
|
+
return HttpClient.post(apiUrl, payload);
|
|
915
1050
|
},
|
|
916
1051
|
update: (props = null) => {
|
|
917
|
-
const portalId = getPortal()?.portalId;
|
|
918
1052
|
const params = {
|
|
919
|
-
hubId: config.hubId,
|
|
920
|
-
portalId,
|
|
1053
|
+
// hubId: config.hubId,
|
|
1054
|
+
// portalId: portalId,
|
|
921
1055
|
objectId: props?.params?.objectId,
|
|
922
1056
|
id: props?.params?.id,
|
|
923
1057
|
note_id: props?.params?.note_id
|
|
924
1058
|
};
|
|
925
1059
|
const { paramsObject: queryParams } = getParamDetails();
|
|
926
1060
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_DETAILS_UPDATE, params, queryParams });
|
|
927
|
-
return
|
|
1061
|
+
return HttpClient.put(apiUrl, props.payload);
|
|
928
1062
|
},
|
|
929
1063
|
image: (props = null) => {
|
|
930
1064
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -932,7 +1066,7 @@ var Client = {
|
|
|
932
1066
|
const payload = props.payload;
|
|
933
1067
|
const axiosConfig = props.config || {};
|
|
934
1068
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_IMAGE_UPLOAD, params, queryParams });
|
|
935
|
-
return
|
|
1069
|
+
return HttpClient.post(apiUrl, payload, {
|
|
936
1070
|
headers: {
|
|
937
1071
|
"Content-Type": "multipart/form-data"
|
|
938
1072
|
},
|
|
@@ -945,7 +1079,7 @@ var Client = {
|
|
|
945
1079
|
const payload = props.payload;
|
|
946
1080
|
const axiosConfig = props.config || {};
|
|
947
1081
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.NOTES_ATTACHMENT_UPLOAD, params, queryParams });
|
|
948
|
-
return
|
|
1082
|
+
return HttpClient.post(apiUrl, payload, {
|
|
949
1083
|
headers: {
|
|
950
1084
|
"Content-Type": "multipart/form-data"
|
|
951
1085
|
},
|
|
@@ -955,35 +1089,33 @@ var Client = {
|
|
|
955
1089
|
},
|
|
956
1090
|
email: {
|
|
957
1091
|
list: (props = null) => {
|
|
958
|
-
const portalId = getPortal()?.portalId;
|
|
959
1092
|
const params = {
|
|
960
|
-
hubId: config.hubId,
|
|
961
|
-
portalId,
|
|
1093
|
+
// hubId: config.hubId,
|
|
1094
|
+
// portalId: portalId,
|
|
962
1095
|
objectId: props?.params?.objectId,
|
|
963
1096
|
id: props?.params?.id
|
|
964
1097
|
};
|
|
965
1098
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS, params, queryParams: props?.queryParams });
|
|
966
|
-
return
|
|
1099
|
+
return HttpClient.get(apiUrl);
|
|
967
1100
|
},
|
|
968
1101
|
create: (props = null) => {
|
|
969
1102
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
970
1103
|
const queryParams = props.queryParams;
|
|
971
1104
|
const payload = props.payload;
|
|
972
1105
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_CREATE, params, queryParams });
|
|
973
|
-
return
|
|
1106
|
+
return HttpClient.post(apiUrl, payload);
|
|
974
1107
|
},
|
|
975
1108
|
update: (props = null) => {
|
|
976
|
-
const portalId = getPortal()?.portalId;
|
|
977
1109
|
const params = {
|
|
978
|
-
hubId: config.hubId,
|
|
979
|
-
portalId,
|
|
1110
|
+
// hubId: config.hubId,
|
|
1111
|
+
// portalId: portalId,
|
|
980
1112
|
objectId: props?.params?.objectId,
|
|
981
1113
|
id: props?.params?.id,
|
|
982
1114
|
note_id: props?.params?.note_id
|
|
983
1115
|
};
|
|
984
1116
|
const { paramsObject: queryParams } = getParamDetails();
|
|
985
1117
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_DETAILS_UPDATE, params, queryParams });
|
|
986
|
-
return
|
|
1118
|
+
return HttpClient.put(apiUrl, props.payload);
|
|
987
1119
|
},
|
|
988
1120
|
image: (props = null) => {
|
|
989
1121
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -991,7 +1123,7 @@ var Client = {
|
|
|
991
1123
|
const payload = props.payload;
|
|
992
1124
|
const axiosConfig = props.config || {};
|
|
993
1125
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_IMAGE_UPLOAD, params, queryParams });
|
|
994
|
-
return
|
|
1126
|
+
return HttpClient.post(apiUrl, payload, {
|
|
995
1127
|
headers: {
|
|
996
1128
|
"Content-Type": "multipart/form-data"
|
|
997
1129
|
},
|
|
@@ -1004,7 +1136,7 @@ var Client = {
|
|
|
1004
1136
|
const payload = props.payload;
|
|
1005
1137
|
const axiosConfig = props.config || {};
|
|
1006
1138
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.EMAILS_ATTACHMENT_UPLOAD, params, queryParams });
|
|
1007
|
-
return
|
|
1139
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1008
1140
|
headers: {
|
|
1009
1141
|
"Content-Type": "multipart/form-data"
|
|
1010
1142
|
},
|
|
@@ -1014,34 +1146,34 @@ var Client = {
|
|
|
1014
1146
|
},
|
|
1015
1147
|
file: {
|
|
1016
1148
|
list: (props = null) => {
|
|
1017
|
-
const portalId = getPortal()?.portalId;
|
|
1018
1149
|
const params = {
|
|
1019
|
-
hubId: config.hubId,
|
|
1020
|
-
portalId,
|
|
1150
|
+
// hubId: config.hubId,
|
|
1151
|
+
// portalId: portalId,
|
|
1021
1152
|
objectId: props?.params?.objectId,
|
|
1022
1153
|
id: props?.params?.id
|
|
1023
1154
|
};
|
|
1155
|
+
console.log("params_0", params);
|
|
1024
1156
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES, params, queryParams: props?.queryParams });
|
|
1025
|
-
return
|
|
1157
|
+
return HttpClient.get(apiUrl);
|
|
1026
1158
|
},
|
|
1027
1159
|
details: (props = null) => {
|
|
1028
|
-
const portalId = getPortal()?.portalId;
|
|
1029
1160
|
const params = {
|
|
1030
|
-
hubId: config.hubId,
|
|
1031
|
-
portalId,
|
|
1161
|
+
// hubId: config.hubId,
|
|
1162
|
+
// portalId: portalId,
|
|
1032
1163
|
objectId: props?.params?.objectId,
|
|
1033
1164
|
id: props?.params?.id,
|
|
1034
1165
|
rowId: props?.params?.rowId
|
|
1035
1166
|
};
|
|
1167
|
+
console.log("params_1", params);
|
|
1036
1168
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILE, params, queryParams: props?.queryParams });
|
|
1037
|
-
return
|
|
1169
|
+
return HttpClient.get(apiUrl);
|
|
1038
1170
|
},
|
|
1039
1171
|
addFolder: (props = null) => {
|
|
1040
1172
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
1041
1173
|
const queryParams = props.queryParams;
|
|
1042
1174
|
const payload = props.payload;
|
|
1043
1175
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_CREATE_FOLDER, params, queryParams });
|
|
1044
|
-
return
|
|
1176
|
+
return HttpClient.post(apiUrl, payload);
|
|
1045
1177
|
},
|
|
1046
1178
|
addFile: (props = null) => {
|
|
1047
1179
|
const params = { hubspotObjectTypeId: props?.hubspotObjectTypeId, ...props.params };
|
|
@@ -1049,7 +1181,7 @@ var Client = {
|
|
|
1049
1181
|
const payload = props.payload;
|
|
1050
1182
|
const axiosConfig = props.config || {};
|
|
1051
1183
|
const apiUrl = generateApiUrl({ route: API_ENDPOINTS.FILES_UPLOAD, params, queryParams });
|
|
1052
|
-
return
|
|
1184
|
+
return HttpClient.post(apiUrl, payload, {
|
|
1053
1185
|
headers: {
|
|
1054
1186
|
"Content-Type": "multipart/form-data"
|
|
1055
1187
|
},
|
|
@@ -1115,6 +1247,7 @@ function login(options) {
|
|
|
1115
1247
|
const tokenData = response?.data?.tokenData || {};
|
|
1116
1248
|
const loggedInDetails = response?.data?.loggedInDetails || {};
|
|
1117
1249
|
const currentPortal = response?.data?.loggedInDetails?.currentPortal || {};
|
|
1250
|
+
const currentPortalId = currentPortal?.portalId || null;
|
|
1118
1251
|
const SubscriptionType = loggedInDetails?.subscriptionType || "BASIC";
|
|
1119
1252
|
const token = tokenData?.token;
|
|
1120
1253
|
const refreshToken = tokenData?.refreshToken;
|
|
@@ -1125,6 +1258,7 @@ function login(options) {
|
|
|
1125
1258
|
await setAccessToken(token, expiresIn);
|
|
1126
1259
|
await setRefreshToken(refreshToken, rExpiresIn);
|
|
1127
1260
|
await setLoggedInDetails(response.data);
|
|
1261
|
+
setConfig.setDevPortalId(currentPortalId);
|
|
1128
1262
|
return response;
|
|
1129
1263
|
},
|
|
1130
1264
|
options
|
|
@@ -1588,7 +1722,7 @@ function list(options) {
|
|
|
1588
1722
|
} = useTable();
|
|
1589
1723
|
const { mutate, isLoading } = createMutation(
|
|
1590
1724
|
async (payload) => {
|
|
1591
|
-
const param = getTableParam(payload?.companyAsMediator);
|
|
1725
|
+
const param = await getTableParam(payload?.companyAsMediator);
|
|
1592
1726
|
const response = await Client.pipeline.list(payload, param);
|
|
1593
1727
|
return response;
|
|
1594
1728
|
},
|
|
@@ -1624,7 +1758,7 @@ function list3(options) {
|
|
|
1624
1758
|
} = useTable();
|
|
1625
1759
|
const { mutate, isLoading } = createMutation(
|
|
1626
1760
|
async (payload) => {
|
|
1627
|
-
const param = getTableParam(payload?.companyAsMediator);
|
|
1761
|
+
const param = await getTableParam(payload?.companyAsMediator);
|
|
1628
1762
|
const response = await Client.object.list(payload, param);
|
|
1629
1763
|
return response;
|
|
1630
1764
|
},
|
|
@@ -1636,6 +1770,20 @@ function list3(options) {
|
|
|
1636
1770
|
isLoading
|
|
1637
1771
|
};
|
|
1638
1772
|
}
|
|
1773
|
+
function sideBarList(options) {
|
|
1774
|
+
const { mutate, isLoading } = createMutation(
|
|
1775
|
+
async (payload) => {
|
|
1776
|
+
const response = await Client.object.sideBarList(payload);
|
|
1777
|
+
return response;
|
|
1778
|
+
},
|
|
1779
|
+
options
|
|
1780
|
+
);
|
|
1781
|
+
return {
|
|
1782
|
+
mutate,
|
|
1783
|
+
getSideBarObjects: mutate,
|
|
1784
|
+
isLoading
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1639
1787
|
function form(options) {
|
|
1640
1788
|
const { mutate, isLoading } = createMutation(
|
|
1641
1789
|
async (payload) => {
|
|
@@ -1827,7 +1975,6 @@ function update3(options) {
|
|
|
1827
1975
|
function imageUpload(options) {
|
|
1828
1976
|
const { mutate, isLoading } = createMutation(
|
|
1829
1977
|
async (payload) => {
|
|
1830
|
-
console.log("payload", payload);
|
|
1831
1978
|
const response = payload?.type === "email" ? await Client.email.image(payload) : await Client.note.image(payload);
|
|
1832
1979
|
return response;
|
|
1833
1980
|
},
|
|
@@ -2144,6 +2291,7 @@ var api = {
|
|
|
2144
2291
|
pipelines: list,
|
|
2145
2292
|
stages: list2,
|
|
2146
2293
|
objects: list3,
|
|
2294
|
+
sideBarObjects: sideBarList,
|
|
2147
2295
|
objectsForm: form,
|
|
2148
2296
|
createObject: create,
|
|
2149
2297
|
createExistingObject: createExisting,
|