data-primals-engine 1.0.1 → 1.0.3

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
@@ -96,7 +96,7 @@ Example:
96
96
 
97
97
  #### Create a model
98
98
  ```bash
99
- curl -X POST http://localhost:7633/api/model?_user=demouser \
99
+ curl -X POST http://localhost:7633/api/model?_user=demo \
100
100
  -H "Authorization: Bearer demotoken" \
101
101
  -H "Content-Type: application/json" \
102
102
  -d '{
@@ -111,7 +111,7 @@ curl -X POST http://localhost:7633/api/model?_user=demouser \
111
111
 
112
112
  #### Update a model
113
113
  ```bash
114
- curl -X PUT http://localhost:7633/api/model/60d0fe4f5311236168a109ca?_user=demouser \
114
+ curl -X PUT http://localhost:7633/api/model/60d0fe4f5311236168a109ca?_user=demo \
115
115
  -H "Authorization: Bearer demotoken" \
116
116
  -H "Content-Type: application/json" \
117
117
  -d '{
@@ -126,7 +126,7 @@ curl -X PUT http://localhost:7633/api/model/60d0fe4f5311236168a109ca?_user=demou
126
126
 
127
127
  #### Delete a model
128
128
  ```bash
129
- curl -X DELETE "http://localhost:7633/api/model?_user=demouser&name=newModel" \
129
+ curl -X DELETE "http://localhost:7633/api/model?_user=demo&name=newModel" \
130
130
  -H "Authorization: Bearer demotoken"
131
131
  ```
132
132
 
@@ -134,7 +134,7 @@ curl -X DELETE "http://localhost:7633/api/model?_user=demouser&name=newModel" \
134
134
 
135
135
  #### Create a document
136
136
  ```bash
137
- curl -X POST http://localhost:7633/api/data?_user=demouser \
137
+ curl -X POST http://localhost:7633/api/data?_user=demo \
138
138
  -H "Authorization: Bearer demotoken" \
139
139
  -H "Content-Type: application/json" \
140
140
  -d '{
@@ -150,7 +150,7 @@ curl -X POST http://localhost:7633/api/data?_user=demouser \
150
150
 
151
151
  #### Search documents
152
152
  ```bash
153
- curl -X POST http://localhost:7633/api/data/search?_user=demouser \
153
+ curl -X POST http://localhost:7633/api/data/search?_user=demo \
154
154
  -H "Authorization: Bearer demotoken" \
155
155
  -H "Content-Type: application/json" \
156
156
  -d '{
@@ -161,7 +161,7 @@ curl -X POST http://localhost:7633/api/data/search?_user=demouser \
161
161
 
162
162
  #### Update a document by ID
163
163
  ```bash
164
- curl -X PUT http://localhost:7633/api/data/64a31c123ef59d4c8d55aa99?_user=demouser \
164
+ curl -X PUT http://localhost:7633/api/data/64a31c123ef59d4c8d55aa99?_user=demo \
165
165
  -H "Authorization: Bearer demotoken" \
166
166
  -H "Content-Type: application/json" \
167
167
  -d '{
@@ -172,7 +172,7 @@ curl -X PUT http://localhost:7633/api/data/64a31c123ef59d4c8d55aa99?_user=demous
172
172
 
173
173
  #### Bulk update
174
174
  ```bash
175
- curl -X PUT http://localhost:7633/api/data?_user=demouser \
175
+ curl -X PUT http://localhost:7633/api/data?_user=demo \
176
176
  -H "Authorization: Bearer demotoken" \
177
177
  -H "Content-Type: application/json" \
178
178
  -d '{
@@ -183,7 +183,7 @@ curl -X PUT http://localhost:7633/api/data?_user=demouser \
183
183
 
184
184
  #### Delete documents
