data-primals-engine 1.0.4 → 1.0.6

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 CHANGED
@@ -30,13 +30,16 @@
30
30
 
31
31
  ## ⚡ Quick Start
32
32
 
33
+ ```bash
34
+ npm i data-primals-engine
35
+ ```
36
+ or
33
37
  ```bash
34
38
  git clone https://your-repo/data-primals-engine.git
35
39
  cd data-primals-engine
36
40
  npm install
37
41
  ```
38
-
39
- Create a `.env` file:
42
+ Possibly create a `.env` file:
40
43
  ```env
41
44
  MONGO_DB_URL=mongodb://127.0.0.1:27017
42
45
  ```
@@ -197,14 +200,15 @@ curl -X DELETE http://localhost:7633/api/data?_user=demo \
197
200
  ```
198
201
  data-primals-engine/
199
202
  ├── src/
200
- │ ├── engine.js
203
+ │ ├── middlewares/
204
+ │ ├── migrations/
201
205
  │ ├── modules/
202
- │ ├── providers/
203
- │ ├── constants.js
204
- │ ├── defaultModels.js
205
- ├── config/
206
- │ ├── models/
207
- └── packs/
206
+ │ ├── workers/
207
+ │ ├── engine.js // The Express engine that serves the API
208
+ │ ├── constants.js // The inner-application constants definitions
209
+ ├── packs.js // The packs that will be loaded and available with installPack() method
210
+ │ ├── defaultModels.js // The default models available to import
211
+ ├── ...
208
212
  └── server.js
209
213
  ```
210
214
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-primals-engine",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "data-primals-engine is the package responsible from handling large amount of data in a practical and performant way. It can handle large amount of data in a practical and performant way. It can also get workflow models working (for automation), and fully supports internationalisation.",
5
5
  "main": "src/engine.js",
6
6
  "type": "module",
@@ -34,28 +34,37 @@
34
34
  "@langchain/openai": "^0.5.18",
35
35
  "archiver": "^7.0.1",
36
36
  "aws-sdk": "^2.1692.0",
37
+ "bcrypt": "^5.1.1",
37
38
  "body-parser": "^1.20.3",
38
39
  "chalk": "^5.4.1",
39
40
  "check-disk-space": "^3.4.0",
40
41
  "compression": "^1.8.0",
41
42
  "connect-mongo": "^5.1.0",
42
- "connect-multiparty": "^2.2.0",
43
43
  "cookie-parser": "^1.4.7",
44
44
  "cronstrue": "^3.1.0",
45
45
  "csv-parse": "^5.6.0",
46
46
  "csv-parser": "^3.2.0",
47
+ "date-fns": "^4.1.0",
47
48
  "express": "^4.21.2",
48
49
  "express-csrf-double-submit-cookie": "^1.2.1",
50
+ "express-formidable": "^1.2.0",
51
+ "express-mongo-sanitize": "^2.2.0",
49
52
  "express-rate-limit": "^8.0.1",
50
53
  "express-session": "^1.18.1",
51
- "express-sitemap-xml": "^3.1.0",
54
+ "i18next": "^24.2.2",
55
+ "i18next-browser-languagedetector": "^8.0.4",
52
56
  "juice": "^11.0.1",
53
57
  "mathjs": "^14.4.0",
54
58
  "mongodb": "^6.12.0",
59
+ "node-cache": "^5.1.2",
55
60
  "node-schedule": "^2.1.1",
56
61
  "nodemailer": "^6.10.0",
62
+ "openai": "^5.8.2",
57
63
  "randomcolor": "^0.6.2",
58
64
  "rate-limiter-flexible": "^5.0.5",
65
+ "react-helmet": "^6.1.0",
66
+ "react-i18next": "^15.4.1",
67
+ "react-markdown": "^10.1.0",
59
68
  "request-ip": "^3.3.0",
60
69
  "sanitize-html": "^2.17.0",
61
70
  "sirv": "^3.0.1",
@@ -64,16 +73,6 @@
64
73
  "tar-fs": "^3.0.8",
65
74
  "uniqid": "^5.4.0",
66
75
  "yaml": "^2.8.0",
67
- "bcrypt": "^5.1.1",
68
- "date-fns": "^4.1.0",
69
- "express-mongo-sanitize": "^2.2.0",
70
- "i18next": "^24.2.2",
71
- "i18next-browser-languagedetector": "^8.0.4",
72
- "node-cache": "^5.1.2",
73
- "openai": "^5.8.2",
74
- "react-helmet": "^6.1.0",
75
- "react-i18next": "^15.4.1",
76
- "react-markdown": "^10.1.0",
77
76
  "zlib": "^1.0.5"
78
77
  },
