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