data-primals-engine 1.5.0 → 1.5.2
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/README.md +37 -0
- package/client/src/AddWidgetTypeModal.jsx +47 -43
- package/client/src/App.jsx +2 -6
- package/client/src/App.scss +13 -1
- package/client/src/AssistantChat.jsx +363 -323
- package/client/src/AssistantChat.scss +27 -10
- package/client/src/Dashboard.jsx +480 -396
- package/client/src/Dashboard.scss +1 -1
- package/client/src/DashboardHtmlViewItem.jsx +147 -0
- package/client/src/DashboardView.jsx +654 -569
- package/client/src/DataEditor.jsx +10 -3
- package/client/src/DataLayout.jsx +807 -755
- package/client/src/DataLayout.scss +14 -0
- package/client/src/DataTable.jsx +39 -75
- package/client/src/Dialog.scss +1 -1
- package/client/src/Field.jsx +2057 -1825
- package/client/src/FlexViewCard.jsx +44 -0
- package/client/src/HistoryDialog.jsx +69 -14
- package/client/src/HtmlViewBuilderModal.jsx +91 -0
- package/client/src/HtmlViewBuilderModal.scss +18 -0
- package/client/src/HtmlViewCard.jsx +44 -0
- package/client/src/HtmlViewCard.scss +35 -0
- package/client/src/KanbanCard.jsx +1 -2
- package/client/src/ModelCreator.jsx +5 -4
- package/client/src/ModelCreatorField.jsx +51 -4
- package/client/src/ModelList.jsx +280 -236
- package/client/src/Notification.jsx +136 -136
- package/client/src/Notification.scss +0 -18
- package/client/src/Pagination.jsx +5 -3
- package/client/src/RelationField.jsx +354 -258
- package/client/src/RelationSelectorWidget.jsx +173 -0
- package/client/src/contexts/ModelContext.jsx +10 -1
- package/client/src/contexts/UIContext.jsx +72 -63
- package/client/src/filter.js +263 -212
- package/client/src/hooks/useValidation.js +75 -0
- package/client/src/translations.js +24 -24
- package/package.json +7 -6
- package/src/constants.js +1 -1
- package/src/core.js +8 -1
- package/src/defaultModels.js +1596 -1544
- package/src/engine.js +85 -43
- package/src/events.js +137 -113
- package/src/i18n.js +710 -10
- package/src/index.js +3 -0
- package/src/modules/assistant/assistant.js +253 -134
- package/src/modules/assistant/constants.js +2 -1
- package/src/modules/bucket.js +2 -1
- package/src/modules/data/data.core.js +118 -92
- package/src/modules/data/data.history.js +555 -492
- package/src/modules/data/data.js +3 -53
- package/src/modules/data/data.operations.js +3381 -3231
- package/src/modules/data/data.relations.js +686 -686
- package/src/modules/data/data.routes.js +1879 -1821
- package/src/modules/data/data.validation.js +81 -2
- package/src/modules/file.js +247 -238
- package/src/modules/user.js +1 -0
- package/src/modules/workflow.js +2 -2
- package/src/openai.jobs.js +3 -2
- package/src/packs.js +5482 -5478
- package/src/sso.js +2 -2
- package/src/workers/import-export-worker.js +1 -1
- package/test/data.history.integration.test.js +264 -192
- package/test/data.integration.test.js +149 -3
|
@@ -1,93 +1,119 @@
|
|
|
1
|
-
import NodeCache from "node-cache";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {Worker} from 'worker_threads';
|
|
4
|
-
import {fileURLToPath} from "node:url";
|
|
5
|
-
export const modelsCache = new NodeCache( { stdTTL: 100, checkperiod: 120 } );
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
import NodeCache from "node-cache";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {Worker} from 'worker_threads';
|
|
4
|
+
import {fileURLToPath} from "node:url";
|
|
5
|
+
export const modelsCache = new NodeCache( { stdTTL: 100, checkperiod: 120 } );
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper to escape characters for regex.
|
|
12
|
+
* @param {string} str The string to escape.
|
|
13
|
+
* @returns {string} The escaped string.
|
|
14
|
+
*/
|
|
15
|
+
function escapeRegex(str) {
|
|
16
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generates a regular expression from a mask pattern and replacement rules.
|
|
21
|
+
* @param {string} mask - The mask pattern, e.g., '+0 (___) ___-__-__'.
|
|
22
|
+
* @param {object} replacement - An object mapping placeholder characters to regex patterns, e.g., { "_": "\\d" }.
|
|
23
|
+
* @returns {string|null} - A regular expression string or null if inputs are invalid.
|
|
24
|
+
*/
|
|
25
|
+
export function generateRegexFromMask(mask, replacement) {
|
|
26
|
+
if (!mask || !replacement || typeof replacement !== 'object') return null;
|
|
27
|
+
|
|
28
|
+
let regex = '^';
|
|
29
|
+
for (const char of mask) {
|
|
30
|
+
regex += replacement[char] ? `(${replacement[char]})` : escapeRegex(char);
|
|
31
|
+
}
|
|
32
|
+
regex += '$';
|
|
33
|
+
return regex;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const mongoDBWhitelist = [
|
|
37
|
+
"$$NOW", "$in", "$eq", "$gt", "$gte", "$in", "$lt", "$lte", "$ne", "$nin", "$type", "$size",
|
|
38
|
+
"$and", "$not", "$nor", "$or", "$regexMatch", "$find", "$elemMatch", "$filter", "$toString", "$toObjectId",
|
|
39
|
+
"$concat",
|
|
40
|
+
'$add', '$subtract', '$multiply', '$divide', '$mod', '$pow', "$sqrt",
|
|
41
|
+
"$rand",
|
|
42
|
+
"$abs", '$sin', '$cos', '$tan', '$asin', '$acos', '$atan',
|
|
43
|
+
"$toDate", "$toBool", "$toString", "$toInt", "$toDouble",
|
|
44
|
+
"$dateDiff", "$dateSubtract", "$dateAdd", "$dateToString",
|
|
45
|
+
'$year', '$month', '$week', '$dayOfMonth', '$dayOfWeek', '$dayOfYear', '$hour', '$minute', '$second', '$millisecond',
|
|
46
|
+
'$geoNear', '$regex', '$text', '$nearSphere','$geoWithin','$geoIntersects'
|
|
47
|
+
];
|
|
48
|
+
export let importJobs = {};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Exécute une tâche d'import/export (parsing, stringify) dans un worker thread.
|
|
53
|
+
* @param {('parse-json'|'parse-csv'|'stringify-json')} action - L'action à effectuer.
|
|
54
|
+
* @param {object} payload - Les données nécessaires pour l'action.
|
|
55
|
+
* @returns {Promise<any>} - Une promesse qui se résout avec les données traitées.
|
|
56
|
+
*/
|
|
57
|
+
export function runImportExportWorker(action, payload) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const workerPath = path.resolve(process.cwd(), './src/workers/import-export-worker.js');
|
|
60
|
+
const worker = new Worker(workerPath);
|
|
61
|
+
|
|
62
|
+
worker.postMessage({ action, payload });
|
|
63
|
+
|
|
64
|
+
worker.on('message', (result) => {
|
|
65
|
+
if (result.success) {
|
|
66
|
+
resolve(result.data);
|
|
67
|
+
} else {
|
|
68
|
+
// Correction : On s'assure de toujours passer une chaîne de caractères à new Error()
|
|
69
|
+
const errorMessage = result.error || `Import/Export Worker failed with an unknown error. Action: ${action}.`;
|
|
70
|
+
reject(new Error(errorMessage));
|
|
71
|
+
}
|
|
72
|
+
worker.terminate();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
worker.on('error', (err) => {
|
|
76
|
+
reject(err);
|
|
77
|
+
worker.terminate();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
worker.on('exit', (code) => {
|
|
81
|
+
if (code !== 0) {
|
|
82
|
+
reject(new Error(`Import/Export Worker stopped with exit code ${code}`));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Exécute une tâche de cryptographie dans un worker thread.
|
|
88
|
+
* @param {('encrypt'|'decrypt'|'hash')} action - L'action à effectuer.
|
|
89
|
+
* @param {object} payload - Les données nécessaires pour l'action.
|
|
90
|
+
* @returns {Promise<any>} - Une promesse qui se résout avec le résultat (si pertinent).
|
|
91
|
+
*/
|
|
92
|
+
export function runCryptoWorkerTask(action, payload) {
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
const workerPath = path.resolve(__dirname, '../../workers/crypto-worker.js');
|
|
95
|
+
const worker = new Worker(workerPath);
|
|
96
|
+
|
|
97
|
+
worker.postMessage({ action, payload });
|
|
98
|
+
|
|
99
|
+
worker.on('message', (result) => {
|
|
100
|
+
if (result.success) {
|
|
101
|
+
resolve(result.data); // Résout avec les données (ex: le hash) ou undefined si pas de retour
|
|
102
|
+
} else {
|
|
103
|
+
reject(new Error(result.error));
|
|
104
|
+
}
|
|
105
|
+
worker.terminate();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
worker.on('error', (err) => {
|
|
109
|
+
reject(err);
|
|
110
|
+
worker.terminate();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
worker.on('exit', (code) => {
|
|
114
|
+
if (code !== 0) {
|
|
115
|
+
reject(new Error(`Crypto Worker stopped with exit code ${code}`));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
93
119
|
}
|