nesoi 3.1.8 → 3.2.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/lib/compiler/apps/distributed/distributed_compiler.d.ts +31 -0
- package/lib/compiler/apps/distributed/distributed_compiler.js +121 -0
- package/lib/compiler/apps/distributed/stages/1_mkdir_stage.d.ts +15 -0
- package/lib/compiler/apps/distributed/stages/1_mkdir_stage.js +96 -0
- package/lib/compiler/apps/distributed/stages/2_build_typescript_stage.d.ts +15 -0
- package/lib/compiler/apps/distributed/stages/2_build_typescript_stage.js +174 -0
- package/lib/compiler/apps/distributed/stages/3_copy_types_stage.d.ts +15 -0
- package/lib/compiler/apps/distributed/stages/3_copy_types_stage.js +82 -0
- package/lib/compiler/apps/distributed/stages/4_dump_modules_stage.d.ts +16 -0
- package/lib/compiler/apps/distributed/stages/4_dump_modules_stage.js +182 -0
- package/lib/compiler/apps/distributed/stages/5_copy_static_stage.d.ts +0 -0
- package/lib/compiler/apps/distributed/stages/5_copy_static_stage.js +31 -0
- package/lib/compiler/apps/distributed/stages/6_dump_cli_stage.d.ts +0 -0
- package/lib/compiler/apps/distributed/stages/6_dump_cli_stage.js +34 -0
- package/lib/compiler/apps/distributed/stages/7_dump_package_json_stage.d.ts +0 -0
- package/lib/compiler/apps/distributed/stages/7_dump_package_json_stage.js +45 -0
- package/lib/compiler/elements/element.js +2 -2
- package/lib/compiler/index.d.ts +1 -0
- package/lib/compiler/index.js +3 -1
- package/lib/elements/blocks/block.builder.d.ts +1 -0
- package/lib/elements/blocks/block.builder.js +16 -1
- package/lib/elements/blocks/block.schema.d.ts +4 -1
- package/lib/elements/blocks/job/internal/resource_job.js +1 -1
- package/lib/elements/blocks/job/job.builder.d.ts +1 -0
- package/lib/elements/blocks/job/job.builder.js +2 -1
- package/lib/elements/blocks/resource/resource.builder.js +1 -1
- package/lib/elements/blocks/resource/resource.js +1 -0
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +2 -2
- package/lib/elements/entities/bucket/adapters/bucket_adapter.js +2 -2
- package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +1 -1
- package/lib/elements/entities/bucket/adapters/memory.nql.js +9 -5
- package/lib/elements/entities/bucket/bucket.d.ts +13 -2
- package/lib/elements/entities/bucket/bucket.js +47 -3
- package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +11 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.js +49 -2
- package/lib/elements/entities/bucket/model/bucket_model.schema.js +14 -11
- package/lib/elements/entities/bucket/query/nql_engine.d.ts +2 -2
- package/lib/elements/entities/bucket/query/nql_engine.js +8 -4
- package/lib/elements/entities/bucket/view/bucket_view.js +65 -12
- package/lib/engine/apps/app.config.d.ts +24 -30
- package/lib/engine/apps/app.config.js +11 -21
- package/lib/engine/apps/app.d.ts +6 -5
- package/lib/engine/apps/app.js +1 -1
- package/lib/engine/apps/distributed/distributed.app.config.d.ts +44 -0
- package/lib/engine/apps/distributed/distributed.app.config.js +36 -0
- package/lib/engine/apps/distributed/distributed.app.d.ts +30 -0
- package/lib/engine/apps/distributed/distributed.app.js +52 -0
- package/lib/engine/apps/distributed/distributed_node.app.d.ts +67 -0
- package/lib/engine/apps/distributed/distributed_node.app.js +191 -0
- package/lib/engine/apps/distributed/elements/distributed_job.d.ts +7 -0
- package/lib/engine/apps/distributed/elements/distributed_job.js +11 -0
- package/lib/engine/apps/distributed/inc/inc.client.d.ts +17 -0
- package/lib/engine/apps/distributed/inc/inc.client.js +105 -0
- package/lib/engine/apps/distributed/inc/inc.server.d.ts +19 -0
- package/lib/engine/apps/distributed/inc/inc.server.js +174 -0
- package/lib/engine/apps/distributed/inc/sandbox.d.ts +1 -0
- package/lib/engine/apps/distributed/inc/sandbox.js +24 -0
- package/lib/engine/apps/inline.app.d.ts +2 -2
- package/lib/engine/apps/inline.app.js +2 -2
- package/lib/engine/apps/monolyth/monolyth.app.d.ts +2 -2
- package/lib/engine/apps/monolyth/monolyth.app.js +1 -1
- package/lib/engine/module.d.ts +11 -1
- package/lib/engine/module.js +17 -4
- package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +5 -0
- package/lib/engine/transaction/nodes/bucket.trx_node.js +10 -0
- package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +2 -0
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +15 -4
- package/lib/engine/util/log.d.ts +1 -1
- package/lib/engine/util/log.js +3 -0
- package/package.json +1 -1
- package/tools/joaquin/bucket.d.ts +23 -3
- package/tools/joaquin/bucket.js +48 -20
- package/tools/joaquin/job.js +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DumpModulesStage = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const log_1 = require("../../../../engine/util/log");
|
|
40
|
+
const app_1 = require("../../../../engine/apps/app");
|
|
41
|
+
/**
|
|
42
|
+
* [distributed Compiler Stage #4]
|
|
43
|
+
* Dump modules to build/modules folder.
|
|
44
|
+
*
|
|
45
|
+
* @category distributed Compiler
|
|
46
|
+
* @subcategory Stages
|
|
47
|
+
*/
|
|
48
|
+
class DumpModulesStage {
|
|
49
|
+
constructor(distributed, app) {
|
|
50
|
+
this.distributed = distributed;
|
|
51
|
+
this.app = app;
|
|
52
|
+
}
|
|
53
|
+
async run() {
|
|
54
|
+
const { compiler, dirs: _dirs } = this.distributed;
|
|
55
|
+
for (const name in this.app.nodes) {
|
|
56
|
+
log_1.Log.info('compiler', 'distributed', `[${name}] Dumping modules to build/modules folder...`);
|
|
57
|
+
const node = this.app.nodes[name];
|
|
58
|
+
const info = app_1.App.getInfo(node);
|
|
59
|
+
const dirs = _dirs.nodes[name];
|
|
60
|
+
for (const name of info.spaceModules) {
|
|
61
|
+
const module = compiler.modules[name];
|
|
62
|
+
this.dumpModule(module, dirs.build_modules);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
dumpModule(module, dir) {
|
|
67
|
+
log_1.Log.debug('compiler', 'distributed', `Dumping module ${module.lowName}`);
|
|
68
|
+
let str = `const { Module } = require('${module.compiler.config?.nesoiPath || 'nesoi'}/lib/engine/module');\n`;
|
|
69
|
+
str += `exports.default = new Module('${module.lowName}')\n`;
|
|
70
|
+
str += ' .inject({';
|
|
71
|
+
const externals = module.module.schema.externals;
|
|
72
|
+
if (externals) {
|
|
73
|
+
str += '\n externals: {';
|
|
74
|
+
if (Object.keys(externals.buckets).length) {
|
|
75
|
+
str += '\n buckets: {';
|
|
76
|
+
for (const b in externals.buckets) {
|
|
77
|
+
const dep = externals.buckets[b];
|
|
78
|
+
str += `\n '${b}': ${JSON.stringify(dep, undefined, 2).replace(/\n/g, '\n ')},`;
|
|
79
|
+
}
|
|
80
|
+
str += '\n },';
|
|
81
|
+
}
|
|
82
|
+
if (Object.keys(externals.messages).length) {
|
|
83
|
+
str += '\n messages: {';
|
|
84
|
+
for (const b in externals.messages) {
|
|
85
|
+
const dep = externals.messages[b];
|
|
86
|
+
str += `\n '${b}': ${JSON.stringify(dep, undefined, 2).replace(/\n/g, '\n ')},`;
|
|
87
|
+
}
|
|
88
|
+
str += '\n },';
|
|
89
|
+
}
|
|
90
|
+
if (Object.keys(externals.jobs).length) {
|
|
91
|
+
str += '\n jobs: {\n';
|
|
92
|
+
for (const b in externals.jobs) {
|
|
93
|
+
const dep = externals.jobs[b];
|
|
94
|
+
str += `\n '${b}': ${JSON.stringify(dep, undefined, 2).replace(/\n/g, '\n ')},`;
|
|
95
|
+
}
|
|
96
|
+
str += '\n },';
|
|
97
|
+
}
|
|
98
|
+
if (Object.keys(externals.machines).length) {
|
|
99
|
+
str += '\n machines: {\n';
|
|
100
|
+
for (const b in externals.machines) {
|
|
101
|
+
const dep = externals.machines[b];
|
|
102
|
+
str += `\n '${b}': ${JSON.stringify(dep, undefined, 2).replace(/\n/g, '\n ')},`;
|
|
103
|
+
}
|
|
104
|
+
str += '\n },';
|
|
105
|
+
}
|
|
106
|
+
str += '\n },';
|
|
107
|
+
}
|
|
108
|
+
const constants = module.module.schema.constants;
|
|
109
|
+
if (constants && (Object.values(constants.values).length || Object.values(constants.enums).length)) {
|
|
110
|
+
str += `\n constants: require('./${module.lowName}/constants__${module.lowName}').default,`;
|
|
111
|
+
}
|
|
112
|
+
const buckets = Object.values(module.module.schema.buckets || {});
|
|
113
|
+
if (buckets.length) {
|
|
114
|
+
str += '\n buckets: [\n';
|
|
115
|
+
buckets.forEach(bucket => {
|
|
116
|
+
str += ` require('./${module.lowName}/bucket__${bucket.name}').default,\n`;
|
|
117
|
+
});
|
|
118
|
+
str += ' ],';
|
|
119
|
+
}
|
|
120
|
+
const messages = Object.values(module.module.schema.messages || {});
|
|
121
|
+
if (messages.length) {
|
|
122
|
+
str += '\n messages: [\n';
|
|
123
|
+
messages.forEach(message => {
|
|
124
|
+
str += ` require('./${module.lowName}/message__${message.name}').default,\n`;
|
|
125
|
+
});
|
|
126
|
+
str += ' ],';
|
|
127
|
+
}
|
|
128
|
+
const jobs = Object.values(module.module.schema.jobs || {});
|
|
129
|
+
if (jobs.length) {
|
|
130
|
+
str += '\n jobs: [\n';
|
|
131
|
+
jobs.forEach(job => {
|
|
132
|
+
str += ` require('./${module.lowName}/job__${job.name}').default,\n`;
|
|
133
|
+
});
|
|
134
|
+
str += ' ],';
|
|
135
|
+
}
|
|
136
|
+
const resources = Object.values(module.module.schema.resources || {});
|
|
137
|
+
if (resources.length) {
|
|
138
|
+
str += '\n resources: [\n';
|
|
139
|
+
resources.forEach(resource => {
|
|
140
|
+
str += ` require('./${module.lowName}/resource__${resource.name}').default,\n`;
|
|
141
|
+
});
|
|
142
|
+
str += ' ],';
|
|
143
|
+
}
|
|
144
|
+
const machines = Object.values(module.module.schema.machines || {});
|
|
145
|
+
if (machines.length) {
|
|
146
|
+
str += '\n machines: [\n';
|
|
147
|
+
machines.forEach(machine => {
|
|
148
|
+
str += ` require('./${module.lowName}/machine__${machine.name}').default,\n`;
|
|
149
|
+
});
|
|
150
|
+
str += ' ],';
|
|
151
|
+
}
|
|
152
|
+
const controllers = Object.values(module.module.schema.controllers || {});
|
|
153
|
+
if (controllers.length) {
|
|
154
|
+
str += '\n controllers: [\n';
|
|
155
|
+
controllers.forEach(controller => {
|
|
156
|
+
str += ` require('./${module.lowName}/controller__${controller.name}').default,\n`;
|
|
157
|
+
});
|
|
158
|
+
str += ' ],';
|
|
159
|
+
}
|
|
160
|
+
const queues = Object.values(module.module.schema.queues || {});
|
|
161
|
+
if (queues.length) {
|
|
162
|
+
str += '\n queues: [\n';
|
|
163
|
+
queues.forEach(queue => {
|
|
164
|
+
str += ` require('./${module.lowName}/queue__${queue.name}').default,\n`;
|
|
165
|
+
});
|
|
166
|
+
str += ' ],';
|
|
167
|
+
}
|
|
168
|
+
const topics = Object.values(module.module.schema.topics || {});
|
|
169
|
+
if (topics.length) {
|
|
170
|
+
str += '\n topics: [\n';
|
|
171
|
+
topics.forEach(topic => {
|
|
172
|
+
str += ` require('./${module.lowName}/topic__${topic.name}').default,\n`;
|
|
173
|
+
});
|
|
174
|
+
str += ' ],';
|
|
175
|
+
}
|
|
176
|
+
str += '})';
|
|
177
|
+
const moduleFilename = `${module.lowName}.js`;
|
|
178
|
+
const modulePath = path.resolve(dir, moduleFilename);
|
|
179
|
+
fs.writeFileSync(modulePath, str);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.DumpModulesStage = DumpModulesStage;
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as fs from 'fs';
|
|
3
|
+
// import * as path from 'path';
|
|
4
|
+
// import { Log } from '~/engine/util/log';
|
|
5
|
+
// import { MonolythApp } from '~/engine/apps/monolyth/monolyth.app';
|
|
6
|
+
// import { MonolythCompiler } from '../monolyth_compiler';
|
|
7
|
+
// import { Space } from '~/engine/space';
|
|
8
|
+
// /**
|
|
9
|
+
// * [Monolyth Compiler Stage #5]
|
|
10
|
+
// * Copy the paths passed to `staticPaths` on the compiler
|
|
11
|
+
// * config to the build folder.
|
|
12
|
+
// *
|
|
13
|
+
// * @category Monolyth Compiler
|
|
14
|
+
// * @subcategory Stages
|
|
15
|
+
// */
|
|
16
|
+
// export class CopyStaticStage {
|
|
17
|
+
// public constructor(
|
|
18
|
+
// private monolyth: MonolythCompiler,
|
|
19
|
+
// private app: MonolythApp<any, any>
|
|
20
|
+
// ) {}
|
|
21
|
+
// public async run() {
|
|
22
|
+
// Log.info('compiler', 'monolyth', 'Copying static paths to build folder...')
|
|
23
|
+
// for (const staticPath of this.monolyth.config.staticPaths || []) {
|
|
24
|
+
// const from = Space.path(this.monolyth.compiler.space, staticPath);
|
|
25
|
+
// const to = path.join(this.monolyth.dirs.build, staticPath);
|
|
26
|
+
// fs.cpSync(from, to, {
|
|
27
|
+
// recursive: true
|
|
28
|
+
// })
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as fs from 'fs';
|
|
3
|
+
// import * as path from 'path';
|
|
4
|
+
// import { Log } from '~/engine/util/log';
|
|
5
|
+
// import { MonolythApp } from '~/engine/apps/monolyth/monolyth.app';
|
|
6
|
+
// import { MonolythCompiler } from '../monolyth_compiler';
|
|
7
|
+
// /**
|
|
8
|
+
// * [Monolyth Compiler Stage #6]
|
|
9
|
+
// * Dump the cli.js file to build/bin folder.
|
|
10
|
+
// *
|
|
11
|
+
// * @category Monolyth Compiler
|
|
12
|
+
// * @subcategory Stages
|
|
13
|
+
// */
|
|
14
|
+
// export class DumpCLIStage {
|
|
15
|
+
// public constructor(
|
|
16
|
+
// private monolyth: MonolythCompiler,
|
|
17
|
+
// private app: MonolythApp<any, any>
|
|
18
|
+
// ) {}
|
|
19
|
+
// public async run() {
|
|
20
|
+
// Log.info('compiler', 'monolyth', 'Dumping cli.js file to build/bin folder...')
|
|
21
|
+
// const { dirs } = this.monolyth;
|
|
22
|
+
// let str = '';
|
|
23
|
+
// str += 'require("nesoi/tools/dotenv");\n';
|
|
24
|
+
// str += 'const app = require(\'../app\').default\n';
|
|
25
|
+
// str += 'const { Log } = require(\'nesoi/lib/engine/util/log\');\n';
|
|
26
|
+
// str += 'Log.level = \'debug\';\n'
|
|
27
|
+
// str += '\n';
|
|
28
|
+
// str += '(async () => {\n';
|
|
29
|
+
// str += ' (await app.daemon()).cli();\n';
|
|
30
|
+
// str += '})()'
|
|
31
|
+
// const filePath = path.resolve(dirs.build_bin, 'cli.js')
|
|
32
|
+
// fs.writeFileSync(filePath, str);
|
|
33
|
+
// }
|
|
34
|
+
// }
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as fs from 'fs';
|
|
3
|
+
// import * as path from 'path';
|
|
4
|
+
// import { Log } from '~/engine/util/log';
|
|
5
|
+
// import { MonolythCompiler } from '../monolyth_compiler';
|
|
6
|
+
// import { Space } from '~/engine/space';
|
|
7
|
+
// import { MonolythApp } from '~/engine/apps/monolyth/monolyth.app';
|
|
8
|
+
// /**
|
|
9
|
+
// * [Monolyth Compiler Stage #7]
|
|
10
|
+
// * Dump the package.json file to build folder.
|
|
11
|
+
// *
|
|
12
|
+
// * @category Monolyth Compiler
|
|
13
|
+
// * @subcategory Stages
|
|
14
|
+
// */
|
|
15
|
+
// export class DumpPackageJsonStage {
|
|
16
|
+
// public constructor(
|
|
17
|
+
// private monolyth: MonolythCompiler,
|
|
18
|
+
// private app: MonolythApp<any, any>
|
|
19
|
+
// ) {}
|
|
20
|
+
// public async run() {
|
|
21
|
+
// Log.info('compiler', 'monolyth', 'Dumping package.json to build folder...')
|
|
22
|
+
// const { config, compiler, dirs } = this.monolyth;
|
|
23
|
+
// const packageJsonPath = config.nesoiPath
|
|
24
|
+
// ? path.join(config.nesoiPath, 'package.json')
|
|
25
|
+
// : path.join('..', '..', '..', '..', '..', 'package.json');
|
|
26
|
+
// const nesoiPackageJson = await import(packageJsonPath);
|
|
27
|
+
// const spacePackageJson = await import(Space.path(compiler.space,'package.json'));
|
|
28
|
+
// const filePath = path.resolve(dirs.build, 'package.json');
|
|
29
|
+
// const scripts: Record<string, string> = {
|
|
30
|
+
// cli: 'node bin/cli.js'
|
|
31
|
+
// };
|
|
32
|
+
// Object.entries(config.scripts || {}).forEach(([name, path]) => {
|
|
33
|
+
// const jspath = path.replace(/\.ts/,'.js');
|
|
34
|
+
// scripts[name] = `node ${jspath}`;
|
|
35
|
+
// });
|
|
36
|
+
// const dependencies = {
|
|
37
|
+
// ...spacePackageJson.dependencies,
|
|
38
|
+
// nesoi: config.nesoiPath
|
|
39
|
+
// ? `file:${config.nesoiPath}`
|
|
40
|
+
// : nesoiPackageJson.version
|
|
41
|
+
// }
|
|
42
|
+
// const packageJson = MonolythApp.package(this.app, scripts, dependencies);
|
|
43
|
+
// fs.writeFileSync(filePath, JSON.stringify(packageJson, undefined, 2))
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
@@ -93,9 +93,9 @@ class Element {
|
|
|
93
93
|
return msgName.type;
|
|
94
94
|
});
|
|
95
95
|
const objs = schema.output?.obj?.map(bucket => {
|
|
96
|
-
const schema = compiler.tree.getSchema(bucket);
|
|
96
|
+
const schema = compiler.tree.getSchema(bucket.dep);
|
|
97
97
|
const bucketName = name_helpers_1.NameHelpers.names(schema);
|
|
98
|
-
return bucketName.high;
|
|
98
|
+
return bucketName.high + (bucket.many ? '[]' : '');
|
|
99
99
|
});
|
|
100
100
|
const type = [
|
|
101
101
|
raw,
|
package/lib/compiler/index.d.ts
CHANGED
package/lib/compiler/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MonolythCompiler = exports.Compiler = void 0;
|
|
3
|
+
exports.DistributedCompiler = exports.MonolythCompiler = exports.Compiler = void 0;
|
|
4
4
|
var compiler_1 = require("./compiler");
|
|
5
5
|
Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return compiler_1.Compiler; } });
|
|
6
6
|
var monolyth_compiler_1 = require("./apps/monolyth/monolyth_compiler");
|
|
7
7
|
Object.defineProperty(exports, "MonolythCompiler", { enumerable: true, get: function () { return monolyth_compiler_1.MonolythCompiler; } });
|
|
8
|
+
var distributed_compiler_1 = require("./apps/distributed/distributed_compiler");
|
|
9
|
+
Object.defineProperty(exports, "DistributedCompiler", { enumerable: true, get: function () { return distributed_compiler_1.DistributedCompiler; } });
|
|
@@ -30,4 +30,5 @@ export declare abstract class BlockBuilder<Space extends $Space, Module extends
|
|
|
30
30
|
protected outputRaw(): unknown;
|
|
31
31
|
protected outputMsg(...msgs: string[]): unknown;
|
|
32
32
|
protected outputObj(...objs: string[]): unknown;
|
|
33
|
+
protected outputObjs(...objs: string[]): unknown;
|
|
33
34
|
}
|
|
@@ -79,7 +79,22 @@ class BlockBuilder {
|
|
|
79
79
|
this._output ?? (this._output = {});
|
|
80
80
|
(_a = this._output).obj ?? (_a.obj = []);
|
|
81
81
|
objs.forEach(obj => {
|
|
82
|
-
this._output?.obj?.push(
|
|
82
|
+
this._output?.obj?.push({
|
|
83
|
+
dep: new dependency_1.$Dependency(this.module, 'bucket', obj, true),
|
|
84
|
+
many: false
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
outputObjs(...objs) {
|
|
90
|
+
var _a;
|
|
91
|
+
this._output ?? (this._output = {});
|
|
92
|
+
(_a = this._output).obj ?? (_a.obj = []);
|
|
93
|
+
objs.forEach(obj => {
|
|
94
|
+
this._output?.obj?.push({
|
|
95
|
+
dep: new dependency_1.$Dependency(this.module, 'bucket', obj, true),
|
|
96
|
+
many: true
|
|
97
|
+
});
|
|
83
98
|
});
|
|
84
99
|
return this;
|
|
85
100
|
}
|
|
@@ -6,7 +6,10 @@ export type $BlockType = 'job' | 'resource' | 'machine' | 'queue' | 'topic';
|
|
|
6
6
|
export type $BlockOutput = {
|
|
7
7
|
raw?: TypeAsObj;
|
|
8
8
|
msg?: $Dependency[];
|
|
9
|
-
obj?:
|
|
9
|
+
obj?: {
|
|
10
|
+
dep: $Dependency;
|
|
11
|
+
many: boolean;
|
|
12
|
+
}[];
|
|
10
13
|
};
|
|
11
14
|
/**
|
|
12
15
|
* @category Schemas
|
|
@@ -30,7 +30,7 @@ class ResourceJob {
|
|
|
30
30
|
obj = await scope.execMethod({ ...$, obj, bucket: scope.bucket });
|
|
31
31
|
}
|
|
32
32
|
if (scope.afterMethod) {
|
|
33
|
-
|
|
33
|
+
await scope.afterMethod({ ...$, obj, bucket: scope.bucket });
|
|
34
34
|
}
|
|
35
35
|
return obj;
|
|
36
36
|
}
|
|
@@ -51,6 +51,7 @@ export declare class JobBuilder<Space extends $Space, Module extends $Module, Jo
|
|
|
51
51
|
obj: <BucketName extends keyof Module["buckets"], Bucket extends NoInfer<Module["buckets"][BucketName]>>(...objs: BucketName[]) => JobBuilder<Space, Module, Overlay<Job, {
|
|
52
52
|
"#output": unknown extends Job["#output"] ? Bucket["#data"] : (Job["#output"] | Bucket["#data"]);
|
|
53
53
|
}>, Ctx>;
|
|
54
|
+
objs: (...objs: string[]) => unknown;
|
|
54
55
|
};
|
|
55
56
|
protected outputRaw<T>(): JobBuilder<Space, Module, Overlay<Job, {
|
|
56
57
|
"#output": unknown extends Job["#output"] ? T : (Job["#output"] | T);
|
|
@@ -41,7 +41,8 @@ class JobBuilder extends block_builder_1.BlockBuilder {
|
|
|
41
41
|
return {
|
|
42
42
|
raw: this.outputRaw.bind(this),
|
|
43
43
|
msg: this.outputMsg.bind(this),
|
|
44
|
-
obj: this.outputObj.bind(this)
|
|
44
|
+
obj: this.outputObj.bind(this),
|
|
45
|
+
objs: this.outputObjs.bind(this)
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
outputRaw() {
|
|
@@ -63,7 +63,7 @@ class ResourceBuilder extends block_builder_1.BlockBuilder {
|
|
|
63
63
|
const jobBuilder = new resource_job_builder_1.ResourceJobBuilder(this.module, name, this._bucket.refName, 'query', alias, resource_1.Resource.query, this._authn)
|
|
64
64
|
.input($ => ({
|
|
65
65
|
view: $.enum(views).default(views[0]),
|
|
66
|
-
query: $.dict($.any).default({}),
|
|
66
|
+
query: $.dict($.any.optional).default({}),
|
|
67
67
|
page: $.int.default(0),
|
|
68
68
|
perPage: $.int.default(10)
|
|
69
69
|
}))
|
|
@@ -136,10 +136,10 @@ export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
|
136
136
|
/**
|
|
137
137
|
* Return the results of a query
|
|
138
138
|
*/
|
|
139
|
-
query<MetadataOnly extends boolean>(trx: AnyTrxNode, query: NQL_AnyQuery, pagination?: NQL_Pagination, params?: Record<string, any
|
|
139
|
+
query<MetadataOnly extends boolean>(trx: AnyTrxNode, query: NQL_AnyQuery, pagination?: NQL_Pagination, params?: Record<string, any>[], config?: {
|
|
140
140
|
view?: string;
|
|
141
141
|
metadataOnly?: MetadataOnly;
|
|
142
|
-
}): Promise<NQL_Result<MetadataOnly extends true ? {
|
|
142
|
+
}, runner?: NQLRunner): Promise<NQL_Result<MetadataOnly extends true ? {
|
|
143
143
|
id: Obj['id'];
|
|
144
144
|
[x: string]: any;
|
|
145
145
|
} : Obj>>;
|
|
@@ -25,14 +25,14 @@ class BucketAdapter {
|
|
|
25
25
|
/**
|
|
26
26
|
* Return the results of a query
|
|
27
27
|
*/
|
|
28
|
-
async query(trx, query, pagination, params, config) {
|
|
28
|
+
async query(trx, query, pagination, params, config, runner) {
|
|
29
29
|
const module = trx_node_1.TrxNode.getModule(trx);
|
|
30
30
|
const refName = (module.name === this.schema.module
|
|
31
31
|
? '' : `${this.schema.module}::`)
|
|
32
32
|
+ this.schema.name;
|
|
33
33
|
const compiled = await nql_compiler_1.NQL_Compiler.build(module, refName, query);
|
|
34
34
|
const view = config?.view ? this.schema.views[config.view] : undefined;
|
|
35
|
-
const result = await module.nql.run(trx, compiled, pagination, params, view);
|
|
35
|
+
const result = await module.nql.run(trx, compiled, pagination, params, view, runner);
|
|
36
36
|
if (config?.metadataOnly) {
|
|
37
37
|
result.data = result.data.map(obj => ({
|
|
38
38
|
id: obj.id,
|
|
@@ -10,7 +10,7 @@ export declare class MemoryNQLRunner extends NQLRunner {
|
|
|
10
10
|
protected adapter?: AnyMemoryBucketAdapter;
|
|
11
11
|
constructor();
|
|
12
12
|
bind(adapter: AnyMemoryBucketAdapter): void;
|
|
13
|
-
run(trx: AnyTrxNode, part: NQL_Part, params: Obj, pagination?: NQL_Pagination): Promise<{
|
|
13
|
+
run(trx: AnyTrxNode, part: NQL_Part, params: Obj[], pagination?: NQL_Pagination): Promise<{
|
|
14
14
|
data: any[];
|
|
15
15
|
totalItems: number | undefined;
|
|
16
16
|
page: number | undefined;
|
|
@@ -21,7 +21,7 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
21
21
|
let response;
|
|
22
22
|
// Empty query, don't filter data
|
|
23
23
|
if (part.union.inters.length === 0) {
|
|
24
|
-
response = data;
|
|
24
|
+
response = { ...data };
|
|
25
25
|
}
|
|
26
26
|
// Non-empty query
|
|
27
27
|
else {
|
|
@@ -105,7 +105,7 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
105
105
|
for (const rule of inter.rules) {
|
|
106
106
|
// <Union>
|
|
107
107
|
if ('inters' in rule) {
|
|
108
|
-
if (!_union(rule, objs,
|
|
108
|
+
if (!_union(rule, objs, params))
|
|
109
109
|
return false;
|
|
110
110
|
}
|
|
111
111
|
// <Rule>
|
|
@@ -132,8 +132,12 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
134
|
const obj = objs[id];
|
|
135
|
-
let match =
|
|
136
|
-
|
|
135
|
+
let match = false;
|
|
136
|
+
for (const paramGroup of params) {
|
|
137
|
+
match = _obj(rule, obj, paramGroup);
|
|
138
|
+
if (match)
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
137
141
|
if (rule.not) {
|
|
138
142
|
match = !match;
|
|
139
143
|
}
|
|
@@ -174,7 +178,7 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
174
178
|
let queryValue;
|
|
175
179
|
// Value is a subquery, run union
|
|
176
180
|
if ('subquery' in rule.value) {
|
|
177
|
-
const subOut = _union(rule.value.subquery.union, objs, params);
|
|
181
|
+
const subOut = _union(rule.value.subquery.union, objs, [params]);
|
|
178
182
|
const subList = Object.values(subOut);
|
|
179
183
|
// Subquery operator is for a list, filter
|
|
180
184
|
if (rule.op === 'in' || rule.op === 'contains_any') {
|
|
@@ -85,7 +85,7 @@ export declare class Bucket<M extends $Module, $ extends $Bucket> {
|
|
|
85
85
|
no_tenancy: boolean;
|
|
86
86
|
}): Promise<Obj[]>;
|
|
87
87
|
/**
|
|
88
|
-
* Read raw entity of a graph link
|
|
88
|
+
* Read raw entity of a graph link for 1 object
|
|
89
89
|
*
|
|
90
90
|
* - Options:
|
|
91
91
|
* - `silent`: If not found, return `undefined` instead of throwing an exception
|
|
@@ -95,6 +95,17 @@ export declare class Bucket<M extends $Module, $ extends $Bucket> {
|
|
|
95
95
|
silent?: boolean;
|
|
96
96
|
no_tenancy?: boolean;
|
|
97
97
|
}): Promise<Link['#many'] extends true ? Obj[] : (Obj | undefined)>;
|
|
98
|
+
/**
|
|
99
|
+
* Read raw entities of a graph link for N objects
|
|
100
|
+
*
|
|
101
|
+
* - Options:
|
|
102
|
+
* - `silent`: If not found, return `undefined` instead of throwing an exception
|
|
103
|
+
* - `no_tenancy`: Don't apply tenancy rules.
|
|
104
|
+
*/
|
|
105
|
+
readManyLinks<LinkName extends keyof $['graph']['links'], Link extends $['graph']['links'][LinkName], LinkBucket extends Link['#bucket'], V extends ViewName<LinkBucket>, Obj extends ViewObj<LinkBucket, V>>(trx: AnyTrxNode, ids: $['#data']['id'][], link: LinkName, options?: {
|
|
106
|
+
silent?: boolean;
|
|
107
|
+
no_tenancy?: boolean;
|
|
108
|
+
}): Promise<Link['#many'] extends true ? Obj[] : (Obj | undefined)>;
|
|
98
109
|
/**
|
|
99
110
|
* Read the view of an entity of a graph link
|
|
100
111
|
*
|
|
@@ -190,7 +201,7 @@ export declare class Bucket<M extends $Module, $ extends $Bucket> {
|
|
|
190
201
|
*/
|
|
191
202
|
query<V extends ViewName<$>, Obj extends ViewObj<$, V>>(trx: AnyTrxNode, query: NQL_AnyQuery, pagination?: NQL_Pagination, view?: V, options?: {
|
|
192
203
|
no_tenancy?: boolean;
|
|
193
|
-
params?: Record<string, any
|
|
204
|
+
params?: Record<string, any>[];
|
|
194
205
|
}): Promise<NQL_Result<Obj>>;
|
|
195
206
|
/**
|
|
196
207
|
* Add `created_by`, `created_at`, `updated_by` and `updated_at` fields to object
|
|
@@ -120,7 +120,7 @@ class Bucket {
|
|
|
120
120
|
let raws;
|
|
121
121
|
// With Tenancy
|
|
122
122
|
if (tenancy) {
|
|
123
|
-
const result = await this.adapter.query(trx, tenancy, undefined, options?.query_view ? { view: options?.query_view } : undefined);
|
|
123
|
+
const result = await this.adapter.query(trx, tenancy, undefined, options?.query_view ? [{ view: options?.query_view }] : undefined);
|
|
124
124
|
raws = result.data;
|
|
125
125
|
}
|
|
126
126
|
// Without Tenancy
|
|
@@ -169,7 +169,7 @@ class Bucket {
|
|
|
169
169
|
}
|
|
170
170
|
// Graph
|
|
171
171
|
/**
|
|
172
|
-
* Read raw entity of a graph link
|
|
172
|
+
* Read raw entity of a graph link for 1 object
|
|
173
173
|
*
|
|
174
174
|
* - Options:
|
|
175
175
|
* - `silent`: If not found, return `undefined` instead of throwing an exception
|
|
@@ -201,6 +201,44 @@ class Bucket {
|
|
|
201
201
|
}
|
|
202
202
|
return linkObj;
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Read raw entities of a graph link for N objects
|
|
206
|
+
*
|
|
207
|
+
* - Options:
|
|
208
|
+
* - `silent`: If not found, return `undefined` instead of throwing an exception
|
|
209
|
+
* - `no_tenancy`: Don't apply tenancy rules.
|
|
210
|
+
*/
|
|
211
|
+
async readManyLinks(trx, ids, link, options) {
|
|
212
|
+
log_1.Log.debug('bucket', this.schema.name, `Read Link, ids=${ids} l=${link}`);
|
|
213
|
+
// Validate IDs
|
|
214
|
+
for (const id of ids) {
|
|
215
|
+
if (typeof id !== 'string' && typeof id !== 'number') {
|
|
216
|
+
throw error_1.NesoiError.Bucket.InvalidId({ bucket: this.schema.alias, id });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Read object
|
|
220
|
+
const objs = await this.query(trx, {
|
|
221
|
+
'id in': ids
|
|
222
|
+
}).then(res => res.data);
|
|
223
|
+
// Empty response
|
|
224
|
+
if (!objs.length) {
|
|
225
|
+
const schema = this.schema.graph.links[link];
|
|
226
|
+
if (schema.many) {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
// Read link
|
|
232
|
+
const linkObj = await this.graph.readManyLinks(trx, objs, link, options);
|
|
233
|
+
// TODO
|
|
234
|
+
// // Encryption
|
|
235
|
+
// if (linkObj) {
|
|
236
|
+
// if (this.schema.model.hasEncryptedField) {
|
|
237
|
+
// await this.decrypt(trx, linkObj);
|
|
238
|
+
// }
|
|
239
|
+
// }
|
|
240
|
+
return linkObj;
|
|
241
|
+
}
|
|
204
242
|
/**
|
|
205
243
|
* Read the view of an entity of a graph link
|
|
206
244
|
*
|
|
@@ -455,7 +493,7 @@ class Bucket {
|
|
|
455
493
|
var _a, _b;
|
|
456
494
|
log_1.Log.debug('bucket', this.schema.name, `Put id=${obj['id']}`, obj);
|
|
457
495
|
// Separate composition
|
|
458
|
-
|
|
496
|
+
let composition = obj['#composition'];
|
|
459
497
|
delete obj['#composition'];
|
|
460
498
|
// Add meta (created_by/created_at/updated_by/updated_at)
|
|
461
499
|
this.addMeta(trx, obj, 'create');
|
|
@@ -470,6 +508,12 @@ class Bucket {
|
|
|
470
508
|
// Put
|
|
471
509
|
const _obj = await this.adapter.put(trx, obj);
|
|
472
510
|
// Composition
|
|
511
|
+
if (composition) {
|
|
512
|
+
this.replaceFutureId(composition, _obj.id);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
composition = {};
|
|
516
|
+
}
|
|
473
517
|
for (const link of Object.values(this.schema.graph.links)) {
|
|
474
518
|
if (link.rel !== 'composition')
|
|
475
519
|
continue;
|
|
@@ -22,6 +22,17 @@ export declare class BucketGraph<M extends $Module, $ extends $Bucket> {
|
|
|
22
22
|
silent?: boolean;
|
|
23
23
|
no_tenancy?: boolean;
|
|
24
24
|
}): Promise<Obj | Obj[] | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Read the data from a link
|
|
27
|
+
*
|
|
28
|
+
* - Options
|
|
29
|
+
* - `silent`: If not found, returns undefined instead of raising an exception (default: `false`)
|
|
30
|
+
* - `no_tenancy`: Don't apply tenancy rules (default: `false`)
|
|
31
|
+
*/
|
|
32
|
+
readManyLinks<LinkName extends keyof $['graph']['links'], LinkBucketName extends $['graph']['links'][LinkName]['bucket']['refName'], LinkBucket extends M['buckets'][LinkBucketName], Obj = LinkBucket['#data']>(trx: AnyTrxNode, objs: $['#data'][], link: LinkName, options?: {
|
|
33
|
+
silent?: boolean;
|
|
34
|
+
no_tenancy?: boolean;
|
|
35
|
+
}): Promise<Obj[] | Obj[][]>;
|
|
25
36
|
/**
|
|
26
37
|
* Read the data from a link and build it with a given view
|
|
27
38
|
*
|