nesoi 3.0.0 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/lib/adapters/postgres/src/migrator/bucket.d.ts +20 -0
- package/lib/adapters/postgres/src/migrator/bucket.js +184 -0
- package/lib/adapters/postgres/src/migrator/csv.d.ts +7 -0
- package/lib/adapters/postgres/src/migrator/csv.js +72 -0
- package/lib/adapters/postgres/src/migrator/migration.d.ts +2 -18
- package/lib/adapters/postgres/src/migrator/migration.js +10 -158
- package/lib/adapters/postgres/src/migrator/migrator.js +8 -5
- package/lib/adapters/postgres/src/migrator/runner.d.ts +16 -6
- package/lib/adapters/postgres/src/migrator/runner.js +103 -34
- package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +19 -22
- package/lib/adapters/postgres/src/postgres.bucket_adapter.js +116 -100
- package/lib/adapters/postgres/src/postgres.cli.d.ts +23 -3
- package/lib/adapters/postgres/src/postgres.cli.js +70 -10
- package/lib/adapters/postgres/src/postgres.config.d.ts +5 -0
- package/lib/adapters/postgres/src/postgres.config.js +2 -0
- package/lib/adapters/postgres/src/postgres.nql.d.ts +7 -3
- package/lib/adapters/postgres/src/postgres.nql.js +86 -32
- package/lib/adapters/postgres/src/postgres.provider.d.ts +18 -0
- package/lib/adapters/postgres/src/postgres.provider.js +77 -0
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +76 -39
- package/lib/compiler/apps/monolyth/monolyth_compiler.d.ts +3 -0
- package/lib/compiler/apps/monolyth/monolyth_compiler.js +24 -0
- package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.js +2 -1
- package/lib/compiler/apps/monolyth/stages/5_dump_cli_stage.js +1 -1
- package/lib/compiler/apps/monolyth/stages/6_dump_package_json_stage.js +1 -1
- package/lib/compiler/elements/bucket.element.js +26 -11
- package/lib/compiler/elements/constants.element.js +1 -1
- package/lib/compiler/elements/element.d.ts +2 -0
- package/lib/compiler/elements/message.element.js +4 -4
- package/lib/compiler/helpers/dump_helpers.js +5 -2
- package/lib/compiler/stages/7_dump_stage.js +2 -0
- package/lib/compiler/treeshake.js +9 -37
- package/lib/compiler/typescript/bridge/extract.js +12 -0
- package/lib/compiler/typescript/bridge/inject.js +3 -0
- package/lib/compiler/typescript/bridge/organize.js +3 -3
- package/lib/elements/blocks/block.builder.js +4 -2
- package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +22 -20
- package/lib/elements/blocks/job/internal/resource_job.d.ts +2 -1
- package/lib/elements/blocks/job/internal/resource_job.js +17 -4
- package/lib/elements/blocks/job/job.js +3 -0
- package/lib/elements/blocks/job/job.types.d.ts +7 -0
- package/lib/elements/blocks/job/job.types.js +2 -0
- package/lib/elements/blocks/machine/machine.js +3 -2
- package/lib/elements/blocks/resource/resource.builder.js +2 -4
- package/lib/elements/blocks/resource/resource.d.ts +5 -3
- package/lib/elements/blocks/resource/resource.js +26 -17
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +2 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.js +11 -2
- package/lib/elements/edge/controller/controller.builder.d.ts +4 -5
- package/lib/elements/edge/controller/controller.builder.js +7 -7
- package/lib/elements/edge/controller/controller.d.ts +2 -1
- package/lib/elements/edge/controller/controller.js +8 -6
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +61 -23
- package/lib/elements/entities/bucket/adapters/bucket_adapter.js +22 -13
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +21 -22
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +68 -2
- package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +10 -6
- package/lib/elements/entities/bucket/adapters/memory.nql.js +38 -3
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.d.ts +0 -20
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.js +46 -30
- package/lib/elements/entities/bucket/bucket.builder.d.ts +8 -2
- package/lib/elements/entities/bucket/bucket.builder.js +13 -19
- package/lib/elements/entities/bucket/bucket.config.d.ts +5 -1
- package/lib/elements/entities/bucket/bucket.d.ts +180 -19
- package/lib/elements/entities/bucket/bucket.js +662 -48
- package/lib/elements/entities/bucket/bucket.schema.d.ts +7 -1
- package/lib/elements/entities/bucket/bucket.schema.js +2 -1
- package/lib/elements/entities/bucket/bucket.types.d.ts +2 -7
- package/lib/elements/entities/bucket/cache/bucket_cache.d.ts +6 -2
- package/lib/elements/entities/bucket/cache/bucket_cache.js +12 -12
- package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +32 -5
- package/lib/elements/entities/bucket/graph/bucket_graph.js +80 -111
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.d.ts +3 -6
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.js +1 -4
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +3 -7
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.js +6 -2
- package/lib/elements/entities/bucket/model/bucket_model.builder.js +1 -1
- package/lib/elements/entities/bucket/model/bucket_model.convert.js +3 -3
- package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +37 -8
- package/lib/elements/entities/bucket/model/bucket_model.schema.js +25 -4
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +33 -14
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +56 -13
- package/lib/elements/entities/bucket/query/nql.schema.d.ts +1 -0
- package/lib/elements/entities/bucket/query/nql_compiler.js +13 -2
- package/lib/elements/entities/bucket/query/nql_engine.d.ts +11 -4
- package/lib/elements/entities/bucket/query/nql_engine.js +20 -11
- package/lib/elements/entities/bucket/view/bucket_view.js +63 -35
- package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +5 -2
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +6 -2
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +22 -16
- package/lib/elements/entities/constants/constants.schema.d.ts +1 -1
- package/lib/elements/entities/drive/drive_adapter.d.ts +44 -0
- package/lib/elements/entities/drive/drive_adapter.js +10 -0
- package/lib/elements/entities/drive/local.drive_adapter.d.ts +10 -0
- package/lib/elements/entities/drive/local.drive_adapter.js +34 -0
- package/lib/elements/entities/message/message.schema.d.ts +1 -0
- package/lib/elements/entities/message/message.schema.js +33 -0
- package/lib/elements/entities/message/message_parser.d.ts +5 -1
- package/lib/elements/entities/message/message_parser.js +56 -35
- package/lib/elements/entities/message/template/message_template.schema.d.ts +10 -8
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +16 -6
- package/lib/elements/entities/message/template/message_template_field.builder.js +25 -0
- package/lib/elements/entities/message/template/message_template_parser.js +2 -1
- package/lib/engine/apps/app.config.d.ts +32 -11
- package/lib/engine/apps/app.config.js +12 -0
- package/lib/engine/apps/app.d.ts +2 -0
- package/lib/engine/apps/app.js +3 -0
- package/lib/engine/apps/inline.app.d.ts +5 -3
- package/lib/engine/apps/inline.app.js +27 -12
- package/lib/engine/apps/monolyth/monolyth.app.d.ts +4 -2
- package/lib/engine/apps/monolyth/monolyth.app.js +22 -10
- package/lib/engine/auth/authn.d.ts +5 -1
- package/lib/engine/auth/zero.authn_provider.d.ts +4 -2
- package/lib/engine/auth/zero.authn_provider.js +2 -2
- package/lib/engine/cli/cli.d.ts +3 -1
- package/lib/engine/cli/cli.js +22 -3
- package/lib/engine/cli/cli_adapter.d.ts +2 -1
- package/lib/engine/cli/cli_adapter.js +2 -1
- package/lib/engine/cli/cli_input.d.ts +19 -0
- package/lib/engine/cli/cli_input.js +207 -0
- package/lib/engine/cli/ui.d.ts +1 -1
- package/lib/engine/cli/ui.js +2 -2
- package/lib/engine/daemon.d.ts +3 -2
- package/lib/engine/daemon.js +14 -2
- package/lib/engine/data/date.js +2 -2
- package/lib/engine/data/datetime.d.ts +40 -4
- package/lib/engine/data/datetime.js +70 -11
- package/lib/engine/data/decimal.d.ts +1 -1
- package/lib/engine/data/decimal.js +3 -3
- package/lib/engine/data/error.d.ts +21 -4
- package/lib/engine/data/error.js +23 -7
- package/lib/engine/data/file.d.ts +38 -0
- package/lib/engine/data/file.js +54 -0
- package/lib/engine/data/json.d.ts +6 -0
- package/lib/engine/data/json.js +26 -0
- package/lib/engine/data/obj.d.ts +1 -1
- package/lib/engine/data/trash.d.ts +14 -0
- package/lib/engine/data/trash.js +2 -0
- package/lib/engine/data/tree.d.ts +7 -12
- package/lib/engine/data/tree.js +101 -49
- package/lib/engine/module.d.ts +2 -1
- package/lib/engine/module.js +2 -5
- package/lib/engine/space.d.ts +1 -0
- package/lib/engine/space.js +6 -0
- package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +184 -24
- package/lib/engine/transaction/nodes/bucket.trx_node.js +346 -451
- package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +4 -2
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +27 -15
- package/lib/engine/transaction/nodes/job.trx_node.d.ts +2 -1
- package/lib/engine/transaction/nodes/job.trx_node.js +6 -0
- package/lib/engine/transaction/trx.d.ts +5 -2
- package/lib/engine/transaction/trx.js +2 -2
- package/lib/engine/transaction/trx_engine.config.d.ts +1 -3
- package/lib/engine/transaction/trx_engine.d.ts +2 -2
- package/lib/engine/transaction/trx_engine.js +14 -11
- package/lib/engine/transaction/trx_node.d.ts +14 -4
- package/lib/engine/transaction/trx_node.js +50 -8
- package/lib/engine/tree.d.ts +1 -1
- package/lib/engine/util/crypto.d.ts +50 -0
- package/lib/engine/util/crypto.js +89 -0
- package/lib/engine/util/deep.d.ts +5 -0
- package/lib/engine/util/deep.js +46 -0
- package/lib/engine/util/dotenv.d.ts +2 -8
- package/lib/engine/util/dotenv.js +14 -36
- package/lib/engine/util/hash.d.ts +3 -0
- package/lib/engine/util/hash.js +23 -0
- package/lib/engine/util/log.js +1 -1
- package/lib/engine/util/mime.d.ts +10 -0
- package/lib/engine/util/mime.js +389 -0
- package/lib/engine/util/parse.d.ts +6 -5
- package/lib/engine/util/parse.js +16 -15
- package/lib/engine/util/path.d.ts +3 -0
- package/lib/engine/util/path.js +92 -0
- package/lib/engine/util/rules.d.ts +4 -0
- package/lib/engine/util/rules.js +12 -0
- package/package.json +2 -2
- package/tools/compile.js +2 -2
- package/tools/dotenv.d.ts +1 -0
- package/tools/dotenv.js +4 -0
- package/tools/joaquin/job.d.ts +5 -5
- package/tools/joaquin/mock.d.ts +23 -2
- package/tools/joaquin/mock.js +127 -21
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/adapters/postgres/test/postgres.bucket_query.test.d.ts +0 -0
- package/lib/adapters/postgres/test/postgres.bucket_query.test.js +0 -136
|
@@ -87,7 +87,11 @@ class Resource extends block_1.Block {
|
|
|
87
87
|
static query($) {
|
|
88
88
|
const scope = $.job.scope;
|
|
89
89
|
return $.trx.bucket(scope.bucket)
|
|
90
|
-
.query($.msg.query).
|
|
90
|
+
.query($.msg.query).page({
|
|
91
|
+
page: $.msg.page,
|
|
92
|
+
perPage: $.msg.perPage,
|
|
93
|
+
count: true
|
|
94
|
+
});
|
|
91
95
|
}
|
|
92
96
|
static create($) {
|
|
93
97
|
const scope = $.job.scope;
|
|
@@ -101,25 +105,30 @@ class Resource extends block_1.Block {
|
|
|
101
105
|
}
|
|
102
106
|
static delete($) {
|
|
103
107
|
const scope = $.job.scope;
|
|
104
|
-
if (!$.obj) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
108
|
return $.trx.bucket(scope.bucket)
|
|
108
|
-
.
|
|
109
|
+
.delete($.obj.id);
|
|
109
110
|
}
|
|
110
111
|
// Custom assertions
|
|
111
|
-
static
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
static assertThat(trx, bucket, obj, type, arg) {
|
|
113
|
+
return {
|
|
114
|
+
else: async (error) => {
|
|
115
|
+
let out = false;
|
|
116
|
+
if (type === 'query is empty') {
|
|
117
|
+
out = !(await trx.bucket(bucket.refName)
|
|
118
|
+
.query(arg)
|
|
119
|
+
.first());
|
|
120
|
+
}
|
|
121
|
+
else if (type === 'has no link') {
|
|
122
|
+
if (!obj)
|
|
123
|
+
out = true;
|
|
124
|
+
else {
|
|
125
|
+
out = !(await trx.bucket(bucket.refName)
|
|
126
|
+
.hasLink(obj.id, arg));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out || error;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
exports.Resource = Resource;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
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
|
+
import { AuthnRequest } from "../../../../engine/auth/authn";
|
|
4
5
|
export type ControllerEndpointPath = ($ControllerDomain | $ControllerGroup | $ControllerEndpoint)[];
|
|
5
6
|
export declare abstract class ControllerAdapter {
|
|
6
7
|
protected schema: $Controller;
|
|
7
8
|
protected daemon?: AnyDaemon;
|
|
8
9
|
constructor(schema: $Controller);
|
|
9
|
-
trx(fn: (trx: AnyTrxNode) => Promise<any>): Promise<import("../../../../engine/transaction/trx").TrxStatus<any>>;
|
|
10
|
+
trx(fn: (trx: AnyTrxNode) => Promise<any>, authn?: AuthnRequest<any>): Promise<import("../../../../engine/transaction/trx").TrxStatus<any>>;
|
|
10
11
|
bind(daemon: AnyDaemon): void;
|
|
11
12
|
protected abstract makeEndpoint(path: string, schema: $ControllerEndpoint): void;
|
|
12
13
|
protected makeGroup(group: $ControllerGroup, root?: ControllerEndpointPath): void;
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ControllerAdapter = void 0;
|
|
4
|
+
const log_1 = require("../../../../engine/util/log");
|
|
4
5
|
class ControllerAdapter {
|
|
5
6
|
constructor(schema) {
|
|
6
7
|
this.schema = schema;
|
|
7
8
|
}
|
|
8
|
-
trx(fn) {
|
|
9
|
+
async trx(fn, authn) {
|
|
9
10
|
if (!this.daemon) {
|
|
10
11
|
throw new Error('Controller not bound to a daemon');
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
try {
|
|
14
|
+
return await this.daemon.trx(this.schema.module)
|
|
15
|
+
.authn(authn)
|
|
16
|
+
.run(fn);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
log_1.Log.error('controller', this.schema.name, 'Unknown error', e);
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
13
22
|
}
|
|
14
23
|
bind(daemon) {
|
|
15
24
|
this.daemon = daemon;
|
|
@@ -14,13 +14,12 @@ type MachinesSupportingMsg<M extends $Module, Msg extends $Message> = {
|
|
|
14
14
|
export declare class ControllerEndpointBuilder<S extends $Space, M extends $Module, Msg extends $Message = never> {
|
|
15
15
|
private module;
|
|
16
16
|
private name;
|
|
17
|
-
private _alias?;
|
|
18
|
-
private _version?;
|
|
19
17
|
private _authn;
|
|
18
|
+
private _alias?;
|
|
20
19
|
private _tags;
|
|
21
20
|
private _msg;
|
|
22
21
|
private _target;
|
|
23
|
-
constructor(module: string, name: string);
|
|
22
|
+
constructor(module: string, name: string, _authn?: string[]);
|
|
24
23
|
as(alias: string): this;
|
|
25
24
|
authn<U extends keyof S['authnUsers']>(providers: U | U[]): this;
|
|
26
25
|
tag(tag: string): this;
|
|
@@ -34,11 +33,11 @@ export declare class ControllerEndpointBuilder<S extends $Space, M extends $Modu
|
|
|
34
33
|
export declare class ControllerGroupBuilder<S extends $Space, M extends $Module> {
|
|
35
34
|
private module;
|
|
36
35
|
protected name: string;
|
|
37
|
-
protected _alias?: string;
|
|
38
36
|
protected _authn: string[];
|
|
37
|
+
protected _alias?: string;
|
|
39
38
|
protected groups: Record<string, ControllerGroupBuilder<any, any>>;
|
|
40
39
|
protected endpoints: Record<string, ControllerEndpointBuilder<any, any>>;
|
|
41
|
-
constructor(module: string, name: string);
|
|
40
|
+
constructor(module: string, name: string, _authn?: string[]);
|
|
42
41
|
as(alias: string): this;
|
|
43
42
|
authn<U extends keyof S['authnUsers']>(providers: U | U[]): this;
|
|
44
43
|
endpoint(name: string, $: ControllerEndpointDef<S, M>): this;
|
|
@@ -4,10 +4,10 @@ exports.ControllerBuilder = exports.ControllerDomainBuilder = exports.Controller
|
|
|
4
4
|
const controller_schema_1 = require("./controller.schema");
|
|
5
5
|
const dependency_1 = require("../../../engine/dependency");
|
|
6
6
|
class ControllerEndpointBuilder {
|
|
7
|
-
constructor(module, name) {
|
|
7
|
+
constructor(module, name, _authn = []) {
|
|
8
8
|
this.module = module;
|
|
9
9
|
this.name = name;
|
|
10
|
-
this._authn =
|
|
10
|
+
this._authn = _authn;
|
|
11
11
|
this._tags = [];
|
|
12
12
|
}
|
|
13
13
|
as(alias) {
|
|
@@ -51,10 +51,10 @@ class ControllerEndpointBuilder {
|
|
|
51
51
|
}
|
|
52
52
|
exports.ControllerEndpointBuilder = ControllerEndpointBuilder;
|
|
53
53
|
class ControllerGroupBuilder {
|
|
54
|
-
constructor(module, name) {
|
|
54
|
+
constructor(module, name, _authn = []) {
|
|
55
55
|
this.module = module;
|
|
56
56
|
this.name = name;
|
|
57
|
-
this._authn =
|
|
57
|
+
this._authn = _authn;
|
|
58
58
|
this.groups = {};
|
|
59
59
|
this.endpoints = {};
|
|
60
60
|
}
|
|
@@ -70,13 +70,13 @@ class ControllerGroupBuilder {
|
|
|
70
70
|
return this;
|
|
71
71
|
}
|
|
72
72
|
endpoint(name, $) {
|
|
73
|
-
const builder = new ControllerEndpointBuilder(this.module, name);
|
|
73
|
+
const builder = new ControllerEndpointBuilder(this.module, name, this._authn);
|
|
74
74
|
$(builder);
|
|
75
75
|
this.endpoints[name] = builder;
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
78
|
group(name, $) {
|
|
79
|
-
const builder = new ControllerGroupBuilder(this.module, name);
|
|
79
|
+
const builder = new ControllerGroupBuilder(this.module, name, this._authn);
|
|
80
80
|
$(builder);
|
|
81
81
|
this.groups[name] = builder;
|
|
82
82
|
return this;
|
|
@@ -139,7 +139,7 @@ class ControllerBuilder {
|
|
|
139
139
|
return this;
|
|
140
140
|
}
|
|
141
141
|
domain(name, $) {
|
|
142
|
-
const builder = new ControllerDomainBuilder(this.module, name);
|
|
142
|
+
const builder = new ControllerDomainBuilder(this.module, name, this._authn);
|
|
143
143
|
$(builder);
|
|
144
144
|
const version = builder._version;
|
|
145
145
|
this.domains[name + '.' + version] = builder;
|
|
@@ -4,12 +4,13 @@ import { $Controller, $ControllerEndpoint } from './controller.schema';
|
|
|
4
4
|
import { ControllerAdapter } from './adapters/controller_adapter';
|
|
5
5
|
import { ControllerConfig } from './controller.config';
|
|
6
6
|
import { AnyDaemon } from "../../../engine/daemon";
|
|
7
|
+
import { AuthnRequest } from "../../../engine/auth/authn";
|
|
7
8
|
export declare class ControllerEndpoint<$ extends $ControllerEndpoint> {
|
|
8
9
|
schema: $;
|
|
9
10
|
adapter: ControllerAdapter;
|
|
10
11
|
path: string;
|
|
11
12
|
constructor(schema: $, adapter: ControllerAdapter, path: string);
|
|
12
|
-
invoke(data: Record<string, any>): Promise<import("../../../engine/transaction/trx").TrxStatus<any>>;
|
|
13
|
+
invoke(data: Record<string, any>, authn?: AuthnRequest<any>): Promise<import("../../../engine/transaction/trx").TrxStatus<any>>;
|
|
13
14
|
}
|
|
14
15
|
export declare class Controller<S extends $Space, M extends $Module, $ extends $Controller> {
|
|
15
16
|
schema: $;
|
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Controller = exports.ControllerEndpoint = void 0;
|
|
4
4
|
const cli_controller_adapter_1 = require("./adapters/cli.controller_adapter");
|
|
5
|
+
const trx_node_1 = require("../../../engine/transaction/trx_node");
|
|
5
6
|
class ControllerEndpoint {
|
|
6
7
|
constructor(schema, adapter, path) {
|
|
7
8
|
this.schema = schema;
|
|
8
9
|
this.adapter = adapter;
|
|
9
10
|
this.path = path;
|
|
10
11
|
}
|
|
11
|
-
invoke(data) {
|
|
12
|
+
invoke(data, authn) {
|
|
12
13
|
const raw = {
|
|
13
14
|
...data,
|
|
14
15
|
$: this.schema.msg.name
|
|
15
16
|
};
|
|
16
|
-
return this.adapter.trx(async (
|
|
17
|
+
return this.adapter.trx(async (trx) => {
|
|
18
|
+
trx_node_1.TrxNode.checkAuthn(trx, this.schema.authn);
|
|
17
19
|
if (this.schema.target.type === 'job') {
|
|
18
|
-
return
|
|
20
|
+
return trx.job(this.schema.target.refName).run(raw);
|
|
19
21
|
}
|
|
20
22
|
if (this.schema.target.type === 'resource') {
|
|
21
|
-
return
|
|
23
|
+
return trx.resource(this.schema.target.refName).run(raw);
|
|
22
24
|
}
|
|
23
25
|
if (this.schema.target.type === 'machine') {
|
|
24
|
-
return
|
|
26
|
+
return trx.machine(this.schema.target.refName).run(raw);
|
|
25
27
|
}
|
|
26
|
-
});
|
|
28
|
+
}, authn);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
exports.ControllerEndpoint = ControllerEndpoint;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
2
|
-
import { NesoiObj,
|
|
2
|
+
import { NesoiObj, ObjWithOptionalId } from "../../../../engine/data/obj";
|
|
3
3
|
import { BucketCacheSync } from '../cache/bucket_cache';
|
|
4
4
|
import { NQL_AnyQuery, NQL_Pagination } from '../query/nql.schema';
|
|
5
|
-
import { NQLRunner } from '../query/nql_engine';
|
|
5
|
+
import { NQLRunner, NQL_Result } from '../query/nql_engine';
|
|
6
6
|
import { $Bucket } from "../../..";
|
|
7
7
|
export type BucketAdapterConfig = {
|
|
8
|
-
|
|
8
|
+
meta: {
|
|
9
|
+
created_at: string;
|
|
10
|
+
created_by: string;
|
|
11
|
+
updated_at: string;
|
|
12
|
+
updated_by: string;
|
|
13
|
+
};
|
|
9
14
|
};
|
|
10
15
|
export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
11
16
|
protected schema: $Bucket;
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
nql: NQLRunner;
|
|
18
|
+
config: BucketAdapterConfig;
|
|
14
19
|
constructor(schema: $Bucket, nql: NQLRunner, config?: Partial<BucketAdapterConfig>);
|
|
15
20
|
/**
|
|
16
|
-
* **
|
|
21
|
+
* **DANGEROUS!**
|
|
17
22
|
* This should only be used on inner adapters of bucket caches.
|
|
18
23
|
* Be extremely careful when implementing this on permanent storage adapters.
|
|
19
24
|
*/
|
|
@@ -27,29 +32,50 @@ export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
|
27
32
|
*/
|
|
28
33
|
abstract index(trx: AnyTrxNode): Promise<Obj[]>;
|
|
29
34
|
/**
|
|
30
|
-
*
|
|
35
|
+
* Create an entity and return it
|
|
36
|
+
*
|
|
37
|
+
* - This method should throw an exception if the obj `id` already exists
|
|
31
38
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}[] : Obj[]>;
|
|
39
|
+
abstract create(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
40
|
+
/**
|
|
41
|
+
* Create many entities and return them
|
|
42
|
+
*/
|
|
43
|
+
abstract createMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* Replace an entity and return it.
|
|
40
46
|
*
|
|
41
|
-
*
|
|
42
|
-
* - If not, it's a **create**.
|
|
47
|
+
* **WARNING**: This method **MUST NOT** replace the `created_by` and `created_at` fields.
|
|
43
48
|
*/
|
|
44
|
-
abstract
|
|
49
|
+
abstract replace(trx: AnyTrxNode, obj: Obj): Promise<Obj>;
|
|
45
50
|
/**
|
|
46
|
-
*
|
|
51
|
+
* Replace many entities and return them
|
|
47
52
|
*
|
|
48
|
-
*
|
|
49
|
-
* - If the `obj` has an `id` property, it's a **replace**.
|
|
50
|
-
* - If not, it's a **create**.
|
|
53
|
+
* **WARNING**: This method **MUST NOT** replace the `created_by` and `created_at` fields.
|
|
51
54
|
*/
|
|
52
|
-
abstract
|
|
55
|
+
abstract replaceMany(trx: AnyTrxNode, objs: Obj[]): Promise<Obj[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Patch (modify) an entity and return it
|
|
58
|
+
*/
|
|
59
|
+
abstract patch(trx: AnyTrxNode, obj: Obj): Promise<Obj>;
|
|
60
|
+
/**
|
|
61
|
+
* Patch (modify) many entities and return them
|
|
62
|
+
*/
|
|
63
|
+
abstract patchMany(trx: AnyTrxNode, objs: Obj[]): Promise<Obj[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Put (Create or Replace) an entity and return it.
|
|
66
|
+
*
|
|
67
|
+
* - If the object does not contains an `id`, it's a `create`
|
|
68
|
+
* - If the object contains an `id`, it's a `replace`
|
|
69
|
+
*
|
|
70
|
+
* **WARNING**: This method **MUST NOT** replace the `created_by` and `created_at` fields on `replace`.
|
|
71
|
+
*/
|
|
72
|
+
abstract put(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
73
|
+
/**
|
|
74
|
+
* Put (Create or Replace) many entities and return them
|
|
75
|
+
*
|
|
76
|
+
* **WARNING**: This method **MUST NOT** replace the `created_by` and `created_at` fields on `replace`.
|
|
77
|
+
*/
|
|
78
|
+
abstract putMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
53
79
|
/**
|
|
54
80
|
* Delete an entity by ID
|
|
55
81
|
*/
|
|
@@ -58,7 +84,6 @@ export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
|
58
84
|
* Delete many entities by their IDs
|
|
59
85
|
*/
|
|
60
86
|
abstract deleteMany(trx: AnyTrxNode, ids: Obj['id'][]): Promise<void>;
|
|
61
|
-
getUpdateEpoch(obj: Obj): number;
|
|
62
87
|
/**
|
|
63
88
|
* Given an id, sync that object only.
|
|
64
89
|
* - If the id doesn't exist on the source, return 'deleted'
|
|
@@ -103,5 +128,18 @@ export declare abstract class BucketAdapter<Obj extends NesoiObj> {
|
|
|
103
128
|
scope: string;
|
|
104
129
|
avgTime: number;
|
|
105
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Return the results of a query
|
|
133
|
+
*/
|
|
134
|
+
query<MetadataOnly extends boolean>(trx: AnyTrxNode, query: NQL_AnyQuery, pagination?: NQL_Pagination, params?: Record<string, any>, config?: {
|
|
135
|
+
metadataOnly: MetadataOnly;
|
|
136
|
+
}): Promise<NQL_Result<MetadataOnly extends true ? {
|
|
137
|
+
id: Obj['id'];
|
|
138
|
+
[x: string]: any;
|
|
139
|
+
}[] : Obj[]>>;
|
|
140
|
+
/**
|
|
141
|
+
* Return the epoch of the last update of an object
|
|
142
|
+
*/
|
|
143
|
+
getUpdateEpoch(obj: Obj): number;
|
|
106
144
|
}
|
|
107
145
|
export type AnyBucketAdapter = BucketAdapter<any>;
|
|
@@ -3,38 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BucketAdapter = void 0;
|
|
4
4
|
const trx_node_1 = require("../../../../engine/transaction/trx_node");
|
|
5
5
|
const error_1 = require("../../../../engine/data/error");
|
|
6
|
-
const datetime_1 = require("../../../../engine/data/datetime");
|
|
7
6
|
const nql_compiler_1 = require("../query/nql_compiler");
|
|
8
7
|
class BucketAdapter {
|
|
9
8
|
constructor(schema, nql, config) {
|
|
10
9
|
this.schema = schema;
|
|
11
10
|
this.nql = nql;
|
|
12
11
|
this.config = {
|
|
13
|
-
|
|
12
|
+
meta: {
|
|
13
|
+
created_at: config?.meta?.created_at || 'created_at',
|
|
14
|
+
created_by: config?.meta?.created_by || 'created_by',
|
|
15
|
+
updated_at: config?.meta?.updated_at || 'updated_at',
|
|
16
|
+
updated_by: config?.meta?.updated_by || 'updated_by'
|
|
17
|
+
}
|
|
14
18
|
};
|
|
15
19
|
}
|
|
20
|
+
/* Generic Implementation */
|
|
16
21
|
/**
|
|
17
22
|
* Return the results of a query
|
|
18
23
|
*/
|
|
19
|
-
async query(trx, query, pagination, config) {
|
|
24
|
+
async query(trx, query, pagination, params, config) {
|
|
20
25
|
const module = trx_node_1.TrxNode.getModule(trx);
|
|
21
|
-
const
|
|
22
|
-
|
|
26
|
+
const refName = (module.name === this.schema.module
|
|
27
|
+
? '' : `${this.schema.module}::`)
|
|
28
|
+
+ this.schema.name;
|
|
29
|
+
const compiled = await nql_compiler_1.NQL_Compiler.build(module, refName, query);
|
|
30
|
+
const result = await module.nql.run(trx, compiled, pagination, params);
|
|
23
31
|
if (config?.metadataOnly) {
|
|
24
|
-
|
|
32
|
+
result.data = result.data.map(obj => ({
|
|
25
33
|
id: obj.id,
|
|
26
|
-
[this.config.
|
|
34
|
+
[this.config.meta.updated_at]: this.getUpdateEpoch(obj)
|
|
27
35
|
}));
|
|
28
36
|
}
|
|
29
|
-
return
|
|
37
|
+
return result;
|
|
30
38
|
}
|
|
31
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Return the epoch of the last update of an object
|
|
41
|
+
*/
|
|
32
42
|
getUpdateEpoch(obj) {
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
throw error_1.NesoiError.Bucket.NoUpdatedAtField({ bucket: 'TODO', id: obj.id, field: this.config.
|
|
43
|
+
const objUpdate = obj[this.config.meta.updated_at];
|
|
44
|
+
if (!objUpdate) {
|
|
45
|
+
throw error_1.NesoiError.Bucket.NoUpdatedAtField({ bucket: 'TODO', id: obj.id, field: this.config.meta.updated_at });
|
|
36
46
|
}
|
|
37
|
-
const objUpdate = datetime_1.NesoiDatetime.fromISO(objUpdateStr);
|
|
38
47
|
return objUpdate.epoch;
|
|
39
48
|
}
|
|
40
49
|
}
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { BucketAdapter, BucketAdapterConfig } from './bucket_adapter';
|
|
2
|
-
import {
|
|
2
|
+
import { ObjWithOptionalId } from "../../../../engine/data/obj";
|
|
3
3
|
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
4
4
|
import { $Bucket } from "../../..";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { BucketCacheSync } from '../cache/bucket_cache';
|
|
6
|
+
export declare class MemoryBucketAdapter<B extends $Bucket, Obj extends B['#data']> extends BucketAdapter<Obj> {
|
|
7
|
+
schema: B;
|
|
8
|
+
data: NoInfer<Record<Obj['id'], Obj>>;
|
|
9
|
+
constructor(schema: B, data?: NoInfer<Record<Obj['id'], Obj>>, config?: BucketAdapterConfig);
|
|
9
10
|
getQueryMeta(): {
|
|
10
11
|
scope: string;
|
|
11
12
|
avgTime: number;
|
|
12
13
|
};
|
|
13
14
|
protected deleteEverything(trx: AnyTrxNode): Promise<void>;
|
|
14
15
|
index(trx: AnyTrxNode): Promise<Obj[]>;
|
|
15
|
-
get(trx: AnyTrxNode, id: Obj['id']): Promise<
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
get(trx: AnyTrxNode, id: Obj['id']): Promise<Obj | undefined>;
|
|
17
|
+
create(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
18
|
+
createMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
19
|
+
replace(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
20
|
+
replaceMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
21
|
+
patch(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
22
|
+
patchMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
23
|
+
put(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
24
|
+
putMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
18
25
|
delete(trx: AnyTrxNode, id: Obj['id']): Promise<void>;
|
|
19
26
|
deleteMany(trx: AnyTrxNode, ids: Obj['id'][]): Promise<void>;
|
|
20
|
-
syncOne(trx: AnyTrxNode, id: Obj['id'], lastObjUpdateEpoch: number): Promise<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
syncOneAndPast(trx: AnyTrxNode, id: Obj['id'], lastUpdateEpoch: number): Promise<"deleted" | {
|
|
25
|
-
obj: Obj;
|
|
26
|
-
updateEpoch: number;
|
|
27
|
-
}[] | null>;
|
|
28
|
-
syncAll(trx: AnyTrxNode, lastHash?: string, lastUpdateEpoch?: number): Promise<{
|
|
29
|
-
sync: {
|
|
30
|
-
obj: Obj;
|
|
31
|
-
updateEpoch: number;
|
|
32
|
-
}[];
|
|
27
|
+
syncOne(trx: AnyTrxNode, id: Obj['id'], lastObjUpdateEpoch: number): Promise<null | 'deleted' | BucketCacheSync<Obj>>;
|
|
28
|
+
syncOneAndPast(trx: AnyTrxNode, id: Obj['id'], lastUpdateEpoch: number): Promise<null | 'deleted' | BucketCacheSync<Obj>[]>;
|
|
29
|
+
syncAll(trx: AnyTrxNode, lastHash?: string, lastUpdateEpoch?: number): Promise<null | {
|
|
30
|
+
sync: BucketCacheSync<Obj>[];
|
|
33
31
|
hash: string;
|
|
34
32
|
updateEpoch: number;
|
|
35
33
|
reset: boolean;
|
|
36
|
-
}
|
|
34
|
+
}>;
|
|
37
35
|
}
|
|
36
|
+
export type AnyMemoryBucketAdapter = MemoryBucketAdapter<any, any>;
|
|
@@ -32,6 +32,59 @@ class MemoryBucketAdapter extends bucket_adapter_1.BucketAdapter {
|
|
|
32
32
|
return Promise.resolve(this.data[id]);
|
|
33
33
|
}
|
|
34
34
|
/* Write Operations */
|
|
35
|
+
async create(trx, obj) {
|
|
36
|
+
const lastId = (await this.index(trx))
|
|
37
|
+
.map((obj) => parseInt(obj.id))
|
|
38
|
+
.sort((a, b) => b - a)[0] || 0;
|
|
39
|
+
obj.id = lastId + 1;
|
|
40
|
+
this.data[obj.id] = obj;
|
|
41
|
+
return Promise.resolve(obj);
|
|
42
|
+
}
|
|
43
|
+
async createMany(trx, objs) {
|
|
44
|
+
const out = [];
|
|
45
|
+
for (const obj of objs) {
|
|
46
|
+
out.push(await this.create(trx, obj));
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
async replace(trx, obj) {
|
|
51
|
+
if (!obj.id || !this.data[obj.id]) {
|
|
52
|
+
throw new Error(`Object with id ${obj.id} not found for replace`);
|
|
53
|
+
}
|
|
54
|
+
this.data[obj.id] = obj;
|
|
55
|
+
return Promise.resolve(obj);
|
|
56
|
+
}
|
|
57
|
+
replaceMany(trx, objs) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const obj of objs) {
|
|
60
|
+
if (!obj.id || !this.data[obj.id]) {
|
|
61
|
+
throw new Error(`Object with id ${obj.id} not found for replace`);
|
|
62
|
+
}
|
|
63
|
+
this.data[obj.id] = obj;
|
|
64
|
+
out.push(obj);
|
|
65
|
+
}
|
|
66
|
+
return Promise.resolve(out);
|
|
67
|
+
}
|
|
68
|
+
async patch(trx, obj) {
|
|
69
|
+
if (!obj.id || !this.data[obj.id]) {
|
|
70
|
+
throw new Error(`Object with id ${obj.id} not found for patch`);
|
|
71
|
+
}
|
|
72
|
+
// TODO: Implement patch
|
|
73
|
+
this.data[obj.id] = obj;
|
|
74
|
+
return Promise.resolve(obj);
|
|
75
|
+
}
|
|
76
|
+
patchMany(trx, objs) {
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const obj of objs) {
|
|
79
|
+
if (!obj.id || !this.data[obj.id]) {
|
|
80
|
+
throw new Error(`Object with id ${obj.id} not found for patch`);
|
|
81
|
+
}
|
|
82
|
+
// TODO: Implement patch
|
|
83
|
+
this.data[obj.id] = obj;
|
|
84
|
+
out.push(obj);
|
|
85
|
+
}
|
|
86
|
+
return Promise.resolve(out);
|
|
87
|
+
}
|
|
35
88
|
async put(trx, obj) {
|
|
36
89
|
if (!obj.id) {
|
|
37
90
|
const lastId = (await this.index(trx))
|
|
@@ -42,8 +95,21 @@ class MemoryBucketAdapter extends bucket_adapter_1.BucketAdapter {
|
|
|
42
95
|
this.data[obj.id] = obj;
|
|
43
96
|
return Promise.resolve(obj);
|
|
44
97
|
}
|
|
45
|
-
putMany(trx, objs) {
|
|
46
|
-
|
|
98
|
+
async putMany(trx, objs) {
|
|
99
|
+
const lastId = (await this.index(trx))
|
|
100
|
+
.map((obj) => parseInt(obj.id))
|
|
101
|
+
.sort((a, b) => b - a)[0] || 0;
|
|
102
|
+
let id = lastId + 1;
|
|
103
|
+
const out = [];
|
|
104
|
+
for (const obj of objs) {
|
|
105
|
+
if (!obj.id) {
|
|
106
|
+
obj.id = id;
|
|
107
|
+
}
|
|
108
|
+
this.data[obj.id] = obj;
|
|
109
|
+
out.push(obj);
|
|
110
|
+
id++;
|
|
111
|
+
}
|
|
112
|
+
return Promise.resolve(out);
|
|
47
113
|
}
|
|
48
114
|
delete(trx, id) {
|
|
49
115
|
delete this.data[id];
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { NQLRunner } from '../query/nql_engine';
|
|
2
2
|
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
3
|
-
import { NQL_Part } from '../query/nql.schema';
|
|
4
|
-
import {
|
|
3
|
+
import { NQL_Pagination, NQL_Part } from '../query/nql.schema';
|
|
4
|
+
import { AnyMemoryBucketAdapter } from './memory.bucket_adapter';
|
|
5
5
|
type Obj = Record<string, any>;
|
|
6
|
-
type Objs = Record<string, Obj>;
|
|
7
6
|
export declare class MemoryNQLRunner extends NQLRunner {
|
|
8
|
-
protected adapter?:
|
|
7
|
+
protected adapter?: AnyMemoryBucketAdapter;
|
|
9
8
|
constructor();
|
|
10
|
-
bind(adapter:
|
|
11
|
-
run(trx: AnyTrxNode, part: NQL_Part, params: Obj): Promise<
|
|
9
|
+
bind(adapter: AnyMemoryBucketAdapter): void;
|
|
10
|
+
run(trx: AnyTrxNode, part: NQL_Part, params: Obj, pagination?: NQL_Pagination): Promise<{
|
|
11
|
+
data: any[];
|
|
12
|
+
count: number | undefined;
|
|
13
|
+
page: number | undefined;
|
|
14
|
+
perPage: number | undefined;
|
|
15
|
+
}>;
|
|
12
16
|
/**
|
|
13
17
|
* Goes through each rule keeping a scoped white and black list to avoid
|
|
14
18
|
* testing objects unnecessarily. Returns a dict of results by id.
|
|
@@ -10,12 +10,47 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
10
10
|
bind(adapter) {
|
|
11
11
|
this.adapter = adapter;
|
|
12
12
|
}
|
|
13
|
-
async run(trx, part, params) {
|
|
13
|
+
async run(trx, part, params, pagination) {
|
|
14
14
|
if (!this.adapter) {
|
|
15
15
|
throw new Error('No adapter bound to NQL Runner');
|
|
16
16
|
}
|
|
17
17
|
const data = this.adapter.data;
|
|
18
|
-
|
|
18
|
+
let response;
|
|
19
|
+
// Empty query, don't filter data
|
|
20
|
+
if (part.union.inters.length === 0) {
|
|
21
|
+
response = data;
|
|
22
|
+
}
|
|
23
|
+
// Non-empty query
|
|
24
|
+
else {
|
|
25
|
+
response = await this.filter(part, data, params);
|
|
26
|
+
}
|
|
27
|
+
let output = Object.values(response);
|
|
28
|
+
if (part.union.order) {
|
|
29
|
+
const k = part.union.order.dir || this.adapter.config.meta.updated_at;
|
|
30
|
+
if (part.union.order.dir === 'asc') {
|
|
31
|
+
output.sort((a, b) => a[k] - b[k]);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
output.sort((a, b) => b[k] - a[k]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let count = undefined;
|
|
38
|
+
if (pagination) {
|
|
39
|
+
if (pagination.count) {
|
|
40
|
+
count = output.length;
|
|
41
|
+
}
|
|
42
|
+
if (pagination.page || pagination.perPage) {
|
|
43
|
+
const a = ((pagination.page || 1) - 1) * (pagination.perPage || 10);
|
|
44
|
+
const b = a + (pagination.perPage || 10);
|
|
45
|
+
output = output.slice(a, b);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
data: output,
|
|
50
|
+
count,
|
|
51
|
+
page: pagination?.page,
|
|
52
|
+
perPage: pagination?.perPage
|
|
53
|
+
};
|
|
19
54
|
}
|
|
20
55
|
/**
|
|
21
56
|
* Goes through each rule keeping a scoped white and black list to avoid
|
|
@@ -102,7 +137,7 @@ class MemoryNQLRunner extends nql_engine_1.NQLRunner {
|
|
|
102
137
|
return false;
|
|
103
138
|
}
|
|
104
139
|
// Fieldpath is a spread, apply rule to each item
|
|
105
|
-
if (rule.fieldpath.includes('
|
|
140
|
+
if (rule.fieldpath.includes('.#')) {
|
|
106
141
|
for (const item of fieldValue) {
|
|
107
142
|
if (_obj(rule, item, params))
|
|
108
143
|
return true;
|