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
|
@@ -6,6 +6,11 @@ import { TrxEngineConfig } from '../transaction/trx_engine.config';
|
|
|
6
6
|
import { CompilerConfig } from "../../compiler/compiler";
|
|
7
7
|
import { App } from './app';
|
|
8
8
|
import { CLIConfig } from '../cli/cli';
|
|
9
|
+
import { BucketAdapter } from "../../elements/entities/bucket/adapters/bucket_adapter";
|
|
10
|
+
import { TrashObj } from '../data/trash';
|
|
11
|
+
import { $Bucket } from "../../elements";
|
|
12
|
+
import { Overlay } from '../util/type';
|
|
13
|
+
import { TrxStatus } from '../transaction/trx';
|
|
9
14
|
export type AppConfig<S extends $Space, Modules extends ModuleName<S>> = {
|
|
10
15
|
i18n?: AppI18nConfig;
|
|
11
16
|
authn?: AppAuthnConfig<S>;
|
|
@@ -20,13 +25,18 @@ export type AppI18nConfig = {
|
|
|
20
25
|
[x: string]: ($: Record<string, any>) => string;
|
|
21
26
|
};
|
|
22
27
|
export type AppAuthnConfig<S extends $Space> = {
|
|
23
|
-
[K in keyof S['authnUsers']]: AuthnProvider<S['authnUsers'][K]>;
|
|
28
|
+
[K in keyof S['authnUsers']]: () => AuthnProvider<S['authnUsers'][K]>;
|
|
24
29
|
};
|
|
25
30
|
export type AppBucketConfig<S extends $Space, Modules extends ModuleName<S>, Providers extends Record<string, any>> = Partial<{
|
|
26
31
|
[M in (Modules & keyof S['modules'])]: Partial<{
|
|
27
|
-
[K in keyof S['modules'][M]['buckets']]: BucketConfig<S['modules'][M]['buckets'][K], Providers>;
|
|
32
|
+
[K in keyof S['modules'][M]['buckets']]: BucketConfig<S['modules'][M], S['modules'][M]['buckets'][K], Providers>;
|
|
28
33
|
}>;
|
|
29
34
|
}>;
|
|
35
|
+
export type AppTrashConfig = {
|
|
36
|
+
adapter: ($: Overlay<$Bucket, {
|
|
37
|
+
'#data': TrashObj;
|
|
38
|
+
}>) => BucketAdapter<TrashObj>;
|
|
39
|
+
};
|
|
30
40
|
export type AppControllerConfig<S extends $Space, Modules extends ModuleName<S>, Providers extends Record<string, any>> = Partial<{
|
|
31
41
|
[M in (Modules & keyof S['modules'])]: Partial<{
|
|
32
42
|
[K in keyof S['modules'][M]['controllers']]: ControllerConfig<S['modules'][M]['controllers'][K], Providers>;
|
|
@@ -35,15 +45,26 @@ export type AppControllerConfig<S extends $Space, Modules extends ModuleName<S>,
|
|
|
35
45
|
export type AppTrxEngineConfig<S extends $Space, Modules extends ModuleName<S>, Providers extends Record<string, any>> = Partial<{
|
|
36
46
|
[M in (Modules & keyof S['modules'])]: TrxEngineConfig<S, S['modules'][M], any, Providers>;
|
|
37
47
|
}>;
|
|
38
|
-
export
|
|
48
|
+
export type AppAuditConfig = {
|
|
49
|
+
adapter: ($: Overlay<$Bucket, {
|
|
50
|
+
'#data': TrashObj;
|
|
51
|
+
}>) => BucketAdapter<TrashObj>;
|
|
52
|
+
transform?: (trx: TrxStatus<any>) => Record<string, any>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Factory
|
|
56
|
+
*/
|
|
57
|
+
export declare class AppConfigFactory<S extends $Space, Modules extends string = ModuleName<S> & string, Providers extends Record<string, any> = Record<string, any>, _App = App<S, Modules, Providers>> {
|
|
39
58
|
private app;
|
|
40
59
|
private config;
|
|
41
|
-
constructor(app:
|
|
42
|
-
i18n(config: AppI18nConfig):
|
|
43
|
-
authn(config: AppAuthnConfig<S>):
|
|
44
|
-
buckets(config: AppBucketConfig<S, Modules, Providers>):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
constructor(app: _App);
|
|
61
|
+
i18n(config: AppI18nConfig): _App;
|
|
62
|
+
authn(config: AppAuthnConfig<S>): _App;
|
|
63
|
+
buckets(config: AppBucketConfig<S, Modules, Providers>): _App;
|
|
64
|
+
trash(config: AppTrashConfig): _App;
|
|
65
|
+
controllers(config: AppControllerConfig<S, Modules, Providers>): _App;
|
|
66
|
+
audit(config: AppI18nConfig): _App;
|
|
67
|
+
compiler(config: CompilerConfig): _App;
|
|
68
|
+
cli(config: CLIConfig<Providers>): _App;
|
|
69
|
+
trx(config: AppTrxEngineConfig<S, Modules, Providers>): _App;
|
|
49
70
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppConfigFactory = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Factory
|
|
6
|
+
*/
|
|
4
7
|
class AppConfigFactory {
|
|
5
8
|
constructor(app) {
|
|
6
9
|
this.app = app;
|
|
@@ -18,10 +21,19 @@ class AppConfigFactory {
|
|
|
18
21
|
this.config.buckets = config;
|
|
19
22
|
return this.app;
|
|
20
23
|
}
|
|
24
|
+
trash(config) {
|
|
25
|
+
// TODO
|
|
26
|
+
// this.config.buckets = config as never;
|
|
27
|
+
return this.app;
|
|
28
|
+
}
|
|
21
29
|
controllers(config) {
|
|
22
30
|
this.config.controllers = config;
|
|
23
31
|
return this.app;
|
|
24
32
|
}
|
|
33
|
+
audit(config) {
|
|
34
|
+
this.config.i18n = config;
|
|
35
|
+
return this.app;
|
|
36
|
+
}
|
|
25
37
|
compiler(config) {
|
|
26
38
|
this.config.compiler = config;
|
|
27
39
|
return this.app;
|
package/lib/engine/apps/app.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type AppProvider<out Name, T> = {
|
|
|
12
12
|
modules: Record<string, AnyModule>;
|
|
13
13
|
}) => T;
|
|
14
14
|
down: (provider: NoInfer<T>) => any;
|
|
15
|
+
libPaths?: string[];
|
|
15
16
|
};
|
|
16
17
|
export type AnyAppProvider = AppProvider<any, any>;
|
|
17
18
|
export declare abstract class App<S extends $Space, Modules extends string = ModuleName<S> & string, Providers extends Record<string, any> = Record<string, any>> {
|
|
@@ -62,6 +63,7 @@ export declare abstract class App<S extends $Space, Modules extends string = Mod
|
|
|
62
63
|
provider<Name extends string, T>($: AppProvider<Name, T>): App<S, Modules, Providers & { [K in Name]: T; }>;
|
|
63
64
|
get config(): AppConfigFactory<S, Modules, Providers>;
|
|
64
65
|
protected makeModules(): Record<string, AnyModule>;
|
|
66
|
+
static getProviders(app: AnyApp): Record<string, AnyAppProvider>;
|
|
65
67
|
static getInfo(app: AnyApp): {
|
|
66
68
|
spaceModules: (string | number | symbol)[];
|
|
67
69
|
config: AnyAppConfig;
|
package/lib/engine/apps/app.js
CHANGED
|
@@ -3,14 +3,13 @@ import { App, AppProvider } from './app';
|
|
|
3
3
|
import { AnyTrxEngine } from '../transaction/trx_engine';
|
|
4
4
|
import { AnyBuilder, AnyModule, Module } from '../module';
|
|
5
5
|
import { AnyDaemon, Daemon } from '../daemon';
|
|
6
|
+
import { AppConfigFactory } from './app.config';
|
|
6
7
|
export declare class InlineApp<S extends $Space, ModuleNames extends string = ModuleName<S> & string, Providers extends Record<string, any> = Record<string, any>> extends App<S, ModuleNames, Providers> {
|
|
7
8
|
protected _daemon?: Daemon<S, ModuleNames>;
|
|
8
9
|
protected _modules: Record<string, AnyModule>;
|
|
9
10
|
private packageJson?;
|
|
10
|
-
|
|
11
|
+
protected bootPromise?: Promise<void>;
|
|
11
12
|
constructor(name: string, builders: AnyBuilder[]);
|
|
12
|
-
modules<M extends ModuleName<S>>(modules: M[]): InlineApp<S, M & ModuleNames>;
|
|
13
|
-
provider<Name extends string, T>($: AppProvider<Name, T>): InlineApp<S, ModuleNames, Providers & { [K in Name]: T; }>;
|
|
14
13
|
boot(): InlineApp<S, ModuleNames, Providers>;
|
|
15
14
|
/**
|
|
16
15
|
* Treeshake and build modules declared for this application.
|
|
@@ -35,6 +34,9 @@ export declare class InlineApp<S extends $Space, ModuleNames extends string = Mo
|
|
|
35
34
|
* TODO: allow overriding this behavior with adapters
|
|
36
35
|
*/
|
|
37
36
|
protected linkExternals(modules: Record<string, Module<S, $Module>>): void;
|
|
37
|
+
modules<M extends ModuleName<S>>(modules: M[]): InlineApp<S, M & ModuleNames>;
|
|
38
|
+
provider<Name extends string, T>($: AppProvider<Name, T>): InlineApp<S, ModuleNames, Providers & { [K in Name]: T; }>;
|
|
39
|
+
get config(): AppConfigFactory<S, ModuleNames, Providers, typeof this>;
|
|
38
40
|
static package(app: InlineApp<any, any>, scripts: Record<string, string>, dependencies: Record<string, string>): {
|
|
39
41
|
name: string;
|
|
40
42
|
version: string;
|
|
@@ -6,20 +6,12 @@ const log_1 = require("../util/log");
|
|
|
6
6
|
const trx_engine_1 = require("../transaction/trx_engine");
|
|
7
7
|
const tree_1 = require("../tree");
|
|
8
8
|
const daemon_1 = require("../daemon");
|
|
9
|
+
const app_config_1 = require("./app.config");
|
|
9
10
|
class InlineApp extends app_1.App {
|
|
10
11
|
constructor(name, builders) {
|
|
11
12
|
super(name, { builders });
|
|
12
13
|
this._modules = {};
|
|
13
14
|
}
|
|
14
|
-
// Type Builder Overrides
|
|
15
|
-
modules(modules) {
|
|
16
|
-
super.modules(modules);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
provider($) {
|
|
20
|
-
super.provider($);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
15
|
// App abstract methods
|
|
24
16
|
boot() {
|
|
25
17
|
if (!this.bootPromise) {
|
|
@@ -58,13 +50,16 @@ class InlineApp extends app_1.App {
|
|
|
58
50
|
}
|
|
59
51
|
const modules = this._modules;
|
|
60
52
|
for (const key in this._injectedModules) {
|
|
61
|
-
|
|
53
|
+
const mod = this._injectedModules[key];
|
|
54
|
+
modules[mod.name] = mod;
|
|
62
55
|
}
|
|
63
56
|
const providers = {};
|
|
64
57
|
for (const key in this._providers) {
|
|
65
|
-
|
|
58
|
+
const provider = this._providers[key].up({
|
|
66
59
|
modules
|
|
67
60
|
});
|
|
61
|
+
provider.__down = this._providers[key].down;
|
|
62
|
+
providers[key] = provider;
|
|
68
63
|
}
|
|
69
64
|
log_1.Log.debug('app', this.name, 'Starting transaction engines');
|
|
70
65
|
const trxEngines = {};
|
|
@@ -72,7 +67,14 @@ class InlineApp extends app_1.App {
|
|
|
72
67
|
const module = modules[m];
|
|
73
68
|
module.start(this, providers);
|
|
74
69
|
const trxConfig = this._config.trxEngine?.[m];
|
|
75
|
-
|
|
70
|
+
const authn = {};
|
|
71
|
+
for (const a in this._config?.authn || {}) {
|
|
72
|
+
const prov = this._config.authn?.[a]?.();
|
|
73
|
+
if (prov) {
|
|
74
|
+
authn[a] = prov;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
trxEngines[m] = new trx_engine_1.TrxEngine(`app:${this.name}`, module, authn, trxConfig, providers);
|
|
76
78
|
}
|
|
77
79
|
log_1.Log.debug('app', this.name, 'Linking externals');
|
|
78
80
|
this.linkExternals(modules);
|
|
@@ -114,6 +116,7 @@ class InlineApp extends app_1.App {
|
|
|
114
116
|
const buckets = module.schema.externals.buckets;
|
|
115
117
|
Object.values(buckets).forEach(bucket => {
|
|
116
118
|
module.buckets[bucket.refName] = modules[bucket.module].buckets[bucket.name];
|
|
119
|
+
module.nql.linkExternal(modules[bucket.module].buckets[bucket.name]);
|
|
117
120
|
});
|
|
118
121
|
const jobs = module.schema.externals.jobs;
|
|
119
122
|
Object.values(jobs).forEach(job => {
|
|
@@ -125,6 +128,18 @@ class InlineApp extends app_1.App {
|
|
|
125
128
|
});
|
|
126
129
|
});
|
|
127
130
|
}
|
|
131
|
+
// Type Builder Overrides
|
|
132
|
+
modules(modules) {
|
|
133
|
+
super.modules(modules);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
provider($) {
|
|
137
|
+
super.provider($);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
get config() {
|
|
141
|
+
return new app_config_1.AppConfigFactory(this);
|
|
142
|
+
}
|
|
128
143
|
//
|
|
129
144
|
static package(app, scripts, dependencies) {
|
|
130
145
|
return {
|
|
@@ -4,17 +4,19 @@ import { InlineApp } from './../inline.app';
|
|
|
4
4
|
import { AnyTrxEngine } from '../../transaction/trx_engine';
|
|
5
5
|
import { Space } from '../../space';
|
|
6
6
|
import { Daemon } from "../../daemon";
|
|
7
|
+
import { AppConfigFactory } from '../app.config';
|
|
7
8
|
export declare class MonolythApp<S extends $Space, ModuleNames extends string = ModuleName<S> & string, Providers extends Record<string, any> = Record<string, any>> extends InlineApp<S, ModuleNames, Providers> {
|
|
8
9
|
private watcher?;
|
|
9
10
|
constructor(name: string, space?: Space<S>);
|
|
10
11
|
protected _packageJson?: Record<string, any>;
|
|
11
|
-
modules<M extends ModuleName<S>>(modules: M[]): MonolythApp<S, M & ModuleNames>;
|
|
12
|
-
provider<Name extends string, T>($: AppProvider<Name, T>): MonolythApp<S, ModuleNames, Providers & { [K in Name]: T; }>;
|
|
13
12
|
daemon($?: {
|
|
14
13
|
watch?: boolean;
|
|
15
14
|
}): Promise<Daemon<S, ModuleNames>>;
|
|
16
15
|
protected makeDaemon(trxEngines: Record<ModuleNames, AnyTrxEngine>, providers: Record<string, any>): MonolythDaemon<$Space, ModuleNames>;
|
|
17
16
|
remake(): Promise<void>;
|
|
17
|
+
modules<M extends ModuleName<S>>(modules: M[]): MonolythApp<S, M & ModuleNames>;
|
|
18
|
+
provider<Name extends string, T>($: AppProvider<Name, T>): MonolythApp<S, ModuleNames, Providers & { [K in Name]: T; }>;
|
|
19
|
+
get config(): AppConfigFactory<S, ModuleNames, Providers, typeof this>;
|
|
18
20
|
}
|
|
19
21
|
export declare class MonolythDaemon<S extends $Space, Modules extends ModuleName<S>> extends Daemon<S, Modules> {
|
|
20
22
|
}
|
|
@@ -38,21 +38,13 @@ const inline_app_1 = require("./../inline.app");
|
|
|
38
38
|
const space_1 = require("../../space");
|
|
39
39
|
const daemon_1 = require("../../daemon");
|
|
40
40
|
const log_1 = require("../../util/log");
|
|
41
|
+
const app_config_1 = require("../app.config");
|
|
41
42
|
class MonolythApp extends inline_app_1.InlineApp {
|
|
42
43
|
constructor(name, space) {
|
|
43
44
|
super(name, []);
|
|
44
45
|
this.builders = undefined;
|
|
45
46
|
this.space = space;
|
|
46
47
|
}
|
|
47
|
-
// Type Builder Overrides
|
|
48
|
-
modules(modules) {
|
|
49
|
-
super.modules(modules);
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
provider($) {
|
|
53
|
-
super.provider($);
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
48
|
// Override InlineApp abstract methods
|
|
57
49
|
async daemon($) {
|
|
58
50
|
/**
|
|
@@ -65,7 +57,13 @@ class MonolythApp extends inline_app_1.InlineApp {
|
|
|
65
57
|
*/
|
|
66
58
|
if (this.space && $?.watch) {
|
|
67
59
|
Promise.resolve().then(() => __importStar(require('chokidar'))).then(({ default: chokidar }) => {
|
|
68
|
-
this.watcher = chokidar.watch(space_1.Space.path(this.space,
|
|
60
|
+
this.watcher = chokidar.watch(space_1.Space.path(this.space), {
|
|
61
|
+
ignored: [
|
|
62
|
+
space_1.Space.path(this.space, 'node_modules'),
|
|
63
|
+
space_1.Space.path(this.space, '.nesoi'),
|
|
64
|
+
space_1.Space.path(this.space, 'build')
|
|
65
|
+
]
|
|
66
|
+
}); // TODO: change to .
|
|
69
67
|
this.watcher
|
|
70
68
|
.on('change', () => {
|
|
71
69
|
this.remake();
|
|
@@ -84,9 +82,23 @@ class MonolythApp extends inline_app_1.InlineApp {
|
|
|
84
82
|
log_1.Log.error('app', 'monolyth', `Attempt to remake app ${this.name} failed: Daemon not running.`);
|
|
85
83
|
return;
|
|
86
84
|
}
|
|
85
|
+
await daemon_1.Daemon.destroy(this._daemon);
|
|
86
|
+
this.bootPromise = undefined;
|
|
87
87
|
const app = await this.make();
|
|
88
88
|
await daemon_1.Daemon.reload(this._daemon, app.trxEngines, app.providers);
|
|
89
89
|
}
|
|
90
|
+
// Type Builder Overrides
|
|
91
|
+
modules(modules) {
|
|
92
|
+
super.modules(modules);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
provider($) {
|
|
96
|
+
super.provider($);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
get config() {
|
|
100
|
+
return new app_config_1.AppConfigFactory(this);
|
|
101
|
+
}
|
|
90
102
|
}
|
|
91
103
|
exports.MonolythApp = MonolythApp;
|
|
92
104
|
class MonolythDaemon extends daemon_1.Daemon {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NesoiObjId } from '../data/obj';
|
|
2
|
+
import { AnyTrxNode } from '../transaction/trx_node';
|
|
2
3
|
export type User = {
|
|
3
4
|
id: NesoiObjId;
|
|
4
5
|
[x: string]: any;
|
|
@@ -8,7 +9,10 @@ export type AuthnRequest<P extends keyof any> = {
|
|
|
8
9
|
[K in P]?: AuthnToken;
|
|
9
10
|
};
|
|
10
11
|
export declare abstract class AuthnProvider<U extends User> {
|
|
11
|
-
abstract authenticate(
|
|
12
|
+
abstract authenticate($: {
|
|
13
|
+
trx: AnyTrxNode;
|
|
14
|
+
token: AuthnToken;
|
|
15
|
+
}): Promise<U>;
|
|
12
16
|
}
|
|
13
17
|
export type AnyAuthnProviders = {
|
|
14
18
|
[K: string]: AuthnProvider<any>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { NesoiObjId } from '../data/obj';
|
|
2
|
-
import { AuthnProvider
|
|
2
|
+
import { AuthnProvider } from './authn';
|
|
3
3
|
type ZeroUser = {
|
|
4
4
|
id: NesoiObjId;
|
|
5
5
|
name: string;
|
|
6
6
|
};
|
|
7
7
|
export declare class ZeroAuthnProvider extends AuthnProvider<ZeroUser> {
|
|
8
|
-
authenticate(
|
|
8
|
+
authenticate($: {
|
|
9
|
+
token: string;
|
|
10
|
+
}): Promise<{
|
|
9
11
|
id: number;
|
|
10
12
|
name: string;
|
|
11
13
|
}>;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZeroAuthnProvider = void 0;
|
|
4
4
|
const authn_1 = require("./authn");
|
|
5
5
|
class ZeroAuthnProvider extends authn_1.AuthnProvider {
|
|
6
|
-
|
|
6
|
+
authenticate($) {
|
|
7
7
|
return Promise.resolve({
|
|
8
8
|
id: 0,
|
|
9
|
-
name:
|
|
9
|
+
name: $.token
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
}
|
package/lib/engine/cli/cli.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export declare class CLI {
|
|
|
11
11
|
private app;
|
|
12
12
|
private ctx;
|
|
13
13
|
private adapters;
|
|
14
|
+
private input;
|
|
14
15
|
constructor(daemon: AnyDaemon, config?: CLIConfig<any> | undefined);
|
|
15
|
-
run(): Promise<void>;
|
|
16
|
+
run(cmd?: string): Promise<void>;
|
|
16
17
|
private runCmd;
|
|
17
18
|
private cmdHelp;
|
|
18
19
|
private cmdClear;
|
|
20
|
+
private getCmds;
|
|
19
21
|
}
|
package/lib/engine/cli/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ const ui_1 = __importDefault(require("./ui"));
|
|
|
9
9
|
const console_1 = __importDefault(require("../util/console"));
|
|
10
10
|
const daemon_1 = require("../daemon");
|
|
11
11
|
const log_1 = require("../util/log");
|
|
12
|
+
const cli_input_1 = require("./cli_input");
|
|
12
13
|
class CLI {
|
|
13
14
|
constructor(daemon, config) {
|
|
14
15
|
this.daemon = daemon;
|
|
@@ -22,13 +23,20 @@ class CLI {
|
|
|
22
23
|
this.adapters[key] = val(daemon_1.Daemon.get(daemon, 'providers'));
|
|
23
24
|
this.adapters[key].name = key;
|
|
24
25
|
});
|
|
26
|
+
this.input = new cli_input_1.CLIInputHandler(this.getCmds());
|
|
25
27
|
}
|
|
26
|
-
async run() {
|
|
28
|
+
async run(cmd) {
|
|
29
|
+
if (cmd) {
|
|
30
|
+
this.runCmd(cmd);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
27
33
|
console_1.default.header('CLI');
|
|
28
34
|
// eslint-disable-next-line no-constant-condition
|
|
29
35
|
while (true) {
|
|
30
36
|
const ctx = `${(0, string_1.colored)(this.app, 'darkgray')}:${(0, string_1.colored)(this.ctx, 'lightcyan')}${(0, string_1.colored)('$', 'brown')}`;
|
|
31
|
-
const cmd = await
|
|
37
|
+
const cmd = await this.input.input(ctx);
|
|
38
|
+
if (!cmd)
|
|
39
|
+
continue;
|
|
32
40
|
try {
|
|
33
41
|
if (await this.runCmd(cmd)) {
|
|
34
42
|
break;
|
|
@@ -66,7 +74,7 @@ class CLI {
|
|
|
66
74
|
return false;
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
|
-
ui_1.default.error(
|
|
77
|
+
ui_1.default.error(`Invalid command '${payload}'`);
|
|
70
78
|
return false;
|
|
71
79
|
}
|
|
72
80
|
cmdHelp() {
|
|
@@ -84,5 +92,16 @@ class CLI {
|
|
|
84
92
|
async cmdClear() {
|
|
85
93
|
console.clear();
|
|
86
94
|
}
|
|
95
|
+
getCmds() {
|
|
96
|
+
const cmds = [];
|
|
97
|
+
for (const a in this.adapters) {
|
|
98
|
+
const adapter = this.adapters[a];
|
|
99
|
+
for (const c in adapter.commands) {
|
|
100
|
+
const command = adapter.commands[c];
|
|
101
|
+
cmds.push(adapter.name + ' ' + command.name);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return cmds;
|
|
105
|
+
}
|
|
87
106
|
}
|
|
88
107
|
exports.CLI = CLI;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AnyDaemon } from '../daemon';
|
|
2
2
|
export declare abstract class CLICommand<T extends Record<string, any> = Record<string, any>> {
|
|
3
|
+
scope: 'dev' | 'prod' | 'any';
|
|
3
4
|
name: string;
|
|
4
5
|
syntax: string;
|
|
5
6
|
description: string;
|
|
6
7
|
regex?: RegExp | undefined;
|
|
7
8
|
groups?: string[] | undefined;
|
|
8
|
-
constructor(name: string, syntax: string, description: string, regex?: RegExp | undefined, groups?: string[] | undefined);
|
|
9
|
+
constructor(scope: 'dev' | 'prod' | 'any', name: string, syntax: string, description: string, regex?: RegExp | undefined, groups?: string[] | undefined);
|
|
9
10
|
input(payload: string): Record<string, any>;
|
|
10
11
|
abstract run(daemon: AnyDaemon, input: T): Promise<void>;
|
|
11
12
|
}
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CLIAdapter = exports.CLICommand = void 0;
|
|
4
4
|
const string_1 = require("../util/string");
|
|
5
5
|
class CLICommand {
|
|
6
|
-
constructor(name, syntax, description, regex, groups) {
|
|
6
|
+
constructor(scope, name, syntax, description, regex, groups) {
|
|
7
|
+
this.scope = scope;
|
|
7
8
|
this.name = name;
|
|
8
9
|
this.syntax = syntax;
|
|
9
10
|
this.description = description;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class CLIInputHandler {
|
|
2
|
+
private suggestions;
|
|
3
|
+
private items;
|
|
4
|
+
private history;
|
|
5
|
+
private buffer;
|
|
6
|
+
private cursor;
|
|
7
|
+
private suggestion?;
|
|
8
|
+
constructor(suggestions?: string[]);
|
|
9
|
+
/**
|
|
10
|
+
* Wait for user input:
|
|
11
|
+
* - Some text + Enter
|
|
12
|
+
* - Special Keys: Up/Down/Tab
|
|
13
|
+
*/
|
|
14
|
+
input(ctx?: string): Promise<string | undefined>;
|
|
15
|
+
add(item: string): void;
|
|
16
|
+
up(): string | undefined;
|
|
17
|
+
down(): string | undefined;
|
|
18
|
+
suggest(_seed: string): string;
|
|
19
|
+
}
|