185
185
  ```bash
186
- curl -X DELETE http://localhost:7633/api/data?_user=demouser \
186
+ curl -X DELETE http://localhost:7633/api/data?_user=demo \
187
187
  -H "Authorization: Bearer demotoken" \
188
188
  -H "Content-Type: application/json" \
189
189
  -d '{
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "data-primals-engine",
3
- "version": "1.0.1",
4
-
3
+ "version": "1.0.3",
5
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.",
6
5
  "main": "src/engine.js",
7
6
  "type": "module",
8
7
  "scripts": {
8
+ "preinstall": "npx npm-force-resolutions",
9
9
  "devserver": "cross-env NODE_ENV=development node server.js",
10
10
  "server": "cross-env NODE_ENV=production node server.js",
11
11
  "migrate:create": "node src/migrate.js create",
@@ -14,6 +14,11 @@
14
14
  "migrate:revert": "node src/migrate.js revert",
15
15
  "migrate:status": "node src/migrate.js status"
16
16
  },
17
+ "resolutions": {
18
+ "tar-fs": "3.0.9",
19
+ "on-headers": "1.1.0",
20
+ "brace-expansion": "2.0.2"
21
+ },
17
22
  "repository": {
18
23
  "type": "git",
19
24
  "url": "https://github.com/anonympins/data-primals-engine.git"
@@ -34,11 +39,14 @@
34
39
  "check-disk-space": "^3.4.0",
35
40
  "compression": "^1.8.0",
36
41
  "connect-mongo": "^5.1.0",
42
+ "connect-multiparty": "^2.2.0",
37
43
  "cookie-parser": "^1.4.7",
44
+ "cronstrue": "^3.1.0",
38
45
  "csv-parse": "^5.6.0",
39
46
  "csv-parser": "^3.2.0",
40
47
  "express": "^4.21.2",
41
48
  "express-csrf-double-submit-cookie": "^1.2.1",
49
+ "express-rate-limit": "^8.0.1",
42
50
  "express-session": "^1.18.1",
43
51
  "express-sitemap-xml": "^3.1.0",
44
52
  "juice": "^11.0.1",
@@ -46,13 +54,27 @@
46
54
  "mongodb": "^6.12.0",
47
55
  "node-schedule": "^2.1.1",
48
56
  "nodemailer": "^6.10.0",
57
+ "randomcolor": "^0.6.2",
49
58
  "rate-limiter-flexible": "^5.0.5",
50
- "swagger-ui-express": "^5.0.1",
59
+ "request-ip": "^3.3.0",
60
+ "sanitize-html": "^2.17.0",
51
61
  "sirv": "^3.0.1",
62
+ "swagger-ui-express": "^5.0.1",
52
63
  "tar": "^7.4.3",
53
64
  "tar-fs": "^3.0.8",
54
65
  "uniqid": "^5.4.0",
55
- "yaml": "^2.8.0"
66
+ "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
+ "zlib": "^1.0.5"
56
78
  },
57
79
  "devDependencies": {
58
80
  "@eslint/js": "^9.17.0",
@@ -67,7 +89,8 @@
67
89
  "primals",
68
90
  "automation",
69
91
  "aws",
70
- "bucket", "S3"
92
+ "bucket",
93
+ "S3"
71
94
  ],
72
95
  "author": "anonympins",
73
96
  "license": "MIT",
package/server.js CHANGED
@@ -32,54 +32,18 @@ import path from "node:path";
32
32
  import { getAllPacks} from "../data-primals-engine/src/packs.js";
33
33
  import {middlewareAuthenticator, userInitiator} from "../data-primals-engine/src/modules/user.js";
34
34
  import {defaultModels} from "../data-primals-engine/src/defaultModels.js";
35
- Config.Set("modules", ["mongodb", "data", "file", "bucket", "workflow","user", "assistant"])
35
+ Config.Set("modules", ["mongodb", "data", "file", "bucket", "workflow","user", "assistant", "swagger"])
36
36
  Config.Set("middlewares", []);
37
37
 
38
38
  const bench = GameObject.Create("Benchmark");
39
39
  const timer = bench.addComponent(BenchmarkTool);
40
40
  timer.start();
41
41
 
42
- const swaggerDocument = YAML.parse(fs.readFileSync(process.cwd()+'/swagger-en.yml', 'utf8'));
43
-
44
42
  const engine = Engine.Create();
45
43
 
46
- const models = defaultModels;
47
-
48
44
  const port = process.env.PORT || 7633;
49
45
  engine.start(port, async (r) => {
50
46
  const logger = engine.getComponent(Logger);
51
- logger.info("Loading and validating models...");
52
- const ms = Object.values(models);
53
-
54
- let dbModels = await getModels();
55
-
56
- for(let i = 0; i < ms.length; ++i){
57
- const model = ms[i];
58
- validateModelStructure(model);
59
- // Création des modèles
60
- if( !dbModels.find(m =>m.name === model.name) )
61
- {
62
- model.locked = true;
63
- const r = await createModel(model);
64
- dbModels.push({...model, _id: r.insertedId });
65
- }
66
- else
67
- logger.info('Model loaded (' + model.name + ')', {});
68
- }
69
-
70
- engine.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
71
-
72
- if( install )
73
- await installAllPacks();
74
47
 
75
48
  timer.stop();
76
49
  });
77
-
78
- const installAllPacks = async () => {
79
-
80
- const packs = await getAllPacks();
81
-
82
- console.log(util.inspect(packs, false, 20, true));
83
- await packsCollection.deleteMany({ _user: { $exists : false }});
84
- await packsCollection.insertMany(packs);
85
- }
@@ -292,5 +292,5 @@ export async function onInit(engine) {
292
292
  res.status(500).json({success: false, message: "Une erreur interne est survenue."});
293
293
  }
294
294
  });
295
- logger.info("Module 'assistant' initialisé et endpoint '/api/assistant/chat' enregistré.");
295
+ logger.info("Module 'assistant' loaded and endpoint '/api/assistant/chat' registered.");
296
296
  }
@@ -14,6 +14,9 @@ import crypto from "node:crypto";
14
14
  import * as tar from "tar";
15
15
  import {promisify} from "node:util";
16
16
  import {calculateTotalUserStorageUsage, hasPermission} from "./user.js";
17
+ import {Logger} from "../gameObject.js";
18
+ import YAML from "yaml";
19
+ import swaggerUi from "swagger-ui-express";
17
20
 
18
21
  const pbkdf2Async = promisify(crypto.pbkdf2);
19
22
 
@@ -190,3 +193,7 @@ export async function decryptFile(filePath, password) {
190
193
  throw new Error(`Decryption failed: ${error.message}`);
191
194
  }
192
195
  }
196
+
197
+ export async function onInit(defaultEngine) {
198
+
199
+ }
package/src/providers.js CHANGED
@@ -47,15 +47,17 @@ export class UserProvider {
47
47
 
48
48
  export class DefaultUserProvider extends UserProvider {
49
49
 
50
+ users= [{ username: "demo", password: "demo" }];
51
+
50
52
  async findUserByUsername(username) {
51
- return { username: "test", password: "test" };
53
+ return this.users.find(user => user.username === username);
52
54
  }
53
55
 
54
56
  async validatePassword(user, password) {
55
- if (!user || !user.password || !password) return false;
56
- return await compare(password, user.password);
57
+ return true;
57
58
  }
58
59
 
59
60
  async initiateUser(req) {
61
+ req.me = this.users[0];
60
62
  }
61
63
  }