data-primals-engine 1.2.6-rc3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/client/package-lock.json +247 -4354
- package/client/package.json +16 -15
- package/client/src/App.jsx +13 -20
- package/client/src/App.scss +1 -0
- package/client/src/AssistantChat.jsx +5 -4
- package/client/src/DataEditor.jsx +2 -2
- package/client/src/DataTable.jsx +47 -3
- package/client/src/ExportDialog.jsx +2 -2
- package/client/src/Field.jsx +6 -18
- package/client/src/KanbanCard.jsx +4 -2
- package/client/src/KanbanConfigModal.jsx +5 -7
- package/client/src/ModelCreatorField.jsx +9 -9
- package/client/src/PackGallery.jsx +89 -9
- package/client/src/PackGallery.scss +58 -4
- package/client/src/RTETrans.jsx +11 -0
- package/client/src/RelationValue.jsx +3 -4
- package/client/src/constants.js +1 -1
- package/client/src/core/data.js +2 -1
- package/client/src/translations.js +80 -0
- package/package.json +8 -1
- package/server.js +4 -4
- package/src/constants.js +6 -0
- package/src/defaultModels.js +23 -10
- package/src/filter.js +35 -5
- package/src/i18n.js +1 -1
- package/src/modules/{assistant.js → assistant/assistant.js} +42 -27
- package/src/modules/assistant/constants.js +16 -0
- package/src/modules/data/data.core.js +1 -3
- package/src/modules/data/data.js +4601 -4525
- package/src/modules/data/data.routes.js +29 -3
- package/src/modules/mongodb.js +3 -1
- package/src/modules/user.js +12 -1
- package/src/modules/workflow.js +198 -117
- package/src/packs.js +1015 -9
- package/src/services/index.js +11 -0
- package/src/services/stripe.js +141 -0
- package/test/data.integration.test.js +66 -3
- package/test/workflow.actions.integration.test.js +474 -0
- package/test/workflow.integration.test.js +1 -1
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
middlewareAuthenticator,
|
|
34
34
|
userInitiator
|
|
35
35
|
} from "../user.js";
|
|
36
|
-
import {assistantGlobalLimiter} from "../assistant.js";
|
|
36
|
+
import {assistantGlobalLimiter} from "../assistant/assistant.js";
|
|
37
37
|
import {Config} from "../../config.js";
|
|
38
38
|
import {processFilterPlaceholders} from "../../../client/src/filter.js";
|
|
39
39
|
import {tutorialsConfig} from "../../../client/src/tutorials.js";
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
editData, editModel, exportData,
|
|
44
44
|
getModel, getResource,
|
|
45
45
|
handleCustomEndpointRequest,
|
|
46
|
-
handleDemoInitialization, importData, insertData, installPack, loadFromDump,
|
|
46
|
+
handleDemoInitialization, importData, insertData, installPack, loadFromDump, middlewareEndpointAuthenticator,
|
|
47
47
|
patchData, searchData, validateModelStructure
|
|
48
48
|
} from "./data.js";
|
|
49
49
|
import process from "node:process";
|
|
@@ -161,7 +161,7 @@ export async function registerRoutes(engine){
|
|
|
161
161
|
|
|
162
162
|
logger = engine.getComponent(Logger);
|
|
163
163
|
|
|
164
|
-
engine.all('/api/actions/:path', [
|
|
164
|
+
engine.all('/api/actions/:path', [middlewareEndpointAuthenticator, userInitiator], handleCustomEndpointRequest);
|
|
165
165
|
engine.post('/api/demo/initialize', [middlewareAuthenticator, userInitiator], handleDemoInitialization);
|
|
166
166
|
|
|
167
167
|
engine.post('/api/magnets', [middlewareAuthenticator, userInitiator], async (req, res) => {
|
|
@@ -1556,6 +1556,32 @@ export async function registerRoutes(engine){
|
|
|
1556
1556
|
res.status(500).json({ success: false, error: error.message || 'An internal server error occurred.' });
|
|
1557
1557
|
}
|
|
1558
1558
|
});
|
|
1559
|
+
engine.post('/api/packs/install', [throttle, middlewareAuthenticator, userInitiator, setTimeoutMiddleware(60000)], async (req, res) => {
|
|
1560
|
+
const { id } = req.params;
|
|
1561
|
+
const user = req.me;
|
|
1562
|
+
const lang = req.query.lang || req.fields.lang;
|
|
1563
|
+
|
|
1564
|
+
try {
|
|
1565
|
+
// Vérification des permissions
|
|
1566
|
+
if (user.username !== 'demo' && isLocalUser(user) && !await hasPermission(["API_ADMIN", "API_INSTALL_PACK"], user)) {
|
|
1567
|
+
return res.status(403).json({ success: false, error: i18n.t('api.permission.installPack') });
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
const result = await installPack(req.fields.packData, user, lang);
|
|
1571
|
+
|
|
1572
|
+
if (result.success) {
|
|
1573
|
+
res.status(200).json({ success: true, message: `Pack installed successfully.`, summary: result.summary });
|
|
1574
|
+
} else if (!result.success && !result.modifiedCount) {
|
|
1575
|
+
res.status(200).json({ success: true, message: `No data to insert.`, summary: result.summary });
|
|
1576
|
+
} else {
|
|
1577
|
+
res.status(400).json({ success: false, error: 'Pack installation had errors.', errors: result.errors, summary: result.summary });
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
logger.error(`[POST /api/packs/${id}/install] Critical error:`, error);
|
|
1582
|
+
res.status(500).json({ success: false, error: error.message || 'An internal server error occurred.' });
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1559
1585
|
/*
|
|
1560
1586
|
engine.post('/api/packs/install', [throttle, middlewareAuthenticator, userInitiator, ...userMiddlewares], async (req, res) => {
|
|
1561
1587
|
|
package/src/modules/mongodb.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import process from "process";
|
|
3
2
|
import {Logger} from "../gameObject.js";
|
|
4
3
|
import {MongoDatabase} from "../engine.js";
|
|
4
|
+
import {ObjectId} from "mongodb";
|
|
5
5
|
|
|
6
6
|
export let modelsCollection, datasCollection, filesCollection, packsCollection;
|
|
7
7
|
|
|
8
|
+
export {ObjectId};
|
|
9
|
+
|
|
8
10
|
let engine, logger;
|
|
9
11
|
export async function onInit(defaultEngine) {
|
|
10
12
|
engine = defaultEngine;
|
package/src/modules/user.js
CHANGED
|
@@ -3,9 +3,10 @@ import {MongoDatabase} from "../engine.js";
|
|
|
3
3
|
import {getCollection, getCollectionForUser, getUserCollectionName} from "./mongodb.js";
|
|
4
4
|
import {isLocalUser} from "../data.js";
|
|
5
5
|
import {ObjectId} from "mongodb";
|
|
6
|
-
import {getAPILang} from "./data/index.js";
|
|
6
|
+
import {getAPILang, searchData} from "./data/index.js";
|
|
7
7
|
import {Logger} from "../gameObject.js";
|
|
8
8
|
import rateLimit from "express-rate-limit";
|
|
9
|
+
import ivm from "isolated-vm";
|
|
9
10
|
|
|
10
11
|
export const userInitiator = async (req, res, next) => {
|
|
11
12
|
|
|
@@ -256,3 +257,13 @@ export async function calculateTotalUserStorageUsage(user) {
|
|
|
256
257
|
logger.debug(`[Storage] User ${userId}: Data size = ${dataSize} bytes, Files size = ${filesSize} bytes. Total = ${dataSize + filesSize} bytes.`);
|
|
257
258
|
return dataSize + filesSize;
|
|
258
259
|
}
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
export async function getEnv(user){
|
|
263
|
+
const result = await searchData({ model: 'env' }, user);
|
|
264
|
+
const envObject = result.data.reduce((acc, v) => {
|
|
265
|
+
acc[v.name] = v.value;
|
|
266
|
+
return acc;
|
|
267
|
+
}, {});
|
|
268
|
+
return envObject;
|
|
269
|
+
}
|