nesoi 3.2.9 → 3.3.0
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 +13 -10
- 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
|
@@ -14,7 +14,7 @@ class ControllerEndpoint {
|
|
|
14
14
|
this.adapter = adapter;
|
|
15
15
|
this.path = path;
|
|
16
16
|
}
|
|
17
|
-
invoke(data,
|
|
17
|
+
invoke(data, auth) {
|
|
18
18
|
const raw = {
|
|
19
19
|
...data,
|
|
20
20
|
$: this.schema.msg.name
|
|
@@ -23,17 +23,17 @@ class ControllerEndpoint {
|
|
|
23
23
|
Object.assign(raw, this.schema.implicit);
|
|
24
24
|
}
|
|
25
25
|
return this.adapter.trx(async (trx) => {
|
|
26
|
-
trx_node_1.TrxNode.
|
|
26
|
+
await trx_node_1.TrxNode.checkAuth(trx, this.schema.auth);
|
|
27
27
|
if (this.schema.target.type === 'job') {
|
|
28
|
-
return trx.job(this.schema.target.
|
|
28
|
+
return trx.job(this.schema.target.short).run(raw);
|
|
29
29
|
}
|
|
30
30
|
if (this.schema.target.type === 'resource') {
|
|
31
|
-
return trx.resource(this.schema.target.
|
|
31
|
+
return trx.resource(this.schema.target.short).run(raw);
|
|
32
32
|
}
|
|
33
33
|
if (this.schema.target.type === 'machine') {
|
|
34
|
-
return trx.machine(this.schema.target.
|
|
34
|
+
return trx.machine(this.schema.target.short).run(raw);
|
|
35
35
|
}
|
|
36
|
-
},
|
|
36
|
+
}, auth);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.ControllerEndpoint = ControllerEndpoint;
|
|
@@ -47,19 +47,19 @@ class ControllerTopic {
|
|
|
47
47
|
this.adapter = adapter;
|
|
48
48
|
this.path = path;
|
|
49
49
|
}
|
|
50
|
-
async subscribe(fn,
|
|
51
|
-
const response = await this.adapter.trx(trx => {
|
|
52
|
-
trx_node_1.TrxNode.
|
|
50
|
+
async subscribe(fn, auth) {
|
|
51
|
+
const response = await this.adapter.trx(async (trx) => {
|
|
52
|
+
await trx_node_1.TrxNode.checkAuth(trx, this.schema.auth);
|
|
53
53
|
return trx.topic(this.schema.name).subscribe(fn);
|
|
54
|
-
},
|
|
54
|
+
}, auth);
|
|
55
55
|
if (response.state === 'error') {
|
|
56
56
|
throw error_1.NesoiError.Controller.SubscribeFailed({ topic: this.schema.alias });
|
|
57
57
|
}
|
|
58
58
|
return response.output;
|
|
59
59
|
}
|
|
60
60
|
async unsubscribe(id) {
|
|
61
|
-
const response = await this.adapter.trx(trx => {
|
|
62
|
-
trx_node_1.TrxNode.
|
|
61
|
+
const response = await this.adapter.trx(async (trx) => {
|
|
62
|
+
await trx_node_1.TrxNode.checkAuth(trx, this.schema.auth);
|
|
63
63
|
return trx.topic(this.schema.name).unsubscribe(id);
|
|
64
64
|
});
|
|
65
65
|
if (response.state === 'error') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { $BlockAuth } from "../../blocks/block.schema";
|
|
1
2
|
import { $Message } from "../../entities/message/message.schema";
|
|
2
3
|
import { AnyUsers } from "../../../engine/auth/authn";
|
|
3
|
-
import {
|
|
4
|
+
import { Tag } from "../../../engine/dependency";
|
|
4
5
|
/**
|
|
5
6
|
* @category Schemas
|
|
6
7
|
* @subcategory Edge
|
|
@@ -8,13 +9,13 @@ import { $Dependency } from "../../../engine/dependency";
|
|
|
8
9
|
export declare class $ControllerEndpoint {
|
|
9
10
|
name: string;
|
|
10
11
|
alias: string;
|
|
11
|
-
|
|
12
|
+
auth: $BlockAuth[];
|
|
12
13
|
tags: string[];
|
|
13
|
-
msg:
|
|
14
|
-
target:
|
|
14
|
+
msg: Tag;
|
|
15
|
+
target: Tag;
|
|
15
16
|
implicit?: Record<string, any> | undefined;
|
|
16
17
|
$t: string;
|
|
17
|
-
constructor(name: string, alias: string,
|
|
18
|
+
constructor(name: string, alias: string, auth: $BlockAuth[], tags: string[], msg: Tag, target: Tag, implicit?: Record<string, any> | undefined);
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* @category Schemas
|
|
@@ -23,12 +24,12 @@ export declare class $ControllerEndpoint {
|
|
|
23
24
|
export declare class $ControllerTopic {
|
|
24
25
|
name: string;
|
|
25
26
|
alias: string;
|
|
26
|
-
|
|
27
|
+
auth: $BlockAuth[];
|
|
27
28
|
tags: string[];
|
|
28
|
-
msgs:
|
|
29
|
-
topic:
|
|
29
|
+
msgs: Tag[];
|
|
30
|
+
topic: Tag;
|
|
30
31
|
$t: string;
|
|
31
|
-
constructor(name: string, alias: string,
|
|
32
|
+
constructor(name: string, alias: string, auth: $BlockAuth[], tags: string[], msgs: Tag[], topic: Tag);
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* @category Schemas
|
|
@@ -37,11 +38,11 @@ export declare class $ControllerTopic {
|
|
|
37
38
|
export declare class $ControllerGroup {
|
|
38
39
|
name: string;
|
|
39
40
|
alias: string;
|
|
40
|
-
|
|
41
|
+
auth: $BlockAuth[];
|
|
41
42
|
groups: Record<string, $ControllerGroup>;
|
|
42
43
|
endpoints: Record<string, $ControllerEndpoint>;
|
|
43
44
|
$t: string;
|
|
44
|
-
constructor(name: string, alias: string,
|
|
45
|
+
constructor(name: string, alias: string, auth: $BlockAuth[], groups?: Record<string, $ControllerGroup>, endpoints?: Record<string, $ControllerEndpoint>);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* @category Schemas
|
|
@@ -50,12 +51,12 @@ export declare class $ControllerGroup {
|
|
|
50
51
|
export declare class $ControllerDomain extends $ControllerGroup {
|
|
51
52
|
name: string;
|
|
52
53
|
alias: string;
|
|
53
|
-
|
|
54
|
+
auth: $BlockAuth[];
|
|
54
55
|
version: string;
|
|
55
56
|
groups: Record<string, $ControllerGroup>;
|
|
56
57
|
endpoints: Record<string, $ControllerEndpoint>;
|
|
57
58
|
$t: string;
|
|
58
|
-
constructor(name: string, alias: string,
|
|
59
|
+
constructor(name: string, alias: string, auth: $BlockAuth[], version: string, groups?: Record<string, $ControllerGroup>, endpoints?: Record<string, $ControllerEndpoint>);
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* @category Schemas
|
|
@@ -65,12 +66,12 @@ export declare class $Controller {
|
|
|
65
66
|
module: string;
|
|
66
67
|
name: string;
|
|
67
68
|
alias: string;
|
|
68
|
-
|
|
69
|
-
input:
|
|
69
|
+
auth: $BlockAuth[];
|
|
70
|
+
input: Tag[];
|
|
70
71
|
domains: Record<string, $ControllerDomain>;
|
|
71
72
|
topics: Record<string, $ControllerTopic>;
|
|
72
73
|
$t: "controller";
|
|
73
74
|
'#authn': AnyUsers;
|
|
74
75
|
'#input': $Message;
|
|
75
|
-
constructor(module: string, name: string, alias: string,
|
|
76
|
+
constructor(module: string, name: string, alias: string, auth: $BlockAuth[], input: Tag[], domains?: Record<string, $ControllerDomain>, topics?: Record<string, $ControllerTopic>);
|
|
76
77
|
}
|
|
@@ -6,10 +6,10 @@ exports.$Controller = exports.$ControllerDomain = exports.$ControllerGroup = exp
|
|
|
6
6
|
* @subcategory Edge
|
|
7
7
|
*/
|
|
8
8
|
class $ControllerEndpoint {
|
|
9
|
-
constructor(name, alias,
|
|
9
|
+
constructor(name, alias, auth, tags, msg, target, implicit) {
|
|
10
10
|
this.name = name;
|
|
11
11
|
this.alias = alias;
|
|
12
|
-
this.
|
|
12
|
+
this.auth = auth;
|
|
13
13
|
this.tags = tags;
|
|
14
14
|
this.msg = msg;
|
|
15
15
|
this.target = target;
|
|
@@ -23,10 +23,10 @@ exports.$ControllerEndpoint = $ControllerEndpoint;
|
|
|
23
23
|
* @subcategory Edge
|
|
24
24
|
*/
|
|
25
25
|
class $ControllerTopic {
|
|
26
|
-
constructor(name, alias,
|
|
26
|
+
constructor(name, alias, auth, tags, msgs, topic) {
|
|
27
27
|
this.name = name;
|
|
28
28
|
this.alias = alias;
|
|
29
|
-
this.
|
|
29
|
+
this.auth = auth;
|
|
30
30
|
this.tags = tags;
|
|
31
31
|
this.msgs = msgs;
|
|
32
32
|
this.topic = topic;
|
|
@@ -39,10 +39,10 @@ exports.$ControllerTopic = $ControllerTopic;
|
|
|
39
39
|
* @subcategory Edge
|
|
40
40
|
*/
|
|
41
41
|
class $ControllerGroup {
|
|
42
|
-
constructor(name, alias,
|
|
42
|
+
constructor(name, alias, auth, groups = {}, endpoints = {}) {
|
|
43
43
|
this.name = name;
|
|
44
44
|
this.alias = alias;
|
|
45
|
-
this.
|
|
45
|
+
this.auth = auth;
|
|
46
46
|
this.groups = groups;
|
|
47
47
|
this.endpoints = endpoints;
|
|
48
48
|
this.$t = 'controller.group';
|
|
@@ -54,11 +54,11 @@ exports.$ControllerGroup = $ControllerGroup;
|
|
|
54
54
|
* @subcategory Edge
|
|
55
55
|
*/
|
|
56
56
|
class $ControllerDomain extends $ControllerGroup {
|
|
57
|
-
constructor(name, alias,
|
|
58
|
-
super(name, alias,
|
|
57
|
+
constructor(name, alias, auth, version, groups = {}, endpoints = {}) {
|
|
58
|
+
super(name, alias, auth, groups, endpoints);
|
|
59
59
|
this.name = name;
|
|
60
60
|
this.alias = alias;
|
|
61
|
-
this.
|
|
61
|
+
this.auth = auth;
|
|
62
62
|
this.version = version;
|
|
63
63
|
this.groups = groups;
|
|
64
64
|
this.endpoints = endpoints;
|
|
@@ -71,11 +71,11 @@ exports.$ControllerDomain = $ControllerDomain;
|
|
|
71
71
|
* @subcategory Edge
|
|
72
72
|
*/
|
|
73
73
|
class $Controller {
|
|
74
|
-
constructor(module, name, alias,
|
|
74
|
+
constructor(module, name, alias, auth, input, domains = {}, topics = {}) {
|
|
75
75
|
this.module = module;
|
|
76
76
|
this.name = name;
|
|
77
77
|
this.alias = alias;
|
|
78
|
-
this.
|
|
78
|
+
this.auth = auth;
|
|
79
79
|
this.input = input;
|
|
80
80
|
this.domains = domains;
|
|
81
81
|
this.topics = topics;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { $Space } from "../../../schema";
|
|
2
2
|
import { $Externals } from './externals.schema';
|
|
3
3
|
import { ResolvedBuilderNode } from "../../../engine/dependency";
|
|
4
|
-
import {
|
|
5
|
-
type MergeAllBuckets<Space extends $Space, Module extends keyof Space['modules'], Modules extends $Space['modules'] = Space['modules']> = MergeUnion<{
|
|
6
|
-
[M in keyof Modules]: {
|
|
7
|
-
[B in keyof Modules[M]['buckets'] as `${M & string}::${B & string}`]: Modules[M]['buckets'][B];
|
|
8
|
-
};
|
|
9
|
-
}[keyof Modules]>;
|
|
10
|
-
type ExternalBucketRefName<Space extends $Space, M extends keyof Space['modules'], AllBuckets = MergeAllBuckets<Space, M>> = Exclude<keyof AllBuckets, `${M & string}::${string}` | `${string}::${string}::${string}`>;
|
|
4
|
+
import { ModuleTree } from "../../../engine/tree";
|
|
11
5
|
/**
|
|
12
6
|
* @category Builders
|
|
13
7
|
* @subcategory Edge
|
|
@@ -16,23 +10,24 @@ export declare class ExternalsBuilder<Space extends $Space, ModuleName extends k
|
|
|
16
10
|
private module;
|
|
17
11
|
$b: "externals";
|
|
18
12
|
name: string;
|
|
13
|
+
private values;
|
|
14
|
+
private enums;
|
|
19
15
|
private buckets;
|
|
20
16
|
private messages;
|
|
21
17
|
private jobs;
|
|
22
18
|
private machines;
|
|
23
|
-
private enums;
|
|
24
19
|
constructor(module: string);
|
|
25
|
-
|
|
20
|
+
value<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['constants']['values']>(ref: `${M & string}::${B & string}`): this;
|
|
21
|
+
enum<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['constants']['enums']>(ref: `${M & string}::${B & string}`): this;
|
|
22
|
+
bucket<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['buckets']>(ref: `${M & string}::${B & string}`): this;
|
|
26
23
|
message<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['messages']>(ref: `${M & string}::${B & string}`): this;
|
|
27
24
|
job<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['jobs']>(ref: `${M & string}::${B & string}`): this;
|
|
28
25
|
machine<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['machines']>(ref: `${M & string}::${B & string}`): this;
|
|
29
|
-
enum<M extends Exclude<keyof Space['modules'], ModuleName>, B extends keyof Space['modules'][M]['constants']['enums']>(ref: `${M & string}::${B & string}`): this;
|
|
30
26
|
static merge(to: AnyExternalsBuilder, from: AnyExternalsBuilder): void;
|
|
31
|
-
static build(node: ExternalsBuilderNode): $Externals;
|
|
27
|
+
static build(node: ExternalsBuilderNode, tree: ModuleTree): $Externals;
|
|
32
28
|
}
|
|
33
29
|
export type AnyExternalsBuilder = ExternalsBuilder<any, any>;
|
|
34
|
-
export type ExternalsBuilderNode = ResolvedBuilderNode & {
|
|
30
|
+
export type ExternalsBuilderNode = Omit<ResolvedBuilderNode, 'schema'> & {
|
|
35
31
|
builder: AnyExternalsBuilder;
|
|
36
32
|
schema?: $Externals;
|
|
37
33
|
};
|
|
38
|
-
export {};
|
|
@@ -12,30 +12,41 @@ class ExternalsBuilder {
|
|
|
12
12
|
this.module = module;
|
|
13
13
|
this.$b = 'externals';
|
|
14
14
|
this.name = '*';
|
|
15
|
+
this.values = {};
|
|
16
|
+
this.enums = {};
|
|
15
17
|
this.buckets = {};
|
|
16
18
|
this.messages = {};
|
|
17
19
|
this.jobs = {};
|
|
18
20
|
this.machines = {};
|
|
19
|
-
|
|
21
|
+
}
|
|
22
|
+
value(ref) {
|
|
23
|
+
const tag = dependency_1.Tag.fromShort('constants.value', ref);
|
|
24
|
+
this.values[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
enum(ref) {
|
|
28
|
+
const tag = dependency_1.Tag.fromShort('constants.enum', ref);
|
|
29
|
+
this.enums[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
30
|
+
return this;
|
|
20
31
|
}
|
|
21
32
|
bucket(ref) {
|
|
22
|
-
|
|
33
|
+
const tag = dependency_1.Tag.fromShort('bucket', ref);
|
|
34
|
+
this.buckets[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
23
35
|
return this;
|
|
24
36
|
}
|
|
25
37
|
message(ref) {
|
|
26
|
-
|
|
38
|
+
const tag = dependency_1.Tag.fromShort('message', ref);
|
|
39
|
+
this.messages[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
27
40
|
return this;
|
|
28
41
|
}
|
|
29
42
|
job(ref) {
|
|
30
|
-
|
|
43
|
+
const tag = dependency_1.Tag.fromShort('job', ref);
|
|
44
|
+
this.jobs[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
31
45
|
return this;
|
|
32
46
|
}
|
|
33
47
|
machine(ref) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
enum(ref) {
|
|
38
|
-
this.enums[ref] = new dependency_1.$Dependency(this.module, 'enum', ref);
|
|
48
|
+
const tag = dependency_1.Tag.fromShort('machine', ref);
|
|
49
|
+
this.machines[tag.short] = new dependency_1.Dependency(this.module, tag, { build: true, compile: true, runtime: true });
|
|
39
50
|
return this;
|
|
40
51
|
}
|
|
41
52
|
static merge(to, from) {
|
|
@@ -43,8 +54,29 @@ class ExternalsBuilder {
|
|
|
43
54
|
Object.assign(to.jobs, from.jobs);
|
|
44
55
|
}
|
|
45
56
|
// Build
|
|
46
|
-
static build(node) {
|
|
47
|
-
|
|
57
|
+
static build(node, tree) {
|
|
58
|
+
const buckets = Object.entries(node.builder.buckets);
|
|
59
|
+
const messages = Object.entries(node.builder.messages);
|
|
60
|
+
const jobs = Object.entries(node.builder.jobs);
|
|
61
|
+
const machines = Object.entries(node.builder.machines);
|
|
62
|
+
const enums = Object.entries(node.builder.enums);
|
|
63
|
+
const values = Object.entries(node.builder.values);
|
|
64
|
+
// Static Externals
|
|
65
|
+
const module = tree.modules[node.tag.module];
|
|
66
|
+
const schema = module.schema;
|
|
67
|
+
for (const value of values) {
|
|
68
|
+
const tag = value[1].tag;
|
|
69
|
+
schema.constants.values[tag.short] = dependency_1.Tag.resolve(tag, tree);
|
|
70
|
+
}
|
|
71
|
+
for (const _enum of enums) {
|
|
72
|
+
const tag = _enum[1].tag;
|
|
73
|
+
schema.constants.enums[tag.short] = dependency_1.Tag.resolve(tag, tree);
|
|
74
|
+
}
|
|
75
|
+
for (const msg of messages) {
|
|
76
|
+
const tag = msg[1].tag;
|
|
77
|
+
schema.messages[tag.short] = dependency_1.Tag.resolve(tag, tree);
|
|
78
|
+
}
|
|
79
|
+
node.schema = new externals_schema_1.$Externals(node.tag.module, Object.fromEntries(values.map(e => [e[0], e[1].tag])), Object.fromEntries(enums.map(e => [e[0], e[1].tag])), Object.fromEntries(buckets.map(e => [e[0], e[1].tag])), Object.fromEntries(messages.map(e => [e[0], e[1].tag])), Object.fromEntries(jobs.map(e => [e[0], e[1].tag])), Object.fromEntries(machines.map(e => [e[0], e[1].tag])));
|
|
48
80
|
return node.schema;
|
|
49
81
|
}
|
|
50
82
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tag } from "../../../engine/dependency";
|
|
2
2
|
/**
|
|
3
3
|
* @category Schemas
|
|
4
4
|
* @subcategory Edge
|
|
5
5
|
*/
|
|
6
6
|
export declare class $Externals {
|
|
7
7
|
name: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
values: Record<string, Tag>;
|
|
9
|
+
enums: Record<string, Tag>;
|
|
10
|
+
buckets: Record<string, Tag>;
|
|
11
|
+
messages: Record<string, Tag>;
|
|
12
|
+
jobs: Record<string, Tag>;
|
|
13
|
+
machines: Record<string, Tag>;
|
|
13
14
|
$t: "externals";
|
|
14
15
|
module: string;
|
|
15
|
-
constructor(name: string,
|
|
16
|
+
constructor(name: string, values?: Record<string, Tag>, enums?: Record<string, Tag>, buckets?: Record<string, Tag>, messages?: Record<string, Tag>, jobs?: Record<string, Tag>, machines?: Record<string, Tag>);
|
|
16
17
|
static merge(to: $Externals, from: $Externals): void;
|
|
17
18
|
}
|
|
@@ -6,22 +6,24 @@ exports.$Externals = void 0;
|
|
|
6
6
|
* @subcategory Edge
|
|
7
7
|
*/
|
|
8
8
|
class $Externals {
|
|
9
|
-
constructor(name,
|
|
9
|
+
constructor(name, values = {}, enums = {}, buckets = {}, messages = {}, jobs = {}, machines = {}) {
|
|
10
10
|
this.name = name;
|
|
11
|
+
this.values = values;
|
|
12
|
+
this.enums = enums;
|
|
11
13
|
this.buckets = buckets;
|
|
12
14
|
this.messages = messages;
|
|
13
15
|
this.jobs = jobs;
|
|
14
16
|
this.machines = machines;
|
|
15
|
-
this.enums = enums;
|
|
16
17
|
this.$t = 'externals';
|
|
17
18
|
this.module = this.name;
|
|
18
19
|
}
|
|
19
20
|
static merge(to, from) {
|
|
21
|
+
Object.assign(to.values, from.values);
|
|
22
|
+
Object.assign(to.enums, from.enums);
|
|
20
23
|
Object.assign(to.buckets, from.buckets);
|
|
21
24
|
Object.assign(to.messages, from.messages);
|
|
22
25
|
Object.assign(to.jobs, from.jobs);
|
|
23
26
|
Object.assign(to.machines, from.machines);
|
|
24
|
-
Object.assign(to.enums, from.enums);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
exports.$Externals = $Externals;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ObjWithOptionalId } from "../../../../engine/data/obj";
|
|
2
|
+
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
3
|
+
import { $Bucket } from "../../..";
|
|
4
|
+
import { BucketCacheSync } from '../cache/bucket_cache';
|
|
5
|
+
import { MemoryBucketAdapter } from './memory.bucket_adapter';
|
|
6
|
+
import { BrowserDBService } from './browserdb.service';
|
|
7
|
+
/**
|
|
8
|
+
* @category Adapters
|
|
9
|
+
* @subcategory Entity
|
|
10
|
+
* */
|
|
11
|
+
export declare class BrowserDBBucketAdapter<B extends $Bucket, Obj extends B['#data']> extends MemoryBucketAdapter<B, Obj> {
|
|
12
|
+
schema: B;
|
|
13
|
+
service: BrowserDBService;
|
|
14
|
+
private refName;
|
|
15
|
+
constructor(schema: B, service: BrowserDBService);
|
|
16
|
+
getQueryMeta(): {
|
|
17
|
+
scope: string;
|
|
18
|
+
avgTime: number;
|
|
19
|
+
};
|
|
20
|
+
private trxData;
|
|
21
|
+
private stage;
|
|
22
|
+
private flagDelete;
|
|
23
|
+
private getStore;
|
|
24
|
+
index(trx: AnyTrxNode): Promise<Obj[]>;
|
|
25
|
+
get(trx: AnyTrxNode, id: Obj['id']): Promise<Obj | undefined>;
|
|
26
|
+
create(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
27
|
+
createMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
28
|
+
replace(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
29
|
+
replaceMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
30
|
+
patch(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
31
|
+
patchMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
32
|
+
put(trx: AnyTrxNode, obj: ObjWithOptionalId<Obj>): Promise<Obj>;
|
|
33
|
+
putMany(trx: AnyTrxNode, objs: ObjWithOptionalId<Obj>[]): Promise<Obj[]>;
|
|
34
|
+
delete(trx: AnyTrxNode, id: Obj['id']): Promise<void>;
|
|
35
|
+
deleteMany(trx: AnyTrxNode, ids: Obj['id'][]): Promise<void>;
|
|
36
|
+
syncOne(trx: AnyTrxNode, id: Obj['id'], lastObjUpdateEpoch: number): Promise<null | 'deleted' | BucketCacheSync<Obj>>;
|
|
37
|
+
syncOneAndPast(trx: AnyTrxNode, id: Obj['id'], lastUpdateEpoch: number): Promise<null | 'deleted' | BucketCacheSync<Obj>[]>;
|
|
38
|
+
syncAll(trx: AnyTrxNode, lastHash?: string, lastUpdateEpoch?: number): Promise<null | {
|
|
39
|
+
sync: BucketCacheSync<Obj>[];
|
|
40
|
+
hash: string;
|
|
41
|
+
updateEpoch: number;
|
|
42
|
+
reset: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
export type AnyBrowserDBBucketAdapter = BrowserDBBucketAdapter<any, any>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserDBBucketAdapter = void 0;
|
|
4
|
+
const trx_node_1 = require("../../../../engine/transaction/trx_node");
|
|
5
|
+
const memory_bucket_adapter_1 = require("./memory.bucket_adapter");
|
|
6
|
+
const browserdb_service_1 = require("./browserdb.service");
|
|
7
|
+
const trx_1 = require("../../../../engine/transaction/trx");
|
|
8
|
+
/**
|
|
9
|
+
* @category Adapters
|
|
10
|
+
* @subcategory Entity
|
|
11
|
+
* */
|
|
12
|
+
class BrowserDBBucketAdapter extends memory_bucket_adapter_1.MemoryBucketAdapter {
|
|
13
|
+
constructor(schema, service) {
|
|
14
|
+
super(schema, undefined, service.config);
|
|
15
|
+
this.schema = schema;
|
|
16
|
+
this.service = service;
|
|
17
|
+
this.refName = `${schema.module}::${schema.name}`;
|
|
18
|
+
}
|
|
19
|
+
getQueryMeta() {
|
|
20
|
+
return {
|
|
21
|
+
scope: `browserdb.${this.schema.name}`,
|
|
22
|
+
avgTime: 100
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/* */
|
|
26
|
+
trxData(trx) {
|
|
27
|
+
return trx_1.Trx.get(trx, this.service.name + '.trxData');
|
|
28
|
+
}
|
|
29
|
+
async stage(trx, objs) {
|
|
30
|
+
var _a;
|
|
31
|
+
const trxData = trx_1.Trx.get(trx, this.service.name + '.trxData');
|
|
32
|
+
if (trxData) {
|
|
33
|
+
for (const obj of objs) {
|
|
34
|
+
trxData[_a = this.refName] ?? (trxData[_a] = {});
|
|
35
|
+
trxData[this.refName][obj.id] = obj;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const module = trx_node_1.TrxNode.getModule(trx);
|
|
40
|
+
const db = await browserdb_service_1.BrowserDBService.db(this.service, module);
|
|
41
|
+
const dbTrx = db.transaction(this.refName, 'readwrite');
|
|
42
|
+
const store = dbTrx.objectStore(this.refName);
|
|
43
|
+
for (const obj in objs) {
|
|
44
|
+
store.put(obj);
|
|
45
|
+
}
|
|
46
|
+
dbTrx.commit();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async flagDelete(trx, ids) {
|
|
50
|
+
var _a;
|
|
51
|
+
const trxData = trx_1.Trx.get(trx, this.service.name + '.trxData');
|
|
52
|
+
if (trxData) {
|
|
53
|
+
for (const id of ids) {
|
|
54
|
+
trxData[_a = this.refName] ?? (trxData[_a] = {});
|
|
55
|
+
trxData[this.refName][id] = { __delete: true };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const module = trx_node_1.TrxNode.getModule(trx);
|
|
60
|
+
const db = await browserdb_service_1.BrowserDBService.db(this.service, module);
|
|
61
|
+
const dbTrx = db.transaction(this.refName, 'readwrite');
|
|
62
|
+
const store = dbTrx.objectStore(this.refName);
|
|
63
|
+
for (const id in ids) {
|
|
64
|
+
store.delete(id);
|
|
65
|
+
}
|
|
66
|
+
dbTrx.commit();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async getStore(trx, mode) {
|
|
70
|
+
const module = trx_node_1.TrxNode.getModule(trx);
|
|
71
|
+
const db = await browserdb_service_1.BrowserDBService.db(this.service, module);
|
|
72
|
+
const dbTrx = db.transaction(this.refName, mode);
|
|
73
|
+
return dbTrx.objectStore(this.refName);
|
|
74
|
+
}
|
|
75
|
+
/* Read operations */
|
|
76
|
+
async index(trx) {
|
|
77
|
+
const store = await this.getStore(trx, 'readonly');
|
|
78
|
+
const objs = await new Promise((resolve, reject) => {
|
|
79
|
+
const req = store.getAll();
|
|
80
|
+
req.onsuccess = () => resolve(req.result);
|
|
81
|
+
req.onerror = e => reject(e);
|
|
82
|
+
});
|
|
83
|
+
this.data = {};
|
|
84
|
+
for (const obj of objs) {
|
|
85
|
+
this.data[obj.id] = obj;
|
|
86
|
+
}
|
|
87
|
+
Object.assign(this.data, this.trxData(trx));
|
|
88
|
+
return objs;
|
|
89
|
+
}
|
|
90
|
+
async get(trx, id) {
|
|
91
|
+
const trxData = this.trxData(trx)[this.refName];
|
|
92
|
+
if (id in trxData) {
|
|
93
|
+
return trxData[id];
|
|
94
|
+
}
|
|
95
|
+
const store = await this.getStore(trx, 'readonly');
|
|
96
|
+
const obj = await new Promise((resolve, reject) => {
|
|
97
|
+
const req = store.get(id);
|
|
98
|
+
req.onsuccess = () => resolve(req.result);
|
|
99
|
+
req.onerror = e => reject(e);
|
|
100
|
+
});
|
|
101
|
+
this.data[obj.id] = obj;
|
|
102
|
+
return obj;
|
|
103
|
+
}
|
|
104
|
+
/* Write Operations */
|
|
105
|
+
async create(trx, obj) {
|
|
106
|
+
const _obj = await super.create(trx, obj);
|
|
107
|
+
await this.stage(trx, [_obj]);
|
|
108
|
+
return _obj;
|
|
109
|
+
}
|
|
110
|
+
async createMany(trx, objs) {
|
|
111
|
+
const _objs = await super.createMany(trx, objs);
|
|
112
|
+
await this.stage(trx, _objs);
|
|
113
|
+
return _objs;
|
|
114
|
+
}
|
|
115
|
+
async replace(trx, obj) {
|
|
116
|
+
const _obj = await super.replace(trx, obj);
|
|
117
|
+
await this.stage(trx, [_obj]);
|
|
118
|
+
return _obj;
|
|
119
|
+
}
|
|
120
|
+
async replaceMany(trx, objs) {
|
|
121
|
+
const _objs = await super.replaceMany(trx, objs);
|
|
122
|
+
await this.stage(trx, _objs);
|
|
123
|
+
return _objs;
|
|
124
|
+
}
|
|
125
|
+
async patch(trx, obj) {
|
|
126
|
+
const _obj = await super.patch(trx, obj);
|
|
127
|
+
await this.stage(trx, [_obj]);
|
|
128
|
+
return _obj;
|
|
129
|
+
}
|
|
130
|
+
async patchMany(trx, objs) {
|
|
131
|
+
const _objs = await super.patchMany(trx, objs);
|
|
132
|
+
await this.stage(trx, _objs);
|
|
133
|
+
return _objs;
|
|
134
|
+
}
|
|
135
|
+
async put(trx, obj) {
|
|
136
|
+
const _obj = await super.put(trx, obj);
|
|
137
|
+
await this.stage(trx, [_obj]);
|
|
138
|
+
return _obj;
|
|
139
|
+
}
|
|
140
|
+
async putMany(trx, objs) {
|
|
141
|
+
const _objs = await super.putMany(trx, objs);
|
|
142
|
+
await this.stage(trx, _objs);
|
|
143
|
+
return _objs;
|
|
144
|
+
}
|
|
145
|
+
async delete(trx, id) {
|
|
146
|
+
await super.delete(trx, id);
|
|
147
|
+
await this.flagDelete(trx, [id]);
|
|
148
|
+
}
|
|
149
|
+
async deleteMany(trx, ids) {
|
|
150
|
+
await super.deleteMany(trx, ids);
|
|
151
|
+
await this.flagDelete(trx, ids);
|
|
152
|
+
}
|
|
153
|
+
/* Cache Operations */
|
|
154
|
+
async syncOne(trx, id, lastObjUpdateEpoch) {
|
|
155
|
+
return super.syncOne(trx, id, lastObjUpdateEpoch);
|
|
156
|
+
}
|
|
157
|
+
async syncOneAndPast(trx, id, lastUpdateEpoch) {
|
|
158
|
+
return super.syncOneAndPast(trx, id, lastUpdateEpoch);
|
|
159
|
+
}
|
|
160
|
+
async syncAll(trx, lastHash, lastUpdateEpoch = 0) {
|
|
161
|
+
return super.syncAll(trx, lastHash, lastUpdateEpoch);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.BrowserDBBucketAdapter = BrowserDBBucketAdapter;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AnyTrx } from "../../../../engine/transaction/trx";
|
|
2
|
+
import { TrxEngineWrapFn } from "../../../../engine/transaction/trx_engine.config";
|
|
3
|
+
import { Service } from "../../../../engine/app/service";
|
|
4
|
+
import { MemoryNQLRunner } from './memory.nql';
|
|
5
|
+
import { BucketAdapterConfig } from './bucket_adapter';
|
|
6
|
+
import { Module } from "../../../../engine/module";
|
|
7
|
+
import { $Module } from "../../..";
|
|
8
|
+
export type BrowserDBConfig = BucketAdapterConfig & {
|
|
9
|
+
dbName: string;
|
|
10
|
+
dbVersion: number;
|
|
11
|
+
};
|
|
12
|
+
export type BrowserDBTrxData = {
|
|
13
|
+
[tag: string]: {
|
|
14
|
+
[id: string | number]: Record<string, any> | {
|
|
15
|
+
__delete: true;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare class BrowserDBService<Name extends string = 'idb'> extends Service<Name, BrowserDBConfig> {
|
|
20
|
+
static defaultName: string;
|
|
21
|
+
private indexedDB;
|
|
22
|
+
connected: boolean;
|
|
23
|
+
private db;
|
|
24
|
+
nql: MemoryNQLRunner;
|
|
25
|
+
up(): Promise<void>;
|
|
26
|
+
down(): Promise<void>;
|
|
27
|
+
private connect;
|
|
28
|
+
static db(service: BrowserDBService, module: Module<any, $Module>): Promise<IDBDatabase>;
|
|
29
|
+
static wrap(service: string): (trx: AnyTrx, fn: TrxEngineWrapFn<any, any>, services: Record<string, any>) => Promise<any>;
|
|
30
|
+
}
|