data-primals-engine 1.4.3 → 1.5.1
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 +913 -867
- package/client/package-lock.json +49 -0
- package/client/package.json +1 -0
- package/client/src/AddWidgetTypeModal.jsx +47 -43
- package/client/src/App.jsx +3 -7
- package/client/src/App.scss +25 -3
- package/client/src/AssistantChat.jsx +363 -323
- package/client/src/AssistantChat.scss +30 -12
- 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 +104 -19
- package/client/src/DataEditor.jsx +12 -5
- package/client/src/DataLayout.jsx +805 -762
- package/client/src/DataLayout.scss +14 -0
- package/client/src/DataTable.jsx +63 -77
- package/client/src/Dialog.scss +1 -1
- package/client/src/Field.jsx +591 -322
- package/client/src/FlexDataRenderer.jsx +2 -0
- package/client/src/FlexTreeUtils.js +1 -1
- package/client/src/FlexViewCard.jsx +44 -0
- package/client/src/HistoryDialog.jsx +47 -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/KPIDialog.jsx +11 -1
- package/client/src/KanbanCard.jsx +1 -2
- package/client/src/ModelCreator.jsx +6 -6
- package/client/src/ModelCreatorField.jsx +74 -31
- package/client/src/ModelList.jsx +93 -54
- 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/constants.js +1 -1
- package/client/src/contexts/ModelContext.jsx +10 -1
- package/client/src/contexts/UIContext.jsx +72 -63
- package/client/src/filter.js +262 -212
- package/client/src/hooks/useTutorials.jsx +62 -65
- package/client/src/hooks/useValidation.js +75 -0
- package/client/src/translations.js +26 -24
- package/package.json +3 -1
- package/perf/README.md +147 -0
- package/perf/artillery-hooks.js +37 -0
- package/perf/perf-shot-hardwork.yml +84 -0
- package/perf/perf-shot-search.yml +45 -0
- package/perf/setup.yml +26 -0
- package/server.js +1 -1
- package/src/constants.js +3 -28
- package/src/core.js +15 -1
- package/src/data.js +1 -1
- package/src/defaultModels.js +63 -7
- package/src/email.js +5 -2
- package/src/engine.js +5 -3
- package/src/filter.js +5 -3
- package/src/i18n.js +710 -10
- package/src/modules/assistant/assistant.js +151 -19
- package/src/modules/bucket.js +14 -16
- package/src/modules/data/data.backup.js +11 -8
- package/src/modules/data/data.core.js +118 -92
- package/src/modules/data/data.history.js +531 -492
- package/src/modules/data/data.js +9 -56
- package/src/modules/data/data.operations.js +3282 -2999
- package/src/modules/data/data.relations.js +686 -686
- package/src/modules/data/data.routes.js +118 -24
- package/src/modules/data/data.scheduling.js +2 -1
- package/src/modules/data/data.validation.js +85 -3
- package/src/modules/file.js +247 -236
- package/src/modules/user.js +4 -1
- package/src/modules/workflow.js +9 -10
- package/src/openai.jobs.js +2 -0
- package/src/packs.js +5482 -5461
- package/src/providers.js +22 -7
- package/test/data.integration.test.js +136 -2
- package/test/import_export.integration.test.js +1 -1
package/src/modules/data/data.js
CHANGED
|
@@ -2,7 +2,7 @@ import {Logger} from "../../gameObject.js";
|
|
|
2
2
|
import {mkdir} from 'node:fs/promises';
|
|
3
3
|
import {onInit as historyInit} from "./data.history.js";
|
|
4
4
|
import {isDemoUser, isLocalUser} from "../../data.js";
|
|
5
|
-
import {install, maxRequestData, storageSafetyMargin} from "../../constants.js";
|
|
5
|
+
import {install, maxAlertsPerUser, maxRequestData, storageSafetyMargin} from "../../constants.js";
|
|
6
6
|
import {createCollection, getCollection} from "../mongodb.js";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import {isGUID, sequential} from "../../core.js";
|
|
@@ -22,6 +22,7 @@ import {validateField, onInit as validationInit} from "./data.validation.js";
|
|
|
22
22
|
import {cancelAlerts, scheduleAlerts, onInit as scheduleInit} from "./data.scheduling.js";
|
|
23
23
|
import {deleteData, installPack, onInit as operationsInit} from "./data.operations.js";
|
|
24
24
|
import {jobDumpUserData, onInit as backupInit} from "./data.backup.js";
|
|
25
|
+
import {Config} from "../../config.js";
|
|
25
26
|
|
|
26
27
|
let engine;
|
|
27
28
|
let logger;
|
|
@@ -54,7 +55,8 @@ export async function onInit(defaultEngine) {
|
|
|
54
55
|
|
|
55
56
|
let modelsCollection, datasCollection, filesCollection, packsCollection, magnetsCollection, historyCollection;
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
const i = Config.Get('install', install);
|
|
59
|
+
if( i ) {
|
|
58
60
|
datasCollection = await createCollection("datas");
|
|
59
61
|
historyCollection = await createCollection("history");
|
|
60
62
|
filesCollection = await createCollection("files");
|
|
@@ -157,56 +159,6 @@ export async function onInit(defaultEngine) {
|
|
|
157
159
|
|
|
158
160
|
// Triggers
|
|
159
161
|
|
|
160
|
-
Event.Listen("OnValidateModelStructure", async (modelStructure) =>{
|
|
161
|
-
|
|
162
|
-
const objectKeys = Object.keys(modelStructure);
|
|
163
|
-
|
|
164
|
-
if( objectKeys.find(o => !["name", "_user", "icon", "history", "locked", "_id", "description", "maxRequestData", "fields"].includes(o)) ){
|
|
165
|
-
throw new Error(i18n.t('api.model.invalidStructure'));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Vérification du type de name
|
|
169
|
-
if (typeof modelStructure.name !== 'string' || !modelStructure.name) {
|
|
170
|
-
throw new Error(i18n.t("api.validate.requiredFieldString", ["name"]));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Vérification du type de description
|
|
174
|
-
if (typeof modelStructure.description !== 'string') {
|
|
175
|
-
throw new Error(i18n.t("api.validate.fieldString", ["description"]));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Vérification de la présence et du type du tableau fields
|
|
179
|
-
if (!Array.isArray(modelStructure.fields)) {
|
|
180
|
-
throw new Error(i18n.t('api.validate.fieldArray', ["fields"]));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Vérification de chaque champ dans le tableau fields
|
|
184
|
-
for (const field of modelStructure.fields) {
|
|
185
|
-
validateField(field);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (modelStructure.constraints) {
|
|
189
|
-
if (!Array.isArray(modelStructure.constraints)) {
|
|
190
|
-
throw new Error('Model "constraints" property must be an array.');
|
|
191
|
-
}
|
|
192
|
-
const fieldNames = new Set(modelStructure.fields.map(f => f.name));
|
|
193
|
-
for (const constraint of modelStructure.constraints) {
|
|
194
|
-
if (constraint.type === 'unique') {
|
|
195
|
-
if (!constraint.name || !Array.isArray(constraint.keys) || constraint.keys.length === 0) {
|
|
196
|
-
throw new Error('Unique constraint must have a "name" and a non-empty "keys" array.');
|
|
197
|
-
}
|
|
198
|
-
for (const key of constraint.keys) {
|
|
199
|
-
if (!fieldNames.has(key)) {
|
|
200
|
-
throw new Error(`Constraint key "${key}" in constraint "${constraint.name}" does not exist as a field in the model.`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return true; // La structure du modèle est valide
|
|
208
|
-
}, "event", "system");
|
|
209
|
-
|
|
210
162
|
}
|
|
211
163
|
|
|
212
164
|
|
|
@@ -220,8 +172,9 @@ export async function checkServerCapacity(incomingDataSize = 0) {
|
|
|
220
172
|
const diskSpace = await checkDiskSpace(DATA_STORAGE_PATH);
|
|
221
173
|
const { free, size } = diskSpace;
|
|
222
174
|
|
|
175
|
+
const storageMargin = Config.Get('storageSafetyMargin', storageSafetyMargin);
|
|
223
176
|
// Limite maximale d'utilisation du disque (ex: 90% de la taille totale)
|
|
224
|
-
const maxAllowedUsage = size *
|
|
177
|
+
const maxAllowedUsage = size * storageMargin;
|
|
225
178
|
const currentUsage = size - free;
|
|
226
179
|
const projectedUsage = currentUsage + incomingDataSize;
|
|
227
180
|
|
|
@@ -324,13 +277,13 @@ export async function handleDemoInitialization(req, res) {
|
|
|
324
277
|
|
|
325
278
|
logger.info(`[Demo Init] Installing dynamically generated pack with models: [${models.join(', ')}].`);
|
|
326
279
|
|
|
280
|
+
// Create and install pack
|
|
281
|
+
const result = await installPack(packToInstall, user, req.query.lang || 'en');
|
|
282
|
+
|
|
327
283
|
await sequential(packs.map(p => {
|
|
328
284
|
return () => installPack(p, user, req.query.lang || 'en');
|
|
329
285
|
}));
|
|
330
286
|
|
|
331
|
-
// Create and install pack
|
|
332
|
-
const result = await installPack(packToInstall, user, req.query.lang || 'en');
|
|
333
|
-
|
|
334
287
|
if (result.success || result.modifiedCount > 0) {
|
|
335
288
|
|
|
336
289
|
await Event.Trigger('OnDemoUserAdded', "event", "system", req.me.username);
|