data-primals-engine 1.2.6-rc1 → 1.2.6-rc2
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/package.json +1 -1
- package/server.js +1 -1
- package/src/engine.js +286 -281
- package/src/modules/data/data.js +1 -2
- package/src/modules/mongodb.js +4 -7
- package/src/modules/workflow.js +3 -1
- package/test/import_export.integration.test.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-primals-engine",
|
|
3
|
-
"version": "1.2.6-
|
|
3
|
+
"version": "1.2.6-rc2",
|
|
4
4
|
"description": "data-primals-engine is a package responsible from handling large amount of data using MongoDB in a practical and performant way. It can also get workflow models working (for automation), and fully supports internationalisation. It also has integrated AI assistant.",
|
|
5
5
|
"main": "src/engine.js",
|
|
6
6
|
"type": "module",
|
package/server.js
CHANGED
|
@@ -8,7 +8,7 @@ import {Config, Engine, BenchmarkTool, GameObject, Logger} from "./src/index.js"
|
|
|
8
8
|
import sirv from "sirv";
|
|
9
9
|
import express from "express";
|
|
10
10
|
|
|
11
|
-
Config.Set("modules", ["
|
|
11
|
+
Config.Set("modules", ["mongodb", "data", "file", "bucket", "workflow","user", "assistant", "swagger"])
|
|
12
12
|
Config.Set("middlewares", []);
|
|
13
13
|
|
|
14
14
|
const bench = GameObject.Create("Benchmark");
|
package/src/engine.js
CHANGED
|
@@ -1,281 +1,286 @@
|
|
|
1
|
-
import {GameObject, Logger} from "./gameObject.js";
|
|
2
|
-
import {Config} from "./config.js";
|
|
3
|
-
import fs from 'node:fs'
|
|
4
|
-
import express from 'express'
|
|
5
|
-
import {MongoClient as InternalMongoClient} from 'mongodb'
|
|
6
|
-
import process from "process";
|
|
7
|
-
import {
|
|
8
|
-
cookiesSecret,
|
|
9
|
-
databasePoolSize,
|
|
10
|
-
dbName,
|
|
11
|
-
tlsAllowInvalidCertificates, tlsAllowInvalidHostnames
|
|
12
|
-
} from "./constants.js";
|
|
13
|
-
import http from "http";
|
|
14
|
-
import cookieParser from "cookie-parser";
|
|
15
|
-
import requestIp from 'request-ip';
|
|
16
|
-
import {createModel, deleteModels, getModels, installAllPacks, validateModelStructure} from "./modules/data/data.js";
|
|
17
|
-
import {defaultModels} from "./defaultModels.js";
|
|
18
|
-
import {DefaultUserProvider} from "./providers.js";
|
|
19
|
-
import formidableMiddleware from 'express-formidable';
|
|
20
|
-
import sirv from "sirv";
|
|
21
|
-
import * as tls from "node:tls";
|
|
22
|
-
import {Event} from "./events.js";
|
|
23
|
-
import path from "node:path";
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
if (process.env.
|
|
36
|
-
|
|
37
|
-
}catch (e) {}
|
|
38
|
-
try{
|
|
39
|
-
if (process.env.
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Path to the certificate
|
|
72
|
-
if (process.env.
|
|
73
|
-
clientOptions.
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
if (
|
|
81
|
-
clientOptions.
|
|
82
|
-
console.warn("🚨 [SECURITY WARNING]
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
engine
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
await
|
|
156
|
-
return {
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
moduleDir =
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
moduleEntryPoint = 'file://'+
|
|
186
|
-
} else if (fs.existsSync(
|
|
187
|
-
moduleEntryPoint = 'file://'+
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
server
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
server.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Event.Trigger("
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
async
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
1
|
+
import {GameObject, Logger} from "./gameObject.js";
|
|
2
|
+
import {Config} from "./config.js";
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import express from 'express'
|
|
5
|
+
import {MongoClient as InternalMongoClient} from 'mongodb'
|
|
6
|
+
import process from "process";
|
|
7
|
+
import {
|
|
8
|
+
cookiesSecret,
|
|
9
|
+
databasePoolSize,
|
|
10
|
+
dbName,
|
|
11
|
+
tlsAllowInvalidCertificates, tlsAllowInvalidHostnames
|
|
12
|
+
} from "./constants.js";
|
|
13
|
+
import http from "http";
|
|
14
|
+
import cookieParser from "cookie-parser";
|
|
15
|
+
import requestIp from 'request-ip';
|
|
16
|
+
import {createModel, deleteModels, getModels, installAllPacks, validateModelStructure} from "./modules/data/data.js";
|
|
17
|
+
import {defaultModels} from "./defaultModels.js";
|
|
18
|
+
import {DefaultUserProvider} from "./providers.js";
|
|
19
|
+
import formidableMiddleware from 'express-formidable';
|
|
20
|
+
import sirv from "sirv";
|
|
21
|
+
import * as tls from "node:tls";
|
|
22
|
+
import {Event} from "./events.js";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
// Constants
|
|
26
|
+
|
|
27
|
+
// On définit __dirname pour obtenir le chemin absolu du répertoire courant,
|
|
28
|
+
// ce qui est la méthode standard en ES Modules.
|
|
29
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
30
|
+
const __dirname = path.dirname(__filename);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
let caFile, certFile, keyFile;
|
|
34
|
+
try {
|
|
35
|
+
if (process.env.CA_CERT)
|
|
36
|
+
caFile = fs.readFileSync(process.env.CA_CERT);
|
|
37
|
+
} catch (e) {}
|
|
38
|
+
try {
|
|
39
|
+
if (process.env.CERT)
|
|
40
|
+
certFile = fs.readFileSync(process.env.CERT);
|
|
41
|
+
}catch (e) {}
|
|
42
|
+
try{
|
|
43
|
+
if (process.env.CERT_KEY)
|
|
44
|
+
keyFile = fs.readFileSync(process.env.CERT_KEY);
|
|
45
|
+
} catch (e) {}
|
|
46
|
+
|
|
47
|
+
const secureContext = tls.createSecureContext({
|
|
48
|
+
ca: caFile, cert: certFile, key: keyFile
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const dbUrl = process.env.CI ? 'mongodb://mongodb:27017' : (process.env.MONGO_DB_URL || 'mongodb://127.0.0.1:27017');
|
|
52
|
+
|
|
53
|
+
const isTlsActive = !(!process.env.TLS || ["0", "false"].includes(process.env.TLS.toLowerCase()));
|
|
54
|
+
|
|
55
|
+
const clientOptions = {
|
|
56
|
+
maxPoolSize: databasePoolSize
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// We add TLS options if enabled
|
|
60
|
+
if (isTlsActive) {
|
|
61
|
+
clientOptions.tls = true;
|
|
62
|
+
|
|
63
|
+
// is mTLS ? (client certificate required instead of password)
|
|
64
|
+
if (process.env.CERT) {
|
|
65
|
+
clientOptions.secureContext = tls.createSecureContext({
|
|
66
|
+
ca: fs.readFileSync(process.env.CA_CERT),
|
|
67
|
+
cert: fs.readFileSync(process.env.CERT),
|
|
68
|
+
key: fs.readFileSync(process.env.CERT_KEY)
|
|
69
|
+
});
|
|
70
|
+
}else {
|
|
71
|
+
// Path to the authority certificate
|
|
72
|
+
if (process.env.CA_CERT) {
|
|
73
|
+
clientOptions.tlsCAFile = process.env.CA_CERT;
|
|
74
|
+
}
|
|
75
|
+
// Path to the certificate key
|
|
76
|
+
if (process.env.CERT_KEY) {
|
|
77
|
+
clientOptions.tlsCertificateKeyFile = process.env.CERT_KEY;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (tlsAllowInvalidCertificates) {
|
|
81
|
+
clientOptions.tlsAllowInvalidCertificates = true;
|
|
82
|
+
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidCertificates is ON. Server certificate will not be validated.");
|
|
83
|
+
}
|
|
84
|
+
if (tlsAllowInvalidHostnames) {
|
|
85
|
+
clientOptions.tlsAllowInvalidHostnames = true;
|
|
86
|
+
console.warn("🚨 [SECURITY WARNING] tlsAllowInvalidHostnames is ON. Server hostname will not be validated.");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const MongoClient = new InternalMongoClient(dbUrl, clientOptions);
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// Database Name
|
|
94
|
+
export const MongoDatabase = MongoClient.db(dbName);
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export const Engine = {
|
|
98
|
+
Create: async (options = { app : null}) => {
|
|
99
|
+
const engine = GameObject.Create("Engine");
|
|
100
|
+
console.log("Creating engine", Config.Get('modules'));
|
|
101
|
+
const logger = engine.addComponent(Logger);
|
|
102
|
+
|
|
103
|
+
engine.userProvider = new DefaultUserProvider(engine);
|
|
104
|
+
|
|
105
|
+
engine.setUserProvider = (providerInstance) => {
|
|
106
|
+
engine.userProvider = providerInstance;
|
|
107
|
+
logger.info(`Custom UserProvider '${providerInstance.constructor.name}' has been set.`);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
if (!options.app) {
|
|
111
|
+
options.app = express();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const { app } = options;
|
|
115
|
+
// Allows you to set port in the project properties.
|
|
116
|
+
app.set('port', process.env.PORT || 3000);
|
|
117
|
+
app.set('engine', engine);
|
|
118
|
+
|
|
119
|
+
app.use(formidableMiddleware({
|
|
120
|
+
encoding: 'utf-8',
|
|
121
|
+
uploadDir: process.cwd()+'/uploads/tmp',
|
|
122
|
+
multiples: true // req.files to be arrays of files
|
|
123
|
+
}));
|
|
124
|
+
app.use(cookieParser(process.env.COOKIES_SECRET || cookiesSecret));
|
|
125
|
+
app.use(requestIp.mw())
|
|
126
|
+
|
|
127
|
+
engine.use = (...args) => {
|
|
128
|
+
return app.use(...args);
|
|
129
|
+
}
|
|
130
|
+
engine.post = (...args) => {
|
|
131
|
+
return app.post(...args);
|
|
132
|
+
};
|
|
133
|
+
engine.get = (...args) => {
|
|
134
|
+
return app.get(...args);
|
|
135
|
+
};
|
|
136
|
+
engine.delete = (...args) => {
|
|
137
|
+
return app.delete(...args);
|
|
138
|
+
};
|
|
139
|
+
engine.patch = (...args) => {
|
|
140
|
+
return app.patch(...args);
|
|
141
|
+
};
|
|
142
|
+
engine.put = (...args) => {
|
|
143
|
+
return app.put(...args);
|
|
144
|
+
};
|
|
145
|
+
engine.all = (...args) => {
|
|
146
|
+
return app.all(...args);
|
|
147
|
+
};
|
|
148
|
+
engine.getModule = (module) => {
|
|
149
|
+
return engine._modules.find(m => m.module === module);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const importModule = async (module) => {
|
|
153
|
+
const moduleA = await import(module);
|
|
154
|
+
if (moduleA.onInit){
|
|
155
|
+
await moduleA.onInit(engine);
|
|
156
|
+
return {...moduleA, module};
|
|
157
|
+
}else {
|
|
158
|
+
const mod = moduleA.default();
|
|
159
|
+
await mod?.onInit(engine);
|
|
160
|
+
return { ...mod, module};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
engine._modules = [];
|
|
165
|
+
for (const moduleIdentifier of Config.Get('modules', [])) {
|
|
166
|
+
try {
|
|
167
|
+
let moduleDir;
|
|
168
|
+
const moduleName = path.basename(moduleIdentifier);
|
|
169
|
+
|
|
170
|
+
const directPath = path.resolve(moduleIdentifier);
|
|
171
|
+
let isDir = fs.existsSync(directPath) && fs.statSync(directPath).isDirectory();
|
|
172
|
+
|
|
173
|
+
if (isDir) {
|
|
174
|
+
moduleDir = directPath;
|
|
175
|
+
} else {
|
|
176
|
+
moduleDir = path.resolve(__dirname, 'modules', moduleIdentifier);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let moduleEntryPoint;
|
|
180
|
+
const jsPath = moduleDir + '.js';
|
|
181
|
+
const indexJsPath = path.join(moduleDir, 'index.js');
|
|
182
|
+
const moduleJsPath = path.join(moduleDir, `${moduleName}.js`);
|
|
183
|
+
|
|
184
|
+
if (fs.existsSync(jsPath)) {
|
|
185
|
+
moduleEntryPoint = 'file://' + jsPath;
|
|
186
|
+
} else if (fs.existsSync(indexJsPath)) {
|
|
187
|
+
moduleEntryPoint = 'file://' + indexJsPath;
|
|
188
|
+
} else if (fs.existsSync(moduleJsPath)) {
|
|
189
|
+
moduleEntryPoint = 'file://' + moduleJsPath;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (moduleEntryPoint) {
|
|
193
|
+
const loadedModule = await importModule(moduleEntryPoint);
|
|
194
|
+
if (loadedModule) {
|
|
195
|
+
engine._modules.push(loadedModule);
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
logger.warn(`Aucun point d'entrée trouvé pour le module '${moduleIdentifier}'.`);
|
|
199
|
+
}
|
|
200
|
+
} catch (e) {
|
|
201
|
+
logger.error(`Échec du chargement du module '${moduleIdentifier}':`, e.stack);
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let server;
|
|
207
|
+
|
|
208
|
+
engine.start = async (port, cb) =>{
|
|
209
|
+
// Use connect method to connect to the server
|
|
210
|
+
|
|
211
|
+
// Start http server
|
|
212
|
+
server = http.createServer(app);
|
|
213
|
+
|
|
214
|
+
// Server Timeout Settings
|
|
215
|
+
server.timeout = 120000;
|
|
216
|
+
server.headersTimeout = 20000;
|
|
217
|
+
server.requestTimeout = 30000;
|
|
218
|
+
server.keepAliveTimeout = 5000;
|
|
219
|
+
|
|
220
|
+
server.listen(port);
|
|
221
|
+
|
|
222
|
+
await setupInitialModels();
|
|
223
|
+
await installAllPacks();
|
|
224
|
+
|
|
225
|
+
if (cb)
|
|
226
|
+
await cb();
|
|
227
|
+
|
|
228
|
+
engine.get('/api/health', (req, res) => {
|
|
229
|
+
res.status(200).json({
|
|
230
|
+
status: 'ok',
|
|
231
|
+
timestamp: new Date().toISOString()
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
app.use(sirv('client/dist', {
|
|
236
|
+
single: true,
|
|
237
|
+
dev: process.env.NODE_ENV === 'development'
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
process.on('uncaughtException', function (exception) {
|
|
241
|
+
console.error(exception);
|
|
242
|
+
fs.appendFile('issues.txt', JSON.stringify({ code: exception.code, message: exception.message, stack: exception.stack }), function (err) {
|
|
243
|
+
if (err){
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
process.exit(1);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
Event.Trigger("OnServerStart", "event", "system", engine);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
engine.stop = async () => {
|
|
254
|
+
await server.close();
|
|
255
|
+
Event.Trigger("OnServerStop", "event", "system", engine);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
async function setupInitialModels() {
|
|
259
|
+
logger.info("Validating structures of default models...");
|
|
260
|
+
const ms = Object.values(Config.Get('defaultModels', defaultModels));
|
|
261
|
+
|
|
262
|
+
let dbModels = await getModels();
|
|
263
|
+
|
|
264
|
+
for(let i = 0; i < ms.length; ++i){
|
|
265
|
+
const model = ms[i];
|
|
266
|
+
validateModelStructure(model);
|
|
267
|
+
// Création des modèles
|
|
268
|
+
if( !dbModels.find(m =>m.name === model.name) )
|
|
269
|
+
{
|
|
270
|
+
model.locked = true;
|
|
271
|
+
const r = await createModel(model);
|
|
272
|
+
dbModels.push({...model, _id: r.insertedId });
|
|
273
|
+
logger.info('Model inserted (' + model.name + ')');
|
|
274
|
+
}else
|
|
275
|
+
logger.info('Model loaded (' + model.name + ')');
|
|
276
|
+
}
|
|
277
|
+
logger.info("All models loaded.");
|
|
278
|
+
Event.Trigger("OnModelsLoaded", "event", "system", engine, dbModels);
|
|
279
|
+
}
|
|
280
|
+
engine.resetModels = async () => {
|
|
281
|
+
await deleteModels();
|
|
282
|
+
Event.Trigger("OnModelsDeleted", "event", "system", engine);
|
|
283
|
+
};
|
|
284
|
+
return engine;
|
|
285
|
+
}
|
|
286
|
+
}
|
package/src/modules/data/data.js
CHANGED
|
@@ -1353,6 +1353,7 @@ export async function onInit(defaultEngine) {
|
|
|
1353
1353
|
packsCollection = getCollection("packs");
|
|
1354
1354
|
}
|
|
1355
1355
|
await registerRoutes(engine);
|
|
1356
|
+
logger = engine.getComponent(Logger);
|
|
1356
1357
|
|
|
1357
1358
|
// set backup scheduler
|
|
1358
1359
|
schedule.scheduleJob("0 2 * * *", jobDumpUserData);
|
|
@@ -1364,8 +1365,6 @@ export async function onInit(defaultEngine) {
|
|
|
1364
1365
|
dt.setTime(dt.getTime()-1000*3600*24*14);
|
|
1365
1366
|
await deleteData("request", {"$lt": ["$timestamp",dt.toISOString()]}, null, false);
|
|
1366
1367
|
});
|
|
1367
|
-
await scheduleWorkflowTriggers();
|
|
1368
|
-
|
|
1369
1368
|
await scheduleAlerts();
|
|
1370
1369
|
|
|
1371
1370
|
}
|
package/src/modules/mongodb.js
CHANGED
|
@@ -10,15 +10,12 @@ export async function onInit(defaultEngine) {
|
|
|
10
10
|
engine = defaultEngine;
|
|
11
11
|
logger = engine.getComponent(Logger);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
filesCollection = MongoDatabase.collection("files");
|
|
18
|
-
packsCollection = MongoDatabase.collection("packs");
|
|
13
|
+
modelsCollection = getCollection("models");
|
|
14
|
+
datasCollection = getCollection("datas");
|
|
15
|
+
filesCollection = getCollection("files");
|
|
16
|
+
packsCollection = getCollection("packs");
|
|
19
17
|
|
|
20
18
|
logger.info("MongoDB collections loaded.");
|
|
21
|
-
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
|
package/src/modules/workflow.js
CHANGED
|
@@ -6,7 +6,7 @@ import crypto from "node:crypto";
|
|
|
6
6
|
import ivm from 'isolated-vm';
|
|
7
7
|
|
|
8
8
|
import {Logger} from "../gameObject.js";
|
|
9
|
-
import {deleteData, insertData, patchData, searchData} from "./data/index.js";
|
|
9
|
+
import {deleteData, insertData, patchData, scheduleAlerts, searchData} from "./data/index.js";
|
|
10
10
|
import {emailDefaultConfig, maxExecutionsByStep, maxWorkflowSteps} from "../constants.js";
|
|
11
11
|
import {ChatOpenAI} from "@langchain/openai";
|
|
12
12
|
import {ChatGoogleGenerativeAI} from "@langchain/google-genai";
|
|
@@ -21,6 +21,8 @@ import util from "node:util";
|
|
|
21
21
|
let logger = null;
|
|
22
22
|
export async function onInit(defaultEngine) {
|
|
23
23
|
logger = defaultEngine.getComponent(Logger);
|
|
24
|
+
|
|
25
|
+
await scheduleWorkflowTriggers();
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -48,7 +48,7 @@ function blobToFile(theBlob, fileName){
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
beforeAll(async () =>{
|
|
51
|
-
Config.Set("modules", ["
|
|
51
|
+
Config.Set("modules", ["mongodb", "data", "file", "bucket", "workflow","user", "assistant"]);
|
|
52
52
|
await initEngine();
|
|
53
53
|
})
|
|
54
54
|
|