woodsportal-client-sdk 1.1.5-dev.0 → 4.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +171 -77
- package/dist/adapters/angular/index.d.ts +58 -5
- package/dist/adapters/angular/index.js +8 -7
- package/dist/adapters/angular/index.js.map +1 -1
- package/dist/adapters/react/index.d.ts +58 -5
- package/dist/adapters/react/index.js +7 -6
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +58 -5
- package/dist/adapters/vue/index.js +8 -7
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/auth-utils-VT7HSLMA.js +3 -0
- package/dist/{auth-utils-A4WPJMPK.js.map → auth-utils-VT7HSLMA.js.map} +1 -1
- package/dist/authentication-BfYhAeMs.d.ts +463 -0
- package/dist/cache-purge-G5WkHckd.d.ts +236 -0
- package/dist/chunk-3FUHGFAQ.js +167 -0
- package/dist/chunk-3FUHGFAQ.js.map +1 -0
- package/dist/chunk-4ZV3MQIB.js +2000 -0
- package/dist/chunk-4ZV3MQIB.js.map +1 -0
- package/dist/{chunk-Y5MRAAGK.js → chunk-AYTO6ND7.js} +3 -3
- package/dist/chunk-AYTO6ND7.js.map +1 -0
- package/dist/chunk-G2KECOVQ.js +504 -0
- package/dist/chunk-G2KECOVQ.js.map +1 -0
- package/dist/chunk-H57IQHVF.js +20 -0
- package/dist/chunk-H57IQHVF.js.map +1 -0
- package/dist/chunk-KBXI2JBA.js +1200 -0
- package/dist/chunk-KBXI2JBA.js.map +1 -0
- package/dist/chunk-KCZFT6OM.js +416 -0
- package/dist/chunk-KCZFT6OM.js.map +1 -0
- package/dist/chunk-SSS4DNXP.js +304 -0
- package/dist/chunk-SSS4DNXP.js.map +1 -0
- package/dist/entries/auth.d.ts +68 -0
- package/dist/entries/auth.js +13 -0
- package/dist/entries/auth.js.map +1 -0
- package/dist/entries/crm.d.ts +208 -0
- package/dist/entries/crm.js +24 -0
- package/dist/entries/crm.js.map +1 -0
- package/dist/index-CCwMopD8.d.ts +38 -0
- package/dist/index.d.ts +405 -406
- package/dist/index.js +23 -1720
- package/dist/index.js.map +1 -1
- package/dist/use-sync-DpazhM4d.d.ts +60 -0
- package/dist/use-uploader-2F1zc7Cl.d.ts +23 -0
- package/package.json +53 -8
- package/dist/auth-utils-A4WPJMPK.js +0 -4
- package/dist/chunk-J7MDPY5P.js +0 -54
- package/dist/chunk-J7MDPY5P.js.map +0 -1
- package/dist/chunk-NB7AINV4.js +0 -35
- package/dist/chunk-NB7AINV4.js.map +0 -1
- package/dist/chunk-RDCT25UV.js +0 -1066
- package/dist/chunk-RDCT25UV.js.map +0 -1
- package/dist/chunk-Y5MRAAGK.js.map +0 -1
- package/dist/chunk-YLZA5S7A.js +0 -102
- package/dist/chunk-YLZA5S7A.js.map +0 -1
- package/dist/use-sync-LbURBOs_.d.ts +0 -29
|
@@ -0,0 +1,1200 @@
|
|
|
1
|
+
import { getProfile, setProfileDetails } from './chunk-3FUHGFAQ.js';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import pako from 'pako';
|
|
4
|
+
import { Base64 } from 'js-base64';
|
|
5
|
+
|
|
6
|
+
// src/main/core/utils/error-log-sanitize.ts
|
|
7
|
+
var SENSITIVE_FIELD_NAMES = /* @__PURE__ */ new Set(["token", "refreshtoken", "accesstoken", "password", "secret", "authorization", "otp", "code"]);
|
|
8
|
+
function isSensitiveField(name) {
|
|
9
|
+
const normalized = name.toLowerCase();
|
|
10
|
+
return SENSITIVE_FIELD_NAMES.has(normalized) || normalized.includes("password");
|
|
11
|
+
}
|
|
12
|
+
function redactValue(value) {
|
|
13
|
+
if (value == null || typeof value !== "object") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return value.map(redactValue);
|
|
18
|
+
}
|
|
19
|
+
const input = value;
|
|
20
|
+
const output = {};
|
|
21
|
+
for (const [key, nested] of Object.entries(input)) {
|
|
22
|
+
output[key] = isSensitiveField(key) ? "[redacted]" : redactValue(nested);
|
|
23
|
+
}
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
function sanitizeAxiosErrorData(data) {
|
|
27
|
+
if (data == null || typeof data !== "object") {
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
const payload = data;
|
|
31
|
+
const safeFields = ["errorCode", "message", "errorMessage", "detailedMessage", "correlationId", "category", "statusCode"];
|
|
32
|
+
const summary = {};
|
|
33
|
+
for (const field of safeFields) {
|
|
34
|
+
if (field in payload) {
|
|
35
|
+
summary[field] = payload[field];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(summary).length > 0) {
|
|
39
|
+
return summary;
|
|
40
|
+
}
|
|
41
|
+
return redactValue(payload);
|
|
42
|
+
}
|
|
43
|
+
function redactLogMeta(meta) {
|
|
44
|
+
if (meta == null) {
|
|
45
|
+
return meta;
|
|
46
|
+
}
|
|
47
|
+
return redactValue(meta);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/main/core/logging/logger.ts
|
|
51
|
+
var LEVEL_RANK = {
|
|
52
|
+
debug: 0,
|
|
53
|
+
info: 1,
|
|
54
|
+
warn: 2,
|
|
55
|
+
error: 3,
|
|
56
|
+
silent: 4
|
|
57
|
+
};
|
|
58
|
+
var DEFAULT_CONFIG = {
|
|
59
|
+
level: "info",
|
|
60
|
+
namespace: "woodsportal-sdk",
|
|
61
|
+
enabled: true,
|
|
62
|
+
httpTracing: true
|
|
63
|
+
};
|
|
64
|
+
var runtimeConfig = { ...DEFAULT_CONFIG };
|
|
65
|
+
var customSinks;
|
|
66
|
+
function shouldEmit(level) {
|
|
67
|
+
if (!runtimeConfig.enabled || runtimeConfig.level === "silent") {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return LEVEL_RANK[level] >= LEVEL_RANK[runtimeConfig.level];
|
|
71
|
+
}
|
|
72
|
+
function formatPrefix(context) {
|
|
73
|
+
return `[${runtimeConfig.namespace}] ${context}`;
|
|
74
|
+
}
|
|
75
|
+
function defaultDebug(context, message, meta) {
|
|
76
|
+
if (meta != null) {
|
|
77
|
+
console.debug(formatPrefix(context), message, meta);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
console.debug(formatPrefix(context), message);
|
|
81
|
+
}
|
|
82
|
+
function defaultInfo(context, message, meta) {
|
|
83
|
+
if (meta != null) {
|
|
84
|
+
console.info(formatPrefix(context), message, meta);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
console.info(formatPrefix(context), message);
|
|
88
|
+
}
|
|
89
|
+
function defaultWarn(context, message, meta) {
|
|
90
|
+
if (meta != null) {
|
|
91
|
+
console.warn(formatPrefix(context), message, meta);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
console.warn(formatPrefix(context), message);
|
|
95
|
+
}
|
|
96
|
+
function defaultError(context, error, meta) {
|
|
97
|
+
if (axios.isAxiosError(error)) {
|
|
98
|
+
const payload = {
|
|
99
|
+
message: error.message,
|
|
100
|
+
status: error.response?.status,
|
|
101
|
+
statusText: error.response?.statusText,
|
|
102
|
+
data: sanitizeAxiosErrorData(error.response?.data),
|
|
103
|
+
url: error.config?.url,
|
|
104
|
+
method: error.config?.method,
|
|
105
|
+
...redactLogMeta(meta)
|
|
106
|
+
};
|
|
107
|
+
console.error(formatPrefix(context), payload);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (error instanceof Error) {
|
|
111
|
+
if (meta != null) {
|
|
112
|
+
console.error(formatPrefix(context), error.message, error, redactLogMeta(meta));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
console.error(formatPrefix(context), error.message, error);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (meta != null) {
|
|
119
|
+
console.error(formatPrefix(context), error, redactLogMeta(meta));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
console.error(formatPrefix(context), error);
|
|
123
|
+
}
|
|
124
|
+
function configureLogger(config = {}) {
|
|
125
|
+
runtimeConfig = {
|
|
126
|
+
level: config.level ?? DEFAULT_CONFIG.level,
|
|
127
|
+
namespace: config.namespace ?? DEFAULT_CONFIG.namespace,
|
|
128
|
+
enabled: config.enabled ?? DEFAULT_CONFIG.enabled,
|
|
129
|
+
httpTracing: config.httpTracing ?? DEFAULT_CONFIG.httpTracing
|
|
130
|
+
};
|
|
131
|
+
customSinks = config.sinks;
|
|
132
|
+
}
|
|
133
|
+
function isHttpTracingEnabled() {
|
|
134
|
+
return runtimeConfig.enabled && runtimeConfig.httpTracing && shouldEmit("debug");
|
|
135
|
+
}
|
|
136
|
+
var logger = {
|
|
137
|
+
debug(context, message, meta) {
|
|
138
|
+
if (!shouldEmit("debug")) return;
|
|
139
|
+
const sink = customSinks?.debug ?? defaultDebug;
|
|
140
|
+
sink(context, message, redactLogMeta(meta));
|
|
141
|
+
},
|
|
142
|
+
info(context, message, meta) {
|
|
143
|
+
if (!shouldEmit("info")) return;
|
|
144
|
+
const sink = customSinks?.info ?? defaultInfo;
|
|
145
|
+
sink(context, message, redactLogMeta(meta));
|
|
146
|
+
},
|
|
147
|
+
warn(context, message, meta) {
|
|
148
|
+
if (!shouldEmit("warn")) return;
|
|
149
|
+
const sink = customSinks?.warn ?? defaultWarn;
|
|
150
|
+
sink(context, message, redactLogMeta(meta));
|
|
151
|
+
},
|
|
152
|
+
error(context, error, meta) {
|
|
153
|
+
if (!shouldEmit("error")) return;
|
|
154
|
+
const sink = customSinks?.error ?? defaultError;
|
|
155
|
+
sink(context, error, redactLogMeta(meta));
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/main/state/crm/store.ts
|
|
160
|
+
function createStore(initialState) {
|
|
161
|
+
let state = initialState;
|
|
162
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
163
|
+
return {
|
|
164
|
+
getState() {
|
|
165
|
+
return state;
|
|
166
|
+
},
|
|
167
|
+
setState(partial) {
|
|
168
|
+
state = {
|
|
169
|
+
...state,
|
|
170
|
+
...partial
|
|
171
|
+
};
|
|
172
|
+
listeners.forEach((listener) => listener(state));
|
|
173
|
+
},
|
|
174
|
+
subscribe(listener) {
|
|
175
|
+
listeners.add(listener);
|
|
176
|
+
return () => listeners.delete(listener);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/main/state/crm/use-form.ts
|
|
182
|
+
var formStore = createStore({
|
|
183
|
+
form: null
|
|
184
|
+
});
|
|
185
|
+
var actions = {
|
|
186
|
+
setFormData(response) {
|
|
187
|
+
formStore.setState({
|
|
188
|
+
form: response
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
clearFormData() {
|
|
192
|
+
formStore.setState({
|
|
193
|
+
form: null
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/main/state/crm/use-table.ts
|
|
199
|
+
var tableStore = createStore({
|
|
200
|
+
queryParams: null,
|
|
201
|
+
multiObjectsQueryParams: {},
|
|
202
|
+
objectsData: null,
|
|
203
|
+
tableData: [],
|
|
204
|
+
tablePrependData: [],
|
|
205
|
+
hubspotObjectTypeId: "",
|
|
206
|
+
selectedPipeline: "",
|
|
207
|
+
viewType: ""
|
|
208
|
+
});
|
|
209
|
+
var actions2 = {
|
|
210
|
+
/** Called from Client.object.list — feeds purgeCrmListCacheAfterCrmWrite / purgeCrmDetailAndListAfterCrmWrite. */
|
|
211
|
+
setObjectsQueryParams(params) {
|
|
212
|
+
tableStore.setState({
|
|
213
|
+
queryParams: params
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
/** Called from Client.object.sideBarList — feeds post-write list purge for sidebarTable writes. */
|
|
217
|
+
setMultiObjectsQueryParams(hubspotObjectTypeId, params) {
|
|
218
|
+
if (!hubspotObjectTypeId) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const state = tableStore.getState();
|
|
222
|
+
tableStore.setState({
|
|
223
|
+
multiObjectsQueryParams: {
|
|
224
|
+
...state.multiObjectsQueryParams,
|
|
225
|
+
[String(hubspotObjectTypeId)]: params
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
async setObjectsData(response, context) {
|
|
230
|
+
const state = tableStore.getState();
|
|
231
|
+
if (response?.info?.viewType == "LIST") {
|
|
232
|
+
tableStore.setState({
|
|
233
|
+
objectsData: response
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (response?.info?.viewType == "BOARD") {
|
|
237
|
+
const stageId = context?.stageId;
|
|
238
|
+
if (stageId) {
|
|
239
|
+
const boardData = { ...state.objectsData };
|
|
240
|
+
const updatedBoardData = await {
|
|
241
|
+
...boardData,
|
|
242
|
+
data: {
|
|
243
|
+
...boardData.data,
|
|
244
|
+
results: boardData.data.results.map(
|
|
245
|
+
(item) => String(item.id) === String(stageId) ? {
|
|
246
|
+
...item,
|
|
247
|
+
data: {
|
|
248
|
+
...item.data,
|
|
249
|
+
results: {
|
|
250
|
+
...item.data.results,
|
|
251
|
+
rows: [
|
|
252
|
+
...item?.data?.results?.rows ?? [],
|
|
253
|
+
// keep existing rows
|
|
254
|
+
...response?.data?.results?.rows ?? []
|
|
255
|
+
// prepend new rows
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
} : item
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
tableStore.setState({
|
|
264
|
+
objectsData: updatedBoardData
|
|
265
|
+
});
|
|
266
|
+
} else {
|
|
267
|
+
tableStore.setState({
|
|
268
|
+
objectsData: response
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
setTableData(response, payload) {
|
|
274
|
+
const state = tableStore.getState();
|
|
275
|
+
const viewType = response?.info?.viewType;
|
|
276
|
+
let newTablePrependData;
|
|
277
|
+
if (viewType === "BOARD") {
|
|
278
|
+
const stages = response?.data?.results ?? [];
|
|
279
|
+
newTablePrependData = state.tablePrependData.map((prependStage) => {
|
|
280
|
+
const matchingStage = stages.find((stage) => String(stage.id) === String(prependStage.id));
|
|
281
|
+
const rows = matchingStage?.data?.results?.rows ?? [];
|
|
282
|
+
const rowIds = new Set(
|
|
283
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
284
|
+
);
|
|
285
|
+
const filteredRows = (prependStage?.data?.results?.rows ?? []).filter((item) => {
|
|
286
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
287
|
+
if (itemId == null || itemId === "") return true;
|
|
288
|
+
return !rowIds.has(String(itemId));
|
|
289
|
+
});
|
|
290
|
+
return {
|
|
291
|
+
...prependStage,
|
|
292
|
+
data: {
|
|
293
|
+
...prependStage.data,
|
|
294
|
+
results: {
|
|
295
|
+
...prependStage.data?.results,
|
|
296
|
+
rows: filteredRows
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
} else {
|
|
302
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
303
|
+
const rowIds = new Set(
|
|
304
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id) => id != null && id !== "").map((id) => String(id))
|
|
305
|
+
);
|
|
306
|
+
newTablePrependData = state.tablePrependData.filter((item) => {
|
|
307
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
308
|
+
if (itemId == null || itemId === "") return true;
|
|
309
|
+
return !rowIds.has(String(itemId));
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const hubspotObjectTypeId = payload?.hubspotObjectTypeId;
|
|
313
|
+
const selectedPipeline = payload?.selectedPipeline;
|
|
314
|
+
if (response?.data?.total < 1 || payload?.componentName) {
|
|
315
|
+
newTablePrependData = [];
|
|
316
|
+
}
|
|
317
|
+
if (state.viewType && state.viewType != viewType) {
|
|
318
|
+
newTablePrependData = [];
|
|
319
|
+
}
|
|
320
|
+
if (state.hubspotObjectTypeId && state.hubspotObjectTypeId != hubspotObjectTypeId) {
|
|
321
|
+
newTablePrependData = [];
|
|
322
|
+
}
|
|
323
|
+
if (state.selectedPipeline && state.selectedPipeline != selectedPipeline) {
|
|
324
|
+
newTablePrependData = [];
|
|
325
|
+
}
|
|
326
|
+
if (payload.isFristTimeLoadData) {
|
|
327
|
+
newTablePrependData = [];
|
|
328
|
+
}
|
|
329
|
+
tableStore.setState({
|
|
330
|
+
tableData: response,
|
|
331
|
+
tablePrependData: newTablePrependData || [],
|
|
332
|
+
hubspotObjectTypeId,
|
|
333
|
+
viewType
|
|
334
|
+
});
|
|
335
|
+
},
|
|
336
|
+
modifiedObjectsData(results) {
|
|
337
|
+
const state = tableStore.getState();
|
|
338
|
+
const tablePrependData = state.tablePrependData;
|
|
339
|
+
const modifiedData = results.map((result) => {
|
|
340
|
+
const matchedPrepend = tablePrependData.find((item) => String(item?.id) === String(result?.id));
|
|
341
|
+
if (!matchedPrepend) {
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
345
|
+
const prependCards = prependRows.map((row) => ({
|
|
346
|
+
id: row.hs_object_id,
|
|
347
|
+
...row
|
|
348
|
+
}));
|
|
349
|
+
return {
|
|
350
|
+
...result,
|
|
351
|
+
// prepend in results.rows
|
|
352
|
+
data: {
|
|
353
|
+
...result.data,
|
|
354
|
+
results: {
|
|
355
|
+
...result.data.results,
|
|
356
|
+
rows: [...prependRows, ...result?.data?.results?.rows ?? []]
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
// prepend in cards
|
|
360
|
+
cards: [...prependCards, ...result?.cards ?? []]
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
tableStore.setState({
|
|
364
|
+
objectsData: modifiedData
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
clearTablePrependData() {
|
|
368
|
+
tableStore.setState({
|
|
369
|
+
tablePrependData: []
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
async setTablePrependData(response, props) {
|
|
373
|
+
const state = tableStore.getState();
|
|
374
|
+
const formState = formStore.getState();
|
|
375
|
+
let rows = [];
|
|
376
|
+
if (state.tableData?.info?.viewType == "BOARD") {
|
|
377
|
+
if (response === "loading") {
|
|
378
|
+
const responseData = state.tableData?.data?.results ?? [];
|
|
379
|
+
const pipelineStage = props?.payload?.propertyPayload?.hs_pipeline_stage || props?.payload?.propertyPayload?.dealstage || formState?.form?.data?.pipelineDefaults?.defaultStage?.id;
|
|
380
|
+
rows = responseData.map(({ id, data }) => {
|
|
381
|
+
const matchedPrepend = state.tablePrependData.find((item) => String(item.id) === String(id));
|
|
382
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
383
|
+
const newRow = String(id) === String(pipelineStage) ? [
|
|
384
|
+
(data?.results?.columns ?? []).reduce((obj, column) => {
|
|
385
|
+
obj[column.key] = "loading";
|
|
386
|
+
return obj;
|
|
387
|
+
}, {})
|
|
388
|
+
] : [];
|
|
389
|
+
return {
|
|
390
|
+
id,
|
|
391
|
+
data: {
|
|
392
|
+
results: {
|
|
393
|
+
columns: data?.results?.columns ?? [],
|
|
394
|
+
// prepend loading row + prepend rows
|
|
395
|
+
rows: [...newRow, ...prependRows]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
});
|
|
400
|
+
} else {
|
|
401
|
+
const data = response?.data;
|
|
402
|
+
const hs_pipeline_stage = data?.hs_pipeline_stage?.value?.value || data?.dealstage?.value?.value;
|
|
403
|
+
if (!data) {
|
|
404
|
+
tableStore.setState({
|
|
405
|
+
tablePrependData: []
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
rows = state?.tablePrependData.map((row) => {
|
|
409
|
+
const matchedPrepend = state.tablePrependData.find((item) => String(item.id) === String(row.id));
|
|
410
|
+
const prependRows = matchedPrepend?.data?.results?.rows ?? [];
|
|
411
|
+
if (String(row.id) === String(hs_pipeline_stage)) {
|
|
412
|
+
const updatedRow = (row?.data?.results?.columns ?? []).reduce((obj, column) => {
|
|
413
|
+
const key = column.key;
|
|
414
|
+
obj[key] = data?.[key]?.value ?? data?.[key] ?? "";
|
|
415
|
+
return obj;
|
|
416
|
+
}, {});
|
|
417
|
+
prependRows[0] = updatedRow;
|
|
418
|
+
return {
|
|
419
|
+
...row,
|
|
420
|
+
data: {
|
|
421
|
+
...row.data,
|
|
422
|
+
results: {
|
|
423
|
+
...row.data.results,
|
|
424
|
+
rows: prependRows
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
return row;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
} else if (state.tableData?.info?.viewType == "LIST") {
|
|
433
|
+
if (response === "loading") {
|
|
434
|
+
const row = await state.tableData?.data?.results?.columns.reduce((acc, item) => {
|
|
435
|
+
if (!item.hidden) {
|
|
436
|
+
acc[item.key] = "loading";
|
|
437
|
+
}
|
|
438
|
+
return acc;
|
|
439
|
+
}, {});
|
|
440
|
+
rows = [row, ...state.tablePrependData];
|
|
441
|
+
} else if (response?.data) {
|
|
442
|
+
const data = response?.data;
|
|
443
|
+
if (!data) {
|
|
444
|
+
tableStore.setState({
|
|
445
|
+
tablePrependData: []
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const row = await Object.fromEntries(Object.entries(data).map(([key, value]) => [key, value?.value ?? value]));
|
|
449
|
+
rows = [...state.tablePrependData];
|
|
450
|
+
if (rows.length > 0) {
|
|
451
|
+
rows[0] = row;
|
|
452
|
+
} else {
|
|
453
|
+
rows.push(row);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
tableStore.setState({
|
|
458
|
+
tablePrependData: rows
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// src/main/state/crm/use-uploader.ts
|
|
464
|
+
var uploaderStore = createStore({
|
|
465
|
+
attachments: []
|
|
466
|
+
});
|
|
467
|
+
function toAttachmentSummary(attachment) {
|
|
468
|
+
return {
|
|
469
|
+
createdAt: attachment.createdAt,
|
|
470
|
+
id: attachment.id,
|
|
471
|
+
name: attachment.name,
|
|
472
|
+
size: attachment.size,
|
|
473
|
+
type: attachment.type,
|
|
474
|
+
updatedAt: attachment.updatedAt
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function resolveAttachmentsFromIds(attachmentIds, storedAttachments) {
|
|
478
|
+
const raw = typeof attachmentIds === "object" && attachmentIds !== null && "value" in attachmentIds ? attachmentIds.value : attachmentIds;
|
|
479
|
+
const ids = String(raw ?? "").split(";").map((id) => id.trim()).filter(Boolean);
|
|
480
|
+
return ids.map((id) => storedAttachments.find((a) => String(a.id) === id)).filter((a) => a != null).map(toAttachmentSummary);
|
|
481
|
+
}
|
|
482
|
+
var actions3 = {
|
|
483
|
+
setAttachment(response) {
|
|
484
|
+
const data = response?.data;
|
|
485
|
+
if (!data?.id) return;
|
|
486
|
+
const state = uploaderStore.getState();
|
|
487
|
+
const id = String(data.id);
|
|
488
|
+
const existing = state.attachments;
|
|
489
|
+
const index = existing.findIndex((item) => String(item.id) === id);
|
|
490
|
+
const attachments = index >= 0 ? existing.map((item, i) => i === index ? data : item) : [...existing, data];
|
|
491
|
+
uploaderStore.setState({ attachments });
|
|
492
|
+
},
|
|
493
|
+
clearAttachments() {
|
|
494
|
+
uploaderStore.setState({ attachments: [] });
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// src/main/state/crm/use-note.ts
|
|
499
|
+
var noteStore = createStore({
|
|
500
|
+
notes: [],
|
|
501
|
+
prependNotes: [],
|
|
502
|
+
id: "",
|
|
503
|
+
queryParams: null
|
|
504
|
+
});
|
|
505
|
+
var actions4 = {
|
|
506
|
+
/** Called from Client.note.list — feeds purgeEngagementCaches (view: notes). */
|
|
507
|
+
setListQueryParams(params) {
|
|
508
|
+
noteStore.setState({
|
|
509
|
+
queryParams: params
|
|
510
|
+
});
|
|
511
|
+
},
|
|
512
|
+
setNotes(response, payload) {
|
|
513
|
+
const state = noteStore.getState();
|
|
514
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
515
|
+
const rowIds = new Set(
|
|
516
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
517
|
+
);
|
|
518
|
+
let newPrependNotes = state.prependNotes.filter((item) => {
|
|
519
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
520
|
+
if (itemId == null || itemId === "") return true;
|
|
521
|
+
return !rowIds.has(String(itemId));
|
|
522
|
+
});
|
|
523
|
+
const id = payload?.params?.id;
|
|
524
|
+
if (state.id && state.id != id) {
|
|
525
|
+
newPrependNotes = [];
|
|
526
|
+
}
|
|
527
|
+
noteStore.setState({
|
|
528
|
+
notes: response,
|
|
529
|
+
prependNotes: newPrependNotes,
|
|
530
|
+
id
|
|
531
|
+
});
|
|
532
|
+
},
|
|
533
|
+
async setPrependNote(response) {
|
|
534
|
+
const state = noteStore.getState();
|
|
535
|
+
let rows = [];
|
|
536
|
+
if (response === "loading") {
|
|
537
|
+
const row = await state.notes?.data?.results?.columns.reduce((acc, item) => {
|
|
538
|
+
if (!item.hidden) {
|
|
539
|
+
acc[item.key] = "loading";
|
|
540
|
+
}
|
|
541
|
+
return acc;
|
|
542
|
+
}, {});
|
|
543
|
+
rows = [row, ...state.prependNotes];
|
|
544
|
+
} else if (response?.data) {
|
|
545
|
+
const data = response?.data;
|
|
546
|
+
if (!data) {
|
|
547
|
+
noteStore.setState({
|
|
548
|
+
prependNotes: []
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
552
|
+
const row = Object.fromEntries(
|
|
553
|
+
Object.entries(data).map(([key, value]) => {
|
|
554
|
+
if (key === "hs_attachment_ids") {
|
|
555
|
+
return [key, resolveAttachmentsFromIds(value, storedAttachments)];
|
|
556
|
+
}
|
|
557
|
+
return [key, value?.value ?? value];
|
|
558
|
+
})
|
|
559
|
+
);
|
|
560
|
+
rows = [...state.prependNotes];
|
|
561
|
+
if (rows.length > 0) {
|
|
562
|
+
rows[0] = row;
|
|
563
|
+
} else {
|
|
564
|
+
rows.push(row);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
noteStore.setState({
|
|
568
|
+
prependNotes: rows
|
|
569
|
+
});
|
|
570
|
+
},
|
|
571
|
+
clearPrependNotes() {
|
|
572
|
+
noteStore.setState({
|
|
573
|
+
prependNotes: []
|
|
574
|
+
});
|
|
575
|
+
actions3.clearAttachments();
|
|
576
|
+
},
|
|
577
|
+
async updatePrependNote(response) {
|
|
578
|
+
const responseData = { ...response };
|
|
579
|
+
const state = noteStore.getState();
|
|
580
|
+
const prependNotes = state.prependNotes || [];
|
|
581
|
+
const note = response.data || null;
|
|
582
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
583
|
+
const notes = prependNotes.map(
|
|
584
|
+
(item) => item?.hs_object_id === note?.hs_object_id?.value ? {
|
|
585
|
+
...item,
|
|
586
|
+
...Object.fromEntries(
|
|
587
|
+
Object.entries(note).map(([key, value]) => {
|
|
588
|
+
if (key === "hs_attachment_ids") {
|
|
589
|
+
return [key, resolveAttachmentsFromIds(value, storedAttachments)];
|
|
590
|
+
}
|
|
591
|
+
return [key, value?.value ?? value];
|
|
592
|
+
})
|
|
593
|
+
)
|
|
594
|
+
} : item
|
|
595
|
+
);
|
|
596
|
+
noteStore.setState({
|
|
597
|
+
prependNotes: notes
|
|
598
|
+
});
|
|
599
|
+
if (responseData?.data?.hs_attachment_ids != null) {
|
|
600
|
+
const noteObjectId = note?.hs_object_id?.value;
|
|
601
|
+
const rows = state.notes?.data?.results?.rows ?? [];
|
|
602
|
+
const matchingRow = rows.find((row) => String(row.hs_object_id) === String(noteObjectId));
|
|
603
|
+
const originalPrependItem = prependNotes.find((item) => String(item?.hs_object_id) === String(noteObjectId));
|
|
604
|
+
const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
|
|
605
|
+
const newAttachments = resolveAttachmentsFromIds(responseData.data.hs_attachment_ids, storedAttachments);
|
|
606
|
+
const mergedAttachments = [
|
|
607
|
+
...existingAttachments,
|
|
608
|
+
...newAttachments.filter((attachment) => !existingAttachments.some((existing) => String(existing.id) === String(attachment.id)))
|
|
609
|
+
];
|
|
610
|
+
const stateUpdates = {};
|
|
611
|
+
if (matchingRow && state.notes?.data?.results) {
|
|
612
|
+
stateUpdates.notes = {
|
|
613
|
+
...state.notes,
|
|
614
|
+
data: {
|
|
615
|
+
...state.notes.data,
|
|
616
|
+
results: {
|
|
617
|
+
...state.notes.data.results,
|
|
618
|
+
rows: rows.map(
|
|
619
|
+
(row) => String(row.hs_object_id) === String(noteObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
|
|
620
|
+
)
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
if (originalPrependItem) {
|
|
626
|
+
stateUpdates.prependNotes = prependNotes.map(
|
|
627
|
+
(item) => String(item?.hs_object_id) === String(noteObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
if (Object.keys(stateUpdates).length > 0) {
|
|
631
|
+
noteStore.setState(stateUpdates);
|
|
632
|
+
}
|
|
633
|
+
responseData.data.hs_attachment_ids = mergedAttachments;
|
|
634
|
+
}
|
|
635
|
+
return responseData;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// src/main/state/crm/use-email.ts
|
|
640
|
+
var emailStore = createStore({
|
|
641
|
+
emails: [],
|
|
642
|
+
prependEmails: [],
|
|
643
|
+
id: "",
|
|
644
|
+
queryParams: null
|
|
645
|
+
});
|
|
646
|
+
var actions5 = {
|
|
647
|
+
/** Called from Client.email.list — feeds purgeEngagementCaches (view: emails). */
|
|
648
|
+
setListQueryParams(params) {
|
|
649
|
+
emailStore.setState({
|
|
650
|
+
queryParams: params
|
|
651
|
+
});
|
|
652
|
+
},
|
|
653
|
+
setEmails(response, payload) {
|
|
654
|
+
const state = emailStore.getState();
|
|
655
|
+
const rows = response?.data?.results?.rows ?? [];
|
|
656
|
+
const rowIds = new Set(
|
|
657
|
+
rows.map((row) => row.id ?? row.hs_object_id).filter((id2) => id2 != null && id2 !== "").map((id2) => String(id2))
|
|
658
|
+
);
|
|
659
|
+
let newPrependEmails = state.prependEmails.filter((item) => {
|
|
660
|
+
const itemId = item.id ?? item.hs_object_id;
|
|
661
|
+
if (itemId == null || itemId === "") return true;
|
|
662
|
+
return !rowIds.has(String(itemId));
|
|
663
|
+
});
|
|
664
|
+
const id = payload?.params?.id;
|
|
665
|
+
if (state.id && state.id != id) {
|
|
666
|
+
newPrependEmails = [];
|
|
667
|
+
}
|
|
668
|
+
emailStore.setState({
|
|
669
|
+
emails: response,
|
|
670
|
+
prependEmails: newPrependEmails,
|
|
671
|
+
id
|
|
672
|
+
});
|
|
673
|
+
},
|
|
674
|
+
async setPrependEmail(response) {
|
|
675
|
+
const state = emailStore.getState();
|
|
676
|
+
let rows = [];
|
|
677
|
+
if (response === "loading") {
|
|
678
|
+
const row = await state.emails?.data?.results?.columns.reduce((acc, item) => {
|
|
679
|
+
if (!item.hidden) {
|
|
680
|
+
acc[item.key] = "loading";
|
|
681
|
+
}
|
|
682
|
+
return acc;
|
|
683
|
+
}, {});
|
|
684
|
+
rows = [row, ...state.prependEmails];
|
|
685
|
+
} else if (response?.data) {
|
|
686
|
+
const data = response?.data;
|
|
687
|
+
if (!data) {
|
|
688
|
+
emailStore.setState({
|
|
689
|
+
prependEmails: []
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
693
|
+
const row = Object.fromEntries(
|
|
694
|
+
Object.entries(data).map(([key, value]) => {
|
|
695
|
+
if (key === "hs_attachment_ids") {
|
|
696
|
+
return [key, resolveAttachmentsFromIds(value, storedAttachments)];
|
|
697
|
+
}
|
|
698
|
+
return [key, value?.value ?? value];
|
|
699
|
+
})
|
|
700
|
+
);
|
|
701
|
+
rows = [...state.prependEmails];
|
|
702
|
+
if (rows.length > 0) {
|
|
703
|
+
rows[0] = row;
|
|
704
|
+
} else {
|
|
705
|
+
rows.push(row);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
emailStore.setState({
|
|
709
|
+
prependEmails: rows
|
|
710
|
+
});
|
|
711
|
+
},
|
|
712
|
+
clearPrependEmails() {
|
|
713
|
+
emailStore.setState({
|
|
714
|
+
prependEmails: []
|
|
715
|
+
});
|
|
716
|
+
actions3.clearAttachments();
|
|
717
|
+
},
|
|
718
|
+
async updatePrependEmail(response) {
|
|
719
|
+
const responseData = { ...response };
|
|
720
|
+
const state = emailStore.getState();
|
|
721
|
+
const prependEmails = state.prependEmails || [];
|
|
722
|
+
const email = response.data || null;
|
|
723
|
+
const storedAttachments = uploaderStore.getState().attachments;
|
|
724
|
+
const emails = prependEmails.map(
|
|
725
|
+
(item) => item?.hs_object_id === email?.hs_object_id?.value ? {
|
|
726
|
+
...item,
|
|
727
|
+
...Object.fromEntries(
|
|
728
|
+
Object.entries(email).map(([key, value]) => {
|
|
729
|
+
if (key === "hs_attachment_ids") {
|
|
730
|
+
return [key, resolveAttachmentsFromIds(value, storedAttachments)];
|
|
731
|
+
}
|
|
732
|
+
return [key, value?.value ?? value];
|
|
733
|
+
})
|
|
734
|
+
)
|
|
735
|
+
} : item
|
|
736
|
+
);
|
|
737
|
+
emailStore.setState({
|
|
738
|
+
prependEmails: emails
|
|
739
|
+
});
|
|
740
|
+
if (responseData?.data?.hs_attachment_ids != null) {
|
|
741
|
+
const emailObjectId = email?.hs_object_id?.value;
|
|
742
|
+
const rows = state.emails?.data?.results?.rows ?? [];
|
|
743
|
+
const matchingRow = rows.find((row) => String(row.hs_object_id) === String(emailObjectId));
|
|
744
|
+
const originalPrependItem = prependEmails.find((item) => String(item?.hs_object_id) === String(emailObjectId));
|
|
745
|
+
const existingAttachments = matchingRow?.hs_attachment_ids ?? originalPrependItem?.hs_attachment_ids ?? [];
|
|
746
|
+
const newAttachments = resolveAttachmentsFromIds(responseData.data.hs_attachment_ids, storedAttachments);
|
|
747
|
+
const mergedAttachments = [
|
|
748
|
+
...existingAttachments,
|
|
749
|
+
...newAttachments.filter((attachment) => !existingAttachments.some((existing) => String(existing.id) === String(attachment.id)))
|
|
750
|
+
];
|
|
751
|
+
const stateUpdates = {};
|
|
752
|
+
if (matchingRow && state.emails?.data?.results) {
|
|
753
|
+
stateUpdates.emails = {
|
|
754
|
+
...state.emails,
|
|
755
|
+
data: {
|
|
756
|
+
...state.emails.data,
|
|
757
|
+
results: {
|
|
758
|
+
...state.emails.data.results,
|
|
759
|
+
rows: rows.map(
|
|
760
|
+
(row) => String(row.hs_object_id) === String(emailObjectId) ? { ...row, hs_attachment_ids: mergedAttachments } : row
|
|
761
|
+
)
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
if (originalPrependItem) {
|
|
767
|
+
stateUpdates.prependEmails = prependEmails.map(
|
|
768
|
+
(item) => String(item?.hs_object_id) === String(emailObjectId) ? { ...item, hs_attachment_ids: mergedAttachments } : item
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
if (Object.keys(stateUpdates).length > 0) {
|
|
772
|
+
emailStore.setState(stateUpdates);
|
|
773
|
+
}
|
|
774
|
+
responseData.data.hs_attachment_ids = mergedAttachments;
|
|
775
|
+
}
|
|
776
|
+
return responseData;
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// src/main/state/crm/use-user.ts
|
|
781
|
+
var userStore = createStore({
|
|
782
|
+
profile: getProfile()
|
|
783
|
+
});
|
|
784
|
+
var actions6 = {
|
|
785
|
+
setProfile(response) {
|
|
786
|
+
const data = response?.data || null;
|
|
787
|
+
userStore.setState({
|
|
788
|
+
profile: data
|
|
789
|
+
});
|
|
790
|
+
setProfileDetails(data);
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// src/main/state/crm/use-sync.ts
|
|
795
|
+
var syncStore = createStore({
|
|
796
|
+
apiSync: false,
|
|
797
|
+
sync: false,
|
|
798
|
+
isSyncLoading: false,
|
|
799
|
+
isSyncDisable: false
|
|
800
|
+
});
|
|
801
|
+
var actions7 = {
|
|
802
|
+
setIsSyncLoading(status) {
|
|
803
|
+
syncStore.setState({
|
|
804
|
+
isSyncLoading: status,
|
|
805
|
+
sync: status
|
|
806
|
+
});
|
|
807
|
+
},
|
|
808
|
+
setSync(status) {
|
|
809
|
+
resetAllStore();
|
|
810
|
+
syncStore.setState({
|
|
811
|
+
isSyncLoading: status,
|
|
812
|
+
sync: status
|
|
813
|
+
});
|
|
814
|
+
},
|
|
815
|
+
setApiSync(status) {
|
|
816
|
+
syncStore.setState({
|
|
817
|
+
isSyncLoading: status,
|
|
818
|
+
apiSync: status
|
|
819
|
+
});
|
|
820
|
+
},
|
|
821
|
+
setSyncDisable(status) {
|
|
822
|
+
syncStore.setState({
|
|
823
|
+
isSyncDisable: status
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
var resetAllStore = () => {
|
|
828
|
+
actions2.clearTablePrependData();
|
|
829
|
+
actions4.clearPrependNotes();
|
|
830
|
+
actions5.clearPrependEmails();
|
|
831
|
+
};
|
|
832
|
+
function convertToBase64(obj) {
|
|
833
|
+
try {
|
|
834
|
+
if (!obj) return "";
|
|
835
|
+
const json = JSON.stringify(obj);
|
|
836
|
+
const compressed = pako.deflate(json);
|
|
837
|
+
const base64 = Base64.fromUint8Array(compressed, true);
|
|
838
|
+
return base64;
|
|
839
|
+
} catch (error) {
|
|
840
|
+
logger.error("compress", error, { operation: "encode" });
|
|
841
|
+
return "";
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
function decodeToBase64(encoded) {
|
|
845
|
+
try {
|
|
846
|
+
if (!encoded) return null;
|
|
847
|
+
const uint8Array = Base64.toUint8Array(encoded);
|
|
848
|
+
const decompressed = pako.inflate(uint8Array, { to: "string" });
|
|
849
|
+
return JSON.parse(decompressed);
|
|
850
|
+
} catch (error) {
|
|
851
|
+
logger.error("compress", error, { operation: "decode" });
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// src/main/features/navigation/url-utils.ts
|
|
857
|
+
function mapKeysDeep(obj, keyMap2) {
|
|
858
|
+
if (Array.isArray(obj)) {
|
|
859
|
+
return obj.map((item) => mapKeysDeep(item, keyMap2));
|
|
860
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
861
|
+
return Object.entries(obj).reduce(
|
|
862
|
+
(acc, [key, value]) => {
|
|
863
|
+
const mappedKey = keyMap2[key] || key;
|
|
864
|
+
acc[mappedKey] = mapKeysDeep(value, keyMap2);
|
|
865
|
+
return acc;
|
|
866
|
+
},
|
|
867
|
+
{}
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
return obj;
|
|
871
|
+
}
|
|
872
|
+
function isMessingParent(breadcrumbs) {
|
|
873
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
874
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
875
|
+
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
876
|
+
return lastItem?.o_r_id && !lastItem2?.o_r_id && lastItem2?.o_t_id && lastItem3?.o_r_id ? true : false;
|
|
877
|
+
}
|
|
878
|
+
function isMessingParentLastItem(breadcrumbs) {
|
|
879
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
880
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
881
|
+
return !lastItem?.o_t_id && lastItem2?.o_r_id && lastItem2?.o_t_id ? false : true;
|
|
882
|
+
}
|
|
883
|
+
function breadcrumbStage(breadcrumbItems) {
|
|
884
|
+
let breadcrumbType = "child";
|
|
885
|
+
if (breadcrumbItems.length === 1) {
|
|
886
|
+
breadcrumbType = "root";
|
|
887
|
+
} else if (breadcrumbItems.length === 2) {
|
|
888
|
+
breadcrumbType = "root_details";
|
|
889
|
+
}
|
|
890
|
+
return breadcrumbType;
|
|
891
|
+
}
|
|
892
|
+
var generateUrl = (props, breadcrumbs) => {
|
|
893
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
894
|
+
let url = "";
|
|
895
|
+
if (props?.objectTypeId && props?.recordId) {
|
|
896
|
+
url = `/${props?.recordId}/${props?.objectTypeId}/${props?.recordId}?b=${newBase64}`;
|
|
897
|
+
} else {
|
|
898
|
+
url = `/association/${props?.objectTypeId}?b=${newBase64}`;
|
|
899
|
+
}
|
|
900
|
+
return url;
|
|
901
|
+
};
|
|
902
|
+
function getTotalParentLength(data) {
|
|
903
|
+
return data.filter((item) => (item.pt || item.o_t_id) && !item.o_r_id).length;
|
|
904
|
+
}
|
|
905
|
+
var generatePath = (breadcrumbs, breadcrumb, index) => {
|
|
906
|
+
const bc = convertToBase64(breadcrumbs.slice(0, index + 1));
|
|
907
|
+
if (index === 0) {
|
|
908
|
+
const pathBase = breadcrumb?.pt || `/${breadcrumb?.o_t_id}`;
|
|
909
|
+
const normalizedPath = pathBase.startsWith("/") ? pathBase : `/${pathBase}`;
|
|
910
|
+
return {
|
|
911
|
+
name: breadcrumb?.n,
|
|
912
|
+
path: `${normalizedPath}?b=${bc}`
|
|
913
|
+
};
|
|
914
|
+
} else if (index === 1) {
|
|
915
|
+
if (breadcrumb?.isHome) {
|
|
916
|
+
return {
|
|
917
|
+
name: breadcrumb?.n,
|
|
918
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
return {
|
|
922
|
+
name: breadcrumb?.n,
|
|
923
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
924
|
+
};
|
|
925
|
+
} else {
|
|
926
|
+
if (breadcrumb?.o_t_id && breadcrumb?.o_r_id && !breadcrumb?.isHome) {
|
|
927
|
+
return {
|
|
928
|
+
name: breadcrumb?.n,
|
|
929
|
+
path: `/${breadcrumb?.o_r_id}/${breadcrumb?.o_t_id}/${breadcrumb?.o_r_id}?b=${bc}`
|
|
930
|
+
};
|
|
931
|
+
} else {
|
|
932
|
+
return {
|
|
933
|
+
name: breadcrumb?.n,
|
|
934
|
+
path: `/association/${breadcrumb?.o_t_id}?b=${bc}`
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
// src/main/features/navigation/key-map.ts
|
|
941
|
+
var keyMap = {
|
|
942
|
+
dp: "defPermissions",
|
|
943
|
+
n: "name",
|
|
944
|
+
sort: "sort",
|
|
945
|
+
o_t_id: "objectTypeId",
|
|
946
|
+
s: "search",
|
|
947
|
+
fPn: "filterPropertyName",
|
|
948
|
+
fO: "filterOperator",
|
|
949
|
+
fV: "filterValue",
|
|
950
|
+
c: "cache",
|
|
951
|
+
isPC: "isPrimaryCompany",
|
|
952
|
+
v: "view",
|
|
953
|
+
l: "limit",
|
|
954
|
+
pt: "path",
|
|
955
|
+
p: "page",
|
|
956
|
+
a: "after",
|
|
957
|
+
aPip: "activePipeline",
|
|
958
|
+
aT: "activeTab",
|
|
959
|
+
cT: "create",
|
|
960
|
+
dP: "display",
|
|
961
|
+
dL: "display_label",
|
|
962
|
+
pId: "pipeline_id"
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
// src/main/core/utils/url.ts
|
|
966
|
+
var ticketHubspotObjectTypeId = () => {
|
|
967
|
+
const paramDetails = getParamDetails();
|
|
968
|
+
if (
|
|
969
|
+
// this hubspotObjectTypeId only for main contact ticket object type
|
|
970
|
+
paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5"
|
|
971
|
+
) {
|
|
972
|
+
return "0-1";
|
|
973
|
+
}
|
|
974
|
+
if (
|
|
975
|
+
// this hubspotObjectTypeId only for main company ticket object type
|
|
976
|
+
paramDetails?.breadcrumbs?.length === 2 && paramDetails?.breadcrumbs[0]?.pt === "/0-5-c"
|
|
977
|
+
) {
|
|
978
|
+
return "0-2";
|
|
979
|
+
}
|
|
980
|
+
return "";
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
// src/main/core/utils/param.ts
|
|
984
|
+
function getParam(paramName) {
|
|
985
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
986
|
+
const hash = globalThis.location.hash || "";
|
|
987
|
+
if (!hash.startsWith("#/")) return null;
|
|
988
|
+
const hashWithoutHash = hash.startsWith("#") ? hash.substring(1) : hash;
|
|
989
|
+
const queryString = hashWithoutHash.split("?")[1];
|
|
990
|
+
if (!queryString) return null;
|
|
991
|
+
const params = new URLSearchParams(queryString);
|
|
992
|
+
return params.get(paramName);
|
|
993
|
+
}
|
|
994
|
+
function getPath() {
|
|
995
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return null;
|
|
996
|
+
const hash = globalThis.location.hash || "";
|
|
997
|
+
if (!hash.startsWith("#/")) return null;
|
|
998
|
+
return hash.slice(1).split("?")[0];
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// src/main/features/navigation/param.ts
|
|
1002
|
+
var getRouteMenu = (path) => {
|
|
1003
|
+
const apiRoutes = globalThis?.apiRoutes || [];
|
|
1004
|
+
return apiRoutes.find((menu) => menu?.path === path);
|
|
1005
|
+
};
|
|
1006
|
+
var getRouteDetails = () => {
|
|
1007
|
+
const search = getParam("b");
|
|
1008
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
1009
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
1010
|
+
const mapped = lastItem ? mapKeysDeep(lastItem, keyMap) : null;
|
|
1011
|
+
return { routeDetails: mapped };
|
|
1012
|
+
};
|
|
1013
|
+
var getParamDetails = (props, isDetailsPage = false) => {
|
|
1014
|
+
const search = getParam("b");
|
|
1015
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
1016
|
+
if (breadcrumbs.length > 0 && breadcrumbs?.[0]?.isHome) {
|
|
1017
|
+
breadcrumbs = breadcrumbs.slice(1);
|
|
1018
|
+
}
|
|
1019
|
+
let mediatorObjectTypeId = "";
|
|
1020
|
+
let mediatorObjectRecordId = "";
|
|
1021
|
+
let parentObjectTypeId = "";
|
|
1022
|
+
let parentObjectRecordId = "";
|
|
1023
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
1024
|
+
const lastItem2 = breadcrumbs[breadcrumbs.length - 2];
|
|
1025
|
+
const lastItem3 = breadcrumbs[breadcrumbs.length - 3];
|
|
1026
|
+
if (isDetailsPage === true && lastItem && "prm" in lastItem) {
|
|
1027
|
+
delete lastItem.prm;
|
|
1028
|
+
}
|
|
1029
|
+
if (breadcrumbs.length > 1) {
|
|
1030
|
+
if (props?.type === "ticket" || props?.type === "association") {
|
|
1031
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
1032
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
1033
|
+
parentObjectTypeId = lastItem?.o_t_id || "";
|
|
1034
|
+
parentObjectRecordId = lastItem?.o_r_id || "";
|
|
1035
|
+
} else {
|
|
1036
|
+
if (breadcrumbs.length > 2) {
|
|
1037
|
+
mediatorObjectTypeId = breadcrumbs[1]?.o_t_id || "";
|
|
1038
|
+
mediatorObjectRecordId = breadcrumbs[1]?.o_r_id || "";
|
|
1039
|
+
}
|
|
1040
|
+
if (!lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
1041
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
1042
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
1043
|
+
}
|
|
1044
|
+
if (lastItem?.o_r_id && breadcrumbs.length > 2) {
|
|
1045
|
+
parentObjectTypeId = lastItem3?.o_t_id || "";
|
|
1046
|
+
parentObjectRecordId = lastItem3?.o_r_id || "";
|
|
1047
|
+
}
|
|
1048
|
+
if (lastItem2?.o_t_id === "0-5" && !parentObjectTypeId && !parentObjectRecordId) {
|
|
1049
|
+
parentObjectTypeId = lastItem2?.o_t_id || "";
|
|
1050
|
+
parentObjectRecordId = lastItem2?.o_r_id || "";
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const paramsObject = {};
|
|
1055
|
+
if (breadcrumbs[0]?.prm?.isPC || breadcrumbs[1]?.prm?.isPC || lastItem?.prm?.isPC) {
|
|
1056
|
+
paramsObject["isPrimaryCompany"] = true;
|
|
1057
|
+
}
|
|
1058
|
+
if (parentObjectTypeId && parentObjectRecordId) {
|
|
1059
|
+
paramsObject["parentObjectTypeId"] = parentObjectTypeId;
|
|
1060
|
+
paramsObject["parentObjectRecordId"] = parentObjectRecordId;
|
|
1061
|
+
}
|
|
1062
|
+
if (mediatorObjectTypeId && mediatorObjectRecordId) {
|
|
1063
|
+
paramsObject["mediatorObjectTypeId"] = mediatorObjectTypeId;
|
|
1064
|
+
paramsObject["mediatorObjectRecordId"] = mediatorObjectRecordId;
|
|
1065
|
+
}
|
|
1066
|
+
const mappedLastItemParam = Object.fromEntries(
|
|
1067
|
+
Object.entries(lastItem?.prm || {}).map(([key, value]) => [
|
|
1068
|
+
keyMap[key] || key,
|
|
1069
|
+
// use mapped name if exists, else keep original
|
|
1070
|
+
value
|
|
1071
|
+
])
|
|
1072
|
+
);
|
|
1073
|
+
let queryString = null;
|
|
1074
|
+
if (props?.type === "association") {
|
|
1075
|
+
queryString = new URLSearchParams({ ...paramsObject, ...{ cache: false } }).toString();
|
|
1076
|
+
} else {
|
|
1077
|
+
queryString = new URLSearchParams({ ...paramsObject, ...mappedLastItemParam }).toString();
|
|
1078
|
+
}
|
|
1079
|
+
const params = queryString ? `?${queryString}` : "";
|
|
1080
|
+
const totalParentLength = getTotalParentLength(breadcrumbs);
|
|
1081
|
+
let parentAccessLabel = false;
|
|
1082
|
+
if (breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 || // company object
|
|
1083
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 3 || // normal object
|
|
1084
|
+
breadcrumbs[0]?.prm?.isPC && totalParentLength > 1 && props?.type === "ticket" || // company ticket
|
|
1085
|
+
!breadcrumbs[0]?.prm?.isPC && totalParentLength > 2 && props?.type === "ticket") {
|
|
1086
|
+
parentAccessLabel = true;
|
|
1087
|
+
}
|
|
1088
|
+
return {
|
|
1089
|
+
breadcrumbs,
|
|
1090
|
+
// paramsObject: Object.keys(mParamsObject).length === 0 ? null : mParamsObject,
|
|
1091
|
+
paramsObject,
|
|
1092
|
+
params,
|
|
1093
|
+
parentAccessLabel
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
// src/main/features/navigation/url.ts
|
|
1098
|
+
var updateLink = () => {
|
|
1099
|
+
const updateLink2 = async (props, displayName = "prm") => {
|
|
1100
|
+
const search = getParam("b");
|
|
1101
|
+
const pathname = getPath();
|
|
1102
|
+
let breadcrumbs = decodeToBase64(search) || [];
|
|
1103
|
+
if (breadcrumbs.length < 1) {
|
|
1104
|
+
const routeMenu = getRouteMenu(pathname);
|
|
1105
|
+
breadcrumbs = [
|
|
1106
|
+
{
|
|
1107
|
+
n: routeMenu?.title,
|
|
1108
|
+
pt: routeMenu?.path
|
|
1109
|
+
}
|
|
1110
|
+
];
|
|
1111
|
+
}
|
|
1112
|
+
const lastBreadcrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
1113
|
+
if (displayName) {
|
|
1114
|
+
const ex = await getDeep(lastBreadcrumb, displayName) || {};
|
|
1115
|
+
await setDeep(lastBreadcrumb, displayName, {
|
|
1116
|
+
...ex,
|
|
1117
|
+
...props
|
|
1118
|
+
});
|
|
1119
|
+
} else {
|
|
1120
|
+
await Object.assign(lastBreadcrumb, props);
|
|
1121
|
+
}
|
|
1122
|
+
const newBase64 = convertToBase64(breadcrumbs);
|
|
1123
|
+
updateBParam(newBase64);
|
|
1124
|
+
};
|
|
1125
|
+
function setDeep(obj, path, value) {
|
|
1126
|
+
const keys = path.split(".");
|
|
1127
|
+
let curr = obj;
|
|
1128
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
1129
|
+
if (!curr[keys[i]] || typeof curr[keys[i]] !== "object") {
|
|
1130
|
+
curr[keys[i]] = {};
|
|
1131
|
+
}
|
|
1132
|
+
curr = curr[keys[i]];
|
|
1133
|
+
}
|
|
1134
|
+
curr[keys[keys.length - 1]] = value;
|
|
1135
|
+
return curr;
|
|
1136
|
+
}
|
|
1137
|
+
function getDeep(obj, path) {
|
|
1138
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
1139
|
+
}
|
|
1140
|
+
const getLinkParams = (displayName = "prm") => {
|
|
1141
|
+
const search = getParam("b");
|
|
1142
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
1143
|
+
if (breadcrumbs.length < 1) return null;
|
|
1144
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
1145
|
+
const getDeep2 = (obj, path) => {
|
|
1146
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
1147
|
+
};
|
|
1148
|
+
const expandKeys = (obj) => {
|
|
1149
|
+
return Object.fromEntries(
|
|
1150
|
+
Object.entries(obj).map(([key, value]) => [
|
|
1151
|
+
keyMap[key] || key,
|
|
1152
|
+
// map if exists, else keep original
|
|
1153
|
+
value
|
|
1154
|
+
])
|
|
1155
|
+
);
|
|
1156
|
+
};
|
|
1157
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
1158
|
+
const output = nestedValue ? expandKeys(nestedValue) : null;
|
|
1159
|
+
return output;
|
|
1160
|
+
};
|
|
1161
|
+
const filterParams = (displayName = "prm") => {
|
|
1162
|
+
const search = getParam("b");
|
|
1163
|
+
const breadcrumbs = decodeToBase64(search) || [];
|
|
1164
|
+
if (breadcrumbs.length < 1) return null;
|
|
1165
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
1166
|
+
const getDeep2 = (obj, path) => {
|
|
1167
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
1168
|
+
};
|
|
1169
|
+
const expandKeys = (obj) => {
|
|
1170
|
+
return Object.fromEntries(
|
|
1171
|
+
Object.entries(obj).map(([key, value]) => [
|
|
1172
|
+
keyMap[key] || key,
|
|
1173
|
+
// map if exists, else keep original
|
|
1174
|
+
value
|
|
1175
|
+
])
|
|
1176
|
+
);
|
|
1177
|
+
};
|
|
1178
|
+
const nestedValue = displayName ? getDeep2(lastItem, displayName) : null;
|
|
1179
|
+
const output = nestedValue ? expandKeys(nestedValue) : expandKeys(lastItem);
|
|
1180
|
+
return output;
|
|
1181
|
+
};
|
|
1182
|
+
return { updateLink: updateLink2, getLinkParams, filterParams };
|
|
1183
|
+
};
|
|
1184
|
+
var updateBParam = (newValue) => {
|
|
1185
|
+
if (typeof globalThis === "undefined" || !globalThis.location) return;
|
|
1186
|
+
const hash = globalThis.location.hash || "";
|
|
1187
|
+
if (!hash.startsWith("#/")) return;
|
|
1188
|
+
const withoutHash = hash.slice(2);
|
|
1189
|
+
const [path, queryString] = withoutHash.split("?");
|
|
1190
|
+
const params = new URLSearchParams(queryString || "");
|
|
1191
|
+
params.set("b", newValue);
|
|
1192
|
+
const newHash = `#/${path}?${params.toString()}`;
|
|
1193
|
+
if (typeof globalThis !== "undefined" && globalThis.history && globalThis.history.replaceState) {
|
|
1194
|
+
globalThis.history.replaceState(null, "", newHash);
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
export { actions, actions2, actions3, actions4, actions5, actions6, actions7, breadcrumbStage, configureLogger, createStore, decodeToBase64, emailStore, generatePath, generateUrl, getParam, getParamDetails, getPath, getRouteDetails, getRouteMenu, isHttpTracingEnabled, isMessingParent, isMessingParentLastItem, logger, noteStore, resetAllStore, sanitizeAxiosErrorData, syncStore, tableStore, ticketHubspotObjectTypeId, updateLink, uploaderStore, userStore };
|
|
1199
|
+
//# sourceMappingURL=chunk-KBXI2JBA.js.map
|
|
1200
|
+
//# sourceMappingURL=chunk-KBXI2JBA.js.map
|