taon 0.0.0 → 18.0.15
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 +115 -0
- package/assets/shared/shared_folder_info.txt +7 -0
- package/bin/start.js +279 -0
- package/bin/taon +6 -5
- package/bin/taon-debug +5 -5
- package/bin/taon-debug-brk +5 -4
- package/browser/README.md +24 -0
- package/browser/esm2022/lib/base-classes/base-abstract-entity.mjs +18 -0
- package/browser/esm2022/lib/base-classes/base-class.mjs +17 -0
- package/browser/esm2022/lib/base-classes/base-context.mjs +14 -0
- package/browser/esm2022/lib/base-classes/base-controller.mjs +18 -0
- package/browser/esm2022/lib/base-classes/base-crud-controller.mjs +279 -0
- package/browser/esm2022/lib/base-classes/base-entity.mjs +18 -0
- package/browser/esm2022/lib/base-classes/base-injector.mjs +160 -0
- package/browser/esm2022/lib/base-classes/base-provider.mjs +6 -0
- package/browser/esm2022/lib/base-classes/base-repository.mjs +514 -0
- package/browser/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
- package/browser/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
- package/browser/esm2022/lib/base-classes/base.mjs +26 -0
- package/browser/esm2022/lib/constants.mjs +4 -0
- package/browser/esm2022/lib/create-context.mjs +87 -0
- package/browser/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
- package/browser/esm2022/lib/decorators/classes/entity-decorator.mjs +27 -0
- package/browser/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
- package/browser/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
- package/browser/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
- package/browser/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
- package/browser/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
- package/browser/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
- package/browser/esm2022/lib/dependency-injection/di-container.mjs +32 -0
- package/browser/esm2022/lib/endpoint-context.mjs +1746 -0
- package/browser/esm2022/lib/entity-process.mjs +207 -0
- package/browser/esm2022/lib/env.mjs +6 -0
- package/browser/esm2022/lib/get-response-value.mjs +41 -0
- package/browser/esm2022/lib/helpers/class-helpers.mjs +183 -0
- package/browser/esm2022/lib/helpers/taon-helpers.mjs +120 -0
- package/browser/esm2022/lib/index.mjs +79 -0
- package/browser/esm2022/lib/inject.mjs +70 -0
- package/browser/esm2022/lib/models.mjs +77 -0
- package/browser/esm2022/lib/orm.mjs +6 -0
- package/browser/esm2022/lib/realtime/realtime-client.mjs +129 -0
- package/browser/esm2022/lib/realtime/realtime-core.mjs +54 -0
- package/browser/esm2022/lib/realtime/realtime-server.mjs +274 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +49 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
- package/browser/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
- package/browser/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
- package/browser/esm2022/lib/realtime/realtime.models.mjs +4 -0
- package/browser/esm2022/lib/storage.mjs +5 -0
- package/browser/esm2022/lib/symbols.mjs +89 -0
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
- package/browser/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
- package/browser/esm2022/lib/validators.mjs +76 -0
- package/browser/esm2022/public-api.mjs +2 -0
- package/browser/esm2022/taon.mjs +5 -0
- package/browser/fesm2022/taon.mjs +4901 -0
- package/browser/fesm2022/taon.mjs.map +1 -0
- package/browser/index.d.ts +6 -0
- package/browser/lib/base-classes/base-abstract-entity.d.ts +7 -0
- package/browser/lib/base-classes/base-class.d.ts +9 -0
- package/browser/lib/base-classes/base-context.d.ts +17 -0
- package/browser/lib/base-classes/base-controller.d.ts +8 -0
- package/browser/lib/base-classes/base-crud-controller.d.ts +28 -0
- package/browser/lib/base-classes/base-entity.d.ts +8 -0
- package/browser/lib/base-classes/base-injector.d.ts +60 -0
- package/browser/lib/base-classes/base-provider.d.ts +4 -0
- package/browser/lib/base-classes/base-repository.d.ts +249 -0
- package/browser/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
- package/browser/lib/base-classes/base-subscriber.d.ts +5 -0
- package/browser/lib/base-classes/base.d.ts +36 -0
- package/browser/lib/constants.d.ts +2 -0
- package/browser/lib/create-context.d.ts +25 -0
- package/browser/lib/decorators/classes/controller-decorator.d.ts +13 -0
- package/browser/lib/decorators/classes/entity-decorator.d.ts +17 -0
- package/browser/lib/decorators/classes/provider-decorator.d.ts +5 -0
- package/browser/lib/decorators/classes/repository-decorator.d.ts +5 -0
- package/browser/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
- package/browser/lib/decorators/http/http-decorators.d.ts +18 -0
- package/browser/lib/decorators/http/http-methods-decorators.d.ts +15 -0
- package/browser/lib/decorators/http/http-params-decorators.d.ts +6 -0
- package/browser/lib/dependency-injection/di-container.d.ts +6 -0
- package/browser/lib/endpoint-context.d.ts +117 -0
- package/browser/lib/entity-process.d.ts +40 -0
- package/browser/lib/env.d.ts +3 -0
- package/browser/lib/get-response-value.d.ts +7 -0
- package/browser/lib/helpers/class-helpers.d.ts +19 -0
- package/browser/lib/helpers/taon-helpers.d.ts +17 -0
- package/browser/lib/index.d.ts +113 -0
- package/browser/lib/inject.d.ts +9 -0
- package/browser/lib/models.d.ts +175 -0
- package/browser/lib/orm.d.ts +3 -0
- package/browser/lib/realtime/realtime-client.d.ts +32 -0
- package/browser/lib/realtime/realtime-core.d.ts +41 -0
- package/browser/lib/realtime/realtime-server.d.ts +14 -0
- package/browser/lib/realtime/realtime-strategy/index.d.ts +5 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
- package/browser/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
- package/browser/lib/realtime/realtime-subs-manager.d.ts +15 -0
- package/browser/lib/realtime/realtime.models.d.ts +14 -0
- package/browser/lib/storage.d.ts +2 -0
- package/browser/lib/symbols.d.ts +73 -0
- package/browser/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
- package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
- package/browser/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
- package/browser/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
- package/browser/lib/validators.d.ts +8 -0
- package/browser/package.json +25 -0
- package/browser/public-api.d.ts +2 -0
- package/cli.d.ts +1 -0
- package/cli.js +24 -0
- package/cli.js.map +1 -0
- package/client/README.md +24 -0
- package/client/esm2022/lib/base-classes/base-abstract-entity.mjs +18 -0
- package/client/esm2022/lib/base-classes/base-class.mjs +17 -0
- package/client/esm2022/lib/base-classes/base-context.mjs +14 -0
- package/client/esm2022/lib/base-classes/base-controller.mjs +18 -0
- package/client/esm2022/lib/base-classes/base-crud-controller.mjs +279 -0
- package/client/esm2022/lib/base-classes/base-entity.mjs +18 -0
- package/client/esm2022/lib/base-classes/base-injector.mjs +160 -0
- package/client/esm2022/lib/base-classes/base-provider.mjs +6 -0
- package/client/esm2022/lib/base-classes/base-repository.mjs +514 -0
- package/client/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
- package/client/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
- package/client/esm2022/lib/base-classes/base.mjs +26 -0
- package/client/esm2022/lib/constants.mjs +4 -0
- package/client/esm2022/lib/create-context.mjs +87 -0
- package/client/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
- package/client/esm2022/lib/decorators/classes/entity-decorator.mjs +27 -0
- package/client/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
- package/client/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
- package/client/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
- package/client/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
- package/client/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
- package/client/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
- package/client/esm2022/lib/dependency-injection/di-container.mjs +32 -0
- package/client/esm2022/lib/endpoint-context.mjs +1746 -0
- package/client/esm2022/lib/entity-process.mjs +207 -0
- package/client/esm2022/lib/env.mjs +6 -0
- package/client/esm2022/lib/get-response-value.mjs +41 -0
- package/client/esm2022/lib/helpers/class-helpers.mjs +183 -0
- package/client/esm2022/lib/helpers/taon-helpers.mjs +120 -0
- package/client/esm2022/lib/index.mjs +79 -0
- package/client/esm2022/lib/inject.mjs +70 -0
- package/client/esm2022/lib/models.mjs +77 -0
- package/client/esm2022/lib/orm.mjs +6 -0
- package/client/esm2022/lib/realtime/realtime-client.mjs +129 -0
- package/client/esm2022/lib/realtime/realtime-core.mjs +54 -0
- package/client/esm2022/lib/realtime/realtime-server.mjs +274 -0
- package/client/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +49 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
- package/client/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
- package/client/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
- package/client/esm2022/lib/realtime/realtime.models.mjs +4 -0
- package/client/esm2022/lib/storage.mjs +5 -0
- package/client/esm2022/lib/symbols.mjs +89 -0
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
- package/client/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
- package/client/esm2022/lib/validators.mjs +76 -0
- package/client/esm2022/public-api.mjs +2 -0
- package/client/esm2022/taon.mjs +5 -0
- package/client/fesm2022/taon.mjs +4901 -0
- package/client/fesm2022/taon.mjs.map +1 -0
- package/client/index.d.ts +6 -0
- package/client/lib/base-classes/base-abstract-entity.d.ts +7 -0
- package/client/lib/base-classes/base-class.d.ts +9 -0
- package/client/lib/base-classes/base-context.d.ts +17 -0
- package/client/lib/base-classes/base-controller.d.ts +8 -0
- package/client/lib/base-classes/base-crud-controller.d.ts +28 -0
- package/client/lib/base-classes/base-entity.d.ts +8 -0
- package/client/lib/base-classes/base-injector.d.ts +60 -0
- package/client/lib/base-classes/base-provider.d.ts +4 -0
- package/client/lib/base-classes/base-repository.d.ts +249 -0
- package/client/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
- package/client/lib/base-classes/base-subscriber.d.ts +5 -0
- package/client/lib/base-classes/base.d.ts +36 -0
- package/client/lib/constants.d.ts +2 -0
- package/client/lib/create-context.d.ts +25 -0
- package/client/lib/decorators/classes/controller-decorator.d.ts +13 -0
- package/client/lib/decorators/classes/entity-decorator.d.ts +17 -0
- package/client/lib/decorators/classes/provider-decorator.d.ts +5 -0
- package/client/lib/decorators/classes/repository-decorator.d.ts +5 -0
- package/client/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
- package/client/lib/decorators/http/http-decorators.d.ts +18 -0
- package/client/lib/decorators/http/http-methods-decorators.d.ts +15 -0
- package/client/lib/decorators/http/http-params-decorators.d.ts +6 -0
- package/client/lib/dependency-injection/di-container.d.ts +6 -0
- package/client/lib/endpoint-context.d.ts +117 -0
- package/client/lib/entity-process.d.ts +40 -0
- package/client/lib/env.d.ts +3 -0
- package/client/lib/get-response-value.d.ts +7 -0
- package/client/lib/helpers/class-helpers.d.ts +19 -0
- package/client/lib/helpers/taon-helpers.d.ts +17 -0
- package/client/lib/index.d.ts +113 -0
- package/client/lib/inject.d.ts +9 -0
- package/client/lib/models.d.ts +175 -0
- package/client/lib/orm.d.ts +3 -0
- package/client/lib/realtime/realtime-client.d.ts +32 -0
- package/client/lib/realtime/realtime-core.d.ts +41 -0
- package/client/lib/realtime/realtime-server.d.ts +14 -0
- package/client/lib/realtime/realtime-strategy/index.d.ts +5 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
- package/client/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
- package/client/lib/realtime/realtime-subs-manager.d.ts +15 -0
- package/client/lib/realtime/realtime.models.d.ts +14 -0
- package/client/lib/storage.d.ts +2 -0
- package/client/lib/symbols.d.ts +73 -0
- package/client/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
- package/client/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
- package/client/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
- package/client/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
- package/client/lib/validators.d.ts +8 -0
- package/client/public-api.d.ts +2 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/index.js.map +1 -0
- package/lib/base-classes/base-abstract-entity.d.ts +6 -0
- package/lib/base-classes/base-abstract-entity.js +40 -0
- package/lib/base-classes/base-abstract-entity.js.map +1 -0
- package/lib/base-classes/base-class.d.ts +8 -0
- package/lib/base-classes/base-class.js +35 -0
- package/lib/base-classes/base-class.js.map +1 -0
- package/lib/base-classes/base-context.d.ts +16 -0
- package/lib/base-classes/base-context.js +15 -0
- package/lib/base-classes/base-context.js.map +1 -0
- package/lib/base-classes/base-controller.d.ts +7 -0
- package/lib/base-classes/base-controller.js +24 -0
- package/lib/base-classes/base-controller.js.map +1 -0
- package/lib/base-classes/base-crud-controller.d.ts +27 -0
- package/lib/base-classes/base-crud-controller.js +385 -0
- package/lib/base-classes/base-crud-controller.js.map +1 -0
- package/lib/base-classes/base-entity.d.ts +7 -0
- package/lib/base-classes/base-entity.js +25 -0
- package/lib/base-classes/base-entity.js.map +1 -0
- package/lib/base-classes/base-injector.d.ts +59 -0
- package/lib/base-classes/base-injector.js +220 -0
- package/lib/base-classes/base-injector.js.map +1 -0
- package/lib/base-classes/base-provider.d.ts +3 -0
- package/lib/base-classes/base-provider.js +14 -0
- package/lib/base-classes/base-provider.js.map +1 -0
- package/lib/base-classes/base-repository.d.ts +254 -0
- package/lib/base-classes/base-repository.js +780 -0
- package/lib/base-classes/base-repository.js.map +1 -0
- package/lib/base-classes/base-subscriber-for-entity.d.ts +81 -0
- package/lib/base-classes/base-subscriber-for-entity.js +136 -0
- package/lib/base-classes/base-subscriber-for-entity.js.map +1 -0
- package/lib/base-classes/base-subscriber.d.ts +4 -0
- package/lib/base-classes/base-subscriber.js +25 -0
- package/lib/base-classes/base-subscriber.js.map +1 -0
- package/lib/base-classes/base.d.ts +35 -0
- package/lib/base-classes/base.js +27 -0
- package/lib/base-classes/base.js.map +1 -0
- package/lib/build-info._auto-generated_.d.ts +1 -0
- package/lib/build-info._auto-generated_.js +5 -0
- package/lib/build-info._auto-generated_.js.map +1 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -0
- package/lib/create-context.d.ts +24 -0
- package/lib/create-context.js +183 -0
- package/lib/create-context.js.map +1 -0
- package/lib/decorators/classes/controller-decorator.d.ts +12 -0
- package/lib/decorators/classes/controller-decorator.js +24 -0
- package/lib/decorators/classes/controller-decorator.js.map +1 -0
- package/lib/decorators/classes/entity-decorator.d.ts +16 -0
- package/lib/decorators/classes/entity-decorator.js +39 -0
- package/lib/decorators/classes/entity-decorator.js.map +1 -0
- package/lib/decorators/classes/provider-decorator.d.ts +4 -0
- package/lib/decorators/classes/provider-decorator.js +24 -0
- package/lib/decorators/classes/provider-decorator.js.map +1 -0
- package/lib/decorators/classes/repository-decorator.d.ts +4 -0
- package/lib/decorators/classes/repository-decorator.js +24 -0
- package/lib/decorators/classes/repository-decorator.js.map +1 -0
- package/lib/decorators/classes/subscriber-decorator.d.ts +5 -0
- package/lib/decorators/classes/subscriber-decorator.js +75 -0
- package/lib/decorators/classes/subscriber-decorator.js.map +1 -0
- package/lib/decorators/http/http-decorators.d.ts +17 -0
- package/lib/decorators/http/http-decorators.js +23 -0
- package/lib/decorators/http/http-decorators.js.map +1 -0
- package/lib/decorators/http/http-methods-decorators.d.ts +14 -0
- package/lib/decorators/http/http-methods-decorators.js +91 -0
- package/lib/decorators/http/http-methods-decorators.js.map +1 -0
- package/lib/decorators/http/http-params-decorators.d.ts +5 -0
- package/lib/decorators/http/http-params-decorators.js +55 -0
- package/lib/decorators/http/http-params-decorators.js.map +1 -0
- package/lib/dependency-injection/di-container.d.ts +5 -0
- package/lib/dependency-injection/di-container.js +40 -0
- package/lib/dependency-injection/di-container.js.map +1 -0
- package/lib/endpoint-context.d.ts +117 -0
- package/lib/endpoint-context.js +2128 -0
- package/lib/endpoint-context.js.map +1 -0
- package/lib/entity-process.d.ts +39 -0
- package/lib/entity-process.js +261 -0
- package/lib/entity-process.js.map +1 -0
- package/lib/env.d.ts +2 -0
- package/lib/env.js +7 -0
- package/lib/env.js.map +1 -0
- package/lib/formly/formly-group-wrapper-component.d.ts +5 -0
- package/lib/formly/formly-group-wrapper-component.js +28 -0
- package/lib/formly/formly-group-wrapper-component.js.map +1 -0
- package/lib/formly/formly-repeat-component.d.ts +5 -0
- package/lib/formly/formly-repeat-component.js +47 -0
- package/lib/formly/formly-repeat-component.js.map +1 -0
- package/lib/formly/formly.models.d.ts +1 -0
- package/lib/formly/formly.models.js +3 -0
- package/lib/formly/formly.models.js.map +1 -0
- package/lib/formly/fromly.d.ts +16 -0
- package/lib/formly/fromly.js +213 -0
- package/lib/formly/fromly.js.map +1 -0
- package/lib/formly/type-from-entity.d.ts +20 -0
- package/lib/formly/type-from-entity.js +65 -0
- package/lib/formly/type-from-entity.js.map +1 -0
- package/lib/get-response-value.d.ts +6 -0
- package/lib/get-response-value.js +65 -0
- package/lib/get-response-value.js.map +1 -0
- package/lib/helpers/class-helpers.d.ts +18 -0
- package/lib/helpers/class-helpers.js +227 -0
- package/lib/helpers/class-helpers.js.map +1 -0
- package/lib/helpers/taon-helpers.d.ts +16 -0
- package/lib/helpers/taon-helpers.js +144 -0
- package/lib/helpers/taon-helpers.js.map +1 -0
- package/lib/index.d.ts +112 -0
- package/lib/index.js +113 -0
- package/lib/index.js.map +1 -0
- package/lib/inject.d.ts +8 -0
- package/lib/inject.js +84 -0
- package/lib/inject.js.map +1 -0
- package/lib/models.d.ts +180 -0
- package/lib/models.js +107 -0
- package/lib/models.js.map +1 -0
- package/lib/orm.d.ts +51 -0
- package/lib/orm.js +79 -0
- package/lib/orm.js.map +1 -0
- package/lib/realtime/realtime-client.d.ts +31 -0
- package/lib/realtime/realtime-client.js +158 -0
- package/lib/realtime/realtime-client.js.map +1 -0
- package/lib/realtime/realtime-core.d.ts +40 -0
- package/lib/realtime/realtime-core.js +72 -0
- package/lib/realtime/realtime-core.js.map +1 -0
- package/lib/realtime/realtime-server.d.ts +13 -0
- package/lib/realtime/realtime-server.js +193 -0
- package/lib/realtime/realtime-server.js.map +1 -0
- package/lib/realtime/realtime-strategy/index.d.ts +4 -0
- package/lib/realtime/realtime-strategy/index.js +8 -0
- package/lib/realtime/realtime-strategy/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.d.ts +0 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js +5 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js +139 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js +68 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js +56 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +10 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js +50 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +22 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js +68 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-ipc.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +2 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js +6 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +16 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js +54 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +17 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js +52 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js +39 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +13 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js +46 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +11 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js +3 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +14 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js +42 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-mock.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js +48 -0
- package/lib/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +1 -0
- package/lib/realtime/realtime-strategy/realtime-strategy.d.ts +12 -0
- package/lib/realtime/realtime-strategy/realtime-strategy.js +14 -0
- package/lib/realtime/realtime-strategy/realtime-strategy.js.map +1 -0
- package/lib/realtime/realtime-subs-manager.d.ts +14 -0
- package/lib/realtime/realtime-subs-manager.js +102 -0
- package/lib/realtime/realtime-subs-manager.js.map +1 -0
- package/lib/realtime/realtime.models.d.ts +13 -0
- package/lib/realtime/realtime.models.js +3 -0
- package/lib/realtime/realtime.models.js.map +1 -0
- package/lib/storage.d.ts +1 -0
- package/lib/storage.js +6 -0
- package/lib/storage.js.map +1 -0
- package/lib/symbols.d.ts +72 -0
- package/lib/symbols.js +91 -0
- package/lib/symbols.js.map +1 -0
- package/lib/ui/directives/firedev-inject-html.directive.d.ts +6 -0
- package/lib/ui/directives/firedev-long-press.directive.d.ts +22 -0
- package/lib/ui/directives/index.d.ts +4 -0
- package/lib/ui/directives/index.js +5 -0
- package/lib/ui/directives/index.js.map +1 -0
- package/lib/ui/directives/safe.pipe.d.ts +7 -0
- package/lib/ui/directives/view-mode.d.ts +5 -0
- package/lib/ui/directives/view-mode.js +10 -0
- package/lib/ui/directives/view-mode.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.component.d.ts +31 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-admin-edit-mode/taon-admin-edit-mode.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.d.ts +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-db-admin/taon-db-admin.component.d.ts +9 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.component.d.ts +14 -0
- package/lib/ui/taon-admin-mode-configuration/components/taon-file-general-opt/taon-file-general-opt.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/index.d.ts +4 -0
- package/lib/ui/taon-admin-mode-configuration/index.js +5 -0
- package/lib/ui/taon-admin-mode-configuration/index.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +5 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js +3 -0
- package/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.js.map +1 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +14 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +47 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.module.d.ts +2 -0
- package/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +21 -0
- package/lib/ui/taon-github-fork-me-corner/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-corner/index.js +5 -0
- package/lib/ui/taon-github-fork-me-corner/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-corner/taon-github-fork-me-corner.module.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.d.ts +2 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js +5 -0
- package/lib/ui/taon-github-fork-me-ribbon/index.js.map +1 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.component.d.ts +3 -0
- package/lib/ui/taon-github-fork-me-ribbon/taon-github-fork-me-ribbon.module.d.ts +2 -0
- package/lib/ui/taon-notifications/index.d.ts +4 -0
- package/lib/ui/taon-notifications/index.js +11 -0
- package/lib/ui/taon-notifications/index.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.component.d.ts +9 -0
- package/lib/ui/taon-notifications/taon-notifications.models.d.ts +6 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js +5 -0
- package/lib/ui/taon-notifications/taon-notifications.models.js.map +1 -0
- package/lib/ui/taon-notifications/taon-notifications.module.d.ts +2 -0
- package/lib/ui/taon-notifications/taon-notifications.service.d.ts +11 -0
- package/lib/ui/taon-progress-bar/index.d.ts +2 -0
- package/lib/ui/taon-progress-bar/index.js +5 -0
- package/lib/ui/taon-progress-bar/index.js.map +1 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.component.d.ts +14 -0
- package/lib/ui/taon-progress-bar/taon-progress-bar.module.d.ts +2 -0
- package/lib/ui/taon-session-passcode/index.d.ts +1 -0
- package/lib/ui/taon-session-passcode/index.js +5 -0
- package/lib/ui/taon-session-passcode/index.js.map +1 -0
- package/lib/ui/taon-session-passcode/taon-session-passcode.component.d.ts +35 -0
- package/lib/ui/taon.models.d.ts +11 -0
- package/lib/ui/taon.models.js +3 -0
- package/lib/ui/taon.models.js.map +1 -0
- package/lib/ui/toan-full-material.module.d.ts +2 -0
- package/lib/validators.d.ts +7 -0
- package/lib/validators.js +53 -0
- package/lib/validators.js.map +1 -0
- package/old-app .d.ts +0 -0
- package/old-app .js +115 -0
- package/old-app .js.map +1 -0
- package/package.json +74 -11
- package/playground.d.ts +0 -0
- package/playground.js +172 -0
- package/playground.js.map +1 -0
- package/src.d.ts +6 -0
- package/taon.jsonc +48 -0
- package/tmp-environment.json +392 -0
- package/websql/README.md +24 -0
- package/websql/esm2022/lib/base-classes/base-abstract-entity.mjs +25 -0
- package/websql/esm2022/lib/base-classes/base-class.mjs +17 -0
- package/websql/esm2022/lib/base-classes/base-context.mjs +14 -0
- package/websql/esm2022/lib/base-classes/base-controller.mjs +18 -0
- package/websql/esm2022/lib/base-classes/base-crud-controller.mjs +238 -0
- package/websql/esm2022/lib/base-classes/base-entity.mjs +16 -0
- package/websql/esm2022/lib/base-classes/base-injector.mjs +160 -0
- package/websql/esm2022/lib/base-classes/base-provider.mjs +6 -0
- package/websql/esm2022/lib/base-classes/base-repository.mjs +431 -0
- package/websql/esm2022/lib/base-classes/base-subscriber-for-entity.mjs +137 -0
- package/websql/esm2022/lib/base-classes/base-subscriber.mjs +27 -0
- package/websql/esm2022/lib/base-classes/base.mjs +26 -0
- package/websql/esm2022/lib/constants.mjs +4 -0
- package/websql/esm2022/lib/create-context.mjs +86 -0
- package/websql/esm2022/lib/decorators/classes/controller-decorator.mjs +15 -0
- package/websql/esm2022/lib/decorators/classes/entity-decorator.mjs +25 -0
- package/websql/esm2022/lib/decorators/classes/provider-decorator.mjs +15 -0
- package/websql/esm2022/lib/decorators/classes/repository-decorator.mjs +15 -0
- package/websql/esm2022/lib/decorators/classes/subscriber-decorator.mjs +41 -0
- package/websql/esm2022/lib/decorators/http/http-decorators.mjs +22 -0
- package/websql/esm2022/lib/decorators/http/http-methods-decorators.mjs +78 -0
- package/websql/esm2022/lib/decorators/http/http-params-decorators.mjs +47 -0
- package/websql/esm2022/lib/dependency-injection/di-container.mjs +32 -0
- package/websql/esm2022/lib/endpoint-context.mjs +1506 -0
- package/websql/esm2022/lib/entity-process.mjs +207 -0
- package/websql/esm2022/lib/env.mjs +6 -0
- package/websql/esm2022/lib/get-response-value.mjs +45 -0
- package/websql/esm2022/lib/helpers/class-helpers.mjs +183 -0
- package/websql/esm2022/lib/helpers/taon-helpers.mjs +120 -0
- package/websql/esm2022/lib/index.mjs +81 -0
- package/websql/esm2022/lib/inject.mjs +70 -0
- package/websql/esm2022/lib/models.mjs +70 -0
- package/websql/esm2022/lib/orm.mjs +60 -0
- package/websql/esm2022/lib/realtime/realtime-client.mjs +129 -0
- package/websql/esm2022/lib/realtime/realtime-core.mjs +54 -0
- package/websql/esm2022/lib/realtime/realtime-server.mjs +158 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/index.mjs +7 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.mjs +98 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.mjs +45 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.mjs +40 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.mjs +25 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.mjs +4 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-ipc.mjs +48 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.mjs +5 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.mjs +50 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.mjs +48 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.mjs +35 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.mjs +43 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.mjs +4 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-mock.mjs +28 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy-socket-io.mjs +33 -0
- package/websql/esm2022/lib/realtime/realtime-strategy/realtime-strategy.mjs +10 -0
- package/websql/esm2022/lib/realtime/realtime-subs-manager.mjs +79 -0
- package/websql/esm2022/lib/realtime/realtime.models.mjs +4 -0
- package/websql/esm2022/lib/storage.mjs +5 -0
- package/websql/esm2022/lib/symbols.mjs +89 -0
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.mjs +4 -0
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.mjs +32 -0
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.mjs +167 -0
- package/websql/esm2022/lib/ui/taon-admin-mode-configuration/taon-admin.service.mjs +64 -0
- package/websql/esm2022/lib/validators.mjs +76 -0
- package/websql/esm2022/public-api.mjs +2 -0
- package/websql/esm2022/taon.mjs +5 -0
- package/websql/fesm2022/taon.mjs +4595 -0
- package/websql/fesm2022/taon.mjs.map +1 -0
- package/websql/index.d.ts +6 -0
- package/websql/lib/base-classes/base-abstract-entity.d.ts +7 -0
- package/websql/lib/base-classes/base-class.d.ts +9 -0
- package/websql/lib/base-classes/base-context.d.ts +17 -0
- package/websql/lib/base-classes/base-controller.d.ts +8 -0
- package/websql/lib/base-classes/base-crud-controller.d.ts +28 -0
- package/websql/lib/base-classes/base-entity.d.ts +8 -0
- package/websql/lib/base-classes/base-injector.d.ts +60 -0
- package/websql/lib/base-classes/base-provider.d.ts +4 -0
- package/websql/lib/base-classes/base-repository.d.ts +255 -0
- package/websql/lib/base-classes/base-subscriber-for-entity.d.ts +82 -0
- package/websql/lib/base-classes/base-subscriber.d.ts +5 -0
- package/websql/lib/base-classes/base.d.ts +36 -0
- package/websql/lib/constants.d.ts +2 -0
- package/websql/lib/create-context.d.ts +25 -0
- package/websql/lib/decorators/classes/controller-decorator.d.ts +13 -0
- package/websql/lib/decorators/classes/entity-decorator.d.ts +17 -0
- package/websql/lib/decorators/classes/provider-decorator.d.ts +5 -0
- package/websql/lib/decorators/classes/repository-decorator.d.ts +5 -0
- package/websql/lib/decorators/classes/subscriber-decorator.d.ts +6 -0
- package/websql/lib/decorators/http/http-decorators.d.ts +18 -0
- package/websql/lib/decorators/http/http-methods-decorators.d.ts +15 -0
- package/websql/lib/decorators/http/http-params-decorators.d.ts +6 -0
- package/websql/lib/dependency-injection/di-container.d.ts +6 -0
- package/websql/lib/endpoint-context.d.ts +117 -0
- package/websql/lib/entity-process.d.ts +40 -0
- package/websql/lib/env.d.ts +3 -0
- package/websql/lib/get-response-value.d.ts +7 -0
- package/websql/lib/helpers/class-helpers.d.ts +19 -0
- package/websql/lib/helpers/taon-helpers.d.ts +17 -0
- package/websql/lib/index.d.ts +113 -0
- package/websql/lib/inject.d.ts +9 -0
- package/websql/lib/models.d.ts +181 -0
- package/websql/lib/orm.d.ts +52 -0
- package/websql/lib/realtime/realtime-client.d.ts +32 -0
- package/websql/lib/realtime/realtime-core.d.ts +41 -0
- package/websql/lib/realtime/realtime-server.d.ts +14 -0
- package/websql/lib/realtime/realtime-strategy/index.d.ts +5 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-namespace.d.ts +22 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-main-wrapper.d.ts +17 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-namespace.d.ts +11 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc-renderer-wrapper.d.ts +11 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc-models/realtime-strategy-ipc.models.d.ts +14 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +23 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/index.d.ts +3 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-client.d.ts +17 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-namespaces.d.ts +18 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-server.d.ts +12 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock-socket.d.ts +14 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock-models/realtime-strategy-mock.models.d.ts +12 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-mock.d.ts +15 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +17 -0
- package/websql/lib/realtime/realtime-strategy/realtime-strategy.d.ts +13 -0
- package/websql/lib/realtime/realtime-subs-manager.d.ts +15 -0
- package/websql/lib/realtime/realtime.models.d.ts +14 -0
- package/websql/lib/storage.d.ts +2 -0
- package/websql/lib/symbols.d.ts +73 -0
- package/websql/lib/ui/taon-admin-mode-configuration/models/taon-admin-mode-tabs.d.ts +6 -0
- package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-control.service.d.ts +18 -0
- package/websql/lib/ui/taon-admin-mode-configuration/taon-admin-mode-configuration.component.d.ts +51 -0
- package/websql/lib/ui/taon-admin-mode-configuration/taon-admin.service.d.ts +25 -0
- package/websql/lib/validators.d.ts +8 -0
- package/websql/package.json +25 -0
- package/websql/public-api.d.ts +2 -0
|
@@ -0,0 +1,2128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointContext = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable @typescript-eslint/typedef */
|
|
6
|
+
//#region imports
|
|
7
|
+
//#region @websql
|
|
8
|
+
var taon_typeorm_1 = require("taon-typeorm");
|
|
9
|
+
var taon_typeorm_2 = require("taon-typeorm");
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region @backend
|
|
12
|
+
var express = require("express");
|
|
13
|
+
var expressSession = require("express-session");
|
|
14
|
+
var cors = require("cors");
|
|
15
|
+
var bodyParser = require("body-parser");
|
|
16
|
+
var cookieParser = require("cookie-parser");
|
|
17
|
+
var methodOverride = require("method-override");
|
|
18
|
+
var fileUpload = require("express-fileupload");
|
|
19
|
+
var url_1 = require("url");
|
|
20
|
+
var tnp_core_1 = require("tnp-core");
|
|
21
|
+
//#endregion
|
|
22
|
+
/* */
|
|
23
|
+
/* */
|
|
24
|
+
var models_1 = require("./models");
|
|
25
|
+
var class_helpers_1 = require("./helpers/class-helpers");
|
|
26
|
+
var symbols_1 = require("./symbols");
|
|
27
|
+
var tnp_core_2 = require("tnp-core");
|
|
28
|
+
var di_container_1 = require("./dependency-injection/di-container");
|
|
29
|
+
var taon_helpers_1 = require("./helpers/taon-helpers");
|
|
30
|
+
var ng2_rest_1 = require("ng2-rest");
|
|
31
|
+
var json10_1 = require("json10");
|
|
32
|
+
var tnp_core_3 = require("tnp-core");
|
|
33
|
+
var rxjs_1 = require("rxjs");
|
|
34
|
+
var entity_process_1 = require("./entity-process");
|
|
35
|
+
var get_response_value_1 = require("./get-response-value");
|
|
36
|
+
var axios_1 = require("axios");
|
|
37
|
+
var taon_typeorm_3 = require("taon-typeorm");
|
|
38
|
+
var env_1 = require("./env");
|
|
39
|
+
var realtime_core_1 = require("./realtime/realtime-core");
|
|
40
|
+
var base_subscriber_for_entity_1 = require("./base-classes/base-subscriber-for-entity");
|
|
41
|
+
//#endregion
|
|
42
|
+
var EndpointContext = /** @class */ (function () {
|
|
43
|
+
//#endregion
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region constructor
|
|
46
|
+
function EndpointContext(originalConfig, configFn) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
this.originalConfig = originalConfig;
|
|
49
|
+
this.configFn = configFn;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region fields
|
|
52
|
+
//#region fields / flags
|
|
53
|
+
this.disabledRealtime = false;
|
|
54
|
+
/**
|
|
55
|
+
* check whether context is inited
|
|
56
|
+
* (with init() function )
|
|
57
|
+
*/
|
|
58
|
+
this.inited = false;
|
|
59
|
+
//#endregion
|
|
60
|
+
this.localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
|
|
61
|
+
//#region fields / all instances of classes from context
|
|
62
|
+
/**
|
|
63
|
+
* all instances of classes from context
|
|
64
|
+
* key is class name
|
|
65
|
+
*/
|
|
66
|
+
this.allClassesInstances = {};
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region fields / class instances by name
|
|
69
|
+
this.classInstancesByNameObj = {};
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region fields / obj with classes instances arr
|
|
72
|
+
this.objWithClassesInstancesArr = {};
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region fields / active routes
|
|
75
|
+
this.activeRoutes = [];
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region fields / types from contexts
|
|
78
|
+
this.injectableTypesfromContexts = [
|
|
79
|
+
models_1.Models.ClassType.CONTROLLER,
|
|
80
|
+
models_1.Models.ClassType.PROVIDER,
|
|
81
|
+
models_1.Models.ClassType.REPOSITORY,
|
|
82
|
+
models_1.Models.ClassType.SUBSCRIBER,
|
|
83
|
+
];
|
|
84
|
+
//#endregion
|
|
85
|
+
this.allTypesfromContexts = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(this.injectableTypesfromContexts), false), [
|
|
86
|
+
models_1.Models.ClassType.ENTITY,
|
|
87
|
+
], false);
|
|
88
|
+
//#region fields / express app
|
|
89
|
+
this.expressApp = {};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region fields / entities triggers
|
|
92
|
+
this.entitiesTriggers = {};
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region methods & getters / clone class
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
96
|
+
this.cloneClassWithNewMetadata = function (_a) {
|
|
97
|
+
var BaseClass = _a.BaseClass, className = _a.className, config = _a.config, ctx = _a.ctx, classType = _a.classType;
|
|
98
|
+
// Return a new class that extends the base class
|
|
99
|
+
var cloneClass = function () {
|
|
100
|
+
var _a, _b, _c, _d, _e, _f;
|
|
101
|
+
if (BaseClass[symbols_1.Symbols.fullClassNameStaticProperty] ===
|
|
102
|
+
"".concat(ctx.contextName, ".").concat(className)) {
|
|
103
|
+
return BaseClass;
|
|
104
|
+
}
|
|
105
|
+
return _f = /** @class */ (function (_super) {
|
|
106
|
+
tslib_1.__extends(class_1, _super);
|
|
107
|
+
function class_1() {
|
|
108
|
+
var _this = _super.apply(this, tslib_1.__spreadArray([], tslib_1.__read(arguments), false)) || this;
|
|
109
|
+
_this[_e] = ctx;
|
|
110
|
+
return _this;
|
|
111
|
+
// You can override prototype properties or methods here if needed
|
|
112
|
+
// static properties override allowed
|
|
113
|
+
}
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/typedef
|
|
115
|
+
class_1.__getFullPathForClass__ = function (arr) {
|
|
116
|
+
if (arr === void 0) { arr = []; }
|
|
117
|
+
var name = this[symbols_1.Symbols.fullClassNameStaticProperty];
|
|
118
|
+
arr.push(name);
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
if (this[symbols_1.Symbols.orignalClass] && // @ts-ignore
|
|
121
|
+
this[symbols_1.Symbols.orignalClass].__getFullPathForClass__) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
this[symbols_1.Symbols.orignalClass].__getFullPathForClass__(arr);
|
|
124
|
+
}
|
|
125
|
+
return arr.join('/');
|
|
126
|
+
};
|
|
127
|
+
Object.defineProperty(class_1, "fullPathForClass", {
|
|
128
|
+
get: function () {
|
|
129
|
+
return this.__getFullPathForClass__();
|
|
130
|
+
},
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: true
|
|
133
|
+
});
|
|
134
|
+
return class_1;
|
|
135
|
+
}(BaseClass)),
|
|
136
|
+
_a = symbols_1.Symbols.orignalClass,
|
|
137
|
+
_b = symbols_1.Symbols.fullClassNameStaticProperty,
|
|
138
|
+
_c = symbols_1.Symbols.classNameStaticProperty,
|
|
139
|
+
_d = symbols_1.Symbols.ctxInClassOrClassObj,
|
|
140
|
+
_e = symbols_1.Symbols.ctxInClassOrClassObj,
|
|
141
|
+
// static ['_'] = BaseClass['_'];
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
_f[_a] = BaseClass,
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
_f[_b] = "".concat(ctx.contextName, ".").concat(className),
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
_f[_c] = className,
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/typedef
|
|
152
|
+
_f[_d] = ctx,
|
|
153
|
+
_f;
|
|
154
|
+
};
|
|
155
|
+
var cloneClassFunction = cloneClass();
|
|
156
|
+
//#region gather all instances for all contexts
|
|
157
|
+
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
158
|
+
// this thinng belowe is nice for debugging purpose
|
|
159
|
+
// if (_.isUndefined(cloneClassFunction[Symbols.orignalClassClonesObj])) {
|
|
160
|
+
// cloneClassFunction[Symbols.orignalClassClonesObj] = {};
|
|
161
|
+
// }
|
|
162
|
+
// if (_.isUndefined(BaseClass[Symbols.orignalClassClonesObj])) {
|
|
163
|
+
// BaseClass[Symbols.orignalClassClonesObj] = {};
|
|
164
|
+
// }
|
|
165
|
+
// const all = {
|
|
166
|
+
// ...BaseClass[Symbols.orignalClassClonesObj],
|
|
167
|
+
// ...cloneClassFunction[Symbols.orignalClassClonesObj],
|
|
168
|
+
// };
|
|
169
|
+
// all[ctx.contextName] = cloneClassFunction;
|
|
170
|
+
// cloneClassFunction[Symbols.orignalClassClonesObj] = all;
|
|
171
|
+
// BaseClass[Symbols.orignalClassClonesObj] = all;
|
|
172
|
+
//#endregion
|
|
173
|
+
return cloneClassFunction;
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region methods & getters / clone classes obj with new metadata
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
178
|
+
this.cloneClassesObjWithNewMetadata = function (_a) {
|
|
179
|
+
var e_1, _b;
|
|
180
|
+
var classesInput = _a.classesInput, config = _a.config, ctx = _a.ctx, classType = _a.classType;
|
|
181
|
+
var classes = {};
|
|
182
|
+
try {
|
|
183
|
+
// console.log(Object.keys(classesInput))
|
|
184
|
+
for (var _c = tslib_1.__values(Object.keys(classesInput || {})), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
185
|
+
var key = _d.value;
|
|
186
|
+
var BaseClass_1 = classesInput[key];
|
|
187
|
+
if (!BaseClass_1) {
|
|
188
|
+
tnp_core_2.Helpers.error("Class ".concat(key, " is not defined in context ").concat(ctx.contextName, "\n\n Please check if you have correct import in context file\n\n "));
|
|
189
|
+
}
|
|
190
|
+
var className = Reflect.getMetadata(symbols_1.Symbols.metadata.className, BaseClass_1);
|
|
191
|
+
// console.log('Metadata className', className, BaseClass);
|
|
192
|
+
// if (!className) {
|
|
193
|
+
// console.warn(`Please provide className for ${BaseClass.name} class`);
|
|
194
|
+
// }
|
|
195
|
+
className = className || key;
|
|
196
|
+
BaseClass_1[symbols_1.Symbols.classNameStaticProperty] = className;
|
|
197
|
+
var clonedClass = _this.cloneClassWithNewMetadata({
|
|
198
|
+
BaseClass: BaseClass_1,
|
|
199
|
+
className: className,
|
|
200
|
+
config: config,
|
|
201
|
+
ctx: ctx,
|
|
202
|
+
classType: classType,
|
|
203
|
+
});
|
|
204
|
+
classes[className] = clonedClass;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
208
|
+
finally {
|
|
209
|
+
try {
|
|
210
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
211
|
+
}
|
|
212
|
+
finally { if (e_1) throw e_1.error; }
|
|
213
|
+
}
|
|
214
|
+
return classes;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
//#region static
|
|
218
|
+
/* */
|
|
219
|
+
/* */
|
|
220
|
+
EndpointContext.initNgZone = function (ngZone) {
|
|
221
|
+
/* */
|
|
222
|
+
/* */
|
|
223
|
+
};
|
|
224
|
+
EndpointContext.findForTraget = function (classFnOrObject) {
|
|
225
|
+
var obj = class_helpers_1.ClassHelpers.getClassFnFromObject(classFnOrObject) || {};
|
|
226
|
+
return (classFnOrObject[symbols_1.Symbols.ctxInClassOrClassObj] ||
|
|
227
|
+
obj[symbols_1.Symbols.ctxInClassOrClassObj]);
|
|
228
|
+
};
|
|
229
|
+
Object.defineProperty(EndpointContext.prototype, "realtimeClient", {
|
|
230
|
+
get: function () {
|
|
231
|
+
return this.realtime.client;
|
|
232
|
+
},
|
|
233
|
+
enumerable: false,
|
|
234
|
+
configurable: true
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(EndpointContext.prototype, "realtimeServer", {
|
|
237
|
+
get: function () {
|
|
238
|
+
return this.realtime.server;
|
|
239
|
+
},
|
|
240
|
+
enumerable: false,
|
|
241
|
+
configurable: true
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(EndpointContext.prototype, "logHttp", {
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region fields / logs
|
|
246
|
+
get: function () {
|
|
247
|
+
var _a, _b;
|
|
248
|
+
if (tnp_core_2._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
249
|
+
return !!this.config.logs.http;
|
|
250
|
+
}
|
|
251
|
+
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
252
|
+
},
|
|
253
|
+
enumerable: false,
|
|
254
|
+
configurable: true
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(EndpointContext.prototype, "logRealtime", {
|
|
257
|
+
get: function () {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
if (tnp_core_2._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
260
|
+
return !!this.config.logs.realtime;
|
|
261
|
+
}
|
|
262
|
+
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
263
|
+
},
|
|
264
|
+
enumerable: false,
|
|
265
|
+
configurable: true
|
|
266
|
+
});
|
|
267
|
+
Object.defineProperty(EndpointContext.prototype, "logFramework", {
|
|
268
|
+
get: function () {
|
|
269
|
+
var _a, _b;
|
|
270
|
+
if (tnp_core_2._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
271
|
+
return !!this.config.logs.framework;
|
|
272
|
+
}
|
|
273
|
+
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
274
|
+
},
|
|
275
|
+
enumerable: false,
|
|
276
|
+
configurable: true
|
|
277
|
+
});
|
|
278
|
+
Object.defineProperty(EndpointContext.prototype, "logDb", {
|
|
279
|
+
get: function () {
|
|
280
|
+
var _a, _b;
|
|
281
|
+
if (tnp_core_2._.isObject((_a = this.config) === null || _a === void 0 ? void 0 : _a.logs)) {
|
|
282
|
+
return !!this.config.logs.db;
|
|
283
|
+
}
|
|
284
|
+
return ((_b = this.config) === null || _b === void 0 ? void 0 : _b.logs) === true;
|
|
285
|
+
},
|
|
286
|
+
enumerable: false,
|
|
287
|
+
configurable: true
|
|
288
|
+
});
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region methods & getters / init
|
|
291
|
+
EndpointContext.prototype.init = function (options) {
|
|
292
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
293
|
+
var initFromRecrusiveContextResovle, oneHour, _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, classTypeName, _o, _p, classTypeName, e_2_1;
|
|
294
|
+
var e_3, _q, e_2, _r;
|
|
295
|
+
var _this = this;
|
|
296
|
+
var _s, _t;
|
|
297
|
+
return tslib_1.__generator(this, function (_u) {
|
|
298
|
+
switch (_u.label) {
|
|
299
|
+
case 0:
|
|
300
|
+
initFromRecrusiveContextResovle = (options || {}).initFromRecrusiveContextResovle;
|
|
301
|
+
this.inited = true;
|
|
302
|
+
this.config = this.configFn(env_1.ENV);
|
|
303
|
+
// console.log(
|
|
304
|
+
// `[${
|
|
305
|
+
// this.contextName
|
|
306
|
+
// }] init context... from resolve: ${!!initFromRecrusiveContextResovle}`,
|
|
307
|
+
// );
|
|
308
|
+
//#region debug config
|
|
309
|
+
// console.log(
|
|
310
|
+
// `[taon][${this.config.contextName}] - resolve config from fn`,
|
|
311
|
+
// {
|
|
312
|
+
// config: this.config,
|
|
313
|
+
// },
|
|
314
|
+
// );
|
|
315
|
+
// for (const ctrlName of Object.keys(config.controllers || {})) {
|
|
316
|
+
// console.log(`${ctrlName} = ${!!config.controllers[ctrlName]}`);
|
|
317
|
+
// }
|
|
318
|
+
// for (const entityName of Object.keys(config.entities || {})) {
|
|
319
|
+
// console.log(`${entityName} = ${!!config.entities[entityName]}`);
|
|
320
|
+
// }
|
|
321
|
+
// for (const providersName of Object.keys(config.providers || {})) {
|
|
322
|
+
// console.log(`${providersName} = ${!!config.providers[providersName]}`);
|
|
323
|
+
// }
|
|
324
|
+
// for (const repositoryName of Object.keys(config.repositories || {})) {
|
|
325
|
+
// console.log(
|
|
326
|
+
// `${repositoryName} = ${!!config.repositories[repositoryName]}`,
|
|
327
|
+
// );
|
|
328
|
+
// }
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region resolve mode
|
|
331
|
+
if (this.config.host) {
|
|
332
|
+
this.mode = 'backend-frontend(tcp+udp)';
|
|
333
|
+
/* */
|
|
334
|
+
/* */
|
|
335
|
+
}
|
|
336
|
+
if (this.config.remoteHost) {
|
|
337
|
+
if (this.config.host) {
|
|
338
|
+
tnp_core_2.Helpers.error("[taon] You can't have remoteHost and host at the same time", false, true);
|
|
339
|
+
}
|
|
340
|
+
this.mode = 'remote-backend(tcp+udp)';
|
|
341
|
+
}
|
|
342
|
+
if (this.config.useIpcWhenElectron && tnp_core_2.Helpers.isElectron) {
|
|
343
|
+
this.mode = 'backend-frontend(ipc-electron)';
|
|
344
|
+
}
|
|
345
|
+
if (!this.mode && !this.config.abstract) {
|
|
346
|
+
tnp_core_2.Helpers.error("[taon] Context \"".concat(this.contextName, "\": You need to provide host or remoteHost or useIpcWhenElectron"), false, true);
|
|
347
|
+
//#region @backend
|
|
348
|
+
process.exit(1);
|
|
349
|
+
//#endregion
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region resolve database config
|
|
353
|
+
if (this.config.database === true) {
|
|
354
|
+
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
355
|
+
}
|
|
356
|
+
else if (tnp_core_2._.isObject(this.config.database)) {
|
|
357
|
+
this.databaseConfig = tnp_core_2._.cloneDeep(this.config.database);
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region resolve session
|
|
361
|
+
if (this.config.session) {
|
|
362
|
+
this.session = tnp_core_2._.cloneDeep(this.config.session);
|
|
363
|
+
oneHour = 1000 * 60 * 60 * 1;
|
|
364
|
+
if (!this.session.cookieMaxAge) {
|
|
365
|
+
this.session.cookieMaxAge = oneHour;
|
|
366
|
+
}
|
|
367
|
+
// serever and browser cookie authentication
|
|
368
|
+
axios_1.default.defaults.withCredentials = true;
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region prepare & gather all classes recrusively
|
|
372
|
+
this.config.contexts = this.config.contexts || {};
|
|
373
|
+
this.config.entities = this.config.entities || {};
|
|
374
|
+
this.config.controllers = this.config.controllers || {};
|
|
375
|
+
this.config.repositories = this.config.repositories || {};
|
|
376
|
+
this.config.providers = this.config.providers || {};
|
|
377
|
+
this.config.subscribers = this.config.subscribers || {};
|
|
378
|
+
_a = this.config;
|
|
379
|
+
_b = [{}];
|
|
380
|
+
return [4 /*yield*/, this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.ENTITY)];
|
|
381
|
+
case 1:
|
|
382
|
+
_a.entities = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _b.concat([(_u.sent())])), this.config.entities]);
|
|
383
|
+
_c = this.config;
|
|
384
|
+
_d = [{}];
|
|
385
|
+
return [4 /*yield*/, this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.CONTROLLER)];
|
|
386
|
+
case 2:
|
|
387
|
+
_c.controllers = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _d.concat([(_u.sent())])), this.config.controllers]);
|
|
388
|
+
_e = this.config;
|
|
389
|
+
_f = [{}];
|
|
390
|
+
return [4 /*yield*/, this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.PROVIDER)];
|
|
391
|
+
case 3:
|
|
392
|
+
_e.providers = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _f.concat([(_u.sent())])), this.config.providers]);
|
|
393
|
+
_g = this.config;
|
|
394
|
+
_h = [{}];
|
|
395
|
+
return [4 /*yield*/, this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.SUBSCRIBER)];
|
|
396
|
+
case 4:
|
|
397
|
+
_g.subscribers = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _h.concat([(_u.sent())])), this.config.subscribers]);
|
|
398
|
+
_j = this.config;
|
|
399
|
+
_k = [{}];
|
|
400
|
+
return [4 /*yield*/, this.getRecrusiveClassesfromContextsObj(models_1.Models.ClassType.REPOSITORY)];
|
|
401
|
+
case 5:
|
|
402
|
+
_j.repositories = tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _k.concat([(_u.sent())])), this.config.repositories]);
|
|
403
|
+
// console.log(this.config);
|
|
404
|
+
// debugger;
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region prepare classes instances/funcitons clones
|
|
407
|
+
this.config.controllers = this.cloneClassesObjWithNewMetadata({
|
|
408
|
+
classesInput: this.config.controllers,
|
|
409
|
+
config: this.config,
|
|
410
|
+
ctx: this,
|
|
411
|
+
classType: models_1.Models.ClassType.CONTROLLER,
|
|
412
|
+
});
|
|
413
|
+
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
414
|
+
classesInput: this.config.repositories,
|
|
415
|
+
config: this.config,
|
|
416
|
+
ctx: this,
|
|
417
|
+
classType: models_1.Models.ClassType.REPOSITORY,
|
|
418
|
+
});
|
|
419
|
+
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
420
|
+
classesInput: this.config.providers,
|
|
421
|
+
config: this.config,
|
|
422
|
+
ctx: this,
|
|
423
|
+
classType: models_1.Models.ClassType.PROVIDER,
|
|
424
|
+
});
|
|
425
|
+
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
426
|
+
classesInput: this.config.subscribers,
|
|
427
|
+
config: this.config,
|
|
428
|
+
ctx: this,
|
|
429
|
+
classType: models_1.Models.ClassType.SUBSCRIBER,
|
|
430
|
+
});
|
|
431
|
+
try {
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region prepare instances
|
|
434
|
+
for (_l = tslib_1.__values(this.injectableTypesfromContexts), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
435
|
+
classTypeName = _m.value;
|
|
436
|
+
this.classInstancesByNameObj[classTypeName] = {};
|
|
437
|
+
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
441
|
+
finally {
|
|
442
|
+
try {
|
|
443
|
+
if (_m && !_m.done && (_q = _l.return)) _q.call(_l);
|
|
444
|
+
}
|
|
445
|
+
finally { if (e_3) throw e_3.error; }
|
|
446
|
+
}
|
|
447
|
+
_u.label = 6;
|
|
448
|
+
case 6:
|
|
449
|
+
_u.trys.push([6, 11, 12, 13]);
|
|
450
|
+
_o = tslib_1.__values(this.injectableTypesfromContexts), _p = _o.next();
|
|
451
|
+
_u.label = 7;
|
|
452
|
+
case 7:
|
|
453
|
+
if (!!_p.done) return [3 /*break*/, 10];
|
|
454
|
+
classTypeName = _p.value;
|
|
455
|
+
return [4 /*yield*/, this.createInstances(this.config[models_1.Models.ClassTypeKey[classTypeName]], classTypeName)];
|
|
456
|
+
case 8:
|
|
457
|
+
_u.sent();
|
|
458
|
+
_u.label = 9;
|
|
459
|
+
case 9:
|
|
460
|
+
_p = _o.next();
|
|
461
|
+
return [3 /*break*/, 7];
|
|
462
|
+
case 10: return [3 /*break*/, 13];
|
|
463
|
+
case 11:
|
|
464
|
+
e_2_1 = _u.sent();
|
|
465
|
+
e_2 = { error: e_2_1 };
|
|
466
|
+
return [3 /*break*/, 13];
|
|
467
|
+
case 12:
|
|
468
|
+
try {
|
|
469
|
+
if (_p && !_p.done && (_r = _o.return)) _r.call(_o);
|
|
470
|
+
}
|
|
471
|
+
finally { if (e_2) throw e_2.error; }
|
|
472
|
+
return [7 /*endfinally*/];
|
|
473
|
+
case 13:
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region prepares server
|
|
476
|
+
if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
|
|
477
|
+
//#region @backend
|
|
478
|
+
this.expressApp = express();
|
|
479
|
+
this.initMidleware();
|
|
480
|
+
this.serverTcpUdp = this.isHttpServer
|
|
481
|
+
? new tnp_core_1.https.Server({
|
|
482
|
+
key: (_s = this.config.https) === null || _s === void 0 ? void 0 : _s.key,
|
|
483
|
+
cert: (_t = this.config.https) === null || _t === void 0 ? void 0 : _t.cert,
|
|
484
|
+
}, this.expressApp)
|
|
485
|
+
: new tnp_core_1.http.Server(this.expressApp);
|
|
486
|
+
this.publicAssets.forEach(function (asset) {
|
|
487
|
+
_this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
488
|
+
});
|
|
489
|
+
//#endregion
|
|
490
|
+
}
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region prepare relatime
|
|
493
|
+
if (!this.config.abstract) {
|
|
494
|
+
this.disabledRealtime = !!this.config.disabledRealtime;
|
|
495
|
+
//#region @backend
|
|
496
|
+
if (tnp_core_2.Helpers.isRunningIn.cliMode()) {
|
|
497
|
+
// TODO for now...
|
|
498
|
+
this.disabledRealtime = true;
|
|
499
|
+
}
|
|
500
|
+
//#endregion
|
|
501
|
+
this.realtime = new realtime_core_1.RealtimeCore(this);
|
|
502
|
+
}
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region show context info
|
|
505
|
+
// console.log({ ref })
|
|
506
|
+
if (this.config.abstract) {
|
|
507
|
+
this.logFramework &&
|
|
508
|
+
tnp_core_2.Helpers.info("[taon] Create abstract context: ".concat(this.config.contextName));
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
if (this.config.remoteHost) {
|
|
512
|
+
this.logFramework &&
|
|
513
|
+
tnp_core_2.Helpers.info("[taon] Create context for remote host: ".concat(this.config.remoteHost));
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
this.logFramework &&
|
|
517
|
+
tnp_core_2.Helpers.info("[taon] Create context for host: ".concat(this.config.host));
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
// update first exposed config
|
|
522
|
+
Object.keys(this.config).forEach(function (key) {
|
|
523
|
+
_this.originalConfig[key] = _this.config[key];
|
|
524
|
+
});
|
|
525
|
+
return [2 /*return*/];
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region methods & getters / get auto generated config
|
|
532
|
+
EndpointContext.prototype.getAutoGeneratedConfig = function () {
|
|
533
|
+
//#region @websqlFunc
|
|
534
|
+
var databaseConfig;
|
|
535
|
+
if (tnp_core_2.Helpers.isRunningInDocker()) {
|
|
536
|
+
tnp_core_2.Helpers.info('Running in docker, using in mysql database');
|
|
537
|
+
// TODO auto resolve database config in docker
|
|
538
|
+
databaseConfig = {
|
|
539
|
+
database: "tmp-db-".concat(tnp_core_2._.kebabCase(this.contextName), ".sqljs.db"),
|
|
540
|
+
type: 'mysql',
|
|
541
|
+
autoSave: true,
|
|
542
|
+
synchronize: true,
|
|
543
|
+
dropSchema: true,
|
|
544
|
+
logging: this.logDb,
|
|
545
|
+
databasePort: 3306,
|
|
546
|
+
databaseHost: 'localhost',
|
|
547
|
+
databaseUsername: 'root',
|
|
548
|
+
databasePassword: 'admin',
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
this.logFramework &&
|
|
553
|
+
tnp_core_2.Helpers.info("[taon][database] Automatically resolving database config for mode ".concat(this.mode));
|
|
554
|
+
switch (this.mode) {
|
|
555
|
+
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
556
|
+
case 'backend-frontend(ipc-electron)':
|
|
557
|
+
return {
|
|
558
|
+
location: "tmp-db-".concat(tnp_core_2._.kebabCase(this.contextName), ".sqljs"),
|
|
559
|
+
type: 'sqljs',
|
|
560
|
+
autoSave: true,
|
|
561
|
+
synchronize: true,
|
|
562
|
+
dropSchema: true,
|
|
563
|
+
logging: this.logDb,
|
|
564
|
+
};
|
|
565
|
+
break;
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region resolve database config for mode backend-frontend(websql)
|
|
568
|
+
case 'backend-frontend(websql)':
|
|
569
|
+
databaseConfig = {
|
|
570
|
+
location: "tmp-db-".concat(tnp_core_2._.kebabCase(this.contextName), ".sqljs"),
|
|
571
|
+
type: 'sqljs',
|
|
572
|
+
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
573
|
+
autoSave: true,
|
|
574
|
+
synchronize: true,
|
|
575
|
+
dropSchema: true,
|
|
576
|
+
logging: this.logDb,
|
|
577
|
+
};
|
|
578
|
+
var keepWebsqlDbDataAfterReload = false;
|
|
579
|
+
/* */
|
|
580
|
+
/* */
|
|
581
|
+
/* */
|
|
582
|
+
if (keepWebsqlDbDataAfterReload) {
|
|
583
|
+
databaseConfig.dropSchema = false;
|
|
584
|
+
delete databaseConfig.synchronize; // false is not auto synchonize - from what I understand
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
databaseConfig.dropSchema = true;
|
|
588
|
+
databaseConfig.synchronize = true;
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
591
|
+
//#endregion
|
|
592
|
+
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
593
|
+
case 'backend-frontend(tcp+udp)':
|
|
594
|
+
databaseConfig = {
|
|
595
|
+
database: "context-db-".concat(tnp_core_2._.kebabCase(this.contextName)),
|
|
596
|
+
location: "tmp-db-".concat(tnp_core_2._.kebabCase(this.contextName), ".sqlite"),
|
|
597
|
+
type: 'sqljs',
|
|
598
|
+
autoSave: true,
|
|
599
|
+
synchronize: true,
|
|
600
|
+
dropSchema: true,
|
|
601
|
+
logging: this.logDb,
|
|
602
|
+
};
|
|
603
|
+
break;
|
|
604
|
+
//#endregion
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return databaseConfig;
|
|
608
|
+
//#endregion
|
|
609
|
+
};
|
|
610
|
+
Object.defineProperty(EndpointContext.prototype, "ngZone", {
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region methods & getters / ng zone
|
|
613
|
+
get: function () {
|
|
614
|
+
/* */
|
|
615
|
+
/* */
|
|
616
|
+
return;
|
|
617
|
+
},
|
|
618
|
+
enumerable: false,
|
|
619
|
+
configurable: true
|
|
620
|
+
});
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region methods & getters / start server
|
|
623
|
+
EndpointContext.prototype.startServer = function () {
|
|
624
|
+
var _this = this;
|
|
625
|
+
//#region @backendFunc
|
|
626
|
+
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
627
|
+
// this.displayRoutes(this.expressApp);
|
|
628
|
+
this.serverTcpUdp.listen(Number(this.uri.port), function () {
|
|
629
|
+
tnp_core_2.Helpers.log("[taon][express-server]listening on port: ".concat(_this.uri.port, ", hostname: ").concat(_this.uri.pathname, ",\n address: ").concat(_this.uri.protocol, "//localhost:").concat(_this.uri.port).concat(_this.uri.pathname, "\n env: ").concat(_this.expressApp.settings.env, "\n "));
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
this.logFramework &&
|
|
634
|
+
tnp_core_2.Helpers.info('Ipc communication enable instead tcp/upd');
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
};
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region methods & getters / display express routes
|
|
640
|
+
EndpointContext.prototype.displayRoutes = function (app) {
|
|
641
|
+
var _a;
|
|
642
|
+
//#region @backend
|
|
643
|
+
var routes = [];
|
|
644
|
+
(_a = app._router) === null || _a === void 0 ? void 0 : _a.stack.forEach(function (middleware) {
|
|
645
|
+
if (middleware.route) {
|
|
646
|
+
// routes registered directly on the app
|
|
647
|
+
var methods = [];
|
|
648
|
+
for (var method in middleware.route.methods) {
|
|
649
|
+
if (middleware.route.methods[method]) {
|
|
650
|
+
methods.push(method.toUpperCase());
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
routes.push({ path: middleware.route.path, methods: methods });
|
|
654
|
+
}
|
|
655
|
+
else if (middleware.name === 'router') {
|
|
656
|
+
// router middleware
|
|
657
|
+
middleware.handle.stack.forEach(function (handler) {
|
|
658
|
+
var methods = [];
|
|
659
|
+
for (var method in handler.route.methods) {
|
|
660
|
+
if (handler.route.methods[method]) {
|
|
661
|
+
methods.push(method.toUpperCase());
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
routes.push({ path: handler.route.path, methods: methods });
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
console.log(routes);
|
|
669
|
+
//#endregion
|
|
670
|
+
};
|
|
671
|
+
Object.defineProperty(EndpointContext.prototype, "modeAllowsDatabaseCreation", {
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region methods & getters / mode allows database creation
|
|
674
|
+
get: function () {
|
|
675
|
+
return (this.mode === 'backend-frontend(tcp+udp)' ||
|
|
676
|
+
this.mode === 'backend-frontend(websql)' ||
|
|
677
|
+
this.mode === 'backend-frontend(ipc-electron)');
|
|
678
|
+
},
|
|
679
|
+
enumerable: false,
|
|
680
|
+
configurable: true
|
|
681
|
+
});
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region methods & getters / get recrusive classes from contexts
|
|
684
|
+
EndpointContext.prototype.getRecrusiveClassesfromContextsObj = function (classType) {
|
|
685
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
686
|
+
var arr;
|
|
687
|
+
return tslib_1.__generator(this, function (_a) {
|
|
688
|
+
switch (_a.label) {
|
|
689
|
+
case 0: return [4 /*yield*/, this.getRecrusiveClassesfromContexts(classType)];
|
|
690
|
+
case 1:
|
|
691
|
+
arr = _a.sent();
|
|
692
|
+
return [2 /*return*/, arr.reduce(function (acc, c) {
|
|
693
|
+
acc[class_helpers_1.ClassHelpers.getName(c)] = c;
|
|
694
|
+
return acc;
|
|
695
|
+
}, {})];
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
EndpointContext.prototype.getRecrusiveClassesfromContexts = function (classType_1) {
|
|
701
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (classType, arr) {
|
|
702
|
+
var contexts, contexts_1, contexts_1_1, ctx, ref, classesInput, clonedClasses, e_4_1;
|
|
703
|
+
var e_4, _a;
|
|
704
|
+
if (arr === void 0) { arr = []; }
|
|
705
|
+
return tslib_1.__generator(this, function (_b) {
|
|
706
|
+
switch (_b.label) {
|
|
707
|
+
case 0:
|
|
708
|
+
contexts = Object.values(this.config.contexts || {});
|
|
709
|
+
_b.label = 1;
|
|
710
|
+
case 1:
|
|
711
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
712
|
+
contexts_1 = tslib_1.__values(contexts), contexts_1_1 = contexts_1.next();
|
|
713
|
+
_b.label = 2;
|
|
714
|
+
case 2:
|
|
715
|
+
if (!!contexts_1_1.done) return [3 /*break*/, 6];
|
|
716
|
+
ctx = contexts_1_1.value;
|
|
717
|
+
return [4 /*yield*/, ctx.__ref()];
|
|
718
|
+
case 3:
|
|
719
|
+
ref = _b.sent();
|
|
720
|
+
classesInput = ref.getClassFunBy(classType);
|
|
721
|
+
clonedClasses = Object.values(this.cloneClassesObjWithNewMetadata({
|
|
722
|
+
classesInput: classesInput,
|
|
723
|
+
config: this.config,
|
|
724
|
+
ctx: this,
|
|
725
|
+
classType: classType,
|
|
726
|
+
}));
|
|
727
|
+
// console.log(`${classType} clonedClasses`, clonedClasses);
|
|
728
|
+
clonedClasses.forEach(function (c) { return arr.push(c); });
|
|
729
|
+
return [4 /*yield*/, ref.getRecrusiveClassesfromContexts(classType, arr)];
|
|
730
|
+
case 4:
|
|
731
|
+
_b.sent();
|
|
732
|
+
_b.label = 5;
|
|
733
|
+
case 5:
|
|
734
|
+
contexts_1_1 = contexts_1.next();
|
|
735
|
+
return [3 /*break*/, 2];
|
|
736
|
+
case 6: return [3 /*break*/, 9];
|
|
737
|
+
case 7:
|
|
738
|
+
e_4_1 = _b.sent();
|
|
739
|
+
e_4 = { error: e_4_1 };
|
|
740
|
+
return [3 /*break*/, 9];
|
|
741
|
+
case 8:
|
|
742
|
+
try {
|
|
743
|
+
if (contexts_1_1 && !contexts_1_1.done && (_a = contexts_1.return)) _a.call(contexts_1);
|
|
744
|
+
}
|
|
745
|
+
finally { if (e_4) throw e_4.error; }
|
|
746
|
+
return [7 /*endfinally*/];
|
|
747
|
+
case 9: return [2 /*return*/, arr];
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region methods & getters / get class instances by class type
|
|
754
|
+
EndpointContext.prototype.getClassInstanceObjBy = function (classType) {
|
|
755
|
+
return this.classInstancesByNameObj[classType];
|
|
756
|
+
};
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region methods & getters / get class instaces arr
|
|
759
|
+
EndpointContext.prototype.getClassesInstancesArrBy = function (classType) {
|
|
760
|
+
return this.objWithClassesInstancesArr[classType];
|
|
761
|
+
};
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region methods & getters / inject
|
|
764
|
+
EndpointContext.prototype.inject = function (ctor, options) {
|
|
765
|
+
var _a;
|
|
766
|
+
if (!options) {
|
|
767
|
+
options = {};
|
|
768
|
+
}
|
|
769
|
+
var className = class_helpers_1.ClassHelpers.getName(ctor);
|
|
770
|
+
var locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
771
|
+
if (this.isCLassType(models_1.Models.ClassType.REPOSITORY, ctor)) {
|
|
772
|
+
options.localInstance = true;
|
|
773
|
+
}
|
|
774
|
+
if (options === null || options === void 0 ? void 0 : options.localInstance) {
|
|
775
|
+
var ctxClassFn = this.getClassFunByClassName(className);
|
|
776
|
+
var entityName = '';
|
|
777
|
+
if (className === 'BaseRepository') {
|
|
778
|
+
var entityFn = locaInstanceConstructorArgs[0];
|
|
779
|
+
var entity = entityFn && entityFn();
|
|
780
|
+
entityName = entity && class_helpers_1.ClassHelpers.getName(entity);
|
|
781
|
+
}
|
|
782
|
+
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
783
|
+
options.contextClassInstance[this.localInstaceObjSymbol] = {};
|
|
784
|
+
}
|
|
785
|
+
var instanceKey = className + (entityName ? ".".concat(entityName) : '');
|
|
786
|
+
var existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
787
|
+
if (existed) {
|
|
788
|
+
// console.log(`exited `, existed)
|
|
789
|
+
return existed;
|
|
790
|
+
}
|
|
791
|
+
if (!ctxClassFn) {
|
|
792
|
+
throw new Error("Not able to inject \"".concat(className, "\" inside context \"").concat(this.contextName, "\"\n\n Make sure they share the same context or import context where \"").concat(className, "\" is defined.\n\n "));
|
|
793
|
+
}
|
|
794
|
+
var injectedInstance = new ((_a = ctxClassFn).bind.apply(_a, tslib_1.__spreadArray([void 0], tslib_1.__read(locaInstanceConstructorArgs), false)))();
|
|
795
|
+
options.contextClassInstance[this.localInstaceObjSymbol][instanceKey] =
|
|
796
|
+
injectedInstance;
|
|
797
|
+
// console.log(`injectedInstance `, existed)
|
|
798
|
+
return injectedInstance;
|
|
799
|
+
}
|
|
800
|
+
var contextScopeInstance = this.allClassesInstances[className];
|
|
801
|
+
// if (className === 'TopicController') {
|
|
802
|
+
// debugger;
|
|
803
|
+
// }
|
|
804
|
+
return contextScopeInstance;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* alias for inject
|
|
808
|
+
*/
|
|
809
|
+
EndpointContext.prototype.getInstanceBy = function (ctor) {
|
|
810
|
+
return this.inject(ctor, { localInstance: false });
|
|
811
|
+
};
|
|
812
|
+
//#endregion
|
|
813
|
+
EndpointContext.prototype.checkIfContextInitialized = function () {
|
|
814
|
+
if (tnp_core_2._.isUndefined(this.config)) {
|
|
815
|
+
throw new Error("Please check if your context has been initilized.\n\n // ...\n await Context.initialize();\n // ...\n\n\n ");
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
//#region methods & getters / get class function by class type name
|
|
819
|
+
EndpointContext.prototype.getClassFunBy = function (classType) {
|
|
820
|
+
this.checkIfContextInitialized();
|
|
821
|
+
switch (classType) {
|
|
822
|
+
case models_1.Models.ClassType.CONTROLLER:
|
|
823
|
+
return this.config.controllers;
|
|
824
|
+
case models_1.Models.ClassType.ENTITY:
|
|
825
|
+
return this.config.entities;
|
|
826
|
+
case models_1.Models.ClassType.PROVIDER:
|
|
827
|
+
return this.config.providers;
|
|
828
|
+
case models_1.Models.ClassType.REPOSITORY:
|
|
829
|
+
return this.config.repositories;
|
|
830
|
+
case models_1.Models.ClassType.SUBSCRIBER:
|
|
831
|
+
return this.config.subscribers;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
EndpointContext.prototype.isCLassType = function (classType, classFn) {
|
|
835
|
+
return !!this.getClassFunBy(classType)[class_helpers_1.ClassHelpers.getName(classFn)];
|
|
836
|
+
};
|
|
837
|
+
/**
|
|
838
|
+
* Only for injectable types
|
|
839
|
+
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER
|
|
840
|
+
*/
|
|
841
|
+
EndpointContext.prototype.getClassFunByClassName = function (className) {
|
|
842
|
+
var e_5, _a;
|
|
843
|
+
try {
|
|
844
|
+
for (var _b = tslib_1.__values(this.allTypesfromContexts), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
845
|
+
var classTypeName = _c.value;
|
|
846
|
+
var classesForInjectableType = this.config[models_1.Models.ClassTypeKey[classTypeName]];
|
|
847
|
+
if (classesForInjectableType[className]) {
|
|
848
|
+
return classesForInjectableType[className];
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
853
|
+
finally {
|
|
854
|
+
try {
|
|
855
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
856
|
+
}
|
|
857
|
+
finally { if (e_5) throw e_5.error; }
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
EndpointContext.prototype.getClassFunByClass = function (classFunction) {
|
|
861
|
+
var className = class_helpers_1.ClassHelpers.getName(classFunction);
|
|
862
|
+
return this.getClassFunByClassName(className);
|
|
863
|
+
};
|
|
864
|
+
EndpointContext.prototype.getClassFunByArr = function (classType) {
|
|
865
|
+
return Object.values(this.getClassFunBy(classType) || {});
|
|
866
|
+
};
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region methods & getters / create class instances
|
|
869
|
+
EndpointContext.prototype.createInstances = function (classes, classType) {
|
|
870
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
871
|
+
var _a, _b, classFn, instance, classInstancesByNameObj, className;
|
|
872
|
+
var e_6, _c;
|
|
873
|
+
return tslib_1.__generator(this, function (_d) {
|
|
874
|
+
try {
|
|
875
|
+
// const recrusiveValuesFromContext =
|
|
876
|
+
// await this.getRecrusiveClassesfromContexts(classType);
|
|
877
|
+
// console.log(this.config.contexts);
|
|
878
|
+
// console.log('recrusiveValuesFromContext', recrusiveValuesFromContext);
|
|
879
|
+
for (_a = tslib_1.__values(tslib_1.__spreadArray([], tslib_1.__read(Object.values(classes)), false)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
880
|
+
classFn = _b.value;
|
|
881
|
+
instance = di_container_1.DITaonContainer.resolve(classFn);
|
|
882
|
+
classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
883
|
+
className = class_helpers_1.ClassHelpers.getName(classFn);
|
|
884
|
+
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
885
|
+
classInstancesByNameObj[className] = instance;
|
|
886
|
+
// update config
|
|
887
|
+
this.config[models_1.Models.ClassTypeKey[classType]][className] = classFn;
|
|
888
|
+
this.objWithClassesInstancesArr[classType].push(instance);
|
|
889
|
+
this.allClassesInstances[className] = instance;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
893
|
+
finally {
|
|
894
|
+
try {
|
|
895
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
896
|
+
}
|
|
897
|
+
finally { if (e_6) throw e_6.error; }
|
|
898
|
+
}
|
|
899
|
+
return [2 /*return*/];
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
};
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region methods & getters / reinit controllers db example data
|
|
905
|
+
EndpointContext.prototype.reinitControllers = function () {
|
|
906
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
907
|
+
var controllers, controllers_1, controllers_1_1, ctrl, e_7_1;
|
|
908
|
+
var e_7, _a;
|
|
909
|
+
return tslib_1.__generator(this, function (_b) {
|
|
910
|
+
switch (_b.label) {
|
|
911
|
+
case 0:
|
|
912
|
+
controllers = this.getClassesInstancesArrBy(models_1.Models.ClassType.CONTROLLER);
|
|
913
|
+
_b.label = 1;
|
|
914
|
+
case 1:
|
|
915
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
916
|
+
controllers_1 = tslib_1.__values(controllers), controllers_1_1 = controllers_1.next();
|
|
917
|
+
_b.label = 2;
|
|
918
|
+
case 2:
|
|
919
|
+
if (!!controllers_1_1.done) return [3 /*break*/, 5];
|
|
920
|
+
ctrl = controllers_1_1.value;
|
|
921
|
+
if (!tnp_core_2._.isFunction(ctrl.initExampleDbData)) return [3 /*break*/, 4];
|
|
922
|
+
return [4 /*yield*/, tnp_core_2.Helpers.runSyncOrAsync({
|
|
923
|
+
functionFn: ctrl.initExampleDbData,
|
|
924
|
+
context: ctrl,
|
|
925
|
+
})];
|
|
926
|
+
case 3:
|
|
927
|
+
_b.sent();
|
|
928
|
+
_b.label = 4;
|
|
929
|
+
case 4:
|
|
930
|
+
controllers_1_1 = controllers_1.next();
|
|
931
|
+
return [3 /*break*/, 2];
|
|
932
|
+
case 5: return [3 /*break*/, 8];
|
|
933
|
+
case 6:
|
|
934
|
+
e_7_1 = _b.sent();
|
|
935
|
+
e_7 = { error: e_7_1 };
|
|
936
|
+
return [3 /*break*/, 8];
|
|
937
|
+
case 7:
|
|
938
|
+
try {
|
|
939
|
+
if (controllers_1_1 && !controllers_1_1.done && (_a = controllers_1.return)) _a.call(controllers_1);
|
|
940
|
+
}
|
|
941
|
+
finally { if (e_7) throw e_7.error; }
|
|
942
|
+
return [7 /*endfinally*/];
|
|
943
|
+
case 8: return [2 /*return*/];
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
EndpointContext.prototype.initClasses = function () {
|
|
949
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
950
|
+
var _a, _b, classTypeName, _c, _d, classFun, e_8_1, e_9_1, _e, _f, classTypeName, _g, _h, ctrl, e_10_1, e_11_1;
|
|
951
|
+
var e_9, _j, e_8, _k, e_11, _l, e_10, _m;
|
|
952
|
+
return tslib_1.__generator(this, function (_o) {
|
|
953
|
+
switch (_o.label) {
|
|
954
|
+
case 0:
|
|
955
|
+
_o.trys.push([0, 11, 12, 13]);
|
|
956
|
+
_a = tslib_1.__values([
|
|
957
|
+
models_1.Models.ClassType.PROVIDER,
|
|
958
|
+
models_1.Models.ClassType.REPOSITORY,
|
|
959
|
+
models_1.Models.ClassType.CONTROLLER,
|
|
960
|
+
models_1.Models.ClassType.ENTITY,
|
|
961
|
+
]), _b = _a.next();
|
|
962
|
+
_o.label = 1;
|
|
963
|
+
case 1:
|
|
964
|
+
if (!!_b.done) return [3 /*break*/, 10];
|
|
965
|
+
classTypeName = _b.value;
|
|
966
|
+
_o.label = 2;
|
|
967
|
+
case 2:
|
|
968
|
+
_o.trys.push([2, 7, 8, 9]);
|
|
969
|
+
_c = (e_8 = void 0, tslib_1.__values(this.getClassFunByArr(classTypeName))), _d = _c.next();
|
|
970
|
+
_o.label = 3;
|
|
971
|
+
case 3:
|
|
972
|
+
if (!!_d.done) return [3 /*break*/, 6];
|
|
973
|
+
classFun = _d.value;
|
|
974
|
+
if (!tnp_core_2._.isFunction(classFun._)) return [3 /*break*/, 5];
|
|
975
|
+
return [4 /*yield*/, tnp_core_2.Helpers.runSyncOrAsync({
|
|
976
|
+
functionFn: classFun._,
|
|
977
|
+
context: classFun,
|
|
978
|
+
})];
|
|
979
|
+
case 4:
|
|
980
|
+
_o.sent();
|
|
981
|
+
_o.label = 5;
|
|
982
|
+
case 5:
|
|
983
|
+
_d = _c.next();
|
|
984
|
+
return [3 /*break*/, 3];
|
|
985
|
+
case 6: return [3 /*break*/, 9];
|
|
986
|
+
case 7:
|
|
987
|
+
e_8_1 = _o.sent();
|
|
988
|
+
e_8 = { error: e_8_1 };
|
|
989
|
+
return [3 /*break*/, 9];
|
|
990
|
+
case 8:
|
|
991
|
+
try {
|
|
992
|
+
if (_d && !_d.done && (_k = _c.return)) _k.call(_c);
|
|
993
|
+
}
|
|
994
|
+
finally { if (e_8) throw e_8.error; }
|
|
995
|
+
return [7 /*endfinally*/];
|
|
996
|
+
case 9:
|
|
997
|
+
_b = _a.next();
|
|
998
|
+
return [3 /*break*/, 1];
|
|
999
|
+
case 10: return [3 /*break*/, 13];
|
|
1000
|
+
case 11:
|
|
1001
|
+
e_9_1 = _o.sent();
|
|
1002
|
+
e_9 = { error: e_9_1 };
|
|
1003
|
+
return [3 /*break*/, 13];
|
|
1004
|
+
case 12:
|
|
1005
|
+
try {
|
|
1006
|
+
if (_b && !_b.done && (_j = _a.return)) _j.call(_a);
|
|
1007
|
+
}
|
|
1008
|
+
finally { if (e_9) throw e_9.error; }
|
|
1009
|
+
return [7 /*endfinally*/];
|
|
1010
|
+
case 13:
|
|
1011
|
+
_o.trys.push([13, 24, 25, 26]);
|
|
1012
|
+
_e = tslib_1.__values([
|
|
1013
|
+
models_1.Models.ClassType.PROVIDER,
|
|
1014
|
+
models_1.Models.ClassType.REPOSITORY,
|
|
1015
|
+
models_1.Models.ClassType.CONTROLLER,
|
|
1016
|
+
]), _f = _e.next();
|
|
1017
|
+
_o.label = 14;
|
|
1018
|
+
case 14:
|
|
1019
|
+
if (!!_f.done) return [3 /*break*/, 23];
|
|
1020
|
+
classTypeName = _f.value;
|
|
1021
|
+
_o.label = 15;
|
|
1022
|
+
case 15:
|
|
1023
|
+
_o.trys.push([15, 20, 21, 22]);
|
|
1024
|
+
_g = (e_10 = void 0, tslib_1.__values(this.getClassesInstancesArrBy(classTypeName))), _h = _g.next();
|
|
1025
|
+
_o.label = 16;
|
|
1026
|
+
case 16:
|
|
1027
|
+
if (!!_h.done) return [3 /*break*/, 19];
|
|
1028
|
+
ctrl = _h.value;
|
|
1029
|
+
if (!tnp_core_2._.isFunction(ctrl._)) return [3 /*break*/, 18];
|
|
1030
|
+
return [4 /*yield*/, tnp_core_2.Helpers.runSyncOrAsync({
|
|
1031
|
+
functionFn: ctrl._,
|
|
1032
|
+
context: ctrl,
|
|
1033
|
+
})];
|
|
1034
|
+
case 17:
|
|
1035
|
+
_o.sent();
|
|
1036
|
+
_o.label = 18;
|
|
1037
|
+
case 18:
|
|
1038
|
+
_h = _g.next();
|
|
1039
|
+
return [3 /*break*/, 16];
|
|
1040
|
+
case 19: return [3 /*break*/, 22];
|
|
1041
|
+
case 20:
|
|
1042
|
+
e_10_1 = _o.sent();
|
|
1043
|
+
e_10 = { error: e_10_1 };
|
|
1044
|
+
return [3 /*break*/, 22];
|
|
1045
|
+
case 21:
|
|
1046
|
+
try {
|
|
1047
|
+
if (_h && !_h.done && (_m = _g.return)) _m.call(_g);
|
|
1048
|
+
}
|
|
1049
|
+
finally { if (e_10) throw e_10.error; }
|
|
1050
|
+
return [7 /*endfinally*/];
|
|
1051
|
+
case 22:
|
|
1052
|
+
_f = _e.next();
|
|
1053
|
+
return [3 /*break*/, 14];
|
|
1054
|
+
case 23: return [3 /*break*/, 26];
|
|
1055
|
+
case 24:
|
|
1056
|
+
e_11_1 = _o.sent();
|
|
1057
|
+
e_11 = { error: e_11_1 };
|
|
1058
|
+
return [3 /*break*/, 26];
|
|
1059
|
+
case 25:
|
|
1060
|
+
try {
|
|
1061
|
+
if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
|
|
1062
|
+
}
|
|
1063
|
+
finally { if (e_11) throw e_11.error; }
|
|
1064
|
+
return [7 /*endfinally*/];
|
|
1065
|
+
case 26: return [2 /*return*/];
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
1069
|
+
};
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region methods & getters / is active on
|
|
1072
|
+
EndpointContext.prototype.isActiveOn = function (classInstance) {
|
|
1073
|
+
var contextRef = classInstance[symbols_1.Symbols.ctxInClassOrClassObj];
|
|
1074
|
+
return this === contextRef;
|
|
1075
|
+
};
|
|
1076
|
+
Object.defineProperty(EndpointContext.prototype, "uri", {
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region methods & getters / uri
|
|
1079
|
+
get: function () {
|
|
1080
|
+
var url = this.host
|
|
1081
|
+
? new url_1.URL(this.host)
|
|
1082
|
+
: this.remoteHost
|
|
1083
|
+
? new url_1.URL(this.remoteHost)
|
|
1084
|
+
: void 0;
|
|
1085
|
+
return url;
|
|
1086
|
+
},
|
|
1087
|
+
enumerable: false,
|
|
1088
|
+
configurable: true
|
|
1089
|
+
});
|
|
1090
|
+
Object.defineProperty(EndpointContext.prototype, "isHttpServer", {
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region methods & getters / is https server
|
|
1093
|
+
get: function () {
|
|
1094
|
+
return this.uri.protocol === 'https:';
|
|
1095
|
+
},
|
|
1096
|
+
enumerable: false,
|
|
1097
|
+
configurable: true
|
|
1098
|
+
});
|
|
1099
|
+
Object.defineProperty(EndpointContext.prototype, "contextName", {
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region methods & getters / public assets
|
|
1102
|
+
/**
|
|
1103
|
+
* ipc/udp needs this
|
|
1104
|
+
*/
|
|
1105
|
+
get: function () {
|
|
1106
|
+
return this.config.contextName;
|
|
1107
|
+
},
|
|
1108
|
+
enumerable: false,
|
|
1109
|
+
configurable: true
|
|
1110
|
+
});
|
|
1111
|
+
Object.defineProperty(EndpointContext.prototype, "publicAssets", {
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region methods & getters / public assets
|
|
1114
|
+
get: function () {
|
|
1115
|
+
var _a;
|
|
1116
|
+
return ((_a = this.config) === null || _a === void 0 ? void 0 : _a.publicAssets) || [];
|
|
1117
|
+
},
|
|
1118
|
+
enumerable: false,
|
|
1119
|
+
configurable: true
|
|
1120
|
+
});
|
|
1121
|
+
Object.defineProperty(EndpointContext.prototype, "isProductionMode", {
|
|
1122
|
+
//#endregion
|
|
1123
|
+
//#region methods & getters / is production mode
|
|
1124
|
+
get: function () {
|
|
1125
|
+
return this.config.productionMode;
|
|
1126
|
+
},
|
|
1127
|
+
enumerable: false,
|
|
1128
|
+
configurable: true
|
|
1129
|
+
});
|
|
1130
|
+
Object.defineProperty(EndpointContext.prototype, "remoteHost", {
|
|
1131
|
+
//#endregion
|
|
1132
|
+
//#region methods & getters / remote host
|
|
1133
|
+
get: function () {
|
|
1134
|
+
return this.config.remoteHost;
|
|
1135
|
+
},
|
|
1136
|
+
enumerable: false,
|
|
1137
|
+
configurable: true
|
|
1138
|
+
});
|
|
1139
|
+
Object.defineProperty(EndpointContext.prototype, "host", {
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region methods & getters / host
|
|
1142
|
+
get: function () {
|
|
1143
|
+
return this.config.host;
|
|
1144
|
+
},
|
|
1145
|
+
enumerable: false,
|
|
1146
|
+
configurable: true
|
|
1147
|
+
});
|
|
1148
|
+
Object.defineProperty(EndpointContext.prototype, "orgin", {
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region methods & getters / host
|
|
1151
|
+
get: function () {
|
|
1152
|
+
var _a;
|
|
1153
|
+
return (_a = this.uri) === null || _a === void 0 ? void 0 : _a.origin;
|
|
1154
|
+
},
|
|
1155
|
+
enumerable: false,
|
|
1156
|
+
configurable: true
|
|
1157
|
+
});
|
|
1158
|
+
//#endregion
|
|
1159
|
+
//#region methods & getters / init subscribers
|
|
1160
|
+
EndpointContext.prototype.initSubscribers = function () {
|
|
1161
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1162
|
+
var subscribers, subscribers_1, subscribers_1_1, subscriber, options, entities, index;
|
|
1163
|
+
var e_12, _a;
|
|
1164
|
+
var _b;
|
|
1165
|
+
return tslib_1.__generator(this, function (_c) {
|
|
1166
|
+
return [2 /*return*/]; // TODO
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
};
|
|
1170
|
+
//#endregion
|
|
1171
|
+
//#region methods & getters / init entities
|
|
1172
|
+
EndpointContext.prototype.initEntities = function () {
|
|
1173
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1174
|
+
var entities, entities_1, entities_1_1, entity, options, createTable, nameForEntity;
|
|
1175
|
+
var e_13, _a;
|
|
1176
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1177
|
+
entities = this.getClassFunByArr(models_1.Models.ClassType.ENTITY);
|
|
1178
|
+
try {
|
|
1179
|
+
for (entities_1 = tslib_1.__values(entities), entities_1_1 = entities_1.next(); !entities_1_1.done; entities_1_1 = entities_1.next()) {
|
|
1180
|
+
entity = entities_1_1.value;
|
|
1181
|
+
options = Reflect.getMetadata(symbols_1.Symbols.metadata.options.entity, entity);
|
|
1182
|
+
createTable = tnp_core_2._.isUndefined(options.createTable)
|
|
1183
|
+
? true
|
|
1184
|
+
: options.createTable;
|
|
1185
|
+
nameForEntity = class_helpers_1.ClassHelpers.getName(entity);
|
|
1186
|
+
if (tnp_core_2._.isUndefined(options.createTable) ? true : options.createTable) {
|
|
1187
|
+
this.logDb &&
|
|
1188
|
+
console.info("[taon][typeorm] create table for entity \"".concat(nameForEntity, "\" ? '").concat(createTable, "'"));
|
|
1189
|
+
// console.log('TypeormEntity', { TypeormEntity });
|
|
1190
|
+
(0, taon_typeorm_2.Entity)(nameForEntity)(entity);
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
this.logDb &&
|
|
1194
|
+
console.info("[taon][typeorm] create table for entity \"".concat(nameForEntity, "\" ? '").concat(createTable, "'"));
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1199
|
+
finally {
|
|
1200
|
+
try {
|
|
1201
|
+
if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
|
|
1202
|
+
}
|
|
1203
|
+
finally { if (e_13) throw e_13.error; }
|
|
1204
|
+
}
|
|
1205
|
+
return [2 /*return*/];
|
|
1206
|
+
});
|
|
1207
|
+
});
|
|
1208
|
+
};
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region methods & getters / init connection
|
|
1211
|
+
EndpointContext.prototype.initDatabaseConnection = function () {
|
|
1212
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1213
|
+
var entities, subscribers, dataSourceDbConfig, connection, error_1;
|
|
1214
|
+
var _a, _b, _c, _d;
|
|
1215
|
+
return tslib_1.__generator(this, function (_e) {
|
|
1216
|
+
switch (_e.label) {
|
|
1217
|
+
case 0:
|
|
1218
|
+
entities = (((_a = this.config.override) === null || _a === void 0 ? void 0 : _a.entities)
|
|
1219
|
+
? this.config.override.entities
|
|
1220
|
+
: this.getClassFunByArr(models_1.Models.ClassType.ENTITY)).map(function (entityFn) {
|
|
1221
|
+
return class_helpers_1.ClassHelpers.getOrginalClass(entityFn);
|
|
1222
|
+
});
|
|
1223
|
+
subscribers = (((_b = this.config.override) === null || _b === void 0 ? void 0 : _b.subscribers)
|
|
1224
|
+
? this.config.override.subscribers
|
|
1225
|
+
: this.getClassFunByArr(models_1.Models.ClassType.SUBSCRIBER)).filter(function (f) { return f instanceof base_subscriber_for_entity_1.BaseSubscriberForEntity; });
|
|
1226
|
+
dataSourceDbConfig = tnp_core_2._.isObject(this.databaseConfig)
|
|
1227
|
+
? {
|
|
1228
|
+
type: this.databaseConfig.type,
|
|
1229
|
+
port: this.databaseConfig.databasePort,
|
|
1230
|
+
host: this.databaseConfig.databaseHost,
|
|
1231
|
+
database: this.databaseConfig.database,
|
|
1232
|
+
username: this.databaseConfig.databaseUsername,
|
|
1233
|
+
password: this.databaseConfig.databasePassword,
|
|
1234
|
+
useLocalForage: this.databaseConfig.useLocalForage,
|
|
1235
|
+
entities: entities,
|
|
1236
|
+
subscribers: subscribers,
|
|
1237
|
+
synchronize: this.databaseConfig.synchronize,
|
|
1238
|
+
autoSave: this.databaseConfig.autoSave,
|
|
1239
|
+
dropSchema: this.databaseConfig.dropSchema,
|
|
1240
|
+
logging: !!this.databaseConfig.logging,
|
|
1241
|
+
location: this.databaseConfig.location,
|
|
1242
|
+
}
|
|
1243
|
+
: {};
|
|
1244
|
+
if (!(this.modeAllowsDatabaseCreation && this.databaseConfig)) return [3 /*break*/, 5];
|
|
1245
|
+
this.logDb &&
|
|
1246
|
+
this.logFramework &&
|
|
1247
|
+
tnp_core_2.Helpers.info('[taon][database] prepare typeorm connection...');
|
|
1248
|
+
_e.label = 1;
|
|
1249
|
+
case 1:
|
|
1250
|
+
_e.trys.push([1, 3, , 4]);
|
|
1251
|
+
connection = new taon_typeorm_3.DataSource(dataSourceDbConfig);
|
|
1252
|
+
this.connection = connection;
|
|
1253
|
+
return [4 /*yield*/, this.connection.initialize()];
|
|
1254
|
+
case 2:
|
|
1255
|
+
_e.sent();
|
|
1256
|
+
return [3 /*break*/, 4];
|
|
1257
|
+
case 3:
|
|
1258
|
+
error_1 = _e.sent();
|
|
1259
|
+
console.error((error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || error_1);
|
|
1260
|
+
return [3 /*break*/, 4];
|
|
1261
|
+
case 4:
|
|
1262
|
+
if (!((_c = this.connection) === null || _c === void 0 ? void 0 : _c.isInitialized)) {
|
|
1263
|
+
console.log('WRONG CONFIG', dataSourceDbConfig);
|
|
1264
|
+
throw new Error("Something wrong with connection init in ".concat(this.mode));
|
|
1265
|
+
//#region @backend
|
|
1266
|
+
process.exit(1);
|
|
1267
|
+
//#endregion
|
|
1268
|
+
}
|
|
1269
|
+
(this.logDb || this.logFramework) &&
|
|
1270
|
+
console.info("\n\n CONTECTION OK for ".concat(this.contextName, " - ").concat(this.mode, "\n\n [taon][typeorm] db prepration done.. db initialize=").concat((_d = this.connection) === null || _d === void 0 ? void 0 : _d.isInitialized, "\n\n\n "), dataSourceDbConfig);
|
|
1271
|
+
return [3 /*break*/, 6];
|
|
1272
|
+
case 5:
|
|
1273
|
+
tnp_core_2.Helpers.info("[taon][typeorm] Not initing db for mode ".concat(this.mode));
|
|
1274
|
+
_e.label = 6;
|
|
1275
|
+
case 6: return [2 /*return*/];
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
});
|
|
1279
|
+
};
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region methods & getters / initialize metadata
|
|
1282
|
+
EndpointContext.prototype.initMetadata = function () {
|
|
1283
|
+
var e_14, _a;
|
|
1284
|
+
var _this = this;
|
|
1285
|
+
var allControllers = this.getClassFunByArr(models_1.Models.ClassType.CONTROLLER);
|
|
1286
|
+
var _loop_1 = function (controllerClassFn) {
|
|
1287
|
+
controllerClassFn[symbols_1.Symbols.classMethodsNames] =
|
|
1288
|
+
class_helpers_1.ClassHelpers.getMethodsNames(controllerClassFn);
|
|
1289
|
+
var configs = class_helpers_1.ClassHelpers.getControllerConfigs(controllerClassFn);
|
|
1290
|
+
// console.log(`Class config for ${ClassHelpers.getName(controllerClassFn)}`, configs)
|
|
1291
|
+
var classConfig = configs[0];
|
|
1292
|
+
var parentscalculatedPath = tnp_core_2._.slice(configs, 1)
|
|
1293
|
+
.reverse()
|
|
1294
|
+
.map(function (bc) {
|
|
1295
|
+
if (taon_helpers_1.TaonHelpers.isGoodPath(bc.path)) {
|
|
1296
|
+
return bc.path;
|
|
1297
|
+
}
|
|
1298
|
+
return bc.className;
|
|
1299
|
+
})
|
|
1300
|
+
.join('/');
|
|
1301
|
+
if (taon_helpers_1.TaonHelpers.isGoodPath(classConfig.path)) {
|
|
1302
|
+
classConfig.calculatedPath = classConfig.path;
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
classConfig.calculatedPath =
|
|
1306
|
+
"".concat(parentscalculatedPath, "/").concat(class_helpers_1.ClassHelpers.getName(controllerClassFn))
|
|
1307
|
+
.replace(/\/\//g, '/')
|
|
1308
|
+
.split('/')
|
|
1309
|
+
.reduce(function (acc, bc) {
|
|
1310
|
+
return tnp_core_2._.last(acc) === bc ? acc : tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(acc), false), [bc], false);
|
|
1311
|
+
}, [])
|
|
1312
|
+
.join('/');
|
|
1313
|
+
}
|
|
1314
|
+
tnp_core_2._.slice(configs, 1).forEach(function (bc) {
|
|
1315
|
+
var alreadyIs = classConfig.methods;
|
|
1316
|
+
var toMerge = tnp_core_2._.cloneDeep(bc.methods);
|
|
1317
|
+
for (var key in toMerge) {
|
|
1318
|
+
if (toMerge.hasOwnProperty(key) && !alreadyIs[key]) {
|
|
1319
|
+
var element = toMerge[key];
|
|
1320
|
+
alreadyIs[key] = element;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
//#region @backend
|
|
1325
|
+
if (!tnp_core_2.Helpers.isRunningIn.cliMode()) {
|
|
1326
|
+
//#endregion
|
|
1327
|
+
this_1.logHttp &&
|
|
1328
|
+
console.groupCollapsed("[taon][express-server] routes [".concat(classConfig.className, "]"));
|
|
1329
|
+
//#region @backend
|
|
1330
|
+
}
|
|
1331
|
+
//#endregion
|
|
1332
|
+
// console.log('methods', classConfig.methods);
|
|
1333
|
+
Object.keys(classConfig.methods).forEach(function (methodName) {
|
|
1334
|
+
var _a;
|
|
1335
|
+
var methodConfig = classConfig.methods[methodName];
|
|
1336
|
+
// debugger
|
|
1337
|
+
var type = methodConfig.type;
|
|
1338
|
+
var expressPath = methodConfig.global
|
|
1339
|
+
? "/".concat((_a = methodConfig.path) === null || _a === void 0 ? void 0 : _a.replace(/\//, ''))
|
|
1340
|
+
: taon_helpers_1.TaonHelpers.getExpressPath(classConfig, methodConfig);
|
|
1341
|
+
// console.log({ expressPath })
|
|
1342
|
+
if (tnp_core_2.Helpers.isNode || tnp_core_2.Helpers.isWebSQL) {
|
|
1343
|
+
//#region @websql
|
|
1344
|
+
var _b = _this.initServer(type, methodConfig, classConfig, expressPath, controllerClassFn), routePath = _b.routePath, method = _b.method;
|
|
1345
|
+
_this.activeRoutes.push({
|
|
1346
|
+
routePath: routePath,
|
|
1347
|
+
method: method,
|
|
1348
|
+
});
|
|
1349
|
+
//#endregion
|
|
1350
|
+
}
|
|
1351
|
+
var shouldInitClient = tnp_core_2.Helpers.isBrowser || _this.remoteHost || tnp_core_2.Helpers.isWebSQL;
|
|
1352
|
+
// console.log('shouldInitClient', shouldInitClient);
|
|
1353
|
+
if (shouldInitClient) {
|
|
1354
|
+
// console.log(
|
|
1355
|
+
// 'initClient',
|
|
1356
|
+
// ClassHelpers.getFullInternalName(controllerClassFn),
|
|
1357
|
+
// type,
|
|
1358
|
+
// methodConfig,
|
|
1359
|
+
// expressPath,
|
|
1360
|
+
// );
|
|
1361
|
+
_this.initClient(controllerClassFn, type, methodConfig, expressPath);
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
//#region @backend
|
|
1365
|
+
if (!tnp_core_2.Helpers.isRunningIn.cliMode()) {
|
|
1366
|
+
//#endregion
|
|
1367
|
+
this_1.logHttp && console.groupEnd();
|
|
1368
|
+
//#region @backend
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
var this_1 = this;
|
|
1372
|
+
try {
|
|
1373
|
+
// console.log('allControllers', allControllers)11
|
|
1374
|
+
for (var allControllers_1 = tslib_1.__values(allControllers), allControllers_1_1 = allControllers_1.next(); !allControllers_1_1.done; allControllers_1_1 = allControllers_1.next()) {
|
|
1375
|
+
var controllerClassFn = allControllers_1_1.value;
|
|
1376
|
+
_loop_1(controllerClassFn);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1380
|
+
finally {
|
|
1381
|
+
try {
|
|
1382
|
+
if (allControllers_1_1 && !allControllers_1_1.done && (_a = allControllers_1.return)) _a.call(allControllers_1);
|
|
1383
|
+
}
|
|
1384
|
+
finally { if (e_14) throw e_14.error; }
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
//#endregion
|
|
1388
|
+
//#region methods & getters / write active routes
|
|
1389
|
+
EndpointContext.prototype.writeActiveRoutes = function () {
|
|
1390
|
+
var _this = this;
|
|
1391
|
+
var contexts = [this];
|
|
1392
|
+
//#region @websql
|
|
1393
|
+
var troutes = this.activeRoutes.map(function (_a) {
|
|
1394
|
+
var method = _a.method, routePath = _a.routePath;
|
|
1395
|
+
return (taon_helpers_1.TaonHelpers.fillUpTo(method.toUpperCase() + ':', 10) +
|
|
1396
|
+
_this.uri.href.replace(/\/$/, '') +
|
|
1397
|
+
routePath);
|
|
1398
|
+
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
1399
|
+
// .fillUpTo(10)}${context.uri.href.replace(/\/$/, '')}${routePath}`
|
|
1400
|
+
});
|
|
1401
|
+
var routes = tslib_1.__spreadArray(tslib_1.__spreadArray([], ['', "---------- FOR HOST ".concat(this.uri.href, " ----------")], false), tslib_1.__read(troutes), false);
|
|
1402
|
+
var fileName = tnp_core_3.path.join(
|
|
1403
|
+
//#region @backend
|
|
1404
|
+
process.cwd(),
|
|
1405
|
+
//#endregion
|
|
1406
|
+
"tmp-routes-".concat(tnp_core_2._.kebabCase(this.config.contextName), ".json"));
|
|
1407
|
+
this.logFramework && console.log("[taon] routes file: ".concat(fileName, " "));
|
|
1408
|
+
// Helpers.log(JSON.stringify(routes, null, 4))
|
|
1409
|
+
//#region @backend
|
|
1410
|
+
tnp_core_1.fse.writeJSONSync(fileName, routes, {
|
|
1411
|
+
spaces: 2,
|
|
1412
|
+
encoding: 'utf8',
|
|
1413
|
+
});
|
|
1414
|
+
//#endregion
|
|
1415
|
+
//#endregion
|
|
1416
|
+
};
|
|
1417
|
+
Object.defineProperty(EndpointContext.prototype, "middlewares", {
|
|
1418
|
+
//#endregion
|
|
1419
|
+
//#region methods & getters / middlewares
|
|
1420
|
+
get: function () {
|
|
1421
|
+
//#region @backendFunc
|
|
1422
|
+
return this.config.middlewares || [];
|
|
1423
|
+
//#endregion
|
|
1424
|
+
},
|
|
1425
|
+
enumerable: false,
|
|
1426
|
+
configurable: true
|
|
1427
|
+
});
|
|
1428
|
+
//#endregion
|
|
1429
|
+
//#region methods & getters / init midleware
|
|
1430
|
+
EndpointContext.prototype.initMidleware = function () {
|
|
1431
|
+
var _this = this;
|
|
1432
|
+
//#region @backend
|
|
1433
|
+
var app = this.expressApp;
|
|
1434
|
+
if (this.middlewares) {
|
|
1435
|
+
this.middlewares.forEach(function (m) {
|
|
1436
|
+
var _a = tslib_1.__read(m, 2), fun = _a[0], args = _a[1];
|
|
1437
|
+
app.use(fun.apply(null, args));
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
this.expressApp.get('/helloworld', function (req, res) {
|
|
1441
|
+
res.send("Hello, world from context ".concat(_this.contextName));
|
|
1442
|
+
});
|
|
1443
|
+
app.use(fileUpload());
|
|
1444
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
1445
|
+
app.use(bodyParser.json());
|
|
1446
|
+
app.use(methodOverride());
|
|
1447
|
+
app.use(cookieParser());
|
|
1448
|
+
if (this.session) {
|
|
1449
|
+
tnp_core_2.Helpers.info('[taon][express-server] session enabled for this context ' +
|
|
1450
|
+
this.contextName);
|
|
1451
|
+
var cookieMaxAge = this.session.cookieMaxAge;
|
|
1452
|
+
var frontendHost = this.config.frontendHost;
|
|
1453
|
+
var sessionObj = {
|
|
1454
|
+
frontendHost: frontendHost,
|
|
1455
|
+
secret: 'mysecretsessioncookithing',
|
|
1456
|
+
saveUninitialized: true,
|
|
1457
|
+
cookieMaxAge: cookieMaxAge,
|
|
1458
|
+
secure: frontendHost.startsWith('https://'),
|
|
1459
|
+
resave: false,
|
|
1460
|
+
};
|
|
1461
|
+
app.use(cors({
|
|
1462
|
+
credentials: true,
|
|
1463
|
+
origin: frontendHost,
|
|
1464
|
+
}));
|
|
1465
|
+
app.use(expressSession(sessionObj));
|
|
1466
|
+
console.log("\n\n CORS ENABLED FOR SESSION\n\n ");
|
|
1467
|
+
}
|
|
1468
|
+
else {
|
|
1469
|
+
// if(this.config?.serverLogs) {
|
|
1470
|
+
this.logHttp &&
|
|
1471
|
+
tnp_core_2.Helpers.info("[taon][express-server] session not enabled for this context '".concat(this.contextName, "'"));
|
|
1472
|
+
// }
|
|
1473
|
+
app.use(cors({
|
|
1474
|
+
// origin: "http://localhost:5555",
|
|
1475
|
+
// methods: ["GET", "POST"],
|
|
1476
|
+
// allowedHeaders: ["my-custom-header"],
|
|
1477
|
+
// credentials: true
|
|
1478
|
+
}));
|
|
1479
|
+
this.logHttp &&
|
|
1480
|
+
console.log("\n\n CORS ENABLED WITHOUT SESSION\n\n ");
|
|
1481
|
+
}
|
|
1482
|
+
(function () {
|
|
1483
|
+
app.use(function (req, res, next) {
|
|
1484
|
+
//#region good for cors session obj
|
|
1485
|
+
// if (this.context.session) {
|
|
1486
|
+
// res.header('Access-Control-Allow-Origin', this.context.session.frontendHost);
|
|
1487
|
+
// res.header('Access-Control-Allow-Credentials', 'true');
|
|
1488
|
+
// res.header(
|
|
1489
|
+
// 'Access-Control-Allow-Headers',
|
|
1490
|
+
// 'Origin, X-Requested-With, Content-Type, Accept'
|
|
1491
|
+
// );
|
|
1492
|
+
// res.header("Access-Control-Allow-Methods", "PUT,POST,GET,HEAD,DELETE,OPTIONS,PATCH");
|
|
1493
|
+
// // maybe this
|
|
1494
|
+
// res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
|
|
1495
|
+
// }
|
|
1496
|
+
//#endregion
|
|
1497
|
+
res.set('Access-Control-Expose-Headers', [
|
|
1498
|
+
'Content-Type',
|
|
1499
|
+
'Authorization',
|
|
1500
|
+
'X-Requested-With',
|
|
1501
|
+
symbols_1.Symbols.old.X_TOTAL_COUNT,
|
|
1502
|
+
symbols_1.Symbols.old.MAPPING_CONFIG_HEADER,
|
|
1503
|
+
symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1504
|
+
symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1505
|
+
].join(', '));
|
|
1506
|
+
next();
|
|
1507
|
+
});
|
|
1508
|
+
})();
|
|
1509
|
+
//#endregion
|
|
1510
|
+
};
|
|
1511
|
+
//#endregion
|
|
1512
|
+
//#region methods & getters / init methods node
|
|
1513
|
+
EndpointContext.prototype.initServer = function (
|
|
1514
|
+
//#region parameters
|
|
1515
|
+
type, methodConfig, classConfig, expressPath, target) {
|
|
1516
|
+
var _this = this;
|
|
1517
|
+
//#region resolve variables
|
|
1518
|
+
//#region @websql
|
|
1519
|
+
var requestHandler = methodConfig.requestHandler &&
|
|
1520
|
+
typeof methodConfig.requestHandler === 'function'
|
|
1521
|
+
? methodConfig.requestHandler
|
|
1522
|
+
: function (req, res, next) {
|
|
1523
|
+
next();
|
|
1524
|
+
};
|
|
1525
|
+
//#endregion
|
|
1526
|
+
var url = this.uri;
|
|
1527
|
+
//#region get result
|
|
1528
|
+
var getResult = function (resolvedParams, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1529
|
+
var response, result;
|
|
1530
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1531
|
+
switch (_a.label) {
|
|
1532
|
+
case 0:
|
|
1533
|
+
response = methodConfig.descriptor.value.apply(
|
|
1534
|
+
/**
|
|
1535
|
+
* Context for method @GET,@PUT etc.
|
|
1536
|
+
*/
|
|
1537
|
+
this.getInstanceBy(target),
|
|
1538
|
+
/**
|
|
1539
|
+
* Params for metjod @GET, @PUT etc.
|
|
1540
|
+
*/
|
|
1541
|
+
resolvedParams);
|
|
1542
|
+
return [4 /*yield*/, (0, get_response_value_1.getResponseValue)(response, { req: req, res: res })];
|
|
1543
|
+
case 1:
|
|
1544
|
+
result = _a.sent();
|
|
1545
|
+
return [2 /*return*/, result];
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
}); };
|
|
1549
|
+
//#endregion
|
|
1550
|
+
url.pathname = url.pathname.replace(/\/$/, '');
|
|
1551
|
+
expressPath = url.pathname.startsWith('/')
|
|
1552
|
+
? "".concat(url.pathname).concat(expressPath)
|
|
1553
|
+
: expressPath;
|
|
1554
|
+
expressPath = expressPath.replace(/\/\//g, '/');
|
|
1555
|
+
// console.log(`BACKEND: expressPath: ${ expressPath } `)
|
|
1556
|
+
//#endregion
|
|
1557
|
+
if (tnp_core_2.Helpers.isElectron) {
|
|
1558
|
+
//#region @backend
|
|
1559
|
+
var ipcKeyName = taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath);
|
|
1560
|
+
tnp_core_2.Helpers.ipcMain.on(ipcKeyName, function (event, paramsFromBrowser) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1561
|
+
var responseJsonData;
|
|
1562
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1563
|
+
switch (_a.label) {
|
|
1564
|
+
case 0: return [4 /*yield*/, getResult(paramsFromBrowser, void 0, void 0)];
|
|
1565
|
+
case 1:
|
|
1566
|
+
responseJsonData = _a.sent();
|
|
1567
|
+
event.sender.send(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), responseJsonData);
|
|
1568
|
+
return [2 /*return*/];
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
}); });
|
|
1572
|
+
return {
|
|
1573
|
+
routePath: expressPath,
|
|
1574
|
+
method: methodConfig.type,
|
|
1575
|
+
};
|
|
1576
|
+
//#endregion
|
|
1577
|
+
}
|
|
1578
|
+
if (!this.remoteHost) {
|
|
1579
|
+
//#region apply dummy websql express routers
|
|
1580
|
+
//#region @websql
|
|
1581
|
+
if (tnp_core_2.Helpers.isWebSQL) {
|
|
1582
|
+
if (!this.expressApp[type.toLowerCase()]) {
|
|
1583
|
+
this.expressApp[type.toLowerCase()] = function () { };
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
//#endregion
|
|
1587
|
+
//#endregion
|
|
1588
|
+
//#region @backend
|
|
1589
|
+
this.logHttp && console.log("[".concat(type.toUpperCase(), "] ").concat(expressPath, " "));
|
|
1590
|
+
this.expressApp[type.toLowerCase()](expressPath, requestHandler, function (req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1591
|
+
var args, tBody, tParams, tQuery, entity, entity, resolvedParams, result, blob, file, _a, _b, img_base64, m, _c, _1, content_type, file_base64, file, error_2, err, err;
|
|
1592
|
+
return tslib_1.__generator(this, function (_d) {
|
|
1593
|
+
switch (_d.label) {
|
|
1594
|
+
case 0:
|
|
1595
|
+
args = [];
|
|
1596
|
+
tBody = req.body;
|
|
1597
|
+
tParams = req.params;
|
|
1598
|
+
tQuery = req.query;
|
|
1599
|
+
if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY]) {
|
|
1600
|
+
try {
|
|
1601
|
+
tBody = JSON.parse(JSON.stringify(tBody), JSON.parse(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY]));
|
|
1602
|
+
}
|
|
1603
|
+
catch (e) { }
|
|
1604
|
+
}
|
|
1605
|
+
if (req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]) {
|
|
1606
|
+
try {
|
|
1607
|
+
tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse(req.headers[symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]));
|
|
1608
|
+
}
|
|
1609
|
+
catch (e) { }
|
|
1610
|
+
}
|
|
1611
|
+
// make class instance from body
|
|
1612
|
+
// console.log('req.headers', req.headers)
|
|
1613
|
+
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1614
|
+
try {
|
|
1615
|
+
entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS]);
|
|
1616
|
+
tBody = ng2_rest_1.Mapping.encode(tBody, entity);
|
|
1617
|
+
}
|
|
1618
|
+
catch (e) { }
|
|
1619
|
+
}
|
|
1620
|
+
else {
|
|
1621
|
+
Object.keys(tBody).forEach(function (paramName) {
|
|
1622
|
+
try {
|
|
1623
|
+
var entityForParam = JSON.parse(req.headers["".concat(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS).concat(paramName, " ")]);
|
|
1624
|
+
tBody[paramName] = ng2_rest_1.Mapping.encode(tBody[paramName], entityForParam);
|
|
1625
|
+
}
|
|
1626
|
+
catch (e) { }
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
// make class instance from query params
|
|
1630
|
+
// console.log('req.headers', tQuery)
|
|
1631
|
+
if (req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1632
|
+
try {
|
|
1633
|
+
entity = JSON.parse(req.headers[symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]);
|
|
1634
|
+
tQuery = taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(ng2_rest_1.Mapping.encode(tQuery, entity));
|
|
1635
|
+
}
|
|
1636
|
+
catch (e) { }
|
|
1637
|
+
}
|
|
1638
|
+
else {
|
|
1639
|
+
Object.keys(tQuery).forEach(function (queryParamName) {
|
|
1640
|
+
try {
|
|
1641
|
+
var entityForParam = JSON.parse(req.headers["".concat(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS).concat(queryParamName, " ")]);
|
|
1642
|
+
var beforeTransofrm = tQuery[queryParamName];
|
|
1643
|
+
if (tnp_core_2._.isString(beforeTransofrm)) {
|
|
1644
|
+
try {
|
|
1645
|
+
var paresed = taon_helpers_1.TaonHelpers.tryTransformParam(beforeTransofrm);
|
|
1646
|
+
beforeTransofrm = paresed;
|
|
1647
|
+
}
|
|
1648
|
+
catch (e) { }
|
|
1649
|
+
}
|
|
1650
|
+
var afterEncoding = ng2_rest_1.Mapping.encode(beforeTransofrm, entityForParam);
|
|
1651
|
+
tQuery[queryParamName] =
|
|
1652
|
+
taon_helpers_1.TaonHelpers.parseJSONwithStringJSONs(afterEncoding);
|
|
1653
|
+
}
|
|
1654
|
+
catch (e) { }
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
Object.keys(methodConfig.parameters).forEach(function (paramName) {
|
|
1658
|
+
var p = methodConfig.parameters[paramName];
|
|
1659
|
+
if (p.paramType === 'Path' && tParams) {
|
|
1660
|
+
args.push(tParams[p.paramName]);
|
|
1661
|
+
}
|
|
1662
|
+
if (p.paramType === 'Query' && tQuery) {
|
|
1663
|
+
if (p.paramName) {
|
|
1664
|
+
args.push(tQuery[p.paramName]);
|
|
1665
|
+
}
|
|
1666
|
+
else {
|
|
1667
|
+
args.push(tQuery);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
if (p.paramType === 'Header' && req.headers) {
|
|
1671
|
+
args.push(req.headers[p.paramName.toLowerCase()]);
|
|
1672
|
+
}
|
|
1673
|
+
if (p.paramType === 'Cookie' && req.cookies) {
|
|
1674
|
+
args.push(req.cookies[p.paramName]);
|
|
1675
|
+
}
|
|
1676
|
+
if (p.paramType === 'Body' && tBody) {
|
|
1677
|
+
if (p.paramName && typeof tBody === 'object') {
|
|
1678
|
+
args.push(tBody[p.paramName]);
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
args.push(tBody);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
resolvedParams = args
|
|
1686
|
+
.reverse()
|
|
1687
|
+
.map(function (v) { return taon_helpers_1.TaonHelpers.tryTransformParam(v); });
|
|
1688
|
+
_d.label = 1;
|
|
1689
|
+
case 1:
|
|
1690
|
+
_d.trys.push([1, 8, , 9]);
|
|
1691
|
+
return [4 /*yield*/, getResult(resolvedParams, req, res)];
|
|
1692
|
+
case 2:
|
|
1693
|
+
result = _d.sent();
|
|
1694
|
+
if (!(result instanceof Blob &&
|
|
1695
|
+
methodConfig.responseType ===
|
|
1696
|
+
'blob')) return [3 /*break*/, 4];
|
|
1697
|
+
blob = result;
|
|
1698
|
+
_b = (_a = Buffer).from;
|
|
1699
|
+
return [4 /*yield*/, blob.arrayBuffer()];
|
|
1700
|
+
case 3:
|
|
1701
|
+
file = _b.apply(_a, [_d.sent()]);
|
|
1702
|
+
res.writeHead(200, {
|
|
1703
|
+
'Content-Type': blob.type,
|
|
1704
|
+
'Content-Length': file.length,
|
|
1705
|
+
});
|
|
1706
|
+
res.end(file);
|
|
1707
|
+
return [3 /*break*/, 7];
|
|
1708
|
+
case 4:
|
|
1709
|
+
if (!(tnp_core_2._.isString(result) &&
|
|
1710
|
+
methodConfig.responseType ===
|
|
1711
|
+
'blob')) return [3 /*break*/, 5];
|
|
1712
|
+
img_base64 = result;
|
|
1713
|
+
m = /^data:(.+?);base64,(.+)$/.exec(img_base64);
|
|
1714
|
+
if (!m) {
|
|
1715
|
+
throw new Error("[taon - framework] Not a base64 image[".concat(img_base64, "]"));
|
|
1716
|
+
}
|
|
1717
|
+
_c = tslib_1.__read(m, 3), _1 = _c[0], content_type = _c[1], file_base64 = _c[2];
|
|
1718
|
+
file = Buffer.from(file_base64, 'base64');
|
|
1719
|
+
res.writeHead(200, {
|
|
1720
|
+
'Content-Type': content_type,
|
|
1721
|
+
'Content-Length': file.length,
|
|
1722
|
+
});
|
|
1723
|
+
res.end(file);
|
|
1724
|
+
return [3 /*break*/, 7];
|
|
1725
|
+
case 5:
|
|
1726
|
+
//#region process json request
|
|
1727
|
+
return [4 /*yield*/, entity_process_1.EntityProcess.init(result, res)];
|
|
1728
|
+
case 6:
|
|
1729
|
+
//#region process json request
|
|
1730
|
+
_d.sent();
|
|
1731
|
+
_d.label = 7;
|
|
1732
|
+
case 7: return [3 /*break*/, 9];
|
|
1733
|
+
case 8:
|
|
1734
|
+
error_2 = _d.sent();
|
|
1735
|
+
//#region process error
|
|
1736
|
+
if (tnp_core_2._.isString(error_2)) {
|
|
1737
|
+
res.status(400).send(json10_1.JSON10.stringify({
|
|
1738
|
+
message: "\n Error inside: ".concat(req.path, "\n\n ").concat(error_2, "\n\n"),
|
|
1739
|
+
}));
|
|
1740
|
+
}
|
|
1741
|
+
else if (error_2 instanceof models_1.Models.Http.Errors) {
|
|
1742
|
+
tnp_core_2.Helpers.error(error_2, true, false);
|
|
1743
|
+
err = error_2;
|
|
1744
|
+
res.status(400).send(json10_1.JSON10.stringify(err));
|
|
1745
|
+
}
|
|
1746
|
+
else if (error_2 instanceof Error) {
|
|
1747
|
+
err = error_2;
|
|
1748
|
+
tnp_core_2.Helpers.error(error_2, true, false);
|
|
1749
|
+
res.status(400).send(json10_1.JSON10.stringify({
|
|
1750
|
+
stack: err.stack,
|
|
1751
|
+
message: err.message,
|
|
1752
|
+
}));
|
|
1753
|
+
}
|
|
1754
|
+
else {
|
|
1755
|
+
tnp_core_2.Helpers.log(error_2);
|
|
1756
|
+
tnp_core_2.Helpers.error("[Taon] Bad result isomorphic method: ".concat(error_2, " "), true, false);
|
|
1757
|
+
res.status(400).send(json10_1.JSON10.stringify(error_2));
|
|
1758
|
+
}
|
|
1759
|
+
return [3 /*break*/, 9];
|
|
1760
|
+
case 9: return [2 /*return*/];
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
}); });
|
|
1764
|
+
//#endregion
|
|
1765
|
+
}
|
|
1766
|
+
return {
|
|
1767
|
+
routePath: expressPath,
|
|
1768
|
+
method: methodConfig.type,
|
|
1769
|
+
};
|
|
1770
|
+
};
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region methods & getters / init client
|
|
1773
|
+
/**
|
|
1774
|
+
* client can be browser or nodejs (when remote host)
|
|
1775
|
+
*/
|
|
1776
|
+
EndpointContext.prototype.initClient = function (
|
|
1777
|
+
//#region parameters
|
|
1778
|
+
target, type, methodConfig, expressPath) {
|
|
1779
|
+
var ctx = this;
|
|
1780
|
+
// : { received: any; /* Rest<any, any> */ }
|
|
1781
|
+
this.logHttp && console.log("".concat(type === null || type === void 0 ? void 0 : type.toUpperCase(), " ").concat(expressPath, " "));
|
|
1782
|
+
// console.log('INITING', methodConfig); // @LAST inject in static
|
|
1783
|
+
//#region resolve storage
|
|
1784
|
+
var storage;
|
|
1785
|
+
if (tnp_core_2.Helpers.isBrowser) {
|
|
1786
|
+
storage = window;
|
|
1787
|
+
}
|
|
1788
|
+
//#region @backend
|
|
1789
|
+
if (tnp_core_2.Helpers.isNode) {
|
|
1790
|
+
storage = global;
|
|
1791
|
+
}
|
|
1792
|
+
//#endregion
|
|
1793
|
+
//#endregion
|
|
1794
|
+
var orgMethods = target.prototype[methodConfig.methodName];
|
|
1795
|
+
//#region handle electron ipc request
|
|
1796
|
+
if (tnp_core_2.Helpers.isElectron) {
|
|
1797
|
+
target.prototype[methodConfig.methodName] = function () {
|
|
1798
|
+
var _this = this;
|
|
1799
|
+
var args = [];
|
|
1800
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1801
|
+
args[_i] = arguments[_i];
|
|
1802
|
+
}
|
|
1803
|
+
var received = new Promise(function (resolve, reject) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
1804
|
+
var headers, _a, request, response;
|
|
1805
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1806
|
+
headers = {};
|
|
1807
|
+
_a = taon_helpers_1.TaonHelpers.websqlMocks(headers), request = _a.request, response = _a.response;
|
|
1808
|
+
tnp_core_2.Helpers.ipcRenderer.once(taon_helpers_1.TaonHelpers.ipcKeyNameResponse(target, methodConfig, expressPath), function (event, responseData) {
|
|
1809
|
+
var res = responseData;
|
|
1810
|
+
console.log({ responseData: responseData });
|
|
1811
|
+
try {
|
|
1812
|
+
var body_1 = res;
|
|
1813
|
+
res = new ng2_rest_1.Models.HttpResponse({
|
|
1814
|
+
body: void 0,
|
|
1815
|
+
isArray: void 0,
|
|
1816
|
+
method: methodConfig.type,
|
|
1817
|
+
url: "".concat(ctx.uri.origin).concat('' // TODO express path
|
|
1818
|
+
).concat(methodConfig.path, " "),
|
|
1819
|
+
}, tnp_core_2.Helpers.isBlob(body_1) || tnp_core_2._.isString(body_1)
|
|
1820
|
+
? body_1
|
|
1821
|
+
: JSON.stringify(body_1), ng2_rest_1.RestHeaders.from(headers), void 0, function () { return body_1; });
|
|
1822
|
+
resolve(res);
|
|
1823
|
+
}
|
|
1824
|
+
catch (error) {
|
|
1825
|
+
console.error(error);
|
|
1826
|
+
reject(error);
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
tnp_core_2.Helpers.ipcRenderer.send(taon_helpers_1.TaonHelpers.ipcKeyNameRequest(target, methodConfig, expressPath), args);
|
|
1830
|
+
return [2 /*return*/];
|
|
1831
|
+
});
|
|
1832
|
+
}); });
|
|
1833
|
+
received['observable'] = (0, rxjs_1.from)(received);
|
|
1834
|
+
return {
|
|
1835
|
+
received: received,
|
|
1836
|
+
};
|
|
1837
|
+
};
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
//#endregion
|
|
1841
|
+
//#region handling web sql request
|
|
1842
|
+
/* */
|
|
1843
|
+
/* */
|
|
1844
|
+
/* */
|
|
1845
|
+
/* */
|
|
1846
|
+
/* */
|
|
1847
|
+
/* */
|
|
1848
|
+
/* */
|
|
1849
|
+
/* */
|
|
1850
|
+
/* */
|
|
1851
|
+
/* */
|
|
1852
|
+
/* */
|
|
1853
|
+
/* */
|
|
1854
|
+
/* */
|
|
1855
|
+
/* */
|
|
1856
|
+
/* */
|
|
1857
|
+
/* */
|
|
1858
|
+
/* */
|
|
1859
|
+
/* */
|
|
1860
|
+
/* */
|
|
1861
|
+
/* */
|
|
1862
|
+
/* */
|
|
1863
|
+
/* */
|
|
1864
|
+
/* */
|
|
1865
|
+
/* */
|
|
1866
|
+
/* */
|
|
1867
|
+
/* */
|
|
1868
|
+
/* */
|
|
1869
|
+
/* */
|
|
1870
|
+
/* */
|
|
1871
|
+
/* */
|
|
1872
|
+
/* */
|
|
1873
|
+
/* */
|
|
1874
|
+
/* */
|
|
1875
|
+
/* */
|
|
1876
|
+
/* */
|
|
1877
|
+
/* */
|
|
1878
|
+
/* */
|
|
1879
|
+
/* */
|
|
1880
|
+
/* */
|
|
1881
|
+
/* */
|
|
1882
|
+
/* */
|
|
1883
|
+
/* */
|
|
1884
|
+
/* */
|
|
1885
|
+
/* */
|
|
1886
|
+
/* */
|
|
1887
|
+
/* */
|
|
1888
|
+
/* */
|
|
1889
|
+
/* */
|
|
1890
|
+
/* */
|
|
1891
|
+
/* */
|
|
1892
|
+
/* */
|
|
1893
|
+
/* */
|
|
1894
|
+
/* */
|
|
1895
|
+
/* */
|
|
1896
|
+
/* */
|
|
1897
|
+
/* */
|
|
1898
|
+
/* */
|
|
1899
|
+
/* */
|
|
1900
|
+
/* */
|
|
1901
|
+
/* */
|
|
1902
|
+
/* */
|
|
1903
|
+
/* */
|
|
1904
|
+
/* */
|
|
1905
|
+
/* */
|
|
1906
|
+
/* */
|
|
1907
|
+
/* */
|
|
1908
|
+
/* */
|
|
1909
|
+
/* */
|
|
1910
|
+
/* */
|
|
1911
|
+
/* */
|
|
1912
|
+
/* */
|
|
1913
|
+
/* */
|
|
1914
|
+
/* */
|
|
1915
|
+
/* */
|
|
1916
|
+
/* */
|
|
1917
|
+
/* */
|
|
1918
|
+
/* */
|
|
1919
|
+
/* */
|
|
1920
|
+
/* */
|
|
1921
|
+
/* */
|
|
1922
|
+
/* */
|
|
1923
|
+
/* */
|
|
1924
|
+
/* */
|
|
1925
|
+
/* */
|
|
1926
|
+
/* */
|
|
1927
|
+
/* */
|
|
1928
|
+
/* */
|
|
1929
|
+
/* */
|
|
1930
|
+
/* */
|
|
1931
|
+
/* */
|
|
1932
|
+
/* */
|
|
1933
|
+
/* */
|
|
1934
|
+
/* */
|
|
1935
|
+
/* */
|
|
1936
|
+
/* */
|
|
1937
|
+
/* */
|
|
1938
|
+
/* */
|
|
1939
|
+
/* */
|
|
1940
|
+
/* */
|
|
1941
|
+
/* */
|
|
1942
|
+
/* */
|
|
1943
|
+
/* */
|
|
1944
|
+
/* */
|
|
1945
|
+
/* */
|
|
1946
|
+
/* */
|
|
1947
|
+
/* */
|
|
1948
|
+
/* */
|
|
1949
|
+
/* */
|
|
1950
|
+
/* */
|
|
1951
|
+
/* */
|
|
1952
|
+
/* */
|
|
1953
|
+
/* */
|
|
1954
|
+
/* */
|
|
1955
|
+
/* */
|
|
1956
|
+
/* */
|
|
1957
|
+
/* */
|
|
1958
|
+
/* */
|
|
1959
|
+
/* */
|
|
1960
|
+
/* */
|
|
1961
|
+
/* */
|
|
1962
|
+
/* */
|
|
1963
|
+
/* */
|
|
1964
|
+
/* */
|
|
1965
|
+
/* */
|
|
1966
|
+
/* */
|
|
1967
|
+
/* */
|
|
1968
|
+
/* */
|
|
1969
|
+
/* */
|
|
1970
|
+
/* */
|
|
1971
|
+
/* */
|
|
1972
|
+
/* */
|
|
1973
|
+
/* */
|
|
1974
|
+
/* */
|
|
1975
|
+
/* */
|
|
1976
|
+
/* */
|
|
1977
|
+
/* */
|
|
1978
|
+
/* */
|
|
1979
|
+
/* */
|
|
1980
|
+
/* */
|
|
1981
|
+
/* */
|
|
1982
|
+
/* */
|
|
1983
|
+
/* */
|
|
1984
|
+
//#endregion
|
|
1985
|
+
//#region handl normal request
|
|
1986
|
+
target.prototype[methodConfig.methodName] = function () {
|
|
1987
|
+
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
1988
|
+
// const productionMode = FrameworkContext.isProductionMode;
|
|
1989
|
+
var args = [];
|
|
1990
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1991
|
+
args[_i] = arguments[_i];
|
|
1992
|
+
}
|
|
1993
|
+
//#region resolve frontend parameters
|
|
1994
|
+
if (!storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG])
|
|
1995
|
+
storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG] = {};
|
|
1996
|
+
if (!storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG][ctx.uri.href])
|
|
1997
|
+
storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG][ctx.uri.href] = {};
|
|
1998
|
+
var endpoints = storage[symbols_1.Symbols.old.ENDPOINT_META_CONFIG];
|
|
1999
|
+
var rest;
|
|
2000
|
+
if (!endpoints[ctx.uri.href][expressPath]) {
|
|
2001
|
+
var headers = {};
|
|
2002
|
+
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
2003
|
+
rest = ng2_rest_1.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, ng2_rest_1.RestHeaders.from({
|
|
2004
|
+
'Content-Type': methodConfig.contentType,
|
|
2005
|
+
Accept: methodConfig.contentType,
|
|
2006
|
+
}));
|
|
2007
|
+
}
|
|
2008
|
+
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
2009
|
+
rest = ng2_rest_1.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, ng2_rest_1.RestHeaders.from({
|
|
2010
|
+
'Content-Type': methodConfig.contentType,
|
|
2011
|
+
Accept: methodConfig.contentType,
|
|
2012
|
+
responsetypeaxios: methodConfig.responseType,
|
|
2013
|
+
}));
|
|
2014
|
+
}
|
|
2015
|
+
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
2016
|
+
rest = ng2_rest_1.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, ng2_rest_1.RestHeaders.from({
|
|
2017
|
+
responsetypeaxios: methodConfig.responseType,
|
|
2018
|
+
}));
|
|
2019
|
+
}
|
|
2020
|
+
else {
|
|
2021
|
+
rest = ng2_rest_1.Resource.create(ctx.uri.href, expressPath, symbols_1.Symbols.old.MAPPING_CONFIG_HEADER, symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
2022
|
+
}
|
|
2023
|
+
endpoints[ctx.uri.href][expressPath] = rest;
|
|
2024
|
+
}
|
|
2025
|
+
else {
|
|
2026
|
+
rest = endpoints[ctx.uri.href][expressPath];
|
|
2027
|
+
}
|
|
2028
|
+
var method = type.toLowerCase();
|
|
2029
|
+
var isWithBody = method === 'put' || method === 'post';
|
|
2030
|
+
var pathPrams = {};
|
|
2031
|
+
var queryParams = {};
|
|
2032
|
+
var bodyObject = {};
|
|
2033
|
+
args.forEach(function (param, i) {
|
|
2034
|
+
var currentParam = void 0;
|
|
2035
|
+
for (var pp in methodConfig.parameters) {
|
|
2036
|
+
var v = methodConfig.parameters[pp];
|
|
2037
|
+
if (v.index === i) {
|
|
2038
|
+
currentParam = v;
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
if (currentParam.paramType === 'Path') {
|
|
2043
|
+
pathPrams[currentParam.paramName] = param;
|
|
2044
|
+
}
|
|
2045
|
+
if (currentParam.paramType === 'Query') {
|
|
2046
|
+
if (currentParam.paramName) {
|
|
2047
|
+
var mapping = ng2_rest_1.Mapping.decode(param, !ctx.isProductionMode);
|
|
2048
|
+
if (mapping) {
|
|
2049
|
+
rest.headers.set("".concat(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS).concat(currentParam.paramName, " "), JSON.stringify(mapping));
|
|
2050
|
+
}
|
|
2051
|
+
queryParams[currentParam.paramName] = param;
|
|
2052
|
+
}
|
|
2053
|
+
else {
|
|
2054
|
+
var mapping = ng2_rest_1.Mapping.decode(param, !ctx.isProductionMode);
|
|
2055
|
+
if (mapping) {
|
|
2056
|
+
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2057
|
+
}
|
|
2058
|
+
queryParams = tnp_core_2._.cloneDeep(param);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
if (currentParam.paramType === 'Header') {
|
|
2062
|
+
if (currentParam.paramName) {
|
|
2063
|
+
if (currentParam.paramName === symbols_1.Symbols.old.MDC_KEY) {
|
|
2064
|
+
// parese MDC
|
|
2065
|
+
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
2066
|
+
}
|
|
2067
|
+
else {
|
|
2068
|
+
rest.headers.set(currentParam.paramName, param);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
else {
|
|
2072
|
+
for (var header in param) {
|
|
2073
|
+
rest.headers.set(header, param[header]);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
if (currentParam.paramType === 'Cookie') {
|
|
2078
|
+
ng2_rest_1.Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
2079
|
+
}
|
|
2080
|
+
if (currentParam.paramType === 'Body') {
|
|
2081
|
+
if (currentParam.paramName) {
|
|
2082
|
+
if (class_helpers_1.ClassHelpers.getName(bodyObject) === 'FormData') {
|
|
2083
|
+
throw new Error("[taon - framework] Don use param names when posting / putting FormData.\n Use this:\n// ...\n(@Taon.Http.Param.Body() formData: FormData) ...\n// ...\n\ninstead\n // ...\n (@Taon.Http.Param.Body('".concat(currentParam.paramName, "') formData: FormData) ...\n// ...\n"));
|
|
2084
|
+
}
|
|
2085
|
+
var mapping = ng2_rest_1.Mapping.decode(param, !ctx.isProductionMode);
|
|
2086
|
+
if (mapping) {
|
|
2087
|
+
rest.headers.set("".concat(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS).concat(currentParam.paramName, " "), JSON.stringify(mapping));
|
|
2088
|
+
}
|
|
2089
|
+
bodyObject[currentParam.paramName] = param;
|
|
2090
|
+
}
|
|
2091
|
+
else {
|
|
2092
|
+
var mapping = ng2_rest_1.Mapping.decode(param, !ctx.isProductionMode);
|
|
2093
|
+
if (mapping) {
|
|
2094
|
+
rest.headers.set(symbols_1.Symbols.old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
2095
|
+
}
|
|
2096
|
+
bodyObject = param;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
if (typeof bodyObject === 'object' &&
|
|
2101
|
+
class_helpers_1.ClassHelpers.getName(bodyObject) !== 'FormData') {
|
|
2102
|
+
var circuralFromItem_1 = [];
|
|
2103
|
+
bodyObject = json10_1.JSON10.parse(json10_1.JSON10.stringify(bodyObject, void 0, void 0, function (circs) {
|
|
2104
|
+
circuralFromItem_1 = circs;
|
|
2105
|
+
}));
|
|
2106
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_BODY, json10_1.JSON10.stringify(circuralFromItem_1));
|
|
2107
|
+
}
|
|
2108
|
+
if (typeof queryParams === 'object') {
|
|
2109
|
+
var circuralFromQueryParams_1 = [];
|
|
2110
|
+
queryParams = json10_1.JSON10.parse(json10_1.JSON10.stringify(queryParams, void 0, void 0, function (circs) {
|
|
2111
|
+
circuralFromQueryParams_1 = circs;
|
|
2112
|
+
}));
|
|
2113
|
+
rest.headers.set(symbols_1.Symbols.old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, json10_1.JSON10.stringify(circuralFromQueryParams_1));
|
|
2114
|
+
}
|
|
2115
|
+
//#endregion
|
|
2116
|
+
var httpResultObj = {
|
|
2117
|
+
received: isWithBody
|
|
2118
|
+
? rest.model(pathPrams)[method](bodyObject, [queryParams])
|
|
2119
|
+
: rest.model(pathPrams)[method]([queryParams]),
|
|
2120
|
+
};
|
|
2121
|
+
return httpResultObj;
|
|
2122
|
+
};
|
|
2123
|
+
//#endregion
|
|
2124
|
+
};
|
|
2125
|
+
return EndpointContext;
|
|
2126
|
+
}());
|
|
2127
|
+
exports.EndpointContext = EndpointContext;
|
|
2128
|
+
//# sourceMappingURL=endpoint-context.js.map
|