nesoi 3.2.9 → 3.3.1
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 +33 -2
- package/lib/bundler/browser/browser.app.d.ts +32 -0
- package/lib/bundler/browser/browser.app.js +51 -0
- package/lib/bundler/browser/browser.bundler.d.ts +5 -0
- package/lib/bundler/browser/browser.bundler.js +27 -0
- package/lib/bundler/browser/stages/8_replace_nesoi_for_browser_stage.d.ts +13 -0
- package/lib/bundler/browser/stages/8_replace_nesoi_for_browser_stage.js +74 -0
- package/lib/bundler/distributed/distributed.app.config.d.ts +43 -0
- package/lib/{engine/apps → bundler}/distributed/distributed.app.config.js +1 -1
- package/lib/{engine/apps → bundler}/distributed/distributed.app.d.ts +14 -14
- package/lib/{engine/apps → bundler}/distributed/distributed.app.js +8 -3
- package/lib/{compiler/apps/distributed/distributed_compiler.d.ts → bundler/distributed/distributed.bundler.d.ts} +7 -7
- package/lib/{compiler/apps/distributed/distributed_compiler.js → bundler/distributed/distributed.bundler.js} +11 -11
- package/lib/{engine/apps → bundler}/distributed/distributed_node.app.d.ts +14 -20
- package/lib/{engine/apps → bundler}/distributed/distributed_node.app.js +18 -50
- package/lib/bundler/distributed/stages/1_mkdir_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/distributed/stages/1_mkdir_stage.js +6 -6
- package/lib/bundler/distributed/stages/2_build_typescript_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/distributed/stages/2_build_typescript_stage.js +7 -7
- package/lib/bundler/distributed/stages/3_copy_types_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/distributed/stages/3_copy_types_stage.js +7 -7
- package/lib/bundler/distributed/stages/4_dump_modules_stage.d.ts +16 -0
- package/lib/{compiler/apps → bundler}/distributed/stages/4_dump_modules_stage.js +5 -5
- package/lib/{compiler/apps → bundler}/distributed/stages/5_copy_static_stage.js +3 -3
- package/lib/{compiler/apps → bundler}/distributed/stages/6_dump_cli_stage.js +3 -3
- package/lib/{compiler/apps → bundler}/distributed/stages/7_dump_package_json_stage.js +3 -3
- package/lib/{engine/apps → bundler}/monolyth/monolyth.app.d.ts +13 -13
- package/lib/{engine/apps → bundler}/monolyth/monolyth.app.js +13 -10
- package/lib/{compiler/apps/monolyth/monolyth_compiler.d.ts → bundler/monolyth/monolyth.bundler.d.ts} +9 -7
- package/lib/{compiler/apps/monolyth/monolyth_compiler.js → bundler/monolyth/monolyth.bundler.js} +13 -12
- package/lib/bundler/monolyth/stages/1_mkdir_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/monolyth/stages/1_mkdir_stage.js +6 -6
- package/lib/bundler/monolyth/stages/2_build_typescript_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/monolyth/stages/2_build_typescript_stage.js +8 -7
- package/lib/bundler/monolyth/stages/3_copy_types_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/monolyth/stages/3_copy_types_stage.js +7 -7
- package/lib/{compiler/apps → bundler}/monolyth/stages/4_dump_modules_stage.d.ts +4 -4
- package/lib/{compiler/apps → bundler}/monolyth/stages/4_dump_modules_stage.js +29 -16
- package/lib/{compiler/apps → bundler}/monolyth/stages/5_copy_static_stage.d.ts +4 -4
- package/lib/{compiler/apps → bundler}/monolyth/stages/5_copy_static_stage.js +7 -7
- package/lib/bundler/monolyth/stages/6_dump_cli_stage.d.ts +15 -0
- package/lib/{compiler/apps → bundler}/monolyth/stages/6_dump_cli_stage.js +4 -4
- package/lib/{compiler/apps → bundler}/monolyth/stages/7_dump_package_json_stage.d.ts +4 -4
- package/lib/{compiler/apps → bundler}/monolyth/stages/7_dump_package_json_stage.js +14 -11
- package/lib/compiler/compiler.d.ts +1 -6
- package/lib/compiler/compiler.js +1 -1
- package/lib/compiler/elements/bucket.element.d.ts +2 -1
- package/lib/compiler/elements/bucket.element.js +16 -21
- package/lib/compiler/elements/cached.element.d.ts +1 -1
- package/lib/compiler/elements/cached.element.js +2 -2
- package/lib/compiler/elements/constants.element.d.ts +1 -1
- package/lib/compiler/elements/constants.element.js +2 -0
- package/lib/compiler/elements/controller.element.js +3 -3
- package/lib/compiler/elements/element.d.ts +6 -13
- package/lib/compiler/elements/element.js +11 -9
- package/lib/compiler/elements/externals.element.js +2 -2
- package/lib/compiler/elements/job.element.d.ts +1 -1
- package/lib/compiler/elements/job.element.js +1 -1
- package/lib/compiler/elements/machine.element.d.ts +2 -2
- package/lib/compiler/elements/machine.element.js +7 -7
- package/lib/compiler/elements/message.element.d.ts +1 -1
- package/lib/compiler/elements/message.element.js +26 -26
- package/lib/compiler/elements/queue.element.js +1 -1
- package/lib/compiler/elements/resource.element.d.ts +1 -1
- package/lib/compiler/elements/resource.element.js +9 -9
- package/lib/compiler/elements/topic.element.js +1 -1
- package/lib/compiler/error.d.ts +1 -5
- package/lib/compiler/error.js +3 -15
- package/lib/compiler/helpers/dump_helpers.d.ts +1 -1
- package/lib/compiler/helpers/dump_helpers.js +1 -1
- package/lib/compiler/index.d.ts +1 -3
- package/lib/compiler/index.js +15 -7
- package/lib/compiler/module.js +12 -12
- package/lib/compiler/progressive.d.ts +3 -4
- package/lib/compiler/progressive.js +3 -4
- package/lib/compiler/stages/2_treeshake_stage.js +4 -0
- package/lib/compiler/stages/3_extract_ts_stage.js +7 -7
- package/lib/compiler/stages/4_build_schemas_stage.js +3 -16
- package/lib/compiler/stages/6_build_elements_stage.js +1 -1
- package/lib/compiler/stages/7_dump_stage.js +35 -10
- package/lib/compiler/typescript/bridge/extract.js +24 -0
- package/lib/compiler/typescript/bridge/inject.js +18 -3
- package/lib/compiler/typescript/bridge/organize.d.ts +4 -0
- package/lib/compiler/typescript/bridge/organize.js +41 -22
- package/lib/compiler/typescript/error.d.ts +2 -83
- package/lib/compiler/typescript/error.js +6 -219
- package/lib/compiler/typescript/parser.js +3 -3
- package/lib/compiler/typescript/source.d.ts +2 -2
- package/lib/compiler/typescript/transformers/app_inject.transformer.js +13 -4
- package/lib/compiler/typescript/typescript_compiler.d.ts +3 -3
- package/lib/compiler/typescript/typescript_compiler.js +2 -2
- package/lib/elements/blocks/block.builder.d.ts +7 -4
- package/lib/elements/blocks/block.builder.js +24 -13
- package/lib/elements/blocks/block.js +2 -2
- package/lib/elements/blocks/block.schema.d.ts +12 -9
- package/lib/elements/blocks/block.schema.js +2 -2
- package/lib/elements/blocks/job/internal/machine_job.builder.d.ts +6 -5
- package/lib/elements/blocks/job/internal/machine_job.builder.js +3 -3
- package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +11 -10
- package/lib/elements/blocks/job/internal/resource_job.builder.js +9 -6
- package/lib/elements/blocks/job/internal/resource_job.js +3 -6
- package/lib/elements/blocks/job/job.builder.d.ts +5 -5
- package/lib/elements/blocks/job/job.builder.js +7 -7
- package/lib/elements/blocks/job/job.js +1 -1
- package/lib/elements/blocks/job/job.schema.d.ts +5 -5
- package/lib/elements/blocks/job/job.schema.js +3 -3
- package/lib/elements/blocks/machine/machine.builder.d.ts +2 -2
- package/lib/elements/blocks/machine/machine.builder.js +12 -9
- package/lib/elements/blocks/machine/machine.js +7 -7
- package/lib/elements/blocks/machine/machine.schema.d.ts +23 -23
- package/lib/elements/blocks/machine/machine.schema.js +9 -9
- package/lib/elements/blocks/machine/machine_state.builder.d.ts +1 -0
- package/lib/elements/blocks/machine/machine_state.builder.js +31 -29
- package/lib/elements/blocks/machine/machine_transition.builder.d.ts +2 -2
- package/lib/elements/blocks/machine/machine_transition.builder.js +8 -8
- package/lib/elements/blocks/queue/queue.builder.d.ts +3 -3
- package/lib/elements/blocks/queue/queue.builder.js +3 -3
- package/lib/elements/blocks/queue/queue.schema.d.ts +6 -6
- package/lib/elements/blocks/queue/queue.schema.js +3 -3
- package/lib/elements/blocks/resource/resource.builder.d.ts +2 -2
- package/lib/elements/blocks/resource/resource.builder.js +37 -40
- package/lib/elements/blocks/resource/resource.d.ts +2 -2
- package/lib/elements/blocks/resource/resource.js +10 -18
- package/lib/elements/blocks/resource/resource.schema.d.ts +15 -15
- package/lib/elements/blocks/resource/resource.schema.js +8 -8
- package/lib/elements/blocks/topic/topic.builder.d.ts +2 -2
- package/lib/elements/blocks/topic/topic.builder.js +4 -4
- package/lib/elements/blocks/topic/topic.d.ts +2 -2
- package/lib/elements/blocks/topic/topic.js +7 -7
- package/lib/elements/blocks/topic/topic.schema.d.ts +6 -6
- package/lib/elements/blocks/topic/topic.schema.js +3 -3
- package/lib/elements/edge/controller/adapters/cli.controller_adapter.js +1 -1
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +2 -2
- package/lib/elements/edge/controller/adapters/controller_adapter.js +2 -2
- package/lib/elements/edge/controller/controller.builder.d.ts +14 -13
- package/lib/elements/edge/controller/controller.builder.js +52 -42
- package/lib/elements/edge/controller/controller.d.ts +3 -3
- package/lib/elements/edge/controller/controller.js +12 -12
- package/lib/elements/edge/controller/controller.schema.d.ts +17 -16
- package/lib/elements/edge/controller/controller.schema.js +11 -11
- package/lib/elements/edge/externals/externals.builder.d.ts +8 -13
- package/lib/elements/edge/externals/externals.builder.js +43 -11
- package/lib/elements/edge/externals/externals.schema.d.ts +8 -7
- package/lib/elements/edge/externals/externals.schema.js +5 -3
- package/lib/elements/entities/bucket/adapters/browserdb.bucket_adapter.d.ts +45 -0
- package/lib/elements/entities/bucket/adapters/browserdb.bucket_adapter.js +164 -0
- package/lib/elements/entities/bucket/adapters/browserdb.service.d.ts +30 -0
- package/lib/elements/entities/bucket/adapters/browserdb.service.js +97 -0
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +6 -1
- package/lib/elements/entities/bucket/adapters/bucket_adapter.js +7 -6
- package/lib/elements/entities/bucket/adapters/json.bucket_adapter.d.ts +1 -1
- package/lib/elements/entities/bucket/adapters/json.bucket_adapter.js +1 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +1 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +14 -13
- package/lib/elements/entities/bucket/adapters/memory.nql.js +41 -35
- package/lib/elements/entities/bucket/bucket.builder.d.ts +6 -8
- package/lib/elements/entities/bucket/bucket.builder.js +19 -34
- package/lib/elements/entities/bucket/bucket.d.ts +2 -2
- package/lib/elements/entities/bucket/bucket.infer.d.ts +5 -5
- package/lib/elements/entities/bucket/bucket.js +19 -17
- package/lib/elements/entities/bucket/bucket.schema.d.ts +3 -3
- package/lib/elements/entities/bucket/bucket.schema.js +2 -2
- package/lib/elements/entities/bucket/cache/bucket_cache.js +14 -2
- package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +3 -3
- package/lib/elements/entities/bucket/graph/bucket_graph.js +101 -29
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.d.ts +3 -3
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +2 -2
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.js +5 -3
- package/lib/elements/entities/bucket/model/bucket_model.builder.d.ts +2 -1
- package/lib/elements/entities/bucket/model/bucket_model.builder.js +2 -2
- package/lib/elements/entities/bucket/model/bucket_model.convert.js +3 -6
- package/lib/elements/entities/bucket/model/bucket_model.d.ts +13 -0
- package/lib/elements/entities/bucket/model/bucket_model.js +93 -0
- package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +4 -8
- package/lib/elements/entities/bucket/model/bucket_model.schema.js +0 -68
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +12 -4
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +30 -33
- package/lib/elements/entities/bucket/query/nql.schema.d.ts +1 -1
- package/lib/elements/entities/bucket/query/nql_compiler.d.ts +8 -4
- package/lib/elements/entities/bucket/query/nql_compiler.js +44 -38
- package/lib/elements/entities/bucket/query/nql_engine.d.ts +1 -1
- package/lib/elements/entities/bucket/query/nql_engine.js +5 -2
- package/lib/elements/entities/bucket/view/bucket_view.builder.d.ts +2 -2
- package/lib/elements/entities/bucket/view/bucket_view.js +113 -81
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +9 -8
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +8 -10
- package/lib/elements/entities/constants/constants.builder.d.ts +3 -3
- package/lib/elements/entities/constants/constants.builder.js +8 -8
- package/lib/elements/entities/constants/constants.schema.d.ts +8 -3
- package/lib/elements/entities/constants/constants.schema.js +7 -2
- package/lib/elements/entities/message/message.infer.d.ts +1 -5
- package/lib/elements/entities/message/message.js +2 -7
- package/lib/elements/entities/message/message.schema.js +1 -1
- package/lib/elements/entities/message/template/message_template.schema.d.ts +7 -5
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +18 -3
- package/lib/elements/entities/message/template/message_template_field.builder.js +49 -30
- package/lib/elements/entities/message/template/message_template_parser.js +2 -2
- package/lib/engine/{apps → app}/app.config.d.ts +11 -5
- package/lib/engine/{apps → app}/app.config.js +2 -2
- package/lib/engine/{apps → app}/app.d.ts +3 -2
- package/lib/engine/{apps → app}/app.js +3 -1
- package/lib/engine/{apps/distributed → app}/inc/inc.client.js +1 -1
- package/lib/engine/{apps/distributed → app}/inc/inc.server.js +3 -3
- package/lib/engine/{apps/distributed → app}/inc/sandbox.js +1 -1
- package/lib/engine/{apps → app}/inline.app.d.ts +2 -12
- package/lib/engine/{apps → app}/inline.app.js +37 -34
- package/lib/engine/auth/authn.d.ts +10 -12
- package/lib/engine/auth/zero.authn_provider.d.ts +3 -4
- package/lib/engine/auth/zero.authn_provider.js +0 -1
- package/lib/engine/builder.d.ts +28 -0
- package/lib/engine/builder.js +99 -0
- package/lib/engine/cli/cli.js +3 -2
- package/lib/engine/cli/ui.js +1 -0
- package/lib/engine/daemon.d.ts +28 -25
- package/lib/engine/daemon.js +37 -8
- package/lib/engine/data/error.d.ts +37 -3
- package/lib/engine/data/error.js +58 -16
- package/lib/engine/data/file.d.ts +1 -0
- package/lib/engine/data/file.js +4 -0
- package/lib/engine/dependency.d.ts +53 -81
- package/lib/engine/dependency.js +246 -120
- package/lib/engine/module.d.ts +18 -48
- package/lib/engine/module.js +78 -158
- package/lib/engine/space.d.ts +2 -2
- package/lib/engine/space.js +6 -6
- package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +7 -4
- package/lib/engine/transaction/nodes/bucket.trx_node.js +66 -43
- package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +10 -4
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +56 -45
- package/lib/engine/transaction/nodes/external.trx_node.d.ts +15 -0
- package/lib/engine/transaction/nodes/external.trx_node.js +53 -0
- package/lib/engine/transaction/nodes/job.trx_node.d.ts +7 -3
- package/lib/engine/transaction/nodes/job.trx_node.js +49 -29
- package/lib/engine/transaction/nodes/machine.trx_node.js +6 -6
- package/lib/engine/transaction/nodes/queue.trx_node.js +3 -3
- package/lib/engine/transaction/nodes/resource.trx_node.d.ts +7 -4
- package/lib/engine/transaction/nodes/resource.trx_node.js +68 -51
- package/lib/engine/transaction/nodes/topic.trx_node.js +9 -9
- package/lib/engine/transaction/trx.d.ts +15 -12
- package/lib/engine/transaction/trx.js +19 -3
- package/lib/engine/transaction/trx_engine.config.d.ts +4 -4
- package/lib/engine/transaction/trx_engine.d.ts +25 -7
- package/lib/engine/transaction/trx_engine.js +67 -16
- package/lib/engine/transaction/trx_node.d.ts +25 -21
- package/lib/engine/transaction/trx_node.js +99 -57
- package/lib/engine/tree.d.ts +4 -16
- package/lib/engine/tree.js +87 -57
- package/lib/{compiler → engine}/treeshake.d.ts +32 -32
- package/lib/{compiler → engine}/treeshake.js +272 -242
- package/lib/engine/util/console.js +3 -0
- package/lib/engine/util/crypto.d.ts +4 -3
- package/lib/engine/util/crypto.js +15 -5
- package/lib/engine/util/hash.js +5 -0
- package/lib/engine/util/log.d.ts +6 -8
- package/lib/engine/util/log.js +1 -1
- package/lib/engine/util/name_helpers.d.ts +37 -0
- package/lib/{compiler/helpers → engine/util}/name_helpers.js +33 -0
- package/lib/engine/util/parse.d.ts +4 -3
- package/lib/engine/util/parse.js +13 -28
- package/lib/engine/util/path.d.ts +1 -0
- package/lib/engine/util/path.js +14 -0
- package/lib/engine/util/random.d.ts +4 -0
- package/lib/engine/util/random.js +31 -0
- package/lib/engine/util/type.d.ts +8 -0
- package/lib/schema.d.ts +1 -1
- package/package.json +4 -1
- package/tools/joaquin/bucket.js +1 -1
- package/tools/joaquin/job.js +1 -1
- package/tools/joaquin/message.js +1 -1
- package/tools/joaquin/mock.js +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/compiler/apps/distributed/stages/1_mkdir_stage.d.ts +0 -15
- package/lib/compiler/apps/distributed/stages/2_build_typescript_stage.d.ts +0 -15
- package/lib/compiler/apps/distributed/stages/3_copy_types_stage.d.ts +0 -15
- package/lib/compiler/apps/distributed/stages/4_dump_modules_stage.d.ts +0 -16
- package/lib/compiler/apps/monolyth/stages/1_mkdir_stage.d.ts +0 -15
- package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.d.ts +0 -15
- package/lib/compiler/apps/monolyth/stages/3_copy_types_stage.d.ts +0 -15
- package/lib/compiler/apps/monolyth/stages/6_dump_cli_stage.d.ts +0 -15
- package/lib/compiler/helpers/name_helpers.d.ts +0 -20
- package/lib/engine/apps/distributed/distributed.app.config.d.ts +0 -44
- package/lib/engine/apps/distributed/elements/distributed_job.d.ts +0 -7
- package/lib/engine/apps/distributed/elements/distributed_job.js +0 -11
- /package/lib/{compiler/apps → bundler}/distributed/stages/5_copy_static_stage.d.ts +0 -0
- /package/lib/{compiler/apps → bundler}/distributed/stages/6_dump_cli_stage.d.ts +0 -0
- /package/lib/{compiler/apps → bundler}/distributed/stages/7_dump_package_json_stage.d.ts +0 -0
- /package/lib/engine/{apps/distributed → app}/inc/inc.client.d.ts +0 -0
- /package/lib/engine/{apps/distributed → app}/inc/inc.server.d.ts +0 -0
- /package/lib/engine/{apps/distributed → app}/inc/sandbox.d.ts +0 -0
- /package/lib/engine/{apps → app}/service.d.ts +0 -0
- /package/lib/engine/{apps → app}/service.js +0 -0
package/README.md
CHANGED
|
@@ -3,8 +3,39 @@ Zero-dependency Typescript framework for data-driven applications.
|
|
|
3
3
|
|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
> :warning: This is a work-in-progress.
|
|
6
|
+
> :warning: This is a work-in-progress. Use it with caution.
|
|
7
|
+
|
|
8
|
+
## Introduction
|
|
9
|
+
|
|
10
|
+
**nesoi** is a framework which makes it easy to implement data operations (crud, query, hidrate), jobs (synchronous or asynchronous), statecharts, queues, topics and controllers.
|
|
11
|
+
|
|
12
|
+
It does so through a _"builder-schema-element"_ paradigm, where you use _builders_ to declare _schemas_. Such _schemas_ are used by the _engine_ to build _elements_, which are runtime objects that perform actions inside _transactions_.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
> `Builder` _-builds->_ `Schema` _-configures->_ `Element`
|
|
16
|
+
|
|
17
|
+
This paradigm allows declaring _modules_, which groups schemas into developer-chosen scopes. Such _modules_ are then used to declare _apps_, which are bundled ECMAScript (JS) applications.
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
modules/
|
|
21
|
+
module1/
|
|
22
|
+
...elements...
|
|
23
|
+
module2/
|
|
24
|
+
...elements...
|
|
25
|
+
apps/
|
|
26
|
+
app1
|
|
27
|
+
app2
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
When declaring an _app_, you plug _adapters_ into the _elements_, which allows them to interact with external aspects of your application, such as databases and topics. This means the schemas are agnostic and plural, allowing adapters to be changed without friction.
|
|
31
|
+
|
|
32
|
+
> A particular great feature of using _adapters_ for data sources - _buckets_ - is that queries can be performed accross different types of storage with a consistent syntax: NQL.
|
|
33
|
+
|
|
34
|
+
It offers a powerful engine for developing cloud or in-browser applications, and a robust plugin system for extending it's functionalities.
|
|
35
|
+
|
|
36
|
+
It also allows building and testing modules in isolation, then bundling them into different architectures.
|
|
7
37
|
|
|
8
38
|
## Getting Started
|
|
9
39
|
|
|
10
|
-
|
|
40
|
+
- [Hands-On Guide](/docs/HANDS-ON.md): A quick practical read with a lot of examples.
|
|
41
|
+
- [Project Template](https://github.com/nesoi-org/nesoi-meta/tree/main/template): A minimal template for building a project with _nesoi_.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { $Space, ModuleName } from "../../schema";
|
|
2
|
+
import { MonolythDaemon } from '../monolyth/monolyth.app';
|
|
3
|
+
import { Compiler } from "../../compiler/compiler";
|
|
4
|
+
import { MonolythBundlerConfig } from "../monolyth/monolyth.bundler";
|
|
5
|
+
import { AppConfigBuilder } from "../../engine/app/app.config";
|
|
6
|
+
import { InlineApp } from "../../engine/app/inline.app";
|
|
7
|
+
import { IService } from "../../engine/app/service";
|
|
8
|
+
import { Space } from "../../engine/space";
|
|
9
|
+
import { AnyTrxEngine } from "../../engine/transaction/trx_engine";
|
|
10
|
+
/**
|
|
11
|
+
* @category App
|
|
12
|
+
* @subcategory Browser
|
|
13
|
+
*/
|
|
14
|
+
export declare class BrowserApp<S extends $Space, ModuleNames extends string = ModuleName<S> & string, Services extends Record<string, any> = Record<string, any>> extends InlineApp<S, ModuleNames, Services> {
|
|
15
|
+
protected _nesoiNpmPkg: string;
|
|
16
|
+
constructor(name: string, space?: Space<S>);
|
|
17
|
+
protected _packageJson?: Record<string, any>;
|
|
18
|
+
static bundle(compiler: Compiler, appPath: string, config?: MonolythBundlerConfig): Promise<void>;
|
|
19
|
+
daemon($?: {
|
|
20
|
+
watch?: boolean;
|
|
21
|
+
}): Promise<import("../../engine/daemon").Daemon<S, ModuleNames>>;
|
|
22
|
+
protected makeDaemon(trxEngines: Record<ModuleNames, AnyTrxEngine>, services: Record<string, IService>): BrowserDaemon<$Space, ModuleNames>;
|
|
23
|
+
modules<M extends ModuleName<S>>(modules: M[]): BrowserApp<S, M & ModuleNames>;
|
|
24
|
+
service<T extends IService>($: T): BrowserApp<S, ModuleNames, Services & { [K in T["name"]]: T; }>;
|
|
25
|
+
get config(): AppConfigBuilder<S, ModuleNames, Services, typeof this>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @category App
|
|
29
|
+
* @subcategory Browser
|
|
30
|
+
*/
|
|
31
|
+
export declare class BrowserDaemon<S extends $Space, Modules extends ModuleName<S>> extends MonolythDaemon<S, Modules> {
|
|
32
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserDaemon = exports.BrowserApp = void 0;
|
|
4
|
+
const monolyth_app_1 = require("../monolyth/monolyth.app");
|
|
5
|
+
const browser_bundler_1 = require("./browser.bundler");
|
|
6
|
+
const app_config_1 = require("../../engine/app/app.config");
|
|
7
|
+
const inline_app_1 = require("../../engine/app/inline.app");
|
|
8
|
+
/**
|
|
9
|
+
* @category App
|
|
10
|
+
* @subcategory Browser
|
|
11
|
+
*/
|
|
12
|
+
class BrowserApp extends inline_app_1.InlineApp {
|
|
13
|
+
constructor(name, space) {
|
|
14
|
+
super(name, []);
|
|
15
|
+
this._nesoiNpmPkg = '@nesoi/for-browser';
|
|
16
|
+
this.builders = undefined;
|
|
17
|
+
this.space = space;
|
|
18
|
+
}
|
|
19
|
+
//
|
|
20
|
+
static bundle(compiler, appPath, config) {
|
|
21
|
+
return new browser_bundler_1.BrowserBundler(compiler, appPath, config)
|
|
22
|
+
.run();
|
|
23
|
+
}
|
|
24
|
+
// Override InlineApp abstract methods
|
|
25
|
+
async daemon($) {
|
|
26
|
+
return super.daemon();
|
|
27
|
+
}
|
|
28
|
+
makeDaemon(trxEngines, services) {
|
|
29
|
+
return new BrowserDaemon(this.name, trxEngines, services, this._config);
|
|
30
|
+
}
|
|
31
|
+
// Type Builder Overrides
|
|
32
|
+
modules(modules) {
|
|
33
|
+
super.modules(modules);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
service($) {
|
|
37
|
+
super.service($);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
get config() {
|
|
41
|
+
return new app_config_1.AppConfigBuilder(this);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BrowserApp = BrowserApp;
|
|
45
|
+
/**
|
|
46
|
+
* @category App
|
|
47
|
+
* @subcategory Browser
|
|
48
|
+
*/
|
|
49
|
+
class BrowserDaemon extends monolyth_app_1.MonolythDaemon {
|
|
50
|
+
}
|
|
51
|
+
exports.BrowserDaemon = BrowserDaemon;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BrowserBundler = void 0;
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
+
const monolyth_bundler_1 = require("../monolyth/monolyth.bundler");
|
|
9
|
+
const console_1 = __importDefault(require("../../engine/util/console"));
|
|
10
|
+
const log_1 = require("../../engine/util/log");
|
|
11
|
+
const _8_replace_nesoi_for_browser_stage_1 = require("./stages/8_replace_nesoi_for_browser_stage");
|
|
12
|
+
class BrowserBundler extends monolyth_bundler_1.MonolythBundler {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.tsconfig = {
|
|
16
|
+
module: typescript_1.default.ModuleKind.ESNext,
|
|
17
|
+
moduleResolution: typescript_1.default.ModuleResolutionKind.Bundler,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async run() {
|
|
21
|
+
await super.run();
|
|
22
|
+
console_1.default.header('Browser Bundler');
|
|
23
|
+
log_1.Log.info('bundler', 'browser', `Importing the monolyth definition from ${this.appPath}`);
|
|
24
|
+
await new _8_replace_nesoi_for_browser_stage_1.ReplaceNesoiForBrowserStage(this).run();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.BrowserBundler = BrowserBundler;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BrowserBundler } from '../browser.bundler';
|
|
2
|
+
/**
|
|
3
|
+
* [Browser Compiler Stage #8]
|
|
4
|
+
* Replace 'nesoi' imports by '@nesoi/for-browser'
|
|
5
|
+
*
|
|
6
|
+
* @category Monolyth Compiler
|
|
7
|
+
* @subcategory Stages
|
|
8
|
+
*/
|
|
9
|
+
export declare class ReplaceNesoiForBrowserStage {
|
|
10
|
+
private bundler;
|
|
11
|
+
constructor(bundler: BrowserBundler);
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ReplaceNesoiForBrowserStage = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const log_1 = require("../../../engine/util/log");
|
|
39
|
+
const path_1 = require("../../../engine/util/path");
|
|
40
|
+
/**
|
|
41
|
+
* [Browser Compiler Stage #8]
|
|
42
|
+
* Replace 'nesoi' imports by '@nesoi/for-browser'
|
|
43
|
+
*
|
|
44
|
+
* @category Monolyth Compiler
|
|
45
|
+
* @subcategory Stages
|
|
46
|
+
*/
|
|
47
|
+
class ReplaceNesoiForBrowserStage {
|
|
48
|
+
constructor(bundler) {
|
|
49
|
+
this.bundler = bundler;
|
|
50
|
+
}
|
|
51
|
+
async run() {
|
|
52
|
+
log_1.Log.info('compiler', 'browser', 'Replacing \'nesoi\' imports by \'@nesoi/for-browser\'');
|
|
53
|
+
const { dirs } = this.bundler;
|
|
54
|
+
const files = path_1.Path.allFiles(dirs.build).map(path => ({
|
|
55
|
+
path,
|
|
56
|
+
content: fs.readFileSync(path).toString()
|
|
57
|
+
}));
|
|
58
|
+
// import ... from 'nesoi/...
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
if (file.content.match(/import.*from ['"]nesoi\//)) {
|
|
61
|
+
file.content = file.content.replace(/(import.*from ['"])nesoi\//g, '$1@nesoi/for-browser/');
|
|
62
|
+
fs.writeFileSync(file.path, file.content);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// await import('nesoi/...
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
if (file.content.match(/await import\(['"]nesoi\//)) {
|
|
68
|
+
file.content = file.content.replace(/(await import\(['"])nesoi\//g, '$1@nesoi/for-browser/');
|
|
69
|
+
fs.writeFileSync(file.path, file.content);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.ReplaceNesoiForBrowserStage = ReplaceNesoiForBrowserStage;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { $Space, ModuleName } from "../../schema";
|
|
2
|
+
import { AppConfig, AppControllerConfig, AppI18nConfig, AppTrashConfig, AppAuthConfig, CompilerConfig } from "../../engine/app/app.config";
|
|
3
|
+
import { CLIConfig } from "../../engine/cli/cli";
|
|
4
|
+
import { DistributedNodeApp } from './distributed_node.app';
|
|
5
|
+
import { TrxEngineConfig } from "../../engine/transaction/trx_engine.config";
|
|
6
|
+
import { BucketConfig } from "../../elements/entities/bucket/bucket.config";
|
|
7
|
+
import { IService } from "../../engine/app/service";
|
|
8
|
+
export type DistributedAppModuleConfig<S extends $Space, M extends ModuleName<S>, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, Services extends Record<string, IService>> = {
|
|
9
|
+
buckets?: DistributedAppBucketConfig<S, M, Nodes, Services>;
|
|
10
|
+
jobs?: DistributedAppJobConfig<S, M, Nodes>;
|
|
11
|
+
trash?: AppTrashConfig<Services>;
|
|
12
|
+
controllers?: AppControllerConfig<S, M, Services>;
|
|
13
|
+
trx?: TrxEngineConfig<S, S['modules'][M], any, Services>;
|
|
14
|
+
};
|
|
15
|
+
export type DistributedAppConfig<S extends $Space, Modules extends ModuleName<S>, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, Services extends Record<string, IService>> = {
|
|
16
|
+
auth?: AppAuthConfig<S>;
|
|
17
|
+
modules?: Partial<{
|
|
18
|
+
[M in (Modules & keyof S['modules'])]: DistributedAppModuleConfig<S, M, Nodes, Services>;
|
|
19
|
+
}>;
|
|
20
|
+
i18n?: AppI18nConfig;
|
|
21
|
+
cli?: CLIConfig<any>;
|
|
22
|
+
compiler?: CompilerConfig;
|
|
23
|
+
};
|
|
24
|
+
export type AnyAppConfig = AppConfig<any, any, any>;
|
|
25
|
+
export type DistributedAppBucketConfig<S extends $Space, M extends keyof S['modules'], Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, Services extends Record<string, IService>> = Partial<{
|
|
26
|
+
[K in keyof S['modules'][M]['buckets']]: keyof Nodes | BucketConfig<S['modules'][M], S['modules'][M]['buckets'][K], Services>;
|
|
27
|
+
}>;
|
|
28
|
+
export type DistributedAppJobConfig<S extends $Space, M extends keyof S['modules'], Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>> = Partial<{
|
|
29
|
+
[K in keyof S['modules'][M]['jobs']]: keyof Nodes;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* @category DistributedApp
|
|
33
|
+
*/
|
|
34
|
+
export declare class DistributedAppConfigBuilder<S extends $Space, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, Modules extends string = ModuleName<S> & string, Services extends Record<string, any> = Record<string, any>> {
|
|
35
|
+
private node;
|
|
36
|
+
constructor(node: DistributedNodeApp<S, Nodes, Modules, Services>);
|
|
37
|
+
auth(config: AppAuthConfig<S>): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
38
|
+
module<M extends Modules>(name: M, config: DistributedAppModuleConfig<S, M, Nodes, Services>): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
39
|
+
audit(config: AppI18nConfig): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
40
|
+
i18n(config: AppI18nConfig): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
41
|
+
cli(config: CLIConfig<Services>): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
42
|
+
compiler(config: CompilerConfig): DistributedNodeApp<S, Nodes, Modules, Services>;
|
|
43
|
+
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { $Space } from "
|
|
2
|
-
import { Space } from
|
|
3
|
-
import { Daemon } from "../../daemon";
|
|
1
|
+
import { $Space } from "../../schema";
|
|
2
|
+
import { Space } from "../../engine/space";
|
|
3
|
+
import { Daemon } from "../../engine/daemon";
|
|
4
4
|
import { DistributedAppConfig } from './distributed.app.config';
|
|
5
|
-
import { App } from
|
|
6
|
-
import {
|
|
7
|
-
import { AnyElementSchema } from "../../module";
|
|
5
|
+
import { App } from "../../engine/app/app";
|
|
6
|
+
import { DistributedNodeApp, DistributedAppNodeDef, DistributedNodeDaemon } from './distributed_node.app';
|
|
7
|
+
import { AnyElementSchema } from "../../engine/module";
|
|
8
|
+
import { Compiler } from "../../compiler/compiler";
|
|
9
|
+
import { Tag } from "../../engine/dependency";
|
|
10
|
+
import { DistributedBundlerConfig } from './distributed.bundler';
|
|
8
11
|
/**
|
|
9
12
|
* @category App
|
|
10
13
|
* @subcategory Distributed
|
|
11
14
|
*/
|
|
12
|
-
export declare class DistributedApp<S extends $Space, Name extends string, Nodes extends Record<string,
|
|
15
|
+
export declare class DistributedApp<S extends $Space, Name extends string, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>> = {}> extends App<S, never, never> {
|
|
13
16
|
nodes: Nodes;
|
|
14
17
|
constructor(name: Name, space?: Space<S>);
|
|
18
|
+
static compile(compiler: Compiler, appPath: string, config?: DistributedBundlerConfig): Promise<void>;
|
|
15
19
|
boot(): DistributedApp<S, Name, Nodes>;
|
|
16
20
|
daemon(): Promise<DistributedDaemon<S, { [N in keyof Nodes as `${Name}-${N & string}`]: Nodes[N]; }>>;
|
|
17
21
|
node<N extends string, ModuleNames extends string, Services extends Record<string, any>, Def extends DistributedAppNodeDef<S, Nodes, ModuleNames, Services>>(name: N, def: Def): DistributedApp<S, Name, Nodes & {
|
|
@@ -22,14 +26,10 @@ export declare class DistributedApp<S extends $Space, Name extends string, Nodes
|
|
|
22
26
|
* @category App
|
|
23
27
|
* @subcategory Distributed
|
|
24
28
|
*/
|
|
25
|
-
export declare class DistributedDaemon<S extends $Space, Nodes extends Record<string,
|
|
26
|
-
protected getSchema(tag:
|
|
27
|
-
module: keyof S['modules'];
|
|
28
|
-
type: string;
|
|
29
|
-
name: string;
|
|
30
|
-
}): Promise<AnyElementSchema>;
|
|
29
|
+
export declare class DistributedDaemon<S extends $Space, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>> extends Daemon<S, never> {
|
|
30
|
+
protected getSchema(tag: Tag): Promise<AnyElementSchema>;
|
|
31
31
|
nodes: {
|
|
32
|
-
[K in keyof Nodes]: DistributedNodeDaemon<S, Nodes[K] extends
|
|
32
|
+
[K in keyof Nodes]: DistributedNodeDaemon<S, Nodes[K] extends DistributedNodeApp<any, any, infer X, any> ? X : never>;
|
|
33
33
|
};
|
|
34
34
|
constructor(name: string, config: DistributedAppConfig<any, any, any, any>);
|
|
35
35
|
boot(nodes: Nodes): Promise<void>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DistributedDaemon = exports.DistributedApp = void 0;
|
|
4
|
-
const daemon_1 = require("../../daemon");
|
|
5
|
-
const app_1 = require("
|
|
4
|
+
const daemon_1 = require("../../engine/daemon");
|
|
5
|
+
const app_1 = require("../../engine/app/app");
|
|
6
6
|
const distributed_node_app_1 = require("./distributed_node.app");
|
|
7
|
+
const distributed_bundler_1 = require("./distributed.bundler");
|
|
7
8
|
/**
|
|
8
9
|
* @category App
|
|
9
10
|
* @subcategory Distributed
|
|
@@ -16,6 +17,10 @@ class DistributedApp extends app_1.App {
|
|
|
16
17
|
this.space = space;
|
|
17
18
|
}
|
|
18
19
|
// Override App abstract methods
|
|
20
|
+
static compile(compiler, appPath, config) {
|
|
21
|
+
return new distributed_bundler_1.DistributedBundler(compiler, appPath, config)
|
|
22
|
+
.run();
|
|
23
|
+
}
|
|
19
24
|
boot() {
|
|
20
25
|
return this;
|
|
21
26
|
}
|
|
@@ -27,7 +32,7 @@ class DistributedApp extends app_1.App {
|
|
|
27
32
|
}
|
|
28
33
|
// Type Builder Overrides
|
|
29
34
|
node(name, def) {
|
|
30
|
-
let node = new distributed_node_app_1.
|
|
35
|
+
let node = new distributed_node_app_1.DistributedNodeApp(`${this.name}-${name}`, this.space);
|
|
31
36
|
node = def(node);
|
|
32
37
|
this.nodes[node.name] = node;
|
|
33
38
|
return this;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Compiler } from "../../compiler";
|
|
2
|
-
import { AnyApp } from "
|
|
3
|
-
import { DistributedApp } from
|
|
4
|
-
export type
|
|
1
|
+
import { Compiler } from "../../compiler/compiler";
|
|
2
|
+
import { AnyApp } from "../../engine/app/app";
|
|
3
|
+
import { DistributedApp } from './distributed.app';
|
|
4
|
+
export type DistributedBundlerConfig = {
|
|
5
5
|
libPaths?: string[];
|
|
6
6
|
staticPaths?: string[];
|
|
7
7
|
scripts?: Record<string, string>;
|
|
8
8
|
nesoiPath?: string;
|
|
9
9
|
};
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class DistributedBundler {
|
|
11
11
|
compiler: Compiler;
|
|
12
12
|
appPath: string;
|
|
13
|
-
config:
|
|
13
|
+
config: DistributedBundlerConfig;
|
|
14
14
|
dirs: {
|
|
15
15
|
build: string;
|
|
16
16
|
nodes: {
|
|
@@ -23,7 +23,7 @@ export declare class DistributedCompiler {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
constructor(compiler: Compiler, appPath: string, config?:
|
|
26
|
+
constructor(compiler: Compiler, appPath: string, config?: DistributedBundlerConfig);
|
|
27
27
|
run(): Promise<void>;
|
|
28
28
|
mergeServicePaths(app: AnyApp): void;
|
|
29
29
|
expandLibPaths(): void;
|
|
@@ -36,11 +36,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.DistributedBundler = void 0;
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
|
-
const space_1 = require("
|
|
43
|
-
const console_1 = __importDefault(require("
|
|
42
|
+
const space_1 = require("../../engine/space");
|
|
43
|
+
const console_1 = __importDefault(require("../../engine/util/console"));
|
|
44
44
|
const _1_mkdir_stage_1 = require("./stages/1_mkdir_stage");
|
|
45
45
|
const _2_build_typescript_stage_1 = require("./stages/2_build_typescript_stage");
|
|
46
46
|
const _3_copy_types_stage_1 = require("./stages/3_copy_types_stage");
|
|
@@ -48,11 +48,11 @@ const _4_dump_modules_stage_1 = require("./stages/4_dump_modules_stage");
|
|
|
48
48
|
// import { CopyStaticStage } from './stages/5_copy_static_stage';
|
|
49
49
|
// import { DumpCLIStage } from './stages/6_dump_cli_stage';
|
|
50
50
|
// import { DumpPackageJsonStage } from './stages/7_dump_package_json_stage';
|
|
51
|
-
const log_1 = require("
|
|
52
|
-
const app_1 = require("
|
|
53
|
-
const distributed_app_1 = require("
|
|
54
|
-
const path_1 = require("
|
|
55
|
-
class
|
|
51
|
+
const log_1 = require("../../engine/util/log");
|
|
52
|
+
const app_1 = require("../../engine/app/app");
|
|
53
|
+
const distributed_app_1 = require("./distributed.app");
|
|
54
|
+
const path_1 = require("../../engine/util/path");
|
|
55
|
+
class DistributedBundler {
|
|
56
56
|
constructor(compiler, appPath, config = {}) {
|
|
57
57
|
this.compiler = compiler;
|
|
58
58
|
this.appPath = appPath;
|
|
@@ -60,8 +60,8 @@ class DistributedCompiler {
|
|
|
60
60
|
this.dirs = {};
|
|
61
61
|
}
|
|
62
62
|
async run() {
|
|
63
|
-
console_1.default.header('Distributed
|
|
64
|
-
log_1.Log.info('
|
|
63
|
+
console_1.default.header('Distributed Bundler');
|
|
64
|
+
log_1.Log.info('bundler', 'distributed', `Importing the Distributed definition from ${this.appPath}`);
|
|
65
65
|
const appFile = space_1.Space.path(this.compiler.space, this.appPath);
|
|
66
66
|
const app = (await Promise.resolve(`${appFile}`).then(s => __importStar(require(s)))).default;
|
|
67
67
|
this.config = Object.assign({}, app_1.App.getInfo(app).config?.compiler || {}, this.config);
|
|
@@ -118,4 +118,4 @@ class DistributedCompiler {
|
|
|
118
118
|
return apps;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
exports.
|
|
121
|
+
exports.DistributedBundler = DistributedBundler;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { $Module, $Space, ModuleName } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { $Module, $Space, ModuleName } from "../../schema";
|
|
2
|
+
import { AnyTrxEngine } from "../../engine/transaction/trx_engine";
|
|
3
|
+
import { AnyModule, Module } from "../../engine/module";
|
|
4
|
+
import { Space } from "../../engine/space";
|
|
5
|
+
import { App } from "../../engine/app/app";
|
|
6
|
+
import { AppConfigBuilder } from "../../engine/app/app.config";
|
|
7
|
+
import { IService } from "../../engine/app/service";
|
|
5
8
|
import { MonolythDaemon } from '../monolyth/monolyth.app';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { Space } from "../../space";
|
|
9
|
-
export declare class DistributedAppNode<S extends $Space, Nodes extends Record<string, DistributedAppNode<any, any, any, any>>, ModuleNames extends string, Services extends Record<string, any>> extends App<S, ModuleNames, Services> {
|
|
9
|
+
import { DistributedAppConfig } from './distributed.app.config';
|
|
10
|
+
export declare class DistributedNodeApp<S extends $Space, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, ModuleNames extends string, Services extends Record<string, any>> extends App<S, ModuleNames, Services> {
|
|
10
11
|
_host: {
|
|
11
12
|
host: string;
|
|
12
13
|
port: number;
|
|
@@ -20,7 +21,7 @@ export declare class DistributedAppNode<S extends $Space, Nodes extends Record<s
|
|
|
20
21
|
* Treeshake and build modules declared for this application.
|
|
21
22
|
*/
|
|
22
23
|
protected build(): Promise<void>;
|
|
23
|
-
boot():
|
|
24
|
+
boot(): DistributedNodeApp<S, Nodes, ModuleNames, Services>;
|
|
24
25
|
/**
|
|
25
26
|
* Build the application, start services and trx engines.
|
|
26
27
|
* Returns references to start a daemon.
|
|
@@ -30,13 +31,6 @@ export declare class DistributedAppNode<S extends $Space, Nodes extends Record<s
|
|
|
30
31
|
services: Record<string, any>;
|
|
31
32
|
trxEngines: Record<ModuleNames, AnyTrxEngine>;
|
|
32
33
|
}>;
|
|
33
|
-
/**
|
|
34
|
-
* This method injects elements flagged as externals by referencing them
|
|
35
|
-
* from the other module directly, given this is a single-threaded App.
|
|
36
|
-
*
|
|
37
|
-
* TODO: allow overriding this behavior with adapters
|
|
38
|
-
*/
|
|
39
|
-
protected linkExternals(modules: Record<string, Module<S, $Module>>): void;
|
|
40
34
|
/**
|
|
41
35
|
* This method injects values from environment variables into each module's
|
|
42
36
|
* app constants.
|
|
@@ -47,12 +41,12 @@ export declare class DistributedAppNode<S extends $Space, Nodes extends Record<s
|
|
|
47
41
|
host: string;
|
|
48
42
|
port: number;
|
|
49
43
|
}): this;
|
|
50
|
-
modules<M extends ModuleName<S>>(modules: M[]):
|
|
51
|
-
service<T extends IService>($: T):
|
|
44
|
+
modules<M extends ModuleName<S>>(modules: M[]): DistributedNodeApp<S, Nodes, M & ModuleNames, Services>;
|
|
45
|
+
service<T extends IService>($: T): DistributedNodeApp<S, Nodes, ModuleNames, Services & { [K in T["name"]]: T; }>;
|
|
52
46
|
package(_package: Record<string, any>): this;
|
|
53
|
-
get config():
|
|
47
|
+
get config(): AppConfigBuilder<S, ModuleNames, Services>;
|
|
54
48
|
}
|
|
55
|
-
export type DistributedAppNodeDef<S extends $Space, Nodes extends Record<string,
|
|
49
|
+
export type DistributedAppNodeDef<S extends $Space, Nodes extends Record<string, DistributedNodeApp<any, any, any, any>>, ModuleNames extends string, Services extends Record<string, any>> = (builder: DistributedNodeApp<S, Nodes, keyof S['modules'] & string, {}>) => DistributedNodeApp<S, Nodes, ModuleNames, Services>;
|
|
56
50
|
/**
|
|
57
51
|
* @category App
|
|
58
52
|
* @subcategory Distributed
|
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DistributedNodeDaemon = exports.
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
exports.DistributedNodeDaemon = exports.DistributedNodeApp = void 0;
|
|
7
|
+
const trx_engine_1 = require("../../engine/transaction/trx_engine");
|
|
8
|
+
const tree_1 = require("../../engine/tree");
|
|
9
|
+
const log_1 = require("../../engine/util/log");
|
|
10
|
+
const promise_1 = __importDefault(require("../../engine/util/promise"));
|
|
11
|
+
const builder_1 = require("../../engine/builder");
|
|
12
|
+
const app_1 = require("../../engine/app/app");
|
|
13
|
+
const inc_server_1 = require("../../engine/app/inc/inc.server");
|
|
9
14
|
const monolyth_app_1 = require("../monolyth/monolyth.app");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const tree_1 = require("../../tree");
|
|
13
|
-
const log_1 = require("../../util/log");
|
|
14
|
-
const promise_1 = __importDefault(require("../../util/promise"));
|
|
15
|
-
const distributed_job_1 = require("./elements/distributed_job");
|
|
16
|
-
class DistributedAppNode extends app_1.App {
|
|
15
|
+
const distributed_app_config_1 = require("./distributed.app.config");
|
|
16
|
+
class DistributedNodeApp extends app_1.App {
|
|
17
17
|
constructor(name, space) {
|
|
18
18
|
super(name, { builders: [] });
|
|
19
19
|
this._modules = {};
|
|
@@ -35,8 +35,8 @@ class DistributedAppNode extends app_1.App {
|
|
|
35
35
|
if (node.isInline) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
const module = this._modules[node.module];
|
|
39
|
-
await
|
|
38
|
+
const module = this._modules[node.tag.module];
|
|
39
|
+
await builder_1.Builder.buildNode(module, node, tree);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
boot() {
|
|
@@ -72,17 +72,15 @@ class DistributedAppNode extends app_1.App {
|
|
|
72
72
|
const module = modules[m];
|
|
73
73
|
module.start(this, services);
|
|
74
74
|
const trxConfig = this._config.modules?.[m]?.trx;
|
|
75
|
-
const
|
|
76
|
-
for (const a in this._config?.
|
|
77
|
-
const prov = this._config.
|
|
75
|
+
const authnProviders = {};
|
|
76
|
+
for (const a in this._config?.auth || {}) {
|
|
77
|
+
const prov = this._config.auth?.[a]?.();
|
|
78
78
|
if (prov) {
|
|
79
|
-
|
|
79
|
+
authnProviders[a] = prov;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
trxEngines[m] = new trx_engine_1.TrxEngine(`app:${this.name}`, module,
|
|
82
|
+
trxEngines[m] = new trx_engine_1.TrxEngine(`app:${this.name}`, module, authnProviders, trxConfig, services);
|
|
83
83
|
}
|
|
84
|
-
log_1.Log.debug('app', this.name, 'Linking externals');
|
|
85
|
-
this.linkExternals(modules);
|
|
86
84
|
log_1.Log.debug('app', this.name, 'Linking app values');
|
|
87
85
|
this.linkAppValues(modules);
|
|
88
86
|
return {
|
|
@@ -91,36 +89,6 @@ class DistributedAppNode extends app_1.App {
|
|
|
91
89
|
trxEngines
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
|
-
/**
|
|
95
|
-
* This method injects elements flagged as externals by referencing them
|
|
96
|
-
* from the other module directly, given this is a single-threaded App.
|
|
97
|
-
*
|
|
98
|
-
* TODO: allow overriding this behavior with adapters
|
|
99
|
-
*/
|
|
100
|
-
linkExternals(modules) {
|
|
101
|
-
Object.values(modules).forEach(module => {
|
|
102
|
-
const jobs = {};
|
|
103
|
-
for (const name in module.schema.externals.jobs) {
|
|
104
|
-
const dep = module.schema.externals.jobs[name];
|
|
105
|
-
const config = this._config;
|
|
106
|
-
const node = config?.modules?.[dep.module]?.jobs?.[dep.name];
|
|
107
|
-
if (!node) {
|
|
108
|
-
throw new Error(`External job '${dep.tag}' not configured on module '${this.name}'`);
|
|
109
|
-
}
|
|
110
|
-
jobs[name] = new distributed_job_1.DistributedJob(module, node);
|
|
111
|
-
}
|
|
112
|
-
module.injectRunners({
|
|
113
|
-
// buckets: Object.values(module.schema.externals.buckets),
|
|
114
|
-
// messages: Object.values(module.schema.externals.messages),
|
|
115
|
-
jobs
|
|
116
|
-
// machines: Object.values(module.schema.externals.machines),
|
|
117
|
-
});
|
|
118
|
-
// const buckets = module.schema.externals.buckets;
|
|
119
|
-
// Object.values(buckets).forEach(bucket => {
|
|
120
|
-
// module.nql.linkExternal(modules[bucket.module].buckets[bucket.name]);
|
|
121
|
-
// })
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
92
|
/**
|
|
125
93
|
* This method injects values from environment variables into each module's
|
|
126
94
|
* app constants.
|
|
@@ -171,7 +139,7 @@ class DistributedAppNode extends app_1.App {
|
|
|
171
139
|
return new distributed_app_config_1.DistributedAppConfigBuilder(this);
|
|
172
140
|
}
|
|
173
141
|
}
|
|
174
|
-
exports.
|
|
142
|
+
exports.DistributedNodeApp = DistributedNodeApp;
|
|
175
143
|
/**
|
|
176
144
|
* @category App
|
|
177
145
|
* @subcategory Distributed
|