nesoi 3.0.9 → 3.0.11
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/monolyth/monolyth_compiler.d.ts +1 -1
- package/lib/compiler/apps/monolyth/monolyth_compiler.js +7 -7
- package/lib/elements/blocks/block.builder.js +1 -1
- package/lib/elements/blocks/job/job.builder.js +3 -2
- package/lib/elements/blocks/machine/machine.builder.js +12 -1
- package/lib/elements/blocks/machine/machine.schema.d.ts +2 -1
- package/lib/elements/blocks/machine/machine.schema.js +2 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +3 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.js +2 -1
- package/lib/elements/edge/controller/controller.config.d.ts +3 -2
- package/lib/elements/edge/controller/controller.d.ts +3 -3
- package/lib/elements/edge/controller/controller.js +3 -3
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +2 -1
- package/lib/elements/entities/bucket/bucket.config.d.ts +3 -3
- package/lib/elements/entities/bucket/bucket.d.ts +3 -2
- package/lib/elements/entities/bucket/bucket.js +4 -4
- package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +1 -1
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +4 -0
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +3 -0
- package/lib/elements/entities/bucket/query/nql_compiler.js +2 -1
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +6 -0
- package/lib/elements/entities/message/template/message_template_field.builder.js +3 -0
- package/lib/elements/entities/message/template/message_template_parser.js +5 -0
- package/lib/engine/apps/app.config.d.ts +12 -11
- package/lib/engine/apps/app.d.ts +11 -22
- package/lib/engine/apps/app.js +9 -9
- package/lib/engine/apps/inline.app.d.ts +9 -8
- package/lib/engine/apps/inline.app.js +24 -24
- package/lib/engine/apps/monolyth/monolyth.app.d.ts +5 -5
- package/lib/engine/apps/monolyth/monolyth.app.js +6 -6
- package/lib/engine/apps/service.d.ts +30 -0
- package/lib/engine/apps/service.js +15 -0
- package/lib/engine/auth/authn.d.ts +10 -1
- package/lib/engine/auth/zero.authn_provider.d.ts +7 -3
- package/lib/engine/auth/zero.authn_provider.js +9 -2
- package/lib/engine/cli/cli.d.ts +2 -2
- package/lib/engine/cli/cli.js +1 -1
- package/lib/engine/cli/ui.js +1 -1
- package/lib/engine/daemon.d.ts +12 -12
- package/lib/engine/daemon.js +18 -18
- package/lib/engine/data/duration.d.ts +53 -0
- package/lib/engine/data/duration.js +62 -0
- package/lib/engine/data/error.d.ts +7 -0
- package/lib/engine/data/error.js +9 -1
- package/lib/engine/dependency.d.ts +2 -1
- package/lib/engine/dependency.js +18 -0
- package/lib/engine/module.d.ts +6 -4
- package/lib/engine/module.js +25 -10
- package/lib/engine/transaction/nodes/bucket.trx_node.js +1 -2
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +5 -10
- package/lib/engine/transaction/nodes/job.trx_node.js +2 -4
- package/lib/engine/transaction/nodes/machine.trx_node.js +2 -4
- package/lib/engine/transaction/nodes/queue.trx_node.js +1 -2
- package/lib/engine/transaction/nodes/resource.trx_node.js +2 -4
- package/lib/engine/transaction/trx.d.ts +6 -4
- package/lib/engine/transaction/trx.js +2 -1
- package/lib/engine/transaction/trx_engine.config.d.ts +2 -2
- package/lib/engine/transaction/trx_engine.d.ts +4 -3
- package/lib/engine/transaction/trx_engine.js +20 -17
- package/lib/engine/transaction/trx_node.d.ts +4 -2
- package/lib/engine/transaction/trx_node.js +13 -1
- package/lib/engine/tree.js +6 -17
- package/lib/engine/util/i18n.js +3 -3
- package/lib/engine/util/parse.d.ts +5 -0
- package/lib/engine/util/parse.js +10 -0
- package/lib/schema.d.ts +1 -1
- package/package.json +2 -3
- package/tools/joaquin/job.js +2 -2
- package/tools/joaquin/message.js +2 -2
- package/tools/joaquin/mock.d.ts +6 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/adapters/postgres/src/migrator/csv.d.ts +0 -7
- package/lib/adapters/postgres/src/migrator/csv.js +0 -72
- package/lib/adapters/postgres/src/migrator/database.d.ts +0 -34
- package/lib/adapters/postgres/src/migrator/database.js +0 -88
- package/lib/adapters/postgres/src/migrator/generator/generator.d.ts +0 -22
- package/lib/adapters/postgres/src/migrator/generator/generator.js +0 -326
- package/lib/adapters/postgres/src/migrator/generator/migration.d.ts +0 -66
- package/lib/adapters/postgres/src/migrator/generator/migration.js +0 -249
- package/lib/adapters/postgres/src/migrator/generator/provider.d.ts +0 -19
- package/lib/adapters/postgres/src/migrator/generator/provider.js +0 -74
- package/lib/adapters/postgres/src/migrator/index.d.ts +0 -47
- package/lib/adapters/postgres/src/migrator/index.js +0 -22
- package/lib/adapters/postgres/src/migrator/runner/runner.d.ts +0 -17
- package/lib/adapters/postgres/src/migrator/runner/runner.js +0 -249
- package/lib/adapters/postgres/src/migrator/runner/status.d.ts +0 -17
- package/lib/adapters/postgres/src/migrator/runner/status.js +0 -55
- package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +0 -42
- package/lib/adapters/postgres/src/postgres.bucket_adapter.js +0 -294
- package/lib/adapters/postgres/src/postgres.cli.d.ts +0 -76
- package/lib/adapters/postgres/src/postgres.cli.js +0 -207
- package/lib/adapters/postgres/src/postgres.config.d.ts +0 -5
- package/lib/adapters/postgres/src/postgres.config.js +0 -2
- package/lib/adapters/postgres/src/postgres.nql.d.ts +0 -16
- package/lib/adapters/postgres/src/postgres.nql.js +0 -123
- package/lib/adapters/postgres/src/postgres.provider.d.ts +0 -18
- package/lib/adapters/postgres/src/postgres.provider.js +0 -77
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.d.ts +0 -1
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +0 -210
|
@@ -18,7 +18,7 @@ export declare class MonolythCompiler {
|
|
|
18
18
|
};
|
|
19
19
|
constructor(compiler: Compiler, appPath: string, config?: MonolythCompilerConfig);
|
|
20
20
|
run(): Promise<void>;
|
|
21
|
-
|
|
21
|
+
mergeServicePaths(app: AnyApp): void;
|
|
22
22
|
expandLibPaths(): void;
|
|
23
23
|
static scanAll(dir: string): Promise<MonolythApp<any, any, Record<string, any>>[] | undefined>;
|
|
24
24
|
}
|
|
@@ -64,7 +64,7 @@ class MonolythCompiler {
|
|
|
64
64
|
const appFile = space_1.Space.path(this.compiler.space, this.appPath);
|
|
65
65
|
const app = (await Promise.resolve(`${appFile}`).then(s => __importStar(require(s)))).default;
|
|
66
66
|
this.config = Object.assign({}, app_1.App.getInfo(app).config?.compiler || {}, this.config);
|
|
67
|
-
this.
|
|
67
|
+
this.mergeServicePaths(app);
|
|
68
68
|
this.expandLibPaths();
|
|
69
69
|
try {
|
|
70
70
|
await new _1_mkdir_stage_1.MkdirStage(this, app).run();
|
|
@@ -79,15 +79,15 @@ class MonolythCompiler {
|
|
|
79
79
|
process.exit();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
mergeServicePaths(app) {
|
|
83
83
|
var _a;
|
|
84
|
-
const
|
|
85
|
-
for (const name in
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
84
|
+
const services = app_1.App.getServices(app);
|
|
85
|
+
for (const name in services) {
|
|
86
|
+
const service = services[name];
|
|
87
|
+
if (!service.libPaths)
|
|
88
88
|
continue;
|
|
89
89
|
(_a = this.config).libPaths ?? (_a.libPaths = []);
|
|
90
|
-
this.config.libPaths.push(...
|
|
90
|
+
this.config.libPaths.push(...service.libPaths);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
expandLibPaths() {
|
|
@@ -76,7 +76,7 @@ class BlockBuilder {
|
|
|
76
76
|
this._output ?? (this._output = {});
|
|
77
77
|
(_a = this._output).msg ?? (_a.msg = []);
|
|
78
78
|
msgs.forEach(msg => {
|
|
79
|
-
this._output
|
|
79
|
+
this._output.msg.push(new dependency_1.$Dependency(this.module, 'message', msg, true));
|
|
80
80
|
});
|
|
81
81
|
return this;
|
|
82
82
|
}
|
|
@@ -8,6 +8,7 @@ const message_builder_1 = require("../../entities/message/message.builder");
|
|
|
8
8
|
const resource_job_builder_1 = require("./internal/resource_job.builder");
|
|
9
9
|
const machine_job_builder_1 = require("./internal/machine_job.builder");
|
|
10
10
|
const error_1 = require("../../../engine/data/error");
|
|
11
|
+
const name_helpers_1 = require("../../../compiler/helpers/name_helpers");
|
|
11
12
|
/**
|
|
12
13
|
* @category Builders
|
|
13
14
|
* @subcategory Block
|
|
@@ -48,11 +49,11 @@ class JobBuilder extends block_builder_1.BlockBuilder {
|
|
|
48
49
|
return this;
|
|
49
50
|
}
|
|
50
51
|
outputMsg(...msgs) {
|
|
51
|
-
super.outputMsg();
|
|
52
|
+
super.outputMsg(...msgs.map(msg => name_helpers_1.NameHelpers.unabbrevName(msg, this.name)));
|
|
52
53
|
return this;
|
|
53
54
|
}
|
|
54
55
|
outputObj(...objs) {
|
|
55
|
-
super.outputObj();
|
|
56
|
+
super.outputObj(...objs.map(obj => name_helpers_1.NameHelpers.unabbrevName(obj, this.name)));
|
|
56
57
|
return this;
|
|
57
58
|
}
|
|
58
59
|
/*
|
|
@@ -86,7 +86,18 @@ class MachineBuilder extends block_builder_1.BlockBuilder {
|
|
|
86
86
|
const input = Object.values(states)
|
|
87
87
|
.map(state => state.input)
|
|
88
88
|
.flat(1);
|
|
89
|
-
|
|
89
|
+
const jobs = [];
|
|
90
|
+
Object.values(states).forEach(state => {
|
|
91
|
+
jobs.push(...Object.values(state.jobs));
|
|
92
|
+
});
|
|
93
|
+
Object.values(transitions.from).forEach(stateTransitions => {
|
|
94
|
+
Object.values(stateTransitions).forEach(transitionList => {
|
|
95
|
+
transitionList.forEach(trans => {
|
|
96
|
+
jobs.push(...trans.jobs);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
node.schema = new machine_schema_1.$Machine(node.builder.module, node.builder.name, node.builder._alias || node.builder.name, node.builder._authn, input, node.builder._buckets, jobs, node.builder._stateField || 'state', states, transitions, node.builder._stateAliasField, node.builder._logger);
|
|
90
101
|
// Configure state jobs with proper input, based on transition targets
|
|
91
102
|
const inlineJobsConfig = {};
|
|
92
103
|
Object.values(states).forEach(state => {
|
|
@@ -75,6 +75,7 @@ export declare class $Machine extends $Block {
|
|
|
75
75
|
authn: string[];
|
|
76
76
|
input: $Dependency[];
|
|
77
77
|
buckets: $Dependency[];
|
|
78
|
+
jobs: $Dependency[];
|
|
78
79
|
stateField: string;
|
|
79
80
|
states: $MachineStates;
|
|
80
81
|
transitions: $MachineTransitions;
|
|
@@ -82,7 +83,7 @@ export declare class $Machine extends $Block {
|
|
|
82
83
|
logger?: $MachineLogFn<any> | undefined;
|
|
83
84
|
$t: "machine";
|
|
84
85
|
'#data': unknown;
|
|
85
|
-
constructor(module: string, name: string, alias: string, authn: string[], input: $Dependency[], buckets: $Dependency[], stateField: string, states: $MachineStates, transitions: $MachineTransitions, stateAliasField?: string | undefined, logger?: $MachineLogFn<any> | undefined);
|
|
86
|
+
constructor(module: string, name: string, alias: string, authn: string[], input: $Dependency[], buckets: $Dependency[], jobs: $Dependency[], stateField: string, states: $MachineStates, transitions: $MachineTransitions, stateAliasField?: string | undefined, logger?: $MachineLogFn<any> | undefined);
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
89
|
* @category Schemas
|
|
@@ -49,7 +49,7 @@ exports.$MachineState = $MachineState;
|
|
|
49
49
|
* @subcategory Block
|
|
50
50
|
*/
|
|
51
51
|
class $Machine extends block_schema_1.$Block {
|
|
52
|
-
constructor(module, name, alias, authn, input, buckets, stateField, states, transitions, stateAliasField, logger) {
|
|
52
|
+
constructor(module, name, alias, authn, input, buckets, jobs, stateField, states, transitions, stateAliasField, logger) {
|
|
53
53
|
super(module, name, alias, authn, input, {});
|
|
54
54
|
this.module = module;
|
|
55
55
|
this.name = name;
|
|
@@ -57,6 +57,7 @@ class $Machine extends block_schema_1.$Block {
|
|
|
57
57
|
this.authn = authn;
|
|
58
58
|
this.input = input;
|
|
59
59
|
this.buckets = buckets;
|
|
60
|
+
this.jobs = jobs;
|
|
60
61
|
this.stateField = stateField;
|
|
61
62
|
this.states = states;
|
|
62
63
|
this.transitions = transitions;
|
|
@@ -2,15 +2,17 @@ import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
|
2
2
|
import { $Controller, $ControllerDomain, $ControllerEndpoint, $ControllerGroup } from '../controller.schema';
|
|
3
3
|
import { AnyDaemon } from "../../../../engine/daemon";
|
|
4
4
|
import { AuthnRequest } from "../../../../engine/auth/authn";
|
|
5
|
+
import { $Module } from "../../..";
|
|
5
6
|
export type ControllerEndpointPath = ($ControllerDomain | $ControllerGroup | $ControllerEndpoint)[];
|
|
6
7
|
/**
|
|
7
8
|
* @category Adapters
|
|
8
9
|
* @subcategory Edge
|
|
9
10
|
*/
|
|
10
11
|
export declare abstract class ControllerAdapter {
|
|
12
|
+
protected module: $Module;
|
|
11
13
|
protected schema: $Controller;
|
|
12
14
|
protected daemon?: AnyDaemon;
|
|
13
|
-
constructor(schema: $Controller);
|
|
15
|
+
constructor(module: $Module, schema: $Controller);
|
|
14
16
|
trx(fn: (trx: AnyTrxNode) => Promise<any>, authn?: AuthnRequest<any>): Promise<import("../../../../engine/transaction/trx").TrxStatus<any>>;
|
|
15
17
|
bind(daemon: AnyDaemon): void;
|
|
16
18
|
protected abstract makeEndpoint(path: string, schema: $ControllerEndpoint): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { $Module } from "../..";
|
|
1
2
|
import { ControllerAdapter } from './adapters/controller_adapter';
|
|
2
3
|
import { $Controller } from './controller.schema';
|
|
3
|
-
export type ControllerConfig<B extends $Controller,
|
|
4
|
+
export type ControllerConfig<M extends $Module, B extends $Controller, Services extends Record<string, any>> = {
|
|
4
5
|
/** Adapter used by this Controller to communicate with a data source */
|
|
5
|
-
adapter?: (schema: B,
|
|
6
|
+
adapter?: (module: M, schema: B, services: Services) => ControllerAdapter;
|
|
6
7
|
};
|
|
@@ -18,10 +18,10 @@ export declare class ControllerEndpoint<$ extends $ControllerEndpoint> {
|
|
|
18
18
|
}
|
|
19
19
|
export declare class Controller<S extends $Space, M extends $Module, $ extends $Controller> {
|
|
20
20
|
schema: $;
|
|
21
|
-
config?: ControllerConfig
|
|
22
|
-
|
|
21
|
+
config?: ControllerConfig<M, $, any> | undefined;
|
|
22
|
+
services: Record<string, any>;
|
|
23
23
|
adapter: ControllerAdapter;
|
|
24
|
-
constructor(module: Module<S, M>, schema: $, config?: ControllerConfig
|
|
24
|
+
constructor(module: Module<S, M>, schema: $, config?: ControllerConfig<M, $, any> | undefined, services?: Record<string, any>);
|
|
25
25
|
bind(daemon: AnyDaemon): void;
|
|
26
26
|
}
|
|
27
27
|
export type AnyController = Controller<any, any, any>;
|
|
@@ -34,11 +34,11 @@ class ControllerEndpoint {
|
|
|
34
34
|
}
|
|
35
35
|
exports.ControllerEndpoint = ControllerEndpoint;
|
|
36
36
|
class Controller {
|
|
37
|
-
constructor(module, schema, config,
|
|
37
|
+
constructor(module, schema, config, services = {}) {
|
|
38
38
|
this.schema = schema;
|
|
39
39
|
this.config = config;
|
|
40
|
-
this.
|
|
41
|
-
this.adapter = config?.adapter?.(schema,
|
|
40
|
+
this.services = services;
|
|
41
|
+
this.adapter = config?.adapter?.(module.schema, schema, services) || new cli_controller_adapter_1.CLIControllerAdapter(module.schema, schema);
|
|
42
42
|
}
|
|
43
43
|
bind(daemon) {
|
|
44
44
|
this.adapter.bind(daemon);
|
|
@@ -28,7 +28,8 @@ export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
|
28
28
|
*/
|
|
29
29
|
protected abstract deleteEverything(trx: AnyTrxNode): Promise<void>;
|
|
30
30
|
/**
|
|
31
|
-
* Return one entity by ID
|
|
31
|
+
* Return one entity by ID.
|
|
32
|
+
* - This method MUST NOT throw an exception if not found. The exception is thrown by Nesoi.
|
|
32
33
|
*/
|
|
33
34
|
abstract get(trx: AnyTrxNode, id: Obj['id']): Promise<undefined | Obj>;
|
|
34
35
|
/**
|
|
@@ -2,11 +2,11 @@ import { $Module } from "../..";
|
|
|
2
2
|
import { BucketAdapter } from './adapters/bucket_adapter';
|
|
3
3
|
import { $Bucket } from './bucket.schema';
|
|
4
4
|
import { DriveAdapter } from '../drive/drive_adapter';
|
|
5
|
-
export type BucketConfig<M extends $Module, B extends $Bucket,
|
|
5
|
+
export type BucketConfig<M extends $Module, B extends $Bucket, Services extends Record<string, any>> = {
|
|
6
6
|
/** Adapter used by this bucket to communicate with a data source */
|
|
7
|
-
adapter?: (schema: B,
|
|
7
|
+
adapter?: (schema: B, services: Services) => BucketAdapter<B['#data']>;
|
|
8
8
|
/** Drive Adapter used by this bucket to write/read files */
|
|
9
|
-
drive?: (schema: B,
|
|
9
|
+
drive?: (schema: B, services: Services) => DriveAdapter;
|
|
10
10
|
/** Settings for the app cache of this bucket */
|
|
11
11
|
cache?: {
|
|
12
12
|
/** Inner adapter used by the cache to manage cache entry data */
|
|
@@ -10,6 +10,7 @@ import { CreateObj, PatchObj, PutObj } from './bucket.types';
|
|
|
10
10
|
import { NQL_Result } from './query/nql_engine';
|
|
11
11
|
import { $BucketModelFields } from './model/bucket_model.schema';
|
|
12
12
|
import { DriveAdapter } from '../drive/drive_adapter';
|
|
13
|
+
import { IService } from "../../../engine/apps/service";
|
|
13
14
|
/**
|
|
14
15
|
* **This should only be used inside a `#composition` of a bucket `create`** to refer to the parent id, which doesn't exist yet.
|
|
15
16
|
*
|
|
@@ -27,13 +28,13 @@ export declare const $id: string | number;
|
|
|
27
28
|
export declare class Bucket<M extends $Module, $ extends $Bucket> {
|
|
28
29
|
schema: $;
|
|
29
30
|
private config?;
|
|
30
|
-
|
|
31
|
+
services: Record<string, IService>;
|
|
31
32
|
adapter: BucketAdapter<$['#data']>;
|
|
32
33
|
private cache?;
|
|
33
34
|
graph: BucketGraph<M, $>;
|
|
34
35
|
private views;
|
|
35
36
|
drive?: DriveAdapter;
|
|
36
|
-
constructor(schema: $, config?: BucketConfig<any, any, any> | undefined,
|
|
37
|
+
constructor(schema: $, config?: BucketConfig<any, any, any> | undefined, services?: Record<string, IService>);
|
|
37
38
|
getQueryMeta(): {
|
|
38
39
|
bucket: $;
|
|
39
40
|
scope: string;
|
|
@@ -27,12 +27,12 @@ exports.$id = Symbol('FUTURE ID OF CREATE');
|
|
|
27
27
|
* @subcategory Entity
|
|
28
28
|
* */
|
|
29
29
|
class Bucket {
|
|
30
|
-
constructor(schema, config,
|
|
30
|
+
constructor(schema, config, services = {}) {
|
|
31
31
|
this.schema = schema;
|
|
32
32
|
this.config = config;
|
|
33
|
-
this.
|
|
33
|
+
this.services = services;
|
|
34
34
|
// Config
|
|
35
|
-
this.adapter = this.config?.adapter?.(schema,
|
|
35
|
+
this.adapter = this.config?.adapter?.(schema, services) || new memory_bucket_adapter_1.MemoryBucketAdapter(schema, {});
|
|
36
36
|
// Graph
|
|
37
37
|
this.graph = new bucket_graph_1.BucketGraph(this);
|
|
38
38
|
// Views
|
|
@@ -47,7 +47,7 @@ class Bucket {
|
|
|
47
47
|
}
|
|
48
48
|
// Drive
|
|
49
49
|
if (this.config?.drive) {
|
|
50
|
-
this.drive = this.config.drive(schema,
|
|
50
|
+
this.drive = this.config.drive(schema, services);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
// Getters
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $Dependency } from "../../../../engine/dependency";
|
|
2
|
-
export type $BucketModelFieldType = 'boolean' | 'date' | 'datetime' | 'decimal' | 'enum' | 'file' | 'float' | 'int' | 'string' | 'obj' | 'unknown' | 'dict';
|
|
2
|
+
export type $BucketModelFieldType = 'boolean' | 'date' | 'datetime' | 'duration' | 'decimal' | 'enum' | 'file' | 'float' | 'int' | 'string' | 'obj' | 'unknown' | 'dict';
|
|
3
3
|
export type $BucketModelFieldCrypto = {
|
|
4
4
|
algorithm: string;
|
|
5
5
|
key: string;
|
|
@@ -6,6 +6,7 @@ import { EnumFromName, EnumName } from '../../constants/constants.schema';
|
|
|
6
6
|
import { NesoiDecimal } from "../../../../engine/data/decimal";
|
|
7
7
|
import { NesoiDatetime } from "../../../../engine/data/datetime";
|
|
8
8
|
import { NesoiFile } from "../../../../engine/data/file";
|
|
9
|
+
import { NesoiDuration } from "../../../../engine/data/duration";
|
|
9
10
|
/**
|
|
10
11
|
* @category Builders
|
|
11
12
|
* @subcategory Entity
|
|
@@ -27,6 +28,9 @@ export declare class BucketModelFieldFactory<Space extends $Space, Module extend
|
|
|
27
28
|
get datetime(): BucketModelFieldBuilder<Module, NesoiDatetime, never, NesoiDatetime, {
|
|
28
29
|
'': NesoiDatetime;
|
|
29
30
|
}>;
|
|
31
|
+
get duration(): BucketModelFieldBuilder<Module, NesoiDuration, never, NesoiDuration, {
|
|
32
|
+
'': NesoiDuration;
|
|
33
|
+
}>;
|
|
30
34
|
decimal(def?: {
|
|
31
35
|
left?: number;
|
|
32
36
|
right?: number;
|
|
@@ -30,6 +30,9 @@ class BucketModelFieldFactory {
|
|
|
30
30
|
get datetime() {
|
|
31
31
|
return new BucketModelFieldBuilder(this.module, 'datetime', this.alias);
|
|
32
32
|
}
|
|
33
|
+
get duration() {
|
|
34
|
+
return new BucketModelFieldBuilder(this.module, 'duration', this.alias);
|
|
35
|
+
}
|
|
33
36
|
decimal(def) {
|
|
34
37
|
return new BucketModelFieldBuilder(this.module, 'decimal', this.alias, {
|
|
35
38
|
decimal: def
|
|
@@ -90,7 +90,7 @@ class NQL_RuleTree {
|
|
|
90
90
|
throw new Error(`Field '${by}' not found on bucket '${bucket.schema.name}'`);
|
|
91
91
|
}
|
|
92
92
|
if (![
|
|
93
|
-
'date', 'datetime', 'decimal', 'enum', 'float', 'int', 'string'
|
|
93
|
+
'date', 'datetime', 'duration', 'decimal', 'enum', 'float', 'int', 'string'
|
|
94
94
|
].includes(field.type)) {
|
|
95
95
|
throw new Error(`Field '${by}' is not sortable`);
|
|
96
96
|
}
|
|
@@ -431,6 +431,7 @@ NQL_RuleTree.OpByType = {
|
|
|
431
431
|
'boolean': ['==', 'in', 'present'],
|
|
432
432
|
'date': ['<', '<=', '==', '>', '>=', 'in', 'present'],
|
|
433
433
|
'datetime': ['<', '<=', '==', '>', '>=', 'in', 'present'],
|
|
434
|
+
'duration': ['<', '<=', '==', '>', '>=', 'in', 'present'],
|
|
434
435
|
'decimal': ['<', '<=', '==', '>', '>=', 'in', 'present'],
|
|
435
436
|
'dict': ['==', 'contains', 'contains_any', 'in', 'present'],
|
|
436
437
|
'enum': ['==', 'contains', 'contains_any', 'in', 'present'],
|
|
@@ -9,6 +9,7 @@ import { MessageEnumpath } from '../../constants/constants.schema';
|
|
|
9
9
|
import { NesoiDecimal } from "../../../../engine/data/decimal";
|
|
10
10
|
import { NesoiDatetime } from "../../../../engine/data/datetime";
|
|
11
11
|
import { NesoiFile } from "../../../../engine/data/file";
|
|
12
|
+
import { NesoiDuration } from "../../../../engine/data/duration";
|
|
12
13
|
/**
|
|
13
14
|
* @category Builders
|
|
14
15
|
* @subcategory Entity
|
|
@@ -38,6 +39,11 @@ export declare class MessageTemplateFieldFactory<Space extends $Space, Module ex
|
|
|
38
39
|
}, {
|
|
39
40
|
'': NesoiDatetime;
|
|
40
41
|
}, {}, [never, never], [never, never]>;
|
|
42
|
+
get duration(): MessageTemplateFieldBuilder<Module, Message, {
|
|
43
|
+
'': string;
|
|
44
|
+
}, {
|
|
45
|
+
'': NesoiDuration;
|
|
46
|
+
}, {}, [never, never], [never, never]>;
|
|
41
47
|
decimal(config?: $MessageTemplateFieldMeta['decimal']): MessageTemplateFieldBuilder<Module, Message, {
|
|
42
48
|
'': string;
|
|
43
49
|
}, {
|
|
@@ -28,6 +28,9 @@ class MessageTemplateFieldFactory {
|
|
|
28
28
|
get datetime() {
|
|
29
29
|
return new MessageTemplateFieldBuilder('datetime', {}, this.alias);
|
|
30
30
|
}
|
|
31
|
+
get duration() {
|
|
32
|
+
return new MessageTemplateFieldBuilder('duration', {}, this.alias);
|
|
33
|
+
}
|
|
31
34
|
decimal(config) {
|
|
32
35
|
return new MessageTemplateFieldBuilder('decimal', { decimal: config }, this.alias);
|
|
33
36
|
}
|
|
@@ -24,6 +24,11 @@ async function MessageTemplateFieldParser(raw, trx, field, value, parseFields) {
|
|
|
24
24
|
'': await (0, parse_1.parseDatetime)(field, value, field.array)
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
if (field.type === 'duration') {
|
|
28
|
+
return {
|
|
29
|
+
'': await (0, parse_1.parseDuration)(field, value, field.array)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
27
32
|
if (field.type === 'decimal') {
|
|
28
33
|
return {
|
|
29
34
|
'': await (0, parse_1.parseDecimal)(field, value, field.array)
|
|
@@ -5,6 +5,7 @@ import { ControllerConfig } from "../../elements/edge/controller/controller.conf
|
|
|
5
5
|
import { TrxEngineConfig } from '../transaction/trx_engine.config';
|
|
6
6
|
import { CompilerConfig } from "../../compiler/compiler";
|
|
7
7
|
import { App } from './app';
|
|
8
|
+
import { IService } from './service';
|
|
8
9
|
import { CLIConfig } from '../cli/cli';
|
|
9
10
|
import { BucketAdapter } from "../../elements/entities/bucket/adapters/bucket_adapter";
|
|
10
11
|
import { TrashObj } from '../data/trash';
|
|
@@ -27,9 +28,9 @@ export type AppI18nConfig = {
|
|
|
27
28
|
export type AppAuthnConfig<S extends $Space> = {
|
|
28
29
|
[K in keyof S['authnUsers']]: () => AuthnProvider<S['authnUsers'][K]>;
|
|
29
30
|
};
|
|
30
|
-
export type AppBucketConfig<S extends $Space, Modules extends ModuleName<S>,
|
|
31
|
+
export type AppBucketConfig<S extends $Space, Modules extends ModuleName<S>, Services extends Record<string, IService>> = Partial<{
|
|
31
32
|
[M in (Modules & keyof S['modules'])]: Partial<{
|
|
32
|
-
[K in keyof S['modules'][M]['buckets']]: BucketConfig<S['modules'][M], S['modules'][M]['buckets'][K],
|
|
33
|
+
[K in keyof S['modules'][M]['buckets']]: BucketConfig<S['modules'][M], S['modules'][M]['buckets'][K], Services>;
|
|
33
34
|
}>;
|
|
34
35
|
}>;
|
|
35
36
|
export type AppTrashConfig = {
|
|
@@ -37,13 +38,13 @@ export type AppTrashConfig = {
|
|
|
37
38
|
'#data': TrashObj;
|
|
38
39
|
}>) => BucketAdapter<TrashObj>;
|
|
39
40
|
};
|
|
40
|
-
export type AppControllerConfig<S extends $Space, Modules extends ModuleName<S>,
|
|
41
|
+
export type AppControllerConfig<S extends $Space, Modules extends ModuleName<S>, Services extends Record<string, IService>> = Partial<{
|
|
41
42
|
[M in (Modules & keyof S['modules'])]: Partial<{
|
|
42
|
-
[K in keyof S['modules'][M]['controllers']]: ControllerConfig<S['modules'][M]['controllers'][K],
|
|
43
|
+
[K in keyof S['modules'][M]['controllers']]: ControllerConfig<S['modules'][M], S['modules'][M]['controllers'][K], Services>;
|
|
43
44
|
}>;
|
|
44
45
|
}>;
|
|
45
|
-
export type AppTrxEngineConfig<S extends $Space, Modules extends ModuleName<S>,
|
|
46
|
-
[M in (Modules & keyof S['modules'])]: TrxEngineConfig<S, S['modules'][M], any,
|
|
46
|
+
export type AppTrxEngineConfig<S extends $Space, Modules extends ModuleName<S>, Services extends Record<string, IService>> = Partial<{
|
|
47
|
+
[M in (Modules & keyof S['modules'])]: TrxEngineConfig<S, S['modules'][M], any, Services>;
|
|
47
48
|
}>;
|
|
48
49
|
export type AppAuditConfig = {
|
|
49
50
|
adapter: ($: Overlay<$Bucket, {
|
|
@@ -57,17 +58,17 @@ export type AppAuditConfig = {
|
|
|
57
58
|
/**
|
|
58
59
|
* @category App
|
|
59
60
|
*/
|
|
60
|
-
export declare class AppConfigFactory<S extends $Space, Modules extends string = ModuleName<S> & string,
|
|
61
|
+
export declare class AppConfigFactory<S extends $Space, Modules extends string = ModuleName<S> & string, Services extends Record<string, any> = Record<string, any>, _App = App<S, Modules, Services>> {
|
|
61
62
|
private app;
|
|
62
63
|
private config;
|
|
63
64
|
constructor(app: _App);
|
|
64
65
|
i18n(config: AppI18nConfig): _App;
|
|
65
66
|
authn(config: AppAuthnConfig<S>): _App;
|
|
66
|
-
buckets(config: AppBucketConfig<S, Modules,
|
|
67
|
+
buckets(config: AppBucketConfig<S, Modules, Services>): _App;
|
|
67
68
|
trash(config: AppTrashConfig): _App;
|
|
68
|
-
controllers(config: AppControllerConfig<S, Modules,
|
|
69
|
+
controllers(config: AppControllerConfig<S, Modules, Services>): _App;
|
|
69
70
|
audit(config: AppI18nConfig): _App;
|
|
70
71
|
compiler(config: CompilerConfig): _App;
|
|
71
|
-
cli(config: CLIConfig<
|
|
72
|
-
trx(config: AppTrxEngineConfig<S, Modules,
|
|
72
|
+
cli(config: CLIConfig<Services>): _App;
|
|
73
|
+
trx(config: AppTrxEngineConfig<S, Modules, Services>): _App;
|
|
73
74
|
}
|
package/lib/engine/apps/app.d.ts
CHANGED
|
@@ -3,27 +3,16 @@ import { AnyBuilder, AnyModule } from '../module';
|
|
|
3
3
|
import { Space } from '../space';
|
|
4
4
|
import { Daemon } from '../daemon';
|
|
5
5
|
import { AnyAppConfig, AppConfigFactory } from './app.config';
|
|
6
|
-
|
|
7
|
-
* Provider
|
|
8
|
-
*/
|
|
9
|
-
export type AppProvider<out Name, T> = {
|
|
10
|
-
name: Name;
|
|
11
|
-
up: ($: {
|
|
12
|
-
modules: Record<string, AnyModule>;
|
|
13
|
-
}) => T;
|
|
14
|
-
down: (provider: NoInfer<T>) => any;
|
|
15
|
-
libPaths?: string[];
|
|
16
|
-
};
|
|
17
|
-
export type AnyAppProvider = AppProvider<any, any>;
|
|
6
|
+
import { IService } from './service';
|
|
18
7
|
/**
|
|
19
8
|
* @category App
|
|
20
9
|
*/
|
|
21
|
-
export declare abstract class App<S extends $Space, Modules extends string = ModuleName<S> & string,
|
|
10
|
+
export declare abstract class App<S extends $Space, Modules extends string = ModuleName<S> & string, Services extends Record<string, any> = Record<string, any>> {
|
|
22
11
|
name: string;
|
|
23
12
|
protected _config: AnyAppConfig;
|
|
24
13
|
protected _spaceModuleNames: ModuleName<S>[];
|
|
25
14
|
protected _injectedModules: AnyModule[];
|
|
26
|
-
protected
|
|
15
|
+
protected _services: Record<string, IService>;
|
|
27
16
|
protected space?: Space<S>;
|
|
28
17
|
protected builders?: AnyBuilder[];
|
|
29
18
|
constructor(name: string, boot?: {
|
|
@@ -37,7 +26,7 @@ export declare abstract class App<S extends $Space, Modules extends string = Mod
|
|
|
37
26
|
* This can be run without await before the daemon,
|
|
38
27
|
* to preload the module in background.
|
|
39
28
|
*/
|
|
40
|
-
abstract boot(): App<S, Modules,
|
|
29
|
+
abstract boot(): App<S, Modules, Services>;
|
|
41
30
|
/**
|
|
42
31
|
* Spawn a daemon for this app.
|
|
43
32
|
*/
|
|
@@ -48,7 +37,7 @@ export declare abstract class App<S extends $Space, Modules extends string = Mod
|
|
|
48
37
|
* ⚠ This has no effect on apps without a `Space`, such as `InlineApp`.
|
|
49
38
|
* @param modules A list of names of modules from the current `Space`.
|
|
50
39
|
*/
|
|
51
|
-
modules<M extends ModuleName<S>>(modules: M[]): App<S, M & Modules,
|
|
40
|
+
modules<M extends ModuleName<S>>(modules: M[]): App<S, M & Modules, Services>;
|
|
52
41
|
/**
|
|
53
42
|
* Injects pre-built modules into this App.
|
|
54
43
|
* These will be included on the Daemon once it starts.
|
|
@@ -57,16 +46,16 @@ export declare abstract class App<S extends $Space, Modules extends string = Mod
|
|
|
57
46
|
*/
|
|
58
47
|
inject(modules: AnyModule[]): this;
|
|
59
48
|
/**
|
|
60
|
-
* Declares a `
|
|
49
|
+
* Declares a `Service`.
|
|
61
50
|
*
|
|
62
|
-
*
|
|
51
|
+
* Services are started and ended along with the daemon, and can be used on the App
|
|
63
52
|
* config to share globals between adapters and other methods.
|
|
64
|
-
* @param $
|
|
53
|
+
* @param $ object with an `up` and `down` method to create/destroy the service
|
|
65
54
|
*/
|
|
66
|
-
|
|
67
|
-
get config(): AppConfigFactory<S, Modules,
|
|
55
|
+
service<T extends IService>($: T): App<S, Modules, Services & { [K in T["name"]]: T; }>;
|
|
56
|
+
get config(): AppConfigFactory<S, Modules, Services>;
|
|
68
57
|
protected makeModules(): Record<string, AnyModule>;
|
|
69
|
-
static
|
|
58
|
+
static getServices(app: AnyApp): Record<string, IService>;
|
|
70
59
|
static getInfo(app: AnyApp): {
|
|
71
60
|
spaceModules: (string | number | symbol)[];
|
|
72
61
|
config: AnyAppConfig;
|
package/lib/engine/apps/app.js
CHANGED
|
@@ -21,10 +21,10 @@ class App {
|
|
|
21
21
|
// running the daemon. These will be included on the daemon
|
|
22
22
|
// once it's run.
|
|
23
23
|
this._injectedModules = [];
|
|
24
|
-
// A list of
|
|
24
|
+
// A list of services, which are created and destroyed
|
|
25
25
|
// along with the daemon. These are internally available for
|
|
26
26
|
// blocks - usually used by adapters.
|
|
27
|
-
this.
|
|
27
|
+
this._services = {};
|
|
28
28
|
if (boot) {
|
|
29
29
|
if ('space' in boot) {
|
|
30
30
|
this.space = boot.space;
|
|
@@ -56,14 +56,14 @@ class App {
|
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Declares a `
|
|
59
|
+
* Declares a `Service`.
|
|
60
60
|
*
|
|
61
|
-
*
|
|
61
|
+
* Services are started and ended along with the daemon, and can be used on the App
|
|
62
62
|
* config to share globals between adapters and other methods.
|
|
63
|
-
* @param $
|
|
63
|
+
* @param $ object with an `up` and `down` method to create/destroy the service
|
|
64
64
|
*/
|
|
65
|
-
|
|
66
|
-
this.
|
|
65
|
+
service($) {
|
|
66
|
+
this._services[$.name] = $;
|
|
67
67
|
return this;
|
|
68
68
|
}
|
|
69
69
|
//
|
|
@@ -94,8 +94,8 @@ class App {
|
|
|
94
94
|
return modules;
|
|
95
95
|
}
|
|
96
96
|
//
|
|
97
|
-
static
|
|
98
|
-
return app.
|
|
97
|
+
static getServices(app) {
|
|
98
|
+
return app._services;
|
|
99
99
|
}
|
|
100
100
|
static getInfo(app) {
|
|
101
101
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $Module, $Space, ModuleName } from "../../schema";
|
|
2
|
-
import { App
|
|
2
|
+
import { App } from './app';
|
|
3
|
+
import { IService } from './service';
|
|
3
4
|
import { AnyTrxEngine } from '../transaction/trx_engine';
|
|
4
5
|
import { AnyBuilder, AnyModule, Module } from '../module';
|
|
5
6
|
import { AnyDaemon, Daemon } from '../daemon';
|
|
@@ -7,28 +8,28 @@ import { AppConfigFactory } from './app.config';
|
|
|
7
8
|
/**
|
|
8
9
|
* @category App
|
|
9
10
|
*/
|
|
10
|
-
export declare class InlineApp<S extends $Space, ModuleNames extends string = ModuleName<S> & string,
|
|
11
|
+
export declare class InlineApp<S extends $Space, ModuleNames extends string = ModuleName<S> & string, Services extends Record<string, any> = Record<string, any>> extends App<S, ModuleNames, Services> {
|
|
11
12
|
protected _daemon?: Daemon<S, ModuleNames>;
|
|
12
13
|
protected _modules: Record<string, AnyModule>;
|
|
13
14
|
private packageJson?;
|
|
14
15
|
protected bootPromise?: Promise<void>;
|
|
15
16
|
constructor(name: string, builders: AnyBuilder[]);
|
|
16
|
-
boot(): InlineApp<S, ModuleNames,
|
|
17
|
+
boot(): InlineApp<S, ModuleNames, Services>;
|
|
17
18
|
/**
|
|
18
19
|
* Treeshake and build modules declared for this application.
|
|
19
20
|
*/
|
|
20
21
|
protected build(): Promise<void>;
|
|
21
22
|
/**
|
|
22
|
-
* Build the application, start
|
|
23
|
+
* Build the application, start services and trx engines.
|
|
23
24
|
* Returns references to start a daemon.
|
|
24
25
|
*/
|
|
25
26
|
protected make(): Promise<{
|
|
26
27
|
modules: Record<string, AnyModule>;
|
|
27
|
-
|
|
28
|
+
services: Record<string, any>;
|
|
28
29
|
trxEngines: Record<ModuleNames, AnyTrxEngine>;
|
|
29
30
|
}>;
|
|
30
31
|
daemon(): Promise<Daemon<S, ModuleNames>>;
|
|
31
|
-
protected makeDaemon(trxEngines: Record<ModuleNames, AnyTrxEngine>,
|
|
32
|
+
protected makeDaemon(trxEngines: Record<ModuleNames, AnyTrxEngine>, services: Record<string, IService>): AnyDaemon;
|
|
32
33
|
package(_package: Record<string, any>): this;
|
|
33
34
|
/**
|
|
34
35
|
* This method injects elements flagged as externals by referencing them
|
|
@@ -38,8 +39,8 @@ export declare class InlineApp<S extends $Space, ModuleNames extends string = Mo
|
|
|
38
39
|
*/
|
|
39
40
|
protected linkExternals(modules: Record<string, Module<S, $Module>>): void;
|
|
40
41
|
modules<M extends ModuleName<S>>(modules: M[]): InlineApp<S, M & ModuleNames>;
|
|
41
|
-
|
|
42
|
-
get config(): AppConfigFactory<S, ModuleNames,
|
|
42
|
+
service<T extends IService>($: T): InlineApp<S, ModuleNames, Services & { [K in T["name"]]: T; }>;
|
|
43
|
+
get config(): AppConfigFactory<S, ModuleNames, Services, typeof this>;
|
|
43
44
|
static package(app: InlineApp<any, any>, scripts: Record<string, string>, dependencies: Record<string, string>): {
|
|
44
45
|
name: string;
|
|
45
46
|
version: string;
|