nesoi 3.0.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/lib/adapters/postgres/src/migrator/database.d.ts +37 -0
- package/lib/adapters/postgres/src/migrator/database.js +88 -0
- package/lib/adapters/postgres/src/migrator/index.d.ts +1 -0
- package/lib/adapters/postgres/src/migrator/index.js +5 -0
- package/lib/adapters/postgres/src/migrator/migration.d.ts +73 -0
- package/lib/adapters/postgres/src/migrator/migration.js +351 -0
- package/lib/adapters/postgres/src/migrator/migrator.d.ts +21 -0
- package/lib/adapters/postgres/src/migrator/migrator.js +73 -0
- package/lib/adapters/postgres/src/migrator/runner.d.ts +61 -0
- package/lib/adapters/postgres/src/migrator/runner.js +202 -0
- package/lib/adapters/postgres/src/postgres.bucket_adapter.d.ts +45 -0
- package/lib/adapters/postgres/src/postgres.bucket_adapter.js +278 -0
- package/lib/adapters/postgres/src/postgres.cli.d.ts +46 -0
- package/lib/adapters/postgres/src/postgres.cli.js +124 -0
- package/lib/adapters/postgres/src/postgres.nql.d.ts +12 -0
- package/lib/adapters/postgres/src/postgres.nql.js +69 -0
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.d.ts +1 -0
- package/lib/adapters/postgres/test/postgres.bucket_adapter.test.js +173 -0
- package/lib/adapters/postgres/test/postgres.bucket_query.test.d.ts +0 -0
- package/lib/adapters/postgres/test/postgres.bucket_query.test.js +136 -0
- package/lib/compiler/apps/monolyth/monolyth_compiler.d.ts +21 -0
- package/lib/compiler/apps/monolyth/monolyth_compiler.js +95 -0
- package/lib/compiler/apps/monolyth/stages/1_mkdir_stage.d.ts +12 -0
- package/lib/compiler/apps/monolyth/stages/1_mkdir_stage.js +80 -0
- package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.d.ts +12 -0
- package/lib/compiler/apps/monolyth/stages/2_build_typescript_stage.js +128 -0
- package/lib/compiler/apps/monolyth/stages/3_copy_types_stage.d.ts +12 -0
- package/lib/compiler/apps/monolyth/stages/3_copy_types_stage.js +75 -0
- package/lib/compiler/apps/monolyth/stages/4_dump_modules_stage.d.ts +13 -0
- package/lib/compiler/apps/monolyth/stages/4_dump_modules_stage.js +130 -0
- package/lib/compiler/apps/monolyth/stages/5_dump_cli_stage.d.ts +12 -0
- package/lib/compiler/apps/monolyth/stages/5_dump_cli_stage.js +65 -0
- package/lib/compiler/apps/monolyth/stages/6_dump_package_json_stage.d.ts +12 -0
- package/lib/compiler/apps/monolyth/stages/6_dump_package_json_stage.js +74 -0
- package/lib/compiler/compiler.d.ts +19 -0
- package/lib/compiler/compiler.js +83 -0
- package/lib/compiler/elements/bucket.element.d.ts +23 -0
- package/lib/compiler/elements/bucket.element.js +304 -0
- package/lib/compiler/elements/constants.element.d.ts +9 -0
- package/lib/compiler/elements/constants.element.js +88 -0
- package/lib/compiler/elements/controller.element.d.ts +6 -0
- package/lib/compiler/elements/controller.element.js +22 -0
- package/lib/compiler/elements/element.d.ts +49 -0
- package/lib/compiler/elements/element.js +105 -0
- package/lib/compiler/elements/externals.element.d.ts +19 -0
- package/lib/compiler/elements/externals.element.js +83 -0
- package/lib/compiler/elements/job.element.d.ts +7 -0
- package/lib/compiler/elements/job.element.js +62 -0
- package/lib/compiler/elements/machine.element.d.ts +10 -0
- package/lib/compiler/elements/machine.element.js +98 -0
- package/lib/compiler/elements/message.element.d.ts +9 -0
- package/lib/compiler/elements/message.element.js +175 -0
- package/lib/compiler/elements/queue.element.d.ts +6 -0
- package/lib/compiler/elements/queue.element.js +24 -0
- package/lib/compiler/elements/resource.element.d.ts +7 -0
- package/lib/compiler/elements/resource.element.js +64 -0
- package/lib/compiler/error.d.ts +21 -0
- package/lib/compiler/error.js +57 -0
- package/lib/compiler/helpers/dump_helpers.d.ts +11 -0
- package/lib/compiler/helpers/dump_helpers.js +157 -0
- package/lib/compiler/helpers/name_helpers.d.ts +20 -0
- package/lib/compiler/helpers/name_helpers.js +44 -0
- package/lib/compiler/index.d.ts +2 -0
- package/lib/compiler/index.js +7 -0
- package/lib/compiler/module.d.ts +24 -0
- package/lib/compiler/module.js +122 -0
- package/lib/compiler/stages/1_scan_stage.d.ts +10 -0
- package/lib/compiler/stages/1_scan_stage.js +23 -0
- package/lib/compiler/stages/2_treeshake_stage.d.ts +11 -0
- package/lib/compiler/stages/2_treeshake_stage.js +24 -0
- package/lib/compiler/stages/3_extract_ts_stage.d.ts +10 -0
- package/lib/compiler/stages/3_extract_ts_stage.js +71 -0
- package/lib/compiler/stages/4_build_schemas_stage.d.ts +10 -0
- package/lib/compiler/stages/4_build_schemas_stage.js +25 -0
- package/lib/compiler/stages/5_inject_ts_stage.d.ts +10 -0
- package/lib/compiler/stages/5_inject_ts_stage.js +22 -0
- package/lib/compiler/stages/6_build_elements_stage.d.ts +11 -0
- package/lib/compiler/stages/6_build_elements_stage.js +22 -0
- package/lib/compiler/stages/7_dump_stage.d.ts +14 -0
- package/lib/compiler/stages/7_dump_stage.js +208 -0
- package/lib/compiler/stages/8_diagnose_stage.d.ts +16 -0
- package/lib/compiler/stages/8_diagnose_stage.js +43 -0
- package/lib/compiler/treeshake.d.ts +58 -0
- package/lib/compiler/treeshake.js +424 -0
- package/lib/compiler/typescript/bridge/extract.d.ts +11 -0
- package/lib/compiler/typescript/bridge/extract.js +270 -0
- package/lib/compiler/typescript/bridge/inject.d.ts +10 -0
- package/lib/compiler/typescript/bridge/inject.js +140 -0
- package/lib/compiler/typescript/bridge/organize.d.ts +61 -0
- package/lib/compiler/typescript/bridge/organize.js +258 -0
- package/lib/compiler/typescript/error.d.ts +88 -0
- package/lib/compiler/typescript/error.js +265 -0
- package/lib/compiler/typescript/parser.d.ts +48 -0
- package/lib/compiler/typescript/parser.js +581 -0
- package/lib/compiler/typescript/source.d.ts +12 -0
- package/lib/compiler/typescript/source.js +87 -0
- package/lib/compiler/typescript/transformers/app_inject.transformer.d.ts +2 -0
- package/lib/compiler/typescript/transformers/app_inject.transformer.js +89 -0
- package/lib/compiler/typescript/transformers/replace_import.transformer.d.ts +4 -0
- package/lib/compiler/typescript/transformers/replace_import.transformer.js +102 -0
- package/lib/compiler/typescript/typescript_compiler.d.ts +63 -0
- package/lib/compiler/typescript/typescript_compiler.js +602 -0
- package/lib/elements/blocks/block.builder.d.ts +29 -0
- package/lib/elements/blocks/block.builder.js +87 -0
- package/lib/elements/blocks/block.d.ts +15 -0
- package/lib/elements/blocks/block.js +37 -0
- package/lib/elements/blocks/block.schema.d.ts +23 -0
- package/lib/elements/blocks/block.schema.js +15 -0
- package/lib/elements/blocks/externals/externals.builder.d.ts +30 -0
- package/lib/elements/blocks/externals/externals.builder.js +37 -0
- package/lib/elements/blocks/externals/externals.schema.d.ts +11 -0
- package/lib/elements/blocks/externals/externals.schema.js +19 -0
- package/lib/elements/blocks/job/internal/machine_job.builder.d.ts +52 -0
- package/lib/elements/blocks/job/internal/machine_job.builder.js +74 -0
- package/lib/elements/blocks/job/internal/machine_job.schema.d.ts +5 -0
- package/lib/elements/blocks/job/internal/machine_job.schema.js +10 -0
- package/lib/elements/blocks/job/internal/resource_job.builder.d.ts +109 -0
- package/lib/elements/blocks/job/internal/resource_job.builder.js +146 -0
- package/lib/elements/blocks/job/internal/resource_job.d.ts +14 -0
- package/lib/elements/blocks/job/internal/resource_job.js +30 -0
- package/lib/elements/blocks/job/internal/resource_job.schema.d.ts +11 -0
- package/lib/elements/blocks/job/internal/resource_job.schema.js +15 -0
- package/lib/elements/blocks/job/job.builder.d.ts +118 -0
- package/lib/elements/blocks/job/job.builder.js +137 -0
- package/lib/elements/blocks/job/job.d.ts +13 -0
- package/lib/elements/blocks/job/job.js +40 -0
- package/lib/elements/blocks/job/job.schema.d.ts +26 -0
- package/lib/elements/blocks/job/job.schema.js +20 -0
- package/lib/elements/blocks/machine/machine.builder.d.ts +58 -0
- package/lib/elements/blocks/machine/machine.builder.js +135 -0
- package/lib/elements/blocks/machine/machine.d.ts +86 -0
- package/lib/elements/blocks/machine/machine.js +228 -0
- package/lib/elements/blocks/machine/machine.schema.d.ts +85 -0
- package/lib/elements/blocks/machine/machine.schema.js +64 -0
- package/lib/elements/blocks/machine/machine_state.builder.d.ts +58 -0
- package/lib/elements/blocks/machine/machine_state.builder.js +186 -0
- package/lib/elements/blocks/machine/machine_transition.builder.d.ts +48 -0
- package/lib/elements/blocks/machine/machine_transition.builder.js +98 -0
- package/lib/elements/blocks/queue/adapters/bucket.queue_adapter.d.ts +10 -0
- package/lib/elements/blocks/queue/adapters/bucket.queue_adapter.js +17 -0
- package/lib/elements/blocks/queue/adapters/queue_adapter.d.ts +6 -0
- package/lib/elements/blocks/queue/adapters/queue_adapter.js +6 -0
- package/lib/elements/blocks/queue/queue.builder.d.ts +40 -0
- package/lib/elements/blocks/queue/queue.builder.js +31 -0
- package/lib/elements/blocks/queue/queue.d.ts +9 -0
- package/lib/elements/blocks/queue/queue.js +11 -0
- package/lib/elements/blocks/queue/queue.schema.d.ts +12 -0
- package/lib/elements/blocks/queue/queue.schema.js +17 -0
- package/lib/elements/blocks/resource/resource.builder.d.ts +60 -0
- package/lib/elements/blocks/resource/resource.builder.js +224 -0
- package/lib/elements/blocks/resource/resource.d.ts +48 -0
- package/lib/elements/blocks/resource/resource.js +125 -0
- package/lib/elements/blocks/resource/resource.schema.d.ts +32 -0
- package/lib/elements/blocks/resource/resource.schema.js +30 -0
- package/lib/elements/blocks/resource/resource.types.d.ts +38 -0
- package/lib/elements/blocks/resource/resource.types.js +3 -0
- package/lib/elements/edge/controller/adapters/cli.controller_adapter.d.ts +8 -0
- package/lib/elements/edge/controller/adapters/cli.controller_adapter.js +17 -0
- package/lib/elements/edge/controller/adapters/controller_adapter.d.ts +14 -0
- package/lib/elements/edge/controller/adapters/controller_adapter.js +44 -0
- package/lib/elements/edge/controller/controller.builder.d.ts +78 -0
- package/lib/elements/edge/controller/controller.builder.js +178 -0
- package/lib/elements/edge/controller/controller.config.d.ts +6 -0
- package/lib/elements/edge/controller/controller.config.js +2 -0
- package/lib/elements/edge/controller/controller.d.ts +22 -0
- package/lib/elements/edge/controller/controller.js +41 -0
- package/lib/elements/edge/controller/controller.schema.d.ts +44 -0
- package/lib/elements/edge/controller/controller.schema.js +51 -0
- package/lib/elements/entities/bucket/adapters/bucket_adapter.d.ts +107 -0
- package/lib/elements/entities/bucket/adapters/bucket_adapter.js +41 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.d.ts +37 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_adapter.js +149 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_query copy.d.ts +0 -0
- package/lib/elements/entities/bucket/adapters/memory.bucket_query copy.js +218 -0
- package/lib/elements/entities/bucket/adapters/memory.nql.d.ts +19 -0
- package/lib/elements/entities/bucket/adapters/memory.nql.js +212 -0
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.d.ts +20 -0
- package/lib/elements/entities/bucket/adapters/slow_memory.bucket_adapter.js +31 -0
- package/lib/elements/entities/bucket/bucket.builder.d.ts +61 -0
- package/lib/elements/entities/bucket/bucket.builder.js +130 -0
- package/lib/elements/entities/bucket/bucket.config.d.ts +29 -0
- package/lib/elements/entities/bucket/bucket.config.js +2 -0
- package/lib/elements/entities/bucket/bucket.d.ts +36 -0
- package/lib/elements/entities/bucket/bucket.infer.d.ts +22 -0
- package/lib/elements/entities/bucket/bucket.infer.js +85 -0
- package/lib/elements/entities/bucket/bucket.js +125 -0
- package/lib/elements/entities/bucket/bucket.schema.d.ts +24 -0
- package/lib/elements/entities/bucket/bucket.schema.js +16 -0
- package/lib/elements/entities/bucket/bucket.types.d.ts +32 -0
- package/lib/elements/entities/bucket/bucket.types.js +2 -0
- package/lib/elements/entities/bucket/cache/bucket_cache.d.ts +35 -0
- package/lib/elements/entities/bucket/cache/bucket_cache.js +182 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.builder.d.ts +11 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.builder.js +27 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.d.ts +16 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.infer.d.ts +9 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.infer.js +2 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.js +136 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.d.ts +28 -0
- package/lib/elements/entities/bucket/graph/bucket_graph.schema.js +27 -0
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.d.ts +36 -0
- package/lib/elements/entities/bucket/graph/bucket_graph_link.builder.js +56 -0
- package/lib/elements/entities/bucket/model/bucket_model.builder.d.ts +13 -0
- package/lib/elements/entities/bucket/model/bucket_model.builder.js +24 -0
- package/lib/elements/entities/bucket/model/bucket_model.convert.d.ts +5 -0
- package/lib/elements/entities/bucket/model/bucket_model.convert.js +51 -0
- package/lib/elements/entities/bucket/model/bucket_model.infer.d.ts +13 -0
- package/lib/elements/entities/bucket/model/bucket_model.infer.js +2 -0
- package/lib/elements/entities/bucket/model/bucket_model.schema.d.ts +35 -0
- package/lib/elements/entities/bucket/model/bucket_model.schema.js +47 -0
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +119 -0
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +154 -0
- package/lib/elements/entities/bucket/query/nql.schema.d.ts +140 -0
- package/lib/elements/entities/bucket/query/nql.schema.js +2 -0
- package/lib/elements/entities/bucket/query/nql_compiler.d.ts +44 -0
- package/lib/elements/entities/bucket/query/nql_compiler.js +620 -0
- package/lib/elements/entities/bucket/query/nql_engine.d.ts +16 -0
- package/lib/elements/entities/bucket/query/nql_engine.js +42 -0
- package/lib/elements/entities/bucket/view/bucket_view.builder.d.ts +14 -0
- package/lib/elements/entities/bucket/view/bucket_view.builder.js +24 -0
- package/lib/elements/entities/bucket/view/bucket_view.d.ts +10 -0
- package/lib/elements/entities/bucket/view/bucket_view.js +102 -0
- package/lib/elements/entities/bucket/view/bucket_view.schema.d.ts +55 -0
- package/lib/elements/entities/bucket/view/bucket_view.schema.js +42 -0
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.d.ts +37 -0
- package/lib/elements/entities/bucket/view/bucket_view_field.builder.js +138 -0
- package/lib/elements/entities/constants/constants.builder.d.ts +57 -0
- package/lib/elements/entities/constants/constants.builder.js +116 -0
- package/lib/elements/entities/constants/constants.d.ts +7 -0
- package/lib/elements/entities/constants/constants.js +15 -0
- package/lib/elements/entities/constants/constants.schema.d.ts +51 -0
- package/lib/elements/entities/constants/constants.schema.js +45 -0
- package/lib/elements/entities/message/message.builder.d.ts +33 -0
- package/lib/elements/entities/message/message.builder.js +41 -0
- package/lib/elements/entities/message/message.d.ts +11 -0
- package/lib/elements/entities/message/message.infer.d.ts +63 -0
- package/lib/elements/entities/message/message.infer.js +2 -0
- package/lib/elements/entities/message/message.js +52 -0
- package/lib/elements/entities/message/message.schema.d.ts +15 -0
- package/lib/elements/entities/message/message.schema.js +13 -0
- package/lib/elements/entities/message/message_parser.d.ts +12 -0
- package/lib/elements/entities/message/message_parser.js +112 -0
- package/lib/elements/entities/message/template/message_template.builder.d.ts +14 -0
- package/lib/elements/entities/message/template/message_template.builder.js +20 -0
- package/lib/elements/entities/message/template/message_template.schema.d.ts +57 -0
- package/lib/elements/entities/message/template/message_template.schema.js +28 -0
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +225 -0
- package/lib/elements/entities/message/template/message_template_field.builder.js +172 -0
- package/lib/elements/entities/message/template/message_template_parser.d.ts +3 -0
- package/lib/elements/entities/message/template/message_template_parser.js +83 -0
- package/lib/elements/index.d.ts +11 -0
- package/lib/elements/index.js +23 -0
- package/lib/engine/apps/app.config.d.ts +49 -0
- package/lib/engine/apps/app.config.js +38 -0
- package/lib/engine/apps/app.d.ts +70 -0
- package/lib/engine/apps/app.js +101 -0
- package/lib/engine/apps/inline.app.d.ts +48 -0
- package/lib/engine/apps/inline.app.js +144 -0
- package/lib/engine/apps/monolyth/monolyth.app.d.ts +20 -0
- package/lib/engine/apps/monolyth/monolyth.app.js +94 -0
- package/lib/engine/apps/monolyth/monolyth.cli.d.ts +45 -0
- package/lib/engine/apps/monolyth/monolyth.cli.js +362 -0
- package/lib/engine/auth/authn.d.ts +18 -0
- package/lib/engine/auth/authn.js +9 -0
- package/lib/engine/auth/zero.authn_provider.d.ts +13 -0
- package/lib/engine/auth/zero.authn_provider.js +13 -0
- package/lib/engine/cli/cli.d.ts +19 -0
- package/lib/engine/cli/cli.js +88 -0
- package/lib/engine/cli/cli_adapter.d.ts +18 -0
- package/lib/engine/cli/cli_adapter.js +61 -0
- package/lib/engine/cli/ui.d.ts +36 -0
- package/lib/engine/cli/ui.js +188 -0
- package/lib/engine/daemon.d.ts +35 -0
- package/lib/engine/daemon.js +66 -0
- package/lib/engine/data/date.d.ts +10 -0
- package/lib/engine/data/date.js +32 -0
- package/lib/engine/data/datetime.d.ts +12 -0
- package/lib/engine/data/datetime.js +31 -0
- package/lib/engine/data/decimal.d.ts +11 -0
- package/lib/engine/data/decimal.js +70 -0
- package/lib/engine/data/error.d.ts +213 -0
- package/lib/engine/data/error.js +386 -0
- package/lib/engine/data/obj.d.ts +16 -0
- package/lib/engine/data/obj.js +5 -0
- package/lib/engine/data/tree.d.ts +17 -0
- package/lib/engine/data/tree.js +111 -0
- package/lib/engine/dependency.d.ts +68 -0
- package/lib/engine/dependency.js +91 -0
- package/lib/engine/module.d.ts +97 -0
- package/lib/engine/module.js +335 -0
- package/lib/engine/space.d.ts +54 -0
- package/lib/engine/space.js +138 -0
- package/lib/engine/transaction/nodes/bucket.trx_node.d.ts +53 -0
- package/lib/engine/transaction/nodes/bucket.trx_node.js +522 -0
- package/lib/engine/transaction/nodes/bucket_query.trx_node.d.ts +17 -0
- package/lib/engine/transaction/nodes/bucket_query.trx_node.js +82 -0
- package/lib/engine/transaction/nodes/job.trx_node.d.ts +13 -0
- package/lib/engine/transaction/nodes/job.trx_node.js +40 -0
- package/lib/engine/transaction/nodes/machine.trx_node.d.ts +12 -0
- package/lib/engine/transaction/nodes/machine.trx_node.js +39 -0
- package/lib/engine/transaction/nodes/queue.trx_node.d.ts +10 -0
- package/lib/engine/transaction/nodes/queue.trx_node.js +24 -0
- package/lib/engine/transaction/nodes/resource.trx_node.d.ts +24 -0
- package/lib/engine/transaction/nodes/resource.trx_node.js +77 -0
- package/lib/engine/transaction/trx.d.ts +50 -0
- package/lib/engine/transaction/trx.js +94 -0
- package/lib/engine/transaction/trx_engine.config.d.ts +15 -0
- package/lib/engine/transaction/trx_engine.config.js +2 -0
- package/lib/engine/transaction/trx_engine.d.ts +27 -0
- package/lib/engine/transaction/trx_engine.js +95 -0
- package/lib/engine/transaction/trx_node.d.ts +61 -0
- package/lib/engine/transaction/trx_node.js +175 -0
- package/lib/engine/tree.d.ts +34 -0
- package/lib/engine/tree.js +237 -0
- package/lib/engine/util/cache.d.ts +6 -0
- package/lib/engine/util/cache.js +20 -0
- package/lib/engine/util/console.d.ts +4 -0
- package/lib/engine/util/console.js +24 -0
- package/lib/engine/util/deep.d.ts +7 -0
- package/lib/engine/util/deep.js +2 -0
- package/lib/engine/util/dotenv.d.ts +15 -0
- package/lib/engine/util/dotenv.js +94 -0
- package/lib/engine/util/i18n.d.ts +5 -0
- package/lib/engine/util/i18n.js +19 -0
- package/lib/engine/util/log.d.ts +17 -0
- package/lib/engine/util/log.js +93 -0
- package/lib/engine/util/parse.d.ts +63 -0
- package/lib/engine/util/parse.js +229 -0
- package/lib/engine/util/promise.d.ts +3 -0
- package/lib/engine/util/promise.js +14 -0
- package/lib/engine/util/shell.d.ts +6 -0
- package/lib/engine/util/shell.js +44 -0
- package/lib/engine/util/string.d.ts +18 -0
- package/lib/engine/util/string.js +25 -0
- package/lib/engine/util/type.d.ts +7 -0
- package/lib/engine/util/type.js +3 -0
- package/lib/schema.d.ts +63 -0
- package/lib/schema.js +2 -0
- package/package.json +22 -0
- package/tools/compile.d.ts +1 -0
- package/tools/compile.js +68 -0
- package/tools/joaquin/job.d.ts +40 -0
- package/tools/joaquin/job.js +47 -0
- package/tools/joaquin/message.d.ts +12 -0
- package/tools/joaquin/message.js +47 -0
- package/tools/joaquin/mock.d.ts +28 -0
- package/tools/joaquin/mock.js +128 -0
- package/tsconfig.build.tsbuildinfo +1 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BucketCache = exports.BucketCacheEntry = void 0;
|
|
4
|
+
const log_1 = require("../../../../engine/util/log");
|
|
5
|
+
const memory_bucket_adapter_1 = require("../adapters/memory.bucket_adapter");
|
|
6
|
+
const datetime_1 = require("../../../../engine/data/datetime");
|
|
7
|
+
class BucketCacheEntry {
|
|
8
|
+
constructor(id, obj, updateEpoch, syncEpoch) {
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.obj = obj;
|
|
11
|
+
this.updateEpoch = updateEpoch;
|
|
12
|
+
this.syncEpoch = syncEpoch;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BucketCacheEntry = BucketCacheEntry;
|
|
16
|
+
class BucketCache {
|
|
17
|
+
constructor(bucketName, outerAdapter, config) {
|
|
18
|
+
this.bucketName = bucketName;
|
|
19
|
+
this.outerAdapter = outerAdapter;
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.innerAdapter = this.config?.adapter || new memory_bucket_adapter_1.MemoryBucketAdapter({}, {});
|
|
22
|
+
}
|
|
23
|
+
async get(trx, id) {
|
|
24
|
+
const mode = this.config?.mode?.get;
|
|
25
|
+
if (mode === 'one') {
|
|
26
|
+
const { action, sync } = await this.syncOne(trx, id);
|
|
27
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE get.one, ${action}`);
|
|
28
|
+
return sync?.obj;
|
|
29
|
+
}
|
|
30
|
+
if (mode === 'past') {
|
|
31
|
+
const { action, sync } = await this.syncOneAndPast(trx, id);
|
|
32
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE get.past, ${action}`);
|
|
33
|
+
return sync?.obj;
|
|
34
|
+
}
|
|
35
|
+
if (mode === 'all') {
|
|
36
|
+
const { action, sync } = await this.syncAll(trx);
|
|
37
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE get.sync, ${action}`);
|
|
38
|
+
return sync.find(s => s.obj.id === id)?.obj;
|
|
39
|
+
}
|
|
40
|
+
return this.outerAdapter.get(trx, id);
|
|
41
|
+
}
|
|
42
|
+
async index(trx) {
|
|
43
|
+
const mode = this.config?.mode?.index;
|
|
44
|
+
if (mode === 'all') {
|
|
45
|
+
const { action, sync } = await this.syncAll(trx);
|
|
46
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE index.sync, ${action}`);
|
|
47
|
+
return sync.map(s => s.obj);
|
|
48
|
+
}
|
|
49
|
+
return this.outerAdapter.index(trx);
|
|
50
|
+
}
|
|
51
|
+
async query(trx, view, query, pagination) {
|
|
52
|
+
const mode = this.config?.mode?.query;
|
|
53
|
+
if (mode === 'incremental') {
|
|
54
|
+
const { action, sync } = await this.syncQuery(trx, view, query, pagination);
|
|
55
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE query.incremental, ${action}`);
|
|
56
|
+
return sync.map(s => s.obj);
|
|
57
|
+
}
|
|
58
|
+
if (mode === 'all') {
|
|
59
|
+
const { action, sync } = await this.syncAll(trx);
|
|
60
|
+
log_1.Log.debug('bucket', this.bucketName, `CACHE query.sync, ${action}`);
|
|
61
|
+
return this.innerAdapter.query(trx, query);
|
|
62
|
+
}
|
|
63
|
+
return this.outerAdapter.query(trx, query);
|
|
64
|
+
}
|
|
65
|
+
/* Cache modes */
|
|
66
|
+
async syncOne(trx, id) {
|
|
67
|
+
const localObj = await this.innerAdapter.get(trx, id);
|
|
68
|
+
if (!localObj) {
|
|
69
|
+
const obj = await this.outerAdapter.get(trx, id);
|
|
70
|
+
if (obj) {
|
|
71
|
+
const entry = new BucketCacheEntry(obj.id, obj, this.outerAdapter.getUpdateEpoch(obj), this.lastSyncEpoch);
|
|
72
|
+
await this.innerAdapter.put(trx, entry);
|
|
73
|
+
return { action: 'update', sync: entry };
|
|
74
|
+
}
|
|
75
|
+
return { action: 'keep' };
|
|
76
|
+
}
|
|
77
|
+
const sync = await this.outerAdapter.syncOne(trx, id, localObj.updateEpoch);
|
|
78
|
+
if (sync === null) {
|
|
79
|
+
return { action: 'keep', sync: localObj };
|
|
80
|
+
}
|
|
81
|
+
if (sync === 'deleted') {
|
|
82
|
+
await this.innerAdapter.delete(trx, id);
|
|
83
|
+
return { action: 'delete' };
|
|
84
|
+
}
|
|
85
|
+
localObj.obj = sync.obj;
|
|
86
|
+
localObj.updateEpoch = sync.updateEpoch;
|
|
87
|
+
localObj.syncEpoch = datetime_1.NesoiDatetime.now().epoch;
|
|
88
|
+
await this.innerAdapter.put(trx, localObj);
|
|
89
|
+
return { action: 'update', sync };
|
|
90
|
+
}
|
|
91
|
+
async syncOneAndPast(trx, id) {
|
|
92
|
+
const localObj = await this.innerAdapter.get(trx, id);
|
|
93
|
+
if (!localObj) {
|
|
94
|
+
const obj = await this.outerAdapter.get(trx, id);
|
|
95
|
+
if (obj) {
|
|
96
|
+
await this.innerAdapter.put(trx, obj);
|
|
97
|
+
return { action: 'update', sync: {
|
|
98
|
+
obj,
|
|
99
|
+
updateEpoch: this.outerAdapter.getUpdateEpoch(obj)
|
|
100
|
+
} };
|
|
101
|
+
}
|
|
102
|
+
return { action: 'keep' };
|
|
103
|
+
}
|
|
104
|
+
const sync = await this.outerAdapter.syncOneAndPast(trx, id, localObj.updateEpoch);
|
|
105
|
+
if (sync === null) {
|
|
106
|
+
return { action: 'keep', sync: localObj };
|
|
107
|
+
}
|
|
108
|
+
if (sync === 'deleted') {
|
|
109
|
+
await this.innerAdapter.delete(trx, id);
|
|
110
|
+
return { action: 'delete' };
|
|
111
|
+
}
|
|
112
|
+
await this.innerAdapter.putMany(trx, sync.map(s => s.obj));
|
|
113
|
+
return { action: 'update', sync: sync.find(s => s.obj.id === id) };
|
|
114
|
+
}
|
|
115
|
+
async syncAll(trx) {
|
|
116
|
+
const sync = await this.outerAdapter.syncAll(trx, this.lastHash, this.lastUpdateEpoch);
|
|
117
|
+
if (sync === null) {
|
|
118
|
+
const all = await this.innerAdapter.index(trx);
|
|
119
|
+
return { action: 'keep', sync: all };
|
|
120
|
+
}
|
|
121
|
+
this.lastUpdateEpoch = sync.updateEpoch;
|
|
122
|
+
this.lastHash = sync.hash;
|
|
123
|
+
this.lastSyncEpoch = datetime_1.NesoiDatetime.now().epoch;
|
|
124
|
+
const entries = sync.sync.map(s => new BucketCacheEntry(s.obj.id, s.obj, s.updateEpoch, this.lastSyncEpoch));
|
|
125
|
+
if (sync.reset) {
|
|
126
|
+
await this.innerAdapter.deleteEverything(trx);
|
|
127
|
+
await this.innerAdapter.putMany(trx, entries);
|
|
128
|
+
return { action: 'reset', sync: sync.sync };
|
|
129
|
+
}
|
|
130
|
+
await this.innerAdapter.putMany(trx, entries);
|
|
131
|
+
return { action: 'update', sync: sync.sync };
|
|
132
|
+
}
|
|
133
|
+
async syncQuery(trx, view, query, pagination) {
|
|
134
|
+
// 1. Query id and epoch from outer adapter
|
|
135
|
+
const outerMetadata = await this.outerAdapter.query(trx, query, pagination, {
|
|
136
|
+
metadataOnly: true
|
|
137
|
+
});
|
|
138
|
+
if (!outerMetadata.length) {
|
|
139
|
+
return { action: 'keep', sync: [] };
|
|
140
|
+
}
|
|
141
|
+
// 2. Read ids from the inner adapter
|
|
142
|
+
const innerData = await this.innerAdapter.query(trx, {
|
|
143
|
+
'id in': outerMetadata.map(obj => obj.id)
|
|
144
|
+
});
|
|
145
|
+
// 3. Filter modified query results
|
|
146
|
+
const outerEpoch = {};
|
|
147
|
+
for (const i in outerMetadata) {
|
|
148
|
+
const obj = outerMetadata[i];
|
|
149
|
+
outerEpoch[obj.id] = this.outerAdapter.getUpdateEpoch(obj);
|
|
150
|
+
}
|
|
151
|
+
const queryResults = {};
|
|
152
|
+
const modifiedIds = [];
|
|
153
|
+
for (const i in innerData) {
|
|
154
|
+
const obj = innerData[i];
|
|
155
|
+
const epoch = outerEpoch[obj.id];
|
|
156
|
+
if (!epoch || epoch > obj.updateEpoch) {
|
|
157
|
+
modifiedIds.push(obj.id);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
queryResults[obj.id] = obj;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// 4. Nothing changed, return current data
|
|
164
|
+
if (!modifiedIds.length) {
|
|
165
|
+
return { action: 'keep', sync: innerData };
|
|
166
|
+
}
|
|
167
|
+
// 5. Query modified objects to outer adapter and merge them on results
|
|
168
|
+
const outerData = await this.outerAdapter.query(trx, {
|
|
169
|
+
'id in': modifiedIds
|
|
170
|
+
});
|
|
171
|
+
for (const i in outerData) {
|
|
172
|
+
const obj = outerData[i];
|
|
173
|
+
const updateEpoch = this.outerAdapter.getUpdateEpoch(obj);
|
|
174
|
+
queryResults[obj.id] = {
|
|
175
|
+
obj,
|
|
176
|
+
updateEpoch
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return { action: 'update', sync: Object.values(queryResults) };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.BucketCache = BucketCache;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { $Module } from "../../../../schema";
|
|
2
|
+
import { $BucketGraph } from './bucket_graph.schema';
|
|
3
|
+
import { BucketGraphLinkBuilders, BucketGraphLinkFactory } from './bucket_graph_link.builder';
|
|
4
|
+
import { BucketBuilderNode } from '../bucket.builder';
|
|
5
|
+
import { $Bucket } from '../bucket.schema';
|
|
6
|
+
export declare class BucketGraphBuilder<Module extends $Module> {
|
|
7
|
+
private _links;
|
|
8
|
+
links(builders: BucketGraphLinkBuilders): this;
|
|
9
|
+
static build(node: BucketBuilderNode, builder: BucketGraphBuilder<any>): $BucketGraph;
|
|
10
|
+
}
|
|
11
|
+
export type BucketGraphDef<Module extends $Module, SelfBucket extends $Bucket> = ($: BucketGraphLinkFactory<Module, SelfBucket>) => BucketGraphLinkBuilders;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BucketGraphBuilder = void 0;
|
|
4
|
+
const bucket_graph_schema_1 = require("./bucket_graph.schema");
|
|
5
|
+
const bucket_graph_link_builder_1 = require("./bucket_graph_link.builder");
|
|
6
|
+
/*
|
|
7
|
+
Builder
|
|
8
|
+
*/
|
|
9
|
+
class BucketGraphBuilder {
|
|
10
|
+
constructor() {
|
|
11
|
+
this._links = {};
|
|
12
|
+
}
|
|
13
|
+
links(builders) {
|
|
14
|
+
this._links = builders;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
// Build
|
|
18
|
+
static build(node, builder) {
|
|
19
|
+
const links = {};
|
|
20
|
+
for (const k in builder._links) {
|
|
21
|
+
const link = builder._links[k];
|
|
22
|
+
links[k] = bucket_graph_link_builder_1.BucketGraphLinkBuilder.build(node, link, k);
|
|
23
|
+
}
|
|
24
|
+
return new bucket_graph_schema_1.$BucketGraph(links);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.BucketGraphBuilder = BucketGraphBuilder;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
2
|
+
import { $Module, ViewName, ViewObj } from "../../../../schema";
|
|
3
|
+
import { Bucket } from '../bucket';
|
|
4
|
+
import { $Bucket } from '../bucket.schema';
|
|
5
|
+
export declare class BucketGraph<M extends $Module, $ extends $Bucket> {
|
|
6
|
+
private bucket;
|
|
7
|
+
private bucketName;
|
|
8
|
+
private schema;
|
|
9
|
+
constructor(bucket: Bucket<M, $>);
|
|
10
|
+
readLinkOrFail<LinkName extends keyof $['graph']['links'], LinkBucketName extends $['graph']['links'][LinkName]['bucket']['refName'], LinkBucket extends M['buckets'][LinkBucketName], V extends ViewName<LinkBucket>, Obj extends ViewObj<LinkBucket, V>>(trx: AnyTrxNode, link: LinkName, obj: $['#data'], view?: V, index?: (string | number)[]): Promise<Obj | Obj[]>;
|
|
11
|
+
readLink<LinkName extends keyof $['graph']['links'], LinkBucketName extends $['graph']['links'][LinkName]['bucket']['refName'], LinkBucket extends M['buckets'][LinkBucketName], V extends ViewName<LinkBucket>, Obj extends ViewObj<LinkBucket, V>>(trx: AnyTrxNode, link: LinkName, obj: $['#data'], view?: V, index?: (string | number)[]): Promise<Obj | Obj[] | undefined>;
|
|
12
|
+
private readOneLink;
|
|
13
|
+
private readManyLink;
|
|
14
|
+
hasLink<LinkName extends keyof $['graph']['links']>(trx: AnyTrxNode, link: LinkName, obj: $['#data']): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export type AnyBucket = Bucket<any, any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Overlay } from "../../../../engine/util/type";
|
|
2
|
+
import { $BucketGraphLink } from './bucket_graph.schema';
|
|
3
|
+
import { BucketGraphLinkBuilder, BucketGraphLinkBuilders } from './bucket_graph_link.builder';
|
|
4
|
+
export type $BucketGraphLinksInfer<Builders extends BucketGraphLinkBuilders> = {
|
|
5
|
+
[K in keyof Builders]: Builders[K] extends BucketGraphLinkBuilder<any, any, infer Y> ? Overlay<$BucketGraphLink, {
|
|
6
|
+
'#bucket': Y;
|
|
7
|
+
'#data': Y['#data'];
|
|
8
|
+
}> : never;
|
|
9
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BucketGraph = void 0;
|
|
4
|
+
const log_1 = require("../../../../engine/util/log");
|
|
5
|
+
const tree_1 = require("../../../../engine/data/tree");
|
|
6
|
+
const error_1 = require("../../../../engine/data/error");
|
|
7
|
+
class BucketGraph {
|
|
8
|
+
constructor(bucket) {
|
|
9
|
+
this.bucket = bucket;
|
|
10
|
+
this.bucketName = bucket.schema.name;
|
|
11
|
+
this.schema = bucket.schema.graph;
|
|
12
|
+
}
|
|
13
|
+
// Graph
|
|
14
|
+
async readLinkOrFail(trx, link, obj, view = 'default', index = []) {
|
|
15
|
+
const res = await this.readLink(trx, link, obj, view, index);
|
|
16
|
+
if (!res) {
|
|
17
|
+
const linkSchema = this.schema.links[link];
|
|
18
|
+
// TODO: get bucket alias instead of name (for error message)
|
|
19
|
+
throw error_1.NesoiError.Bucket.ObjNotFound({ bucket: linkSchema.bucket.name, id: obj.id });
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
async readLink(trx, link, obj, view = 'default', index = []) {
|
|
24
|
+
const schema = this.schema.links[link];
|
|
25
|
+
log_1.Log.trace('bucket', this.bucketName, `Read link ${link}`, schema);
|
|
26
|
+
const selfValue = tree_1.Tree.get(obj, schema.selfKey, index);
|
|
27
|
+
if (!selfValue) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
// Validate value type
|
|
31
|
+
if (schema.many) {
|
|
32
|
+
if (schema.keyOwner === 'self') {
|
|
33
|
+
if (!Array.isArray(selfValue)) {
|
|
34
|
+
throw error_1.NesoiError.Bucket.Graph.LinkManyRefOnSelfWithoutArrayValue(schema.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (Array.isArray(selfValue)) {
|
|
39
|
+
throw error_1.NesoiError.Bucket.Graph.LinkManyRefOffSelfWithArrayValue(schema.name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (Array.isArray(selfValue)) {
|
|
45
|
+
throw error_1.NesoiError.Bucket.Graph.LinkOneWithArrayValue(schema.name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//
|
|
49
|
+
const links = schema.many
|
|
50
|
+
? await this.readManyLink(trx, schema, selfValue, view)
|
|
51
|
+
: await this.readOneLink(trx, schema, selfValue, view);
|
|
52
|
+
if (!schema.many && !schema.optional && !links) {
|
|
53
|
+
throw error_1.NesoiError.Bucket.Graph.RequiredLinkNotFound(schema.name, selfValue);
|
|
54
|
+
}
|
|
55
|
+
return links;
|
|
56
|
+
}
|
|
57
|
+
async readOneLink(trx, link, selfValue, view) {
|
|
58
|
+
const linkBucket = trx.bucket(link.bucket.refName);
|
|
59
|
+
if (link.keyOwner === 'self' || link.keyOwner === 'other') {
|
|
60
|
+
const q = linkBucket.query({
|
|
61
|
+
[link.otherKey]: selfValue
|
|
62
|
+
}, view);
|
|
63
|
+
if (link.query) {
|
|
64
|
+
q.merge(link.query);
|
|
65
|
+
}
|
|
66
|
+
return q.first();
|
|
67
|
+
}
|
|
68
|
+
else if (link.keyOwner === 'pivot') {
|
|
69
|
+
const pivotBucket = trx.bucket(link.pivotBucket);
|
|
70
|
+
const pivotSelfKey = this.bucket.schema.name + '_id';
|
|
71
|
+
const pivotOtherKey = link.bucket + '_id';
|
|
72
|
+
const pivotObj = await linkBucket.query({
|
|
73
|
+
[pivotSelfKey]: selfValue
|
|
74
|
+
}, view).first();
|
|
75
|
+
const pivotValue = pivotObj[pivotOtherKey];
|
|
76
|
+
if (pivotValue === undefined || pivotValue === null) {
|
|
77
|
+
throw error_1.NesoiError.Bucket.Graph.PivotValueIsUndefined(link.name);
|
|
78
|
+
}
|
|
79
|
+
const q = linkBucket.query({
|
|
80
|
+
[link.otherKey]: pivotValue
|
|
81
|
+
}, view);
|
|
82
|
+
if (link.query) {
|
|
83
|
+
q.merge(link.query);
|
|
84
|
+
}
|
|
85
|
+
return q.first();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async readManyLink(trx, link, selfValue, view) {
|
|
89
|
+
const linkBucket = trx.bucket(link.bucket.refName);
|
|
90
|
+
if (link.keyOwner === 'self') {
|
|
91
|
+
const q = linkBucket.query({
|
|
92
|
+
[link.otherKey]: selfValue
|
|
93
|
+
}, view);
|
|
94
|
+
if (link.query) {
|
|
95
|
+
q.merge(link.query);
|
|
96
|
+
}
|
|
97
|
+
return q.all();
|
|
98
|
+
}
|
|
99
|
+
else if (link.keyOwner === 'other') {
|
|
100
|
+
const q = linkBucket.query({
|
|
101
|
+
[link.otherKey]: selfValue
|
|
102
|
+
}, view);
|
|
103
|
+
if (link.query) {
|
|
104
|
+
q.merge(link.query);
|
|
105
|
+
}
|
|
106
|
+
return q.all();
|
|
107
|
+
}
|
|
108
|
+
else if (link.keyOwner === 'pivot') {
|
|
109
|
+
const pivotBucket = trx.bucket(link.pivotBucket);
|
|
110
|
+
const pivotSelfKey = this.bucket.schema.name + '_id';
|
|
111
|
+
const pivotOtherKey = link.bucket + '_id';
|
|
112
|
+
const q = pivotBucket.query({
|
|
113
|
+
[pivotSelfKey]: selfValue
|
|
114
|
+
}, view);
|
|
115
|
+
if (link.query) {
|
|
116
|
+
q.merge(link.query);
|
|
117
|
+
}
|
|
118
|
+
const pivotObjs = await q.all();
|
|
119
|
+
const pivotValues = pivotObjs.map(obj => obj[pivotOtherKey]);
|
|
120
|
+
if (!pivotValues.length) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
return linkBucket.query({
|
|
124
|
+
[`${link.otherKey} in`]: pivotValues
|
|
125
|
+
}, view);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async hasLink(trx, link, obj) {
|
|
129
|
+
const links = await this.readLink(trx, link, obj);
|
|
130
|
+
if (Array.isArray(links)) {
|
|
131
|
+
return !!links.length;
|
|
132
|
+
}
|
|
133
|
+
return !!links;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.BucketGraph = BucketGraph;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { $Dependency } from "../../../../engine/dependency";
|
|
2
|
+
import { $Bucket } from '../bucket.schema';
|
|
3
|
+
import { AnyQuery } from '../query/nql.schema';
|
|
4
|
+
export declare class $BucketGraphLink {
|
|
5
|
+
name: string;
|
|
6
|
+
alias: string;
|
|
7
|
+
bucket: $Dependency;
|
|
8
|
+
rel: 'aggregation' | 'composition';
|
|
9
|
+
many: boolean;
|
|
10
|
+
optional: boolean;
|
|
11
|
+
keyOwner: 'self' | 'other' | 'pivot';
|
|
12
|
+
selfKey: string;
|
|
13
|
+
otherKey: string;
|
|
14
|
+
pivotBucket?: string | undefined;
|
|
15
|
+
query?: AnyQuery<any, any> | undefined;
|
|
16
|
+
$t: string;
|
|
17
|
+
'#bucket': $Bucket;
|
|
18
|
+
'#many': boolean;
|
|
19
|
+
constructor(name: string, alias: string, bucket: $Dependency, rel: 'aggregation' | 'composition', many: boolean, optional: boolean, keyOwner: 'self' | 'other' | 'pivot', selfKey: string, otherKey: string, pivotBucket?: string | undefined, query?: AnyQuery<any, any> | undefined);
|
|
20
|
+
}
|
|
21
|
+
export type $BucketGraphLinks = {
|
|
22
|
+
[x: string]: $BucketGraphLink;
|
|
23
|
+
};
|
|
24
|
+
export declare class $BucketGraph {
|
|
25
|
+
links: $BucketGraphLinks;
|
|
26
|
+
$t: string;
|
|
27
|
+
constructor(links?: $BucketGraphLinks);
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$BucketGraph = exports.$BucketGraphLink = void 0;
|
|
4
|
+
class $BucketGraphLink {
|
|
5
|
+
constructor(name, alias, bucket, rel, many, optional, keyOwner, selfKey, otherKey, pivotBucket, query) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.alias = alias;
|
|
8
|
+
this.bucket = bucket;
|
|
9
|
+
this.rel = rel;
|
|
10
|
+
this.many = many;
|
|
11
|
+
this.optional = optional;
|
|
12
|
+
this.keyOwner = keyOwner;
|
|
13
|
+
this.selfKey = selfKey;
|
|
14
|
+
this.otherKey = otherKey;
|
|
15
|
+
this.pivotBucket = pivotBucket;
|
|
16
|
+
this.query = query;
|
|
17
|
+
this.$t = 'bucket.graph.link';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.$BucketGraphLink = $BucketGraphLink;
|
|
21
|
+
class $BucketGraph {
|
|
22
|
+
constructor(links = {}) {
|
|
23
|
+
this.links = links;
|
|
24
|
+
this.$t = 'bucket.graph';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.$BucketGraph = $BucketGraph;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { $Module } from "../../../../schema";
|
|
2
|
+
import { $BucketGraphLink } from './bucket_graph.schema';
|
|
3
|
+
import { BucketBuilderNode } from '../bucket.builder';
|
|
4
|
+
import { $Dependency } from "../../../../engine/dependency";
|
|
5
|
+
import { $Bucket } from '../bucket.schema';
|
|
6
|
+
import { NQL_Query } from '../query/nql.schema';
|
|
7
|
+
export declare class BucketGraphLinkFactory<Module extends $Module, SelfBucket extends $Bucket, Fieldpaths = NoInfer<SelfBucket['#fieldpath']>> {
|
|
8
|
+
private module;
|
|
9
|
+
private alias?;
|
|
10
|
+
private type;
|
|
11
|
+
constructor(module: string);
|
|
12
|
+
as(alias: string): this;
|
|
13
|
+
get compose(): typeof this;
|
|
14
|
+
one<N extends keyof Module['buckets'], Bucket extends $Bucket = Module['buckets'][N]>(bucket: N, query: NQL_Query<Module, Bucket, Fieldpaths>): BucketGraphLinkBuilder<Module, SelfBucket, Module["buckets"][N]>;
|
|
15
|
+
many<N extends keyof Module['buckets'], Bucket extends $Bucket = Module['buckets'][N]>(bucket: N, query: NQL_Query<Module, Bucket, Fieldpaths>): BucketGraphLinkBuilder<Module, SelfBucket, Module["buckets"][N]>;
|
|
16
|
+
}
|
|
17
|
+
export declare class BucketGraphLinkBuilder<Module extends $Module, SelfBucket extends $Bucket, OtherBucket extends $Bucket> {
|
|
18
|
+
private bucket;
|
|
19
|
+
private rel;
|
|
20
|
+
private query;
|
|
21
|
+
private many;
|
|
22
|
+
private alias?;
|
|
23
|
+
private keyOwner;
|
|
24
|
+
private pivotBucket?;
|
|
25
|
+
private selfKey?;
|
|
26
|
+
private otherKey?;
|
|
27
|
+
private _query?;
|
|
28
|
+
private _optional;
|
|
29
|
+
constructor(bucket: $Dependency, rel: 'aggregation' | 'composition', query: NQL_Query<any, any>, many: boolean, alias?: string | undefined);
|
|
30
|
+
as(alias: string): this;
|
|
31
|
+
get optional(): this;
|
|
32
|
+
static build(node: BucketBuilderNode, builder: BucketGraphLinkBuilder<any, any, any>, name: string): $BucketGraphLink;
|
|
33
|
+
}
|
|
34
|
+
export type BucketGraphLinkBuilders = {
|
|
35
|
+
[x: string]: BucketGraphLinkBuilder<any, any, any>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BucketGraphLinkBuilder = exports.BucketGraphLinkFactory = void 0;
|
|
4
|
+
const bucket_graph_schema_1 = require("./bucket_graph.schema");
|
|
5
|
+
const dependency_1 = require("../../../../engine/dependency");
|
|
6
|
+
/*
|
|
7
|
+
Factory
|
|
8
|
+
*/
|
|
9
|
+
class BucketGraphLinkFactory {
|
|
10
|
+
constructor(module) {
|
|
11
|
+
this.module = module;
|
|
12
|
+
this.type = 'aggregation';
|
|
13
|
+
}
|
|
14
|
+
as(alias) {
|
|
15
|
+
this.alias = alias;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
get compose() {
|
|
19
|
+
const self = new BucketGraphLinkFactory(this.module);
|
|
20
|
+
self.type = 'composition';
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
one(bucket, query) {
|
|
24
|
+
return new BucketGraphLinkBuilder(new dependency_1.$Dependency(this.module, 'bucket', bucket, true), this.type, query, false, this.alias);
|
|
25
|
+
}
|
|
26
|
+
many(bucket, query) {
|
|
27
|
+
return new BucketGraphLinkBuilder(new dependency_1.$Dependency(this.module, 'bucket', bucket, true), this.type, query, true, this.alias);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BucketGraphLinkFactory = BucketGraphLinkFactory;
|
|
31
|
+
/*
|
|
32
|
+
Builder
|
|
33
|
+
*/
|
|
34
|
+
class BucketGraphLinkBuilder {
|
|
35
|
+
constructor(bucket, rel, query, many, alias) {
|
|
36
|
+
this.bucket = bucket;
|
|
37
|
+
this.rel = rel;
|
|
38
|
+
this.query = query;
|
|
39
|
+
this.many = many;
|
|
40
|
+
this.alias = alias;
|
|
41
|
+
this.keyOwner = 'self';
|
|
42
|
+
this._optional = false;
|
|
43
|
+
}
|
|
44
|
+
as(alias) {
|
|
45
|
+
this.alias = alias;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
get optional() {
|
|
49
|
+
this._optional = true;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
static build(node, builder, name) {
|
|
53
|
+
return new bucket_graph_schema_1.$BucketGraphLink(name, builder.alias || name, builder.bucket, builder.rel, builder.many, builder._optional, builder.keyOwner, builder.selfKey || 'id', builder.otherKey || 'id', builder.pivotBucket, builder._query);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.BucketGraphLinkBuilder = BucketGraphLinkBuilder;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { $Module, $Space } from "../../../../schema";
|
|
2
|
+
import { $BucketModel } from './bucket_model.schema';
|
|
3
|
+
import { BucketModelFieldBuilder, BucketModelFieldBuilders, BucketModelFieldFactory } from './bucket_model_field.builder';
|
|
4
|
+
export declare class BucketModelBuilder<Module extends $Module> {
|
|
5
|
+
private module;
|
|
6
|
+
constructor(module: string);
|
|
7
|
+
private builders;
|
|
8
|
+
fields(builders: BucketModelFieldBuilders<Module>): this;
|
|
9
|
+
static build(builder: BucketModelBuilder<any>): $BucketModel;
|
|
10
|
+
}
|
|
11
|
+
export type BucketModelDef<Space extends $Space, Module extends $Module> = ($: BucketModelFieldFactory<Space, Module>) => {
|
|
12
|
+
id: BucketModelFieldBuilder<Module, any>;
|
|
13
|
+
} & BucketModelFieldBuilders<Module>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BucketModelBuilder = void 0;
|
|
4
|
+
const bucket_model_schema_1 = require("./bucket_model.schema");
|
|
5
|
+
const bucket_model_field_builder_1 = require("./bucket_model_field.builder");
|
|
6
|
+
/*
|
|
7
|
+
Builder
|
|
8
|
+
*/
|
|
9
|
+
class BucketModelBuilder {
|
|
10
|
+
constructor(module) {
|
|
11
|
+
this.module = module;
|
|
12
|
+
this.builders = {};
|
|
13
|
+
}
|
|
14
|
+
fields(builders) {
|
|
15
|
+
this.builders = builders;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
// Build
|
|
19
|
+
static build(builder) {
|
|
20
|
+
const fields = bucket_model_field_builder_1.BucketModelFieldBuilder.buildChildren(builder.module, builder.builders);
|
|
21
|
+
return new bucket_model_schema_1.$BucketModel(fields.schema, fields.defaults);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.BucketModelBuilder = BucketModelBuilder;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { $BucketModel, $BucketModelFields } from "./bucket_model.schema";
|
|
2
|
+
import { $BucketView } from "../view/bucket_view.schema";
|
|
3
|
+
import { $Message } from "../../message/message.schema";
|
|
4
|
+
export declare function convertToView<Model extends $BucketModel>(model: Model, name: string, fields?: $BucketModelFields, path?: string): $BucketView;
|
|
5
|
+
export declare function convertToMessage<Model extends $BucketModel>(module: string, model: Model, name: string, alias: string, include?: string[], exclude?: string[]): $Message;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToView = convertToView;
|
|
4
|
+
exports.convertToMessage = convertToMessage;
|
|
5
|
+
const bucket_view_builder_1 = require("../view/bucket_view.builder");
|
|
6
|
+
const bucket_view_schema_1 = require("../view/bucket_view.schema");
|
|
7
|
+
const message_template_schema_1 = require("../../message/template/message_template.schema");
|
|
8
|
+
const bucket_graph_schema_1 = require("../graph/bucket_graph.schema");
|
|
9
|
+
const bucket_view_field_builder_1 = require("../view/bucket_view_field.builder");
|
|
10
|
+
const message_schema_1 = require("../../message/message.schema");
|
|
11
|
+
const dependency_1 = require("../../../../engine/dependency");
|
|
12
|
+
function convertToView(model, name, fields = model.fields, path) {
|
|
13
|
+
const view = new bucket_view_builder_1.BucketViewBuilder(name);
|
|
14
|
+
const convertFields = (fields) => {
|
|
15
|
+
const viewFields = {};
|
|
16
|
+
for (const f in fields) {
|
|
17
|
+
const field = fields[f];
|
|
18
|
+
const $ = new bucket_view_field_builder_1.BucketViewFieldFactory(view);
|
|
19
|
+
const key = (path ? path + '.' : '')
|
|
20
|
+
+ field.name;
|
|
21
|
+
const builder = $.model(key);
|
|
22
|
+
const graph = new bucket_graph_schema_1.$BucketGraph();
|
|
23
|
+
viewFields[f] = bucket_view_field_builder_1.BucketViewFieldBuilder.build(builder, model, graph, {}, field.name);
|
|
24
|
+
}
|
|
25
|
+
return viewFields;
|
|
26
|
+
};
|
|
27
|
+
return new bucket_view_schema_1.$BucketView(name, convertFields(fields));
|
|
28
|
+
}
|
|
29
|
+
function convertToMessage(module, model, name, alias, include = [], exclude = []) {
|
|
30
|
+
const convertFields = (fields, include = [], exclude = [], root = '') => {
|
|
31
|
+
const msgFields = {};
|
|
32
|
+
for (const f in fields) {
|
|
33
|
+
const field = fields[f];
|
|
34
|
+
const path = root.length ? `${root}.${f}` : f;
|
|
35
|
+
if ((include.length && !include.includes(path))
|
|
36
|
+
|| exclude.includes(path)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
msgFields[f] = new message_template_schema_1.$MessageTemplateField(field.type, field.name, field.alias, path, field.array, field.required, undefined, false, [], {
|
|
40
|
+
enum: field._enum ? {
|
|
41
|
+
options: field._enum.options,
|
|
42
|
+
dep: field._enum.dep ? new dependency_1.$Dependency(module, 'constants', `${field._enum.dep.module}::${field._enum.dep.name}`) : undefined
|
|
43
|
+
} : undefined
|
|
44
|
+
}, field.children ? convertFields(field.children, include, exclude) : undefined);
|
|
45
|
+
}
|
|
46
|
+
return msgFields;
|
|
47
|
+
};
|
|
48
|
+
const msgFields = convertFields(model.fields, include, exclude);
|
|
49
|
+
const template = new message_template_schema_1.$MessageTemplate(msgFields);
|
|
50
|
+
return new message_schema_1.$Message(module, name, alias, template);
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MergeUnion } from "../../../../engine/util/type";
|
|
2
|
+
import { BucketModelDef } from './bucket_model.builder';
|
|
3
|
+
import { BucketModelFieldBuilder, BucketModelFieldBuilders } from './bucket_model_field.builder';
|
|
4
|
+
export type BucketModelObjInfer<Builders extends BucketModelFieldBuilders<any>> = {
|
|
5
|
+
[K in keyof Builders]: Builders[K] extends BucketModelFieldBuilder<any, any, any, infer X> ? X : BucketModelObjInfer<Builders[K] & BucketModelFieldBuilders<any>>;
|
|
6
|
+
};
|
|
7
|
+
export type BucketModelInfer<Def extends BucketModelDef<any, any>> = BucketModelObjInfer<ReturnType<Def>>;
|
|
8
|
+
export type BucketFieldpathObjInfer<Builders extends BucketModelFieldBuilders<any>, Prefix extends string> = MergeUnion<{
|
|
9
|
+
[K in keyof Builders]: Builders[K] extends BucketModelFieldBuilder<any, any, any, any, infer X> ? {
|
|
10
|
+
[J in keyof X as `${Prefix}${K & string}${J & string}`]: X[J];
|
|
11
|
+
} : never;
|
|
12
|
+
}[keyof Builders]>;
|
|
13
|
+
export type BucketFieldpathInfer<Def extends BucketModelDef<any, any>, Prefix extends string = ''> = BucketFieldpathObjInfer<ReturnType<Def>, Prefix>;
|