data-primals-engine 1.7.0 → 1.7.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 +160 -160
- package/client/package-lock.json +1080 -212
- package/client/package.json +12 -6
- package/client/src/AssistantChat.jsx +1 -3
- package/client/src/DataLayout.jsx +19 -20
- package/client/src/DataTable.jsx +2 -2
- package/client/src/DocumentationPageLayout.scss +1 -1
- package/client/src/ViewSwitcher.jsx +1 -1
- package/client/vite.config.js +31 -30
- package/package.json +39 -23
- package/src/ai.jobs.js +135 -0
- package/src/constants.js +561 -545
- package/src/core.js +487 -477
- package/src/data.js +2 -0
- package/src/email.js +0 -2
- package/src/engine.js +50 -42
- package/src/filter.js +348 -343
- package/src/modules/assistant/assistant.js +782 -763
- package/src/modules/assistant/constants.js +23 -16
- package/src/modules/assistant/providers.js +77 -37
- package/src/modules/bucket.js +4 -0
- package/src/modules/data/data.cluster.js +191 -0
- package/src/modules/data/data.core.js +11 -8
- package/src/modules/data/data.js +13 -4
- package/src/modules/data/data.operations.js +186 -106
- package/src/modules/data/data.relations.js +1 -0
- package/src/modules/data/data.replication.js +83 -0
- package/src/modules/data/data.routes.js +2183 -1879
- package/src/modules/mongodb.js +76 -73
- package/src/modules/user.js +7 -1
- package/src/modules/worker-script-runner.js +97 -0
- package/src/modules/workflow.js +1953 -1815
- package/src/packs.js +5701 -5697
- package/src/providers.js +298 -297
- package/test/assistant.test.js +207 -206
- package/test/data.integration.test.js +1425 -1416
- package/test/import_export.integration.test.js +210 -210
- package/test/workflow.actions.integration.test.js +487 -475
- package/test/workflow.integration.test.js +332 -329
package/src/data.js
CHANGED
|
@@ -37,6 +37,8 @@ export function getUserHash(user) {
|
|
|
37
37
|
if( isDemoUser(user) ){
|
|
38
38
|
return user.username;
|
|
39
39
|
}
|
|
40
|
+
if( user.hash )
|
|
41
|
+
return user.hash;
|
|
40
42
|
return user ? (
|
|
41
43
|
isLocalUser(user) ? getObjectHash({id: 'LOCAL_USER'+user._user+user.username}) : getObjectHash({id: user.hash})
|
|
42
44
|
) : 0;
|
package/src/email.js
CHANGED
|
@@ -55,8 +55,6 @@ export const sendEmail = async (email = "", data, smtpConfig = null, lang, tpl =
|
|
|
55
55
|
// Choisir le transporteur à utiliser
|
|
56
56
|
const transporter = smtpConfig ? createTransporter(smtpConfig||cfg) : defaultTransporter;
|
|
57
57
|
|
|
58
|
-
Event.Listen("OnEmailTemplate", (data, lang) => data.content, "event", "system");
|
|
59
|
-
|
|
60
58
|
if (tpl === null) tpl = await Event.Trigger("OnEmailTemplate", "event", "system", data, lang);
|
|
61
59
|
let html = tpl;
|
|
62
60
|
try {
|
package/src/engine.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import process from "process";
|
|
4
|
+
// Charger les variables d'environnement depuis le fichier .env
|
|
5
|
+
import dotenv from "dotenv";
|
|
6
|
+
|
|
7
|
+
// Charger le .env depuis la racine du projet appelant, et non depuis la lib.
|
|
8
|
+
dotenv.config({ path: path.resolve(process.cwd(), '.env') });
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
1
11
|
import {GameObject, Logger} from "./gameObject.js";
|
|
2
12
|
import {Config} from "./config.js";
|
|
3
13
|
import fs from 'node:fs'
|
|
4
14
|
import express from 'express'
|
|
5
15
|
import {MongoClient as InternalMongoClient} from 'mongodb'
|
|
6
|
-
import process from "process";
|
|
7
16
|
import {
|
|
8
17
|
cookiesSecret,
|
|
9
18
|
databasePoolSize,
|
|
@@ -19,19 +28,13 @@ import formidableMiddleware from 'express-formidable';
|
|
|
19
28
|
import sirv from "sirv";
|
|
20
29
|
import * as tls from "node:tls";
|
|
21
30
|
import {Event} from "./events.js";
|
|
22
|
-
import
|
|
23
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
31
|
+
import { pathToFileURL } from 'node:url';
|
|
24
32
|
import {validateModelStructure} from "./modules/data/data.validation.js";
|
|
25
33
|
import { setSafeRegex } from "./filter.js";
|
|
26
34
|
import safeRegexCallback from "safe-regex";
|
|
27
35
|
import {createModel, deleteModels, getModels, installAllPacks} from "./modules/data/data.operations.js";
|
|
28
36
|
// Constants
|
|
29
37
|
|
|
30
|
-
// On définit __dirname pour obtenir le chemin absolu du répertoire courant,
|
|
31
|
-
// ce qui est la méthode standard en ES Modules.
|
|
32
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
33
|
-
const __dirname = path.dirname(__filename);
|
|
34
|
-
|
|
35
38
|
let dbName = Config.Get('dbName', dbNameBase);
|
|
36
39
|
let caFile, certFile, keyFile;
|
|
37
40
|
try {
|
|
@@ -53,49 +56,54 @@ const secureContext = tls.createSecureContext({
|
|
|
53
56
|
|
|
54
57
|
export const dbUrl = process.env.CI ? 'mongodb://mongodb:27017' : (process.env.MONGO_DB_URL || 'mongodb://127.0.0.1:27017');
|
|
55
58
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const clientOptions = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
export const InitMongo = () => {
|
|
60
|
+
const isTlsActive = !(!process.env.TLS || ["0", "false"].includes(process.env.TLS.toLowerCase()));
|
|
61
|
+
const clientOptions = {
|
|
62
|
+
maxPoolSize: databasePoolSize,
|
|
63
|
+
authSource: 'admin'
|
|
64
|
+
};
|
|
65
|
+
if (isTlsActive) {
|
|
66
|
+
clientOptions.tls = true;
|
|
67
|
+
console.log("TLS ACTIVE");
|
|
68
|
+
// is mTLS ? (client certificate required instead of password)
|
|
69
|
+
if (process.env.CERT) {
|
|
70
|
+
clientOptions.secureContext = tls.createSecureContext({
|
|
71
|
+
ca: fs.readFileSync(process.env.CA_CERT),
|
|
72
|
+
cert: fs.readFileSync(process.env.CERT),
|
|
73
|
+
key: fs.readFileSync(process.env.CERT_KEY)
|
|
74
|
+
});
|
|
75
|
+
}else {
|
|
76
|
+
// Path to the authority certificate
|
|
77
|
+
if (process.env.CA_CERT) {
|
|
78
|
+
clientOptions.tlsCAFile = process.env.CA_CERT;
|
|
79
|
+
}
|
|
80
|
+
// Path to the certificate key
|
|
81
|
+
if (process.env.CERT_KEY) {
|
|
82
|
+
clientOptions.tlsCertificateKeyFile = process.env.CERT_KEY;
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
if (tlsAllowInvalidCertificates) {
|
|
86
|
+
clientOptions.tlsAllowInvalidCertificates = true;
|
|
87
|
+
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidCertificates is ON. Server certificate will not be validated.");
|
|
81
88
|
}
|
|
89
|
+
if (tlsAllowInvalidHostnames) {
|
|
90
|
+
clientOptions.tlsAllowInvalidHostnames = true;
|
|
91
|
+
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidHostnames is ON. Server hostname will not be validated.");
|
|
92
|
+
}
|
|
93
|
+
}else{
|
|
94
|
+
console.log("🚨[SEC] TLS INACTIVE", dbUrl, clientOptions);
|
|
82
95
|
}
|
|
83
|
-
|
|
84
|
-
clientOptions.tlsAllowInvalidCertificates = true;
|
|
85
|
-
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidCertificates is ON. Server certificate will not be validated.");
|
|
86
|
-
}
|
|
87
|
-
if (tlsAllowInvalidHostnames) {
|
|
88
|
-
clientOptions.tlsAllowInvalidHostnames = true;
|
|
89
|
-
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidHostnames is ON. Server hostname will not be validated.");
|
|
90
|
-
}
|
|
96
|
+
return new InternalMongoClient(dbUrl, clientOptions);
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
export
|
|
94
|
-
|
|
99
|
+
export let MongoClient = null;
|
|
95
100
|
|
|
96
101
|
// Database Name
|
|
97
102
|
export const MongoDatabase = () => {
|
|
98
103
|
let dbName = Config.Get('dbName', dbNameBase);
|
|
104
|
+
if( !MongoClient)
|
|
105
|
+
MongoClient = InitMongo();
|
|
106
|
+
console.log('SELECTING ' + dbName + " database.");
|
|
99
107
|
return MongoClient.db(dbName);
|
|
100
108
|
}
|
|
101
109
|
|