taon 21.0.44 → 21.0.48
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/bin/start.js +8 -211
- package/bin/taon +1 -2
- package/bin/taon-debug +1 -1
- package/bin/taon-debug-brk +1 -2
- package/browser/package.json +1 -1
- package/browser/types/taon-browser.d.ts +3 -3
- package/browser-prod/package.json +1 -1
- package/browser-prod/types/taon-browser.d.ts +3 -3
- package/cli.js +3 -0
- package/cli.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/taon-admin-mode-configuration/index.js +2 -2
- package/lib-prod/base-classes/base-abstract-entity.ts +34 -0
- package/lib-prod/base-classes/base-angular-service.ts +107 -0
- package/lib-prod/base-classes/base-class.ts +46 -0
- package/lib-prod/base-classes/base-context.ts +21 -0
- package/lib-prod/base-classes/base-controller.ts +240 -0
- package/lib-prod/base-classes/base-crud-controller.ts +298 -0
- package/lib-prod/base-classes/base-custom-repository.ts +10 -0
- package/lib-prod/base-classes/{base-electron-service.js → base-electron-service.ts} +12 -2
- package/lib-prod/base-classes/base-entity.ts +28 -0
- package/lib-prod/base-classes/base-file-upload.middleware.ts +92 -0
- package/lib-prod/base-classes/base-injector.ts +278 -0
- package/lib-prod/base-classes/base-middleware.ts +71 -0
- package/lib-prod/base-classes/base-migration.ts +26 -0
- package/lib-prod/base-classes/{base-provider.d.ts → base-provider.ts} +2 -2
- package/lib-prod/base-classes/base-repository.ts +942 -0
- package/lib-prod/base-classes/base-subscriber-for-entity.ts +196 -0
- package/lib-prod/base-classes/{base.js → base.ts} +15 -4
- package/lib-prod/{build-info._auto-generated_.d.ts → build-info._auto-generated_.ts} +9 -6
- package/lib-prod/config/controller-config.ts +58 -0
- package/lib-prod/config/controller-options.ts +19 -0
- package/lib-prod/config/method-config.ts +55 -0
- package/lib-prod/config/param-config.ts +16 -0
- package/lib-prod/constants.ts +63 -0
- package/lib-prod/context-db-migrations.ts +488 -0
- package/lib-prod/create-context.ts +345 -0
- package/lib-prod/decorators/classes/controller-decorator.ts +25 -0
- package/lib-prod/decorators/classes/entity-decorator.ts +57 -0
- package/lib-prod/decorators/classes/middleware-decorator.ts +29 -0
- package/lib-prod/decorators/classes/migration-decorator.ts +27 -0
- package/lib-prod/decorators/classes/provider-decorator.ts +28 -0
- package/lib-prod/decorators/classes/repository-decorator.ts +26 -0
- package/lib-prod/decorators/classes/subscriber-decorator.ts +28 -0
- package/lib-prod/decorators/decorator-abstract-opt.ts +4 -0
- package/lib-prod/decorators/http/http-decorators.ts +26 -0
- package/lib-prod/decorators/http/http-methods-decorators.ts +275 -0
- package/lib-prod/decorators/http/http-params-decorators.ts +105 -0
- package/lib-prod/dependency-injection/di-container.ts +39 -0
- package/lib-prod/endpoint-context-storage.ts +47 -0
- package/lib-prod/endpoint-context.ts +3100 -0
- package/lib-prod/entity-process.ts +283 -0
- package/lib-prod/env/env.angular-node-app.ts +66 -0
- package/lib-prod/env/env.docs-webapp.ts +66 -0
- package/lib-prod/env/env.electron-app.ts +66 -0
- package/lib-prod/env/env.mobile-app.ts +66 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.ts +66 -0
- package/lib-prod/env/env.vscode-plugin.ts +66 -0
- package/lib-prod/express-types.ts +4 -0
- package/lib-prod/formly/formly.models.ts +7 -0
- package/lib-prod/formly/fromly.ts +261 -0
- package/lib-prod/formly/type-from-entity.ts +80 -0
- package/lib-prod/get-response-value.ts +30 -0
- package/lib-prod/global-state/taon-global-state/{index.d.ts → index.ts} +2 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.ts +21 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.ts +9 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.ts +44 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.ts +40 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.ts +12 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.ts +48 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.ts +16 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.ts +47 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.ts +18 -0
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.ts +21 -0
- package/lib-prod/global-state/taon-transaction-registry/{index.d.ts → index.ts} +2 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.ts +23 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.ts +7 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.ts +38 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.ts +54 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.ts +12 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.ts +6 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.ts +16 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.ts +29 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.ts +20 -0
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.ts +9 -0
- package/lib-prod/helpers/class-helpers.ts +315 -0
- package/lib-prod/helpers/clone-obj.ts +24 -0
- package/lib-prod/helpers/taon-helpers.ts +181 -0
- package/lib-prod/{index._auto-generated_.js → index._auto-generated_.ts} +0 -1
- package/lib-prod/index.ts +323 -0
- package/lib-prod/{inject.js → inject.ts} +57 -40
- package/lib-prod/lib-info.md +8 -0
- package/lib-prod/migrations/index.ts +2 -0
- package/lib-prod/migrations/migrations-info.md +6 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.js → migrations_index._auto-generated_.ts} +2 -1
- package/lib-prod/models.ts +427 -0
- package/lib-prod/orm/columns.ts +121 -0
- package/lib-prod/orm/index.ts +62 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/realtime/realtime-client.ts +288 -0
- package/lib-prod/realtime/realtime-core.ts +134 -0
- package/lib-prod/realtime/realtime-server.ts +398 -0
- package/lib-prod/realtime/realtime-strategy/{index.d.ts → index.ts} +1 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.ts +344 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.ts +349 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.ts +30 -0
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.ts +21 -0
- package/lib-prod/realtime/realtime-subs-manager.ts +127 -0
- package/lib-prod/realtime/{realtime.models.d.ts → realtime.models.ts} +13 -5
- package/lib-prod/symbols.ts +136 -0
- package/lib-prod/ui/index.ts +1 -0
- package/lib-prod/ui/taon-admin-mode-configuration/index.ts +1 -0
- package/lib-prod/validators.ts +103 -0
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql/types/taon-websql.d.ts +3 -3
- package/websql-prod/package.json +1 -1
- package/websql-prod/types/taon-websql.d.ts +3 -3
- package/lib-prod/base-classes/base-abstract-entity.d.ts +0 -7
- package/lib-prod/base-classes/base-abstract-entity.js +0 -42
- package/lib-prod/base-classes/base-abstract-entity.js.map +0 -1
- package/lib-prod/base-classes/base-angular-service.d.ts +0 -27
- package/lib-prod/base-classes/base-angular-service.js +0 -89
- package/lib-prod/base-classes/base-angular-service.js.map +0 -1
- package/lib-prod/base-classes/base-class.d.ts +0 -15
- package/lib-prod/base-classes/base-class.js +0 -40
- package/lib-prod/base-classes/base-class.js.map +0 -1
- package/lib-prod/base-classes/base-context.d.ts +0 -20
- package/lib-prod/base-classes/base-context.js +0 -23
- package/lib-prod/base-classes/base-context.js.map +0 -1
- package/lib-prod/base-classes/base-controller.d.ts +0 -84
- package/lib-prod/base-classes/base-controller.js +0 -173
- package/lib-prod/base-classes/base-controller.js.map +0 -1
- package/lib-prod/base-classes/base-crud-controller.d.ts +0 -28
- package/lib-prod/base-classes/base-crud-controller.js +0 -318
- package/lib-prod/base-classes/base-crud-controller.js.map +0 -1
- package/lib-prod/base-classes/base-custom-repository.d.ts +0 -3
- package/lib-prod/base-classes/base-custom-repository.js +0 -19
- package/lib-prod/base-classes/base-custom-repository.js.map +0 -1
- package/lib-prod/base-classes/base-electron-service.d.ts +0 -0
- package/lib-prod/base-classes/base-electron-service.js.map +0 -1
- package/lib-prod/base-classes/base-entity.d.ts +0 -16
- package/lib-prod/base-classes/base-entity.js +0 -32
- package/lib-prod/base-classes/base-entity.js.map +0 -1
- package/lib-prod/base-classes/base-file-upload.middleware.d.ts +0 -14
- package/lib-prod/base-classes/base-file-upload.middleware.js +0 -85
- package/lib-prod/base-classes/base-file-upload.middleware.js.map +0 -1
- package/lib-prod/base-classes/base-injector.d.ts +0 -67
- package/lib-prod/base-classes/base-injector.js +0 -198
- package/lib-prod/base-classes/base-injector.js.map +0 -1
- package/lib-prod/base-classes/base-middleware.d.ts +0 -38
- package/lib-prod/base-classes/base-middleware.js +0 -14
- package/lib-prod/base-classes/base-middleware.js.map +0 -1
- package/lib-prod/base-classes/base-migration.d.ts +0 -11
- package/lib-prod/base-classes/base-migration.js +0 -25
- package/lib-prod/base-classes/base-migration.js.map +0 -1
- package/lib-prod/base-classes/base-provider.js +0 -13
- package/lib-prod/base-classes/base-provider.js.map +0 -1
- package/lib-prod/base-classes/base-repository.d.ts +0 -272
- package/lib-prod/base-classes/base-repository.js +0 -634
- package/lib-prod/base-classes/base-repository.js.map +0 -1
- package/lib-prod/base-classes/base-subscriber-for-entity.d.ts +0 -81
- package/lib-prod/base-classes/base-subscriber-for-entity.js +0 -155
- package/lib-prod/base-classes/base-subscriber-for-entity.js.map +0 -1
- package/lib-prod/base-classes/base.d.ts +0 -1
- package/lib-prod/base-classes/base.js.map +0 -1
- package/lib-prod/build-info._auto-generated_.js +0 -30
- package/lib-prod/build-info._auto-generated_.js.map +0 -1
- package/lib-prod/config/controller-config.d.ts +0 -21
- package/lib-prod/config/controller-config.js +0 -34
- package/lib-prod/config/controller-config.js.map +0 -1
- package/lib-prod/config/controller-options.d.ts +0 -16
- package/lib-prod/config/controller-options.js +0 -8
- package/lib-prod/config/controller-options.js.map +0 -1
- package/lib-prod/config/method-config.d.ts +0 -39
- package/lib-prod/config/method-config.js +0 -12
- package/lib-prod/config/method-config.js.map +0 -1
- package/lib-prod/config/param-config.d.ts +0 -8
- package/lib-prod/config/param-config.js +0 -8
- package/lib-prod/config/param-config.js.map +0 -1
- package/lib-prod/constants.d.ts +0 -9
- package/lib-prod/constants.js +0 -32
- package/lib-prod/constants.js.map +0 -1
- package/lib-prod/context-db-migrations.d.ts +0 -17
- package/lib-prod/context-db-migrations.js +0 -349
- package/lib-prod/context-db-migrations.js.map +0 -1
- package/lib-prod/create-context.d.ts +0 -78
- package/lib-prod/create-context.js +0 -223
- package/lib-prod/create-context.js.map +0 -1
- package/lib-prod/decorators/classes/controller-decorator.d.ts +0 -5
- package/lib-prod/decorators/classes/controller-decorator.js +0 -21
- package/lib-prod/decorators/classes/controller-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/entity-decorator.d.ts +0 -19
- package/lib-prod/decorators/classes/entity-decorator.js +0 -43
- package/lib-prod/decorators/classes/entity-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/middleware-decorator.d.ts +0 -8
- package/lib-prod/decorators/classes/middleware-decorator.js +0 -22
- package/lib-prod/decorators/classes/middleware-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/migration-decorator.d.ts +0 -7
- package/lib-prod/decorators/classes/migration-decorator.js +0 -21
- package/lib-prod/decorators/classes/migration-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/provider-decorator.d.ts +0 -7
- package/lib-prod/decorators/classes/provider-decorator.js +0 -21
- package/lib-prod/decorators/classes/provider-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/repository-decorator.d.ts +0 -7
- package/lib-prod/decorators/classes/repository-decorator.js +0 -21
- package/lib-prod/decorators/classes/repository-decorator.js.map +0 -1
- package/lib-prod/decorators/classes/subscriber-decorator.d.ts +0 -8
- package/lib-prod/decorators/classes/subscriber-decorator.js +0 -22
- package/lib-prod/decorators/classes/subscriber-decorator.js.map +0 -1
- package/lib-prod/decorators/decorator-abstract-opt.d.ts +0 -3
- package/lib-prod/decorators/decorator-abstract-opt.js +0 -7
- package/lib-prod/decorators/decorator-abstract-opt.js.map +0 -1
- package/lib-prod/decorators/http/http-decorators.d.ts +0 -3
- package/lib-prod/decorators/http/http-decorators.js +0 -24
- package/lib-prod/decorators/http/http-decorators.js.map +0 -1
- package/lib-prod/decorators/http/http-methods-decorators.d.ts +0 -70
- package/lib-prod/decorators/http/http-methods-decorators.js +0 -112
- package/lib-prod/decorators/http/http-methods-decorators.js.map +0 -1
- package/lib-prod/decorators/http/http-params-decorators.d.ts +0 -8
- package/lib-prod/decorators/http/http-params-decorators.js +0 -50
- package/lib-prod/decorators/http/http-params-decorators.js.map +0 -1
- package/lib-prod/dependency-injection/di-container.d.ts +0 -5
- package/lib-prod/dependency-injection/di-container.js +0 -35
- package/lib-prod/dependency-injection/di-container.js.map +0 -1
- package/lib-prod/endpoint-context-storage.d.ts +0 -11
- package/lib-prod/endpoint-context-storage.js +0 -38
- package/lib-prod/endpoint-context-storage.js.map +0 -1
- package/lib-prod/endpoint-context.d.ts +0 -197
- package/lib-prod/endpoint-context.js +0 -2416
- package/lib-prod/endpoint-context.js.map +0 -1
- package/lib-prod/entity-process.d.ts +0 -39
- package/lib-prod/entity-process.js +0 -242
- package/lib-prod/entity-process.js.map +0 -1
- package/lib-prod/env/env.angular-node-app.d.ts +0 -64
- package/lib-prod/env/env.angular-node-app.js +0 -71
- package/lib-prod/env/env.angular-node-app.js.map +0 -1
- package/lib-prod/env/env.docs-webapp.d.ts +0 -64
- package/lib-prod/env/env.docs-webapp.js +0 -71
- package/lib-prod/env/env.docs-webapp.js.map +0 -1
- package/lib-prod/env/env.electron-app.d.ts +0 -64
- package/lib-prod/env/env.electron-app.js +0 -71
- package/lib-prod/env/env.electron-app.js.map +0 -1
- package/lib-prod/env/env.mobile-app.d.ts +0 -64
- package/lib-prod/env/env.mobile-app.js +0 -71
- package/lib-prod/env/env.mobile-app.js.map +0 -1
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +0 -64
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +0 -71
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +0 -1
- package/lib-prod/env/env.vscode-plugin.d.ts +0 -64
- package/lib-prod/env/env.vscode-plugin.js +0 -71
- package/lib-prod/env/env.vscode-plugin.js.map +0 -1
- package/lib-prod/env/index.js +0 -23
- package/lib-prod/env/index.js.map +0 -1
- package/lib-prod/express-types.d.ts +0 -1
- package/lib-prod/express-types.js +0 -3
- package/lib-prod/express-types.js.map +0 -1
- package/lib-prod/formly/formly.models.d.ts +0 -1
- package/lib-prod/formly/formly.models.js +0 -3
- package/lib-prod/formly/formly.models.js.map +0 -1
- package/lib-prod/formly/fromly.d.ts +0 -16
- package/lib-prod/formly/fromly.js +0 -209
- package/lib-prod/formly/fromly.js.map +0 -1
- package/lib-prod/formly/type-from-entity.d.ts +0 -20
- package/lib-prod/formly/type-from-entity.js +0 -60
- package/lib-prod/formly/type-from-entity.js.map +0 -1
- package/lib-prod/get-response-value.d.ts +0 -6
- package/lib-prod/get-response-value.js +0 -27
- package/lib-prod/get-response-value.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/index.js +0 -23
- package/lib-prod/global-state/taon-global-state/index.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.d.ts +0 -19
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js +0 -23
- package/lib-prod/global-state/taon-global-state/taon-global-state.abstract.context.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.d.ts +0 -2
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js +0 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.constants.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.d.ts +0 -11
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js +0 -61
- package/lib-prod/global-state/taon-global-state/taon-global-state.controller.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.d.ts +0 -7
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js +0 -64
- package/lib-prod/global-state/taon-global-state/taon-global-state.entity.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.d.ts +0 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js +0 -22
- package/lib-prod/global-state/taon-global-state/taon-global-state.middleware.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.d.ts +0 -28
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js +0 -48
- package/lib-prod/global-state/taon-global-state/taon-global-state.models.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.d.ts +0 -3
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js +0 -22
- package/lib-prod/global-state/taon-global-state/taon-global-state.provider.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.d.ts +0 -9
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js +0 -53
- package/lib-prod/global-state/taon-global-state/taon-global-state.repository.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.d.ts +0 -7
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js +0 -29
- package/lib-prod/global-state/taon-global-state/taon-global-state.subscriber.js.map +0 -1
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.d.ts +0 -2
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js +0 -16
- package/lib-prod/global-state/taon-global-state/taon-global-state.utils.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/index.js +0 -28
- package/lib-prod/global-state/taon-transaction-registry/index.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.d.ts +0 -19
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js +0 -25
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.abstract.context.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.d.ts +0 -2
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js +0 -9
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.constants.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.d.ts +0 -9
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js +0 -51
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.controller.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.d.ts +0 -12
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js +0 -77
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.entity.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.d.ts +0 -3
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js +0 -22
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.middleware.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.d.ts +0 -6
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js +0 -11
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.models.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.d.ts +0 -3
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js +0 -22
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.provider.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.d.ts +0 -9
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js +0 -38
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.repository.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.d.ts +0 -7
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js +0 -29
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.subscriber.js.map +0 -1
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.d.ts +0 -2
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js +0 -9
- package/lib-prod/global-state/taon-transaction-registry/taon-transaction-registry.utils.js.map +0 -1
- package/lib-prod/helpers/class-helpers.d.ts +0 -22
- package/lib-prod/helpers/class-helpers.js +0 -246
- package/lib-prod/helpers/class-helpers.js.map +0 -1
- package/lib-prod/helpers/clone-obj.d.ts +0 -1
- package/lib-prod/helpers/clone-obj.js +0 -22
- package/lib-prod/helpers/clone-obj.js.map +0 -1
- package/lib-prod/helpers/taon-helpers.d.ts +0 -16
- package/lib-prod/helpers/taon-helpers.js +0 -162
- package/lib-prod/helpers/taon-helpers.js.map +0 -1
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js.map +0 -1
- package/lib-prod/index.d.ts +0 -230
- package/lib-prod/index.js +0 -273
- package/lib-prod/index.js.map +0 -1
- package/lib-prod/inject.d.ts +0 -4
- package/lib-prod/inject.js.map +0 -1
- package/lib-prod/migrations/index.d.ts +0 -1
- package/lib-prod/migrations/index.js +0 -19
- package/lib-prod/migrations/index.js.map +0 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.d.ts +0 -0
- package/lib-prod/migrations/migrations_index._auto-generated_.js.map +0 -1
- package/lib-prod/models.d.ts +0 -255
- package/lib-prod/models.js +0 -117
- package/lib-prod/models.js.map +0 -1
- package/lib-prod/orm/columns.d.ts +0 -32
- package/lib-prod/orm/columns.js +0 -112
- package/lib-prod/orm/columns.js.map +0 -1
- package/lib-prod/orm/index.d.ts +0 -1
- package/lib-prod/orm/index.js +0 -73
- package/lib-prod/orm/index.js.map +0 -1
- package/lib-prod/realtime/realtime-client.d.ts +0 -41
- package/lib-prod/realtime/realtime-client.js +0 -204
- package/lib-prod/realtime/realtime-client.js.map +0 -1
- package/lib-prod/realtime/realtime-core.d.ts +0 -40
- package/lib-prod/realtime/realtime-core.js +0 -106
- package/lib-prod/realtime/realtime-core.js.map +0 -1
- package/lib-prod/realtime/realtime-server.d.ts +0 -43
- package/lib-prod/realtime/realtime-server.js +0 -243
- package/lib-prod/realtime/realtime-server.js.map +0 -1
- package/lib-prod/realtime/realtime-strategy/index.js +0 -21
- package/lib-prod/realtime/realtime-strategy/index.js.map +0 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.d.ts +0 -80
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js +0 -297
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-ipc.js.map +0 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.d.ts +0 -14
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js +0 -303
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-mock.js.map +0 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.d.ts +0 -16
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js +0 -33
- package/lib-prod/realtime/realtime-strategy/realtime-strategy-socket-io.js.map +0 -1
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.d.ts +0 -11
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js +0 -17
- package/lib-prod/realtime/realtime-strategy/realtime-strategy.js.map +0 -1
- package/lib-prod/realtime/realtime-subs-manager.d.ts +0 -14
- package/lib-prod/realtime/realtime-subs-manager.js +0 -94
- package/lib-prod/realtime/realtime-subs-manager.js.map +0 -1
- package/lib-prod/realtime/realtime.models.js +0 -4
- package/lib-prod/realtime/realtime.models.js.map +0 -1
- package/lib-prod/symbols.d.ts +0 -63
- package/lib-prod/symbols.js +0 -109
- package/lib-prod/symbols.js.map +0 -1
- package/lib-prod/ui/index.d.ts +0 -1
- package/lib-prod/ui/index.js +0 -5
- package/lib-prod/ui/index.js.map +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.d.ts +0 -1
- package/lib-prod/ui/taon-admin-mode-configuration/index.js +0 -5
- package/lib-prod/ui/taon-admin-mode-configuration/index.js.map +0 -1
- package/lib-prod/validators.d.ts +0 -5
- package/lib-prod/validators.js +0 -88
- package/lib-prod/validators.js.map +0 -1
- /package/lib-prod/env/{index.d.ts → index.ts} +0 -0
|
@@ -1,2416 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EndpointContext = void 0;
|
|
4
|
-
const url_1 = require("url"); // @backend
|
|
5
|
-
const axios_1 = require("axios");
|
|
6
|
-
const bodyParser = require("body-parser"); // @backend
|
|
7
|
-
const cookieParser = require("cookie-parser"); // @backend
|
|
8
|
-
const cors = require("cors"); // @backend
|
|
9
|
-
const electron_1 = require("electron"); // @backend
|
|
10
|
-
const express = require("express");
|
|
11
|
-
// multer in taon middleware will do better job than express-fileupload
|
|
12
|
-
// import * as fileUpload from 'express-fileupload'; // @backend
|
|
13
|
-
const expressSession = require("express-session"); // @backend
|
|
14
|
-
const lib_prod_1 = require("json10/lib-prod");
|
|
15
|
-
const lib_prod_2 = require("lodash-walk-object/lib-prod");
|
|
16
|
-
const methodOverride = require("method-override"); // @backend
|
|
17
|
-
const lib_prod_3 = require("ng2-rest/lib-prod");
|
|
18
|
-
const rxjs_1 = require("rxjs");
|
|
19
|
-
const lib_prod_4 = require("taon-typeorm/lib-prod"); // @websql
|
|
20
|
-
const lib_prod_5 = require("taon-typeorm/lib-prod"); // @websql
|
|
21
|
-
const lib_prod_6 = require("taon-typeorm/lib-prod");
|
|
22
|
-
const lib_prod_7 = require("tnp-core/lib-prod");
|
|
23
|
-
const lib_prod_8 = require("tnp-core/lib-prod");
|
|
24
|
-
const lib_prod_9 = require("tnp-core/lib-prod"); // @backend
|
|
25
|
-
const lib_prod_10 = require("tnp-core/lib-prod");
|
|
26
|
-
const lib_prod_11 = require("tnp-core/lib-prod");
|
|
27
|
-
const lib_prod_12 = require("tnp-core/lib-prod");
|
|
28
|
-
const lib_prod_13 = require("tnp-core/lib-prod");
|
|
29
|
-
const constants_1 = require("./constants");
|
|
30
|
-
const context_db_migrations_1 = require("./context-db-migrations");
|
|
31
|
-
const di_container_1 = require("./dependency-injection/di-container");
|
|
32
|
-
const entity_process_1 = require("./entity-process");
|
|
33
|
-
const get_response_value_1 = require("./get-response-value");
|
|
34
|
-
const class_helpers_1 = require("./helpers/class-helpers");
|
|
35
|
-
const taon_helpers_1 = require("./helpers/taon-helpers");
|
|
36
|
-
const models_1 = require("./models");
|
|
37
|
-
const realtime_core_1 = require("./realtime/realtime-core");
|
|
38
|
-
const symbols_1 = require("./symbols");
|
|
39
|
-
/* */
|
|
40
|
-
//#endregion
|
|
41
|
-
class EndpointContext {
|
|
42
|
-
originalConfig;
|
|
43
|
-
configFn;
|
|
44
|
-
cloneOptions;
|
|
45
|
-
//#region fields
|
|
46
|
-
//#region fields / use mariadb mysql in docker
|
|
47
|
-
/**
|
|
48
|
-
* JUST FOR TESTING PURPOSES
|
|
49
|
-
*/
|
|
50
|
-
USE_MARIADB_MYSQL_IN_DOCKER = false;
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region fields / flags
|
|
53
|
-
disabledRealtime = false;
|
|
54
|
-
/**
|
|
55
|
-
* check whether context is inited
|
|
56
|
-
* (with init() function )
|
|
57
|
-
*/
|
|
58
|
-
inited = false;
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region fields / db migrations
|
|
61
|
-
dbMigrations = new context_db_migrations_1.ContextDbMigrations(this);
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region fields / local instance obj symbol
|
|
64
|
-
localInstaceObjSymbol = Symbol('localInstaceObjSymbol');
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region fields / all instances of classes from context
|
|
67
|
-
/**
|
|
68
|
-
* all instances of classes from context
|
|
69
|
-
* key is class name
|
|
70
|
-
*/
|
|
71
|
-
allClassesInstances = {};
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region fields / class instances by name
|
|
74
|
-
classInstancesByNameObj = {};
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region fields / obj with classes instances arr
|
|
77
|
-
objWithClassesInstancesArr = {};
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region fields / active routes
|
|
80
|
-
activeRoutes = [];
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region fields / typeorm repositories
|
|
83
|
-
//#region @websql
|
|
84
|
-
repos = new Map();
|
|
85
|
-
//#endregion
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region fields / source context
|
|
88
|
-
get sourceContext() {
|
|
89
|
-
return this.cloneOptions?.sourceContext;
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region fields / skip writing server routes
|
|
93
|
-
skipWritingServerRoutes = false;
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region fields / types from contexts
|
|
96
|
-
injectableTypesfromContexts = [
|
|
97
|
-
models_1.Models__NS__ClassType.CONTROLLER,
|
|
98
|
-
models_1.Models__NS__ClassType.PROVIDER,
|
|
99
|
-
models_1.Models__NS__ClassType.MIDDLEWARE,
|
|
100
|
-
models_1.Models__NS__ClassType.REPOSITORY,
|
|
101
|
-
models_1.Models__NS__ClassType.SUBSCRIBER,
|
|
102
|
-
models_1.Models__NS__ClassType.MIGRATION,
|
|
103
|
-
];
|
|
104
|
-
//#endregion
|
|
105
|
-
//#region fields / all types from contexts
|
|
106
|
-
allTypesfromContexts = [
|
|
107
|
-
...this.injectableTypesfromContexts,
|
|
108
|
-
models_1.Models__NS__ClassType.ENTITY,
|
|
109
|
-
];
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region fields / express app
|
|
112
|
-
expressApp = {};
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region fields / server tcp udp
|
|
115
|
-
serverTcpUdp;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region fields / database config
|
|
118
|
-
databaseConfig;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region fields / mode
|
|
121
|
-
mode;
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region fields / only migration start
|
|
124
|
-
onlyMigrationRun = false;
|
|
125
|
-
onlyMigrationRevertToTimestamp = undefined;
|
|
126
|
-
get isRunOrRevertOnlyMigrationAppStart() {
|
|
127
|
-
return !!(this.onlyMigrationRun || this.onlyMigrationRevertToTimestamp);
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region fields / session
|
|
131
|
-
session;
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region fields / connection
|
|
134
|
-
connection;
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region fields / entities triggers
|
|
137
|
-
entitiesTriggers = {};
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region fields / realtime
|
|
140
|
-
realtime;
|
|
141
|
-
get realtimeClient() {
|
|
142
|
-
return this.realtime.client;
|
|
143
|
-
}
|
|
144
|
-
get realtimeServer() {
|
|
145
|
-
return this.realtime.server;
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region fields / config
|
|
149
|
-
/**
|
|
150
|
-
* available after init()
|
|
151
|
-
*/
|
|
152
|
-
config;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region fields / logs
|
|
155
|
-
get logHttp() {
|
|
156
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
157
|
-
return !!this.config.logs.http;
|
|
158
|
-
}
|
|
159
|
-
return this.config?.logs === true;
|
|
160
|
-
}
|
|
161
|
-
get logRealtime() {
|
|
162
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
163
|
-
return !!this.config.logs.realtime;
|
|
164
|
-
}
|
|
165
|
-
return this.config?.logs === true;
|
|
166
|
-
}
|
|
167
|
-
get logFramework() {
|
|
168
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
169
|
-
return !!this.config.logs.framework;
|
|
170
|
-
}
|
|
171
|
-
return this.config?.logs === true;
|
|
172
|
-
}
|
|
173
|
-
get logRoutes() {
|
|
174
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
175
|
-
return !!this.config.logs.routes;
|
|
176
|
-
}
|
|
177
|
-
return this.config?.logs === true;
|
|
178
|
-
}
|
|
179
|
-
get logDb() {
|
|
180
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
181
|
-
return !!this.config.logs.db;
|
|
182
|
-
}
|
|
183
|
-
return this.config?.logs === true;
|
|
184
|
-
}
|
|
185
|
-
get logMigrations() {
|
|
186
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config?.logs)) {
|
|
187
|
-
return !!this.config.logs.migrations;
|
|
188
|
-
}
|
|
189
|
-
return this.config?.logs === true;
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region constructor
|
|
194
|
-
/**
|
|
195
|
-
* Inside docker there is not need for https secure server
|
|
196
|
-
*/
|
|
197
|
-
isRunningInsideDocker = false;
|
|
198
|
-
constructor(originalConfig, configFn,
|
|
199
|
-
/**
|
|
200
|
-
* (@default: false)
|
|
201
|
-
* If TRUE context is NOT going to create db/express server/http endpoints
|
|
202
|
-
* PURPOSE OF THIS PROPERTY
|
|
203
|
-
* -> ONLY remote access from backend or frontend to specific backend
|
|
204
|
-
*/
|
|
205
|
-
cloneOptions) {
|
|
206
|
-
this.originalConfig = originalConfig;
|
|
207
|
-
this.configFn = configFn;
|
|
208
|
-
this.cloneOptions = cloneOptions;
|
|
209
|
-
this.cloneOptions = this.cloneOptions || {};
|
|
210
|
-
this.isRunningInsideDocker = (0, lib_prod_10.UtilsOs__NS__isRunningInDocker)();
|
|
211
|
-
}
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region methods & getters / init
|
|
214
|
-
async init(options) {
|
|
215
|
-
const { initFromRecrusiveContextResovle, onlyMigrationRun, onlyMigrationRevertToTimestamp, } = options || {}; // TODO use it ?
|
|
216
|
-
this.inited = true;
|
|
217
|
-
// @ts-ignore
|
|
218
|
-
this.onlyMigrationRun = onlyMigrationRun;
|
|
219
|
-
// @ts-ignore
|
|
220
|
-
this.onlyMigrationRevertToTimestamp = onlyMigrationRevertToTimestamp;
|
|
221
|
-
this.config = this.configFn({});
|
|
222
|
-
if ((0, lib_prod_12.___NS__isObject)(this.config.database)) {
|
|
223
|
-
this.config.database = models_1.Models__NS__DatabaseConfig.from(this.config.database).databaseConfigTypeORM;
|
|
224
|
-
}
|
|
225
|
-
this.config.host = this.host === null ? void 0 : this.host;
|
|
226
|
-
if (this.cloneOptions.overrideHost &&
|
|
227
|
-
!this.cloneOptions.useAsRemoteContext) {
|
|
228
|
-
this.config.host = this.cloneOptions.overrideHost;
|
|
229
|
-
}
|
|
230
|
-
if (this.cloneOptions.overrideRemoteHost &&
|
|
231
|
-
this.cloneOptions.useAsRemoteContext) {
|
|
232
|
-
this.config.host = this.cloneOptions.overrideRemoteHost;
|
|
233
|
-
}
|
|
234
|
-
if (this.config.host &&
|
|
235
|
-
!this.config.host.startsWith('http://') &&
|
|
236
|
-
!this.config.host.startsWith('https://')) {
|
|
237
|
-
(0, lib_prod_12.Helpers__NS__throwError)(`[taon-config] Your${this.host ? ' remote' : ''} 'host' must start with http:// or https://`);
|
|
238
|
-
}
|
|
239
|
-
if ((0, lib_prod_12.___NS__isUndefined)(this.config.useIpcWhenElectron)) {
|
|
240
|
-
this.config.useIpcWhenElectron = true;
|
|
241
|
-
}
|
|
242
|
-
// console.log(`config for ${this.contextName}`, this.config);
|
|
243
|
-
//#region resolve if skipping writing server routes
|
|
244
|
-
//@ts-expect-error overriding readonly
|
|
245
|
-
this.skipWritingServerRoutes = (0, lib_prod_12.___NS__isBoolean)(this.config.skipWritingServerRoutes)
|
|
246
|
-
? this.config.skipWritingServerRoutes
|
|
247
|
-
: false;
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region resolve mode
|
|
250
|
-
if (this.config.host) {
|
|
251
|
-
this.mode = 'backend-frontend(tcp+udp)';
|
|
252
|
-
/* */
|
|
253
|
-
/* */
|
|
254
|
-
}
|
|
255
|
-
if (this.isRemoteHost) {
|
|
256
|
-
this.mode = 'remote-backend(tcp+udp)';
|
|
257
|
-
}
|
|
258
|
-
// console.log(`
|
|
259
|
-
// useIpcWhenElectron: ${this.config.useIpcWhenElectron}
|
|
260
|
-
// UtilsOs__NS__isElectron: ${UtilsOs__NS__isElectron}
|
|
261
|
-
// `)
|
|
262
|
-
if (this.config.useIpcWhenElectron && lib_prod_10.UtilsOs__NS__isElectron) {
|
|
263
|
-
if (lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
264
|
-
this.mode = 'backend-frontend(websql-electron)';
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
this.mode = 'backend-frontend(ipc-electron)';
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
// mode === undefined for TaonBaseContext => ok behavior
|
|
271
|
-
// console.log(`Mode for BE/FE communication: ${this.mode}`);
|
|
272
|
-
// if(!this.mode) {
|
|
273
|
-
// console.log(this.config)
|
|
274
|
-
// }
|
|
275
|
-
if (!this.mode && !this.config.abstract) {
|
|
276
|
-
const errMsg = `You need to provide host property or ` +
|
|
277
|
-
`useIpcWhenElectron or mark it as abstract`;
|
|
278
|
-
(0, lib_prod_12.Helpers__NS__error)(`[taon][Context=${this.contextName}]: ${errMsg}`, false, true);
|
|
279
|
-
//#region @backend
|
|
280
|
-
process.exit(1);
|
|
281
|
-
//#endregion
|
|
282
|
-
}
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region resolve database config
|
|
285
|
-
if (this.config.database === true) {
|
|
286
|
-
this.logFramework &&
|
|
287
|
-
console.log(`
|
|
288
|
-
|
|
289
|
-
ASSIGNING AUTO GENERATED DATABASE CONFIG
|
|
290
|
-
|
|
291
|
-
`);
|
|
292
|
-
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
293
|
-
}
|
|
294
|
-
else if ((0, lib_prod_12.___NS__isObject)(this.config.database)) {
|
|
295
|
-
this.logFramework &&
|
|
296
|
-
console.log(`
|
|
297
|
-
|
|
298
|
-
OVERRIDE DATABASE CONFIG FROM CONFIGURATION
|
|
299
|
-
|
|
300
|
-
`);
|
|
301
|
-
this.databaseConfig = this.getAutoGeneratedConfig();
|
|
302
|
-
lib_prod_2.walk.Object(this.config.database, (value, lodashPath) => {
|
|
303
|
-
if ((0, lib_prod_12.___NS__isNil)(value) || (0, lib_prod_12.___NS__isFunction)(value) || (0, lib_prod_12.___NS__isObject)(value)) {
|
|
304
|
-
// skipping
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
this.logFramework &&
|
|
308
|
-
console.info(`Overriding database config: ${lodashPath}=${value}`);
|
|
309
|
-
(0, lib_prod_12.___NS__set)(this.databaseConfig, lodashPath, value);
|
|
310
|
-
}
|
|
311
|
-
}, {
|
|
312
|
-
walkGetters: false,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region resolve session
|
|
317
|
-
if (this.config.session) {
|
|
318
|
-
this.session = (0, lib_prod_12.___NS__cloneDeep)(this.config.session);
|
|
319
|
-
const oneHour = 1000 * 60 * 60 * 1; // 24;
|
|
320
|
-
if (!this.session.cookieMaxAge) {
|
|
321
|
-
this.session.cookieMaxAge = oneHour;
|
|
322
|
-
}
|
|
323
|
-
// serever and browser cookie authentication
|
|
324
|
-
axios_1.default.defaults.withCredentials = true;
|
|
325
|
-
}
|
|
326
|
-
//#endregion
|
|
327
|
-
//#region prepare & gather all classes recursively
|
|
328
|
-
this.config.contexts = this.config.contexts || {};
|
|
329
|
-
this.config.entities = this.config.entities || {};
|
|
330
|
-
this.config.controllers = this.config.controllers || {};
|
|
331
|
-
this.config.repositories = this.config.repositories || {};
|
|
332
|
-
this.config.providers = this.config.providers || {};
|
|
333
|
-
this.config.subscribers = this.config.subscribers || {};
|
|
334
|
-
this.config.migrations = this.config.migrations || {};
|
|
335
|
-
this.config.entities = {
|
|
336
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.ENTITY)),
|
|
337
|
-
...this.config.entities,
|
|
338
|
-
};
|
|
339
|
-
this.config.controllers = {
|
|
340
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.CONTROLLER)),
|
|
341
|
-
...this.config.controllers,
|
|
342
|
-
};
|
|
343
|
-
this.config.providers = {
|
|
344
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.PROVIDER)),
|
|
345
|
-
...this.config.providers,
|
|
346
|
-
};
|
|
347
|
-
this.config.middlewares = {
|
|
348
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.MIDDLEWARE)),
|
|
349
|
-
...this.config.middlewares,
|
|
350
|
-
};
|
|
351
|
-
this.config.subscribers = {
|
|
352
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.SUBSCRIBER)),
|
|
353
|
-
...this.config.subscribers,
|
|
354
|
-
};
|
|
355
|
-
this.config.repositories = {
|
|
356
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.REPOSITORY)),
|
|
357
|
-
...this.config.repositories,
|
|
358
|
-
};
|
|
359
|
-
this.config.migrations = {
|
|
360
|
-
...(await this.getRecrusiveClassesfromContextsObj(models_1.Models__NS__ClassType.MIGRATION)),
|
|
361
|
-
...this.config.migrations,
|
|
362
|
-
};
|
|
363
|
-
// console.log(this.config);
|
|
364
|
-
// debugger;
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region prepare classes instances/functions clones
|
|
367
|
-
this.config.controllers = this.cloneClassesObjWithNewMetadata({
|
|
368
|
-
classesInput: this.config.controllers,
|
|
369
|
-
config: this.config,
|
|
370
|
-
ctx: this,
|
|
371
|
-
classType: models_1.Models__NS__ClassType.CONTROLLER,
|
|
372
|
-
});
|
|
373
|
-
this.config.repositories = this.cloneClassesObjWithNewMetadata({
|
|
374
|
-
classesInput: this.config.repositories,
|
|
375
|
-
config: this.config,
|
|
376
|
-
ctx: this,
|
|
377
|
-
classType: models_1.Models__NS__ClassType.REPOSITORY,
|
|
378
|
-
});
|
|
379
|
-
this.config.providers = this.cloneClassesObjWithNewMetadata({
|
|
380
|
-
classesInput: this.config.providers,
|
|
381
|
-
config: this.config,
|
|
382
|
-
ctx: this,
|
|
383
|
-
classType: models_1.Models__NS__ClassType.PROVIDER,
|
|
384
|
-
});
|
|
385
|
-
this.config.middlewares = this.cloneClassesObjWithNewMetadata({
|
|
386
|
-
classesInput: this.config.middlewares,
|
|
387
|
-
config: this.config,
|
|
388
|
-
ctx: this,
|
|
389
|
-
classType: models_1.Models__NS__ClassType.MIDDLEWARE,
|
|
390
|
-
});
|
|
391
|
-
this.config.subscribers = this.cloneClassesObjWithNewMetadata({
|
|
392
|
-
classesInput: this.config.subscribers,
|
|
393
|
-
config: this.config,
|
|
394
|
-
ctx: this,
|
|
395
|
-
classType: models_1.Models__NS__ClassType.SUBSCRIBER,
|
|
396
|
-
});
|
|
397
|
-
this.config.migrations = this.cloneClassesObjWithNewMetadata({
|
|
398
|
-
classesInput: this.config.migrations,
|
|
399
|
-
config: this.config,
|
|
400
|
-
ctx: this,
|
|
401
|
-
classType: models_1.Models__NS__ClassType.MIGRATION,
|
|
402
|
-
});
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region prepare instances
|
|
405
|
-
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
406
|
-
this.classInstancesByNameObj[classTypeName] = {};
|
|
407
|
-
this.objWithClassesInstancesArr[classTypeName] = [];
|
|
408
|
-
}
|
|
409
|
-
for (const classTypeName of this.injectableTypesfromContexts) {
|
|
410
|
-
await this.createInstances(this.config[models_1.Models__NS__ClassTypeKey[classTypeName]], classTypeName);
|
|
411
|
-
}
|
|
412
|
-
//#endregion
|
|
413
|
-
if (!this.isRunOrRevertOnlyMigrationAppStart) {
|
|
414
|
-
//#region prepares server
|
|
415
|
-
if (this.mode === 'backend-frontend(tcp+udp)' && !this.config.abstract) {
|
|
416
|
-
//#region @backend
|
|
417
|
-
this.expressApp = express();
|
|
418
|
-
if (process.env.NODE_ENV === 'production') {
|
|
419
|
-
this.expressApp.set('trust proxy', 1);
|
|
420
|
-
}
|
|
421
|
-
await this.initBackendMiddlewares();
|
|
422
|
-
await this.initCustomBackendMiddlewares();
|
|
423
|
-
const shouldStartHttpsSecureServer = this.isHttpServer && !this.isRunningInsideDocker;
|
|
424
|
-
this.logFramework &&
|
|
425
|
-
(0, lib_prod_12.Helpers__NS__info)(`
|
|
426
|
-
|
|
427
|
-
Starting server ${shouldStartHttpsSecureServer ? 'with' : 'without'} HTTPS secure server
|
|
428
|
-
|
|
429
|
-
`);
|
|
430
|
-
this.serverTcpUdp = shouldStartHttpsSecureServer
|
|
431
|
-
? new lib_prod_9.https.Server({
|
|
432
|
-
key: this.config.https?.key,
|
|
433
|
-
cert: this.config.https?.cert,
|
|
434
|
-
}, this.expressApp)
|
|
435
|
-
: new lib_prod_9.http.Server(this.expressApp);
|
|
436
|
-
this.publicAssets.forEach(asset => {
|
|
437
|
-
this.expressApp.use(asset.serverPath, express.static(asset.locationOnDisk));
|
|
438
|
-
});
|
|
439
|
-
//#endregion
|
|
440
|
-
await this.initCustomClientMiddlewares();
|
|
441
|
-
}
|
|
442
|
-
//#endregion
|
|
443
|
-
//#region prepare realtime
|
|
444
|
-
if (!this.config.abstract) {
|
|
445
|
-
this.disabledRealtime = this.config.disabledRealtime;
|
|
446
|
-
if (!this.host) {
|
|
447
|
-
throw `
|
|
448
|
-
|
|
449
|
-
host is required for context initialization..
|
|
450
|
-
(Or maybe you forgot mark ${this.config.contextName} context as abstract?)
|
|
451
|
-
|
|
452
|
-
`;
|
|
453
|
-
}
|
|
454
|
-
//#region @backend
|
|
455
|
-
// if (UtilsOs__NS__isRunningInCliMode() && !___NS__isNil(this.config.disabledRealtime)) {
|
|
456
|
-
// // TODO for now...
|
|
457
|
-
// Helpers__NS__logInfo(`Realtime disable on backend for cli mode`);
|
|
458
|
-
// this.disabledRealtime = true;
|
|
459
|
-
// } else {
|
|
460
|
-
// Helpers__NS__logInfo(`Realtime enabled on backend`);
|
|
461
|
-
// }
|
|
462
|
-
//#endregion
|
|
463
|
-
this.logRealtime &&
|
|
464
|
-
(0, lib_prod_12.Helpers__NS__info)(`[ctx=${this.contextName}] Init Realtime for ${this.mode}`);
|
|
465
|
-
this.realtime = new realtime_core_1.RealtimeCore(this);
|
|
466
|
-
}
|
|
467
|
-
//#endregion
|
|
468
|
-
}
|
|
469
|
-
//#region show context info
|
|
470
|
-
// console.log({ ref })
|
|
471
|
-
if (this.config.abstract) {
|
|
472
|
-
this.logFramework &&
|
|
473
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create abstract context: ${this.config.contextName}`);
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
if (this.isRemoteHost) {
|
|
477
|
-
this.logFramework &&
|
|
478
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create context for remote host: ${this.config.host}`);
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
this.logFramework &&
|
|
482
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon] Create context for host: ${this.config.host}`);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
//#endregion
|
|
486
|
-
// update first exposed config
|
|
487
|
-
Object.keys(this.config).forEach(key => {
|
|
488
|
-
this.originalConfig[key] = this.config[key];
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
//#endregion
|
|
492
|
-
//#region methods & getters / get auto generated config
|
|
493
|
-
getAutoGeneratedConfig() {
|
|
494
|
-
this.logFramework &&
|
|
495
|
-
console.log(`
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
IS RUNNING IN DOCKER: ${this.isRunningInsideDocker}
|
|
499
|
-
|
|
500
|
-
`);
|
|
501
|
-
//#region @websqlFunc
|
|
502
|
-
let databaseConfig = models_1.Models__NS__DatabaseConfig.from({});
|
|
503
|
-
const tcpUdpDatabaseSqliteRelativeFileLocation = `${models_1.Models__NS__DatabasesFolder}/db-${this.contextName}.sqlite`;
|
|
504
|
-
if (this.isRunningInsideDocker) {
|
|
505
|
-
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
506
|
-
// Helpers__NS__info('Running in docker, using in mysql database');
|
|
507
|
-
// // TODO auto resolve database config in docker
|
|
508
|
-
// databaseConfig = Models__NS__DatabaseConfig.from({
|
|
509
|
-
// database: `db-${this.contextName}.sqlite`,
|
|
510
|
-
// type: 'mysql',
|
|
511
|
-
// recreateMode: 'PRESERVE_DATA+MIGRATIONS',
|
|
512
|
-
// logging: this.logDb,
|
|
513
|
-
// databasePort: 3306,
|
|
514
|
-
// databaseHost: 'localhost',
|
|
515
|
-
// databaseUsername: 'root',
|
|
516
|
-
// databasePassword: 'admin',
|
|
517
|
-
// });
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
// TOOD @LAST for now.. just use sqljs in docker
|
|
521
|
-
this.logFramework &&
|
|
522
|
-
console.log(`
|
|
523
|
-
|
|
524
|
-
USING GENERATED CONFIG FOR SQLJS IN DOCKER
|
|
525
|
-
|
|
526
|
-
`);
|
|
527
|
-
//#region @backend
|
|
528
|
-
const locationOfTheDatabase = (0, lib_prod_11.crossPlatformPath)([
|
|
529
|
-
process.cwd(),
|
|
530
|
-
`db-${this.contextName}.sqlite`,
|
|
531
|
-
]);
|
|
532
|
-
//#endregion
|
|
533
|
-
databaseConfig = databaseConfig = models_1.Models__NS__DatabaseConfig.from({
|
|
534
|
-
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
535
|
-
type: 'sqljs',
|
|
536
|
-
useLocalForage: false,
|
|
537
|
-
recreateMode: 'PRESERVE_DATA+MIGRATIONS',
|
|
538
|
-
logging: true,
|
|
539
|
-
});
|
|
540
|
-
//#region @backend
|
|
541
|
-
if (!lib_prod_9.fse.existsSync(locationOfTheDatabase)) {
|
|
542
|
-
databaseConfig.recreateMode = 'DROP_DB+MIGRATIONS';
|
|
543
|
-
}
|
|
544
|
-
// TODO @LAST add same thing for mariadb/mysql
|
|
545
|
-
this.logFramework &&
|
|
546
|
-
console.log(`
|
|
547
|
-
location of database: ${locationOfTheDatabase}
|
|
548
|
-
db file exists: ${lib_prod_9.fse.existsSync(locationOfTheDatabase)}
|
|
549
|
-
synchronize: ${databaseConfig.synchronize}
|
|
550
|
-
dropSchema: ${databaseConfig.dropSchema}
|
|
551
|
-
`);
|
|
552
|
-
//#endregion
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
//#region auto resolve db config
|
|
557
|
-
this.logFramework &&
|
|
558
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon][database] Automatically resolving database config for mode ${this.mode}`);
|
|
559
|
-
switch (this.mode) {
|
|
560
|
-
//#region resolve database config for backend-frontend(ipc-electron)
|
|
561
|
-
case 'backend-frontend(ipc-electron)':
|
|
562
|
-
let dbLocationInOs;
|
|
563
|
-
//#region @backend
|
|
564
|
-
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
565
|
-
dbLocationInOs = (0, lib_prod_11.crossPlatformPath)([
|
|
566
|
-
(0, lib_prod_10.UtilsOs__NS__getRealHomeDir)(),
|
|
567
|
-
`.taon/databases-for-electron-apps/${this.appId || (0, lib_prod_12.___NS__snakeCase)(process.cwd()).replace(/\_/, '.')}/${this.contextName}.sqlite`,
|
|
568
|
-
]);
|
|
569
|
-
if (!(0, lib_prod_12.Helpers__NS__exists)(lib_prod_13.path.dirname(dbLocationInOs))) {
|
|
570
|
-
(0, lib_prod_12.Helpers__NS__mkdirp)(lib_prod_13.path.dirname(dbLocationInOs));
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
//#endregion
|
|
574
|
-
databaseConfig = models_1.Models__NS__DatabaseConfig.from({
|
|
575
|
-
location: lib_prod_10.UtilsOs__NS__isElectron
|
|
576
|
-
? dbLocationInOs
|
|
577
|
-
: `db-${this.contextName}.sqlite`,
|
|
578
|
-
type: 'sqljs',
|
|
579
|
-
recreateMode: 'DROP_DB+MIGRATIONS',
|
|
580
|
-
logging: this.logDb,
|
|
581
|
-
});
|
|
582
|
-
break;
|
|
583
|
-
//#endregion
|
|
584
|
-
//#region resolve database config for mode backend-frontend(websql)
|
|
585
|
-
case 'backend-frontend(websql-electron)':
|
|
586
|
-
case 'backend-frontend(websql)':
|
|
587
|
-
let keepWebsqlDbDataAfterReload = false;
|
|
588
|
-
/* */
|
|
589
|
-
/* */
|
|
590
|
-
/* */
|
|
591
|
-
databaseConfig = databaseConfig = models_1.Models__NS__DatabaseConfig.from({
|
|
592
|
-
location: `db-${this.contextName}.sqlite`,
|
|
593
|
-
type: 'sqljs',
|
|
594
|
-
useLocalForage: true, // !!window['localforage'], // TODO this need to be checked in runtime
|
|
595
|
-
recreateMode: keepWebsqlDbDataAfterReload
|
|
596
|
-
? 'PRESERVE_DATA+MIGRATIONS'
|
|
597
|
-
: 'DROP_DB+MIGRATIONS',
|
|
598
|
-
logging: this.logDb,
|
|
599
|
-
});
|
|
600
|
-
break;
|
|
601
|
-
//#endregion
|
|
602
|
-
//#region resolve database config for mode backend-frontend(tcp+udp)
|
|
603
|
-
case 'backend-frontend(tcp+udp)':
|
|
604
|
-
databaseConfig = models_1.Models__NS__DatabaseConfig.from({
|
|
605
|
-
database: `context-db-${this.contextName}`,
|
|
606
|
-
location: tcpUdpDatabaseSqliteRelativeFileLocation,
|
|
607
|
-
type: 'sqljs',
|
|
608
|
-
recreateMode: 'DROP_DB+MIGRATIONS',
|
|
609
|
-
logging: this.logDb,
|
|
610
|
-
});
|
|
611
|
-
break;
|
|
612
|
-
//#endregion
|
|
613
|
-
}
|
|
614
|
-
//#endregion
|
|
615
|
-
}
|
|
616
|
-
return databaseConfig.databaseConfigTypeORM;
|
|
617
|
-
//#endregion
|
|
618
|
-
}
|
|
619
|
-
//#endregion
|
|
620
|
-
//#region methods & getters / start server
|
|
621
|
-
async startServer() {
|
|
622
|
-
//#region @backendFunc
|
|
623
|
-
if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
if (this.mode === 'backend-frontend(tcp+udp)') {
|
|
627
|
-
return await new Promise(resolve => {
|
|
628
|
-
if (this.isRunningInsideDocker) {
|
|
629
|
-
// this.displayRoutes(this.expressApp);
|
|
630
|
-
this.serverTcpUdp.listen(Number(this.uriPort), '0.0.0.0', () => {
|
|
631
|
-
this.logFramework &&
|
|
632
|
-
(0, lib_prod_12.Helpers__NS__log)(`[ctx=${this.contextName}] Express server (inside docker) started 0.0.0.0:${this.uriPort}`);
|
|
633
|
-
this.logFramework &&
|
|
634
|
-
(0, lib_prod_12.Helpers__NS__log)(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
635
|
-
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
636
|
-
ExpressJS mode: ${this.expressApp.settings.env}
|
|
637
|
-
`);
|
|
638
|
-
resolve(void 0);
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
else {
|
|
642
|
-
// this.displayRoutes(this.expressApp);
|
|
643
|
-
this.serverTcpUdp.listen(Number(this.uriPort), () => {
|
|
644
|
-
this.logFramework &&
|
|
645
|
-
(0, lib_prod_12.Helpers__NS__log)(`[ctx=${this.contextName}] Express server (inside nodejs app) started on localhost:${this.uriPort}`);
|
|
646
|
-
this.logFramework &&
|
|
647
|
-
(0, lib_prod_12.Helpers__NS__log)(`[taon][express-server]listening on port: ${this.uriPort}, hostname: ${this.uriPathname},
|
|
648
|
-
address: ${this.uriProtocol}//localhost:${this.uriPort}${this.uriPathname}
|
|
649
|
-
expressJS mode: ${this.expressApp.settings.env}
|
|
650
|
-
`);
|
|
651
|
-
resolve(void 0);
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
else {
|
|
657
|
-
this.logFramework &&
|
|
658
|
-
(0, lib_prod_12.Helpers__NS__info)('Ipc communication enable instead tcp/upd');
|
|
659
|
-
}
|
|
660
|
-
//#endregion
|
|
661
|
-
}
|
|
662
|
-
//#endregion
|
|
663
|
-
//#region methods & getters / display express routes
|
|
664
|
-
displayRoutes(app) {
|
|
665
|
-
//#region @backend
|
|
666
|
-
const routes = [];
|
|
667
|
-
app._router?.stack.forEach(function (middleware) {
|
|
668
|
-
if (middleware.route) {
|
|
669
|
-
// routes registered directly on the app
|
|
670
|
-
const methods = [];
|
|
671
|
-
for (let method in middleware.route.methods) {
|
|
672
|
-
if (middleware.route.methods[method]) {
|
|
673
|
-
methods.push(method.toUpperCase());
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
routes.push({ path: middleware.route.path, methods: methods });
|
|
677
|
-
}
|
|
678
|
-
else if (middleware.name === 'router') {
|
|
679
|
-
// router middleware
|
|
680
|
-
middleware.handle.stack.forEach(function (handler) {
|
|
681
|
-
const methods = [];
|
|
682
|
-
for (let method in handler.route.methods) {
|
|
683
|
-
if (handler.route.methods[method]) {
|
|
684
|
-
methods.push(method.toUpperCase());
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
routes.push({ path: handler.route.path, methods: methods });
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
console.log(routes);
|
|
692
|
-
//#endregion
|
|
693
|
-
}
|
|
694
|
-
//#endregion
|
|
695
|
-
//#region methods & getters / mode allows database creation
|
|
696
|
-
get modeAllowsDatabaseCreation() {
|
|
697
|
-
return (this.mode === 'backend-frontend(tcp+udp)' ||
|
|
698
|
-
this.mode === 'backend-frontend(websql)' ||
|
|
699
|
-
this.mode === 'backend-frontend(ipc-electron)');
|
|
700
|
-
}
|
|
701
|
-
//#endregion
|
|
702
|
-
//#region methods & getters / clone class
|
|
703
|
-
cloneClassWithNewMetadata = ({ TaonBaseClass, className, config, ctx, classType, }) => {
|
|
704
|
-
// Return a new class that extends the base class
|
|
705
|
-
const cloneClass = () => {
|
|
706
|
-
if (TaonBaseClass[symbols_1.Symbols__NS__fullClassNameStaticProperty] ===
|
|
707
|
-
`${ctx.contextName}.${className}`) {
|
|
708
|
-
return TaonBaseClass;
|
|
709
|
-
}
|
|
710
|
-
return class extends TaonBaseClass {
|
|
711
|
-
// static ['_'] = TaonBaseClass['_'];
|
|
712
|
-
// @ts-ignore
|
|
713
|
-
static [symbols_1.Symbols__NS__orignalClass] = TaonBaseClass;
|
|
714
|
-
// @ts-ignore
|
|
715
|
-
static [symbols_1.Symbols__NS__fullClassNameStaticProperty] = `${ctx.contextName}.${className}`;
|
|
716
|
-
// @ts-ignore
|
|
717
|
-
static [symbols_1.Symbols__NS__classNameStaticProperty] = className;
|
|
718
|
-
static [symbols_1.Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
719
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
720
|
-
static __getFullPathForClass__(arr = []) {
|
|
721
|
-
const name = this[symbols_1.Symbols__NS__fullClassNameStaticProperty];
|
|
722
|
-
arr.push(name);
|
|
723
|
-
// @ts-ignore
|
|
724
|
-
if (this[symbols_1.Symbols__NS__orignalClass] && // @ts-ignore
|
|
725
|
-
this[symbols_1.Symbols__NS__orignalClass].__getFullPathForClass__) {
|
|
726
|
-
// @ts-ignore
|
|
727
|
-
this[symbols_1.Symbols__NS__orignalClass].__getFullPathForClass__(arr);
|
|
728
|
-
}
|
|
729
|
-
return arr.join('/');
|
|
730
|
-
}
|
|
731
|
-
static get fullPathForClass() {
|
|
732
|
-
return this.__getFullPathForClass__();
|
|
733
|
-
}
|
|
734
|
-
[symbols_1.Symbols__NS__ctxInClassOrClassObj] = ctx;
|
|
735
|
-
};
|
|
736
|
-
};
|
|
737
|
-
const cloneClassFunction = cloneClass();
|
|
738
|
-
//#region gather all instances for all contexts
|
|
739
|
-
// TODO this is not needed anymore - for typeorm I use normal entities
|
|
740
|
-
// this thinng belowe is nice for debugging purpose
|
|
741
|
-
// if (___NS__isUndefined(cloneClassFunction[Symbols__NS__orignalClassClonesObj])) {
|
|
742
|
-
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = {};
|
|
743
|
-
// }
|
|
744
|
-
// if (___NS__isUndefined(TaonBaseClass[Symbols__NS__orignalClassClonesObj])) {
|
|
745
|
-
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = {};
|
|
746
|
-
// }
|
|
747
|
-
// const all = {
|
|
748
|
-
// ...TaonBaseClass[Symbols__NS__orignalClassClonesObj],
|
|
749
|
-
// ...cloneClassFunction[Symbols__NS__orignalClassClonesObj],
|
|
750
|
-
// };
|
|
751
|
-
// all[ctx.contextName] = cloneClassFunction;
|
|
752
|
-
// cloneClassFunction[Symbols__NS__orignalClassClonesObj] = all;
|
|
753
|
-
// TaonBaseClass[Symbols__NS__orignalClassClonesObj] = all;
|
|
754
|
-
//#endregion
|
|
755
|
-
return cloneClassFunction;
|
|
756
|
-
};
|
|
757
|
-
//#endregion
|
|
758
|
-
//#region methods & getters / clone classes obj with new metadata
|
|
759
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
760
|
-
cloneClassesObjWithNewMetadata = ({ classesInput, config, ctx, classType, }) => {
|
|
761
|
-
const classes = {};
|
|
762
|
-
// console.log(Object.keys(classesInput))
|
|
763
|
-
for (const key of Object.keys(classesInput || {})) {
|
|
764
|
-
const TaonBaseClass = classesInput[key];
|
|
765
|
-
if (!TaonBaseClass) {
|
|
766
|
-
(0, lib_prod_12.Helpers__NS__error)(`Class ${key} is not defined in context ${ctx.contextName}
|
|
767
|
-
|
|
768
|
-
Please check if you have correct import in context file
|
|
769
|
-
|
|
770
|
-
`);
|
|
771
|
-
}
|
|
772
|
-
var className = Reflect.getMetadata(symbols_1.Symbols__NS__metadata.className, TaonBaseClass);
|
|
773
|
-
// console.log('Metadata className', className, TaonBaseClass);
|
|
774
|
-
// if (!className) {
|
|
775
|
-
// console.warn(`Please provide className for ${TaonBaseClass.name} class`);
|
|
776
|
-
// }
|
|
777
|
-
className = className || key;
|
|
778
|
-
TaonBaseClass[symbols_1.Symbols__NS__classNameStaticProperty] = className;
|
|
779
|
-
const clonedClass = this.cloneClassWithNewMetadata({
|
|
780
|
-
TaonBaseClass,
|
|
781
|
-
className,
|
|
782
|
-
config,
|
|
783
|
-
ctx,
|
|
784
|
-
classType,
|
|
785
|
-
});
|
|
786
|
-
classes[className] = clonedClass;
|
|
787
|
-
}
|
|
788
|
-
return classes;
|
|
789
|
-
};
|
|
790
|
-
//#endregion
|
|
791
|
-
//#region methods & getters / get recursive classes from contexts
|
|
792
|
-
async getRecrusiveClassesfromContextsObj(classType) {
|
|
793
|
-
const arr = await this.getRecrusiveClassesfromContexts(classType);
|
|
794
|
-
return arr.reduce((acc, c) => {
|
|
795
|
-
acc[(0, class_helpers_1.ClassHelpers__NS__getName)(c)] = c;
|
|
796
|
-
return acc;
|
|
797
|
-
}, {});
|
|
798
|
-
}
|
|
799
|
-
async getRecrusiveClassesfromContexts(classType, arr = []) {
|
|
800
|
-
const contexts = Object.values(this.config.contexts || {});
|
|
801
|
-
// console.log({
|
|
802
|
-
// contexts,
|
|
803
|
-
// });
|
|
804
|
-
for (const ctx of contexts) {
|
|
805
|
-
// console.log(`STARTING ${ctx.contextName}`);
|
|
806
|
-
const ref = await ctx.__ref();
|
|
807
|
-
// console.log(`CTX FROM ${ctx.contextName}`, ref.contextName);
|
|
808
|
-
const classesInput = ref.getClassFunBy(classType);
|
|
809
|
-
// console.log(`${ref.contextName} - ${classType}`, { classesInput });
|
|
810
|
-
const clonedClasses = Object.values(this.cloneClassesObjWithNewMetadata({
|
|
811
|
-
classesInput,
|
|
812
|
-
config: this.config,
|
|
813
|
-
ctx: this,
|
|
814
|
-
classType,
|
|
815
|
-
}));
|
|
816
|
-
// console.log(`${classType} clonedClasses`, clonedClasses);
|
|
817
|
-
clonedClasses.forEach(c => arr.push(c));
|
|
818
|
-
await ref.getRecrusiveClassesfromContexts(classType, arr);
|
|
819
|
-
}
|
|
820
|
-
return arr;
|
|
821
|
-
}
|
|
822
|
-
//#endregion
|
|
823
|
-
//#region methods & getters / get class instances by class type
|
|
824
|
-
getClassInstanceObjBy(classType) {
|
|
825
|
-
return this.classInstancesByNameObj[classType];
|
|
826
|
-
}
|
|
827
|
-
//#endregion
|
|
828
|
-
//#region methods & getters / get class instances arr
|
|
829
|
-
getClassesInstancesArrBy(classType) {
|
|
830
|
-
return this.objWithClassesInstancesArr[classType];
|
|
831
|
-
}
|
|
832
|
-
//#endregion
|
|
833
|
-
//#region methods & getters / inject
|
|
834
|
-
inject(ctor, options) {
|
|
835
|
-
const className = (0, class_helpers_1.ClassHelpers__NS__getName)(ctor);
|
|
836
|
-
const locaInstanceConstructorArgs = options.locaInstanceConstructorArgs || [];
|
|
837
|
-
if (this.isCLassType(models_1.Models__NS__ClassType.REPOSITORY, ctor)) {
|
|
838
|
-
options.localInstance = true;
|
|
839
|
-
}
|
|
840
|
-
if (options?.localInstance) {
|
|
841
|
-
const ctxClassFn = this.getClassFunByClassName(className);
|
|
842
|
-
let entityName = '';
|
|
843
|
-
// entity thing is only for repositories local repositories
|
|
844
|
-
// if (className === 'TaonBaseRepository') {
|
|
845
|
-
const entityFn = (0, lib_prod_12.___NS__first)(locaInstanceConstructorArgs);
|
|
846
|
-
const entity = entityFn && entityFn();
|
|
847
|
-
entityName = (entity && (0, class_helpers_1.ClassHelpers__NS__getName)(entity)) || '';
|
|
848
|
-
// console.log(`entityName `, entityName);
|
|
849
|
-
// }
|
|
850
|
-
if (!options.contextClassInstance[this.localInstaceObjSymbol]) {
|
|
851
|
-
options.contextClassInstance[this.localInstaceObjSymbol] = {};
|
|
852
|
-
}
|
|
853
|
-
const instanceKey = className + (entityName ? `.${entityName}` : '');
|
|
854
|
-
const existed = options.contextClassInstance[this.localInstaceObjSymbol][instanceKey];
|
|
855
|
-
if (existed) {
|
|
856
|
-
// console.log(
|
|
857
|
-
// `EXISTED ${ClassHelpers__NS__getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
858
|
-
// );
|
|
859
|
-
return existed;
|
|
860
|
-
}
|
|
861
|
-
// console.log(
|
|
862
|
-
// `NEW ${ClassHelpers__NS__getName(options.parentInstanceThatWillGetInjectedStuff)} Inject ${className} instanceKey "${instanceKey}"`,
|
|
863
|
-
// );
|
|
864
|
-
if (!ctxClassFn) {
|
|
865
|
-
throw new Error(`Not able to inject "${className}" inside context "${this.contextName}"
|
|
866
|
-
|
|
867
|
-
Make sure they share the same context or import context where "${className}" is defined.
|
|
868
|
-
|
|
869
|
-
`);
|
|
870
|
-
}
|
|
871
|
-
const injectedInstance = new ctxClassFn(...locaInstanceConstructorArgs);
|
|
872
|
-
options.contextClassInstance[this.localInstaceObjSymbol][instanceKey] =
|
|
873
|
-
injectedInstance;
|
|
874
|
-
// console.log(`injectedInstance `, existed)
|
|
875
|
-
return injectedInstance;
|
|
876
|
-
}
|
|
877
|
-
const contextScopeInstance = this.allClassesInstances[className];
|
|
878
|
-
// if (className === 'TopicController') {
|
|
879
|
-
// debugger;
|
|
880
|
-
// }
|
|
881
|
-
return contextScopeInstance;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* alias for inject
|
|
885
|
-
*/
|
|
886
|
-
getInstanceBy(ctor) {
|
|
887
|
-
// if (!!this.__contextForControllerInstanceAccess) {
|
|
888
|
-
// const className = ClassHelpers__NS__getName(ctor);
|
|
889
|
-
// const allControllers = this.getClassFunByArr(Models__NS__ClassType.CONTROLLER);
|
|
890
|
-
// // TODO QUICK_FIX cache controllers
|
|
891
|
-
// for (const ctrl of allControllers) {
|
|
892
|
-
// if (ClassHelpers__NS__getName(ctrl) === className) {
|
|
893
|
-
// // console.log('injecting from contextForControllerInstanceAcesss', className);
|
|
894
|
-
// return this.__contextForControllerInstanceAccess.inject(ctor, {
|
|
895
|
-
// localInstance: false,
|
|
896
|
-
// });
|
|
897
|
-
// }
|
|
898
|
-
// }
|
|
899
|
-
// }
|
|
900
|
-
return this.inject(ctor, {
|
|
901
|
-
localInstance: false,
|
|
902
|
-
parentInstanceThatWillGetInjectedStuff: this,
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
//#endregion
|
|
906
|
-
//#region methods & getters / check if context initialized
|
|
907
|
-
checkIfContextInitialized() {
|
|
908
|
-
if ((0, lib_prod_12.___NS__isUndefined)(this.config)) {
|
|
909
|
-
throw new Error(`Please check if your context has been initialized.
|
|
910
|
-
|
|
911
|
-
// ...
|
|
912
|
-
await Context.initialize();
|
|
913
|
-
// ...
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
`);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region methods & getters / get class function by class type name
|
|
921
|
-
getClassFunBy(classType) {
|
|
922
|
-
this.checkIfContextInitialized();
|
|
923
|
-
switch (classType) {
|
|
924
|
-
case models_1.Models__NS__ClassType.CONTROLLER:
|
|
925
|
-
return this.config.controllers;
|
|
926
|
-
case models_1.Models__NS__ClassType.ENTITY:
|
|
927
|
-
return this.config.entities;
|
|
928
|
-
case models_1.Models__NS__ClassType.PROVIDER:
|
|
929
|
-
return this.config.providers;
|
|
930
|
-
case models_1.Models__NS__ClassType.MIDDLEWARE:
|
|
931
|
-
return this.config.middlewares;
|
|
932
|
-
case models_1.Models__NS__ClassType.REPOSITORY:
|
|
933
|
-
return this.config.repositories;
|
|
934
|
-
case models_1.Models__NS__ClassType.SUBSCRIBER:
|
|
935
|
-
return this.config.subscribers;
|
|
936
|
-
case models_1.Models__NS__ClassType.MIGRATION:
|
|
937
|
-
return this.config.migrations;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
isCLassType(classType, classFn) {
|
|
941
|
-
return !!this.getClassFunBy(classType)[(0, class_helpers_1.ClassHelpers__NS__getName)(classFn)];
|
|
942
|
-
}
|
|
943
|
-
/**
|
|
944
|
-
* Only for injectable types
|
|
945
|
-
* Only for classType: CONTROLLER, REPOSITORY, PROVIDER, MIDDLEWARES
|
|
946
|
-
*/
|
|
947
|
-
getClassFunByClassName(className) {
|
|
948
|
-
for (const classTypeName of this.allTypesfromContexts) {
|
|
949
|
-
const classesForInjectableType = this.config[models_1.Models__NS__ClassTypeKey[classTypeName]];
|
|
950
|
-
if (classesForInjectableType[className]) {
|
|
951
|
-
return classesForInjectableType[className];
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
getClassFunByClass(classFunction) {
|
|
956
|
-
const className = (0, class_helpers_1.ClassHelpers__NS__getName)(classFunction);
|
|
957
|
-
return this.getClassFunByClassName(className);
|
|
958
|
-
}
|
|
959
|
-
getClassFunByArr(classType) {
|
|
960
|
-
return Object.values(this.getClassFunBy(classType) || {});
|
|
961
|
-
}
|
|
962
|
-
//#endregion
|
|
963
|
-
//#region methods & getters / create class instances
|
|
964
|
-
async createInstances(classes, classType) {
|
|
965
|
-
// const recrusiveValuesFromContext =
|
|
966
|
-
// await this.getRecrusiveClassesfromContexts(classType);
|
|
967
|
-
// console.log(this.config.contexts);
|
|
968
|
-
// console.log('recrusiveValuesFromContext', recrusiveValuesFromContext);
|
|
969
|
-
for (const classFn of [
|
|
970
|
-
// ...recrusiveValuesFromContext,
|
|
971
|
-
...Object.values(classes),
|
|
972
|
-
]) {
|
|
973
|
-
const instance = di_container_1.DITaonContainer.resolve(classFn);
|
|
974
|
-
const classInstancesByNameObj = this.classInstancesByNameObj[classType];
|
|
975
|
-
const className = (0, class_helpers_1.ClassHelpers__NS__getName)(classFn);
|
|
976
|
-
// console.log({ classFn, classType, instance, place, className, 'classInstancesByNameObj': this.classInstancesByNameObj });
|
|
977
|
-
classInstancesByNameObj[className] = instance;
|
|
978
|
-
// update config
|
|
979
|
-
this.config[models_1.Models__NS__ClassTypeKey[classType]][className] = classFn;
|
|
980
|
-
this.objWithClassesInstancesArr[classType].push(instance);
|
|
981
|
-
this.allClassesInstances[className] = instance;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
//#endregion
|
|
985
|
-
//#region methods & getters / init classes
|
|
986
|
-
async initClasses() {
|
|
987
|
-
if (this.isRemoteHost) {
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
//#region @websql
|
|
991
|
-
for (const classFun of this.getClassFunByArr(models_1.Models__NS__ClassType.ENTITY)) {
|
|
992
|
-
const repo = (await this.connection.getRepository((0, class_helpers_1.ClassHelpers__NS__getOrginalClass)(classFun)));
|
|
993
|
-
this.repos.set((0, class_helpers_1.ClassHelpers__NS__getName)(classFun), repo);
|
|
994
|
-
}
|
|
995
|
-
//#endregion
|
|
996
|
-
for (const classTypeName of [
|
|
997
|
-
models_1.Models__NS__ClassType.MIDDLEWARE,
|
|
998
|
-
models_1.Models__NS__ClassType.PROVIDER,
|
|
999
|
-
models_1.Models__NS__ClassType.REPOSITORY,
|
|
1000
|
-
models_1.Models__NS__ClassType.CONTROLLER,
|
|
1001
|
-
models_1.Models__NS__ClassType.ENTITY,
|
|
1002
|
-
models_1.Models__NS__ClassType.MIGRATION,
|
|
1003
|
-
]) {
|
|
1004
|
-
//#region init class static _ property
|
|
1005
|
-
for (const classFun of this.getClassFunByArr(classTypeName)) {
|
|
1006
|
-
if ((0, lib_prod_12.___NS__isFunction)(classFun._)) {
|
|
1007
|
-
await classFun._();
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
//#endregion
|
|
1011
|
-
}
|
|
1012
|
-
for (const classTypeName of [
|
|
1013
|
-
models_1.Models__NS__ClassType.MIDDLEWARE,
|
|
1014
|
-
models_1.Models__NS__ClassType.PROVIDER,
|
|
1015
|
-
models_1.Models__NS__ClassType.REPOSITORY,
|
|
1016
|
-
models_1.Models__NS__ClassType.CONTROLLER,
|
|
1017
|
-
models_1.Models__NS__ClassType.MIGRATION,
|
|
1018
|
-
]) {
|
|
1019
|
-
//#region init providers, repositories _ property
|
|
1020
|
-
// Helpers__NS__taskStarted(
|
|
1021
|
-
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} STARTED`,
|
|
1022
|
-
// );
|
|
1023
|
-
for (const ctrl of this.getClassesInstancesArrBy(classTypeName)) {
|
|
1024
|
-
if ((0, lib_prod_12.___NS__isFunction)(ctrl._)) {
|
|
1025
|
-
await ctrl._();
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
// Helpers__NS__taskStarted(
|
|
1029
|
-
// `[taon] REINITING _ INS FN ${classTypeName} ${this.contextName} DONE`,
|
|
1030
|
-
// );
|
|
1031
|
-
//#endregion
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region methods & getters / is active on
|
|
1036
|
-
isActiveOn(classInstance) {
|
|
1037
|
-
let contextRef = classInstance[symbols_1.Symbols__NS__ctxInClassOrClassObj];
|
|
1038
|
-
return this === contextRef;
|
|
1039
|
-
}
|
|
1040
|
-
//#endregion
|
|
1041
|
-
//#region methods & getters / uri
|
|
1042
|
-
get frontendHostUri() {
|
|
1043
|
-
const url = this.config?.frontendHost?.startsWith('http')
|
|
1044
|
-
? this.config.frontendHost
|
|
1045
|
-
: `${globalThis?.location?.protocol || 'http:'}//${this.config?.frontendHost}`;
|
|
1046
|
-
const uri = new url_1.URL(url.replace(/\/$/, ''));
|
|
1047
|
-
return uri;
|
|
1048
|
-
}
|
|
1049
|
-
get uri() {
|
|
1050
|
-
const url = this.host ? new url_1.URL(this.host) : void 0;
|
|
1051
|
-
return url;
|
|
1052
|
-
}
|
|
1053
|
-
//#endregion
|
|
1054
|
-
//#region methods & getters / host uri protocol
|
|
1055
|
-
get uriProtocol() {
|
|
1056
|
-
return this.uri?.protocol;
|
|
1057
|
-
}
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region methods & getters / host uri origin
|
|
1060
|
-
/**
|
|
1061
|
-
* Examples
|
|
1062
|
-
* http://localhost:3000
|
|
1063
|
-
* https://localhost (from localhost:80) *
|
|
1064
|
-
*/
|
|
1065
|
-
get uriOrigin() {
|
|
1066
|
-
return this.uri?.origin;
|
|
1067
|
-
}
|
|
1068
|
-
//#endregion
|
|
1069
|
-
//#region methods & getters / host uri pathname
|
|
1070
|
-
/**
|
|
1071
|
-
* Exampels
|
|
1072
|
-
* http://localhost:3000/path/to/somewhere
|
|
1073
|
-
* https://localhost/path/to/somewhere (from localhost:80)
|
|
1074
|
-
*/
|
|
1075
|
-
// get uriOriginWithPathname(): string | undefined {
|
|
1076
|
-
// return this.uri?.origin
|
|
1077
|
-
// ? this.uri?.origin + this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')
|
|
1078
|
-
// : undefined;
|
|
1079
|
-
// }
|
|
1080
|
-
get uriPathname() {
|
|
1081
|
-
return this.uri?.pathname;
|
|
1082
|
-
}
|
|
1083
|
-
//#endregion
|
|
1084
|
-
//#region methods & getters / uri pathname or nothing if root
|
|
1085
|
-
/**
|
|
1086
|
-
* Examples
|
|
1087
|
-
* http://localhost:3000/path/to/somewhere -> '/path/to/somewhere'
|
|
1088
|
-
* http://localhost:3000 -> '' #
|
|
1089
|
-
* https://localhost/path/to/ -> '/path/to/somewhere' # remove last slash
|
|
1090
|
-
*/
|
|
1091
|
-
get uriPathnameOrNothingIfRoot() {
|
|
1092
|
-
const isNonRootProperPathName = this.uri?.pathname && this.uri.pathname !== '/';
|
|
1093
|
-
return isNonRootProperPathName ? this.uri.pathname.replace(/\/$/, '') : '';
|
|
1094
|
-
}
|
|
1095
|
-
//#endregion
|
|
1096
|
-
//#region methods & getters / port from uri
|
|
1097
|
-
get uriPort() {
|
|
1098
|
-
if (!this.uri?.origin?.includes('localhost')) {
|
|
1099
|
-
return this.config?.hostPortNumber?.toString();
|
|
1100
|
-
}
|
|
1101
|
-
return this.uri?.port;
|
|
1102
|
-
}
|
|
1103
|
-
// TODO do i need 2 getters for port?
|
|
1104
|
-
/**
|
|
1105
|
-
* Port from uri as number
|
|
1106
|
-
* @returns {Number | undefined}
|
|
1107
|
-
*/
|
|
1108
|
-
get port() {
|
|
1109
|
-
return this.uri?.port ? Number(this.uriPort) : undefined;
|
|
1110
|
-
}
|
|
1111
|
-
//#endregion
|
|
1112
|
-
//#region methods & getters / is https server
|
|
1113
|
-
get isHttpServer() {
|
|
1114
|
-
return this.uriProtocol === 'https:';
|
|
1115
|
-
}
|
|
1116
|
-
//#endregion
|
|
1117
|
-
//#region methods & getters / is remote host
|
|
1118
|
-
/**
|
|
1119
|
-
* Check if context is for remote only
|
|
1120
|
-
*/
|
|
1121
|
-
get isRemoteHost() {
|
|
1122
|
-
return !!this.cloneOptions?.useAsRemoteContext;
|
|
1123
|
-
}
|
|
1124
|
-
//#endregion
|
|
1125
|
-
//#region methods & getters / context name
|
|
1126
|
-
/**
|
|
1127
|
-
* ipc/udp needs this
|
|
1128
|
-
*/
|
|
1129
|
-
get contextName() {
|
|
1130
|
-
// console.log(this.originalConfig);
|
|
1131
|
-
return this.config?.contextName || this.originalConfig?.contextName;
|
|
1132
|
-
}
|
|
1133
|
-
//#endregion
|
|
1134
|
-
//#region methods & getters / context name for communication
|
|
1135
|
-
/**
|
|
1136
|
-
* ipc/udp needs this
|
|
1137
|
-
*/
|
|
1138
|
-
get contextNameForCommunication() {
|
|
1139
|
-
let contextName = this.contextName;
|
|
1140
|
-
if (this.isRemoteHost) {
|
|
1141
|
-
if (this.sourceContext?.contextName) {
|
|
1142
|
-
contextName = this.sourceContext?.contextName;
|
|
1143
|
-
}
|
|
1144
|
-
else {
|
|
1145
|
-
// console.log(
|
|
1146
|
-
// `CANT GET SOURCE CONTEXT NAME FOR REMOTE CONTEXT ${this.contextName}`,
|
|
1147
|
-
// );
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
return contextName;
|
|
1151
|
-
}
|
|
1152
|
-
//#endregion
|
|
1153
|
-
//#region methods & getters / get context type
|
|
1154
|
-
/**
|
|
1155
|
-
* Check context type
|
|
1156
|
-
*/
|
|
1157
|
-
get contextType() {
|
|
1158
|
-
if (this.config.abstract) {
|
|
1159
|
-
return 'abstract';
|
|
1160
|
-
}
|
|
1161
|
-
if (this.host) {
|
|
1162
|
-
return this.isRemoteHost ? 'remote' : 'normal';
|
|
1163
|
-
}
|
|
1164
|
-
return 'invalid';
|
|
1165
|
-
}
|
|
1166
|
-
//#endregion
|
|
1167
|
-
//#region methods & getters / current working directory
|
|
1168
|
-
get cwd() {
|
|
1169
|
-
return this.config.cwd || process.cwd();
|
|
1170
|
-
}
|
|
1171
|
-
//#endregion
|
|
1172
|
-
//#region methods & getters / active context
|
|
1173
|
-
get activeContext() {
|
|
1174
|
-
return this.config.activeContext || null;
|
|
1175
|
-
}
|
|
1176
|
-
//#endregion
|
|
1177
|
-
//#region methods & getters / app id
|
|
1178
|
-
get appId() {
|
|
1179
|
-
return this.config.appId;
|
|
1180
|
-
}
|
|
1181
|
-
//#endregion
|
|
1182
|
-
//#region methods & getters / public assets
|
|
1183
|
-
get publicAssets() {
|
|
1184
|
-
return this.config?.publicAssets || [];
|
|
1185
|
-
}
|
|
1186
|
-
//#endregion
|
|
1187
|
-
//#region methods & getters / is production mode
|
|
1188
|
-
get isProductionMode() {
|
|
1189
|
-
return this.config.productionMode;
|
|
1190
|
-
}
|
|
1191
|
-
//#endregion
|
|
1192
|
-
//#region methods & getters / host
|
|
1193
|
-
get host() {
|
|
1194
|
-
return this.config.host;
|
|
1195
|
-
}
|
|
1196
|
-
//#endregion
|
|
1197
|
-
//#region methods & getters / origin
|
|
1198
|
-
get origin() {
|
|
1199
|
-
return this.uri?.origin;
|
|
1200
|
-
}
|
|
1201
|
-
//#endregion
|
|
1202
|
-
//#region methods & getters / init subscribers
|
|
1203
|
-
async initSubscribers() {
|
|
1204
|
-
//#region @websqlFunc
|
|
1205
|
-
if (this.isRemoteHost) {
|
|
1206
|
-
return;
|
|
1207
|
-
}
|
|
1208
|
-
const subscriberClasses = this.getClassFunByArr(models_1.Models__NS__ClassType.SUBSCRIBER);
|
|
1209
|
-
for (const subscriberClassFn of subscriberClasses) {
|
|
1210
|
-
const options = Reflect.getMetadata(symbols_1.Symbols__NS__metadata.options.subscriber, subscriberClassFn);
|
|
1211
|
-
// console.log('subscriber options', options);
|
|
1212
|
-
// const nameForSubscriber = ClassHelpers__NS__getName(subscriber);
|
|
1213
|
-
(0, lib_prod_4.EventSubscriber)()(subscriberClassFn);
|
|
1214
|
-
}
|
|
1215
|
-
//#endregion
|
|
1216
|
-
}
|
|
1217
|
-
//#endregion
|
|
1218
|
-
//#region methods & getters / init entities
|
|
1219
|
-
async initEntities() {
|
|
1220
|
-
//#region @websql
|
|
1221
|
-
if (this.isRemoteHost) {
|
|
1222
|
-
return;
|
|
1223
|
-
}
|
|
1224
|
-
const entities = this.getClassFunByArr(models_1.Models__NS__ClassType.ENTITY);
|
|
1225
|
-
for (const entity of entities) {
|
|
1226
|
-
const options = Reflect.getMetadata(symbols_1.Symbols__NS__metadata.options.entity, entity);
|
|
1227
|
-
const createTable = (0, lib_prod_12.___NS__isUndefined)(options.createTable)
|
|
1228
|
-
? true
|
|
1229
|
-
: options.createTable;
|
|
1230
|
-
const nameForEntity = (0, class_helpers_1.ClassHelpers__NS__getName)(entity);
|
|
1231
|
-
if (createTable) {
|
|
1232
|
-
this.logDb &&
|
|
1233
|
-
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
1234
|
-
// console.log('TypeormEntity', { TypeormEntity });
|
|
1235
|
-
(0, lib_prod_5.Entity)(nameForEntity)(entity);
|
|
1236
|
-
}
|
|
1237
|
-
else {
|
|
1238
|
-
this.logDb &&
|
|
1239
|
-
console.info(`[taon][typeorm] create table for entity "${nameForEntity}" ? '${createTable}'`);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
//#endregion
|
|
1243
|
-
}
|
|
1244
|
-
//#endregion
|
|
1245
|
-
//#region methods & getters / destroy
|
|
1246
|
-
async destroy() {
|
|
1247
|
-
//#region @websqlFunc
|
|
1248
|
-
if (this.connection) {
|
|
1249
|
-
await this.connection?.destroy();
|
|
1250
|
-
delete this.connection;
|
|
1251
|
-
}
|
|
1252
|
-
if (this.serverTcpUdp) {
|
|
1253
|
-
await new Promise(resolve => {
|
|
1254
|
-
this.serverTcpUdp?.close(() => {
|
|
1255
|
-
resolve(true);
|
|
1256
|
-
});
|
|
1257
|
-
});
|
|
1258
|
-
delete this.serverTcpUdp;
|
|
1259
|
-
}
|
|
1260
|
-
delete this.expressApp;
|
|
1261
|
-
//#endregion
|
|
1262
|
-
}
|
|
1263
|
-
//#endregion
|
|
1264
|
-
//#region methods & getters / init connection
|
|
1265
|
-
async initDatabaseConnection() {
|
|
1266
|
-
//#region @websqlFunc
|
|
1267
|
-
if (this.isRemoteHost || !this.databaseConfig) {
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
const entities = this.getClassFunByArr(models_1.Models__NS__ClassType.ENTITY).map(entityFn => {
|
|
1271
|
-
return (0, class_helpers_1.ClassHelpers__NS__getOrginalClass)(entityFn);
|
|
1272
|
-
});
|
|
1273
|
-
const subscribers = this.getClassFunByArr(models_1.Models__NS__ClassType.SUBSCRIBER);
|
|
1274
|
-
let autoSave = false;
|
|
1275
|
-
if (!(0, lib_prod_12.___NS__isNil)(this.databaseConfig.autoSave)) {
|
|
1276
|
-
autoSave = this.databaseConfig.autoSave;
|
|
1277
|
-
}
|
|
1278
|
-
else {
|
|
1279
|
-
if (this.USE_MARIADB_MYSQL_IN_DOCKER) {
|
|
1280
|
-
autoSave = !this.isRunningInsideDocker; // in docker I am using mysql or posgress
|
|
1281
|
-
}
|
|
1282
|
-
else {
|
|
1283
|
-
autoSave = true; // on docker with sqljs I need to save db
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
const dataSourceDbConfig = (0, lib_prod_12.___NS__isObject)(this.databaseConfig)
|
|
1287
|
-
? {
|
|
1288
|
-
type: this.databaseConfig.type,
|
|
1289
|
-
port: this.databaseConfig.databasePort,
|
|
1290
|
-
host: this.databaseConfig.databaseHost,
|
|
1291
|
-
database: this.databaseConfig.database,
|
|
1292
|
-
username: this.databaseConfig.databaseUsername,
|
|
1293
|
-
password: this.databaseConfig.databasePassword,
|
|
1294
|
-
useLocalForage: this.databaseConfig.useLocalForage,
|
|
1295
|
-
// I am not using typeorm migration system
|
|
1296
|
-
entities,
|
|
1297
|
-
subscribers,
|
|
1298
|
-
synchronize: this.isRunOrRevertOnlyMigrationAppStart
|
|
1299
|
-
? false
|
|
1300
|
-
: this.databaseConfig.synchronize,
|
|
1301
|
-
autoSave,
|
|
1302
|
-
dropSchema: this.isRunOrRevertOnlyMigrationAppStart
|
|
1303
|
-
? false
|
|
1304
|
-
: this.databaseConfig.dropSchema,
|
|
1305
|
-
logging: !!this.databaseConfig.logging,
|
|
1306
|
-
location: this.databaseConfig.location,
|
|
1307
|
-
}
|
|
1308
|
-
: {};
|
|
1309
|
-
// debugger;
|
|
1310
|
-
this.logFramework &&
|
|
1311
|
-
console.log(`[Context: "${this.contextName}"] dataSourceDbConfig`, dataSourceDbConfig);
|
|
1312
|
-
if (this.modeAllowsDatabaseCreation && this.databaseConfig) {
|
|
1313
|
-
this.logDb &&
|
|
1314
|
-
this.logFramework &&
|
|
1315
|
-
(0, lib_prod_12.Helpers__NS__info)('[taon][database] prepare typeorm connection...');
|
|
1316
|
-
try {
|
|
1317
|
-
const connection = new lib_prod_6.DataSource(dataSourceDbConfig);
|
|
1318
|
-
this.connection = connection;
|
|
1319
|
-
await this.connection.initialize();
|
|
1320
|
-
}
|
|
1321
|
-
catch (error) {
|
|
1322
|
-
console.error(`[taon][typeorm] Error while initializing connection for ${this.contextName}, ERROR STARTED `);
|
|
1323
|
-
console.error(error?.stack || '< No stack trace > ');
|
|
1324
|
-
console.error(error?.message || error);
|
|
1325
|
-
console.error(`[taon][typeorm] Error while initializing connection for ${this.contextName}, ERROR ENDS `);
|
|
1326
|
-
}
|
|
1327
|
-
if (!this.connection?.isInitialized) {
|
|
1328
|
-
console.log('WRONG CONFIG', dataSourceDbConfig);
|
|
1329
|
-
throw new Error(`Something wrong with connection init in ${this.mode}`);
|
|
1330
|
-
//#region @backend
|
|
1331
|
-
process.exit(1);
|
|
1332
|
-
//#endregion
|
|
1333
|
-
}
|
|
1334
|
-
if (this.logDb || this.logFramework) {
|
|
1335
|
-
console.info(`
|
|
1336
|
-
|
|
1337
|
-
CONTECTION OK for ${this.contextName} - ${this.mode}
|
|
1338
|
-
|
|
1339
|
-
[taon][typeorm] db prepration done.. db initialize=${this.connection?.isInitialized}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
`,
|
|
1343
|
-
// dataSourceDbConfig,
|
|
1344
|
-
{ 'this.connection': !!this.connection });
|
|
1345
|
-
console.log(`Database file location: ${this.connection.options.database}`);
|
|
1346
|
-
}
|
|
1347
|
-
// const entityMetadata = getMetadataArgsStorage();
|
|
1348
|
-
// console.log(
|
|
1349
|
-
// `
|
|
1350
|
-
// entityMetadata after connection init for ${this.contextName} - ${this.mode}
|
|
1351
|
-
// `,
|
|
1352
|
-
// entityMetadata,
|
|
1353
|
-
// );
|
|
1354
|
-
// debugger;
|
|
1355
|
-
}
|
|
1356
|
-
else {
|
|
1357
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon][typeorm] Not initing db for mode ${this.mode}`);
|
|
1358
|
-
}
|
|
1359
|
-
//#endregion
|
|
1360
|
-
}
|
|
1361
|
-
//#endregion
|
|
1362
|
-
//#region methods & getters / initialize metadata
|
|
1363
|
-
//#region methods & getters / update class calculate path
|
|
1364
|
-
updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn) {
|
|
1365
|
-
const parentsCalculatedPath = (0, lib_prod_12.___NS__slice)(rawConfigs, 1)
|
|
1366
|
-
.reverse()
|
|
1367
|
-
.map(bc => {
|
|
1368
|
-
if ((0, taon_helpers_1.TaonHelpers__NS__isGoodPath)(bc.path)) {
|
|
1369
|
-
return bc.path;
|
|
1370
|
-
}
|
|
1371
|
-
return bc.className;
|
|
1372
|
-
})
|
|
1373
|
-
.join('/');
|
|
1374
|
-
const contextNameForCommunication = this.contextNameForCommunication;
|
|
1375
|
-
if ((0, taon_helpers_1.TaonHelpers__NS__isGoodPath)(classConfig.path)) {
|
|
1376
|
-
classConfig.calculatedPath = classConfig.path;
|
|
1377
|
-
}
|
|
1378
|
-
else {
|
|
1379
|
-
classConfig.calculatedPath = (`${this.uriPathnameOrNothingIfRoot}` +
|
|
1380
|
-
`/${constants_1.apiPrefix}/${contextNameForCommunication}/tcp${parentsCalculatedPath}/` +
|
|
1381
|
-
`${(0, class_helpers_1.ClassHelpers__NS__getName)(controllerClassFn)}`)
|
|
1382
|
-
.replace(/\/\//g, '/')
|
|
1383
|
-
.split('/')
|
|
1384
|
-
.reduce((acc, bc) => {
|
|
1385
|
-
return (0, lib_prod_12.___NS__last)(acc) === bc ? acc : [...acc, bc];
|
|
1386
|
-
}, [])
|
|
1387
|
-
.join('/');
|
|
1388
|
-
}
|
|
1389
|
-
// console.log('calculatedPath', classConfig.calculatedPath);
|
|
1390
|
-
}
|
|
1391
|
-
//#endregion
|
|
1392
|
-
//#region methods & getters / dedupe class configs
|
|
1393
|
-
mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn) {
|
|
1394
|
-
const currentControllerMethodsConfig = classConfig.methods;
|
|
1395
|
-
(0, lib_prod_12.___NS__slice)(rawConfigs, 1).forEach(bc => {
|
|
1396
|
-
const parentControllerMethods = (0, lib_prod_12.___NS__cloneDeep)(bc.methods);
|
|
1397
|
-
for (const methodsName in parentControllerMethods) {
|
|
1398
|
-
if (parentControllerMethods.hasOwnProperty(methodsName)) {
|
|
1399
|
-
if (!currentControllerMethodsConfig[methodsName]) {
|
|
1400
|
-
//#region add non existed method
|
|
1401
|
-
const methodConfig = parentControllerMethods[methodsName];
|
|
1402
|
-
currentControllerMethodsConfig[methodsName] = methodConfig;
|
|
1403
|
-
//#endregion
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
//#endregion
|
|
1410
|
-
async initControllersHook(ctxStorage) {
|
|
1411
|
-
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1412
|
-
return;
|
|
1413
|
-
}
|
|
1414
|
-
const allControllers = this.getClassFunByArr(models_1.Models__NS__ClassType.CONTROLLER);
|
|
1415
|
-
for (const controllerClassFn of allControllers) {
|
|
1416
|
-
const instance = this.getInstanceBy(controllerClassFn);
|
|
1417
|
-
if ((0, lib_prod_12.___NS__isFunction)(instance.afterAllCtxInited)) {
|
|
1418
|
-
await instance.afterAllCtxInited({ ctxStorage });
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
async initControllers() {
|
|
1423
|
-
if (this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1424
|
-
return;
|
|
1425
|
-
}
|
|
1426
|
-
const allControllers = this.getClassFunByArr(models_1.Models__NS__ClassType.CONTROLLER);
|
|
1427
|
-
// debugger
|
|
1428
|
-
// console.log('allControllers', allControllers);
|
|
1429
|
-
for (const controllerClassFn of allControllers) {
|
|
1430
|
-
// console.log(ClassHelpers__NS__getClassConfig(controllerClassFn));
|
|
1431
|
-
// const controllerName = ClassHelpers__NS__getName(controllerClassFn);
|
|
1432
|
-
// console.log(
|
|
1433
|
-
// `for ${controllerName}`,
|
|
1434
|
-
// ClassHelpers__NS__getClassConfig(controllerClassFn),
|
|
1435
|
-
// );
|
|
1436
|
-
controllerClassFn[symbols_1.Symbols__NS__classMethodsNames] =
|
|
1437
|
-
(0, class_helpers_1.ClassHelpers__NS__getMethodsNames)(controllerClassFn);
|
|
1438
|
-
const rawConfigs = (0, class_helpers_1.ClassHelpers__NS__getControllerConfigs)(controllerClassFn);
|
|
1439
|
-
// console.log(controllerName, { rawConfigs });
|
|
1440
|
-
// console.log(`Class config for ${ClassHelpers__NS__getName(controllerClassFn)}`, configs)
|
|
1441
|
-
const classConfig = rawConfigs[0];
|
|
1442
|
-
this.updateCalculatedPathsForControllers(rawConfigs, classConfig, controllerClassFn);
|
|
1443
|
-
this.mergeControllerMethodsConfigs(rawConfigs, classConfig, controllerClassFn);
|
|
1444
|
-
//#region combine middlewares from controllers
|
|
1445
|
-
classConfig.calculatedMiddlewaresControllerObj = {};
|
|
1446
|
-
[...rawConfigs].reverse().forEach(rc => {
|
|
1447
|
-
if ((0, lib_prod_12.___NS__isFunction)(rc.middlewares)) {
|
|
1448
|
-
classConfig.calculatedMiddlewaresControllerObj = rc.middlewares({
|
|
1449
|
-
parentMiddlewares: classConfig.calculatedMiddlewaresControllerObj,
|
|
1450
|
-
className(middlewareClass) {
|
|
1451
|
-
return (0, class_helpers_1.ClassHelpers__NS__getName)(controllerClassFn);
|
|
1452
|
-
},
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
//#endregion
|
|
1457
|
-
//#region group start
|
|
1458
|
-
//#region @backend
|
|
1459
|
-
if (!(0, lib_prod_10.UtilsOs__NS__isRunningInCliMode)()) {
|
|
1460
|
-
//#endregion
|
|
1461
|
-
this.logHttp &&
|
|
1462
|
-
console.groupCollapsed(`[taon][express-server] routes [${classConfig.className}]`);
|
|
1463
|
-
//#region @backend
|
|
1464
|
-
}
|
|
1465
|
-
//#endregion
|
|
1466
|
-
//#endregion
|
|
1467
|
-
//#region init client or server methods
|
|
1468
|
-
const methodNames = Object.keys(classConfig.methods);
|
|
1469
|
-
for (const methodName of methodNames) {
|
|
1470
|
-
const methodConfig = classConfig.methods[methodName];
|
|
1471
|
-
//#region combine all class methods middlewares
|
|
1472
|
-
let calculatedMiddlewaresMethodObj = {};
|
|
1473
|
-
[...rawConfigs].reverse().forEach(rc => {
|
|
1474
|
-
if (rc.methods[methodName]) {
|
|
1475
|
-
const parentMethodConfig = rc.methods[methodName];
|
|
1476
|
-
if ((0, lib_prod_12.___NS__isFunction)(parentMethodConfig.middlewares)) {
|
|
1477
|
-
calculatedMiddlewaresMethodObj = parentMethodConfig.middlewares({
|
|
1478
|
-
parentMiddlewares: calculatedMiddlewaresMethodObj,
|
|
1479
|
-
className(middlewareClass) {
|
|
1480
|
-
return (0, class_helpers_1.ClassHelpers__NS__getName)(controllerClassFn);
|
|
1481
|
-
},
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
});
|
|
1486
|
-
// add class middlewares to method middlewares
|
|
1487
|
-
methodConfig.calculatedMiddlewaresMethodObj = {
|
|
1488
|
-
...calculatedMiddlewaresMethodObj,
|
|
1489
|
-
...classConfig.calculatedMiddlewaresControllerObj,
|
|
1490
|
-
};
|
|
1491
|
-
methodConfig.calculatedMiddlewares = Object.values(methodConfig.calculatedMiddlewaresMethodObj || {});
|
|
1492
|
-
//#endregion
|
|
1493
|
-
// methodConfig.calculatedMiddlewares = TODO
|
|
1494
|
-
//#region initialized method express path
|
|
1495
|
-
const httpMethodType = methodConfig.type;
|
|
1496
|
-
// this is quick fix - in docker global path should not be used
|
|
1497
|
-
const globalPathPart = this.isRunningInsideDocker ||
|
|
1498
|
-
!this.frontendHostUri?.origin?.includes('localhost') // fe with domain -> is in docker
|
|
1499
|
-
? `${this.uriPathnameOrNothingIfRoot.replace(/\/$/, '')}/${constants_1.apiPrefix}/${this.contextName}`.replace(/\/\//, '/')
|
|
1500
|
-
: '';
|
|
1501
|
-
const expressPath = methodConfig.global
|
|
1502
|
-
? `${globalPathPart}/${methodConfig.path?.replace(/\/$/, '')}`.replace(/\/\//, '/')
|
|
1503
|
-
: (0, taon_helpers_1.TaonHelpers__NS__getExpressPath)(classConfig, methodConfig);
|
|
1504
|
-
//#endregion
|
|
1505
|
-
//#region init server
|
|
1506
|
-
// console.log({ expressPath });
|
|
1507
|
-
if (lib_prod_10.UtilsOs__NS__isNode || lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
1508
|
-
//#region @websql
|
|
1509
|
-
const route = this.initServer(httpMethodType, methodConfig, classConfig, expressPath, controllerClassFn);
|
|
1510
|
-
this.activeRoutes.push({
|
|
1511
|
-
expressPath: route.expressPath,
|
|
1512
|
-
method: route.method,
|
|
1513
|
-
});
|
|
1514
|
-
//#endregion
|
|
1515
|
-
}
|
|
1516
|
-
//#endregion
|
|
1517
|
-
//#region init client
|
|
1518
|
-
const shouldInitClient = lib_prod_10.UtilsOs__NS__isBrowser || this.isRemoteHost || lib_prod_10.UtilsOs__NS__isWebSQL;
|
|
1519
|
-
// console.log('shouldInitClient', shouldInitClient);
|
|
1520
|
-
if (shouldInitClient) {
|
|
1521
|
-
// console.log(
|
|
1522
|
-
// 'initClient',
|
|
1523
|
-
// ClassHelpers__NS__getFullInternalName(controllerClassFn),
|
|
1524
|
-
// type,
|
|
1525
|
-
// methodConfig,
|
|
1526
|
-
// expressPath,
|
|
1527
|
-
// );
|
|
1528
|
-
await this.initClient(controllerClassFn, httpMethodType, methodConfig, expressPath);
|
|
1529
|
-
}
|
|
1530
|
-
//#endregion
|
|
1531
|
-
}
|
|
1532
|
-
//#endregion
|
|
1533
|
-
//#region group end
|
|
1534
|
-
//#region @backend
|
|
1535
|
-
if (!(0, lib_prod_10.UtilsOs__NS__isRunningInCliMode)()) {
|
|
1536
|
-
//#endregion
|
|
1537
|
-
this.logHttp && console.groupEnd();
|
|
1538
|
-
//#region @backend
|
|
1539
|
-
}
|
|
1540
|
-
//#endregion
|
|
1541
|
-
//#endregion
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
//#endregion
|
|
1545
|
-
//#region methods & getters / write active routes
|
|
1546
|
-
writeActiveRoutes() {
|
|
1547
|
-
if (this.isRemoteHost || this.isRunOrRevertOnlyMigrationAppStart) {
|
|
1548
|
-
return;
|
|
1549
|
-
}
|
|
1550
|
-
// const contexts: EndpointContext[] = [this];
|
|
1551
|
-
//#region @websql
|
|
1552
|
-
const troutes = (0, lib_prod_10.Utils__NS__uniqArray)(this.activeRoutes.map(f => {
|
|
1553
|
-
return `${f.method} ${f.expressPath}`;
|
|
1554
|
-
})).map(f => {
|
|
1555
|
-
const [method, expressPath] = f.split(' ');
|
|
1556
|
-
return (`\n### ${(0, lib_prod_12.___NS__startCase)((0, lib_prod_12.___NS__last)(expressPath.split('/')))}\n` +
|
|
1557
|
-
(0, taon_helpers_1.TaonHelpers__NS__fillUpTo)(method.toUpperCase() + ' ', 10) +
|
|
1558
|
-
this.uriOrigin +
|
|
1559
|
-
expressPath);
|
|
1560
|
-
// return `${TaonHelpers.string(method.toUpperCase() + ':')
|
|
1561
|
-
// .fillUpTo(10)}${context.uriHref.replace(/\/$/, '')}${expressPath}`
|
|
1562
|
-
});
|
|
1563
|
-
const routes = [
|
|
1564
|
-
...['', `# ROUTES FOR HOST ${this.uriOrigin} `],
|
|
1565
|
-
...troutes,
|
|
1566
|
-
].join('\n');
|
|
1567
|
-
const fileName = (0, lib_prod_11.crossPlatformPath)([
|
|
1568
|
-
//#region @backend
|
|
1569
|
-
process.cwd(),
|
|
1570
|
-
//#endregion
|
|
1571
|
-
`routes/routes-${this.config.contextName}.rest`,
|
|
1572
|
-
]);
|
|
1573
|
-
this.logFramework && console.log(`[taon] routes file: ${fileName} `);
|
|
1574
|
-
this.logRoutes && console.log(routes);
|
|
1575
|
-
//#region @backend
|
|
1576
|
-
if (!lib_prod_10.UtilsOs__NS__isElectron && !this.skipWritingServerRoutes) {
|
|
1577
|
-
(0, lib_prod_12.Helpers__NS__writeFile)(fileName, routes);
|
|
1578
|
-
}
|
|
1579
|
-
//#endregion
|
|
1580
|
-
//#endregion
|
|
1581
|
-
}
|
|
1582
|
-
//#endregion
|
|
1583
|
-
//#region methods & getters / middlewares
|
|
1584
|
-
get middlewares() {
|
|
1585
|
-
//#region @backendFunc
|
|
1586
|
-
return this.config.middlewares || [];
|
|
1587
|
-
//#endregion
|
|
1588
|
-
}
|
|
1589
|
-
//#endregion
|
|
1590
|
-
//#region methods & getters / init middlewares
|
|
1591
|
-
async initCustomClientMiddlewares() {
|
|
1592
|
-
const middlewares = this.getClassesInstancesArrBy(models_1.Models__NS__ClassType.MIDDLEWARE)
|
|
1593
|
-
.map(f => f)
|
|
1594
|
-
.filter(f => (0, lib_prod_12.___NS__isFunction)(f.interceptClient));
|
|
1595
|
-
middlewares.forEach(middlewareInstanceName => {
|
|
1596
|
-
const contextName = this.contextName;
|
|
1597
|
-
const interceptorName = `${contextName}-${(0, class_helpers_1.ClassHelpers__NS__getName)(middlewareInstanceName)}`;
|
|
1598
|
-
lib_prod_3.Resource.request.interceptors.set(interceptorName, {
|
|
1599
|
-
intercept: ({ req, next }) => {
|
|
1600
|
-
const url = new url_1.URL(req.url);
|
|
1601
|
-
if (url.pathname.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${contextName}/`)) {
|
|
1602
|
-
// console.log('intercepting', url.pathname, req);
|
|
1603
|
-
return middlewareInstanceName.interceptClient({
|
|
1604
|
-
req,
|
|
1605
|
-
next,
|
|
1606
|
-
});
|
|
1607
|
-
}
|
|
1608
|
-
return next.handle(req);
|
|
1609
|
-
},
|
|
1610
|
-
});
|
|
1611
|
-
});
|
|
1612
|
-
}
|
|
1613
|
-
async initCustomBackendMiddlewares() {
|
|
1614
|
-
//#region @backend
|
|
1615
|
-
const app = this.expressApp;
|
|
1616
|
-
const middlewares = this.getClassesInstancesArrBy(models_1.Models__NS__ClassType.MIDDLEWARE);
|
|
1617
|
-
for (const middleware of middlewares) {
|
|
1618
|
-
const middlewareInstance = middleware;
|
|
1619
|
-
if ((0, lib_prod_12.___NS__isFunction)(middlewareInstance.interceptServer)) {
|
|
1620
|
-
const middlewareFn = (0, class_helpers_1.ClassHelpers__NS__asyncHandler)(async (req, res, next) => {
|
|
1621
|
-
if (req.originalUrl.startsWith(`${this.uriPathnameOrNothingIfRoot}/${constants_1.apiPrefix}/${this.contextName}/`)) {
|
|
1622
|
-
await middlewareInstance.interceptServer({
|
|
1623
|
-
req,
|
|
1624
|
-
res,
|
|
1625
|
-
next,
|
|
1626
|
-
});
|
|
1627
|
-
}
|
|
1628
|
-
else {
|
|
1629
|
-
next();
|
|
1630
|
-
}
|
|
1631
|
-
});
|
|
1632
|
-
app.use(middlewareFn);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
//#endregion
|
|
1636
|
-
}
|
|
1637
|
-
async initBackendMiddlewares() {
|
|
1638
|
-
//#region @backend
|
|
1639
|
-
const app = this.expressApp;
|
|
1640
|
-
// if (this.middlewares) {
|
|
1641
|
-
// this.middlewares.forEach(m => {
|
|
1642
|
-
// const [fun, args] = m;
|
|
1643
|
-
// app.use(fun.apply(null, args));
|
|
1644
|
-
// });
|
|
1645
|
-
// }
|
|
1646
|
-
this.expressApp.get('/helloworld', (req, res) => {
|
|
1647
|
-
res.send(`Hello, world from context ${this.contextName}`);
|
|
1648
|
-
});
|
|
1649
|
-
// app.use(fileUpload());
|
|
1650
|
-
app.use(bodyParser.urlencoded({ extended: true }));
|
|
1651
|
-
app.use(bodyParser.json());
|
|
1652
|
-
app.use(methodOverride());
|
|
1653
|
-
app.use(cookieParser());
|
|
1654
|
-
if (this.session) {
|
|
1655
|
-
(0, lib_prod_12.Helpers__NS__info)('[taon][express-server] session enabled for this context ' +
|
|
1656
|
-
this.contextName);
|
|
1657
|
-
const { cookieMaxAge } = this.session;
|
|
1658
|
-
const frontendHost = this.config.frontendHost;
|
|
1659
|
-
const sessionObj = {
|
|
1660
|
-
frontendHost,
|
|
1661
|
-
secret: 'mysecretsessioncookithing',
|
|
1662
|
-
saveUninitialized: true,
|
|
1663
|
-
cookieMaxAge,
|
|
1664
|
-
secure: frontendHost.startsWith('https://'),
|
|
1665
|
-
resave: false,
|
|
1666
|
-
};
|
|
1667
|
-
app.use(cors({
|
|
1668
|
-
credentials: true,
|
|
1669
|
-
origin: frontendHost,
|
|
1670
|
-
}));
|
|
1671
|
-
app.use(expressSession(sessionObj));
|
|
1672
|
-
console.log(`
|
|
1673
|
-
|
|
1674
|
-
CORS ENABLED FOR SESSION
|
|
1675
|
-
|
|
1676
|
-
`);
|
|
1677
|
-
}
|
|
1678
|
-
else {
|
|
1679
|
-
// if(this.config?.serverLogs) {
|
|
1680
|
-
this.logHttp &&
|
|
1681
|
-
(0, lib_prod_12.Helpers__NS__info)(`[taon][express-server] session not enabled for this context '${this.contextName}'`);
|
|
1682
|
-
// }
|
|
1683
|
-
app.use(cors({
|
|
1684
|
-
// origin: "http://localhost:5555",
|
|
1685
|
-
// methods: ["GET", "POST"],
|
|
1686
|
-
// allowedHeaders: ["my-custom-header"],
|
|
1687
|
-
// credentials: true
|
|
1688
|
-
}));
|
|
1689
|
-
this.logHttp &&
|
|
1690
|
-
console.log(`
|
|
1691
|
-
|
|
1692
|
-
CORS ENABLED WITHOUT SESSION
|
|
1693
|
-
|
|
1694
|
-
`);
|
|
1695
|
-
}
|
|
1696
|
-
(() => {
|
|
1697
|
-
app.use((req, res, next) => {
|
|
1698
|
-
//#region good for cors session obj
|
|
1699
|
-
// if (this.context.session) {
|
|
1700
|
-
// res.header('Access-Control-Allow-Origin', this.context.session.frontendHost);
|
|
1701
|
-
// res.header('Access-Control-Allow-Credentials', 'true');
|
|
1702
|
-
// res.header(
|
|
1703
|
-
// 'Access-Control-Allow-Headers',
|
|
1704
|
-
// 'Origin, X-Requested-With, Content-Type, Accept'
|
|
1705
|
-
// );
|
|
1706
|
-
// res.header("Access-Control-Allow-Methods", "PUT,POST,GET,HEAD,DELETE,OPTIONS,PATCH");
|
|
1707
|
-
// // maybe this
|
|
1708
|
-
// res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
|
|
1709
|
-
// }
|
|
1710
|
-
//#endregion
|
|
1711
|
-
res.set('Access-Control-Expose-Headers', [
|
|
1712
|
-
'Content-Type',
|
|
1713
|
-
'Authorization',
|
|
1714
|
-
'X-Requested-With',
|
|
1715
|
-
symbols_1.Symbols__NS__old.X_TOTAL_COUNT,
|
|
1716
|
-
symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER,
|
|
1717
|
-
symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY,
|
|
1718
|
-
symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM,
|
|
1719
|
-
].join(', '));
|
|
1720
|
-
next();
|
|
1721
|
-
});
|
|
1722
|
-
})();
|
|
1723
|
-
//#endregion
|
|
1724
|
-
}
|
|
1725
|
-
//#endregion
|
|
1726
|
-
//#region methods & getters / init methods node
|
|
1727
|
-
initServer(
|
|
1728
|
-
//#region parameters
|
|
1729
|
-
httpMethodType, methodConfig, classConfig, expressPath, target) {
|
|
1730
|
-
//#region resolve variables
|
|
1731
|
-
// console.log(
|
|
1732
|
-
// `CLIENT: expressPath: "${expressPath}" interceptor for method: ${methodConfig.calculatedMiddlewares.length}`,
|
|
1733
|
-
// );
|
|
1734
|
-
const middlewareHandlers = methodConfig.calculatedMiddlewares
|
|
1735
|
-
.map(middlewareClassFun => {
|
|
1736
|
-
const middlewareInstance = this.getInstanceBy(middlewareClassFun);
|
|
1737
|
-
if (middlewareInstance &&
|
|
1738
|
-
(0, lib_prod_12.___NS__isFunction)(middlewareInstance.interceptServerMethod)) {
|
|
1739
|
-
const middlewareFn = (0, class_helpers_1.ClassHelpers__NS__asyncHandler)(async (req, res, next) => {
|
|
1740
|
-
await middlewareInstance.interceptServerMethod({
|
|
1741
|
-
req,
|
|
1742
|
-
res,
|
|
1743
|
-
next,
|
|
1744
|
-
}, {
|
|
1745
|
-
methodName: methodConfig.methodName,
|
|
1746
|
-
expressPath,
|
|
1747
|
-
httpRequestType: methodConfig.type,
|
|
1748
|
-
});
|
|
1749
|
-
});
|
|
1750
|
-
return middlewareFn;
|
|
1751
|
-
}
|
|
1752
|
-
})
|
|
1753
|
-
.filter(f => !!f);
|
|
1754
|
-
// const url = this.uri;
|
|
1755
|
-
//#region get result
|
|
1756
|
-
const getResult = async (resolvedParams, req, res) => {
|
|
1757
|
-
const response = methodConfig.descriptor.value.apply(
|
|
1758
|
-
/**
|
|
1759
|
-
* Context for method @GET,@PUT etc.
|
|
1760
|
-
*/
|
|
1761
|
-
this.getInstanceBy(target),
|
|
1762
|
-
/**
|
|
1763
|
-
* Params for method @GET, @PUT etc.
|
|
1764
|
-
*/
|
|
1765
|
-
resolvedParams);
|
|
1766
|
-
let result = await (0, get_response_value_1.getResponseValue)(response, { req, res });
|
|
1767
|
-
return result;
|
|
1768
|
-
};
|
|
1769
|
-
//#endregion
|
|
1770
|
-
// console.log(`BACKEND: expressPath: "${expressPath}" `);
|
|
1771
|
-
//#endregion
|
|
1772
|
-
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
1773
|
-
//#region @backend
|
|
1774
|
-
const ipcKeyName = (0, taon_helpers_1.TaonHelpers__NS__ipcKeyNameRequest)(target, methodConfig, expressPath);
|
|
1775
|
-
electron_1.ipcMain.on(ipcKeyName, async (event, paramsFromBrowser) => {
|
|
1776
|
-
const responseJsonData = await getResult(paramsFromBrowser, void 0, void 0);
|
|
1777
|
-
const sendToIpsMainOn = (0, taon_helpers_1.TaonHelpers__NS__ipcKeyNameResponse)(target, methodConfig, expressPath);
|
|
1778
|
-
// console.log({ sendToIpsMainOn });
|
|
1779
|
-
event.sender.send(sendToIpsMainOn, responseJsonData);
|
|
1780
|
-
});
|
|
1781
|
-
return {
|
|
1782
|
-
expressPath,
|
|
1783
|
-
method: methodConfig.type,
|
|
1784
|
-
};
|
|
1785
|
-
//#endregion
|
|
1786
|
-
}
|
|
1787
|
-
if (!this.isRemoteHost) {
|
|
1788
|
-
//#region apply dummy websql express routers
|
|
1789
|
-
//#region @websql
|
|
1790
|
-
if (lib_prod_10.UtilsOs__NS__isWebSQL) {
|
|
1791
|
-
if (!this.expressApp[httpMethodType.toLowerCase()]) {
|
|
1792
|
-
this.expressApp[httpMethodType.toLowerCase()] = () => { };
|
|
1793
|
-
// TODO add middlewares for WEBSQL and ELECTRON mode
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
//#endregion
|
|
1797
|
-
//#endregion
|
|
1798
|
-
//#region @backend
|
|
1799
|
-
// this.logHttp &&
|
|
1800
|
-
// console.log(`[${httpMethodType.toUpperCase()}] ${expressPath} `);
|
|
1801
|
-
this.expressApp[httpMethodType.toLowerCase()](expressPath, ...middlewareHandlers, async (req, res) => {
|
|
1802
|
-
// console.log(`[${type.toUpperCase()}] ${expressPath} `);
|
|
1803
|
-
//#region process params
|
|
1804
|
-
const args = [];
|
|
1805
|
-
let tBody = req.body;
|
|
1806
|
-
let tParams = req.params;
|
|
1807
|
-
let tQuery = req.query;
|
|
1808
|
-
if (req.headers[symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY]) {
|
|
1809
|
-
try {
|
|
1810
|
-
tBody = JSON.parse(JSON.stringify(tBody), JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY])));
|
|
1811
|
-
}
|
|
1812
|
-
catch (e) { }
|
|
1813
|
-
}
|
|
1814
|
-
if (req.headers[symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM]) {
|
|
1815
|
-
try {
|
|
1816
|
-
tQuery = JSON.parse(JSON.stringify(tQuery), JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM])));
|
|
1817
|
-
}
|
|
1818
|
-
catch (e) { }
|
|
1819
|
-
}
|
|
1820
|
-
// make class instance from body
|
|
1821
|
-
// console.log('req.headers', req.headers)
|
|
1822
|
-
if (req.headers[symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS]) {
|
|
1823
|
-
try {
|
|
1824
|
-
const entity = JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS]));
|
|
1825
|
-
tBody = (0, lib_prod_3.Mapping__NS__encode)(tBody, entity);
|
|
1826
|
-
}
|
|
1827
|
-
catch (e) { }
|
|
1828
|
-
}
|
|
1829
|
-
else {
|
|
1830
|
-
Object.keys(tBody).forEach(paramName => {
|
|
1831
|
-
try {
|
|
1832
|
-
const entityForParam = JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[`${symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${paramName} `]));
|
|
1833
|
-
tBody[paramName] = (0, lib_prod_3.Mapping__NS__encode)(tBody[paramName], entityForParam);
|
|
1834
|
-
}
|
|
1835
|
-
catch (e) { }
|
|
1836
|
-
});
|
|
1837
|
-
}
|
|
1838
|
-
// make class instance from query params
|
|
1839
|
-
// console.log('req.headers', tQuery)
|
|
1840
|
-
if (req.headers[symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]) {
|
|
1841
|
-
try {
|
|
1842
|
-
const entity = JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS]));
|
|
1843
|
-
tQuery = (0, taon_helpers_1.TaonHelpers__NS__parseJSONwithStringJSONs)((0, lib_prod_3.Mapping__NS__encode)(tQuery, entity));
|
|
1844
|
-
}
|
|
1845
|
-
catch (e) { }
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
Object.keys(tQuery).forEach(queryParamName => {
|
|
1849
|
-
try {
|
|
1850
|
-
const entityForParam = JSON.parse((0, taon_helpers_1.TaonHelpers__NS__firstStringOrElemFromArray)(req.headers[`${symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${queryParamName} `]));
|
|
1851
|
-
let beforeTransofrm = tQuery[queryParamName];
|
|
1852
|
-
if ((0, lib_prod_12.___NS__isString)(beforeTransofrm)) {
|
|
1853
|
-
try {
|
|
1854
|
-
const paresed = (0, taon_helpers_1.TaonHelpers__NS__tryTransformParam)(beforeTransofrm);
|
|
1855
|
-
beforeTransofrm = paresed;
|
|
1856
|
-
}
|
|
1857
|
-
catch (e) { }
|
|
1858
|
-
}
|
|
1859
|
-
const afterEncoding = (0, lib_prod_3.Mapping__NS__encode)(beforeTransofrm, entityForParam);
|
|
1860
|
-
tQuery[queryParamName] =
|
|
1861
|
-
(0, taon_helpers_1.TaonHelpers__NS__parseJSONwithStringJSONs)(afterEncoding);
|
|
1862
|
-
}
|
|
1863
|
-
catch (e) { }
|
|
1864
|
-
});
|
|
1865
|
-
}
|
|
1866
|
-
Object.keys(methodConfig.parameters).forEach(paramName => {
|
|
1867
|
-
let p = methodConfig.parameters[paramName];
|
|
1868
|
-
if (p.paramType === 'Path' && tParams) {
|
|
1869
|
-
args.push(tParams[p.paramName]);
|
|
1870
|
-
}
|
|
1871
|
-
if (p.paramType === 'Query' && tQuery) {
|
|
1872
|
-
if (p.paramName) {
|
|
1873
|
-
args.push(tQuery[p.paramName]);
|
|
1874
|
-
}
|
|
1875
|
-
else {
|
|
1876
|
-
args.push(tQuery);
|
|
1877
|
-
}
|
|
1878
|
-
}
|
|
1879
|
-
if (p.paramType === 'Header' && req.headers) {
|
|
1880
|
-
args.push(req.headers[p.paramName.toLowerCase()]);
|
|
1881
|
-
}
|
|
1882
|
-
if (p.paramType === 'Cookie' && req.cookies) {
|
|
1883
|
-
args.push(req.cookies[p.paramName]);
|
|
1884
|
-
}
|
|
1885
|
-
if (p.paramType === 'Body' && tBody) {
|
|
1886
|
-
if (p.paramName && typeof tBody === 'object') {
|
|
1887
|
-
args.push(tBody[p.paramName]);
|
|
1888
|
-
}
|
|
1889
|
-
else {
|
|
1890
|
-
args.push(tBody);
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
});
|
|
1894
|
-
//#endregion
|
|
1895
|
-
const resolvedParams = args
|
|
1896
|
-
.reverse()
|
|
1897
|
-
.map(v => (0, taon_helpers_1.TaonHelpers__NS__tryTransformParam)(v));
|
|
1898
|
-
try {
|
|
1899
|
-
let result = await getResult(resolvedParams, req, res);
|
|
1900
|
-
if (methodConfig.responseType)
|
|
1901
|
-
if (res.headersSent) {
|
|
1902
|
-
// SKIP FURTHER PROCESSING IF RESPONSE ALREADY SENT
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
if (methodConfig.overrideExpressSendAsHtml) {
|
|
1906
|
-
res.setHeader('Content-Type', 'text/html');
|
|
1907
|
-
res.send(result);
|
|
1908
|
-
return;
|
|
1909
|
-
}
|
|
1910
|
-
if (result instanceof Blob &&
|
|
1911
|
-
methodConfig.responseType ===
|
|
1912
|
-
'blob') {
|
|
1913
|
-
// console.log('INSTANCE OF BLOB')
|
|
1914
|
-
//#region processs blob result type
|
|
1915
|
-
const blob = result;
|
|
1916
|
-
const file = Buffer.from(await blob.arrayBuffer());
|
|
1917
|
-
res.writeHead(200, {
|
|
1918
|
-
'Content-Type': blob.type,
|
|
1919
|
-
'Content-Length': file.length,
|
|
1920
|
-
});
|
|
1921
|
-
res.end(file);
|
|
1922
|
-
//#endregion
|
|
1923
|
-
}
|
|
1924
|
-
else if ((0, lib_prod_12.___NS__isString)(result) &&
|
|
1925
|
-
methodConfig.responseType ===
|
|
1926
|
-
'blob') {
|
|
1927
|
-
// console.log('BASE64')
|
|
1928
|
-
//#region process string buffer TODO refacetor
|
|
1929
|
-
const img_base64 = result;
|
|
1930
|
-
const m = /^data:(.+?);base64,(.+)$/.exec(img_base64);
|
|
1931
|
-
if (!m) {
|
|
1932
|
-
throw new Error(`[taon - framework] Not a base64 image[${img_base64}]`);
|
|
1933
|
-
}
|
|
1934
|
-
const [_, content_type, file_base64] = m;
|
|
1935
|
-
const file = Buffer.from(file_base64, 'base64');
|
|
1936
|
-
res.writeHead(200, {
|
|
1937
|
-
'Content-Type': content_type,
|
|
1938
|
-
'Content-Length': file.length,
|
|
1939
|
-
});
|
|
1940
|
-
res.end(file);
|
|
1941
|
-
//#endregion
|
|
1942
|
-
}
|
|
1943
|
-
else {
|
|
1944
|
-
//#region process json request
|
|
1945
|
-
await entity_process_1.EntityProcess.init(result, res);
|
|
1946
|
-
//#endregion
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
catch (error) {
|
|
1950
|
-
if (res.headersSent) {
|
|
1951
|
-
// SKIP FURTHER PROCESSING IF RESPONSE ALREADY SENT
|
|
1952
|
-
return;
|
|
1953
|
-
}
|
|
1954
|
-
if (methodConfig.overrideExpressSendAsHtml) {
|
|
1955
|
-
res.setHeader('Content-Type', 'text/html');
|
|
1956
|
-
res.send(error);
|
|
1957
|
-
return;
|
|
1958
|
-
}
|
|
1959
|
-
this.sendError(res, error, req, expressPath);
|
|
1960
|
-
}
|
|
1961
|
-
});
|
|
1962
|
-
//#endregion
|
|
1963
|
-
}
|
|
1964
|
-
return {
|
|
1965
|
-
expressPath: expressPath,
|
|
1966
|
-
method: methodConfig.type,
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
//#endregion
|
|
1970
|
-
//#region methods & getters / send error
|
|
1971
|
-
sendError(res, error, req, expressPath) {
|
|
1972
|
-
//#region @backendFunc
|
|
1973
|
-
let status = 500;
|
|
1974
|
-
let message = 'Internal Server Error';
|
|
1975
|
-
let details = undefined;
|
|
1976
|
-
let success = false;
|
|
1977
|
-
let code = undefined;
|
|
1978
|
-
if (typeof error === 'function') {
|
|
1979
|
-
const obj = error(res) || {};
|
|
1980
|
-
status = obj.status || 400;
|
|
1981
|
-
message = obj.message;
|
|
1982
|
-
details = obj.details;
|
|
1983
|
-
code = obj.code;
|
|
1984
|
-
}
|
|
1985
|
-
else if (typeof error === 'string') {
|
|
1986
|
-
message = error;
|
|
1987
|
-
status = 400;
|
|
1988
|
-
}
|
|
1989
|
-
else if (error instanceof Error) {
|
|
1990
|
-
message = error.message;
|
|
1991
|
-
details = process.env.NODE_ENV !== 'production' ? error.stack : undefined;
|
|
1992
|
-
}
|
|
1993
|
-
else {
|
|
1994
|
-
message = 'Unexpected error';
|
|
1995
|
-
details = error;
|
|
1996
|
-
}
|
|
1997
|
-
res.status(status).json({
|
|
1998
|
-
success,
|
|
1999
|
-
message,
|
|
2000
|
-
details,
|
|
2001
|
-
code,
|
|
2002
|
-
[lib_prod_8.CoreModels__NS__TaonHttpErrorCustomProp]: true,
|
|
2003
|
-
});
|
|
2004
|
-
//#endregion
|
|
2005
|
-
}
|
|
2006
|
-
//#endregion
|
|
2007
|
-
//#region methods & getters / init client
|
|
2008
|
-
/**
|
|
2009
|
-
* client can be browser or nodejs (when remote host)
|
|
2010
|
-
*/
|
|
2011
|
-
async initClient(target, httpRequestType, methodConfig, // Models.Http.Rest.MethodConfig,
|
|
2012
|
-
expressPath) {
|
|
2013
|
-
const ctx = this;
|
|
2014
|
-
// console.log(
|
|
2015
|
-
// `CLIENT: expressPath: "${expressPath}" interceptor for method: ${methodConfig.calculatedMiddlewares?.length} `,
|
|
2016
|
-
// );
|
|
2017
|
-
//#region init middlewares
|
|
2018
|
-
const middlewares = methodConfig.calculatedMiddlewares;
|
|
2019
|
-
const middlewaresInstances = middlewares
|
|
2020
|
-
.map(f => this.getInstanceBy(f))
|
|
2021
|
-
.filter(f => (0, lib_prod_12.___NS__isFunction)(f.interceptClientMethod));
|
|
2022
|
-
middlewaresInstances.forEach(instance => {
|
|
2023
|
-
const middlewareName = (0, class_helpers_1.ClassHelpers__NS__getName)(instance);
|
|
2024
|
-
// middlewareName - only needed for inheritace and uniqness of interceptors
|
|
2025
|
-
const interceptorKey = `${middlewareName}-${methodConfig.type?.toUpperCase()}-${expressPath}`;
|
|
2026
|
-
lib_prod_3.Resource.request.methodsInterceptors.set(interceptorKey, {
|
|
2027
|
-
intercept: ({ req, next }) => {
|
|
2028
|
-
return instance.interceptClientMethod({
|
|
2029
|
-
req,
|
|
2030
|
-
next,
|
|
2031
|
-
}, {
|
|
2032
|
-
methodName: methodConfig.methodName,
|
|
2033
|
-
expressPath,
|
|
2034
|
-
httpRequestType: httpRequestType,
|
|
2035
|
-
});
|
|
2036
|
-
},
|
|
2037
|
-
});
|
|
2038
|
-
});
|
|
2039
|
-
//#endregion
|
|
2040
|
-
// : { received: any; /* Rest<any, any> */ }
|
|
2041
|
-
// this.logHttp &&
|
|
2042
|
-
// console.log(`${httpRequestType?.toUpperCase()} ${expressPath} `);
|
|
2043
|
-
// console.log('INITING', methodConfig); // TODO inject in static
|
|
2044
|
-
//#region resolve storage
|
|
2045
|
-
// TODO not a good idea
|
|
2046
|
-
const storage = globalThis;
|
|
2047
|
-
//#endregion
|
|
2048
|
-
const orgMethods = target.prototype[methodConfig.methodName];
|
|
2049
|
-
//#region handle electron ipc request
|
|
2050
|
-
if (lib_prod_10.UtilsOs__NS__isElectron) {
|
|
2051
|
-
const ipcRenderer = window.require('electron').ipcRenderer;
|
|
2052
|
-
target.prototype[methodConfig.methodName] = function (...args) {
|
|
2053
|
-
const received = new Promise(async (resolve, reject) => {
|
|
2054
|
-
const headers = {};
|
|
2055
|
-
const { request, response } = (0, taon_helpers_1.TaonHelpers__NS__websqlMocks)(headers);
|
|
2056
|
-
/* */
|
|
2057
|
-
/* */
|
|
2058
|
-
/* */
|
|
2059
|
-
/* */
|
|
2060
|
-
/* */
|
|
2061
|
-
/* */
|
|
2062
|
-
/* */
|
|
2063
|
-
/* */
|
|
2064
|
-
/* */
|
|
2065
|
-
/* */
|
|
2066
|
-
/* */
|
|
2067
|
-
/* */
|
|
2068
|
-
/* */
|
|
2069
|
-
/* */
|
|
2070
|
-
/* */
|
|
2071
|
-
/* */
|
|
2072
|
-
/* */
|
|
2073
|
-
/* */
|
|
2074
|
-
/* */
|
|
2075
|
-
/* */
|
|
2076
|
-
/* */
|
|
2077
|
-
/* */
|
|
2078
|
-
/* */
|
|
2079
|
-
/* */
|
|
2080
|
-
/* */
|
|
2081
|
-
/* */
|
|
2082
|
-
/* */
|
|
2083
|
-
/* */
|
|
2084
|
-
/* */
|
|
2085
|
-
/* */
|
|
2086
|
-
/* */
|
|
2087
|
-
/* */
|
|
2088
|
-
/* */
|
|
2089
|
-
/* */
|
|
2090
|
-
/* */
|
|
2091
|
-
/* */
|
|
2092
|
-
});
|
|
2093
|
-
received['observable'] = (0, rxjs_1.from)(received);
|
|
2094
|
-
return {
|
|
2095
|
-
received,
|
|
2096
|
-
request(axiosConfig) {
|
|
2097
|
-
return received;
|
|
2098
|
-
},
|
|
2099
|
-
};
|
|
2100
|
-
};
|
|
2101
|
-
return;
|
|
2102
|
-
}
|
|
2103
|
-
//#endregion
|
|
2104
|
-
//#region handling web sql request
|
|
2105
|
-
/* */
|
|
2106
|
-
/* */
|
|
2107
|
-
/* */
|
|
2108
|
-
/* */
|
|
2109
|
-
/* */
|
|
2110
|
-
/* */
|
|
2111
|
-
/* */
|
|
2112
|
-
/* */
|
|
2113
|
-
/* */
|
|
2114
|
-
/* */
|
|
2115
|
-
/* */
|
|
2116
|
-
/* */
|
|
2117
|
-
/* */
|
|
2118
|
-
/* */
|
|
2119
|
-
/* */
|
|
2120
|
-
/* */
|
|
2121
|
-
/* */
|
|
2122
|
-
/* */
|
|
2123
|
-
/* */
|
|
2124
|
-
/* */
|
|
2125
|
-
/* */
|
|
2126
|
-
/* */
|
|
2127
|
-
/* */
|
|
2128
|
-
/* */
|
|
2129
|
-
/* */
|
|
2130
|
-
/* */
|
|
2131
|
-
/* */
|
|
2132
|
-
/* */
|
|
2133
|
-
/* */
|
|
2134
|
-
/* */
|
|
2135
|
-
/* */
|
|
2136
|
-
/* */
|
|
2137
|
-
/* */
|
|
2138
|
-
/* */
|
|
2139
|
-
/* */
|
|
2140
|
-
/* */
|
|
2141
|
-
/* */
|
|
2142
|
-
/* */
|
|
2143
|
-
/* */
|
|
2144
|
-
/* */
|
|
2145
|
-
/* */
|
|
2146
|
-
/* */
|
|
2147
|
-
/* */
|
|
2148
|
-
/* */
|
|
2149
|
-
/* */
|
|
2150
|
-
/* */
|
|
2151
|
-
/* */
|
|
2152
|
-
/* */
|
|
2153
|
-
/* */
|
|
2154
|
-
/* */
|
|
2155
|
-
/* */
|
|
2156
|
-
/* */
|
|
2157
|
-
/* */
|
|
2158
|
-
/* */
|
|
2159
|
-
/* */
|
|
2160
|
-
/* */
|
|
2161
|
-
/* */
|
|
2162
|
-
/* */
|
|
2163
|
-
/* */
|
|
2164
|
-
/* */
|
|
2165
|
-
/* */
|
|
2166
|
-
/* */
|
|
2167
|
-
/* */
|
|
2168
|
-
/* */
|
|
2169
|
-
/* */
|
|
2170
|
-
/* */
|
|
2171
|
-
/* */
|
|
2172
|
-
/* */
|
|
2173
|
-
/* */
|
|
2174
|
-
/* */
|
|
2175
|
-
/* */
|
|
2176
|
-
/* */
|
|
2177
|
-
/* */
|
|
2178
|
-
/* */
|
|
2179
|
-
/* */
|
|
2180
|
-
/* */
|
|
2181
|
-
/* */
|
|
2182
|
-
/* */
|
|
2183
|
-
/* */
|
|
2184
|
-
/* */
|
|
2185
|
-
/* */
|
|
2186
|
-
/* */
|
|
2187
|
-
/* */
|
|
2188
|
-
/* */
|
|
2189
|
-
/* */
|
|
2190
|
-
/* */
|
|
2191
|
-
/* */
|
|
2192
|
-
/* */
|
|
2193
|
-
/* */
|
|
2194
|
-
/* */
|
|
2195
|
-
/* */
|
|
2196
|
-
/* */
|
|
2197
|
-
/* */
|
|
2198
|
-
/* */
|
|
2199
|
-
/* */
|
|
2200
|
-
/* */
|
|
2201
|
-
/* */
|
|
2202
|
-
/* */
|
|
2203
|
-
/* */
|
|
2204
|
-
/* */
|
|
2205
|
-
/* */
|
|
2206
|
-
/* */
|
|
2207
|
-
/* */
|
|
2208
|
-
/* */
|
|
2209
|
-
/* */
|
|
2210
|
-
/* */
|
|
2211
|
-
/* */
|
|
2212
|
-
/* */
|
|
2213
|
-
/* */
|
|
2214
|
-
/* */
|
|
2215
|
-
/* */
|
|
2216
|
-
/* */
|
|
2217
|
-
/* */
|
|
2218
|
-
/* */
|
|
2219
|
-
/* */
|
|
2220
|
-
/* */
|
|
2221
|
-
/* */
|
|
2222
|
-
/* */
|
|
2223
|
-
/* */
|
|
2224
|
-
/* */
|
|
2225
|
-
/* */
|
|
2226
|
-
/* */
|
|
2227
|
-
/* */
|
|
2228
|
-
/* */
|
|
2229
|
-
/* */
|
|
2230
|
-
/* */
|
|
2231
|
-
/* */
|
|
2232
|
-
/* */
|
|
2233
|
-
/* */
|
|
2234
|
-
/* */
|
|
2235
|
-
/* */
|
|
2236
|
-
/* */
|
|
2237
|
-
/* */
|
|
2238
|
-
/* */
|
|
2239
|
-
/* */
|
|
2240
|
-
/* */
|
|
2241
|
-
/* */
|
|
2242
|
-
/* */
|
|
2243
|
-
/* */
|
|
2244
|
-
/* */
|
|
2245
|
-
/* */
|
|
2246
|
-
/* */
|
|
2247
|
-
/* */
|
|
2248
|
-
/* */
|
|
2249
|
-
/* */
|
|
2250
|
-
/* */
|
|
2251
|
-
/* */
|
|
2252
|
-
/* */
|
|
2253
|
-
/* */
|
|
2254
|
-
/* */
|
|
2255
|
-
//#endregion
|
|
2256
|
-
//#region handle normal request
|
|
2257
|
-
target.prototype[methodConfig.methodName] = function (...args) {
|
|
2258
|
-
// console.log('[init method browser] FRONTEND expressPath', expressPath)
|
|
2259
|
-
// const productionMode = FrameworkContext.isProductionMode;
|
|
2260
|
-
//#region resolve frontend parameters
|
|
2261
|
-
if (!storage[symbols_1.Symbols__NS__old.ENDPOINT_META_CONFIG])
|
|
2262
|
-
storage[symbols_1.Symbols__NS__old.ENDPOINT_META_CONFIG] = {};
|
|
2263
|
-
if (!storage[symbols_1.Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin])
|
|
2264
|
-
storage[symbols_1.Symbols__NS__old.ENDPOINT_META_CONFIG][ctx.uriOrigin] = {};
|
|
2265
|
-
const endpoints = storage[symbols_1.Symbols__NS__old.ENDPOINT_META_CONFIG];
|
|
2266
|
-
let rest;
|
|
2267
|
-
if (!endpoints[ctx.uriOrigin][expressPath]) {
|
|
2268
|
-
let headers = {};
|
|
2269
|
-
if (methodConfig.contentType && !methodConfig.responseType) {
|
|
2270
|
-
rest = lib_prod_3.Resource.create(ctx.uriOrigin, expressPath, symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER, symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, lib_prod_3.RestHeaders.from({
|
|
2271
|
-
'Content-Type': methodConfig.contentType,
|
|
2272
|
-
Accept: methodConfig.contentType,
|
|
2273
|
-
}));
|
|
2274
|
-
}
|
|
2275
|
-
else if (methodConfig.contentType && methodConfig.responseType) {
|
|
2276
|
-
rest = lib_prod_3.Resource.create(ctx.uriOrigin, expressPath, symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER, symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, lib_prod_3.RestHeaders.from({
|
|
2277
|
-
'Content-Type': methodConfig.contentType,
|
|
2278
|
-
Accept: methodConfig.contentType,
|
|
2279
|
-
responsetypeaxios: methodConfig.responseType,
|
|
2280
|
-
}));
|
|
2281
|
-
}
|
|
2282
|
-
else if (!methodConfig.contentType && methodConfig.responseType) {
|
|
2283
|
-
rest = lib_prod_3.Resource.create(ctx.uriOrigin, expressPath, symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER, symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, lib_prod_3.RestHeaders.from({
|
|
2284
|
-
responsetypeaxios: methodConfig.responseType,
|
|
2285
|
-
}));
|
|
2286
|
-
}
|
|
2287
|
-
else {
|
|
2288
|
-
rest = lib_prod_3.Resource.create(ctx.uriOrigin, expressPath, symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER, symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY);
|
|
2289
|
-
}
|
|
2290
|
-
endpoints[ctx.uriOrigin][expressPath] = rest;
|
|
2291
|
-
}
|
|
2292
|
-
else {
|
|
2293
|
-
rest = endpoints[ctx.uriOrigin][expressPath];
|
|
2294
|
-
}
|
|
2295
|
-
const method = httpRequestType.toLowerCase();
|
|
2296
|
-
const pathPrams = {};
|
|
2297
|
-
let queryParams = {};
|
|
2298
|
-
let bodyObject = {};
|
|
2299
|
-
args.forEach((param, i) => {
|
|
2300
|
-
let currentParam = void 0;
|
|
2301
|
-
for (let pp in methodConfig.parameters) {
|
|
2302
|
-
let v = methodConfig.parameters[pp];
|
|
2303
|
-
if (v.index === i) {
|
|
2304
|
-
currentParam = v;
|
|
2305
|
-
break;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
if (!currentParam) {
|
|
2309
|
-
const errorMessage = `[${lib_prod_7.config.frameworkName}] Unable to resolve parameter` +
|
|
2310
|
-
` at index ${i} for method ${methodConfig.methodName} at path ${expressPath}.`;
|
|
2311
|
-
//#region @backend
|
|
2312
|
-
console.error(errorMessage);
|
|
2313
|
-
process.exit(0);
|
|
2314
|
-
//#endregion
|
|
2315
|
-
throw new Error(errorMessage);
|
|
2316
|
-
}
|
|
2317
|
-
if (currentParam.paramType === 'Path') {
|
|
2318
|
-
pathPrams[currentParam.paramName] = param;
|
|
2319
|
-
}
|
|
2320
|
-
if (currentParam.paramType === 'Query') {
|
|
2321
|
-
if (currentParam.paramName) {
|
|
2322
|
-
const mapping = (0, lib_prod_3.Mapping__NS__decode)(param, !ctx.isProductionMode);
|
|
2323
|
-
if (mapping) {
|
|
2324
|
-
rest.headers.set(`${symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2325
|
-
}
|
|
2326
|
-
queryParams[currentParam.paramName] = param;
|
|
2327
|
-
}
|
|
2328
|
-
else {
|
|
2329
|
-
const mapping = (0, lib_prod_3.Mapping__NS__decode)(param, !ctx.isProductionMode);
|
|
2330
|
-
if (mapping) {
|
|
2331
|
-
rest.headers.set(symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_QUERY_PARAMS, JSON.stringify(mapping));
|
|
2332
|
-
}
|
|
2333
|
-
queryParams = (0, lib_prod_12.___NS__cloneDeep)(param);
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
if (currentParam.paramType === 'Header') {
|
|
2337
|
-
if (currentParam.paramName) {
|
|
2338
|
-
if (currentParam.paramName === symbols_1.Symbols__NS__old.MDC_KEY) {
|
|
2339
|
-
// parese MDC
|
|
2340
|
-
rest.headers.set(currentParam.paramName, encodeURIComponent(JSON.stringify(param)));
|
|
2341
|
-
}
|
|
2342
|
-
else {
|
|
2343
|
-
rest.headers.set(currentParam.paramName, param);
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
else {
|
|
2347
|
-
for (let header in param) {
|
|
2348
|
-
rest.headers.set(header, param[header]);
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
if (currentParam.paramType === 'Cookie') {
|
|
2353
|
-
lib_prod_3.Resource.Cookies.write(currentParam.paramName, param, currentParam.expireInSeconds);
|
|
2354
|
-
}
|
|
2355
|
-
if (currentParam.paramType === 'Body') {
|
|
2356
|
-
if (currentParam.paramName) {
|
|
2357
|
-
if ((0, class_helpers_1.ClassHelpers__NS__getName)(bodyObject) === 'FormData') {
|
|
2358
|
-
throw new Error(`[taon - framework] Don use param names when posting / putting FormData.
|
|
2359
|
-
Use this:
|
|
2360
|
-
// ...
|
|
2361
|
-
(@Taon.Http.Param.Body() formData: FormData) ...
|
|
2362
|
-
// ...
|
|
2363
|
-
|
|
2364
|
-
instead
|
|
2365
|
-
// ...
|
|
2366
|
-
(@Taon.Http.Param.Body('${currentParam.paramName}') formData: FormData) ...
|
|
2367
|
-
// ...
|
|
2368
|
-
`);
|
|
2369
|
-
}
|
|
2370
|
-
const mapping = (0, lib_prod_3.Mapping__NS__decode)(param, !ctx.isProductionMode);
|
|
2371
|
-
if (mapping) {
|
|
2372
|
-
rest.headers.set(`${symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS}${currentParam.paramName} `, JSON.stringify(mapping));
|
|
2373
|
-
}
|
|
2374
|
-
bodyObject[currentParam.paramName] = param;
|
|
2375
|
-
}
|
|
2376
|
-
else {
|
|
2377
|
-
const mapping = (0, lib_prod_3.Mapping__NS__decode)(param, !ctx.isProductionMode);
|
|
2378
|
-
if (mapping) {
|
|
2379
|
-
rest.headers.set(symbols_1.Symbols__NS__old.MAPPING_CONFIG_HEADER_BODY_PARAMS, JSON.stringify(mapping));
|
|
2380
|
-
}
|
|
2381
|
-
bodyObject = param;
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
});
|
|
2385
|
-
if (typeof bodyObject === 'object' &&
|
|
2386
|
-
(0, class_helpers_1.ClassHelpers__NS__getName)(bodyObject) !== 'FormData') {
|
|
2387
|
-
let circuralFromItem = [];
|
|
2388
|
-
bodyObject = lib_prod_1.JSON10.parse(lib_prod_1.JSON10.stringify(bodyObject, void 0, void 0, circs => {
|
|
2389
|
-
circuralFromItem = circs;
|
|
2390
|
-
}));
|
|
2391
|
-
rest.headers.set(symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_BODY, lib_prod_1.JSON10.stringify(circuralFromItem));
|
|
2392
|
-
}
|
|
2393
|
-
if (typeof queryParams === 'object') {
|
|
2394
|
-
let circuralFromQueryParams = [];
|
|
2395
|
-
queryParams = lib_prod_1.JSON10.parse(lib_prod_1.JSON10.stringify(queryParams, void 0, void 0, circs => {
|
|
2396
|
-
circuralFromQueryParams = circs;
|
|
2397
|
-
}));
|
|
2398
|
-
rest.headers.set(symbols_1.Symbols__NS__old.CIRCURAL_OBJECTS_MAP_QUERY_PARAM, lib_prod_1.JSON10.stringify(circuralFromQueryParams));
|
|
2399
|
-
}
|
|
2400
|
-
//#endregion
|
|
2401
|
-
const httpResultObj = {
|
|
2402
|
-
get received() {
|
|
2403
|
-
return rest.model(pathPrams)[method](bodyObject, [queryParams]);
|
|
2404
|
-
},
|
|
2405
|
-
request(axiosConfig) {
|
|
2406
|
-
return rest
|
|
2407
|
-
.model(pathPrams)[method](bodyObject, [queryParams], axiosConfig);
|
|
2408
|
-
},
|
|
2409
|
-
};
|
|
2410
|
-
return httpResultObj;
|
|
2411
|
-
};
|
|
2412
|
-
//#endregion
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
exports.EndpointContext = EndpointContext;
|
|
2416
|
-
//# sourceMappingURL=endpoint-context.js.map
|