79
78
  "devDependencies": {
package/server.js CHANGED
@@ -4,34 +4,8 @@
4
4
 
5
5
  //set ES modules to be loaded by the script
6
6
  import process from "node:process";
7
- import {Config} from "../data-primals-engine/src/config.js";
8
- import {Engine} from "../data-primals-engine/src/engine.js";
9
- import {BenchmarkTool, GameObject, Logger} from "../data-primals-engine/src/gameObject.js";
10
- import {
11
- createModel, DATAS_API_TOKEN,
12
- getModels, getResource,
13
- searchData,
14
- validateModelStructure
15
- } from "../data-primals-engine/src/modules/data.js";
16
- import {availableLangs, install, langs, maxBytesPerSecondThrottleFile} from "../data-primals-engine/src/constants.js";
17
- import fs from "node:fs";
18
- import {
19
- event_on, getFileExtension,
20
- shuffle,
21
- uuidv4
22
- } from "../data-primals-engine/src/core.js";
23
- import {datasCollection, filesCollection, modelsCollection, packsCollection} from "../data-primals-engine/src/modules/mongodb.js";
24
- import {translations} from "../data-primals-engine/src/i18n.js";
25
- import {getFieldValueHash} from "../data-primals-engine/src/data.js";
26
-
27
- import swaggerUi from 'swagger-ui-express';
28
-
29
- import YAML from 'yaml';
30
- import util from "node:util";
31
- import path from "node:path";
32
- import { getAllPacks} from "../data-primals-engine/src/packs.js";
33
- import {middlewareAuthenticator, userInitiator} from "../data-primals-engine/src/modules/user.js";
34
- import {defaultModels} from "../data-primals-engine/src/defaultModels.js";
7
+ import {Config, Engine, BenchmarkTool, GameObject, Logger} from "./src/index.js";
8
+
35
9
  Config.Set("modules", ["mongodb", "data", "file", "bucket", "workflow","user", "assistant", "swagger"])
36
10
  Config.Set("middlewares", []);
37
11
 
package/src/data.js CHANGED
@@ -420,6 +420,7 @@ export const getFieldValueHash = (model, data) => {
420
420
  * @returns {string} - La chaîne de caractères représentant la donnée.
421
421
  */
422
422
  export const getDataAsString = (model, data, t, allModels, extended=false) => {
423
+
423
424
  // Cas de base : si le modèle ou les données sont manquants, on ne peut rien faire.
424
425
  if (!model || !data) {
425
426
  return '';
@@ -484,8 +485,14 @@ export const getDataAsString = (model, data, t, allModels, extended=false) => {
484
485
  return value.value; // Champs traduits
485
486
  }
486
487
 
487
- const translatedValue = t(value, {defaultValue: value});
488
- return translatedValue || value.toString();
488
+ if( typeof(value) === 'string' ) {
489
+ const translatedValue = t(value, {defaultValue: value});
490
+ return translatedValue || value.toString();
491
+ }
492
+ if( typeof(value) === 'object' ) {
493
+ return JSON.stringify(value, null, 2);
494
+ }
495
+ return value;
489
496
 
490
497
  }).filter(Boolean).join(', ');
491
498
 
package/src/email.js CHANGED
@@ -1,4 +1,4 @@
1
- import { translations } from "../../data-primals-engine/src/i18n.js";
1
+ import { translations } from "data-primals-engine/i18n";
2
2
  import process from "node:process";
3
3
  import nodemailer from "nodemailer";
4
4
  import juice from "juice";
package/src/engine.js CHANGED
@@ -14,6 +14,7 @@ import requestIp from 'request-ip';
14
14
  import {createModel, getModels, installAllPacks, validateModelStructure} from "./modules/data.js";
15
15
  import {defaultModels} from "./defaultModels.js";
16
16
  import {DefaultUserProvider} from "./providers.js";
17
+ import formidableMiddleware from 'express-formidable';
17
18
 
18
19
  // Constants
19
20
  const isProduction = process.env.NODE_ENV === 'production'
@@ -44,13 +45,12 @@ export const Engine = {
44
45
  app.set('port', process.env.PORT || 3000);
45
46
  app.set('engine', engine);
46
47
 
47
- app.use(bodyParser.urlencoded({extended: true, limit: 4096 }))
48
- app.use(bodyParser.json({ limit: maxDataSize }))
48
+ app.use(formidableMiddleware({
49
+ encoding: 'utf-8',
50
+ uploadDir: process.cwd()+'/uploads/tmp',
51
+ multiples: true, // req.files to be arrays of files
52
+ }));
49
53
  app.use(cookieParser(isProduction ? cookiesSecret : 'secret'));
50
-
51
- var multipartMiddleware = multipart();
52
- app.use(multipartMiddleware);
53
-
54
54
  app.use(requestIp.mw())
55
55
 
56
56
  engine.use = (...args) => {
@@ -124,7 +124,7 @@ export const Engine = {
124
124
 
125
125
  process.on('uncaughtException', function (exception) {
126
126
  console.error(exception);
127
- fs.appendFile('bugs.txt', JSON.stringify({ code: exception.code, message: exception.message, stack: exception.stack }), function (err) {
127
+ fs.appendFile('issues.txt', JSON.stringify({ code: exception.code, message: exception.message, stack: exception.stack }), function (err) {
128
128
  if (err){
129
129
  throw err;
130
130
  }