@fctc/edu-logic-lib 1.0.1 → 1.0.3
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/config.js +259 -4
- package/dist/config.mjs +255 -6
- package/dist/constants.js +154 -30
- package/dist/constants.mjs +140 -29
- package/dist/environment.js +841 -7
- package/dist/environment.mjs +840 -14
- package/dist/hooks.d.mts +2 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +4372 -283
- package/dist/hooks.mjs +4275 -237
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +5323 -0
- package/dist/index.mjs +5165 -0
- package/dist/models.js +3200 -18
- package/dist/models.mjs +3192 -18
- package/dist/provider.js +3179 -33
- package/dist/provider.mjs +3171 -33
- package/dist/services.js +4028 -9
- package/dist/services.mjs +4031 -25
- package/dist/store.js +582 -128
- package/dist/store.mjs +502 -111
- package/dist/types.js +2 -1
- package/dist/types.mjs +1 -0
- package/dist/utils.js +2346 -20
- package/dist/utils.mjs +2343 -33
- package/package.json +9 -6
- package/dist/chunk-6BLY7NZ6.mjs +0 -124
- package/dist/chunk-6QXB3XX7.mjs +0 -258
- package/dist/chunk-ELARQVCE.mjs +0 -2364
- package/dist/chunk-FVGPSTJ7.js +0 -124
- package/dist/chunk-GGOFXFSX.js +0 -2364
- package/dist/chunk-IXDDYGKE.js +0 -61
- package/dist/chunk-MJLXGYQ4.mjs +0 -102
- package/dist/chunk-MLJQPO4Q.mjs +0 -61
- package/dist/chunk-QLUONJPQ.mjs +0 -604
- package/dist/chunk-RZBHZYXG.js +0 -604
- package/dist/chunk-S7B3VKMJ.mjs +0 -95
- package/dist/chunk-S7YF2I23.js +0 -95
- package/dist/chunk-U4CC2BBB.js +0 -1074
- package/dist/chunk-UY6GNZNB.js +0 -258
- package/dist/chunk-W4W2L2NA.js +0 -102
- package/dist/chunk-WYXAE5LI.mjs +0 -1074
package/dist/hooks.mjs
CHANGED
|
@@ -1,29 +1,4121 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
|
+
import 'react-redux';
|
|
3
|
+
import { createSlice, configureStore } from '@reduxjs/toolkit';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import React, { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
// src/hooks/auth/use-forgot-password.ts
|
|
8
|
+
|
|
9
|
+
// src/constants/api/uri-constant.ts
|
|
10
|
+
var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
|
|
11
|
+
UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
|
|
12
|
+
UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
|
|
13
|
+
UriConstants2["CALL_PATH"] = "/call";
|
|
14
|
+
UriConstants2["COMPANY_PATH"] = "/company";
|
|
15
|
+
UriConstants2["PROFILE_PATH"] = "/userinfo";
|
|
16
|
+
UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
|
|
17
|
+
UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
|
|
18
|
+
UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
|
|
19
|
+
UriConstants2["LOAD_ACTION"] = `/load_action`;
|
|
20
|
+
UriConstants2["REPORT_PATH"] = `/report`;
|
|
21
|
+
UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
|
|
22
|
+
UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
|
|
23
|
+
UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
|
|
24
|
+
UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
|
|
25
|
+
UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
|
|
26
|
+
UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
|
|
27
|
+
UriConstants2["IMAGE_PATH"] = `/web/image`;
|
|
28
|
+
UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
|
|
29
|
+
UriConstants2["TOKEN"] = `/check_token`;
|
|
30
|
+
UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
|
|
31
|
+
UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
|
|
32
|
+
UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
|
|
33
|
+
return UriConstants2;
|
|
34
|
+
})(UriConstants || {});
|
|
35
|
+
var initialState = {
|
|
36
|
+
baseUrl: "",
|
|
37
|
+
requests: null,
|
|
38
|
+
companies: [],
|
|
39
|
+
user: {},
|
|
40
|
+
envFile: null,
|
|
41
|
+
defaultCompany: {
|
|
42
|
+
id: null,
|
|
43
|
+
logo: "",
|
|
44
|
+
secondary_color: "",
|
|
45
|
+
primary_color: ""
|
|
46
|
+
},
|
|
47
|
+
context: {
|
|
48
|
+
uid: null,
|
|
49
|
+
allowed_company_ids: [],
|
|
50
|
+
lang: "vi_VN",
|
|
51
|
+
tz: "Asia/Saigon"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var envSlice = createSlice({
|
|
55
|
+
name: "env",
|
|
56
|
+
initialState,
|
|
57
|
+
reducers: {
|
|
58
|
+
setEnv: (state, action) => {
|
|
59
|
+
Object.assign(state, action.payload);
|
|
60
|
+
},
|
|
61
|
+
setUid: (state, action) => {
|
|
62
|
+
state.context.uid = action.payload;
|
|
63
|
+
},
|
|
64
|
+
setAllowCompanies: (state, action) => {
|
|
65
|
+
state.context.allowed_company_ids = action.payload;
|
|
66
|
+
},
|
|
67
|
+
setCompanies: (state, action) => {
|
|
68
|
+
state.companies = action.payload;
|
|
69
|
+
},
|
|
70
|
+
setDefaultCompany: (state, action) => {
|
|
71
|
+
state.defaultCompany = action.payload;
|
|
72
|
+
},
|
|
73
|
+
setLang: (state, action) => {
|
|
74
|
+
state.context.lang = action.payload;
|
|
75
|
+
},
|
|
76
|
+
setUser: (state, action) => {
|
|
77
|
+
state.user = action.payload;
|
|
78
|
+
},
|
|
79
|
+
setEnvFile: (state, action) => {
|
|
80
|
+
state.envFile = action.payload;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var {
|
|
85
|
+
setEnv,
|
|
86
|
+
setUid,
|
|
87
|
+
setLang,
|
|
88
|
+
setAllowCompanies,
|
|
89
|
+
setCompanies,
|
|
90
|
+
setDefaultCompany,
|
|
91
|
+
setUser,
|
|
92
|
+
setEnvFile
|
|
93
|
+
} = envSlice.actions;
|
|
94
|
+
var env_slice_default = envSlice.reducer;
|
|
95
|
+
var initialState2 = {
|
|
96
|
+
dataParse: null,
|
|
97
|
+
idFile: null,
|
|
98
|
+
isFileLoaded: false,
|
|
99
|
+
loadingImport: false,
|
|
100
|
+
selectedFile: null,
|
|
101
|
+
errorData: null
|
|
102
|
+
};
|
|
103
|
+
var excelSlice = createSlice({
|
|
104
|
+
name: "excel",
|
|
105
|
+
initialState: initialState2,
|
|
106
|
+
reducers: {
|
|
107
|
+
setDataParse: (state, action) => {
|
|
108
|
+
state.dataParse = action.payload;
|
|
109
|
+
},
|
|
110
|
+
setIdFile: (state, action) => {
|
|
111
|
+
state.idFile = action.payload;
|
|
112
|
+
},
|
|
113
|
+
setIsFileLoaded: (state, action) => {
|
|
114
|
+
state.isFileLoaded = action.payload;
|
|
115
|
+
},
|
|
116
|
+
setLoadingImport: (state, action) => {
|
|
117
|
+
state.loadingImport = action.payload;
|
|
118
|
+
},
|
|
119
|
+
setSelectedFile: (state, action) => {
|
|
120
|
+
state.selectedFile = action.payload;
|
|
121
|
+
},
|
|
122
|
+
setErrorData: (state, action) => {
|
|
123
|
+
state.errorData = action.payload;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
var {
|
|
128
|
+
setDataParse,
|
|
129
|
+
setIdFile,
|
|
130
|
+
setIsFileLoaded,
|
|
131
|
+
setLoadingImport,
|
|
132
|
+
setSelectedFile,
|
|
133
|
+
setErrorData
|
|
134
|
+
} = excelSlice.actions;
|
|
135
|
+
var excel_slice_default = excelSlice.reducer;
|
|
136
|
+
var initialState3 = {
|
|
137
|
+
viewDataStore: {},
|
|
138
|
+
isShowingModalDetail: false,
|
|
139
|
+
isShowModalTranslate: false,
|
|
140
|
+
formSubmitComponent: {},
|
|
141
|
+
fieldTranslation: null,
|
|
142
|
+
listSubject: {},
|
|
143
|
+
dataUser: {}
|
|
144
|
+
};
|
|
145
|
+
var formSlice = createSlice({
|
|
146
|
+
name: "form",
|
|
147
|
+
initialState: initialState3,
|
|
148
|
+
reducers: {
|
|
149
|
+
setViewDataStore: (state, action) => {
|
|
150
|
+
state.viewDataStore = action.payload;
|
|
151
|
+
},
|
|
152
|
+
setIsShowingModalDetail: (state, action) => {
|
|
153
|
+
state.isShowingModalDetail = action.payload;
|
|
154
|
+
},
|
|
155
|
+
setIsShowModalTranslate: (state, action) => {
|
|
156
|
+
state.isShowModalTranslate = action.payload;
|
|
157
|
+
},
|
|
158
|
+
setFormSubmitComponent: (state, action) => {
|
|
159
|
+
state.formSubmitComponent[action.payload.key] = action.payload.component;
|
|
160
|
+
},
|
|
161
|
+
setFieldTranslate: (state, action) => {
|
|
162
|
+
state.fieldTranslation = action.payload;
|
|
163
|
+
},
|
|
164
|
+
setListSubject: (state, action) => {
|
|
165
|
+
state.listSubject = action.payload;
|
|
166
|
+
},
|
|
167
|
+
setDataUser: (state, action) => {
|
|
168
|
+
state.dataUser = action.payload;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var {
|
|
173
|
+
setViewDataStore,
|
|
174
|
+
setIsShowingModalDetail,
|
|
175
|
+
setIsShowModalTranslate,
|
|
176
|
+
setFormSubmitComponent,
|
|
177
|
+
setFieldTranslate,
|
|
178
|
+
setListSubject,
|
|
179
|
+
setDataUser
|
|
180
|
+
} = formSlice.actions;
|
|
181
|
+
var form_slice_default = formSlice.reducer;
|
|
182
|
+
var initialState4 = {
|
|
183
|
+
pageLimit: 10,
|
|
184
|
+
fields: {},
|
|
185
|
+
order: "",
|
|
186
|
+
selectedRowKeys: [],
|
|
187
|
+
indexRowTableModal: -2,
|
|
188
|
+
footerGroupTable: {},
|
|
189
|
+
page: 0,
|
|
190
|
+
domainTable: []
|
|
191
|
+
};
|
|
192
|
+
var listSlice = createSlice({
|
|
193
|
+
name: "list",
|
|
194
|
+
initialState: initialState4,
|
|
195
|
+
reducers: {
|
|
196
|
+
setPageLimit: (state, action) => {
|
|
197
|
+
state.pageLimit = action.payload;
|
|
198
|
+
},
|
|
199
|
+
setFields: (state, action) => {
|
|
200
|
+
state.fields = action.payload;
|
|
201
|
+
},
|
|
202
|
+
setOrder: (state, action) => {
|
|
203
|
+
state.order = action.payload;
|
|
204
|
+
},
|
|
205
|
+
setSelectedRowKeys: (state, action) => {
|
|
206
|
+
state.selectedRowKeys = action.payload;
|
|
207
|
+
},
|
|
208
|
+
setIndexRowTableModal: (state, action) => {
|
|
209
|
+
state.indexRowTableModal = action.payload;
|
|
210
|
+
},
|
|
211
|
+
setPage: (state, action) => {
|
|
212
|
+
state.page = action.payload;
|
|
213
|
+
},
|
|
214
|
+
setDomainTable: (state, action) => {
|
|
215
|
+
state.domainTable = action.payload;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
var {
|
|
220
|
+
setPageLimit,
|
|
221
|
+
setFields,
|
|
222
|
+
setOrder,
|
|
223
|
+
setSelectedRowKeys,
|
|
224
|
+
setIndexRowTableModal,
|
|
225
|
+
setPage,
|
|
226
|
+
setDomainTable
|
|
227
|
+
} = listSlice.actions;
|
|
228
|
+
var list_slice_default = listSlice.reducer;
|
|
229
|
+
var initialState5 = {
|
|
230
|
+
menuList: []
|
|
231
|
+
};
|
|
232
|
+
var navbarSlice = createSlice({
|
|
233
|
+
name: "navbar",
|
|
234
|
+
initialState: initialState5,
|
|
235
|
+
reducers: {
|
|
236
|
+
setMenuList: (state, action) => {
|
|
237
|
+
state.menuList = action.payload;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
var { setMenuList } = navbarSlice.actions;
|
|
242
|
+
var navbar_slice_default = navbarSlice.reducer;
|
|
243
|
+
var initialState6 = {
|
|
244
|
+
profile: {}
|
|
245
|
+
};
|
|
246
|
+
var profileSlice = createSlice({
|
|
247
|
+
name: "profile",
|
|
248
|
+
initialState: initialState6,
|
|
249
|
+
reducers: {
|
|
250
|
+
setProfile: (state, action) => {
|
|
251
|
+
state.profile = action.payload;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
var { setProfile } = profileSlice.actions;
|
|
256
|
+
var profile_slice_default = profileSlice.reducer;
|
|
257
|
+
var initialState7 = {
|
|
258
|
+
groupByDomain: null,
|
|
259
|
+
tableHead: [],
|
|
260
|
+
searchString: "",
|
|
261
|
+
hoveredIndexSearchList: null,
|
|
262
|
+
selectedTags: [],
|
|
263
|
+
firstDomain: null,
|
|
264
|
+
searchMap: {},
|
|
265
|
+
typeFieldsSearch: "",
|
|
266
|
+
modelSearch: "",
|
|
267
|
+
filterBy: [],
|
|
268
|
+
groupBy: []
|
|
269
|
+
};
|
|
270
|
+
var searchSlice = createSlice({
|
|
271
|
+
name: "search",
|
|
272
|
+
initialState: initialState7,
|
|
273
|
+
reducers: {
|
|
274
|
+
setGroupByDomain: (state, action) => {
|
|
275
|
+
state.groupByDomain = action.payload;
|
|
276
|
+
},
|
|
277
|
+
setTableHead: (state, action) => {
|
|
278
|
+
state.tableHead = action.payload;
|
|
279
|
+
},
|
|
280
|
+
setSearchString: (state, action) => {
|
|
281
|
+
state.searchString = action.payload;
|
|
282
|
+
},
|
|
283
|
+
setHoveredIndexSearchList: (state, action) => {
|
|
284
|
+
state.hoveredIndexSearchList = action.payload;
|
|
285
|
+
},
|
|
286
|
+
setSelectedTags: (state, action) => {
|
|
287
|
+
state.selectedTags = action.payload;
|
|
288
|
+
},
|
|
289
|
+
setFirstDomain: (state, action) => {
|
|
290
|
+
state.firstDomain = action.payload;
|
|
291
|
+
},
|
|
292
|
+
setTypeFieldsSearch: (state, action) => {
|
|
293
|
+
state.typeFieldsSearch = action.payload;
|
|
294
|
+
},
|
|
295
|
+
setModelSearch: (state, action) => {
|
|
296
|
+
state.modelSearch = action.payload;
|
|
297
|
+
},
|
|
298
|
+
setFilterBy: (state, action) => {
|
|
299
|
+
state.filterBy = action.payload;
|
|
300
|
+
},
|
|
301
|
+
setGroupBy: (state, action) => {
|
|
302
|
+
state.groupBy = action.payload;
|
|
303
|
+
},
|
|
304
|
+
setSearchMap: (state, action) => {
|
|
305
|
+
state.searchMap = action.payload;
|
|
306
|
+
},
|
|
307
|
+
updateSearchMap: (state, action) => {
|
|
308
|
+
if (!state.searchMap[action.payload.key]) {
|
|
309
|
+
state.searchMap[action.payload.key] = [];
|
|
310
|
+
}
|
|
311
|
+
state.searchMap[action.payload.key].push(action.payload.value);
|
|
312
|
+
},
|
|
313
|
+
removeKeyFromSearchMap: (state, action) => {
|
|
314
|
+
const { key, item } = action.payload;
|
|
315
|
+
const values = state.searchMap[key];
|
|
316
|
+
if (!values) return;
|
|
317
|
+
if (item) {
|
|
318
|
+
const filtered = values.filter((value) => value.name !== item.name);
|
|
319
|
+
if (filtered.length > 0) {
|
|
320
|
+
state.searchMap[key] = filtered;
|
|
321
|
+
} else {
|
|
322
|
+
delete state.searchMap[key];
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
delete state.searchMap[key];
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
clearSearchMap: (state) => {
|
|
329
|
+
state.searchMap = {};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
var {
|
|
334
|
+
setGroupByDomain,
|
|
335
|
+
setSelectedTags,
|
|
336
|
+
setSearchString,
|
|
337
|
+
setHoveredIndexSearchList,
|
|
338
|
+
setFirstDomain,
|
|
339
|
+
setTableHead,
|
|
340
|
+
setFilterBy,
|
|
341
|
+
setTypeFieldsSearch,
|
|
342
|
+
setModelSearch,
|
|
343
|
+
setSearchMap,
|
|
344
|
+
updateSearchMap,
|
|
345
|
+
removeKeyFromSearchMap,
|
|
346
|
+
setGroupBy,
|
|
347
|
+
clearSearchMap
|
|
348
|
+
} = searchSlice.actions;
|
|
349
|
+
var search_slice_default = searchSlice.reducer;
|
|
350
|
+
|
|
351
|
+
// node_modules/redux/dist/redux.mjs
|
|
352
|
+
function formatProdErrorMessage(code) {
|
|
353
|
+
return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
354
|
+
}
|
|
355
|
+
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
|
356
|
+
var ActionTypes = {
|
|
357
|
+
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
|
358
|
+
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
|
359
|
+
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
|
360
|
+
};
|
|
361
|
+
var actionTypes_default = ActionTypes;
|
|
362
|
+
function isPlainObject(obj) {
|
|
363
|
+
if (typeof obj !== "object" || obj === null)
|
|
364
|
+
return false;
|
|
365
|
+
let proto = obj;
|
|
366
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
367
|
+
proto = Object.getPrototypeOf(proto);
|
|
368
|
+
}
|
|
369
|
+
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
|
370
|
+
}
|
|
371
|
+
function miniKindOf(val) {
|
|
372
|
+
if (val === void 0)
|
|
373
|
+
return "undefined";
|
|
374
|
+
if (val === null)
|
|
375
|
+
return "null";
|
|
376
|
+
const type = typeof val;
|
|
377
|
+
switch (type) {
|
|
378
|
+
case "boolean":
|
|
379
|
+
case "string":
|
|
380
|
+
case "number":
|
|
381
|
+
case "symbol":
|
|
382
|
+
case "function": {
|
|
383
|
+
return type;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (Array.isArray(val))
|
|
387
|
+
return "array";
|
|
388
|
+
if (isDate(val))
|
|
389
|
+
return "date";
|
|
390
|
+
if (isError(val))
|
|
391
|
+
return "error";
|
|
392
|
+
const constructorName = ctorName(val);
|
|
393
|
+
switch (constructorName) {
|
|
394
|
+
case "Symbol":
|
|
395
|
+
case "Promise":
|
|
396
|
+
case "WeakMap":
|
|
397
|
+
case "WeakSet":
|
|
398
|
+
case "Map":
|
|
399
|
+
case "Set":
|
|
400
|
+
return constructorName;
|
|
401
|
+
}
|
|
402
|
+
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
403
|
+
}
|
|
404
|
+
function ctorName(val) {
|
|
405
|
+
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
406
|
+
}
|
|
407
|
+
function isError(val) {
|
|
408
|
+
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
409
|
+
}
|
|
410
|
+
function isDate(val) {
|
|
411
|
+
if (val instanceof Date)
|
|
412
|
+
return true;
|
|
413
|
+
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
414
|
+
}
|
|
415
|
+
function kindOf(val) {
|
|
416
|
+
let typeOfVal = typeof val;
|
|
417
|
+
if (process.env.NODE_ENV !== "production") {
|
|
418
|
+
typeOfVal = miniKindOf(val);
|
|
419
|
+
}
|
|
420
|
+
return typeOfVal;
|
|
421
|
+
}
|
|
422
|
+
function warning(message) {
|
|
423
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
424
|
+
console.error(message);
|
|
425
|
+
}
|
|
426
|
+
try {
|
|
427
|
+
throw new Error(message);
|
|
428
|
+
} catch (e) {
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
432
|
+
const reducerKeys = Object.keys(reducers);
|
|
433
|
+
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
434
|
+
if (reducerKeys.length === 0) {
|
|
435
|
+
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
436
|
+
}
|
|
437
|
+
if (!isPlainObject(inputState)) {
|
|
438
|
+
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
|
439
|
+
}
|
|
440
|
+
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
|
441
|
+
unexpectedKeys.forEach((key) => {
|
|
442
|
+
unexpectedKeyCache[key] = true;
|
|
443
|
+
});
|
|
444
|
+
if (action && action.type === actionTypes_default.REPLACE)
|
|
445
|
+
return;
|
|
446
|
+
if (unexpectedKeys.length > 0) {
|
|
447
|
+
return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function assertReducerShape(reducers) {
|
|
451
|
+
Object.keys(reducers).forEach((key) => {
|
|
452
|
+
const reducer = reducers[key];
|
|
453
|
+
const initialState8 = reducer(void 0, {
|
|
454
|
+
type: actionTypes_default.INIT
|
|
455
|
+
});
|
|
456
|
+
if (typeof initialState8 === "undefined") {
|
|
457
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
|
458
|
+
}
|
|
459
|
+
if (typeof reducer(void 0, {
|
|
460
|
+
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
|
461
|
+
}) === "undefined") {
|
|
462
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function combineReducers(reducers) {
|
|
467
|
+
const reducerKeys = Object.keys(reducers);
|
|
468
|
+
const finalReducers = {};
|
|
469
|
+
for (let i = 0; i < reducerKeys.length; i++) {
|
|
470
|
+
const key = reducerKeys[i];
|
|
471
|
+
if (process.env.NODE_ENV !== "production") {
|
|
472
|
+
if (typeof reducers[key] === "undefined") {
|
|
473
|
+
warning(`No reducer provided for key "${key}"`);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (typeof reducers[key] === "function") {
|
|
477
|
+
finalReducers[key] = reducers[key];
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const finalReducerKeys = Object.keys(finalReducers);
|
|
481
|
+
let unexpectedKeyCache;
|
|
482
|
+
if (process.env.NODE_ENV !== "production") {
|
|
483
|
+
unexpectedKeyCache = {};
|
|
484
|
+
}
|
|
485
|
+
let shapeAssertionError;
|
|
486
|
+
try {
|
|
487
|
+
assertReducerShape(finalReducers);
|
|
488
|
+
} catch (e) {
|
|
489
|
+
shapeAssertionError = e;
|
|
490
|
+
}
|
|
491
|
+
return function combination(state = {}, action) {
|
|
492
|
+
if (shapeAssertionError) {
|
|
493
|
+
throw shapeAssertionError;
|
|
494
|
+
}
|
|
495
|
+
if (process.env.NODE_ENV !== "production") {
|
|
496
|
+
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
497
|
+
if (warningMessage) {
|
|
498
|
+
warning(warningMessage);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
let hasChanged = false;
|
|
502
|
+
const nextState = {};
|
|
503
|
+
for (let i = 0; i < finalReducerKeys.length; i++) {
|
|
504
|
+
const key = finalReducerKeys[i];
|
|
505
|
+
const reducer = finalReducers[key];
|
|
506
|
+
const previousStateForKey = state[key];
|
|
507
|
+
const nextStateForKey = reducer(previousStateForKey, action);
|
|
508
|
+
if (typeof nextStateForKey === "undefined") {
|
|
509
|
+
const actionType = action && action.type;
|
|
510
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
|
|
511
|
+
}
|
|
512
|
+
nextState[key] = nextStateForKey;
|
|
513
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
514
|
+
}
|
|
515
|
+
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
516
|
+
return hasChanged ? nextState : state;
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// src/store/store.ts
|
|
521
|
+
var rootReducer = combineReducers({
|
|
522
|
+
env: env_slice_default,
|
|
523
|
+
navbar: navbar_slice_default,
|
|
524
|
+
list: list_slice_default,
|
|
525
|
+
search: search_slice_default,
|
|
526
|
+
form: form_slice_default,
|
|
527
|
+
excel: excel_slice_default,
|
|
528
|
+
profile: profile_slice_default
|
|
529
|
+
});
|
|
530
|
+
var envStore = configureStore({
|
|
531
|
+
reducer: rootReducer,
|
|
532
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
533
|
+
serializableCheck: false
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
var MAINT_KEY = "MAINTENANCE_ACTIVE";
|
|
537
|
+
var MAINT_AT = "MAINTENANCE_AT";
|
|
538
|
+
var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
|
|
539
|
+
var hasRedirectedToMaintenance = false;
|
|
540
|
+
function setMaintenanceFlags() {
|
|
541
|
+
if (typeof window === "undefined") return;
|
|
542
|
+
const { pathname, search } = window.location;
|
|
543
|
+
const lastPath = pathname + (search || "");
|
|
544
|
+
if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
|
|
545
|
+
window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
|
|
546
|
+
}
|
|
547
|
+
window.localStorage.setItem(MAINT_KEY, "true");
|
|
548
|
+
window.localStorage.setItem(MAINT_AT, String(Date.now()));
|
|
549
|
+
}
|
|
550
|
+
async function clearMaintenanceAndExit(getToken, opts) {
|
|
551
|
+
if (typeof window === "undefined") return;
|
|
552
|
+
const forceLogin = opts?.forceLogin === true;
|
|
553
|
+
const clearTokenOnForce = opts?.clearTokenOnForce !== false;
|
|
554
|
+
window.localStorage.removeItem(MAINT_KEY);
|
|
555
|
+
window.localStorage.removeItem(MAINT_AT);
|
|
556
|
+
const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
|
|
557
|
+
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
558
|
+
try {
|
|
559
|
+
if (forceLogin) {
|
|
560
|
+
if (clearTokenOnForce) {
|
|
561
|
+
try {
|
|
562
|
+
await opts?.clearToken?.();
|
|
563
|
+
} catch {
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
window.location.replace("/login");
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const token = await getToken();
|
|
570
|
+
if (token) {
|
|
571
|
+
const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
|
|
572
|
+
window.location.replace(target);
|
|
573
|
+
} else {
|
|
574
|
+
window.location.replace("/login");
|
|
575
|
+
}
|
|
576
|
+
} catch {
|
|
577
|
+
window.location.replace("/login");
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
var axiosClient = {
|
|
581
|
+
init(config) {
|
|
582
|
+
const localStorage = config.localStorageUtils;
|
|
583
|
+
const sessionStorage = config.sessionStorageUtils;
|
|
584
|
+
const db = config.db;
|
|
585
|
+
let isRefreshing = false;
|
|
586
|
+
let failedQueue = [];
|
|
587
|
+
const processQueue = (error, token = null) => {
|
|
588
|
+
failedQueue?.forEach((prom) => {
|
|
589
|
+
if (error) {
|
|
590
|
+
prom.reject(error);
|
|
591
|
+
} else {
|
|
592
|
+
prom.resolve(token);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
failedQueue = [];
|
|
596
|
+
};
|
|
597
|
+
const instance = axios.create({
|
|
598
|
+
adapter: axios.defaults.adapter,
|
|
599
|
+
baseURL: config.baseUrl,
|
|
600
|
+
timeout: 5e4,
|
|
601
|
+
paramsSerializer: (params) => new URLSearchParams(params).toString()
|
|
602
|
+
});
|
|
603
|
+
if (typeof window !== "undefined") {
|
|
604
|
+
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
605
|
+
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
606
|
+
if (isMaint && !onMaintenancePage) {
|
|
607
|
+
hasRedirectedToMaintenance = true;
|
|
608
|
+
window.location.replace("/maintenance");
|
|
609
|
+
}
|
|
610
|
+
if (isMaint && onMaintenancePage) {
|
|
611
|
+
const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
|
|
612
|
+
(async () => {
|
|
613
|
+
try {
|
|
614
|
+
await axios.get(healthUrl, { timeout: 8e3 });
|
|
615
|
+
await clearMaintenanceAndExit(() => localStorage.getAccessToken(), {
|
|
616
|
+
forceLogin: true,
|
|
617
|
+
clearTokenOnForce: true,
|
|
618
|
+
clearToken: () => localStorage.clearToken()
|
|
619
|
+
});
|
|
620
|
+
} catch {
|
|
621
|
+
}
|
|
622
|
+
})();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
instance.interceptors.request.use(
|
|
626
|
+
async (configReq) => {
|
|
627
|
+
const token = await localStorage.getAccessToken();
|
|
628
|
+
if (token) {
|
|
629
|
+
configReq.headers["Authorization"] = "Bearer " + token;
|
|
630
|
+
}
|
|
631
|
+
return configReq;
|
|
632
|
+
},
|
|
633
|
+
(error) => Promise.reject(error)
|
|
634
|
+
);
|
|
635
|
+
instance.interceptors.response.use(
|
|
636
|
+
(response) => {
|
|
637
|
+
if (typeof window !== "undefined") {
|
|
638
|
+
const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
|
|
639
|
+
const onMaintenancePage = window.location.pathname === "/maintenance";
|
|
640
|
+
if (isMaint && onMaintenancePage) {
|
|
641
|
+
(async () => {
|
|
642
|
+
await clearMaintenanceAndExit(
|
|
643
|
+
() => localStorage.getAccessToken(),
|
|
644
|
+
{
|
|
645
|
+
forceLogin: true,
|
|
646
|
+
clearTokenOnForce: true,
|
|
647
|
+
clearToken: () => localStorage.clearToken()
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
})();
|
|
651
|
+
} else if (isMaint) {
|
|
652
|
+
window.localStorage.removeItem(MAINT_KEY);
|
|
653
|
+
window.localStorage.removeItem(MAINT_AT);
|
|
654
|
+
window.localStorage.removeItem(MAINT_LAST_PATH);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return handleResponse(response);
|
|
658
|
+
},
|
|
659
|
+
async (error) => {
|
|
660
|
+
const status = error?.response?.status;
|
|
661
|
+
if (status === 503) {
|
|
662
|
+
if (typeof window !== "undefined") {
|
|
663
|
+
setMaintenanceFlags();
|
|
664
|
+
if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
|
|
665
|
+
hasRedirectedToMaintenance = true;
|
|
666
|
+
window.location.replace("/maintenance");
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return Promise.reject({
|
|
670
|
+
code: 503,
|
|
671
|
+
message: "SERVICE_UNAVAILABLE",
|
|
672
|
+
original: error?.response?.data
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
const handleError = async (err) => {
|
|
676
|
+
if (!err.response) {
|
|
677
|
+
return err;
|
|
678
|
+
}
|
|
679
|
+
const { data } = err.response;
|
|
680
|
+
if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
|
|
681
|
+
await clearAuthToken();
|
|
682
|
+
}
|
|
683
|
+
return data;
|
|
684
|
+
};
|
|
685
|
+
const originalRequest = error.config;
|
|
686
|
+
if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
|
|
687
|
+
error.response.data.code
|
|
688
|
+
)) {
|
|
689
|
+
if (isRefreshing) {
|
|
690
|
+
return new Promise(function(resolve, reject) {
|
|
691
|
+
failedQueue.push({ resolve, reject });
|
|
692
|
+
}).then((token) => {
|
|
693
|
+
originalRequest.headers["Authorization"] = "Bearer " + token;
|
|
694
|
+
return instance.request(originalRequest);
|
|
695
|
+
}).catch(async (err) => {
|
|
696
|
+
if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
|
|
697
|
+
await clearAuthToken();
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
const browserSession = await sessionStorage.getBrowserSession();
|
|
702
|
+
const refreshToken = await localStorage.getRefreshToken();
|
|
703
|
+
const accessTokenExp = await localStorage.getAccessToken();
|
|
704
|
+
isRefreshing = true;
|
|
705
|
+
if (!refreshToken && (!browserSession || browserSession == "unActive")) {
|
|
706
|
+
await clearAuthToken();
|
|
707
|
+
} else {
|
|
708
|
+
const payload = Object.fromEntries(
|
|
709
|
+
Object.entries({
|
|
710
|
+
refresh_token: refreshToken,
|
|
711
|
+
grant_type: "refresh_token",
|
|
712
|
+
client_id: config.config.clientId,
|
|
713
|
+
client_secret: config.config.clientSecret
|
|
714
|
+
}).filter(([_, value]) => !!value)
|
|
715
|
+
);
|
|
716
|
+
return new Promise(function(resolve) {
|
|
717
|
+
axios.post(
|
|
718
|
+
`${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
|
|
719
|
+
payload,
|
|
720
|
+
{
|
|
721
|
+
headers: {
|
|
722
|
+
"Content-Type": "multipart/form-data",
|
|
723
|
+
Authorization: `Bearer ${accessTokenExp}`
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
).then(async (res) => {
|
|
727
|
+
const data = res.data;
|
|
728
|
+
await localStorage.setToken(data.access_token);
|
|
729
|
+
await localStorage.setRefreshToken(data.refresh_token);
|
|
730
|
+
axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
|
|
731
|
+
originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
|
|
732
|
+
processQueue(null, data.access_token);
|
|
733
|
+
resolve(instance.request(originalRequest));
|
|
734
|
+
}).catch(async (err) => {
|
|
735
|
+
if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
|
|
736
|
+
await clearAuthToken();
|
|
737
|
+
}
|
|
738
|
+
if (err && err.response) {
|
|
739
|
+
const { error_code } = err.response?.data || {};
|
|
740
|
+
if (error_code === "AUTHEN_FAIL") {
|
|
741
|
+
await clearAuthToken();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
processQueue(err, null);
|
|
745
|
+
}).finally(() => {
|
|
746
|
+
isRefreshing = false;
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return Promise.reject(await handleError(error));
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
const handleResponse = (res) => {
|
|
755
|
+
if (res && res.data) {
|
|
756
|
+
return res.data;
|
|
757
|
+
}
|
|
758
|
+
return res;
|
|
759
|
+
};
|
|
760
|
+
const clearAuthToken = async () => {
|
|
761
|
+
await localStorage.clearToken();
|
|
762
|
+
if (typeof window !== "undefined") {
|
|
763
|
+
window.location.href = `/login`;
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
function formatUrl(url, db2) {
|
|
767
|
+
return url + (db2 ? "?db=" + db2 : "");
|
|
768
|
+
}
|
|
769
|
+
const responseBody = (response) => response;
|
|
770
|
+
const requests = {
|
|
771
|
+
get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
|
|
772
|
+
post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
|
|
773
|
+
post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
|
|
774
|
+
responseType: "arraybuffer",
|
|
775
|
+
headers: {
|
|
776
|
+
"Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
|
|
777
|
+
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
778
|
+
}
|
|
779
|
+
}).then(responseBody),
|
|
780
|
+
put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
|
|
781
|
+
patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
|
|
782
|
+
delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
|
|
783
|
+
};
|
|
784
|
+
return requests;
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
// src/environment/EnvStore.ts
|
|
789
|
+
var EnvStore = class {
|
|
790
|
+
envStore;
|
|
791
|
+
baseUrl;
|
|
792
|
+
requests;
|
|
793
|
+
context;
|
|
794
|
+
defaultCompany;
|
|
795
|
+
config;
|
|
796
|
+
companies;
|
|
797
|
+
user;
|
|
798
|
+
db;
|
|
799
|
+
localStorageUtils;
|
|
800
|
+
sessionStorageUtils;
|
|
801
|
+
constructor(envStore2, localStorageUtils, sessionStorageUtils) {
|
|
802
|
+
this.envStore = envStore2;
|
|
803
|
+
this.localStorageUtils = localStorageUtils;
|
|
804
|
+
this.sessionStorageUtils = sessionStorageUtils;
|
|
805
|
+
this.setup();
|
|
806
|
+
}
|
|
807
|
+
setup() {
|
|
808
|
+
const env2 = this.envStore.getState().env;
|
|
809
|
+
this.baseUrl = env2?.baseUrl;
|
|
810
|
+
this.requests = env2?.requests;
|
|
811
|
+
this.context = env2?.context;
|
|
812
|
+
this.defaultCompany = env2?.defaultCompany;
|
|
813
|
+
this.config = env2?.config;
|
|
814
|
+
this.companies = env2?.companies || [];
|
|
815
|
+
this.user = env2?.user;
|
|
816
|
+
this.db = env2?.db;
|
|
817
|
+
}
|
|
818
|
+
setupEnv(envConfig) {
|
|
819
|
+
const dispatch = this.envStore.dispatch;
|
|
820
|
+
const env2 = {
|
|
821
|
+
...envConfig,
|
|
822
|
+
localStorageUtils: this.localStorageUtils,
|
|
823
|
+
sessionStorageUtils: this.sessionStorageUtils
|
|
824
|
+
};
|
|
825
|
+
const requests = axiosClient.init(env2);
|
|
826
|
+
dispatch(setEnv({ ...env2, requests }));
|
|
827
|
+
this.setup();
|
|
828
|
+
}
|
|
829
|
+
setUid(uid) {
|
|
830
|
+
const dispatch = this.envStore.dispatch;
|
|
831
|
+
dispatch(setUid(uid));
|
|
832
|
+
this.setup();
|
|
833
|
+
}
|
|
834
|
+
setLang(lang) {
|
|
835
|
+
const dispatch = this.envStore.dispatch;
|
|
836
|
+
dispatch(setLang(lang));
|
|
837
|
+
this.setup();
|
|
838
|
+
}
|
|
839
|
+
setAllowCompanies(allowCompanies) {
|
|
840
|
+
const dispatch = this.envStore.dispatch;
|
|
841
|
+
dispatch(setAllowCompanies(allowCompanies));
|
|
842
|
+
this.setup();
|
|
843
|
+
}
|
|
844
|
+
setCompanies(companies) {
|
|
845
|
+
const dispatch = this.envStore.dispatch;
|
|
846
|
+
dispatch(setCompanies(companies));
|
|
847
|
+
this.setup();
|
|
848
|
+
}
|
|
849
|
+
setDefaultCompany(company) {
|
|
850
|
+
const dispatch = this.envStore.dispatch;
|
|
851
|
+
dispatch(setDefaultCompany(company));
|
|
852
|
+
this.setup();
|
|
853
|
+
}
|
|
854
|
+
setUserInfo(userInfo) {
|
|
855
|
+
const dispatch = this.envStore.dispatch;
|
|
856
|
+
dispatch(setUser(userInfo));
|
|
857
|
+
this.setup();
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
var env = null;
|
|
861
|
+
function getEnv() {
|
|
862
|
+
if (!env) env = new EnvStore(envStore);
|
|
863
|
+
return env;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// src/utils/domain/py_tokenizer.ts
|
|
867
|
+
var TokenizerError = class extends Error {
|
|
868
|
+
};
|
|
869
|
+
var directMap = {
|
|
870
|
+
"\\": "\\",
|
|
871
|
+
'"': '"',
|
|
872
|
+
"'": "'",
|
|
873
|
+
a: "\x07",
|
|
874
|
+
b: "\b",
|
|
875
|
+
f: "\f",
|
|
876
|
+
n: "\n",
|
|
877
|
+
r: "\r",
|
|
878
|
+
t: " ",
|
|
879
|
+
v: "\v"
|
|
880
|
+
};
|
|
881
|
+
function decodeStringLiteral(str, unicode) {
|
|
882
|
+
const out = [];
|
|
883
|
+
let code;
|
|
884
|
+
for (let i = 0; i < str.length; ++i) {
|
|
885
|
+
if (str[i] !== "\\") {
|
|
886
|
+
out.push(str[i]);
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
const escape = str[i + 1];
|
|
890
|
+
if (escape in directMap) {
|
|
891
|
+
out.push(directMap[escape]);
|
|
892
|
+
++i;
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
switch (escape) {
|
|
896
|
+
case "\n":
|
|
897
|
+
++i;
|
|
898
|
+
continue;
|
|
899
|
+
case "N":
|
|
900
|
+
if (!unicode) {
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
|
|
904
|
+
case "u":
|
|
905
|
+
if (!unicode) {
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
const uni = str.slice(i + 2, i + 6);
|
|
909
|
+
if (!/[0-9a-f]{4}/i.test(uni)) {
|
|
910
|
+
throw new TokenizerError(
|
|
911
|
+
[
|
|
912
|
+
"SyntaxError: (unicode error) 'unicodeescape' codec",
|
|
913
|
+
" can't decode bytes in position ",
|
|
914
|
+
i,
|
|
915
|
+
"-",
|
|
916
|
+
i + 4,
|
|
917
|
+
": truncated \\uXXXX escape"
|
|
918
|
+
].join("")
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
code = parseInt(uni, 16);
|
|
922
|
+
out.push(String.fromCharCode(code));
|
|
923
|
+
i += 5;
|
|
924
|
+
continue;
|
|
925
|
+
case "U":
|
|
926
|
+
if (!unicode) {
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
throw new TokenizerError("SyntaxError: \\U escape not implemented");
|
|
930
|
+
case "x":
|
|
931
|
+
const hex = str.slice(i + 2, i + 4);
|
|
932
|
+
if (!/[0-9a-f]{2}/i.test(hex)) {
|
|
933
|
+
if (!unicode) {
|
|
934
|
+
throw new TokenizerError("ValueError: invalid \\x escape");
|
|
935
|
+
}
|
|
936
|
+
throw new TokenizerError(
|
|
937
|
+
[
|
|
938
|
+
"SyntaxError: (unicode error) 'unicodeescape'",
|
|
939
|
+
" codec can't decode bytes in position ",
|
|
940
|
+
i,
|
|
941
|
+
"-",
|
|
942
|
+
i + 2,
|
|
943
|
+
": truncated \\xXX escape"
|
|
944
|
+
].join("")
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
code = parseInt(hex, 16);
|
|
948
|
+
out.push(String.fromCharCode(code));
|
|
949
|
+
i += 3;
|
|
950
|
+
continue;
|
|
951
|
+
default:
|
|
952
|
+
if (!/[0-8]/.test(escape)) {
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
const r = /[0-8]{1,3}/g;
|
|
956
|
+
r.lastIndex = i + 1;
|
|
957
|
+
const m = r.exec(str);
|
|
958
|
+
if (!m) break;
|
|
959
|
+
const oct = m[0];
|
|
960
|
+
code = parseInt(oct, 8);
|
|
961
|
+
out.push(String.fromCharCode(code));
|
|
962
|
+
i += oct.length;
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
out.push("\\");
|
|
966
|
+
}
|
|
967
|
+
return out.join("");
|
|
968
|
+
}
|
|
969
|
+
var constants = /* @__PURE__ */ new Set(["None", "False", "True"]);
|
|
970
|
+
var comparators = [
|
|
971
|
+
"in",
|
|
972
|
+
"not",
|
|
973
|
+
"not in",
|
|
974
|
+
"is",
|
|
975
|
+
"is not",
|
|
976
|
+
"<",
|
|
977
|
+
"<=",
|
|
978
|
+
">",
|
|
979
|
+
">=",
|
|
980
|
+
"<>",
|
|
981
|
+
"!=",
|
|
982
|
+
"=="
|
|
983
|
+
];
|
|
984
|
+
var binaryOperators = [
|
|
985
|
+
"or",
|
|
986
|
+
"and",
|
|
987
|
+
"|",
|
|
988
|
+
"^",
|
|
989
|
+
"&",
|
|
990
|
+
"<<",
|
|
991
|
+
">>",
|
|
992
|
+
"+",
|
|
993
|
+
"-",
|
|
994
|
+
"*",
|
|
995
|
+
"/",
|
|
996
|
+
"//",
|
|
997
|
+
"%",
|
|
998
|
+
"~",
|
|
999
|
+
"**",
|
|
1000
|
+
"."
|
|
1001
|
+
];
|
|
1002
|
+
var unaryOperators = ["-"];
|
|
1003
|
+
var symbols = /* @__PURE__ */ new Set([
|
|
1004
|
+
...["(", ")", "[", "]", "{", "}", ":", ","],
|
|
1005
|
+
...["if", "else", "lambda", "="],
|
|
1006
|
+
...comparators,
|
|
1007
|
+
...binaryOperators,
|
|
1008
|
+
...unaryOperators
|
|
1009
|
+
]);
|
|
1010
|
+
function group(...args) {
|
|
1011
|
+
return "(" + args.join("|") + ")";
|
|
1012
|
+
}
|
|
1013
|
+
var Name = "[a-zA-Z_]\\w*";
|
|
1014
|
+
var Whitespace = "[ \\f\\t]*";
|
|
1015
|
+
var DecNumber = "\\d+(L|l)?";
|
|
1016
|
+
var IntNumber = DecNumber;
|
|
1017
|
+
var Exponent = "[eE][+-]?\\d+";
|
|
1018
|
+
var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
|
|
1019
|
+
var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
|
|
1020
|
+
var Number2 = group(FloatNumber, IntNumber);
|
|
1021
|
+
var Operator = group(
|
|
1022
|
+
"\\*\\*=?",
|
|
1023
|
+
">>=?",
|
|
1024
|
+
"<<=?",
|
|
1025
|
+
"<>",
|
|
1026
|
+
"!=",
|
|
1027
|
+
"//=?",
|
|
1028
|
+
"[+\\-*/%&|^=<>]=?",
|
|
1029
|
+
"~"
|
|
1030
|
+
);
|
|
1031
|
+
var Bracket = "[\\[\\]\\(\\)\\{\\}]";
|
|
1032
|
+
var Special = "[:;.,`@]";
|
|
1033
|
+
var Funny = group(Operator, Bracket, Special);
|
|
1034
|
+
var ContStr = group(
|
|
1035
|
+
"([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
|
|
1036
|
+
'([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
|
|
1037
|
+
);
|
|
1038
|
+
var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
|
|
1039
|
+
var NumberPattern = new RegExp("^" + Number2 + "$");
|
|
1040
|
+
var StringPattern = new RegExp("^" + ContStr + "$");
|
|
1041
|
+
var NamePattern = new RegExp("^" + Name + "$");
|
|
1042
|
+
var strip = new RegExp("^" + Whitespace);
|
|
1043
|
+
function tokenize(str) {
|
|
1044
|
+
const tokens = [];
|
|
1045
|
+
const max = str.length;
|
|
1046
|
+
let start = 0;
|
|
1047
|
+
let end = 0;
|
|
1048
|
+
const pseudoprog = new RegExp(PseudoToken, "g");
|
|
1049
|
+
while (pseudoprog.lastIndex < max) {
|
|
1050
|
+
const pseudomatch = pseudoprog.exec(str);
|
|
1051
|
+
if (!pseudomatch) {
|
|
1052
|
+
if (/^\s+$/.test(str.slice(end))) {
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
throw new TokenizerError(
|
|
1056
|
+
"Failed to tokenize <<" + str + ">> at index " + (end || 0) + "; parsed so far: " + tokens
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
if (pseudomatch.index > end) {
|
|
1060
|
+
if (str.slice(end, pseudomatch.index).trim()) {
|
|
1061
|
+
throw new TokenizerError("Invalid expression");
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
start = pseudomatch.index;
|
|
1065
|
+
end = pseudoprog.lastIndex;
|
|
1066
|
+
let token = str.slice(start, end).replace(strip, "");
|
|
1067
|
+
if (NumberPattern.test(token)) {
|
|
1068
|
+
tokens.push({
|
|
1069
|
+
type: 0,
|
|
1070
|
+
value: parseFloat(token)
|
|
1071
|
+
});
|
|
1072
|
+
} else if (StringPattern.test(token)) {
|
|
1073
|
+
const m = StringPattern.exec(token);
|
|
1074
|
+
if (!m) throw new TokenizerError("Invalid string match");
|
|
1075
|
+
tokens.push({
|
|
1076
|
+
type: 1,
|
|
1077
|
+
value: decodeStringLiteral(
|
|
1078
|
+
m[3] !== void 0 ? m[3] : m[5],
|
|
1079
|
+
!!(m[2] || m[4])
|
|
1080
|
+
)
|
|
1081
|
+
});
|
|
1082
|
+
} else if (symbols.has(token)) {
|
|
1083
|
+
if (token === "in" && tokens.length > 0 && tokens[tokens.length - 1].value === "not") {
|
|
1084
|
+
token = "not in";
|
|
1085
|
+
tokens.pop();
|
|
1086
|
+
} else if (token === "not" && tokens.length > 0 && tokens[tokens.length - 1].value === "is") {
|
|
1087
|
+
token = "is not";
|
|
1088
|
+
tokens.pop();
|
|
1089
|
+
}
|
|
1090
|
+
tokens.push({
|
|
1091
|
+
type: 2,
|
|
1092
|
+
value: token
|
|
1093
|
+
});
|
|
1094
|
+
} else if (constants.has(token)) {
|
|
1095
|
+
tokens.push({
|
|
1096
|
+
type: 4,
|
|
1097
|
+
value: token
|
|
1098
|
+
});
|
|
1099
|
+
} else if (NamePattern.test(token)) {
|
|
1100
|
+
tokens.push({
|
|
1101
|
+
type: 3,
|
|
1102
|
+
value: token
|
|
1103
|
+
});
|
|
1104
|
+
} else {
|
|
1105
|
+
throw new TokenizerError("Invalid expression");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return tokens;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// src/utils/domain/py_parser.ts
|
|
1112
|
+
var ParserError = class extends Error {
|
|
1113
|
+
};
|
|
1114
|
+
var chainedOperators = new Set(comparators);
|
|
1115
|
+
var infixOperators = /* @__PURE__ */ new Set([...binaryOperators, ...comparators]);
|
|
1116
|
+
function bp(symbol) {
|
|
1117
|
+
switch (symbol) {
|
|
1118
|
+
case "=":
|
|
1119
|
+
return 10;
|
|
1120
|
+
case "if":
|
|
1121
|
+
return 20;
|
|
1122
|
+
case "in":
|
|
1123
|
+
case "not in":
|
|
1124
|
+
case "is":
|
|
1125
|
+
case "is not":
|
|
1126
|
+
case "<":
|
|
1127
|
+
case "<=":
|
|
1128
|
+
case ">":
|
|
1129
|
+
case ">=":
|
|
1130
|
+
case "<>":
|
|
1131
|
+
case "==":
|
|
1132
|
+
case "!=":
|
|
1133
|
+
return 60;
|
|
1134
|
+
case "or":
|
|
1135
|
+
return 30;
|
|
1136
|
+
case "and":
|
|
1137
|
+
return 40;
|
|
1138
|
+
case "not":
|
|
1139
|
+
return 50;
|
|
1140
|
+
case "|":
|
|
1141
|
+
return 70;
|
|
1142
|
+
case "^":
|
|
1143
|
+
return 80;
|
|
1144
|
+
case "&":
|
|
1145
|
+
return 90;
|
|
1146
|
+
case "<<":
|
|
1147
|
+
case ">>":
|
|
1148
|
+
return 100;
|
|
1149
|
+
case "+":
|
|
1150
|
+
case "-":
|
|
1151
|
+
return 110;
|
|
1152
|
+
case "*":
|
|
1153
|
+
case "/":
|
|
1154
|
+
case "//":
|
|
1155
|
+
case "%":
|
|
1156
|
+
return 120;
|
|
1157
|
+
case "**":
|
|
1158
|
+
return 140;
|
|
1159
|
+
case ".":
|
|
1160
|
+
case "(":
|
|
1161
|
+
case "[":
|
|
1162
|
+
return 150;
|
|
1163
|
+
default:
|
|
1164
|
+
return 0;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function bindingPower(token) {
|
|
1168
|
+
return token.type === 2 ? bp(token.value) : 0;
|
|
1169
|
+
}
|
|
1170
|
+
function isSymbol(token, value) {
|
|
1171
|
+
return token.type === 2 && token.value === value;
|
|
1172
|
+
}
|
|
1173
|
+
function parsePrefix(current, tokens) {
|
|
1174
|
+
switch (current.type) {
|
|
1175
|
+
case 0:
|
|
1176
|
+
return { type: 0, value: current.value };
|
|
1177
|
+
case 1:
|
|
1178
|
+
return { type: 1, value: current.value };
|
|
1179
|
+
case 4:
|
|
1180
|
+
if (current.value === "None") {
|
|
1181
|
+
return {
|
|
1182
|
+
type: 3
|
|
1183
|
+
/* None */
|
|
1184
|
+
};
|
|
1185
|
+
} else {
|
|
1186
|
+
return { type: 2, value: current.value === "True" };
|
|
1187
|
+
}
|
|
1188
|
+
case 3:
|
|
1189
|
+
return { type: 5, value: current.value };
|
|
1190
|
+
case 2:
|
|
1191
|
+
switch (current.value) {
|
|
1192
|
+
case "-":
|
|
1193
|
+
case "+":
|
|
1194
|
+
case "~":
|
|
1195
|
+
return {
|
|
1196
|
+
type: 6,
|
|
1197
|
+
op: current.value,
|
|
1198
|
+
right: _parse(tokens, 130)
|
|
1199
|
+
};
|
|
1200
|
+
case "not":
|
|
1201
|
+
return {
|
|
1202
|
+
type: 6,
|
|
1203
|
+
op: current.value,
|
|
1204
|
+
right: _parse(tokens, 50)
|
|
1205
|
+
};
|
|
1206
|
+
case "(":
|
|
1207
|
+
const content = [];
|
|
1208
|
+
let isTuple = false;
|
|
1209
|
+
while (tokens[0] && !isSymbol(tokens[0], ")")) {
|
|
1210
|
+
content.push(_parse(tokens, 0));
|
|
1211
|
+
if (tokens[0]) {
|
|
1212
|
+
if (tokens[0] && isSymbol(tokens[0], ",")) {
|
|
1213
|
+
isTuple = true;
|
|
1214
|
+
tokens.shift();
|
|
1215
|
+
} else if (!isSymbol(tokens[0], ")")) {
|
|
1216
|
+
throw new ParserError("parsing error");
|
|
1217
|
+
}
|
|
1218
|
+
} else {
|
|
1219
|
+
throw new ParserError("parsing error");
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if (!tokens[0] || !isSymbol(tokens[0], ")")) {
|
|
1223
|
+
throw new ParserError("parsing error");
|
|
1224
|
+
}
|
|
1225
|
+
tokens.shift();
|
|
1226
|
+
isTuple = isTuple || content.length === 0;
|
|
1227
|
+
return isTuple ? { type: 10, value: content } : content[0];
|
|
1228
|
+
case "[":
|
|
1229
|
+
const value = [];
|
|
1230
|
+
while (tokens[0] && !isSymbol(tokens[0], "]")) {
|
|
1231
|
+
value.push(_parse(tokens, 0));
|
|
1232
|
+
if (tokens[0]) {
|
|
1233
|
+
if (isSymbol(tokens[0], ",")) {
|
|
1234
|
+
tokens.shift();
|
|
1235
|
+
} else if (!isSymbol(tokens[0], "]")) {
|
|
1236
|
+
throw new ParserError("parsing error");
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (!tokens[0] || !isSymbol(tokens[0], "]")) {
|
|
1241
|
+
throw new ParserError("parsing error");
|
|
1242
|
+
}
|
|
1243
|
+
tokens.shift();
|
|
1244
|
+
return { type: 4, value };
|
|
1245
|
+
case "{":
|
|
1246
|
+
const dict = {};
|
|
1247
|
+
while (tokens[0] && !isSymbol(tokens[0], "}")) {
|
|
1248
|
+
const key = _parse(tokens, 0);
|
|
1249
|
+
if (key.type !== 1 && key.type !== 0 || !tokens[0] || !isSymbol(tokens[0], ":")) {
|
|
1250
|
+
throw new ParserError("parsing error");
|
|
1251
|
+
}
|
|
1252
|
+
tokens.shift();
|
|
1253
|
+
const val = _parse(tokens, 0);
|
|
1254
|
+
dict[key.value] = val;
|
|
1255
|
+
if (isSymbol(tokens[0], ",")) {
|
|
1256
|
+
tokens.shift();
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
if (!tokens.shift()) {
|
|
1260
|
+
throw new ParserError("parsing error");
|
|
1261
|
+
}
|
|
1262
|
+
return { type: 11, value: dict };
|
|
1263
|
+
default:
|
|
1264
|
+
throw new ParserError("Token cannot be parsed");
|
|
1265
|
+
}
|
|
1266
|
+
default:
|
|
1267
|
+
throw new ParserError("Token cannot be parsed");
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
function parseInfix(left, current, tokens) {
|
|
1271
|
+
switch (current.type) {
|
|
1272
|
+
case 2:
|
|
1273
|
+
if (infixOperators.has(current.value)) {
|
|
1274
|
+
let right = _parse(tokens, bindingPower(current));
|
|
1275
|
+
if (current.value === "and" || current.value === "or") {
|
|
1276
|
+
return {
|
|
1277
|
+
type: 14,
|
|
1278
|
+
op: current.value,
|
|
1279
|
+
left,
|
|
1280
|
+
right
|
|
1281
|
+
};
|
|
1282
|
+
} else if (current.value === ".") {
|
|
1283
|
+
if (right.type === 5) {
|
|
1284
|
+
return {
|
|
1285
|
+
type: 15,
|
|
1286
|
+
obj: left,
|
|
1287
|
+
key: right.value
|
|
1288
|
+
};
|
|
1289
|
+
} else {
|
|
1290
|
+
throw new ParserError("invalid obj lookup");
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
let op = {
|
|
1294
|
+
type: 7,
|
|
1295
|
+
op: current.value,
|
|
1296
|
+
left,
|
|
1297
|
+
right
|
|
1298
|
+
};
|
|
1299
|
+
while (chainedOperators.has(current.value) && tokens[0] && tokens[0].type === 2 && chainedOperators.has(tokens[0].value)) {
|
|
1300
|
+
const nextToken = tokens.shift();
|
|
1301
|
+
op = {
|
|
1302
|
+
type: 14,
|
|
1303
|
+
op: "and",
|
|
1304
|
+
left: op,
|
|
1305
|
+
right: {
|
|
1306
|
+
type: 7,
|
|
1307
|
+
op: nextToken.value,
|
|
1308
|
+
left: right,
|
|
1309
|
+
right: _parse(tokens, bindingPower(nextToken))
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
right = op.right;
|
|
1313
|
+
}
|
|
1314
|
+
return op;
|
|
1315
|
+
}
|
|
1316
|
+
switch (current.value) {
|
|
1317
|
+
case "(":
|
|
1318
|
+
const args = [];
|
|
1319
|
+
const kwargs = {};
|
|
1320
|
+
while (tokens[0] && !isSymbol(tokens[0], ")")) {
|
|
1321
|
+
const arg = _parse(tokens, 0);
|
|
1322
|
+
if (arg.type === 9) {
|
|
1323
|
+
kwargs[arg.name.value] = arg.value;
|
|
1324
|
+
} else {
|
|
1325
|
+
args.push(arg);
|
|
1326
|
+
}
|
|
1327
|
+
if (tokens[0] && isSymbol(tokens[0], ",")) {
|
|
1328
|
+
tokens.shift();
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
if (!tokens[0] || !isSymbol(tokens[0], ")")) {
|
|
1332
|
+
throw new ParserError("parsing error");
|
|
1333
|
+
}
|
|
1334
|
+
tokens.shift();
|
|
1335
|
+
return { type: 8, fn: left, args, kwargs };
|
|
1336
|
+
case "=":
|
|
1337
|
+
if (left.type === 5) {
|
|
1338
|
+
return {
|
|
1339
|
+
type: 9,
|
|
1340
|
+
name: left,
|
|
1341
|
+
value: _parse(tokens, 10)
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
break;
|
|
1345
|
+
case "[":
|
|
1346
|
+
const key = _parse(tokens);
|
|
1347
|
+
if (!tokens[0] || !isSymbol(tokens[0], "]")) {
|
|
1348
|
+
throw new ParserError("parsing error");
|
|
1349
|
+
}
|
|
1350
|
+
tokens.shift();
|
|
1351
|
+
return {
|
|
1352
|
+
type: 12,
|
|
1353
|
+
target: left,
|
|
1354
|
+
key
|
|
1355
|
+
};
|
|
1356
|
+
case "if":
|
|
1357
|
+
const condition = _parse(tokens);
|
|
1358
|
+
if (!tokens[0] || !isSymbol(tokens[0], "else")) {
|
|
1359
|
+
throw new ParserError("parsing error");
|
|
1360
|
+
}
|
|
1361
|
+
tokens.shift();
|
|
1362
|
+
const ifFalse = _parse(tokens);
|
|
1363
|
+
return {
|
|
1364
|
+
type: 13,
|
|
1365
|
+
condition,
|
|
1366
|
+
ifTrue: left,
|
|
1367
|
+
ifFalse
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
throw new ParserError("Token cannot be parsed");
|
|
1372
|
+
}
|
|
1373
|
+
function _parse(tokens, bp2 = 0) {
|
|
1374
|
+
const token = tokens.shift();
|
|
1375
|
+
if (!token) {
|
|
1376
|
+
throw new ParserError("Unexpected end of input");
|
|
1377
|
+
}
|
|
1378
|
+
let expr = parsePrefix(token, tokens);
|
|
1379
|
+
while (tokens[0] && bindingPower(tokens[0]) > bp2) {
|
|
1380
|
+
expr = parseInfix(expr, tokens.shift(), tokens);
|
|
1381
|
+
}
|
|
1382
|
+
return expr;
|
|
1383
|
+
}
|
|
1384
|
+
function parse(tokens) {
|
|
1385
|
+
if (tokens.length) {
|
|
1386
|
+
return _parse(tokens, 0);
|
|
1387
|
+
}
|
|
1388
|
+
throw new ParserError("Missing token");
|
|
1389
|
+
}
|
|
1390
|
+
function parseArgs(args, spec) {
|
|
1391
|
+
const last = args[args.length - 1];
|
|
1392
|
+
const unnamedArgs = typeof last === "object" ? args.slice(0, -1) : args;
|
|
1393
|
+
const kwargs = typeof last === "object" ? last : {};
|
|
1394
|
+
for (const [index, val] of unnamedArgs.entries()) {
|
|
1395
|
+
kwargs[spec[index]] = val;
|
|
1396
|
+
}
|
|
1397
|
+
return kwargs;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// src/utils/domain/py_date.ts
|
|
1401
|
+
var AssertionError = class extends Error {
|
|
1402
|
+
};
|
|
1403
|
+
var ValueError = class extends Error {
|
|
1404
|
+
};
|
|
1405
|
+
var NotSupportedError = class extends Error {
|
|
1406
|
+
};
|
|
1407
|
+
function fmt2(n) {
|
|
1408
|
+
return String(n).padStart(2, "0");
|
|
1409
|
+
}
|
|
1410
|
+
function fmt4(n) {
|
|
1411
|
+
return String(n).padStart(4, "0");
|
|
1412
|
+
}
|
|
1413
|
+
function divmod(a, b, fn) {
|
|
1414
|
+
let mod = a % b;
|
|
1415
|
+
if (mod > 0 && b < 0 || mod < 0 && b > 0) {
|
|
1416
|
+
mod += b;
|
|
1417
|
+
}
|
|
1418
|
+
return fn(Math.floor(a / b), mod);
|
|
1419
|
+
}
|
|
1420
|
+
function assert(bool, message = "AssertionError") {
|
|
1421
|
+
if (!bool) {
|
|
1422
|
+
throw new AssertionError(message);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
var DAYS_IN_MONTH = [
|
|
1426
|
+
null,
|
|
1427
|
+
31,
|
|
1428
|
+
28,
|
|
1429
|
+
31,
|
|
1430
|
+
30,
|
|
1431
|
+
31,
|
|
1432
|
+
30,
|
|
1433
|
+
31,
|
|
1434
|
+
31,
|
|
1435
|
+
30,
|
|
1436
|
+
31,
|
|
1437
|
+
30,
|
|
1438
|
+
31
|
|
1439
|
+
];
|
|
1440
|
+
var DAYS_BEFORE_MONTH = [null];
|
|
1441
|
+
for (let dbm = 0, i = 1; i < DAYS_IN_MONTH.length; ++i) {
|
|
1442
|
+
DAYS_BEFORE_MONTH.push(dbm);
|
|
1443
|
+
dbm += DAYS_IN_MONTH[i];
|
|
1444
|
+
}
|
|
1445
|
+
function daysInMonth(year, month) {
|
|
1446
|
+
if (month === 2 && isLeap(year)) {
|
|
1447
|
+
return 29;
|
|
1448
|
+
}
|
|
1449
|
+
return DAYS_IN_MONTH[month];
|
|
1450
|
+
}
|
|
1451
|
+
function isLeap(year) {
|
|
1452
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
1453
|
+
}
|
|
1454
|
+
function daysBeforeYear(year) {
|
|
1455
|
+
const y = year - 1;
|
|
1456
|
+
return y * 365 + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
|
|
1457
|
+
}
|
|
1458
|
+
function daysBeforeMonth(year, month) {
|
|
1459
|
+
const postLeapFeb = month > 2 && isLeap(year);
|
|
1460
|
+
return DAYS_BEFORE_MONTH[month] + (postLeapFeb ? 1 : 0);
|
|
1461
|
+
}
|
|
1462
|
+
function ymd2ord(year, month, day) {
|
|
1463
|
+
const dim = daysInMonth(year, month);
|
|
1464
|
+
if (!(1 <= day && day <= dim)) {
|
|
1465
|
+
throw new ValueError(`day must be in 1..${dim}`);
|
|
1466
|
+
}
|
|
1467
|
+
return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
|
|
1468
|
+
}
|
|
1469
|
+
var DI400Y = daysBeforeYear(401);
|
|
1470
|
+
var DI100Y = daysBeforeYear(101);
|
|
1471
|
+
var DI4Y = daysBeforeYear(5);
|
|
1472
|
+
function ord2ymd(n) {
|
|
1473
|
+
--n;
|
|
1474
|
+
let n400 = 0, n100 = 0, n4 = 0, n1 = 0, n0 = 0;
|
|
1475
|
+
divmod(n, DI400Y, (_n400, n2) => {
|
|
1476
|
+
n400 = _n400;
|
|
1477
|
+
divmod(n2, DI100Y, (_n100, n3) => {
|
|
1478
|
+
n100 = _n100;
|
|
1479
|
+
divmod(n3, DI4Y, (_n4, n5) => {
|
|
1480
|
+
n4 = _n4;
|
|
1481
|
+
divmod(n5, 365, (_n1, n6) => {
|
|
1482
|
+
n1 = _n1;
|
|
1483
|
+
n0 = n6;
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
});
|
|
1487
|
+
});
|
|
1488
|
+
n = n0;
|
|
1489
|
+
const year = n400 * 400 + 1 + n100 * 100 + n4 * 4 + n1;
|
|
1490
|
+
if (n1 === 4 || n100 === 100) {
|
|
1491
|
+
assert(n0 === 0);
|
|
1492
|
+
return {
|
|
1493
|
+
year: year - 1,
|
|
1494
|
+
month: 12,
|
|
1495
|
+
day: 31
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
const leapyear = n1 === 3 && (n4 !== 24 || n100 === 3);
|
|
1499
|
+
assert(leapyear === isLeap(year));
|
|
1500
|
+
let month = n + 50 >> 5;
|
|
1501
|
+
let preceding = DAYS_BEFORE_MONTH[month] + (month > 2 && leapyear ? 1 : 0);
|
|
1502
|
+
if (preceding > n) {
|
|
1503
|
+
--month;
|
|
1504
|
+
preceding -= DAYS_IN_MONTH[month] + (month === 2 && leapyear ? 1 : 0);
|
|
1505
|
+
}
|
|
1506
|
+
n -= preceding;
|
|
1507
|
+
return {
|
|
1508
|
+
year,
|
|
1509
|
+
month,
|
|
1510
|
+
day: n + 1
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
function tmxxx(year, month, day, hour, minute, second, microsecond) {
|
|
1514
|
+
hour = hour || 0;
|
|
1515
|
+
minute = minute || 0;
|
|
1516
|
+
second = second || 0;
|
|
1517
|
+
microsecond = microsecond || 0;
|
|
1518
|
+
if (microsecond < 0 || microsecond > 999999) {
|
|
1519
|
+
divmod(microsecond, 1e6, (carry, ms) => {
|
|
1520
|
+
microsecond = ms;
|
|
1521
|
+
second += carry;
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
if (second < 0 || second > 59) {
|
|
1525
|
+
divmod(second, 60, (carry, s) => {
|
|
1526
|
+
second = s;
|
|
1527
|
+
minute += carry;
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
if (minute < 0 || minute > 59) {
|
|
1531
|
+
divmod(minute, 60, (carry, m) => {
|
|
1532
|
+
minute = m;
|
|
1533
|
+
hour += carry;
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
if (hour < 0 || hour > 23) {
|
|
1537
|
+
divmod(hour, 24, (carry, h) => {
|
|
1538
|
+
hour = h;
|
|
1539
|
+
day += carry;
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
if (month < 1 || month > 12) {
|
|
1543
|
+
divmod(month - 1, 12, (carry, m) => {
|
|
1544
|
+
month = m + 1;
|
|
1545
|
+
year += carry;
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
const dim = daysInMonth(year, month);
|
|
1549
|
+
if (day < 1 || day > dim) {
|
|
1550
|
+
if (day === 0) {
|
|
1551
|
+
--month;
|
|
1552
|
+
if (month > 0) {
|
|
1553
|
+
day = daysInMonth(year, month);
|
|
1554
|
+
} else {
|
|
1555
|
+
--year;
|
|
1556
|
+
month = 12;
|
|
1557
|
+
day = 31;
|
|
1558
|
+
}
|
|
1559
|
+
} else if (day === dim + 1) {
|
|
1560
|
+
++month;
|
|
1561
|
+
day = 1;
|
|
1562
|
+
if (month > 12) {
|
|
1563
|
+
month = 1;
|
|
1564
|
+
++year;
|
|
1565
|
+
}
|
|
1566
|
+
} else {
|
|
1567
|
+
const r = ord2ymd(ymd2ord(year, month, 1) + (day - 1));
|
|
1568
|
+
year = r.year;
|
|
1569
|
+
month = r.month;
|
|
1570
|
+
day = r.day;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
return {
|
|
1574
|
+
year,
|
|
1575
|
+
month,
|
|
1576
|
+
day,
|
|
1577
|
+
hour,
|
|
1578
|
+
minute,
|
|
1579
|
+
second,
|
|
1580
|
+
microsecond
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
var PyDate = class _PyDate {
|
|
1584
|
+
constructor(year, month, day) {
|
|
1585
|
+
this.year = year;
|
|
1586
|
+
this.month = month;
|
|
1587
|
+
this.day = day;
|
|
1588
|
+
}
|
|
1589
|
+
static today() {
|
|
1590
|
+
return this.convertDate(/* @__PURE__ */ new Date());
|
|
1591
|
+
}
|
|
1592
|
+
static convertDate(date) {
|
|
1593
|
+
const year = date.getFullYear();
|
|
1594
|
+
const month = date.getMonth() + 1;
|
|
1595
|
+
const day = date.getDate();
|
|
1596
|
+
return new _PyDate(year, month, day);
|
|
1597
|
+
}
|
|
1598
|
+
static create(...args) {
|
|
1599
|
+
const { year, month, day } = parseArgs(args, ["year", "month", "day"]);
|
|
1600
|
+
return new _PyDate(year, month, day);
|
|
1601
|
+
}
|
|
1602
|
+
add(timedelta) {
|
|
1603
|
+
const s = tmxxx(this.year, this.month, this.day + timedelta.days, 0, 0, 0);
|
|
1604
|
+
return new _PyDate(s.year, s.month, s.day);
|
|
1605
|
+
}
|
|
1606
|
+
isEqual(other) {
|
|
1607
|
+
if (!(other instanceof _PyDate)) {
|
|
1608
|
+
return false;
|
|
1609
|
+
}
|
|
1610
|
+
return this.year === other.year && this.month === other.month && this.day === other.day;
|
|
1611
|
+
}
|
|
1612
|
+
strftime(format) {
|
|
1613
|
+
return format.replace(/%([A-Za-z])/g, (m, c) => {
|
|
1614
|
+
switch (c) {
|
|
1615
|
+
case "Y":
|
|
1616
|
+
return fmt4(this.year);
|
|
1617
|
+
case "m":
|
|
1618
|
+
return fmt2(this.month);
|
|
1619
|
+
case "d":
|
|
1620
|
+
return fmt2(this.day);
|
|
1621
|
+
default:
|
|
1622
|
+
throw new ValueError(`No known conversion for ${m}`);
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
substract(other) {
|
|
1627
|
+
if (other instanceof PyTimeDelta) {
|
|
1628
|
+
return this.add(other.negate());
|
|
1629
|
+
}
|
|
1630
|
+
if (other instanceof _PyDate) {
|
|
1631
|
+
return PyTimeDelta.create(this.toordinal() - other.toordinal());
|
|
1632
|
+
}
|
|
1633
|
+
throw new NotSupportedError();
|
|
1634
|
+
}
|
|
1635
|
+
toJSON() {
|
|
1636
|
+
return this.strftime("%Y-%m-%d");
|
|
1637
|
+
}
|
|
1638
|
+
toordinal() {
|
|
1639
|
+
return ymd2ord(this.year, this.month, this.day);
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
var PyDateTime = class _PyDateTime {
|
|
1643
|
+
constructor(year, month, day, hour, minute, second, microsecond) {
|
|
1644
|
+
this.year = year;
|
|
1645
|
+
this.month = month;
|
|
1646
|
+
this.day = day;
|
|
1647
|
+
this.hour = hour;
|
|
1648
|
+
this.minute = minute;
|
|
1649
|
+
this.second = second;
|
|
1650
|
+
this.microsecond = microsecond;
|
|
1651
|
+
}
|
|
1652
|
+
static now() {
|
|
1653
|
+
return this.convertDate(/* @__PURE__ */ new Date());
|
|
1654
|
+
}
|
|
1655
|
+
static convertDate(date) {
|
|
1656
|
+
const year = date.getFullYear();
|
|
1657
|
+
const month = date.getMonth() + 1;
|
|
1658
|
+
const day = date.getDate();
|
|
1659
|
+
const hour = date.getHours();
|
|
1660
|
+
const minute = date.getMinutes();
|
|
1661
|
+
const second = date.getSeconds();
|
|
1662
|
+
return new _PyDateTime(year, month, day, hour, minute, second, 0);
|
|
1663
|
+
}
|
|
1664
|
+
static create(...args) {
|
|
1665
|
+
const namedArgs = parseArgs(args, [
|
|
1666
|
+
"year",
|
|
1667
|
+
"month",
|
|
1668
|
+
"day",
|
|
1669
|
+
"hour",
|
|
1670
|
+
"minute",
|
|
1671
|
+
"second",
|
|
1672
|
+
"microsecond"
|
|
1673
|
+
]);
|
|
1674
|
+
const year = namedArgs.year;
|
|
1675
|
+
const month = namedArgs.month;
|
|
1676
|
+
const day = namedArgs.day;
|
|
1677
|
+
const hour = namedArgs.hour || 0;
|
|
1678
|
+
const minute = namedArgs.minute || 0;
|
|
1679
|
+
const second = namedArgs.second || 0;
|
|
1680
|
+
const ms = namedArgs.microsecond / 1e3 || 0;
|
|
1681
|
+
return new _PyDateTime(year, month, day, hour, minute, second, ms);
|
|
1682
|
+
}
|
|
1683
|
+
static combine(...args) {
|
|
1684
|
+
const { date, time } = parseArgs(args, ["date", "time"]);
|
|
1685
|
+
return _PyDateTime.create(
|
|
1686
|
+
date.year,
|
|
1687
|
+
date.month,
|
|
1688
|
+
date.day,
|
|
1689
|
+
time.hour,
|
|
1690
|
+
time.minute,
|
|
1691
|
+
time.second
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
add(timedelta) {
|
|
1695
|
+
const s = tmxxx(
|
|
1696
|
+
this.year,
|
|
1697
|
+
this.month,
|
|
1698
|
+
this.day + timedelta.days,
|
|
1699
|
+
this.hour,
|
|
1700
|
+
this.minute,
|
|
1701
|
+
this.second + timedelta.seconds,
|
|
1702
|
+
this.microsecond + timedelta.microseconds
|
|
1703
|
+
);
|
|
1704
|
+
return new _PyDateTime(
|
|
1705
|
+
s.year,
|
|
1706
|
+
s.month,
|
|
1707
|
+
s.day,
|
|
1708
|
+
s.hour,
|
|
1709
|
+
s.minute,
|
|
1710
|
+
s.second,
|
|
1711
|
+
s.microsecond
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
isEqual(other) {
|
|
1715
|
+
if (!(other instanceof _PyDateTime)) {
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
|
|
1719
|
+
}
|
|
1720
|
+
strftime(format) {
|
|
1721
|
+
return format.replace(/%([A-Za-z])/g, (m, c) => {
|
|
1722
|
+
switch (c) {
|
|
1723
|
+
case "Y":
|
|
1724
|
+
return fmt4(this.year);
|
|
1725
|
+
case "m":
|
|
1726
|
+
return fmt2(this.month);
|
|
1727
|
+
case "d":
|
|
1728
|
+
return fmt2(this.day);
|
|
1729
|
+
case "H":
|
|
1730
|
+
return fmt2(this.hour);
|
|
1731
|
+
case "M":
|
|
1732
|
+
return fmt2(this.minute);
|
|
1733
|
+
case "S":
|
|
1734
|
+
return fmt2(this.second);
|
|
1735
|
+
default:
|
|
1736
|
+
throw new ValueError(`No known conversion for ${m}`);
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
substract(timedelta) {
|
|
1741
|
+
return this.add(timedelta.negate());
|
|
1742
|
+
}
|
|
1743
|
+
toJSON() {
|
|
1744
|
+
return this.strftime("%Y-%m-%d %H:%M:%S");
|
|
1745
|
+
}
|
|
1746
|
+
to_utc() {
|
|
1747
|
+
const d = new Date(
|
|
1748
|
+
this.year,
|
|
1749
|
+
this.month - 1,
|
|
1750
|
+
this.day,
|
|
1751
|
+
this.hour,
|
|
1752
|
+
this.minute,
|
|
1753
|
+
this.second
|
|
1754
|
+
);
|
|
1755
|
+
const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
|
|
1756
|
+
return this.add(timedelta);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
var PyTime = class _PyTime extends PyDate {
|
|
1760
|
+
constructor(hour, minute, second) {
|
|
1761
|
+
const now = /* @__PURE__ */ new Date();
|
|
1762
|
+
const year = now.getFullYear();
|
|
1763
|
+
const month = now.getMonth() + 1;
|
|
1764
|
+
const day = now.getDate();
|
|
1765
|
+
super(year, month, day);
|
|
1766
|
+
this.hour = hour;
|
|
1767
|
+
this.minute = minute;
|
|
1768
|
+
this.second = second;
|
|
1769
|
+
this.hour = hour;
|
|
1770
|
+
this.minute = minute;
|
|
1771
|
+
this.second = second;
|
|
1772
|
+
}
|
|
1773
|
+
static create(...args) {
|
|
1774
|
+
const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
|
|
1775
|
+
const hour = namedArgs.hour || 0;
|
|
1776
|
+
const minute = namedArgs.minute || 0;
|
|
1777
|
+
const second = namedArgs.second || 0;
|
|
1778
|
+
return new _PyTime(hour, minute, second);
|
|
1779
|
+
}
|
|
1780
|
+
strftime(format) {
|
|
1781
|
+
return format.replace(/%([A-Za-z])/g, (m, c) => {
|
|
1782
|
+
switch (c) {
|
|
1783
|
+
case "Y":
|
|
1784
|
+
return fmt4(this.year);
|
|
1785
|
+
case "m":
|
|
1786
|
+
return fmt2(this.month);
|
|
1787
|
+
case "d":
|
|
1788
|
+
return fmt2(this.day);
|
|
1789
|
+
case "H":
|
|
1790
|
+
return fmt2(this.hour);
|
|
1791
|
+
case "M":
|
|
1792
|
+
return fmt2(this.minute);
|
|
1793
|
+
case "S":
|
|
1794
|
+
return fmt2(this.second);
|
|
1795
|
+
default:
|
|
1796
|
+
throw new ValueError(`No known conversion for ${m}`);
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
toJSON() {
|
|
1801
|
+
return this.strftime("%H:%M:%S");
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1804
|
+
var DAYS_IN_YEAR = [
|
|
1805
|
+
31,
|
|
1806
|
+
59,
|
|
1807
|
+
90,
|
|
1808
|
+
120,
|
|
1809
|
+
151,
|
|
1810
|
+
181,
|
|
1811
|
+
212,
|
|
1812
|
+
243,
|
|
1813
|
+
273,
|
|
1814
|
+
304,
|
|
1815
|
+
334,
|
|
1816
|
+
366
|
|
1817
|
+
];
|
|
1818
|
+
var TIME_PERIODS = ["hour", "minute", "second"];
|
|
1819
|
+
var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
|
|
1820
|
+
var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
|
|
1821
|
+
" "
|
|
1822
|
+
);
|
|
1823
|
+
var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
|
|
1824
|
+
" "
|
|
1825
|
+
);
|
|
1826
|
+
var argsSpec = ["dt1", "dt2"];
|
|
1827
|
+
var PyRelativeDelta = class _PyRelativeDelta {
|
|
1828
|
+
static create(...args) {
|
|
1829
|
+
const params = parseArgs(args, argsSpec);
|
|
1830
|
+
if ("dt1" in params) {
|
|
1831
|
+
throw new Error("relativedelta(dt1, dt2) is not supported for now");
|
|
1832
|
+
}
|
|
1833
|
+
for (const period of PERIODS) {
|
|
1834
|
+
if (period in params) {
|
|
1835
|
+
const val = params[period];
|
|
1836
|
+
assert(val >= 0, `${period} ${val} is out of range`);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
for (const key of RELATIVE_KEYS) {
|
|
1840
|
+
params[key] = params[key] || 0;
|
|
1841
|
+
}
|
|
1842
|
+
for (const key of ABSOLUTE_KEYS) {
|
|
1843
|
+
params[key] = key in params ? params[key] : null;
|
|
1844
|
+
}
|
|
1845
|
+
params.days += 7 * params.weeks;
|
|
1846
|
+
let yearDay = 0;
|
|
1847
|
+
if (params.nlyearday) {
|
|
1848
|
+
yearDay = params.nlyearday;
|
|
1849
|
+
} else if (params.yearday) {
|
|
1850
|
+
yearDay = params.yearday;
|
|
1851
|
+
if (yearDay > 59) {
|
|
1852
|
+
params.leapDays = -1;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
if (yearDay) {
|
|
1856
|
+
for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
|
|
1857
|
+
if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
|
|
1858
|
+
params.month = monthIndex + 1;
|
|
1859
|
+
if (monthIndex === 0) {
|
|
1860
|
+
params.day = yearDay;
|
|
1861
|
+
} else {
|
|
1862
|
+
params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
|
|
1863
|
+
}
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
return new _PyRelativeDelta(params);
|
|
1869
|
+
}
|
|
1870
|
+
static add(date, delta) {
|
|
1871
|
+
if (!(date instanceof PyDate || date instanceof PyDateTime)) {
|
|
1872
|
+
throw new NotSupportedError();
|
|
1873
|
+
}
|
|
1874
|
+
const s = tmxxx(
|
|
1875
|
+
(delta.year || date.year) + delta.years,
|
|
1876
|
+
(delta.month || date.month) + delta.months,
|
|
1877
|
+
delta.day || date.day,
|
|
1878
|
+
delta.hour || (date instanceof PyDateTime ? date.hour : 0),
|
|
1879
|
+
delta.minute || (date instanceof PyDateTime ? date.minute : 0),
|
|
1880
|
+
delta.second || (date instanceof PyDateTime ? date.second : 0),
|
|
1881
|
+
delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
|
|
1882
|
+
);
|
|
1883
|
+
const newDateTime = new PyDateTime(
|
|
1884
|
+
s.year,
|
|
1885
|
+
s.month,
|
|
1886
|
+
s.day,
|
|
1887
|
+
s.hour,
|
|
1888
|
+
s.minute,
|
|
1889
|
+
s.second,
|
|
1890
|
+
s.microsecond
|
|
1891
|
+
);
|
|
1892
|
+
let leapDays = 0;
|
|
1893
|
+
if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
|
|
1894
|
+
leapDays = delta.leapDays;
|
|
1895
|
+
}
|
|
1896
|
+
const temp = newDateTime.add(
|
|
1897
|
+
PyTimeDelta.create({
|
|
1898
|
+
days: delta.days + leapDays,
|
|
1899
|
+
hours: delta.hours,
|
|
1900
|
+
minutes: delta.minutes,
|
|
1901
|
+
seconds: delta.seconds,
|
|
1902
|
+
microseconds: delta.microseconds
|
|
1903
|
+
})
|
|
1904
|
+
);
|
|
1905
|
+
const hasTime = Boolean(
|
|
1906
|
+
temp.hour || temp.minute || temp.second || temp.microsecond
|
|
1907
|
+
);
|
|
1908
|
+
const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
|
|
1909
|
+
if (delta.weekday !== null) {
|
|
1910
|
+
const wantedDow = delta.weekday + 1;
|
|
1911
|
+
const _date = new Date(
|
|
1912
|
+
returnDate.year,
|
|
1913
|
+
returnDate.month - 1,
|
|
1914
|
+
returnDate.day
|
|
1915
|
+
);
|
|
1916
|
+
const days = (7 - _date.getDay() + wantedDow) % 7;
|
|
1917
|
+
return returnDate.add(new PyTimeDelta(days, 0, 0));
|
|
1918
|
+
}
|
|
1919
|
+
return returnDate;
|
|
1920
|
+
}
|
|
1921
|
+
static substract(date, delta) {
|
|
1922
|
+
return _PyRelativeDelta.add(date, delta.negate());
|
|
1923
|
+
}
|
|
1924
|
+
constructor(params = {}, sign = 1) {
|
|
1925
|
+
this.years = sign * params.years;
|
|
1926
|
+
this.months = sign * params.months;
|
|
1927
|
+
this.days = sign * params.days;
|
|
1928
|
+
this.hours = sign * params.hours;
|
|
1929
|
+
this.minutes = sign * params.minutes;
|
|
1930
|
+
this.seconds = sign * params.seconds;
|
|
1931
|
+
this.microseconds = sign * params.microseconds;
|
|
1932
|
+
this.leapDays = params.leapDays;
|
|
1933
|
+
this.year = params.year;
|
|
1934
|
+
this.month = params.month;
|
|
1935
|
+
this.day = params.day;
|
|
1936
|
+
this.hour = params.hour;
|
|
1937
|
+
this.minute = params.minute;
|
|
1938
|
+
this.second = params.second;
|
|
1939
|
+
this.microsecond = params.microsecond;
|
|
1940
|
+
this.weekday = params.weekday;
|
|
1941
|
+
}
|
|
1942
|
+
years;
|
|
1943
|
+
months;
|
|
1944
|
+
days;
|
|
1945
|
+
hours;
|
|
1946
|
+
minutes;
|
|
1947
|
+
seconds;
|
|
1948
|
+
microseconds;
|
|
1949
|
+
leapDays;
|
|
1950
|
+
year;
|
|
1951
|
+
month;
|
|
1952
|
+
day;
|
|
1953
|
+
hour;
|
|
1954
|
+
minute;
|
|
1955
|
+
second;
|
|
1956
|
+
microsecond;
|
|
1957
|
+
weekday;
|
|
1958
|
+
negate() {
|
|
1959
|
+
return new _PyRelativeDelta(this, -1);
|
|
1960
|
+
}
|
|
1961
|
+
isEqual() {
|
|
1962
|
+
throw new NotSupportedError();
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
|
|
1966
|
+
function modf(x) {
|
|
1967
|
+
const mod = x % 1;
|
|
1968
|
+
return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
|
|
1969
|
+
}
|
|
1970
|
+
var PyTimeDelta = class _PyTimeDelta {
|
|
1971
|
+
constructor(days, seconds, microseconds) {
|
|
1972
|
+
this.days = days;
|
|
1973
|
+
this.seconds = seconds;
|
|
1974
|
+
this.microseconds = microseconds;
|
|
1975
|
+
}
|
|
1976
|
+
static create(...args) {
|
|
1977
|
+
const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
|
|
1978
|
+
for (const key of TIME_DELTA_KEYS) {
|
|
1979
|
+
namedArgs[key] = namedArgs[key] || 0;
|
|
1980
|
+
}
|
|
1981
|
+
let d = 0;
|
|
1982
|
+
let s = 0;
|
|
1983
|
+
let us = 0;
|
|
1984
|
+
const days = namedArgs.days + namedArgs.weeks * 7;
|
|
1985
|
+
let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
|
|
1986
|
+
let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
|
|
1987
|
+
const [dFrac, dInt] = modf(days);
|
|
1988
|
+
d = dInt;
|
|
1989
|
+
let daysecondsfrac = 0;
|
|
1990
|
+
if (dFrac) {
|
|
1991
|
+
const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
|
|
1992
|
+
s = dsInt;
|
|
1993
|
+
daysecondsfrac = dsFrac;
|
|
1994
|
+
}
|
|
1995
|
+
const [sFrac, sInt] = modf(seconds);
|
|
1996
|
+
seconds = sInt;
|
|
1997
|
+
const secondsfrac = sFrac + daysecondsfrac;
|
|
1998
|
+
divmod(seconds, 24 * 3600, (days2, seconds2) => {
|
|
1999
|
+
d += days2;
|
|
2000
|
+
s += seconds2;
|
|
2001
|
+
});
|
|
2002
|
+
microseconds += secondsfrac * 1e6;
|
|
2003
|
+
divmod(microseconds, 1e6, (seconds2, microseconds2) => {
|
|
2004
|
+
divmod(seconds2, 24 * 3600, (days2, seconds3) => {
|
|
2005
|
+
d += days2;
|
|
2006
|
+
s += seconds3;
|
|
2007
|
+
us += Math.round(microseconds2);
|
|
2008
|
+
});
|
|
2009
|
+
});
|
|
2010
|
+
return new _PyTimeDelta(d, s, us);
|
|
2011
|
+
}
|
|
2012
|
+
add(other) {
|
|
2013
|
+
return _PyTimeDelta.create({
|
|
2014
|
+
days: this.days + other.days,
|
|
2015
|
+
seconds: this.seconds + other.seconds,
|
|
2016
|
+
microseconds: this.microseconds + other.microseconds
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
divide(n) {
|
|
2020
|
+
const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
|
|
2021
|
+
return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
|
|
2022
|
+
}
|
|
2023
|
+
isEqual(other) {
|
|
2024
|
+
if (!(other instanceof _PyTimeDelta)) {
|
|
2025
|
+
return false;
|
|
2026
|
+
}
|
|
2027
|
+
return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
|
|
2028
|
+
}
|
|
2029
|
+
isTrue() {
|
|
2030
|
+
return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
|
|
2031
|
+
}
|
|
2032
|
+
multiply(n) {
|
|
2033
|
+
return _PyTimeDelta.create({
|
|
2034
|
+
days: n * this.days,
|
|
2035
|
+
seconds: n * this.seconds,
|
|
2036
|
+
microseconds: n * this.microseconds
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
negate() {
|
|
2040
|
+
return _PyTimeDelta.create({
|
|
2041
|
+
days: -this.days,
|
|
2042
|
+
seconds: -this.seconds,
|
|
2043
|
+
microseconds: -this.microseconds
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
substract(other) {
|
|
2047
|
+
return _PyTimeDelta.create({
|
|
2048
|
+
days: this.days - other.days,
|
|
2049
|
+
seconds: this.seconds - other.seconds,
|
|
2050
|
+
microseconds: this.microseconds - other.microseconds
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
total_seconds() {
|
|
2054
|
+
return this.days * 86400 + this.seconds + this.microseconds / 1e6;
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
// src/utils/domain/py_builtin.ts
|
|
2059
|
+
var EvaluationError = class extends Error {
|
|
2060
|
+
constructor(message) {
|
|
2061
|
+
super(message);
|
|
2062
|
+
this.name = "EvaluationError";
|
|
2063
|
+
}
|
|
2064
|
+
};
|
|
2065
|
+
function execOnIterable(iterable, func) {
|
|
2066
|
+
if (iterable === null) {
|
|
2067
|
+
throw new EvaluationError("value not iterable");
|
|
2068
|
+
}
|
|
2069
|
+
if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
|
|
2070
|
+
iterable = Object.keys(iterable);
|
|
2071
|
+
}
|
|
2072
|
+
if (typeof iterable?.[Symbol.iterator] !== "function") {
|
|
2073
|
+
throw new EvaluationError("value not iterable");
|
|
2074
|
+
}
|
|
2075
|
+
return func(iterable);
|
|
2076
|
+
}
|
|
2077
|
+
var BUILTINS = {
|
|
2078
|
+
/**
|
|
2079
|
+
* @param {any} value
|
|
2080
|
+
* @returns {boolean}
|
|
2081
|
+
*/
|
|
2082
|
+
bool(value) {
|
|
2083
|
+
switch (typeof value) {
|
|
2084
|
+
case "number":
|
|
2085
|
+
return value !== 0;
|
|
2086
|
+
case "string":
|
|
2087
|
+
return value !== "";
|
|
2088
|
+
case "boolean":
|
|
2089
|
+
return value;
|
|
2090
|
+
case "object":
|
|
2091
|
+
if (value === null || value === void 0) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
if ("isTrue" in value && typeof value.isTrue === "function") {
|
|
2095
|
+
return value.isTrue();
|
|
2096
|
+
}
|
|
2097
|
+
if (value instanceof Array) {
|
|
2098
|
+
return !!value.length;
|
|
2099
|
+
}
|
|
2100
|
+
if (value instanceof Set) {
|
|
2101
|
+
return !!value.size;
|
|
2102
|
+
}
|
|
2103
|
+
return Object.keys(value).length !== 0;
|
|
2104
|
+
default:
|
|
2105
|
+
return true;
|
|
2106
|
+
}
|
|
2107
|
+
},
|
|
2108
|
+
set(iterable) {
|
|
2109
|
+
if (arguments.length > 2) {
|
|
2110
|
+
throw new EvaluationError(
|
|
2111
|
+
`set expected at most 1 argument, got (${arguments.length - 1})`
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
return execOnIterable(
|
|
2115
|
+
iterable,
|
|
2116
|
+
(iterable2) => new Set(iterable2)
|
|
2117
|
+
);
|
|
2118
|
+
},
|
|
2119
|
+
time: {
|
|
2120
|
+
strftime(format) {
|
|
2121
|
+
return PyDateTime.now().strftime(format);
|
|
2122
|
+
}
|
|
2123
|
+
},
|
|
2124
|
+
context_today() {
|
|
2125
|
+
return PyDate.today();
|
|
2126
|
+
},
|
|
2127
|
+
get current_date() {
|
|
2128
|
+
return this.today;
|
|
2129
|
+
},
|
|
2130
|
+
get today() {
|
|
2131
|
+
return PyDate.today().strftime("%Y-%m-%d");
|
|
2132
|
+
},
|
|
2133
|
+
get now() {
|
|
2134
|
+
return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
|
|
2135
|
+
},
|
|
2136
|
+
datetime: {
|
|
2137
|
+
time: PyTime,
|
|
2138
|
+
timedelta: PyTimeDelta,
|
|
2139
|
+
datetime: PyDateTime,
|
|
2140
|
+
date: PyDate
|
|
2141
|
+
},
|
|
2142
|
+
relativedelta: PyRelativeDelta,
|
|
2143
|
+
true: true,
|
|
2144
|
+
false: false
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
// src/utils/domain/py_utils.ts
|
|
2148
|
+
function toPyValue(value) {
|
|
2149
|
+
switch (typeof value) {
|
|
2150
|
+
case "string":
|
|
2151
|
+
return { type: 1, value };
|
|
2152
|
+
case "number":
|
|
2153
|
+
return { type: 0, value };
|
|
2154
|
+
case "boolean":
|
|
2155
|
+
return { type: 2, value };
|
|
2156
|
+
case "object":
|
|
2157
|
+
if (Array.isArray(value)) {
|
|
2158
|
+
return { type: 4, value: value.map(toPyValue) };
|
|
2159
|
+
} else if (value === null) {
|
|
2160
|
+
return {
|
|
2161
|
+
type: 3
|
|
2162
|
+
/* None */
|
|
2163
|
+
};
|
|
2164
|
+
} else if (value instanceof Date) {
|
|
2165
|
+
return {
|
|
2166
|
+
type: 1,
|
|
2167
|
+
value: String(PyDateTime.convertDate(value))
|
|
2168
|
+
};
|
|
2169
|
+
} else if (value instanceof PyDate || value instanceof PyDateTime) {
|
|
2170
|
+
return { type: 1, value };
|
|
2171
|
+
} else {
|
|
2172
|
+
const content = {};
|
|
2173
|
+
for (const key in value) {
|
|
2174
|
+
content[key] = toPyValue(value[key]);
|
|
2175
|
+
}
|
|
2176
|
+
return { type: 11, value: content };
|
|
2177
|
+
}
|
|
2178
|
+
default:
|
|
2179
|
+
throw new Error("Invalid type");
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
function formatAST(ast, lbp = 0) {
|
|
2183
|
+
switch (ast.type) {
|
|
2184
|
+
case 3:
|
|
2185
|
+
return "None";
|
|
2186
|
+
case 1:
|
|
2187
|
+
return JSON.stringify(ast.value);
|
|
2188
|
+
case 0:
|
|
2189
|
+
return String(ast.value);
|
|
2190
|
+
case 2:
|
|
2191
|
+
return ast.value ? "True" : "False";
|
|
2192
|
+
case 4:
|
|
2193
|
+
return `[${ast.value.map(formatAST).join(", ")}]`;
|
|
2194
|
+
case 6:
|
|
2195
|
+
if (ast.op === "not") {
|
|
2196
|
+
return `not ${formatAST(ast.right, 50)}`;
|
|
2197
|
+
}
|
|
2198
|
+
return `${ast.op}${formatAST(ast.right, 130)}`;
|
|
2199
|
+
case 7:
|
|
2200
|
+
const abp = bp(ast.op);
|
|
2201
|
+
const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
|
|
2202
|
+
return abp < lbp ? `(${binaryStr})` : binaryStr;
|
|
2203
|
+
case 11:
|
|
2204
|
+
const pairs = [];
|
|
2205
|
+
for (const k in ast.value) {
|
|
2206
|
+
pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
|
|
2207
|
+
}
|
|
2208
|
+
return `{${pairs.join(", ")}}`;
|
|
2209
|
+
case 10:
|
|
2210
|
+
return `(${ast.value.map(formatAST).join(", ")})`;
|
|
2211
|
+
case 5:
|
|
2212
|
+
return ast.value;
|
|
2213
|
+
case 12:
|
|
2214
|
+
return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
|
|
2215
|
+
case 13:
|
|
2216
|
+
const { ifTrue, condition, ifFalse } = ast;
|
|
2217
|
+
return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
|
|
2218
|
+
case 14:
|
|
2219
|
+
const boolAbp = bp(ast.op);
|
|
2220
|
+
const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
|
|
2221
|
+
return boolAbp < lbp ? `(${boolStr})` : boolStr;
|
|
2222
|
+
case 15:
|
|
2223
|
+
return `${formatAST(ast.obj, 150)}.${ast.key}`;
|
|
2224
|
+
case 8:
|
|
2225
|
+
const args = ast.args.map(formatAST);
|
|
2226
|
+
const kwargs = [];
|
|
2227
|
+
for (const kwarg in ast.kwargs) {
|
|
2228
|
+
kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
|
|
2229
|
+
}
|
|
2230
|
+
const argStr = args.concat(kwargs).join(", ");
|
|
2231
|
+
return `${formatAST(ast.fn)}(${argStr})`;
|
|
2232
|
+
default:
|
|
2233
|
+
throw new Error("invalid expression: " + JSON.stringify(ast));
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
var PY_DICT = /* @__PURE__ */ Object.create(null);
|
|
2237
|
+
function toPyDict(obj) {
|
|
2238
|
+
return new Proxy(obj, {
|
|
2239
|
+
getPrototypeOf() {
|
|
2240
|
+
return PY_DICT;
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
// src/utils/domain/py_interpreter.ts
|
|
2246
|
+
var isTrue = BUILTINS.bool;
|
|
2247
|
+
function applyUnaryOp(ast, context) {
|
|
2248
|
+
const value = evaluate(ast.right, context);
|
|
2249
|
+
switch (ast.op) {
|
|
2250
|
+
case "-":
|
|
2251
|
+
if (value instanceof Object && "negate" in value) {
|
|
2252
|
+
return value.negate();
|
|
2253
|
+
}
|
|
2254
|
+
return -value;
|
|
2255
|
+
case "+":
|
|
2256
|
+
return value;
|
|
2257
|
+
case "not":
|
|
2258
|
+
return !isTrue(value);
|
|
2259
|
+
default:
|
|
2260
|
+
throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function pytypeIndex(val) {
|
|
2264
|
+
switch (typeof val) {
|
|
2265
|
+
case "object":
|
|
2266
|
+
return val === null ? 1 : Array.isArray(val) ? 5 : 3;
|
|
2267
|
+
case "number":
|
|
2268
|
+
return 2;
|
|
2269
|
+
case "string":
|
|
2270
|
+
return 4;
|
|
2271
|
+
default:
|
|
2272
|
+
throw new EvaluationError(`Unknown type: ${typeof val}`);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
function isLess(left, right) {
|
|
2276
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
2277
|
+
return left < right;
|
|
2278
|
+
}
|
|
2279
|
+
if (typeof left === "boolean") {
|
|
2280
|
+
left = left ? 1 : 0;
|
|
2281
|
+
}
|
|
2282
|
+
if (typeof right === "boolean") {
|
|
2283
|
+
right = right ? 1 : 0;
|
|
2284
|
+
}
|
|
2285
|
+
const leftIndex = pytypeIndex(left);
|
|
2286
|
+
const rightIndex = pytypeIndex(right);
|
|
2287
|
+
if (leftIndex === rightIndex) {
|
|
2288
|
+
return left < right;
|
|
2289
|
+
}
|
|
2290
|
+
return leftIndex < rightIndex;
|
|
2291
|
+
}
|
|
2292
|
+
function isEqual(left, right) {
|
|
2293
|
+
if (typeof left !== typeof right) {
|
|
2294
|
+
if (typeof left === "boolean" && typeof right === "number") {
|
|
2295
|
+
return right === (left ? 1 : 0);
|
|
2296
|
+
}
|
|
2297
|
+
if (typeof left === "number" && typeof right === "boolean") {
|
|
2298
|
+
return left === (right ? 1 : 0);
|
|
2299
|
+
}
|
|
2300
|
+
return false;
|
|
2301
|
+
}
|
|
2302
|
+
if (left instanceof Object && "isEqual" in left) {
|
|
2303
|
+
return left.isEqual(right);
|
|
2304
|
+
}
|
|
2305
|
+
return left === right;
|
|
2306
|
+
}
|
|
2307
|
+
function isIn(left, right) {
|
|
2308
|
+
if (Array.isArray(right)) {
|
|
2309
|
+
return right.includes(left);
|
|
2310
|
+
}
|
|
2311
|
+
if (typeof right === "string" && typeof left === "string") {
|
|
2312
|
+
return right.includes(left);
|
|
2313
|
+
}
|
|
2314
|
+
if (typeof right === "object") {
|
|
2315
|
+
return left in right;
|
|
2316
|
+
}
|
|
2317
|
+
return false;
|
|
2318
|
+
}
|
|
2319
|
+
function applyBinaryOp(ast, context) {
|
|
2320
|
+
const left = evaluate(ast.left, context);
|
|
2321
|
+
const right = evaluate(ast.right, context);
|
|
2322
|
+
switch (ast.op) {
|
|
2323
|
+
case "+": {
|
|
2324
|
+
const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
|
|
2325
|
+
const relativeDeltaOnRight = right instanceof PyRelativeDelta;
|
|
2326
|
+
if (relativeDeltaOnLeft || relativeDeltaOnRight) {
|
|
2327
|
+
const date = relativeDeltaOnLeft ? right : left;
|
|
2328
|
+
const delta = relativeDeltaOnLeft ? left : right;
|
|
2329
|
+
return PyRelativeDelta.add(date, delta);
|
|
2330
|
+
}
|
|
2331
|
+
const timeDeltaOnLeft = left instanceof PyTimeDelta;
|
|
2332
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
2333
|
+
if (timeDeltaOnLeft && timeDeltaOnRight) {
|
|
2334
|
+
return left.add(right);
|
|
2335
|
+
}
|
|
2336
|
+
if (timeDeltaOnLeft) {
|
|
2337
|
+
if (right instanceof PyDate || right instanceof PyDateTime) {
|
|
2338
|
+
return right.add(left);
|
|
2339
|
+
} else {
|
|
2340
|
+
throw new NotSupportedError();
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
if (timeDeltaOnRight) {
|
|
2344
|
+
if (left instanceof PyDate || left instanceof PyDateTime) {
|
|
2345
|
+
return left.add(right);
|
|
2346
|
+
} else {
|
|
2347
|
+
throw new NotSupportedError();
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
if (left instanceof Array && right instanceof Array) {
|
|
2351
|
+
return [...left, ...right];
|
|
2352
|
+
}
|
|
2353
|
+
return left + right;
|
|
2354
|
+
}
|
|
2355
|
+
case "-": {
|
|
2356
|
+
const isRightDelta = right instanceof PyRelativeDelta;
|
|
2357
|
+
if (isRightDelta) {
|
|
2358
|
+
return PyRelativeDelta.substract(left, right);
|
|
2359
|
+
}
|
|
2360
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
2361
|
+
if (timeDeltaOnRight) {
|
|
2362
|
+
if (left instanceof PyTimeDelta) {
|
|
2363
|
+
return left.substract(right);
|
|
2364
|
+
} else if (left instanceof PyDate || left instanceof PyDateTime) {
|
|
2365
|
+
return left.substract(right);
|
|
2366
|
+
} else {
|
|
2367
|
+
throw new NotSupportedError();
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
if (left instanceof PyDate) {
|
|
2371
|
+
return left.substract(right);
|
|
2372
|
+
}
|
|
2373
|
+
return left - right;
|
|
2374
|
+
}
|
|
2375
|
+
case "*": {
|
|
2376
|
+
const timeDeltaOnLeft = left instanceof PyTimeDelta;
|
|
2377
|
+
const timeDeltaOnRight = right instanceof PyTimeDelta;
|
|
2378
|
+
if (timeDeltaOnLeft || timeDeltaOnRight) {
|
|
2379
|
+
const number = timeDeltaOnLeft ? right : left;
|
|
2380
|
+
const delta = timeDeltaOnLeft ? left : right;
|
|
2381
|
+
return delta.multiply(number);
|
|
2382
|
+
}
|
|
2383
|
+
return left * right;
|
|
2384
|
+
}
|
|
2385
|
+
case "/":
|
|
2386
|
+
return left / right;
|
|
2387
|
+
case "%":
|
|
2388
|
+
return left % right;
|
|
2389
|
+
case "//":
|
|
2390
|
+
if (left instanceof PyTimeDelta) {
|
|
2391
|
+
return left.divide(right);
|
|
2392
|
+
}
|
|
2393
|
+
return Math.floor(left / right);
|
|
2394
|
+
case "**":
|
|
2395
|
+
return left ** right;
|
|
2396
|
+
case "==":
|
|
2397
|
+
return isEqual(left, right);
|
|
2398
|
+
case "<>":
|
|
2399
|
+
case "!=":
|
|
2400
|
+
return !isEqual(left, right);
|
|
2401
|
+
case "<":
|
|
2402
|
+
return isLess(left, right);
|
|
2403
|
+
case ">":
|
|
2404
|
+
return isLess(right, left);
|
|
2405
|
+
case ">=":
|
|
2406
|
+
return isEqual(left, right) || isLess(right, left);
|
|
2407
|
+
case "<=":
|
|
2408
|
+
return isEqual(left, right) || isLess(left, right);
|
|
2409
|
+
case "in":
|
|
2410
|
+
return isIn(left, right);
|
|
2411
|
+
case "not in":
|
|
2412
|
+
return !isIn(left, right);
|
|
2413
|
+
default:
|
|
2414
|
+
throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
var DICT = {
|
|
2418
|
+
get(...args) {
|
|
2419
|
+
const { key, defValue } = parseArgs(args, ["key", "defValue"]);
|
|
2420
|
+
const self = this;
|
|
2421
|
+
if (key in self) {
|
|
2422
|
+
return self[key];
|
|
2423
|
+
} else if (defValue !== void 0) {
|
|
2424
|
+
return defValue;
|
|
2425
|
+
}
|
|
2426
|
+
return null;
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
var STRING = {
|
|
2430
|
+
lower() {
|
|
2431
|
+
return this.toLowerCase();
|
|
2432
|
+
},
|
|
2433
|
+
upper() {
|
|
2434
|
+
return this.toUpperCase();
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
function applyFunc(key, func, set, ...args) {
|
|
2438
|
+
if (args.length === 1) {
|
|
2439
|
+
return new Set(set);
|
|
2440
|
+
}
|
|
2441
|
+
if (args.length > 2) {
|
|
2442
|
+
throw new EvaluationError(
|
|
2443
|
+
`${key}: py_js supports at most 1 argument, got (${args.length - 1})`
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
return execOnIterable(args[0], func);
|
|
2447
|
+
}
|
|
2448
|
+
var SET = {
|
|
2449
|
+
intersection(...args) {
|
|
2450
|
+
return applyFunc(
|
|
2451
|
+
"intersection",
|
|
2452
|
+
(iterable) => {
|
|
2453
|
+
const intersection = /* @__PURE__ */ new Set();
|
|
2454
|
+
for (const i of iterable) {
|
|
2455
|
+
if (this.has(i)) {
|
|
2456
|
+
intersection.add(i);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
return intersection;
|
|
2460
|
+
},
|
|
2461
|
+
this,
|
|
2462
|
+
...args
|
|
2463
|
+
);
|
|
2464
|
+
},
|
|
2465
|
+
difference(...args) {
|
|
2466
|
+
return applyFunc(
|
|
2467
|
+
"difference",
|
|
2468
|
+
(iterable) => {
|
|
2469
|
+
iterable = new Set(iterable);
|
|
2470
|
+
const difference = /* @__PURE__ */ new Set();
|
|
2471
|
+
for (const e of this) {
|
|
2472
|
+
if (!iterable.has(e)) {
|
|
2473
|
+
difference.add(e);
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
return difference;
|
|
2477
|
+
},
|
|
2478
|
+
this,
|
|
2479
|
+
...args
|
|
2480
|
+
);
|
|
2481
|
+
},
|
|
2482
|
+
union(...args) {
|
|
2483
|
+
return applyFunc(
|
|
2484
|
+
"union",
|
|
2485
|
+
(iterable) => {
|
|
2486
|
+
return /* @__PURE__ */ new Set([...this, ...iterable]);
|
|
2487
|
+
},
|
|
2488
|
+
this,
|
|
2489
|
+
...args
|
|
2490
|
+
);
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
function methods(_class) {
|
|
2494
|
+
return Object.getOwnPropertyNames(_class.prototype).map(
|
|
2495
|
+
(prop) => _class.prototype[prop]
|
|
2496
|
+
);
|
|
2497
|
+
}
|
|
2498
|
+
var allowedFns = /* @__PURE__ */ new Set([
|
|
2499
|
+
BUILTINS.time.strftime,
|
|
2500
|
+
BUILTINS.set,
|
|
2501
|
+
BUILTINS.bool,
|
|
2502
|
+
BUILTINS.context_today,
|
|
2503
|
+
BUILTINS.datetime.datetime.now,
|
|
2504
|
+
BUILTINS.datetime.datetime.combine,
|
|
2505
|
+
BUILTINS.datetime.date.today,
|
|
2506
|
+
...methods(BUILTINS.relativedelta),
|
|
2507
|
+
...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
|
|
2508
|
+
...Object.values(SET),
|
|
2509
|
+
...Object.values(DICT),
|
|
2510
|
+
...Object.values(STRING)
|
|
2511
|
+
]);
|
|
2512
|
+
var unboundFn = /* @__PURE__ */ Symbol("unbound function");
|
|
2513
|
+
function evaluate(ast, context = {}) {
|
|
2514
|
+
const dicts = /* @__PURE__ */ new Set();
|
|
2515
|
+
let pyContext;
|
|
2516
|
+
const evalContext = Object.create(context);
|
|
2517
|
+
if (!evalContext?.context) {
|
|
2518
|
+
Object.defineProperty(evalContext, "context", {
|
|
2519
|
+
get() {
|
|
2520
|
+
if (!pyContext) {
|
|
2521
|
+
pyContext = toPyDict(context);
|
|
2522
|
+
}
|
|
2523
|
+
return pyContext;
|
|
2524
|
+
}
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
function _innerEvaluate(ast2) {
|
|
2528
|
+
switch (ast2?.type) {
|
|
2529
|
+
case 0:
|
|
2530
|
+
// Number
|
|
2531
|
+
case 1:
|
|
2532
|
+
return ast2.value;
|
|
2533
|
+
case 5:
|
|
2534
|
+
if (ast2.value in evalContext) {
|
|
2535
|
+
if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id && ast2?.value !== "parent") {
|
|
2536
|
+
return evalContext[ast2.value]?.id;
|
|
2537
|
+
}
|
|
2538
|
+
return evalContext[ast2.value] ?? false;
|
|
2539
|
+
} else if (ast2.value in BUILTINS) {
|
|
2540
|
+
return BUILTINS[ast2.value];
|
|
2541
|
+
} else {
|
|
2542
|
+
return false;
|
|
2543
|
+
}
|
|
2544
|
+
case 3:
|
|
2545
|
+
return null;
|
|
2546
|
+
case 2:
|
|
2547
|
+
return ast2.value;
|
|
2548
|
+
case 6:
|
|
2549
|
+
return applyUnaryOp(ast2, evalContext);
|
|
2550
|
+
case 7:
|
|
2551
|
+
return applyBinaryOp(ast2, evalContext);
|
|
2552
|
+
case 14:
|
|
2553
|
+
const left = _evaluate(ast2.left);
|
|
2554
|
+
if (ast2.op === "and") {
|
|
2555
|
+
return isTrue(left) ? _evaluate(ast2.right) : left;
|
|
2556
|
+
} else {
|
|
2557
|
+
return isTrue(left) ? left : _evaluate(ast2.right);
|
|
2558
|
+
}
|
|
2559
|
+
case 4:
|
|
2560
|
+
// List
|
|
2561
|
+
case 10:
|
|
2562
|
+
return ast2.value.map(_evaluate);
|
|
2563
|
+
case 11:
|
|
2564
|
+
const dict = {};
|
|
2565
|
+
for (const key2 in ast2.value) {
|
|
2566
|
+
dict[key2] = _evaluate(ast2.value[key2]);
|
|
2567
|
+
}
|
|
2568
|
+
dicts.add(dict);
|
|
2569
|
+
return dict;
|
|
2570
|
+
case 8:
|
|
2571
|
+
const fnValue = _evaluate(ast2.fn);
|
|
2572
|
+
const args = ast2.args.map(_evaluate);
|
|
2573
|
+
const kwargs = {};
|
|
2574
|
+
for (const kwarg in ast2.kwargs) {
|
|
2575
|
+
kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
|
|
2576
|
+
}
|
|
2577
|
+
if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
|
|
2578
|
+
return fnValue.create(...args, kwargs);
|
|
2579
|
+
}
|
|
2580
|
+
return fnValue(...args, kwargs);
|
|
2581
|
+
case 12:
|
|
2582
|
+
const dictVal = _evaluate(ast2.target);
|
|
2583
|
+
const key = _evaluate(ast2.key);
|
|
2584
|
+
return dictVal[key];
|
|
2585
|
+
case 13:
|
|
2586
|
+
if (isTrue(_evaluate(ast2.condition))) {
|
|
2587
|
+
return _evaluate(ast2.ifTrue);
|
|
2588
|
+
} else {
|
|
2589
|
+
return _evaluate(ast2.ifFalse);
|
|
2590
|
+
}
|
|
2591
|
+
case 15:
|
|
2592
|
+
let leftVal = _evaluate(ast2.obj);
|
|
2593
|
+
let result;
|
|
2594
|
+
if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
|
|
2595
|
+
result = DICT[ast2.key];
|
|
2596
|
+
} else if (typeof leftVal === "string") {
|
|
2597
|
+
result = STRING[ast2.key];
|
|
2598
|
+
} else if (leftVal instanceof Set) {
|
|
2599
|
+
result = SET[ast2.key];
|
|
2600
|
+
} else if (ast2.key === "get" && typeof leftVal === "object") {
|
|
2601
|
+
result = DICT[ast2.key];
|
|
2602
|
+
leftVal = toPyDict(leftVal);
|
|
2603
|
+
} else if (typeof leftVal === "number") {
|
|
2604
|
+
result = leftVal;
|
|
2605
|
+
} else if (Array.isArray(leftVal[ast2.key])) {
|
|
2606
|
+
result = leftVal[ast2.key]?.map(
|
|
2607
|
+
(value) => value?.id ?? value
|
|
2608
|
+
);
|
|
2609
|
+
} else {
|
|
2610
|
+
result = leftVal[ast2.key]?.id ?? leftVal[ast2.key] ?? false;
|
|
2611
|
+
}
|
|
2612
|
+
if (typeof result === "function") {
|
|
2613
|
+
const bound = result.bind(leftVal);
|
|
2614
|
+
bound[unboundFn] = result;
|
|
2615
|
+
return bound;
|
|
2616
|
+
}
|
|
2617
|
+
return result;
|
|
2618
|
+
default:
|
|
2619
|
+
throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
function _evaluate(ast2) {
|
|
2623
|
+
const val = _innerEvaluate(ast2);
|
|
2624
|
+
if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
|
|
2625
|
+
throw new Error("Invalid Function Call");
|
|
2626
|
+
}
|
|
2627
|
+
return val;
|
|
2628
|
+
}
|
|
2629
|
+
return _evaluate(ast);
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
// src/utils/domain/py.ts
|
|
2633
|
+
function parseExpr(expr) {
|
|
2634
|
+
const tokens = tokenize(expr);
|
|
2635
|
+
return parse(tokens);
|
|
2636
|
+
}
|
|
2637
|
+
function evaluateExpr(expr, context = {}) {
|
|
2638
|
+
let ast;
|
|
2639
|
+
try {
|
|
2640
|
+
ast = parseExpr(expr);
|
|
2641
|
+
} catch (error) {
|
|
2642
|
+
throw new EvalError(
|
|
2643
|
+
`Can not parse python expression: (${expr})
|
|
2644
|
+
Error: ${error.message}`
|
|
2645
|
+
);
|
|
2646
|
+
}
|
|
2647
|
+
try {
|
|
2648
|
+
return evaluate(ast, context);
|
|
2649
|
+
} catch (error) {
|
|
2650
|
+
throw new EvalError(
|
|
2651
|
+
`Can not evaluate python expression: (${expr})
|
|
2652
|
+
Error: ${error.message}`
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
function evaluateBooleanExpr(expr, context = {}) {
|
|
2657
|
+
if (!expr || expr === "False" || expr === "0") {
|
|
2658
|
+
return false;
|
|
2659
|
+
}
|
|
2660
|
+
if (expr === "True" || expr === "1") {
|
|
2661
|
+
return true;
|
|
2662
|
+
}
|
|
2663
|
+
return evaluateExpr(`bool(${expr})`, context);
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
// src/utils/domain/objects.ts
|
|
2667
|
+
function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
|
|
2668
|
+
if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
|
|
2669
|
+
return obj1 === obj2;
|
|
2670
|
+
}
|
|
2671
|
+
const obj1Keys = Object.keys(obj1);
|
|
2672
|
+
return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
// src/utils/domain/arrays.ts
|
|
2676
|
+
var shallowEqual2 = shallowEqual;
|
|
2677
|
+
|
|
2678
|
+
// src/utils/domain/strings.ts
|
|
2679
|
+
function escapeRegExp(str) {
|
|
2680
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
// src/utils/domain/domain.ts
|
|
2684
|
+
var InvalidDomainError = class extends Error {
|
|
2685
|
+
};
|
|
2686
|
+
var Domain = class _Domain {
|
|
2687
|
+
ast = { type: -1, value: null };
|
|
2688
|
+
static TRUE;
|
|
2689
|
+
static FALSE;
|
|
2690
|
+
static combine(domains, operator) {
|
|
2691
|
+
if (domains.length === 0) {
|
|
2692
|
+
return new _Domain([]);
|
|
2693
|
+
}
|
|
2694
|
+
const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
|
|
2695
|
+
if (domains.length === 1) {
|
|
2696
|
+
return domain1;
|
|
2697
|
+
}
|
|
2698
|
+
const domain2 = _Domain.combine(domains.slice(1), operator);
|
|
2699
|
+
const result = new _Domain([]);
|
|
2700
|
+
const astValues1 = domain1.ast.value;
|
|
2701
|
+
const astValues2 = domain2.ast.value;
|
|
2702
|
+
const op = operator === "AND" ? "&" : "|";
|
|
2703
|
+
const combinedAST = {
|
|
2704
|
+
type: 4,
|
|
2705
|
+
value: astValues1.concat(astValues2)
|
|
2706
|
+
};
|
|
2707
|
+
result.ast = normalizeDomainAST(combinedAST, op);
|
|
2708
|
+
return result;
|
|
2709
|
+
}
|
|
2710
|
+
static and(domains) {
|
|
2711
|
+
return _Domain.combine(domains, "AND");
|
|
2712
|
+
}
|
|
2713
|
+
static or(domains) {
|
|
2714
|
+
return _Domain.combine(domains, "OR");
|
|
2715
|
+
}
|
|
2716
|
+
static not(domain) {
|
|
2717
|
+
const result = new _Domain(domain);
|
|
2718
|
+
result.ast.value.unshift({ type: 1, value: "!" });
|
|
2719
|
+
return result;
|
|
2720
|
+
}
|
|
2721
|
+
static removeDomainLeaves(domain, keysToRemove) {
|
|
2722
|
+
function processLeaf(elements, idx, operatorCtx, newDomain2) {
|
|
2723
|
+
const leaf = elements[idx];
|
|
2724
|
+
if (leaf.type === 10) {
|
|
2725
|
+
if (keysToRemove.includes(leaf.value[0].value)) {
|
|
2726
|
+
if (operatorCtx === "&") {
|
|
2727
|
+
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
2728
|
+
} else if (operatorCtx === "|") {
|
|
2729
|
+
newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
|
|
2730
|
+
}
|
|
2731
|
+
} else {
|
|
2732
|
+
newDomain2.ast.value.push(leaf);
|
|
2733
|
+
}
|
|
2734
|
+
return 1;
|
|
2735
|
+
} else if (leaf.type === 1) {
|
|
2736
|
+
if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
|
|
2737
|
+
newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
|
|
2738
|
+
return 3;
|
|
2739
|
+
}
|
|
2740
|
+
newDomain2.ast.value.push(leaf);
|
|
2741
|
+
if (leaf.value === "!") {
|
|
2742
|
+
return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
|
|
2743
|
+
}
|
|
2744
|
+
const firstLeafSkip = processLeaf(
|
|
2745
|
+
elements,
|
|
2746
|
+
idx + 1,
|
|
2747
|
+
leaf.value,
|
|
2748
|
+
newDomain2
|
|
2749
|
+
);
|
|
2750
|
+
const secondLeafSkip = processLeaf(
|
|
2751
|
+
elements,
|
|
2752
|
+
idx + 1 + firstLeafSkip,
|
|
2753
|
+
leaf.value,
|
|
2754
|
+
newDomain2
|
|
2755
|
+
);
|
|
2756
|
+
return 1 + firstLeafSkip + secondLeafSkip;
|
|
2757
|
+
}
|
|
2758
|
+
return 0;
|
|
2759
|
+
}
|
|
2760
|
+
const d = new _Domain(domain);
|
|
2761
|
+
if (d.ast.value.length === 0) {
|
|
2762
|
+
return d;
|
|
2763
|
+
}
|
|
2764
|
+
const newDomain = new _Domain([]);
|
|
2765
|
+
processLeaf(d.ast.value, 0, "&", newDomain);
|
|
2766
|
+
return newDomain;
|
|
2767
|
+
}
|
|
2768
|
+
constructor(descr = []) {
|
|
2769
|
+
if (descr instanceof _Domain) {
|
|
2770
|
+
return new _Domain(descr.toString());
|
|
2771
|
+
} else {
|
|
2772
|
+
let rawAST;
|
|
2773
|
+
try {
|
|
2774
|
+
rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
|
|
2775
|
+
} catch (error) {
|
|
2776
|
+
throw new InvalidDomainError(
|
|
2777
|
+
`Invalid domain representation: ${descr}`,
|
|
2778
|
+
{
|
|
2779
|
+
cause: error
|
|
2780
|
+
}
|
|
2781
|
+
);
|
|
2782
|
+
}
|
|
2783
|
+
this.ast = normalizeDomainAST(rawAST);
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
contains(record) {
|
|
2787
|
+
const expr = evaluate(this.ast, record);
|
|
2788
|
+
return matchDomain(record, expr);
|
|
2789
|
+
}
|
|
2790
|
+
toString() {
|
|
2791
|
+
return formatAST(this.ast);
|
|
2792
|
+
}
|
|
2793
|
+
toList(context) {
|
|
2794
|
+
return evaluate(this.ast, context);
|
|
2795
|
+
}
|
|
2796
|
+
toJson() {
|
|
2797
|
+
try {
|
|
2798
|
+
const evaluatedAsList = this.toList({});
|
|
2799
|
+
const evaluatedDomain = new _Domain(evaluatedAsList);
|
|
2800
|
+
if (evaluatedDomain.toString() === this.toString()) {
|
|
2801
|
+
return evaluatedAsList;
|
|
2802
|
+
}
|
|
2803
|
+
return this.toString();
|
|
2804
|
+
} catch {
|
|
2805
|
+
return this.toString();
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
};
|
|
2809
|
+
var TRUE_LEAF = [1, "=", 1];
|
|
2810
|
+
var FALSE_LEAF = [0, "=", 1];
|
|
2811
|
+
var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
|
|
2812
|
+
var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
|
|
2813
|
+
Domain.TRUE = TRUE_DOMAIN;
|
|
2814
|
+
Domain.FALSE = FALSE_DOMAIN;
|
|
2815
|
+
function toAST(domain) {
|
|
2816
|
+
const elems = domain.map((elem) => {
|
|
2817
|
+
switch (elem) {
|
|
2818
|
+
case "!":
|
|
2819
|
+
case "&":
|
|
2820
|
+
case "|":
|
|
2821
|
+
return { type: 1, value: elem };
|
|
2822
|
+
default:
|
|
2823
|
+
return {
|
|
2824
|
+
type: 10,
|
|
2825
|
+
value: elem.map(toPyValue)
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
});
|
|
2829
|
+
return { type: 4, value: elems };
|
|
2830
|
+
}
|
|
2831
|
+
function normalizeDomainAST(domain, op = "&") {
|
|
2832
|
+
if (domain.type !== 4) {
|
|
2833
|
+
if (domain.type === 10) {
|
|
2834
|
+
const value = domain.value;
|
|
2835
|
+
if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
|
|
2836
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2837
|
+
}
|
|
2838
|
+
} else {
|
|
2839
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
if (domain.value.length === 0) {
|
|
2843
|
+
return domain;
|
|
2844
|
+
}
|
|
2845
|
+
let expected = 1;
|
|
2846
|
+
for (const child of domain.value) {
|
|
2847
|
+
switch (child.type) {
|
|
2848
|
+
case 1:
|
|
2849
|
+
if (child.value === "&" || child.value === "|") {
|
|
2850
|
+
expected++;
|
|
2851
|
+
} else if (child.value !== "!") {
|
|
2852
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2853
|
+
}
|
|
2854
|
+
break;
|
|
2855
|
+
case 4:
|
|
2856
|
+
/* list */
|
|
2857
|
+
case 10:
|
|
2858
|
+
if (child.value.length === 3) {
|
|
2859
|
+
expected--;
|
|
2860
|
+
break;
|
|
2861
|
+
}
|
|
2862
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2863
|
+
default:
|
|
2864
|
+
throw new InvalidDomainError("Invalid domain AST");
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
const values = domain.value.slice();
|
|
2868
|
+
while (expected < 0) {
|
|
2869
|
+
expected++;
|
|
2870
|
+
values.unshift({ type: 1, value: op });
|
|
2871
|
+
}
|
|
2872
|
+
if (expected > 0) {
|
|
2873
|
+
throw new InvalidDomainError(
|
|
2874
|
+
`invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
|
|
2875
|
+
);
|
|
2876
|
+
}
|
|
2877
|
+
return { type: 4, value: values };
|
|
2878
|
+
}
|
|
2879
|
+
function matchCondition(record, condition) {
|
|
2880
|
+
if (typeof condition === "boolean") {
|
|
2881
|
+
return condition;
|
|
2882
|
+
}
|
|
2883
|
+
const [field, operator, value] = condition;
|
|
2884
|
+
if (typeof field === "string") {
|
|
2885
|
+
const names = field.split(".");
|
|
2886
|
+
if (names.length >= 2) {
|
|
2887
|
+
return matchCondition(record[names[0]], [
|
|
2888
|
+
names.slice(1).join("."),
|
|
2889
|
+
operator,
|
|
2890
|
+
value
|
|
2891
|
+
]);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
let likeRegexp, ilikeRegexp;
|
|
2895
|
+
if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
|
|
2896
|
+
likeRegexp = new RegExp(
|
|
2897
|
+
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2898
|
+
"g"
|
|
2899
|
+
);
|
|
2900
|
+
ilikeRegexp = new RegExp(
|
|
2901
|
+
`(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
|
|
2902
|
+
"gi"
|
|
2903
|
+
);
|
|
2904
|
+
}
|
|
2905
|
+
const fieldValue = typeof field === "number" ? field : record[field];
|
|
2906
|
+
switch (operator) {
|
|
2907
|
+
case "=?":
|
|
2908
|
+
if ([false, null].includes(value)) {
|
|
2909
|
+
return true;
|
|
2910
|
+
}
|
|
2911
|
+
// eslint-disable-next-line no-fallthrough
|
|
2912
|
+
case "=":
|
|
2913
|
+
case "==":
|
|
2914
|
+
if (Array.isArray(fieldValue) && Array.isArray(value)) {
|
|
2915
|
+
return shallowEqual2(fieldValue, value);
|
|
2916
|
+
}
|
|
2917
|
+
return fieldValue === value;
|
|
2918
|
+
case "!=":
|
|
2919
|
+
case "<>":
|
|
2920
|
+
return !matchCondition(record, [field, "==", value]);
|
|
2921
|
+
case "<":
|
|
2922
|
+
return fieldValue < value;
|
|
2923
|
+
case "<=":
|
|
2924
|
+
return fieldValue <= value;
|
|
2925
|
+
case ">":
|
|
2926
|
+
return fieldValue > value;
|
|
2927
|
+
case ">=":
|
|
2928
|
+
return fieldValue >= value;
|
|
2929
|
+
case "in": {
|
|
2930
|
+
const val = Array.isArray(value) ? value : [value];
|
|
2931
|
+
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2932
|
+
return fieldVal.some((fv) => val.includes(fv));
|
|
2933
|
+
}
|
|
2934
|
+
case "not in": {
|
|
2935
|
+
const val = Array.isArray(value) ? value : [value];
|
|
2936
|
+
const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
|
|
2937
|
+
return !fieldVal.some((fv) => val.includes(fv));
|
|
2938
|
+
}
|
|
2939
|
+
case "like":
|
|
2940
|
+
if (fieldValue === false) {
|
|
2941
|
+
return false;
|
|
2942
|
+
}
|
|
2943
|
+
return Boolean(fieldValue.match(likeRegexp));
|
|
2944
|
+
case "not like":
|
|
2945
|
+
if (fieldValue === false) {
|
|
2946
|
+
return false;
|
|
2947
|
+
}
|
|
2948
|
+
return Boolean(!fieldValue.match(likeRegexp));
|
|
2949
|
+
case "=like":
|
|
2950
|
+
if (fieldValue === false) {
|
|
2951
|
+
return false;
|
|
2952
|
+
}
|
|
2953
|
+
return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
|
|
2954
|
+
fieldValue
|
|
2955
|
+
);
|
|
2956
|
+
case "ilike":
|
|
2957
|
+
if (fieldValue === false) {
|
|
2958
|
+
return false;
|
|
2959
|
+
}
|
|
2960
|
+
return Boolean(fieldValue.match(ilikeRegexp));
|
|
2961
|
+
case "not ilike":
|
|
2962
|
+
if (fieldValue === false) {
|
|
2963
|
+
return false;
|
|
2964
|
+
}
|
|
2965
|
+
return Boolean(!fieldValue.match(ilikeRegexp));
|
|
2966
|
+
case "=ilike":
|
|
2967
|
+
if (fieldValue === false) {
|
|
2968
|
+
return false;
|
|
2969
|
+
}
|
|
2970
|
+
return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
|
|
2971
|
+
fieldValue
|
|
2972
|
+
);
|
|
2973
|
+
}
|
|
2974
|
+
throw new InvalidDomainError("could not match domain");
|
|
2975
|
+
}
|
|
2976
|
+
function makeOperators(record) {
|
|
2977
|
+
const match = matchCondition.bind(null, record);
|
|
2978
|
+
return {
|
|
2979
|
+
"!": (x) => !match(x),
|
|
2980
|
+
"&": (a, b) => match(a) && match(b),
|
|
2981
|
+
"|": (a, b) => match(a) || match(b)
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
function matchDomain(record, domain) {
|
|
2985
|
+
if (domain.length === 0) {
|
|
2986
|
+
return true;
|
|
2987
|
+
}
|
|
2988
|
+
const operators = makeOperators(record);
|
|
2989
|
+
const reversedDomain = Array.from(domain).reverse();
|
|
2990
|
+
const condStack = [];
|
|
2991
|
+
for (const item of reversedDomain) {
|
|
2992
|
+
const operator = typeof item === "string" && operators[item];
|
|
2993
|
+
if (operator) {
|
|
2994
|
+
const operands = condStack.splice(-operator.length);
|
|
2995
|
+
condStack.push(operator(...operands));
|
|
2996
|
+
} else {
|
|
2997
|
+
condStack.push(item);
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
return matchCondition(record, condStack.pop());
|
|
3001
|
+
}
|
|
3002
|
+
var checkDomain = (context, domain) => {
|
|
3003
|
+
try {
|
|
3004
|
+
if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
|
|
3005
|
+
return false;
|
|
3006
|
+
} else if (domain === "1" || domain === "True" || domain === true) {
|
|
3007
|
+
return true;
|
|
3008
|
+
}
|
|
3009
|
+
try {
|
|
3010
|
+
if (context && domain) {
|
|
3011
|
+
const d = new Domain(domain);
|
|
3012
|
+
return d.contains(context);
|
|
3013
|
+
}
|
|
3014
|
+
} catch (error) {
|
|
3015
|
+
if (context && domain) {
|
|
3016
|
+
const domainEval = evaluateBooleanExpr(domain, context);
|
|
3017
|
+
return domainEval;
|
|
3018
|
+
}
|
|
3019
|
+
return false;
|
|
3020
|
+
}
|
|
3021
|
+
return false;
|
|
3022
|
+
} catch (e) {
|
|
3023
|
+
return false;
|
|
3024
|
+
}
|
|
3025
|
+
};
|
|
3026
|
+
var matchDomains = (context, domains) => {
|
|
3027
|
+
if (Array.isArray(domains)) {
|
|
3028
|
+
if (domains?.length > 0) {
|
|
3029
|
+
return domains && domains.some((domain) => checkDomain(context, domain));
|
|
3030
|
+
}
|
|
3031
|
+
} else return checkDomain(context, domains);
|
|
3032
|
+
return false;
|
|
3033
|
+
};
|
|
3034
|
+
|
|
3035
|
+
// src/utils/function.ts
|
|
3036
|
+
var toQueryString = (params) => {
|
|
3037
|
+
return Object.keys(params).map(
|
|
3038
|
+
(key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
|
|
3039
|
+
).join("&");
|
|
3040
|
+
};
|
|
3041
|
+
var isBase64File = (str) => {
|
|
3042
|
+
try {
|
|
3043
|
+
const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
|
|
3044
|
+
if (dataUriPattern.test(str)) {
|
|
3045
|
+
return true;
|
|
3046
|
+
}
|
|
3047
|
+
const base64Pattern = (
|
|
3048
|
+
// eslint-disable-next-line no-useless-escape
|
|
3049
|
+
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
|
|
3050
|
+
);
|
|
3051
|
+
return base64Pattern.test(str);
|
|
3052
|
+
} catch (e) {
|
|
3053
|
+
return false;
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
|
|
3057
|
+
// src/services/action-service/index.ts
|
|
3058
|
+
var ActionService = {
|
|
3059
|
+
async loadAction({
|
|
3060
|
+
idAction,
|
|
3061
|
+
context
|
|
3062
|
+
}) {
|
|
3063
|
+
const env2 = getEnv();
|
|
3064
|
+
const jsonData = {
|
|
3065
|
+
action_id: idAction,
|
|
3066
|
+
with_context: {
|
|
3067
|
+
...context
|
|
3068
|
+
}
|
|
3069
|
+
};
|
|
3070
|
+
return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
|
|
3071
|
+
headers: {
|
|
3072
|
+
"Content-Type": "application/json"
|
|
3073
|
+
}
|
|
3074
|
+
});
|
|
3075
|
+
},
|
|
3076
|
+
async callButton({
|
|
3077
|
+
model,
|
|
3078
|
+
ids = [],
|
|
3079
|
+
context,
|
|
3080
|
+
method
|
|
3081
|
+
}) {
|
|
3082
|
+
try {
|
|
3083
|
+
const env2 = getEnv();
|
|
3084
|
+
const jsonData = {
|
|
3085
|
+
model,
|
|
3086
|
+
method,
|
|
3087
|
+
ids,
|
|
3088
|
+
with_context: context
|
|
3089
|
+
};
|
|
3090
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3091
|
+
headers: {
|
|
3092
|
+
"Content-Type": "application/json"
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
} catch (error) {
|
|
3096
|
+
console.error("Error when calling button action:", error);
|
|
3097
|
+
throw error;
|
|
3098
|
+
}
|
|
3099
|
+
},
|
|
3100
|
+
async removeRows({
|
|
3101
|
+
model,
|
|
3102
|
+
ids,
|
|
3103
|
+
context
|
|
3104
|
+
}) {
|
|
3105
|
+
const env2 = getEnv();
|
|
3106
|
+
const jsonData = {
|
|
3107
|
+
model,
|
|
3108
|
+
method: "unlink",
|
|
3109
|
+
ids,
|
|
3110
|
+
with_context: context
|
|
3111
|
+
};
|
|
3112
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3113
|
+
headers: {
|
|
3114
|
+
"Content-Type": "application/json"
|
|
3115
|
+
}
|
|
3116
|
+
});
|
|
3117
|
+
},
|
|
3118
|
+
async duplicateRecord({
|
|
3119
|
+
model,
|
|
3120
|
+
id,
|
|
3121
|
+
context
|
|
3122
|
+
}) {
|
|
3123
|
+
const env2 = getEnv();
|
|
3124
|
+
const jsonData = {
|
|
3125
|
+
model,
|
|
3126
|
+
method: "copy",
|
|
3127
|
+
ids: id,
|
|
3128
|
+
with_context: context
|
|
3129
|
+
};
|
|
3130
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3131
|
+
headers: {
|
|
3132
|
+
"Content-Type": "application/json"
|
|
3133
|
+
}
|
|
3134
|
+
});
|
|
3135
|
+
},
|
|
3136
|
+
async print({ id, report, db }) {
|
|
3137
|
+
const env2 = getEnv();
|
|
3138
|
+
const jsonData = {
|
|
3139
|
+
report,
|
|
3140
|
+
id,
|
|
3141
|
+
type: "pdf",
|
|
3142
|
+
file_response: true,
|
|
3143
|
+
db
|
|
3144
|
+
};
|
|
3145
|
+
const queryString = toQueryString(jsonData);
|
|
3146
|
+
const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
|
|
3147
|
+
return env2.requests.get(urlWithParams, {
|
|
3148
|
+
headers: {
|
|
3149
|
+
"Content-Type": "application/json"
|
|
3150
|
+
},
|
|
3151
|
+
responseType: "arraybuffer"
|
|
3152
|
+
});
|
|
3153
|
+
},
|
|
3154
|
+
async runAction({
|
|
3155
|
+
idAction,
|
|
3156
|
+
context
|
|
3157
|
+
}) {
|
|
3158
|
+
const env2 = getEnv();
|
|
3159
|
+
const jsonData = {
|
|
3160
|
+
action_id: idAction,
|
|
3161
|
+
with_context: {
|
|
3162
|
+
...context
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
|
|
3166
|
+
headers: {
|
|
3167
|
+
"Content-Type": "application/json"
|
|
3168
|
+
}
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
};
|
|
3172
|
+
var action_service_default = ActionService;
|
|
3173
|
+
|
|
3174
|
+
// src/services/auth-service/index.ts
|
|
3175
|
+
var AuthService = {
|
|
3176
|
+
async login(body) {
|
|
3177
|
+
const env2 = getEnv();
|
|
3178
|
+
const payload = Object.fromEntries(
|
|
3179
|
+
Object.entries({
|
|
3180
|
+
username: body.email,
|
|
3181
|
+
password: body.password,
|
|
3182
|
+
grant_type: env2?.config?.grantType || "",
|
|
3183
|
+
client_id: env2?.config?.clientId || "",
|
|
3184
|
+
client_secret: env2?.config?.clientSecret || ""
|
|
3185
|
+
}).filter(([_, value]) => !!value)
|
|
3186
|
+
);
|
|
3187
|
+
const encodedData = new URLSearchParams(payload).toString();
|
|
3188
|
+
return env2?.requests?.post(body.path, encodedData, {
|
|
3189
|
+
headers: {
|
|
3190
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3191
|
+
}
|
|
3192
|
+
});
|
|
3193
|
+
},
|
|
3194
|
+
async forgotPassword(email) {
|
|
3195
|
+
const env2 = getEnv();
|
|
3196
|
+
const bodyData = {
|
|
3197
|
+
login: email,
|
|
3198
|
+
url: `${window.location.origin}/reset-password`
|
|
3199
|
+
};
|
|
3200
|
+
return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
|
|
3201
|
+
headers: {
|
|
3202
|
+
"Content-Type": "application/json"
|
|
3203
|
+
}
|
|
3204
|
+
});
|
|
3205
|
+
},
|
|
3206
|
+
async resetPassword(data, token) {
|
|
3207
|
+
const env2 = getEnv();
|
|
3208
|
+
const bodyData = {
|
|
3209
|
+
token,
|
|
3210
|
+
password: data.password,
|
|
3211
|
+
new_password: data.confirmPassword
|
|
3212
|
+
};
|
|
3213
|
+
return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
|
|
3214
|
+
headers: {
|
|
3215
|
+
"Content-Type": "application/json"
|
|
3216
|
+
}
|
|
3217
|
+
});
|
|
3218
|
+
},
|
|
3219
|
+
async updatePassword(data, token) {
|
|
3220
|
+
const env2 = getEnv();
|
|
3221
|
+
const bodyData = {
|
|
3222
|
+
token,
|
|
3223
|
+
old_password: data.oldPassword,
|
|
3224
|
+
new_password: data.newPassword
|
|
3225
|
+
};
|
|
3226
|
+
return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
|
|
3227
|
+
headers: {
|
|
3228
|
+
"Content-Type": "application/json"
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
3231
|
+
},
|
|
3232
|
+
async isValidToken(token) {
|
|
3233
|
+
const env2 = getEnv();
|
|
3234
|
+
const bodyData = {
|
|
3235
|
+
token
|
|
3236
|
+
};
|
|
3237
|
+
return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
|
|
3238
|
+
headers: {
|
|
3239
|
+
"Content-Type": "application/json"
|
|
3240
|
+
}
|
|
3241
|
+
});
|
|
3242
|
+
},
|
|
3243
|
+
async loginSocial({
|
|
3244
|
+
state,
|
|
3245
|
+
access_token
|
|
3246
|
+
}) {
|
|
3247
|
+
const env2 = getEnv();
|
|
3248
|
+
return env2?.requests?.post(
|
|
3249
|
+
"/token/generate" /* GENTOKEN_SOCIAL */,
|
|
3250
|
+
{ state, access_token },
|
|
3251
|
+
{
|
|
3252
|
+
headers: {
|
|
3253
|
+
"Content-Type": "application/json"
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
);
|
|
3257
|
+
},
|
|
3258
|
+
async getProviders(db) {
|
|
3259
|
+
const env2 = getEnv();
|
|
3260
|
+
return env2?.requests?.get("/oauth/providers", { params: { db } });
|
|
3261
|
+
}
|
|
3262
|
+
};
|
|
3263
|
+
var auth_service_default = AuthService;
|
|
3264
|
+
|
|
3265
|
+
// src/constants/widget/widget-avatar-constant.ts
|
|
3266
|
+
var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
|
|
3267
|
+
WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
|
|
3268
|
+
WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
|
|
3269
|
+
return WIDGETAVATAR2;
|
|
3270
|
+
})(WIDGETAVATAR || {});
|
|
3271
|
+
|
|
3272
|
+
// src/services/company-service/index.ts
|
|
3273
|
+
var CompanyService = {
|
|
3274
|
+
async getCurrentCompany() {
|
|
3275
|
+
const env2 = getEnv();
|
|
3276
|
+
return await env2.requests.get("/company" /* COMPANY_PATH */, {
|
|
3277
|
+
headers: {
|
|
3278
|
+
"Content-Type": "application/json"
|
|
3279
|
+
}
|
|
3280
|
+
});
|
|
3281
|
+
},
|
|
3282
|
+
async getInfoCompany(id) {
|
|
3283
|
+
const env2 = getEnv();
|
|
3284
|
+
const jsonData = {
|
|
3285
|
+
ids: [id],
|
|
3286
|
+
model: "res.company" /* COMPANY */,
|
|
3287
|
+
method: "web_read" /* WEB_READ */,
|
|
3288
|
+
kwargs: {
|
|
3289
|
+
specification: {
|
|
3290
|
+
primary_color: {},
|
|
3291
|
+
secondary_color: {},
|
|
3292
|
+
logo: {},
|
|
3293
|
+
display_name: {},
|
|
3294
|
+
secondary_logo: {}
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
};
|
|
3298
|
+
return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3299
|
+
headers: {
|
|
3300
|
+
"Content-Type": "application/json"
|
|
3301
|
+
}
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
};
|
|
3305
|
+
var company_service_default = CompanyService;
|
|
3306
|
+
|
|
3307
|
+
// src/services/excel-service/index.ts
|
|
3308
|
+
var ExcelService = {
|
|
3309
|
+
async uploadFile({ formData }) {
|
|
3310
|
+
const env2 = getEnv();
|
|
3311
|
+
return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
|
|
3312
|
+
headers: {
|
|
3313
|
+
"Content-Type": "multipart/form-data"
|
|
3314
|
+
}
|
|
3315
|
+
});
|
|
3316
|
+
},
|
|
3317
|
+
async uploadIdFile({ formData }) {
|
|
3318
|
+
const env2 = getEnv();
|
|
3319
|
+
return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
|
|
3320
|
+
headers: {
|
|
3321
|
+
"Content-Type": "multipart/form-data"
|
|
3322
|
+
}
|
|
3323
|
+
});
|
|
3324
|
+
},
|
|
3325
|
+
async parsePreview({
|
|
3326
|
+
id,
|
|
3327
|
+
selectedSheet,
|
|
3328
|
+
isHeader,
|
|
3329
|
+
context
|
|
3330
|
+
}) {
|
|
3331
|
+
const env2 = getEnv();
|
|
3332
|
+
const jsonData = {
|
|
3333
|
+
model: "base_import.import" /* BASE_IMPORT */,
|
|
3334
|
+
method: "parse_preview",
|
|
3335
|
+
ids: [id],
|
|
3336
|
+
kwargs: {
|
|
3337
|
+
options: {
|
|
3338
|
+
import_skip_records: [],
|
|
3339
|
+
import_set_empty_fields: [],
|
|
3340
|
+
fallback_values: {},
|
|
3341
|
+
name_create_enabled_fields: {},
|
|
3342
|
+
encoding: "",
|
|
3343
|
+
separator: "",
|
|
3344
|
+
quoting: '"',
|
|
3345
|
+
date_format: "",
|
|
3346
|
+
datetime_format: "",
|
|
3347
|
+
float_thousand_separator: ",",
|
|
3348
|
+
float_decimal_separator: ".",
|
|
3349
|
+
advanced: true,
|
|
3350
|
+
has_headers: isHeader,
|
|
3351
|
+
keep_matches: false,
|
|
3352
|
+
limit: 2e3,
|
|
3353
|
+
sheets: [],
|
|
3354
|
+
sheet: selectedSheet,
|
|
3355
|
+
skip: 0,
|
|
3356
|
+
tracking_disable: true
|
|
3357
|
+
}
|
|
3358
|
+
},
|
|
3359
|
+
with_context: context
|
|
3360
|
+
};
|
|
3361
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3362
|
+
headers: {
|
|
3363
|
+
"Content-Type": "multipart/form-data"
|
|
3364
|
+
}
|
|
3365
|
+
});
|
|
3366
|
+
},
|
|
3367
|
+
async executeImport({
|
|
3368
|
+
columns,
|
|
3369
|
+
fields,
|
|
3370
|
+
idFile,
|
|
3371
|
+
options,
|
|
3372
|
+
dryrun,
|
|
3373
|
+
context
|
|
3374
|
+
}) {
|
|
3375
|
+
const env2 = getEnv();
|
|
3376
|
+
const jsonData = {
|
|
3377
|
+
model: "base_import.import" /* BASE_IMPORT */,
|
|
3378
|
+
method: "execute_import",
|
|
3379
|
+
ids: [idFile],
|
|
3380
|
+
kwargs: {
|
|
3381
|
+
fields,
|
|
3382
|
+
columns,
|
|
3383
|
+
options,
|
|
3384
|
+
dryrun
|
|
3385
|
+
},
|
|
3386
|
+
with_context: context
|
|
3387
|
+
};
|
|
3388
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3389
|
+
headers: {
|
|
3390
|
+
"Content-Type": "multipart/form-data"
|
|
3391
|
+
}
|
|
3392
|
+
});
|
|
3393
|
+
},
|
|
3394
|
+
async getFileExcel({ model, context }) {
|
|
3395
|
+
const env2 = getEnv();
|
|
3396
|
+
const jsonData = {
|
|
3397
|
+
model,
|
|
3398
|
+
method: "get_import_templates" /* GET_IMPORT */,
|
|
3399
|
+
args: [],
|
|
3400
|
+
with_context: context
|
|
3401
|
+
};
|
|
3402
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData);
|
|
3403
|
+
},
|
|
3404
|
+
async getFieldExport({
|
|
3405
|
+
ids,
|
|
3406
|
+
model,
|
|
3407
|
+
isShow,
|
|
3408
|
+
parentField,
|
|
3409
|
+
fieldType,
|
|
3410
|
+
parentName,
|
|
3411
|
+
prefix,
|
|
3412
|
+
name,
|
|
3413
|
+
context,
|
|
3414
|
+
importCompat
|
|
3415
|
+
}) {
|
|
3416
|
+
const env2 = getEnv();
|
|
3417
|
+
const jsonData = {
|
|
3418
|
+
model,
|
|
3419
|
+
import_compat: importCompat,
|
|
3420
|
+
domain: [["id", "in", ids]],
|
|
3421
|
+
with_context: context
|
|
3422
|
+
};
|
|
3423
|
+
if (isShow) {
|
|
3424
|
+
jsonData.parent_field = parentField;
|
|
3425
|
+
jsonData.parent_field_type = fieldType;
|
|
3426
|
+
jsonData.parent_name = parentName;
|
|
3427
|
+
jsonData.name = name;
|
|
3428
|
+
jsonData.prefix = prefix;
|
|
3429
|
+
jsonData.exclude = [null];
|
|
3430
|
+
}
|
|
3431
|
+
return env2.requests.post("/export/get_fields", jsonData);
|
|
3432
|
+
},
|
|
3433
|
+
async exportExcel({
|
|
3434
|
+
model,
|
|
3435
|
+
domain,
|
|
3436
|
+
ids,
|
|
3437
|
+
fields,
|
|
3438
|
+
type,
|
|
3439
|
+
importCompat,
|
|
3440
|
+
context,
|
|
3441
|
+
groupby
|
|
3442
|
+
}) {
|
|
3443
|
+
const env2 = getEnv();
|
|
3444
|
+
const jsonData = {
|
|
3445
|
+
model,
|
|
3446
|
+
domain,
|
|
3447
|
+
ids,
|
|
3448
|
+
import_compat: importCompat,
|
|
3449
|
+
fields,
|
|
3450
|
+
with_context: context,
|
|
3451
|
+
groupby: groupby ?? []
|
|
3452
|
+
};
|
|
3453
|
+
return env2.requests.post_excel(`/export/${type}`, jsonData);
|
|
3454
|
+
}
|
|
3455
|
+
};
|
|
3456
|
+
var excel_service_default = ExcelService;
|
|
3457
|
+
|
|
3458
|
+
// src/services/form-service/index.ts
|
|
3459
|
+
var FormService = {
|
|
3460
|
+
async getComment({ data }) {
|
|
3461
|
+
try {
|
|
3462
|
+
const env2 = getEnv();
|
|
3463
|
+
const jsonData = {
|
|
3464
|
+
thread_id: data.thread_id,
|
|
3465
|
+
thread_model: data.thread_model,
|
|
3466
|
+
limit: 100,
|
|
3467
|
+
with_context: {
|
|
3468
|
+
lang: data.lang
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
|
|
3472
|
+
headers: {
|
|
3473
|
+
"Content-Type": "application/json"
|
|
3474
|
+
}
|
|
3475
|
+
});
|
|
3476
|
+
} catch (error) {
|
|
3477
|
+
console.error("Error when sending message:", error);
|
|
3478
|
+
throw error;
|
|
3479
|
+
}
|
|
3480
|
+
},
|
|
3481
|
+
async sentComment({ data }) {
|
|
3482
|
+
try {
|
|
3483
|
+
const env2 = getEnv();
|
|
3484
|
+
const jsonData = {
|
|
3485
|
+
context: {
|
|
3486
|
+
tz: "Asia/Saigon",
|
|
3487
|
+
uid: 2,
|
|
3488
|
+
allowed_company_ids: [1],
|
|
3489
|
+
mail_post_autofollow: false,
|
|
3490
|
+
temporary_id: 142183.01
|
|
3491
|
+
},
|
|
3492
|
+
post_data: {
|
|
3493
|
+
body: data.message,
|
|
3494
|
+
message_type: "comment",
|
|
3495
|
+
attachment_ids: data.attachment_ids,
|
|
3496
|
+
attachment_tokens: [],
|
|
3497
|
+
subtype_xmlid: data.subtype
|
|
3498
|
+
},
|
|
3499
|
+
thread_id: Number(data.thread_id),
|
|
3500
|
+
thread_model: data.thread_model
|
|
3501
|
+
};
|
|
3502
|
+
return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
|
|
3503
|
+
headers: {
|
|
3504
|
+
"Content-Type": "application/json"
|
|
3505
|
+
}
|
|
3506
|
+
});
|
|
3507
|
+
} catch (error) {
|
|
3508
|
+
console.error("Error when sent message:", error);
|
|
3509
|
+
throw error;
|
|
3510
|
+
}
|
|
3511
|
+
},
|
|
3512
|
+
async deleteComment({ data }) {
|
|
3513
|
+
try {
|
|
3514
|
+
const env2 = getEnv();
|
|
3515
|
+
const jsonData = {
|
|
3516
|
+
attachment_ids: [],
|
|
3517
|
+
attachment_tokens: [],
|
|
3518
|
+
body: "",
|
|
3519
|
+
message_id: data.message_id
|
|
3520
|
+
};
|
|
3521
|
+
return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
|
|
3522
|
+
headers: {
|
|
3523
|
+
"Content-Type": "application/json"
|
|
3524
|
+
}
|
|
3525
|
+
});
|
|
3526
|
+
} catch (error) {
|
|
3527
|
+
console.error("Error when sent message:", error);
|
|
3528
|
+
throw error;
|
|
3529
|
+
}
|
|
3530
|
+
},
|
|
3531
|
+
async getImage({ data }) {
|
|
3532
|
+
try {
|
|
3533
|
+
const env2 = getEnv();
|
|
3534
|
+
return env2.requests.get(
|
|
3535
|
+
`${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
|
|
3536
|
+
{
|
|
3537
|
+
headers: {
|
|
3538
|
+
"Content-Type": "application/json"
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
);
|
|
3542
|
+
} catch (error) {
|
|
3543
|
+
console.error("Error when sent message:", error);
|
|
3544
|
+
throw error;
|
|
3545
|
+
}
|
|
3546
|
+
},
|
|
3547
|
+
async uploadImage({ data }) {
|
|
3548
|
+
try {
|
|
3549
|
+
const env2 = getEnv();
|
|
3550
|
+
return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
|
|
3551
|
+
headers: {
|
|
3552
|
+
"Content-Type": "multipart/form-data"
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3555
|
+
} catch (error) {
|
|
3556
|
+
console.error("Error when sent message:", error);
|
|
3557
|
+
throw error;
|
|
3558
|
+
}
|
|
3559
|
+
},
|
|
3560
|
+
async getFormView({ data }) {
|
|
3561
|
+
try {
|
|
3562
|
+
const env2 = getEnv();
|
|
3563
|
+
const jsonData = {
|
|
3564
|
+
model: data.model,
|
|
3565
|
+
method: "get_formview_action",
|
|
3566
|
+
ids: data.id ? [data.id] : [],
|
|
3567
|
+
with_context: data.context
|
|
3568
|
+
};
|
|
3569
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3570
|
+
headers: {
|
|
3571
|
+
"Content-Type": "application/json"
|
|
3572
|
+
}
|
|
3573
|
+
});
|
|
3574
|
+
} catch (error) {
|
|
3575
|
+
console.error("Error when fetching form view:", error);
|
|
3576
|
+
throw error;
|
|
3577
|
+
}
|
|
3578
|
+
},
|
|
3579
|
+
async changeStatus({ data }) {
|
|
3580
|
+
const env2 = getEnv();
|
|
3581
|
+
const vals = {
|
|
3582
|
+
[data.name]: data.stage_id
|
|
3583
|
+
};
|
|
3584
|
+
const jsonData = {
|
|
3585
|
+
model: data.model,
|
|
3586
|
+
method: "web_save",
|
|
3587
|
+
with_context: {
|
|
3588
|
+
lang: data.lang,
|
|
3589
|
+
allowed_company_ids: [1],
|
|
3590
|
+
uid: 2,
|
|
3591
|
+
search_default_my_ticket: true,
|
|
3592
|
+
search_default_is_open: true
|
|
3593
|
+
},
|
|
3594
|
+
ids: [data.id],
|
|
3595
|
+
kwargs: {
|
|
3596
|
+
vals,
|
|
3597
|
+
specification: {}
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3600
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3601
|
+
headers: {
|
|
3602
|
+
"Content-Type": "application/json"
|
|
3603
|
+
}
|
|
3604
|
+
});
|
|
3605
|
+
}
|
|
3606
|
+
};
|
|
3607
|
+
var form_service_default = FormService;
|
|
3608
|
+
|
|
3609
|
+
// src/services/model-service/index.ts
|
|
3610
|
+
var OBJECT_POSITION = 2;
|
|
3611
|
+
var ModelService = {
|
|
3612
|
+
async getAll({ data }) {
|
|
3613
|
+
const env2 = getEnv();
|
|
3614
|
+
const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
|
|
3615
|
+
fields: data.fields,
|
|
3616
|
+
groupby: data.groupby
|
|
3617
|
+
} : {
|
|
3618
|
+
count_limit: 10001,
|
|
3619
|
+
order: data.sort,
|
|
3620
|
+
specification: data.specification
|
|
3621
|
+
};
|
|
3622
|
+
const jsonData = {
|
|
3623
|
+
model: String(data.model),
|
|
3624
|
+
method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
|
|
3625
|
+
ids: data.ids,
|
|
3626
|
+
with_context: data.context,
|
|
3627
|
+
kwargs: {
|
|
3628
|
+
domain: data.domain,
|
|
3629
|
+
limit: data.limit,
|
|
3630
|
+
offset: data.offset,
|
|
3631
|
+
...jsonReadGroup
|
|
3632
|
+
}
|
|
3633
|
+
};
|
|
3634
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3635
|
+
headers: {
|
|
3636
|
+
"Content-Type": "application/json"
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
},
|
|
3640
|
+
async getList({
|
|
3641
|
+
model,
|
|
3642
|
+
ids = [],
|
|
3643
|
+
specification = {},
|
|
3644
|
+
domain = [],
|
|
3645
|
+
offset,
|
|
3646
|
+
order,
|
|
3647
|
+
context = {},
|
|
3648
|
+
limit = 10
|
|
3649
|
+
}) {
|
|
3650
|
+
const env2 = getEnv();
|
|
3651
|
+
const jsonData = {
|
|
3652
|
+
model,
|
|
3653
|
+
method: "web_search_read" /* WEB_SEARCH_READ */,
|
|
3654
|
+
ids,
|
|
3655
|
+
with_context: context,
|
|
3656
|
+
kwargs: {
|
|
3657
|
+
specification,
|
|
3658
|
+
domain,
|
|
3659
|
+
limit,
|
|
3660
|
+
offset,
|
|
3661
|
+
order
|
|
3662
|
+
}
|
|
3663
|
+
};
|
|
3664
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3665
|
+
headers: {
|
|
3666
|
+
"Content-Type": "application/json"
|
|
3667
|
+
}
|
|
3668
|
+
});
|
|
3669
|
+
},
|
|
3670
|
+
async getDetail({
|
|
3671
|
+
ids = [],
|
|
3672
|
+
model,
|
|
3673
|
+
specification,
|
|
3674
|
+
context
|
|
3675
|
+
}) {
|
|
3676
|
+
const env2 = getEnv();
|
|
3677
|
+
const jsonData = {
|
|
3678
|
+
model,
|
|
3679
|
+
method: "web_read" /* WEB_READ */,
|
|
3680
|
+
ids,
|
|
3681
|
+
with_context: context,
|
|
3682
|
+
kwargs: {
|
|
3683
|
+
specification
|
|
3684
|
+
}
|
|
3685
|
+
};
|
|
3686
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3687
|
+
headers: {
|
|
3688
|
+
"Content-Type": "application/json"
|
|
3689
|
+
}
|
|
3690
|
+
});
|
|
3691
|
+
},
|
|
3692
|
+
async save({
|
|
3693
|
+
model,
|
|
3694
|
+
ids = [],
|
|
3695
|
+
data = {},
|
|
3696
|
+
specification = {},
|
|
3697
|
+
context = {}
|
|
3698
|
+
}) {
|
|
3699
|
+
const env2 = getEnv();
|
|
3700
|
+
const jsonData = {
|
|
3701
|
+
model,
|
|
3702
|
+
method: "web_save" /* WEB_SAVE */,
|
|
3703
|
+
with_context: context,
|
|
3704
|
+
ids,
|
|
3705
|
+
kwargs: {
|
|
3706
|
+
vals: data,
|
|
3707
|
+
specification
|
|
3708
|
+
}
|
|
3709
|
+
};
|
|
3710
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3711
|
+
headers: {
|
|
3712
|
+
"Content-Type": "application/json"
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3715
|
+
},
|
|
3716
|
+
async delete({ ids = [], model }) {
|
|
3717
|
+
const env2 = getEnv();
|
|
3718
|
+
const jsonData = {
|
|
3719
|
+
model,
|
|
3720
|
+
method: "unlink" /* UNLINK */,
|
|
3721
|
+
ids
|
|
3722
|
+
};
|
|
3723
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3724
|
+
headers: {
|
|
3725
|
+
"Content-Type": "application/json"
|
|
3726
|
+
}
|
|
3727
|
+
});
|
|
3728
|
+
},
|
|
3729
|
+
async onChange({
|
|
3730
|
+
ids = [],
|
|
3731
|
+
model,
|
|
3732
|
+
object,
|
|
3733
|
+
specification,
|
|
3734
|
+
context,
|
|
3735
|
+
fieldChange
|
|
3736
|
+
}) {
|
|
3737
|
+
const env2 = getEnv();
|
|
3738
|
+
const jsonData = {
|
|
3739
|
+
model,
|
|
3740
|
+
method: "onchange" /* ONCHANGE */,
|
|
3741
|
+
ids,
|
|
3742
|
+
with_context: context,
|
|
3743
|
+
args: [
|
|
3744
|
+
object ? object : {},
|
|
3745
|
+
fieldChange ? fieldChange : [],
|
|
3746
|
+
specification
|
|
3747
|
+
]
|
|
3748
|
+
};
|
|
3749
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3750
|
+
headers: {
|
|
3751
|
+
"Content-Type": "application/json"
|
|
3752
|
+
}
|
|
3753
|
+
});
|
|
3754
|
+
},
|
|
3755
|
+
async getListFieldsOnchange({ model }) {
|
|
3756
|
+
const env2 = getEnv();
|
|
3757
|
+
const jsonData = {
|
|
3758
|
+
model,
|
|
3759
|
+
method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
|
|
3760
|
+
};
|
|
3761
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
3762
|
+
headers: {
|
|
3763
|
+
"Content-Type": "application/json"
|
|
3764
|
+
}
|
|
3765
|
+
});
|
|
3766
|
+
},
|
|
3767
|
+
parseORMOdoo(data) {
|
|
3768
|
+
for (const key in data) {
|
|
3769
|
+
if (key === "display_name") {
|
|
3770
|
+
delete data[key];
|
|
3771
|
+
}
|
|
3772
|
+
if (!data[key] && data[key] !== 0) {
|
|
3773
|
+
data[key] = false;
|
|
3774
|
+
} else if (data[key] === "Draft") {
|
|
3775
|
+
data[key] = "/";
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
return { ...data };
|
|
3779
|
+
},
|
|
3780
|
+
toDataJS(data, viewData, model) {
|
|
3781
|
+
for (const key in data) {
|
|
3782
|
+
if (data[key] === false) {
|
|
3783
|
+
if (viewData && model) {
|
|
3784
|
+
if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
|
|
3785
|
+
data[key] = null;
|
|
3786
|
+
}
|
|
3787
|
+
} else {
|
|
3788
|
+
data[key] = null;
|
|
3789
|
+
}
|
|
3790
|
+
} else if (data[key] === "/") {
|
|
3791
|
+
data[key] = "Draft";
|
|
3792
|
+
} else if (data[key] !== false) {
|
|
3793
|
+
if (model !== void 0) {
|
|
3794
|
+
if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
|
|
3795
|
+
data[key] = (data[key] ??= [])?.map((item, index) => {
|
|
3796
|
+
const relation = viewData?.models?.[model]?.[key]?.relation;
|
|
3797
|
+
if (relation !== void 0) {
|
|
3798
|
+
if (viewData?.models?.[relation]) {
|
|
3799
|
+
if (item?.length >= 3) {
|
|
3800
|
+
if (item[0] === 2 /* DELETE */) {
|
|
3801
|
+
delete data[key][index];
|
|
3802
|
+
return;
|
|
3803
|
+
}
|
|
3804
|
+
return ModelService.toDataJS(
|
|
3805
|
+
{ ...item[OBJECT_POSITION], id: `virtual_${index}` },
|
|
3806
|
+
viewData,
|
|
3807
|
+
relation
|
|
3808
|
+
);
|
|
3809
|
+
} else {
|
|
3810
|
+
return ModelService.toDataJS(item, viewData, relation);
|
|
3811
|
+
}
|
|
3812
|
+
} else {
|
|
3813
|
+
if (item?.length >= 3) {
|
|
3814
|
+
if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
|
|
3815
|
+
delete data[key][index];
|
|
3816
|
+
return;
|
|
3817
|
+
}
|
|
3818
|
+
return item[OBJECT_POSITION];
|
|
3819
|
+
} else {
|
|
3820
|
+
return item;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
});
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
return { ...data };
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
var model_service_default = ModelService;
|
|
3833
|
+
|
|
3834
|
+
// src/services/user-service/index.ts
|
|
3835
|
+
var UserService = {
|
|
3836
|
+
async getProfile() {
|
|
3837
|
+
const env2 = getEnv();
|
|
3838
|
+
return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
|
|
3839
|
+
headers: {
|
|
3840
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3841
|
+
}
|
|
3842
|
+
});
|
|
3843
|
+
},
|
|
3844
|
+
async getUser({ context, id }) {
|
|
3845
|
+
const env2 = getEnv();
|
|
3846
|
+
const jsonData = {
|
|
3847
|
+
model: "res.users",
|
|
3848
|
+
method: "web_read",
|
|
3849
|
+
ids: [id],
|
|
3850
|
+
with_context: context,
|
|
3851
|
+
kwargs: {
|
|
3852
|
+
specification: {
|
|
3853
|
+
display_name: {},
|
|
3854
|
+
image_1920: {},
|
|
3855
|
+
name: {},
|
|
3856
|
+
login: {},
|
|
3857
|
+
email: {},
|
|
3858
|
+
password: {},
|
|
3859
|
+
visible_group_id: {
|
|
3860
|
+
fields: {
|
|
3861
|
+
id: {},
|
|
3862
|
+
display_name: {}
|
|
3863
|
+
}
|
|
3864
|
+
},
|
|
3865
|
+
company_id: {
|
|
3866
|
+
fields: {
|
|
3867
|
+
id: {},
|
|
3868
|
+
display_name: {}
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
};
|
|
3874
|
+
return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
3875
|
+
headers: {
|
|
3876
|
+
"Content-Type": "application/json"
|
|
3877
|
+
}
|
|
3878
|
+
});
|
|
3879
|
+
},
|
|
3880
|
+
switchUserLocale: async ({ id, values }) => {
|
|
3881
|
+
const env2 = getEnv();
|
|
3882
|
+
const jsonData = {
|
|
3883
|
+
model: "res.users",
|
|
3884
|
+
domain: [["id", "=", id]],
|
|
3885
|
+
values
|
|
3886
|
+
};
|
|
3887
|
+
return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
|
|
3888
|
+
headers: {
|
|
3889
|
+
"Content-Type": "application/json"
|
|
3890
|
+
}
|
|
3891
|
+
});
|
|
3892
|
+
}
|
|
3893
|
+
};
|
|
3894
|
+
var user_service_default = UserService;
|
|
3895
|
+
|
|
3896
|
+
// src/services/view-service/index.ts
|
|
3897
|
+
var ViewService = {
|
|
3898
|
+
async getView({
|
|
3899
|
+
model,
|
|
3900
|
+
views,
|
|
3901
|
+
context = {},
|
|
3902
|
+
options = {},
|
|
3903
|
+
aid
|
|
3904
|
+
}) {
|
|
3905
|
+
const env2 = getEnv();
|
|
3906
|
+
const defaultOptions = {
|
|
3907
|
+
load_filters: true,
|
|
3908
|
+
toolbar: true,
|
|
3909
|
+
action_id: aid
|
|
3910
|
+
};
|
|
3911
|
+
const jsonDataView = {
|
|
3912
|
+
model,
|
|
3913
|
+
method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
|
|
3914
|
+
kwargs: {
|
|
3915
|
+
views,
|
|
3916
|
+
options: { ...options, ...defaultOptions }
|
|
3917
|
+
},
|
|
3918
|
+
with_context: context
|
|
3919
|
+
};
|
|
3920
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
|
|
3921
|
+
headers: {
|
|
3922
|
+
"Content-Type": "application/json"
|
|
3923
|
+
}
|
|
3924
|
+
});
|
|
3925
|
+
},
|
|
3926
|
+
async getMenu(context) {
|
|
3927
|
+
const env2 = getEnv();
|
|
3928
|
+
const jsonData = {
|
|
3929
|
+
model: "ir.ui.menu" /* MENU */,
|
|
3930
|
+
method: "web_search_read" /* WEB_SEARCH_READ */,
|
|
3931
|
+
ids: [],
|
|
3932
|
+
with_context: context,
|
|
3933
|
+
kwargs: {
|
|
3934
|
+
specification: {
|
|
3935
|
+
active: {},
|
|
3936
|
+
name: {},
|
|
3937
|
+
is_display: {},
|
|
3938
|
+
sequence: {},
|
|
3939
|
+
complete_name: {},
|
|
3940
|
+
action: {
|
|
3941
|
+
fields: {
|
|
3942
|
+
display_name: {},
|
|
3943
|
+
type: {},
|
|
3944
|
+
binding_view_types: {}
|
|
3945
|
+
// res_model: {},
|
|
3946
|
+
}
|
|
3947
|
+
},
|
|
3948
|
+
url_icon: {},
|
|
3949
|
+
web_icon: {},
|
|
3950
|
+
web_icon_data: {},
|
|
3951
|
+
groups_id: {
|
|
3952
|
+
fields: {
|
|
3953
|
+
full_name: {}
|
|
3954
|
+
},
|
|
3955
|
+
limit: 40,
|
|
3956
|
+
order: ""
|
|
3957
|
+
},
|
|
3958
|
+
display_name: {},
|
|
3959
|
+
child_id: {
|
|
3960
|
+
fields: {
|
|
3961
|
+
active: {},
|
|
3962
|
+
name: {},
|
|
3963
|
+
is_display: {},
|
|
3964
|
+
sequence: {},
|
|
3965
|
+
complete_name: {},
|
|
3966
|
+
action: {
|
|
3967
|
+
fields: {
|
|
3968
|
+
display_name: {},
|
|
3969
|
+
type: {},
|
|
3970
|
+
binding_view_types: {}
|
|
3971
|
+
// res_model: {},
|
|
3972
|
+
}
|
|
3973
|
+
},
|
|
3974
|
+
url_icon: {},
|
|
3975
|
+
web_icon: {},
|
|
3976
|
+
web_icon_data: {},
|
|
3977
|
+
groups_id: {
|
|
3978
|
+
fields: {
|
|
3979
|
+
full_name: {}
|
|
3980
|
+
},
|
|
3981
|
+
limit: 40,
|
|
3982
|
+
order: ""
|
|
3983
|
+
},
|
|
3984
|
+
display_name: {},
|
|
3985
|
+
child_id: {
|
|
3986
|
+
fields: {
|
|
3987
|
+
active: {},
|
|
3988
|
+
name: {},
|
|
3989
|
+
is_display: {},
|
|
3990
|
+
sequence: {},
|
|
3991
|
+
complete_name: {},
|
|
3992
|
+
action: {
|
|
3993
|
+
fields: {
|
|
3994
|
+
display_name: {},
|
|
3995
|
+
type: {},
|
|
3996
|
+
binding_view_types: {}
|
|
3997
|
+
// res_model: {},
|
|
3998
|
+
}
|
|
3999
|
+
},
|
|
4000
|
+
url_icon: {},
|
|
4001
|
+
web_icon: {},
|
|
4002
|
+
web_icon_data: {},
|
|
4003
|
+
groups_id: {
|
|
4004
|
+
fields: {
|
|
4005
|
+
full_name: {}
|
|
4006
|
+
},
|
|
4007
|
+
limit: 40,
|
|
4008
|
+
order: ""
|
|
4009
|
+
},
|
|
4010
|
+
display_name: {},
|
|
4011
|
+
child_id: {
|
|
4012
|
+
fields: {
|
|
4013
|
+
active: {},
|
|
4014
|
+
name: {},
|
|
4015
|
+
is_display: {},
|
|
4016
|
+
sequence: {},
|
|
4017
|
+
complete_name: {},
|
|
4018
|
+
action: {
|
|
4019
|
+
fields: {
|
|
4020
|
+
display_name: {},
|
|
4021
|
+
type: {},
|
|
4022
|
+
binding_view_types: {}
|
|
4023
|
+
// res_model: {},
|
|
4024
|
+
}
|
|
4025
|
+
},
|
|
4026
|
+
url_icon: {},
|
|
4027
|
+
web_icon: {},
|
|
4028
|
+
web_icon_data: {},
|
|
4029
|
+
groups_id: {
|
|
4030
|
+
fields: {
|
|
4031
|
+
full_name: {}
|
|
4032
|
+
},
|
|
4033
|
+
limit: 40,
|
|
4034
|
+
order: ""
|
|
4035
|
+
},
|
|
4036
|
+
display_name: {},
|
|
4037
|
+
child_id: {
|
|
4038
|
+
fields: {},
|
|
4039
|
+
limit: 40,
|
|
4040
|
+
order: ""
|
|
4041
|
+
}
|
|
4042
|
+
},
|
|
4043
|
+
limit: 40,
|
|
4044
|
+
order: ""
|
|
4045
|
+
}
|
|
4046
|
+
},
|
|
4047
|
+
limit: 40,
|
|
4048
|
+
order: ""
|
|
4049
|
+
}
|
|
4050
|
+
},
|
|
4051
|
+
limit: 40,
|
|
4052
|
+
order: ""
|
|
4053
|
+
}
|
|
4054
|
+
},
|
|
4055
|
+
domain: [
|
|
4056
|
+
"&",
|
|
4057
|
+
["is_display", "=", true],
|
|
4058
|
+
"&",
|
|
4059
|
+
["active", "=", true],
|
|
4060
|
+
["parent_id", "=", false]
|
|
4061
|
+
]
|
|
4062
|
+
}
|
|
4063
|
+
};
|
|
4064
|
+
return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
|
|
4065
|
+
headers: {
|
|
4066
|
+
"Content-Type": "application/json"
|
|
4067
|
+
}
|
|
4068
|
+
});
|
|
4069
|
+
},
|
|
4070
|
+
async getSelectionItem({ data }) {
|
|
4071
|
+
const env2 = getEnv();
|
|
4072
|
+
const jsonData = {
|
|
4073
|
+
model: data.model,
|
|
4074
|
+
ids: [],
|
|
4075
|
+
method: "get_data_select",
|
|
4076
|
+
with_context: data.context,
|
|
4077
|
+
kwargs: {
|
|
4078
|
+
count_limit: 10001,
|
|
4079
|
+
domain: data.domain ? data.domain : [],
|
|
4080
|
+
offset: 0,
|
|
4081
|
+
order: "",
|
|
4082
|
+
specification: data?.specification ?? {
|
|
4083
|
+
id: {},
|
|
4084
|
+
name: {},
|
|
4085
|
+
display_name: {}
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
};
|
|
4089
|
+
return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
|
|
4090
|
+
headers: {
|
|
4091
|
+
"Content-Type": "application/json"
|
|
4092
|
+
}
|
|
4093
|
+
});
|
|
4094
|
+
},
|
|
4095
|
+
async loadMessages() {
|
|
4096
|
+
const env2 = getEnv();
|
|
4097
|
+
return env2.requests.post(
|
|
4098
|
+
"/load_message_failures" /* LOAD_MESSAGE */,
|
|
4099
|
+
{},
|
|
4100
|
+
{
|
|
4101
|
+
headers: {
|
|
4102
|
+
"Content-Type": "application/json"
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
);
|
|
4106
|
+
},
|
|
4107
|
+
async getVersion() {
|
|
4108
|
+
const env2 = getEnv();
|
|
4109
|
+
return env2?.requests.get("", {
|
|
4110
|
+
headers: {
|
|
4111
|
+
"Content-Type": "application/json"
|
|
4112
|
+
}
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
var view_service_default = ViewService;
|
|
24
4117
|
|
|
25
4118
|
// src/hooks/auth/use-forgot-password.ts
|
|
26
|
-
import { useMutation } from "@tanstack/react-query";
|
|
27
4119
|
var useForgotPassword = () => {
|
|
28
4120
|
return useMutation({
|
|
29
4121
|
mutationFn: (email) => {
|
|
@@ -32,75 +4124,54 @@ var useForgotPassword = () => {
|
|
|
32
4124
|
});
|
|
33
4125
|
};
|
|
34
4126
|
var use_forgot_password_default = useForgotPassword;
|
|
35
|
-
|
|
36
|
-
// src/hooks/auth/use-get-provider.ts
|
|
37
|
-
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
38
4127
|
var useGetProvider = () => {
|
|
39
|
-
return
|
|
4128
|
+
return useMutation({
|
|
40
4129
|
mutationFn: (data) => {
|
|
41
4130
|
return auth_service_default.getProviders(data?.db);
|
|
42
4131
|
}
|
|
43
4132
|
});
|
|
44
4133
|
};
|
|
45
4134
|
var use_get_provider_default = useGetProvider;
|
|
46
|
-
|
|
47
|
-
// src/hooks/auth/use-isvalid-token.ts
|
|
48
|
-
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
49
4135
|
var useIsValidToken = () => {
|
|
50
|
-
return
|
|
4136
|
+
return useMutation({
|
|
51
4137
|
mutationFn: (token) => {
|
|
52
4138
|
return auth_service_default.isValidToken(token);
|
|
53
4139
|
}
|
|
54
4140
|
});
|
|
55
4141
|
};
|
|
56
4142
|
var use_isvalid_token_default = useIsValidToken;
|
|
57
|
-
|
|
58
|
-
// src/hooks/auth/use-login-credential.ts
|
|
59
|
-
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
60
4143
|
var useLoginCredential = () => {
|
|
61
|
-
return
|
|
4144
|
+
return useMutation({
|
|
62
4145
|
mutationFn: (data) => {
|
|
63
4146
|
return auth_service_default.login(data);
|
|
64
4147
|
}
|
|
65
4148
|
});
|
|
66
4149
|
};
|
|
67
4150
|
var use_login_credential_default = useLoginCredential;
|
|
68
|
-
|
|
69
|
-
// src/hooks/auth/use-login-socical.ts
|
|
70
|
-
import { useMutation as useMutation5 } from "@tanstack/react-query";
|
|
71
4151
|
var useLoginSocial = () => {
|
|
72
|
-
return
|
|
4152
|
+
return useMutation({
|
|
73
4153
|
mutationFn: (data) => {
|
|
74
4154
|
return auth_service_default.loginSocial(data);
|
|
75
4155
|
}
|
|
76
4156
|
});
|
|
77
4157
|
};
|
|
78
4158
|
var use_login_socical_default = useLoginSocial;
|
|
79
|
-
|
|
80
|
-
// src/hooks/auth/use-reset-password.ts
|
|
81
|
-
import { useMutation as useMutation6 } from "@tanstack/react-query";
|
|
82
4159
|
var useResetPassword = () => {
|
|
83
|
-
return
|
|
4160
|
+
return useMutation({
|
|
84
4161
|
mutationFn: (request) => {
|
|
85
4162
|
return auth_service_default.resetPassword(request.data, request.token);
|
|
86
4163
|
}
|
|
87
4164
|
});
|
|
88
4165
|
};
|
|
89
4166
|
var use_reset_password_default = useResetPassword;
|
|
90
|
-
|
|
91
|
-
// src/hooks/auth/use-update-password.ts
|
|
92
|
-
import { useMutation as useMutation7 } from "@tanstack/react-query";
|
|
93
4167
|
var useUpdatePassword = () => {
|
|
94
|
-
return
|
|
4168
|
+
return useMutation({
|
|
95
4169
|
mutationFn: (request) => {
|
|
96
4170
|
return auth_service_default.updatePassword(request.data, request.token);
|
|
97
4171
|
}
|
|
98
4172
|
});
|
|
99
4173
|
};
|
|
100
4174
|
var use_update_password_default = useUpdatePassword;
|
|
101
|
-
|
|
102
|
-
// src/hooks/common/use-field.ts
|
|
103
|
-
import React, { useEffect } from "react";
|
|
104
4175
|
var useField = (props) => {
|
|
105
4176
|
const [invisible, setInvisible] = React.useState(true);
|
|
106
4177
|
const [required, setRequired] = React.useState(false);
|
|
@@ -134,29 +4205,20 @@ var useField = (props) => {
|
|
|
134
4205
|
};
|
|
135
4206
|
};
|
|
136
4207
|
var use_field_default = useField;
|
|
137
|
-
|
|
138
|
-
// src/hooks/company/use-get-company-info.ts
|
|
139
|
-
import { useMutation as useMutation8 } from "@tanstack/react-query";
|
|
140
4208
|
var useGetCompanyInfo = () => {
|
|
141
|
-
return
|
|
4209
|
+
return useMutation({
|
|
142
4210
|
mutationFn: (id) => company_service_default.getInfoCompany(id)
|
|
143
4211
|
});
|
|
144
4212
|
};
|
|
145
4213
|
var use_get_company_info_default = useGetCompanyInfo;
|
|
146
|
-
|
|
147
|
-
// src/hooks/company/use-get-current-company.ts
|
|
148
|
-
import { useMutation as useMutation9 } from "@tanstack/react-query";
|
|
149
4214
|
var useGetCurrentCompany = () => {
|
|
150
|
-
return
|
|
4215
|
+
return useMutation({
|
|
151
4216
|
mutationFn: () => company_service_default.getCurrentCompany()
|
|
152
4217
|
});
|
|
153
4218
|
};
|
|
154
4219
|
var use_get_current_company_default = useGetCurrentCompany;
|
|
155
|
-
|
|
156
|
-
// src/hooks/form/use-change-status.ts
|
|
157
|
-
import { useMutation as useMutation10 } from "@tanstack/react-query";
|
|
158
4220
|
var useChangeStatus = () => {
|
|
159
|
-
return
|
|
4221
|
+
return useMutation({
|
|
160
4222
|
mutationFn: ({ data }) => {
|
|
161
4223
|
return form_service_default.changeStatus({
|
|
162
4224
|
data
|
|
@@ -165,20 +4227,14 @@ var useChangeStatus = () => {
|
|
|
165
4227
|
});
|
|
166
4228
|
};
|
|
167
4229
|
var use_change_status_default = useChangeStatus;
|
|
168
|
-
|
|
169
|
-
// src/hooks/form/use-delete-comment.ts
|
|
170
|
-
import { useMutation as useMutation11 } from "@tanstack/react-query";
|
|
171
4230
|
var useDeleteComment = () => {
|
|
172
|
-
return
|
|
4231
|
+
return useMutation({
|
|
173
4232
|
mutationFn: ({ data }) => form_service_default.deleteComment({
|
|
174
4233
|
data
|
|
175
4234
|
})
|
|
176
4235
|
});
|
|
177
4236
|
};
|
|
178
4237
|
var use_delete_comment_default = useDeleteComment;
|
|
179
|
-
|
|
180
|
-
// src/hooks/form/use-get-comment.ts
|
|
181
|
-
import { useQuery } from "@tanstack/react-query";
|
|
182
4238
|
var useGetComment = ({ data, queryKey }) => {
|
|
183
4239
|
return useQuery({
|
|
184
4240
|
queryKey,
|
|
@@ -192,15 +4248,12 @@ var useGetComment = ({ data, queryKey }) => {
|
|
|
192
4248
|
});
|
|
193
4249
|
};
|
|
194
4250
|
var use_get_comment_default = useGetComment;
|
|
195
|
-
|
|
196
|
-
// src/hooks/form/use-get-form-view.ts
|
|
197
|
-
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
198
4251
|
var useGetFormView = ({
|
|
199
4252
|
data,
|
|
200
4253
|
queryKey,
|
|
201
4254
|
enabled
|
|
202
4255
|
}) => {
|
|
203
|
-
return
|
|
4256
|
+
return useQuery({
|
|
204
4257
|
queryKey,
|
|
205
4258
|
queryFn: () => form_service_default.getFormView({ data }).then((res) => {
|
|
206
4259
|
if (res) {
|
|
@@ -212,15 +4265,12 @@ var useGetFormView = ({
|
|
|
212
4265
|
});
|
|
213
4266
|
};
|
|
214
4267
|
var use_get_form_view_default = useGetFormView;
|
|
215
|
-
|
|
216
|
-
// src/hooks/form/use-get-image.ts
|
|
217
|
-
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
218
4268
|
var useGetImage = ({
|
|
219
4269
|
data,
|
|
220
4270
|
queryKey,
|
|
221
4271
|
src
|
|
222
4272
|
}) => {
|
|
223
|
-
return
|
|
4273
|
+
return useQuery({
|
|
224
4274
|
queryKey,
|
|
225
4275
|
queryFn: () => form_service_default.getImage({ data }).then((res) => {
|
|
226
4276
|
if (res) {
|
|
@@ -232,33 +4282,24 @@ var useGetImage = ({
|
|
|
232
4282
|
});
|
|
233
4283
|
};
|
|
234
4284
|
var use_get_image_default = useGetImage;
|
|
235
|
-
|
|
236
|
-
// src/hooks/form/use-send-comment.ts
|
|
237
|
-
import { useMutation as useMutation12 } from "@tanstack/react-query";
|
|
238
4285
|
var useSendComment = () => {
|
|
239
|
-
return
|
|
4286
|
+
return useMutation({
|
|
240
4287
|
mutationFn: ({ data }) => form_service_default.sentComment({
|
|
241
4288
|
data
|
|
242
4289
|
})
|
|
243
4290
|
});
|
|
244
4291
|
};
|
|
245
4292
|
var use_send_comment_default = useSendComment;
|
|
246
|
-
|
|
247
|
-
// src/hooks/form/use-upload-image.ts
|
|
248
|
-
import { useMutation as useMutation13 } from "@tanstack/react-query";
|
|
249
4293
|
var useUploadImage = () => {
|
|
250
|
-
return
|
|
4294
|
+
return useMutation({
|
|
251
4295
|
mutationFn: ({ data }) => form_service_default.uploadImage({
|
|
252
4296
|
data
|
|
253
4297
|
})
|
|
254
4298
|
});
|
|
255
4299
|
};
|
|
256
4300
|
var use_upload_image_default = useUploadImage;
|
|
257
|
-
|
|
258
|
-
// src/hooks/excel/use-export-excel.ts
|
|
259
|
-
import { useMutation as useMutation14 } from "@tanstack/react-query";
|
|
260
4301
|
var useExportExcel = () => {
|
|
261
|
-
return
|
|
4302
|
+
return useMutation({
|
|
262
4303
|
mutationFn: ({
|
|
263
4304
|
model,
|
|
264
4305
|
domain,
|
|
@@ -281,11 +4322,8 @@ var useExportExcel = () => {
|
|
|
281
4322
|
});
|
|
282
4323
|
};
|
|
283
4324
|
var use_export_excel_default = useExportExcel;
|
|
284
|
-
|
|
285
|
-
// src/hooks/excel/use-get-field-export.ts
|
|
286
|
-
import { useMutation as useMutation15 } from "@tanstack/react-query";
|
|
287
4325
|
var useGetFieldExport = () => {
|
|
288
|
-
return
|
|
4326
|
+
return useMutation({
|
|
289
4327
|
mutationFn: ({
|
|
290
4328
|
ids,
|
|
291
4329
|
model,
|
|
@@ -312,14 +4350,11 @@ var useGetFieldExport = () => {
|
|
|
312
4350
|
});
|
|
313
4351
|
};
|
|
314
4352
|
var use_get_field_export_default = useGetFieldExport;
|
|
315
|
-
|
|
316
|
-
// src/hooks/excel/use-get-file-excel.ts
|
|
317
|
-
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
318
4353
|
var useGetFileExcel = ({
|
|
319
4354
|
model,
|
|
320
4355
|
context
|
|
321
4356
|
}) => {
|
|
322
|
-
return
|
|
4357
|
+
return useQuery({
|
|
323
4358
|
queryKey: [],
|
|
324
4359
|
queryFn: () => excel_service_default.getFileExcel({
|
|
325
4360
|
model,
|
|
@@ -334,11 +4369,8 @@ var useGetFileExcel = ({
|
|
|
334
4369
|
});
|
|
335
4370
|
};
|
|
336
4371
|
var use_get_file_excel_default = useGetFileExcel;
|
|
337
|
-
|
|
338
|
-
// src/hooks/excel/use-parse-preview.ts
|
|
339
|
-
import { useMutation as useMutation16 } from "@tanstack/react-query";
|
|
340
4372
|
var useParsePreview = () => {
|
|
341
|
-
return
|
|
4373
|
+
return useMutation({
|
|
342
4374
|
mutationFn: ({
|
|
343
4375
|
id,
|
|
344
4376
|
selectedSheet,
|
|
@@ -353,33 +4385,24 @@ var useParsePreview = () => {
|
|
|
353
4385
|
});
|
|
354
4386
|
};
|
|
355
4387
|
var use_parse_preview_default = useParsePreview;
|
|
356
|
-
|
|
357
|
-
// src/hooks/excel/use-upload-file.ts
|
|
358
|
-
import { useMutation as useMutation17 } from "@tanstack/react-query";
|
|
359
4388
|
var useUploadFile = () => {
|
|
360
|
-
return
|
|
4389
|
+
return useMutation({
|
|
361
4390
|
mutationFn: ({ formData }) => excel_service_default.uploadFile({
|
|
362
4391
|
formData
|
|
363
4392
|
})
|
|
364
4393
|
});
|
|
365
4394
|
};
|
|
366
4395
|
var use_upload_file_default = useUploadFile;
|
|
367
|
-
|
|
368
|
-
// src/hooks/excel/use-upload-id-file.ts
|
|
369
|
-
import { useMutation as useMutation18 } from "@tanstack/react-query";
|
|
370
4396
|
var useUploadIdFile = () => {
|
|
371
|
-
return
|
|
4397
|
+
return useMutation({
|
|
372
4398
|
mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
|
|
373
4399
|
formData
|
|
374
4400
|
})
|
|
375
4401
|
});
|
|
376
4402
|
};
|
|
377
4403
|
var use_upload_id_file_default = useUploadIdFile;
|
|
378
|
-
|
|
379
|
-
// src/hooks/excel/uss-execute-import.ts
|
|
380
|
-
import { useMutation as useMutation19 } from "@tanstack/react-query";
|
|
381
4404
|
var useExecuteImport = () => {
|
|
382
|
-
return
|
|
4405
|
+
return useMutation({
|
|
383
4406
|
mutationFn: ({
|
|
384
4407
|
fields,
|
|
385
4408
|
columns,
|
|
@@ -398,20 +4421,14 @@ var useExecuteImport = () => {
|
|
|
398
4421
|
});
|
|
399
4422
|
};
|
|
400
4423
|
var uss_execute_import_default = useExecuteImport;
|
|
401
|
-
|
|
402
|
-
// src/hooks/model/use-delete.ts
|
|
403
|
-
import { useMutation as useMutation20 } from "@tanstack/react-query";
|
|
404
4424
|
var useDelete = () => {
|
|
405
|
-
return
|
|
4425
|
+
return useMutation({
|
|
406
4426
|
mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
|
|
407
4427
|
});
|
|
408
4428
|
};
|
|
409
4429
|
var use_delete_default = useDelete;
|
|
410
|
-
|
|
411
|
-
// src/hooks/model/use-get-all.ts
|
|
412
|
-
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
413
4430
|
var useGetAll = ({ data, queryKey, viewResponse }) => {
|
|
414
|
-
return
|
|
4431
|
+
return useQuery({
|
|
415
4432
|
queryKey,
|
|
416
4433
|
queryFn: () => model_service_default.getAll({ data }).then((res) => {
|
|
417
4434
|
if (res) {
|
|
@@ -424,11 +4441,8 @@ var useGetAll = ({ data, queryKey, viewResponse }) => {
|
|
|
424
4441
|
});
|
|
425
4442
|
};
|
|
426
4443
|
var use_get_all_default = useGetAll;
|
|
427
|
-
|
|
428
|
-
// src/hooks/model/use-get-detail.ts
|
|
429
|
-
import { useMutation as useMutation21 } from "@tanstack/react-query";
|
|
430
4444
|
var useGetDetail = () => {
|
|
431
|
-
return
|
|
4445
|
+
return useMutation({
|
|
432
4446
|
mutationFn: ({
|
|
433
4447
|
model,
|
|
434
4448
|
ids,
|
|
@@ -443,11 +4457,8 @@ var useGetDetail = () => {
|
|
|
443
4457
|
});
|
|
444
4458
|
};
|
|
445
4459
|
var use_get_detail_default = useGetDetail;
|
|
446
|
-
|
|
447
|
-
// src/hooks/model/use-get-field-onchange.ts
|
|
448
|
-
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
449
4460
|
var useGetFieldOnChange = ({ model }) => {
|
|
450
|
-
return
|
|
4461
|
+
return useQuery({
|
|
451
4462
|
queryKey: [`field-onchange-${model}`, model],
|
|
452
4463
|
queryFn: () => model_service_default.getListFieldsOnchange({
|
|
453
4464
|
model
|
|
@@ -462,6 +4473,123 @@ var useGetFieldOnChange = ({ model }) => {
|
|
|
462
4473
|
};
|
|
463
4474
|
var use_get_field_onchange_default = useGetFieldOnChange;
|
|
464
4475
|
|
|
4476
|
+
// src/models/base-model/index.ts
|
|
4477
|
+
var BaseModel = class {
|
|
4478
|
+
name;
|
|
4479
|
+
view;
|
|
4480
|
+
actContext;
|
|
4481
|
+
fields;
|
|
4482
|
+
constructor(init) {
|
|
4483
|
+
this.name = init.name;
|
|
4484
|
+
this.view = init.view;
|
|
4485
|
+
this.actContext = init.actContext;
|
|
4486
|
+
this.fields = init.fields;
|
|
4487
|
+
}
|
|
4488
|
+
getSpecificationByFields({
|
|
4489
|
+
fields = [],
|
|
4490
|
+
specification = {},
|
|
4491
|
+
modelsData,
|
|
4492
|
+
model,
|
|
4493
|
+
modelRoot
|
|
4494
|
+
}) {
|
|
4495
|
+
if (Array.isArray(fields)) {
|
|
4496
|
+
let spec = { ...specification };
|
|
4497
|
+
fields.forEach((field) => {
|
|
4498
|
+
if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
|
|
4499
|
+
if (modelsData?.[model]?.[field?.name]) {
|
|
4500
|
+
if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
|
|
4501
|
+
const relation = modelsData?.[model]?.[field?.name]?.relation;
|
|
4502
|
+
const modelRelation = modelsData?.[relation];
|
|
4503
|
+
if (modelRelation) {
|
|
4504
|
+
spec[field?.name] = {
|
|
4505
|
+
fields: {}
|
|
4506
|
+
};
|
|
4507
|
+
if (modelRoot && modelRoot === relation) {
|
|
4508
|
+
spec[field?.name].fields = { id: {} };
|
|
4509
|
+
} else {
|
|
4510
|
+
spec[field?.name].fields = this.getSpecificationByFields({
|
|
4511
|
+
fields: Object.values(modelRelation),
|
|
4512
|
+
specification: {},
|
|
4513
|
+
modelsData,
|
|
4514
|
+
model: relation,
|
|
4515
|
+
modelRoot: model
|
|
4516
|
+
});
|
|
4517
|
+
}
|
|
4518
|
+
} else {
|
|
4519
|
+
spec[field?.name] = {
|
|
4520
|
+
fields: {
|
|
4521
|
+
id: {},
|
|
4522
|
+
display_name: {}
|
|
4523
|
+
}
|
|
4524
|
+
};
|
|
4525
|
+
}
|
|
4526
|
+
} else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
|
|
4527
|
+
spec[field?.name] = {
|
|
4528
|
+
fields: {
|
|
4529
|
+
id: {},
|
|
4530
|
+
display_name: {},
|
|
4531
|
+
...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
|
|
4532
|
+
...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
|
|
4533
|
+
...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
|
|
4534
|
+
}
|
|
4535
|
+
};
|
|
4536
|
+
} else {
|
|
4537
|
+
spec[field?.name] = {};
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
} else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
|
|
4541
|
+
const specGroup = this.getSpecificationByFields({
|
|
4542
|
+
fields: field?.fields,
|
|
4543
|
+
specification: spec,
|
|
4544
|
+
modelsData,
|
|
4545
|
+
model
|
|
4546
|
+
});
|
|
4547
|
+
spec = { ...spec, ...specGroup };
|
|
4548
|
+
} else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
|
|
4549
|
+
const relation = modelsData?.[model]?.[field?.name]?.relation;
|
|
4550
|
+
const specTreee = this.getSpecificationByFields({
|
|
4551
|
+
fields: field?.fields,
|
|
4552
|
+
specification: {},
|
|
4553
|
+
modelsData,
|
|
4554
|
+
model: relation,
|
|
4555
|
+
modelRoot: model
|
|
4556
|
+
});
|
|
4557
|
+
spec = {
|
|
4558
|
+
...spec,
|
|
4559
|
+
[field?.name]: {
|
|
4560
|
+
fields: { ...spec?.[field?.name]?.fields, ...specTreee }
|
|
4561
|
+
}
|
|
4562
|
+
};
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
return spec;
|
|
4566
|
+
} else {
|
|
4567
|
+
console.warn("fields is not array");
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4570
|
+
getTreeProps() {
|
|
4571
|
+
const props = this.view?.views?.list || {};
|
|
4572
|
+
return props;
|
|
4573
|
+
}
|
|
4574
|
+
getTreeFields() {
|
|
4575
|
+
const fields = this.view?.views?.list?.fields || [];
|
|
4576
|
+
return fields;
|
|
4577
|
+
}
|
|
4578
|
+
getSpecification() {
|
|
4579
|
+
const specInit = {};
|
|
4580
|
+
const modelData = this.view?.models || {};
|
|
4581
|
+
const specification = this.getSpecificationByFields({
|
|
4582
|
+
fields: this.fields,
|
|
4583
|
+
specification: specInit,
|
|
4584
|
+
modelsData: modelData,
|
|
4585
|
+
model: this.name,
|
|
4586
|
+
modelRoot: ""
|
|
4587
|
+
});
|
|
4588
|
+
return specification;
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
var base_model_default = BaseModel;
|
|
4592
|
+
|
|
465
4593
|
// src/hooks/model/use-model.ts
|
|
466
4594
|
var useModel = () => {
|
|
467
4595
|
const initModel = (modelData) => {
|
|
@@ -484,11 +4612,8 @@ var useOdooDataTransform = () => {
|
|
|
484
4612
|
};
|
|
485
4613
|
};
|
|
486
4614
|
var use_odoo_data_transform_default = useOdooDataTransform;
|
|
487
|
-
|
|
488
|
-
// src/hooks/model/use-onchange-form.ts
|
|
489
|
-
import { useMutation as useMutation22 } from "@tanstack/react-query";
|
|
490
4615
|
var useOnChangeForm = () => {
|
|
491
|
-
return
|
|
4616
|
+
return useMutation({
|
|
492
4617
|
mutationFn: ({
|
|
493
4618
|
ids,
|
|
494
4619
|
model,
|
|
@@ -507,11 +4632,8 @@ var useOnChangeForm = () => {
|
|
|
507
4632
|
});
|
|
508
4633
|
};
|
|
509
4634
|
var use_onchange_form_default = useOnChangeForm;
|
|
510
|
-
|
|
511
|
-
// src/hooks/model/use-save.ts
|
|
512
|
-
import { useMutation as useMutation23 } from "@tanstack/react-query";
|
|
513
4635
|
var useSave = () => {
|
|
514
|
-
return
|
|
4636
|
+
return useMutation({
|
|
515
4637
|
mutationFn: ({
|
|
516
4638
|
ids,
|
|
517
4639
|
model,
|
|
@@ -522,20 +4644,14 @@ var useSave = () => {
|
|
|
522
4644
|
});
|
|
523
4645
|
};
|
|
524
4646
|
var use_save_default = useSave;
|
|
525
|
-
|
|
526
|
-
// src/hooks/user/use-get-profile.ts
|
|
527
|
-
import { useMutation as useMutation24 } from "@tanstack/react-query";
|
|
528
4647
|
var useGetProfile = () => {
|
|
529
|
-
return
|
|
4648
|
+
return useMutation({
|
|
530
4649
|
mutationFn: () => user_service_default.getProfile()
|
|
531
4650
|
});
|
|
532
4651
|
};
|
|
533
4652
|
var use_get_profile_default = useGetProfile;
|
|
534
|
-
|
|
535
|
-
// src/hooks/user/use-get-user.ts
|
|
536
|
-
import { useMutation as useMutation25 } from "@tanstack/react-query";
|
|
537
4653
|
var useGetUser = () => {
|
|
538
|
-
return
|
|
4654
|
+
return useMutation({
|
|
539
4655
|
mutationFn: ({ id, context }) => user_service_default.getUser({
|
|
540
4656
|
id,
|
|
541
4657
|
context
|
|
@@ -543,11 +4659,8 @@ var useGetUser = () => {
|
|
|
543
4659
|
});
|
|
544
4660
|
};
|
|
545
4661
|
var use_get_user_default = useGetUser;
|
|
546
|
-
|
|
547
|
-
// src/hooks/user/use-switch-locale.ts
|
|
548
|
-
import { useMutation as useMutation26 } from "@tanstack/react-query";
|
|
549
4662
|
var useSwitchLocale = () => {
|
|
550
|
-
return
|
|
4663
|
+
return useMutation({
|
|
551
4664
|
mutationFn: ({ data }) => {
|
|
552
4665
|
return user_service_default.switchUserLocale({
|
|
553
4666
|
id: data.id,
|
|
@@ -557,11 +4670,8 @@ var useSwitchLocale = () => {
|
|
|
557
4670
|
});
|
|
558
4671
|
};
|
|
559
4672
|
var use_switch_locale_default = useSwitchLocale;
|
|
560
|
-
|
|
561
|
-
// src/hooks/view/use-button.ts
|
|
562
|
-
import { useMutation as useMutation27 } from "@tanstack/react-query";
|
|
563
4673
|
var useButton = () => {
|
|
564
|
-
return
|
|
4674
|
+
return useMutation({
|
|
565
4675
|
mutationFn: ({
|
|
566
4676
|
model,
|
|
567
4677
|
ids,
|
|
@@ -579,11 +4689,8 @@ var useButton = () => {
|
|
|
579
4689
|
});
|
|
580
4690
|
};
|
|
581
4691
|
var use_button_default = useButton;
|
|
582
|
-
|
|
583
|
-
// src/hooks/view/use-duplicate-record.ts
|
|
584
|
-
import { useMutation as useMutation28 } from "@tanstack/react-query";
|
|
585
4692
|
var useDuplicateRecord = () => {
|
|
586
|
-
return
|
|
4693
|
+
return useMutation({
|
|
587
4694
|
mutationFn: ({
|
|
588
4695
|
id,
|
|
589
4696
|
model,
|
|
@@ -596,11 +4703,8 @@ var useDuplicateRecord = () => {
|
|
|
596
4703
|
});
|
|
597
4704
|
};
|
|
598
4705
|
var use_duplicate_record_default = useDuplicateRecord;
|
|
599
|
-
|
|
600
|
-
// src/hooks/view/use-get-list-data.ts
|
|
601
|
-
import { useQuery as useQuery7 } from "@tanstack/react-query";
|
|
602
4706
|
var useGetListData = (listDataProps, queryKey, enabled) => {
|
|
603
|
-
return
|
|
4707
|
+
return useQuery({
|
|
604
4708
|
queryKey,
|
|
605
4709
|
queryFn: () => model_service_default.getAll({ data: listDataProps }).then((res) => {
|
|
606
4710
|
if (res) {
|
|
@@ -614,11 +4718,8 @@ var useGetListData = (listDataProps, queryKey, enabled) => {
|
|
|
614
4718
|
});
|
|
615
4719
|
};
|
|
616
4720
|
var use_get_list_data_default = useGetListData;
|
|
617
|
-
|
|
618
|
-
// src/hooks/view/use-get-menu.ts
|
|
619
|
-
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
620
4721
|
var useGetMenu = ({ context, enabled, queryKey }) => {
|
|
621
|
-
return
|
|
4722
|
+
return useQuery({
|
|
622
4723
|
queryKey,
|
|
623
4724
|
queryFn: async () => {
|
|
624
4725
|
const res = await view_service_default.getMenu(context);
|
|
@@ -633,15 +4734,12 @@ var useGetMenu = ({ context, enabled, queryKey }) => {
|
|
|
633
4734
|
});
|
|
634
4735
|
};
|
|
635
4736
|
var use_get_menu_default = useGetMenu;
|
|
636
|
-
|
|
637
|
-
// src/hooks/view/use-get-selection.ts
|
|
638
|
-
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
639
4737
|
var useGetSelection = ({
|
|
640
4738
|
data,
|
|
641
4739
|
queryKey,
|
|
642
4740
|
enabled
|
|
643
4741
|
}) => {
|
|
644
|
-
return
|
|
4742
|
+
return useQuery({
|
|
645
4743
|
queryKey,
|
|
646
4744
|
queryFn: () => view_service_default.getSelectionItem({ data }),
|
|
647
4745
|
enabled,
|
|
@@ -649,11 +4747,8 @@ var useGetSelection = ({
|
|
|
649
4747
|
});
|
|
650
4748
|
};
|
|
651
4749
|
var use_get_selection_default = useGetSelection;
|
|
652
|
-
|
|
653
|
-
// src/hooks/view/use-get-view.ts
|
|
654
|
-
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
655
4750
|
var useGetView = (viewParams, actData) => {
|
|
656
|
-
return
|
|
4751
|
+
return useQuery({
|
|
657
4752
|
queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
|
|
658
4753
|
queryFn: () => view_service_default.getView(viewParams),
|
|
659
4754
|
enabled: !!actData,
|
|
@@ -662,14 +4757,11 @@ var useGetView = (viewParams, actData) => {
|
|
|
662
4757
|
});
|
|
663
4758
|
};
|
|
664
4759
|
var use_get_view_default = useGetView;
|
|
665
|
-
|
|
666
|
-
// src/hooks/view/use-load-action.ts
|
|
667
|
-
import { useQuery as useQuery11 } from "@tanstack/react-query";
|
|
668
4760
|
var useLoadAction = ({
|
|
669
4761
|
idAction,
|
|
670
4762
|
context
|
|
671
4763
|
}) => {
|
|
672
|
-
return
|
|
4764
|
+
return useQuery({
|
|
673
4765
|
queryKey: ["load_action", idAction],
|
|
674
4766
|
queryFn: () => action_service_default.loadAction({
|
|
675
4767
|
idAction,
|
|
@@ -681,11 +4773,8 @@ var useLoadAction = ({
|
|
|
681
4773
|
});
|
|
682
4774
|
};
|
|
683
4775
|
var use_load_action_default = useLoadAction;
|
|
684
|
-
|
|
685
|
-
// src/hooks/view/use-print.ts
|
|
686
|
-
import { useMutation as useMutation29 } from "@tanstack/react-query";
|
|
687
4776
|
var usePrint = () => {
|
|
688
|
-
return
|
|
4777
|
+
return useMutation({
|
|
689
4778
|
mutationFn: ({ id, report, db }) => action_service_default.print({
|
|
690
4779
|
id,
|
|
691
4780
|
report,
|
|
@@ -694,11 +4783,8 @@ var usePrint = () => {
|
|
|
694
4783
|
});
|
|
695
4784
|
};
|
|
696
4785
|
var use_print_default = usePrint;
|
|
697
|
-
|
|
698
|
-
// src/hooks/view/use-remove-row.ts
|
|
699
|
-
import { useMutation as useMutation30 } from "@tanstack/react-query";
|
|
700
4786
|
var useRemoveRow = () => {
|
|
701
|
-
return
|
|
4787
|
+
return useMutation({
|
|
702
4788
|
mutationFn: ({
|
|
703
4789
|
model,
|
|
704
4790
|
ids,
|
|
@@ -711,11 +4797,8 @@ var useRemoveRow = () => {
|
|
|
711
4797
|
});
|
|
712
4798
|
};
|
|
713
4799
|
var use_remove_row_default = useRemoveRow;
|
|
714
|
-
|
|
715
|
-
// src/hooks/view/use-run-action.ts
|
|
716
|
-
import { useQuery as useQuery12 } from "@tanstack/react-query";
|
|
717
4800
|
var useRunAction = ({ idAction, context }) => {
|
|
718
|
-
return
|
|
4801
|
+
return useQuery({
|
|
719
4802
|
queryKey: ["run_action", idAction],
|
|
720
4803
|
queryFn: () => action_service_default.runAction({
|
|
721
4804
|
idAction,
|
|
@@ -727,50 +4810,5 @@ var useRunAction = ({ idAction, context }) => {
|
|
|
727
4810
|
});
|
|
728
4811
|
};
|
|
729
4812
|
var use_run_action_default = useRunAction;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
use_change_status_default as useChangeStatus,
|
|
733
|
-
use_delete_default as useDelete,
|
|
734
|
-
use_delete_comment_default as useDeleteComment,
|
|
735
|
-
use_duplicate_record_default as useDuplicateRecord,
|
|
736
|
-
uss_execute_import_default as useExecuteImport,
|
|
737
|
-
use_export_excel_default as useExportExcel,
|
|
738
|
-
use_field_default as useField,
|
|
739
|
-
use_forgot_password_default as useForgotPassword,
|
|
740
|
-
use_get_all_default as useGetAll,
|
|
741
|
-
use_get_comment_default as useGetComment,
|
|
742
|
-
use_get_company_info_default as useGetCompanyInfo,
|
|
743
|
-
use_get_current_company_default as useGetCurrentCompany,
|
|
744
|
-
use_get_detail_default as useGetDetail,
|
|
745
|
-
use_get_field_export_default as useGetFieldExport,
|
|
746
|
-
use_get_field_onchange_default as useGetFieldOnChange,
|
|
747
|
-
use_get_file_excel_default as useGetFileExcel,
|
|
748
|
-
use_get_form_view_default as useGetFormView,
|
|
749
|
-
use_get_image_default as useGetImage,
|
|
750
|
-
use_get_list_data_default as useGetListData,
|
|
751
|
-
use_get_menu_default as useGetMenu,
|
|
752
|
-
use_get_profile_default as useGetProfile,
|
|
753
|
-
use_get_provider_default as useGetProvider,
|
|
754
|
-
use_get_selection_default as useGetSelection,
|
|
755
|
-
use_get_user_default as useGetUser,
|
|
756
|
-
use_get_view_default as useGetView,
|
|
757
|
-
use_isvalid_token_default as useIsValidToken,
|
|
758
|
-
use_load_action_default as useLoadAction,
|
|
759
|
-
use_login_credential_default as useLoginCredential,
|
|
760
|
-
use_login_socical_default as useLoginSocial,
|
|
761
|
-
use_model_default as useModel,
|
|
762
|
-
use_odoo_data_transform_default as useOdooDataTransform,
|
|
763
|
-
use_onchange_form_default as useOnChangeForm,
|
|
764
|
-
use_parse_preview_default as useParsePreview,
|
|
765
|
-
use_print_default as usePrint,
|
|
766
|
-
use_remove_row_default as useRemoveRow,
|
|
767
|
-
use_reset_password_default as useResetPassword,
|
|
768
|
-
use_run_action_default as useRunAction,
|
|
769
|
-
use_save_default as useSave,
|
|
770
|
-
use_send_comment_default as useSendComment,
|
|
771
|
-
use_switch_locale_default as useSwitchLocale,
|
|
772
|
-
use_update_password_default as useUpdatePassword,
|
|
773
|
-
use_upload_file_default as useUploadFile,
|
|
774
|
-
use_upload_id_file_default as useUploadIdFile,
|
|
775
|
-
use_upload_image_default as useUploadImage
|
|
776
|
-
};
|
|
4813
|
+
|
|
4814
|
+
export { use_button_default as useButton, use_change_status_default as useChangeStatus, use_delete_default as useDelete, use_delete_comment_default as useDeleteComment, use_duplicate_record_default as useDuplicateRecord, uss_execute_import_default as useExecuteImport, use_export_excel_default as useExportExcel, use_field_default as useField, use_forgot_password_default as useForgotPassword, use_get_all_default as useGetAll, use_get_comment_default as useGetComment, use_get_company_info_default as useGetCompanyInfo, use_get_current_company_default as useGetCurrentCompany, use_get_detail_default as useGetDetail, use_get_field_export_default as useGetFieldExport, use_get_field_onchange_default as useGetFieldOnChange, use_get_file_excel_default as useGetFileExcel, use_get_form_view_default as useGetFormView, use_get_image_default as useGetImage, use_get_list_data_default as useGetListData, use_get_menu_default as useGetMenu, use_get_profile_default as useGetProfile, use_get_provider_default as useGetProvider, use_get_selection_default as useGetSelection, use_get_user_default as useGetUser, use_get_view_default as useGetView, use_isvalid_token_default as useIsValidToken, use_load_action_default as useLoadAction, use_login_credential_default as useLoginCredential, use_login_socical_default as useLoginSocial, use_model_default as useModel, use_odoo_data_transform_default as useOdooDataTransform, use_onchange_form_default as useOnChangeForm, use_parse_preview_default as useParsePreview, use_print_default as usePrint, use_remove_row_default as useRemoveRow, use_reset_password_default as useResetPassword, use_run_action_default as useRunAction, use_save_default as useSave, use_send_comment_default as useSendComment, use_switch_locale_default as useSwitchLocale, use_update_password_default as useUpdatePassword, use_upload_file_default as useUploadFile, use_upload_id_file_default as useUploadIdFile, use_upload_image_default as useUploadImage };
|