From 2bc88e7a3dee3b5734ca0351e57af7d7360bd10c Mon Sep 17 00:00:00 2001 From: crusader Date: Mon, 31 Jul 2017 21:46:08 +0900 Subject: [PATCH] ing --- src/ts/@loafer/context/AppContext.ts | 8 + .../context/constants/index.ts | 0 src/ts/@loafer/context/constants/reflect.ts | 2 + .../context/decorator/Configuration.ts | 31 +++ .../@loafer/context/decorator/Injectable.ts | 30 +++ .../context/decorator/PostConstruct.ts | 16 ++ src/ts/@loafer/context/decorator/Pouch.ts | 18 ++ .../context/decorator/PouchConfig.ts | 0 .../@loafer/context/decorator/PreDestroy.ts | 16 ++ src/ts/@loafer/context/decorator/Scope.ts | 17 ++ src/ts/@loafer/context/decorator/Service.ts | 31 +++ .../definition/ConfigurationDefinition.ts | 32 +++ .../definition/InjectableDefinition.ts | 75 +++++++ .../context/implement/DefaultAppContext.ts | 30 +++ src/ts/@loafer/context/index.ts | 13 ++ .../context/redux/action/lifecycle.ts | 0 .../context/redux/saga/index.ts | 0 .../context/util/metadata/configuration.ts | 6 + .../context/util/metadata/index.ts | 1 + .../context/util/metadata/injectable.ts | 6 + .../core/constants/index.ts | 0 .../core/constants/reflect.ts | 0 .../core/constants/types.ts | 2 +- .../core}/util/decorators/createDecorator.ts | 0 .../core/util/metadata/getClassMetadata.ts | 23 +++ src/ts/@loafer/pouches/constants/index.ts | 5 + src/ts/@loafer/pouches/constants/reflect.ts | 1 + .../@loafer/pouches/constants/stereotype.ts | 11 + src/ts/@loafer/pouches/constants/types.ts | 4 + src/ts/@loafer/pouches/decorator/Inject.ts | 18 ++ .../pouches/decorator/InjectConfig.ts | 0 src/ts/@loafer/pouches/decorator/Value.ts | 17 ++ .../pouches/definition/InjectDefinition.ts} | 37 +++- .../@loafer/pouches/factory/PouchFactory.ts | 9 + .../pouches/factory/config/PouchDefinition.ts | 16 ++ .../factory/implement/DefaultPouchFactory.ts | 55 +++++ .../registry/PouchDefinitionRegistry.ts | 13 ++ .../pouches/util/metadata/index.ts | 1 - .../@loafer/pouches/util/metadata/inject.ts | 8 + src/ts/@overflow/apikey/redux/saga/read.ts | 39 ---- src/ts/@overflow/apikey/redux/saga/regist.ts | 39 ---- src/ts/@overflow/app/config/AppConfig.ts | 4 +- src/ts/@overflow/app/index.tsx | 4 +- src/ts/@overflow/commons/api/Service.ts | 2 +- .../@overflow/commons/context/AppContext.ts | 42 ---- .../context/config/ConfigurationDefinition.ts | 46 ----- .../commons/context/constants/reflect.ts | 2 - .../context/decorator/Configuration.ts | 20 -- .../commons/context/decorator/Pouch.ts | 21 -- .../context/pouches/config/PouchDefinition.ts | 59 ------ .../context/pouches/constants/index.ts | 2 - .../context/pouches/constants/reflect.ts | 5 - .../context/pouches/constants/types.ts | 7 - .../context/pouches/decorator/Inject.ts | 21 -- .../context/pouches/decorator/Injectable.ts | 21 -- .../pouches/decorator/PostConstruct.ts | 17 -- .../context/pouches/decorator/PreDestroy.ts | 17 -- .../context/pouches/decorator/Qualifier.ts | 21 -- .../context/pouches/decorator/Scope.ts | 18 -- .../context/pouches/factory/PouchFactory.ts | 194 ------------------ .../context/pouches/util/metadata/inject.ts | 8 - .../context/pouches/util/metadata/pouch.ts | 8 - .../context/util/metadata/configuration.ts | 9 - src/ts/@overflow/commons/redux-saga/index.ts | 3 - .../commons/redux/action/asyncRequest.ts | 22 ++ .../redux/payload/AsyncRequestPayload.ts | 10 + .../redux/saga/asyncRequest.ts} | 23 +-- .../commons/util/metadata/getClassMetadata.ts | 24 --- .../discovery/redux/saga/discovery.ts | 0 .../domain/redux/saga/member_regist.ts | 39 ---- src/ts/@overflow/domain/redux/saga/regist.ts | 39 ---- src/ts/@overflow/email/redux/saga/modify.ts | 44 ---- src/ts/@overflow/email/redux/saga/read.ts | 40 ---- .../email/redux/saga/read_by_auth_key.ts | 40 ---- .../email/redux/saga/read_by_member.ts | 40 ---- .../email/redux/saga/send_email_by_member.ts | 40 ---- src/ts/@overflow/history/redux/saga/_ | 0 .../@overflow/infra/redux/saga/host_read.ts | 39 ---- .../@overflow/infra/redux/saga/host_regist.ts | 39 ---- .../infra/redux/saga/machine_read.ts | 39 ---- .../infra/redux/saga/machine_regist.ts | 40 ---- .../infra/redux/saga/os_application_read.ts | 39 ---- .../infra/redux/saga/os_application_regist.ts | 39 ---- .../infra/redux/saga/os_daemon_read.ts | 39 ---- .../infra/redux/saga/os_daemon_regist.ts | 39 ---- .../infra/redux/saga/os_port_read.ts | 39 ---- .../infra/redux/saga/os_port_regist.ts | 39 ---- src/ts/@overflow/infra/redux/saga/os_read.ts | 39 ---- .../@overflow/infra/redux/saga/os_regist.ts | 39 ---- src/ts/@overflow/infra/redux/saga/read.ts | 39 ---- src/ts/@overflow/infra/redux/saga/regist.ts | 39 ---- .../infra/redux/saga/service_read.ts | 39 ---- .../infra/redux/saga/service_regist.ts | 39 ---- .../@overflow/member/redux/action/signIn.ts | 42 +--- src/ts/@overflow/member/redux/saga/modify.ts | 39 ---- src/ts/@overflow/member/redux/saga/read.ts | 39 ---- src/ts/@overflow/member/redux/saga/signOut.ts | 27 --- src/ts/@overflow/member/redux/saga/signUp.ts | 29 --- src/ts/@overflow/meta/redux/saga/_ | 0 .../@overflow/noauthprobe/redux/saga/read.ts | 39 ---- .../redux/saga/read_all_by_domain.ts | 39 ---- .../noauthprobe/redux/saga/regist.ts | 39 ---- .../probe/redux/saga/read_all_by_domain.ts | 31 --- .../probe/redux/saga/read_by_probekey.ts | 38 ---- src/ts/@overflow/probe/redux/saga/regist.ts | 38 ---- .../redux/saga/task_read_all_by_probe.ts | 37 ---- .../@overflow/probe/redux/saga/task_regist.ts | 38 ---- .../@overflow/sensor/redux/saga/item_read.ts | 38 ---- .../sensor/redux/saga/item_read_by_sensor.ts | 38 ---- .../sensor/redux/saga/item_regist.ts | 38 ---- .../sensor/redux/saga/item_remove.ts | 38 ---- src/ts/@overflow/sensor/redux/saga/read.ts | 38 ---- .../sensor/redux/saga/read_all_by_domain.ts | 38 ---- .../sensor/redux/saga/read_all_by_probe.ts | 38 ---- .../sensor/redux/saga/read_all_by_target.ts | 38 ---- src/ts/@overflow/sensor/redux/saga/regist.ts | 38 ---- src/ts/@overflow/sensor/redux/saga/remove.ts | 38 ---- src/ts/@overflow/sensor/redux/saga/start.ts | 38 ---- src/ts/@overflow/sensor/redux/saga/stop.ts | 38 ---- src/ts/@overflow/target/redux/saga/read.ts | 39 ---- .../target/redux/saga/read_all_by_probe.ts | 39 ---- src/ts/@overflow/target/redux/saga/regist.ts | 38 ---- .../redux/saga/regist_discovered_target.ts | 38 ---- src/ts/@overflow/target/redux/saga/remove.ts | 39 ---- 124 files changed, 593 insertions(+), 2698 deletions(-) create mode 100644 src/ts/@loafer/context/AppContext.ts rename src/ts/{@overflow/commons => @loafer}/context/constants/index.ts (100%) create mode 100644 src/ts/@loafer/context/constants/reflect.ts create mode 100644 src/ts/@loafer/context/decorator/Configuration.ts create mode 100644 src/ts/@loafer/context/decorator/Injectable.ts create mode 100644 src/ts/@loafer/context/decorator/PostConstruct.ts create mode 100644 src/ts/@loafer/context/decorator/Pouch.ts rename src/ts/{@overflow/commons => @loafer}/context/decorator/PouchConfig.ts (100%) create mode 100644 src/ts/@loafer/context/decorator/PreDestroy.ts create mode 100644 src/ts/@loafer/context/decorator/Scope.ts create mode 100644 src/ts/@loafer/context/decorator/Service.ts create mode 100644 src/ts/@loafer/context/definition/ConfigurationDefinition.ts create mode 100644 src/ts/@loafer/context/definition/InjectableDefinition.ts create mode 100644 src/ts/@loafer/context/implement/DefaultAppContext.ts create mode 100644 src/ts/@loafer/context/index.ts rename src/ts/{@overflow/commons => @loafer}/context/redux/action/lifecycle.ts (100%) rename src/ts/{@overflow/commons => @loafer}/context/redux/saga/index.ts (100%) create mode 100644 src/ts/@loafer/context/util/metadata/configuration.ts rename src/ts/{@overflow/commons => @loafer}/context/util/metadata/index.ts (52%) create mode 100644 src/ts/@loafer/context/util/metadata/injectable.ts rename src/ts/{@overflow/commons => @loafer}/core/constants/index.ts (100%) rename src/ts/{@overflow/commons => @loafer}/core/constants/reflect.ts (100%) rename src/ts/{@overflow/commons => @loafer}/core/constants/types.ts (56%) rename src/ts/{@overflow/commons => @loafer/core}/util/decorators/createDecorator.ts (100%) create mode 100644 src/ts/@loafer/core/util/metadata/getClassMetadata.ts create mode 100644 src/ts/@loafer/pouches/constants/index.ts create mode 100644 src/ts/@loafer/pouches/constants/reflect.ts create mode 100644 src/ts/@loafer/pouches/constants/stereotype.ts create mode 100644 src/ts/@loafer/pouches/constants/types.ts create mode 100644 src/ts/@loafer/pouches/decorator/Inject.ts rename src/ts/{@overflow/commons/context => @loafer}/pouches/decorator/InjectConfig.ts (100%) create mode 100644 src/ts/@loafer/pouches/decorator/Value.ts rename src/ts/{@overflow/commons/context/pouches/config/PouchInjectDefinition.ts => @loafer/pouches/definition/InjectDefinition.ts} (70%) create mode 100644 src/ts/@loafer/pouches/factory/PouchFactory.ts create mode 100644 src/ts/@loafer/pouches/factory/config/PouchDefinition.ts create mode 100644 src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts create mode 100644 src/ts/@loafer/pouches/factory/registry/PouchDefinitionRegistry.ts rename src/ts/{@overflow/commons/context => @loafer}/pouches/util/metadata/index.ts (50%) create mode 100644 src/ts/@loafer/pouches/util/metadata/inject.ts delete mode 100644 src/ts/@overflow/apikey/redux/saga/read.ts delete mode 100644 src/ts/@overflow/apikey/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/commons/context/AppContext.ts delete mode 100644 src/ts/@overflow/commons/context/config/ConfigurationDefinition.ts delete mode 100644 src/ts/@overflow/commons/context/constants/reflect.ts delete mode 100644 src/ts/@overflow/commons/context/decorator/Configuration.ts delete mode 100644 src/ts/@overflow/commons/context/decorator/Pouch.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/config/PouchDefinition.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/constants/index.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/constants/reflect.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/constants/types.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/Inject.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/PostConstruct.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/PreDestroy.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/Qualifier.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/decorator/Scope.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/util/metadata/inject.ts delete mode 100644 src/ts/@overflow/commons/context/pouches/util/metadata/pouch.ts delete mode 100644 src/ts/@overflow/commons/context/util/metadata/configuration.ts delete mode 100644 src/ts/@overflow/commons/redux-saga/index.ts create mode 100644 src/ts/@overflow/commons/redux/action/asyncRequest.ts create mode 100644 src/ts/@overflow/commons/redux/payload/AsyncRequestPayload.ts rename src/ts/@overflow/{member/redux/saga/signIn.ts => commons/redux/saga/asyncRequest.ts} (53%) delete mode 100644 src/ts/@overflow/commons/util/metadata/getClassMetadata.ts delete mode 100644 src/ts/@overflow/discovery/redux/saga/discovery.ts delete mode 100644 src/ts/@overflow/domain/redux/saga/member_regist.ts delete mode 100644 src/ts/@overflow/domain/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/email/redux/saga/modify.ts delete mode 100644 src/ts/@overflow/email/redux/saga/read.ts delete mode 100644 src/ts/@overflow/email/redux/saga/read_by_auth_key.ts delete mode 100644 src/ts/@overflow/email/redux/saga/read_by_member.ts delete mode 100644 src/ts/@overflow/email/redux/saga/send_email_by_member.ts delete mode 100644 src/ts/@overflow/history/redux/saga/_ delete mode 100644 src/ts/@overflow/infra/redux/saga/host_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/host_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/machine_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/machine_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_application_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_application_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_daemon_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_daemon_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_port_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_port_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/os_regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/service_read.ts delete mode 100644 src/ts/@overflow/infra/redux/saga/service_regist.ts delete mode 100644 src/ts/@overflow/member/redux/saga/modify.ts delete mode 100644 src/ts/@overflow/member/redux/saga/read.ts delete mode 100644 src/ts/@overflow/member/redux/saga/signOut.ts delete mode 100644 src/ts/@overflow/member/redux/saga/signUp.ts delete mode 100644 src/ts/@overflow/meta/redux/saga/_ delete mode 100644 src/ts/@overflow/noauthprobe/redux/saga/read.ts delete mode 100644 src/ts/@overflow/noauthprobe/redux/saga/read_all_by_domain.ts delete mode 100644 src/ts/@overflow/noauthprobe/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts delete mode 100644 src/ts/@overflow/probe/redux/saga/read_by_probekey.ts delete mode 100644 src/ts/@overflow/probe/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts delete mode 100644 src/ts/@overflow/probe/redux/saga/task_regist.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/item_read.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/item_regist.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/item_remove.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/read.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/remove.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/start.ts delete mode 100644 src/ts/@overflow/sensor/redux/saga/stop.ts delete mode 100644 src/ts/@overflow/target/redux/saga/read.ts delete mode 100644 src/ts/@overflow/target/redux/saga/read_all_by_probe.ts delete mode 100644 src/ts/@overflow/target/redux/saga/regist.ts delete mode 100644 src/ts/@overflow/target/redux/saga/regist_discovered_target.ts delete mode 100644 src/ts/@overflow/target/redux/saga/remove.ts diff --git a/src/ts/@loafer/context/AppContext.ts b/src/ts/@loafer/context/AppContext.ts new file mode 100644 index 0000000..624d0c2 --- /dev/null +++ b/src/ts/@loafer/context/AppContext.ts @@ -0,0 +1,8 @@ +import PouchFactory from '@loafer/pouches/factory/PouchFactory'; +import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; + +interface AppContext extends PouchFactory { + getPouchFactory(): DefaultPouchFactory; +} + +export default AppContext; diff --git a/src/ts/@overflow/commons/context/constants/index.ts b/src/ts/@loafer/context/constants/index.ts similarity index 100% rename from src/ts/@overflow/commons/context/constants/index.ts rename to src/ts/@loafer/context/constants/index.ts diff --git a/src/ts/@loafer/context/constants/reflect.ts b/src/ts/@loafer/context/constants/reflect.ts new file mode 100644 index 0000000..c85fa52 --- /dev/null +++ b/src/ts/@loafer/context/constants/reflect.ts @@ -0,0 +1,2 @@ +export const CONTEXT_CONFIGURATION_DEFINITION = 'loafer:context/configuration_definition'; +export const CONTEXT_INJECTABLE_DEFINITION = 'loafer:context/injectable_definition'; diff --git a/src/ts/@loafer/context/decorator/Configuration.ts b/src/ts/@loafer/context/decorator/Configuration.ts new file mode 100644 index 0000000..9d64ee4 --- /dev/null +++ b/src/ts/@loafer/context/decorator/Configuration.ts @@ -0,0 +1,31 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import ConfigurationDefinition from '@loafer/context/definition/ConfigurationDefinition'; +import { getConfigurationDefinition } from '@loafer/context/util/metadata'; + +import GetAppContext from '@loafer/context'; +import { DEFAULT_QUALIFIER, InjectableSterotype } from '@loafer/pouches/constants'; +import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; +import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; + +const Configuration = (qualifier: string | symbol = DEFAULT_QUALIFIER ) => createDecorator('Configuration', { + classDecorator: (target: TFunction): TFunction | void => { + let configurationDefinition: ConfigurationDefinition = getConfigurationDefinition(target.prototype, false); + if (undefined !== configurationDefinition) { + throw new Error('Cannot apply @Injectable or @Injectable stereotype decorator multiple times.'); + } + + configurationDefinition = getConfigurationDefinition(target, true); + configurationDefinition.Stereotype = InjectableSterotype.CONFIGURATION; + configurationDefinition.Qualifier = qualifier; + + let pouchFactory: DefaultPouchFactory = GetAppContext().getPouchFactory(); + let pouchDefinitionRegistry = pouchFactory; + pouchDefinitionRegistry.registerPouchDefinition(configurationDefinition); + + return target; + }, + +}); + + +export default Configuration; diff --git a/src/ts/@loafer/context/decorator/Injectable.ts b/src/ts/@loafer/context/decorator/Injectable.ts new file mode 100644 index 0000000..8e9dd8b --- /dev/null +++ b/src/ts/@loafer/context/decorator/Injectable.ts @@ -0,0 +1,30 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import { getInjectableDefinition } from '@loafer/context/util/metadata'; + +import GetAppContext from '@loafer/context'; +import { DEFAULT_QUALIFIER } from '@loafer/pouches/constants'; +import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; +import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; + +const Injectable = (qualifier: string | symbol = DEFAULT_QUALIFIER ) => createDecorator('Injectable', { + classDecorator: (target: TFunction): TFunction | void => { + let injectableDefinition: InjectableDefinition = getInjectableDefinition(target.prototype, false); + if (undefined !== injectableDefinition) { + throw new Error('Cannot apply @Injectable decorator multiple times.'); + } + + injectableDefinition = getInjectableDefinition(target, true); + injectableDefinition.Qualifier = qualifier; + + let pouchFactory: DefaultPouchFactory = GetAppContext().getPouchFactory(); + let pouchDefinitionRegistry = pouchFactory; + pouchDefinitionRegistry.registerPouchDefinition(injectableDefinition); + + return target; + }, + +}); + + +export default Injectable; diff --git a/src/ts/@loafer/context/decorator/PostConstruct.ts b/src/ts/@loafer/context/decorator/PostConstruct.ts new file mode 100644 index 0000000..f7d8ab4 --- /dev/null +++ b/src/ts/@loafer/context/decorator/PostConstruct.ts @@ -0,0 +1,16 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import { getInjectableDefinition } from '@loafer/context/util/metadata'; + +const PostConstruct = createDecorator('PostConstruct', { + methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { + let injectableDefinition = getInjectableDefinition(target, false); + if (undefined === injectableDefinition) { + throw new Error('Cannot apply @PostConstruct decorator on the not @Injectable or @Injectable stereotype class.'); + } + injectableDefinition.addPostConstruct(propertyKey); + return descriptor; + }, +}); + +export default PostConstruct; diff --git a/src/ts/@loafer/context/decorator/Pouch.ts b/src/ts/@loafer/context/decorator/Pouch.ts new file mode 100644 index 0000000..7399b44 --- /dev/null +++ b/src/ts/@loafer/context/decorator/Pouch.ts @@ -0,0 +1,18 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import ConfigurationDefinition from '@loafer/context/definition/ConfigurationDefinition'; +import { getConfigurationDefinition } from '@loafer/context/util/metadata'; +import { InjectableSterotype } from '@loafer/pouches/constants'; +import PouchConfig from '@loafer/context/decorator/PouchConfig'; + +const Pouch = (pouchConfig: PouchConfig = {}) => createDecorator('Pouch', { + methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { + let configurationDefinition: ConfigurationDefinition = getConfigurationDefinition(target, false); + if (undefined === configurationDefinition || InjectableSterotype.CONFIGURATION !== configurationDefinition.Stereotype) { + throw new Error('Cannot apply @Pouch decorator on not @Configuration class.'); + } + configurationDefinition.addPouch(propertyKey, pouchConfig); + return descriptor; + }, +}); + +export default Pouch; diff --git a/src/ts/@overflow/commons/context/decorator/PouchConfig.ts b/src/ts/@loafer/context/decorator/PouchConfig.ts similarity index 100% rename from src/ts/@overflow/commons/context/decorator/PouchConfig.ts rename to src/ts/@loafer/context/decorator/PouchConfig.ts diff --git a/src/ts/@loafer/context/decorator/PreDestroy.ts b/src/ts/@loafer/context/decorator/PreDestroy.ts new file mode 100644 index 0000000..798b368 --- /dev/null +++ b/src/ts/@loafer/context/decorator/PreDestroy.ts @@ -0,0 +1,16 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import { getInjectableDefinition } from '@loafer/context/util/metadata'; + +const PreDestroy = createDecorator('PreDestroy', { + methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { + let injectableDefinition = getInjectableDefinition(target, false); + if (undefined === injectableDefinition) { + throw new Error('Cannot apply @PreDestroy decorator on the not @Injectable or @Injectable stereotype class.'); + } + injectableDefinition.addPreDestroy(propertyKey); + return descriptor; + }, +}); + +export default PreDestroy; diff --git a/src/ts/@loafer/context/decorator/Scope.ts b/src/ts/@loafer/context/decorator/Scope.ts new file mode 100644 index 0000000..b9f07a2 --- /dev/null +++ b/src/ts/@loafer/context/decorator/Scope.ts @@ -0,0 +1,17 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import { getInjectableDefinition } from '@loafer/context/util/metadata'; +import { PouchScope } from '@loafer/pouches/constants'; + +const Scope = (scope: PouchScope = PouchScope.SINGLETON) => createDecorator('Scope', { + classDecorator: (target: TFunction): TFunction | void => { + let injectableDefinition = getInjectableDefinition(target.prototype, false); + if (undefined === injectableDefinition) { + throw new Error('Cannot apply @Scope decorator on the not @Injectable or @Injectable stereotype class.'); + } + injectableDefinition.Scope = scope; + return target; + }, +}); + +export default Scope; diff --git a/src/ts/@loafer/context/decorator/Service.ts b/src/ts/@loafer/context/decorator/Service.ts new file mode 100644 index 0000000..182c5c8 --- /dev/null +++ b/src/ts/@loafer/context/decorator/Service.ts @@ -0,0 +1,31 @@ +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import { getInjectableDefinition } from '@loafer/context/util/metadata'; + +import GetAppContext from '@loafer/context'; +import { DEFAULT_QUALIFIER, InjectableSterotype } from '@loafer/pouches/constants'; +import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; +import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; + +const Service = (qualifier: string | symbol = DEFAULT_QUALIFIER ) => createDecorator('Service', { + classDecorator: (target: TFunction): TFunction | void => { + let injectableDefinition: InjectableDefinition = getInjectableDefinition(target.prototype, false); + if (undefined !== injectableDefinition) { + throw new Error('Cannot apply @Injectable or @Injectable stereotype decorator multiple times.'); + } + + injectableDefinition = getInjectableDefinition(target, true); + injectableDefinition.Stereotype = InjectableSterotype.SERVICE; + injectableDefinition.Qualifier = qualifier; + + let pouchFactory: DefaultPouchFactory = GetAppContext().getPouchFactory(); + let pouchDefinitionRegistry = pouchFactory; + pouchDefinitionRegistry.registerPouchDefinition(injectableDefinition); + + return target; + }, + +}); + + +export default Service; diff --git a/src/ts/@loafer/context/definition/ConfigurationDefinition.ts b/src/ts/@loafer/context/definition/ConfigurationDefinition.ts new file mode 100644 index 0000000..7c912b4 --- /dev/null +++ b/src/ts/@loafer/context/definition/ConfigurationDefinition.ts @@ -0,0 +1,32 @@ +import { DESIGN_RETURNTYPE } from '@loafer/core/constants'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; +import PouchConfig from '@loafer/context/decorator/PouchConfig'; + +class ConfigurationDefinition extends InjectableDefinition { + protected _qualifier: string | symbol = undefined; + protected _pouchMap: Map; + + public constructor(type: Object) { + super(type); + } + + public addPouch(propertyKey: string, pouchConfig: PouchConfig): void { + if (undefined === this._pouchMap) { + this._pouchMap = new Map(); + } + let returnType: any = Reflect.getMetadata(DESIGN_RETURNTYPE, this._type, propertyKey); + + if (undefined === pouchConfig.type) { + pouchConfig.type = returnType; + } + + this._pouchMap.set(propertyKey, pouchConfig); + } + + public get Pouches(): Map { + return this._pouchMap; + } + +} + +export default ConfigurationDefinition; diff --git a/src/ts/@loafer/context/definition/InjectableDefinition.ts b/src/ts/@loafer/context/definition/InjectableDefinition.ts new file mode 100644 index 0000000..c376f7b --- /dev/null +++ b/src/ts/@loafer/context/definition/InjectableDefinition.ts @@ -0,0 +1,75 @@ +import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; +import { InjectableSterotype, PouchScope } from '@loafer/pouches/constants'; + +class InjectableDefinition implements PouchDefinition { + protected _type: Object; + protected _stereotype: InjectableSterotype; + protected _scope: PouchScope = PouchScope.SINGLETON; + protected _qualifier: string | symbol = undefined; + protected _postConstruct: Set = undefined; + protected _preDestroy: Set = undefined; + + public constructor(type: Object) { + this._type = type; + this._stereotype = InjectableSterotype.INJECTABLE; + } + + public get Type(): Object { + return this._type; + } + + public get Stereotype(): InjectableSterotype { + return this._stereotype; + } + + public set Stereotype(stereotype: InjectableSterotype) { + this._stereotype = stereotype; + } + + public get Scope(): PouchScope { + return this._scope; + } + + public set Scope(scope: PouchScope) { + this._scope = scope; + } + + public get Qualifier(): string | symbol { + return this._qualifier; + } + + public set Qualifier(qualifier: string | symbol) { + this._qualifier = qualifier; + } + + public get PostConstruct(): Set { + return this._postConstruct; + } + + public addPostConstruct(postConstruct: string): void { + if (undefined === this._postConstruct) { + this._postConstruct = new Set(); + } + this._postConstruct.add(postConstruct); + } + + public get PreDestroy(): Set { + return this._preDestroy; + } + + public addPreDestroy(preDestroy: string): void { + if (undefined === this._preDestroy) { + this._preDestroy = new Set(); + } + this._preDestroy.add(preDestroy); + } + + public isSingleton(): boolean { + return this._scope === PouchScope.SINGLETON; + } + public isTransient(): boolean { + return this._scope === PouchScope.TRANSIENT; + } +} + +export default InjectableDefinition; diff --git a/src/ts/@loafer/context/implement/DefaultAppContext.ts b/src/ts/@loafer/context/implement/DefaultAppContext.ts new file mode 100644 index 0000000..2d3546c --- /dev/null +++ b/src/ts/@loafer/context/implement/DefaultAppContext.ts @@ -0,0 +1,30 @@ +import { + Construtorable, +} from '@loafer/core/constants'; + +import AppContext from '@loafer/context/AppContext'; + +import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; + +class DefaultAppContext implements AppContext { + private readonly pouchFactory: DefaultPouchFactory; + + public constructor() { + this.pouchFactory = new DefaultPouchFactory(); + } + + public getPouchFactory(): DefaultPouchFactory { + return this.pouchFactory; + } + + public getPouch(type: Construtorable, ...args: any[]): T { + return this.pouchFactory.getPouch(type, args); + } + + public getPouchByQualifier(type: Construtorable, qualifier: string | symbol, ...args: any[]): T { + return this.pouchFactory.getPouchByQualifier(type, qualifier, args); + } + +} + +export default DefaultAppContext; diff --git a/src/ts/@loafer/context/index.ts b/src/ts/@loafer/context/index.ts new file mode 100644 index 0000000..4d6cdd8 --- /dev/null +++ b/src/ts/@loafer/context/index.ts @@ -0,0 +1,13 @@ +import AppContext from '@loafer/context/AppContext'; +import DefaultAppContext from '@loafer/context/implement/DefaultAppContext'; + +let _appContext: AppContext = undefined; + +const GetAppContext = (): AppContext => { + if (undefined === _appContext) { + _appContext = new DefaultAppContext(); + } + return _appContext; +}; + +export default GetAppContext; diff --git a/src/ts/@overflow/commons/context/redux/action/lifecycle.ts b/src/ts/@loafer/context/redux/action/lifecycle.ts similarity index 100% rename from src/ts/@overflow/commons/context/redux/action/lifecycle.ts rename to src/ts/@loafer/context/redux/action/lifecycle.ts diff --git a/src/ts/@overflow/commons/context/redux/saga/index.ts b/src/ts/@loafer/context/redux/saga/index.ts similarity index 100% rename from src/ts/@overflow/commons/context/redux/saga/index.ts rename to src/ts/@loafer/context/redux/saga/index.ts diff --git a/src/ts/@loafer/context/util/metadata/configuration.ts b/src/ts/@loafer/context/util/metadata/configuration.ts new file mode 100644 index 0000000..8fd103e --- /dev/null +++ b/src/ts/@loafer/context/util/metadata/configuration.ts @@ -0,0 +1,6 @@ +import getClassMetadata from '@loafer/core/util/metadata/getClassMetadata'; +import { CONTEXT_INJECTABLE_DEFINITION } from '@loafer/context/constants'; +import ConfigurationDefinition from '@loafer/context/definition/ConfigurationDefinition'; + +export const getConfigurationDefinition = (target: Object, isCreate: boolean = false) => + getClassMetadata(target, CONTEXT_INJECTABLE_DEFINITION, ConfigurationDefinition, isCreate); diff --git a/src/ts/@overflow/commons/context/util/metadata/index.ts b/src/ts/@loafer/context/util/metadata/index.ts similarity index 52% rename from src/ts/@overflow/commons/context/util/metadata/index.ts rename to src/ts/@loafer/context/util/metadata/index.ts index 75a1114..eafcf4b 100644 --- a/src/ts/@overflow/commons/context/util/metadata/index.ts +++ b/src/ts/@loafer/context/util/metadata/index.ts @@ -1 +1,2 @@ export * from './configuration'; +export * from './injectable'; diff --git a/src/ts/@loafer/context/util/metadata/injectable.ts b/src/ts/@loafer/context/util/metadata/injectable.ts new file mode 100644 index 0000000..1b3ac63 --- /dev/null +++ b/src/ts/@loafer/context/util/metadata/injectable.ts @@ -0,0 +1,6 @@ +import getClassMetadata from '@loafer/core/util/metadata/getClassMetadata'; +import { CONTEXT_INJECTABLE_DEFINITION } from '@loafer/context/constants'; +import InjectableDefinition from '@loafer/context/definition/InjectableDefinition'; + +export const getInjectableDefinition = (target: Object, isCreate: boolean = false) => + getClassMetadata(target, CONTEXT_INJECTABLE_DEFINITION, InjectableDefinition, isCreate); diff --git a/src/ts/@overflow/commons/core/constants/index.ts b/src/ts/@loafer/core/constants/index.ts similarity index 100% rename from src/ts/@overflow/commons/core/constants/index.ts rename to src/ts/@loafer/core/constants/index.ts diff --git a/src/ts/@overflow/commons/core/constants/reflect.ts b/src/ts/@loafer/core/constants/reflect.ts similarity index 100% rename from src/ts/@overflow/commons/core/constants/reflect.ts rename to src/ts/@loafer/core/constants/reflect.ts diff --git a/src/ts/@overflow/commons/core/constants/types.ts b/src/ts/@loafer/core/constants/types.ts similarity index 56% rename from src/ts/@overflow/commons/core/constants/types.ts rename to src/ts/@loafer/core/constants/types.ts index dde5a51..da78154 100644 --- a/src/ts/@overflow/commons/core/constants/types.ts +++ b/src/ts/@loafer/core/constants/types.ts @@ -1,4 +1,4 @@ -export type Newable = {new(...args: any[]): T}; +export type Construtorable = {new(...args: any[]): T}; export enum DecoratorType { CLASS, diff --git a/src/ts/@overflow/commons/util/decorators/createDecorator.ts b/src/ts/@loafer/core/util/decorators/createDecorator.ts similarity index 100% rename from src/ts/@overflow/commons/util/decorators/createDecorator.ts rename to src/ts/@loafer/core/util/decorators/createDecorator.ts diff --git a/src/ts/@loafer/core/util/metadata/getClassMetadata.ts b/src/ts/@loafer/core/util/metadata/getClassMetadata.ts new file mode 100644 index 0000000..838e934 --- /dev/null +++ b/src/ts/@loafer/core/util/metadata/getClassMetadata.ts @@ -0,0 +1,23 @@ +export type MetadataDefinable = {new(target: Function): T}; + +const getClassMetadata = (target: Object, + metadataKey: any, + definitionType: MetadataDefinable, + isCreate: boolean = false): DefinitionType => { + + let definition: DefinitionType; + if (Reflect.hasOwnMetadata(metadataKey, target) !== true) { + if (!isCreate) { + return undefined; + } + definition = Object.create(definitionType.prototype); + definition.constructor.call(definition, target); + + Reflect.defineMetadata(metadataKey, definition, target); + } else { + definition = Reflect.getMetadata(metadataKey, target); + } + return definition; +}; + +export default getClassMetadata; diff --git a/src/ts/@loafer/pouches/constants/index.ts b/src/ts/@loafer/pouches/constants/index.ts new file mode 100644 index 0000000..c4e0621 --- /dev/null +++ b/src/ts/@loafer/pouches/constants/index.ts @@ -0,0 +1,5 @@ +export * from './reflect'; +export * from './stereotype'; +export * from './types'; + +export const DEFAULT_QUALIFIER = Symbol('__DEFAULT_QUALIFIER__'); diff --git a/src/ts/@loafer/pouches/constants/reflect.ts b/src/ts/@loafer/pouches/constants/reflect.ts new file mode 100644 index 0000000..2020891 --- /dev/null +++ b/src/ts/@loafer/pouches/constants/reflect.ts @@ -0,0 +1 @@ +export const POUCH_INJECT_DEFINITION = 'loafer:pouch/inject_definition'; diff --git a/src/ts/@loafer/pouches/constants/stereotype.ts b/src/ts/@loafer/pouches/constants/stereotype.ts new file mode 100644 index 0000000..28469f8 --- /dev/null +++ b/src/ts/@loafer/pouches/constants/stereotype.ts @@ -0,0 +1,11 @@ +export enum InjectableSterotype { + INJECTABLE = 'Injectable', + CONFIGURATION = 'Configuration', + SERVICE = 'Service', +} + +export enum InjectSterotype { + INJECT = 'Inject', + VALUE = 'Value', +} + diff --git a/src/ts/@loafer/pouches/constants/types.ts b/src/ts/@loafer/pouches/constants/types.ts new file mode 100644 index 0000000..292f5c0 --- /dev/null +++ b/src/ts/@loafer/pouches/constants/types.ts @@ -0,0 +1,4 @@ +export enum PouchScope { + SINGLETON = 'Singleton', + TRANSIENT = 'Transient', +} diff --git a/src/ts/@loafer/pouches/decorator/Inject.ts b/src/ts/@loafer/pouches/decorator/Inject.ts new file mode 100644 index 0000000..9073ca3 --- /dev/null +++ b/src/ts/@loafer/pouches/decorator/Inject.ts @@ -0,0 +1,18 @@ +import InjectConfig from '@loafer/pouches/decorator/InjectConfig'; +import InjectDefinition from '@loafer/pouches/definition/InjectDefinition'; +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import { getInjectDefinition } from '@loafer/pouches/util/metadata'; + +const Inject = (injectConfig: InjectConfig = {}) => createDecorator('Inject', { + propertyDecorator: (target: Object, propertyKey: string | symbol): void => { + let injectDefinition: InjectDefinition = getInjectDefinition(target, true); + injectDefinition.addInject(injectConfig, propertyKey); + }, + parameterDecorator: (target: Object, propertyKey: string | symbol, parameterIndex: number): void => { + let injectDefinition: InjectDefinition = getInjectDefinition(target, true); + injectDefinition.addInject(injectConfig, propertyKey, parameterIndex); + }, + +}); + +export default Inject; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/InjectConfig.ts b/src/ts/@loafer/pouches/decorator/InjectConfig.ts similarity index 100% rename from src/ts/@overflow/commons/context/pouches/decorator/InjectConfig.ts rename to src/ts/@loafer/pouches/decorator/InjectConfig.ts diff --git a/src/ts/@loafer/pouches/decorator/Value.ts b/src/ts/@loafer/pouches/decorator/Value.ts new file mode 100644 index 0000000..b7e622b --- /dev/null +++ b/src/ts/@loafer/pouches/decorator/Value.ts @@ -0,0 +1,17 @@ +import InjectDefinition from '@loafer/pouches/definition/InjectDefinition'; +import createDecorator from '@loafer/core/util/decorators/createDecorator'; +import { getInjectDefinition } from '@loafer/pouches/util/metadata'; + +const Value = (value: string) => createDecorator('Value', { + propertyDecorator: (target: Object, propertyKey: string | symbol): void => { + let injectDefinition: InjectDefinition = getInjectDefinition(target, true); + injectDefinition.addValue(value, propertyKey); + }, + parameterDecorator: (target: Object, propertyKey: string | symbol, parameterIndex: number): void => { + let injectDefinition: InjectDefinition = getInjectDefinition(target, true); + injectDefinition.addValue(value, propertyKey, parameterIndex); + }, + +}); + +export default Value; diff --git a/src/ts/@overflow/commons/context/pouches/config/PouchInjectDefinition.ts b/src/ts/@loafer/pouches/definition/InjectDefinition.ts similarity index 70% rename from src/ts/@overflow/commons/context/pouches/config/PouchInjectDefinition.ts rename to src/ts/@loafer/pouches/definition/InjectDefinition.ts index 3efa136..9e0e8db 100644 --- a/src/ts/@overflow/commons/context/pouches/config/PouchInjectDefinition.ts +++ b/src/ts/@loafer/pouches/definition/InjectDefinition.ts @@ -1,15 +1,16 @@ -import * as METADATA from '../constants'; -import { POUCH_DEFAULT_QUALIFIER } from '../constants'; -import InjectConfig from '../decorator/InjectConfig'; -import * as CoreConstants from '@overflow/commons/core/constants'; +import * as METADATA from '@loafer/pouches/constants'; +import { DEFAULT_QUALIFIER, InjectSterotype } from '@loafer/pouches/constants'; +import InjectConfig from '@loafer/pouches/decorator/InjectConfig'; +import * as CoreConstants from '@loafer/core/constants'; export interface InjectItem { + stereotype: InjectSterotype; decoratorType: CoreConstants.DecoratorType; propertyConfig?: InjectConfig; parameterConfigMap?: Map; } -class PouchInjectDefinition { +class InjectDefinition { protected target: Object; protected injectMap: Map; @@ -27,7 +28,7 @@ class PouchInjectDefinition { */ public addInject(injectConfig: InjectConfig, propertyKey: string | symbol, parameterIndex?: number): void { if (undefined === injectConfig.qualifier) { - injectConfig.qualifier = POUCH_DEFAULT_QUALIFIER; + injectConfig.qualifier = DEFAULT_QUALIFIER; } if (undefined === injectConfig.required) { injectConfig.required = false; @@ -40,7 +41,25 @@ class PouchInjectDefinition { } } - private addInjectParameter(injectConfig: InjectConfig, propertyKey: string | symbol, parameterIndex: number): void { + /** + * addValue + */ + public addValue(value: string, propertyKey: string | symbol, parameterIndex?: number): void { + if(typeof parameterIndex === 'number') { + this.addValueParameter(value, propertyKey, parameterIndex); + } else { + this.addValueProperty(value, propertyKey); + } + } + + private addValueProperty(value: string, propertyKey: string | symbol): void { + + } + + + + private addInjectParameter(injectConfig: InjectConfig, + propertyKey: string | symbol, parameterIndex: number): void { let injectItem: InjectItem; let parameterTypes: any[] = Reflect.getMetadata(CoreConstants.DESIGN_PARAMTYPES, this.target, propertyKey); @@ -52,6 +71,7 @@ class PouchInjectDefinition { injectItem = this.injectMap.get(propertyKey); } else { injectItem = { + stereotype: InjectSterotype.INJECT, decoratorType: CoreConstants.DecoratorType.PARAMETER, }; this.injectMap.set(propertyKey, injectItem); @@ -81,6 +101,7 @@ class PouchInjectDefinition { } let injectItem: InjectItem = { + stereotype: InjectSterotype.INJECT, decoratorType: CoreConstants.DecoratorType.PROPERTY, propertyConfig: injectConfig, }; @@ -90,4 +111,4 @@ class PouchInjectDefinition { } -export default PouchInjectDefinition; +export default InjectDefinition; diff --git a/src/ts/@loafer/pouches/factory/PouchFactory.ts b/src/ts/@loafer/pouches/factory/PouchFactory.ts new file mode 100644 index 0000000..f5c6abf --- /dev/null +++ b/src/ts/@loafer/pouches/factory/PouchFactory.ts @@ -0,0 +1,9 @@ +import { Construtorable } from '@loafer/core/constants'; + +interface PouchFactory { + getPouch(type: Construtorable, ...args: any[]): T; + getPouchByQualifier(type: Construtorable, qualifier: string | symbol, ...args: any[]): T; + +} + +export default PouchFactory; diff --git a/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts b/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts new file mode 100644 index 0000000..5d9e1e4 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts @@ -0,0 +1,16 @@ +import { InjectableSterotype, PouchScope } from '@loafer/pouches/constants'; + +interface PouchDefinition { + readonly Type: Object; + Stereotype: InjectableSterotype; + Scope: PouchScope; + Qualifier: string | symbol; + readonly PostConstruct: Set; + readonly PreDestroy: Set; + addPostConstruct(postConstruct: string): void; + addPreDestroy(preDestroy: string): void; + isSingleton(): boolean; + isTransient(): boolean; +} + +export default PouchDefinition; diff --git a/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts b/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts new file mode 100644 index 0000000..0f6877c --- /dev/null +++ b/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts @@ -0,0 +1,55 @@ +import * as METADATA from '@loafer/pouches/constants'; + +import { + Construtorable, + DecoratorType, +} from '@loafer/core/constants'; + +import { + PouchScope, + DEFAULT_QUALIFIER, +} from '@loafer/pouches/constants'; + +import PouchFactory from '@loafer/pouches/factory/PouchFactory'; +import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; +import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; + +class DefaultPouchFactory implements PouchFactory, PouchDefinitionRegistry { + public constructor() { + } + + public getPouch(type: Construtorable, ...args: any[]): T { + let qualifier = DEFAULT_QUALIFIER; + return this.getPouchByQualifier(type, qualifier, args); + } + + public getPouchByQualifier(type: Construtorable, qualifier: string | symbol, ...args: any[]): T { + let clazz: Function = type.prototype; + let instance: T; + return instance; + } + + public registerPouchDefinition(pouchDefinition: PouchDefinition): void { + let type = pouchDefinition.Type; + let qualifier = pouchDefinition.Qualifier; + + } + public removePouchDefinition(type: Object, qualifier?: string | symbol): void { + + } + public getPouchDefinition(type: Object, qualifier?: string | symbol): PouchDefinition { + + } + public hasPouchDefinition(type: Object, qualifier?: string | symbol): boolean { + + } + public getPouchDefinitions(): PouchDefinition[] { + + } + public getPouchDefinitionCount(): number { + + } + +} + +export default DefaultPouchFactory; diff --git a/src/ts/@loafer/pouches/factory/registry/PouchDefinitionRegistry.ts b/src/ts/@loafer/pouches/factory/registry/PouchDefinitionRegistry.ts new file mode 100644 index 0000000..19a6509 --- /dev/null +++ b/src/ts/@loafer/pouches/factory/registry/PouchDefinitionRegistry.ts @@ -0,0 +1,13 @@ +import { Construtorable } from '@loafer/core/constants'; +import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; + +interface PouchDefinitionRegistry { + registerPouchDefinition(pouchDefinition: PouchDefinition): void; + removePouchDefinition(type: Object, qualifier?: string | symbol): void; + getPouchDefinition(type: Object, qualifier?: string | symbol): PouchDefinition; + hasPouchDefinition(type: Object, qualifier?: string | symbol): boolean; + getPouchDefinitions(): PouchDefinition[]; + getPouchDefinitionCount(): number; +} + +export default PouchDefinitionRegistry; diff --git a/src/ts/@overflow/commons/context/pouches/util/metadata/index.ts b/src/ts/@loafer/pouches/util/metadata/index.ts similarity index 50% rename from src/ts/@overflow/commons/context/pouches/util/metadata/index.ts rename to src/ts/@loafer/pouches/util/metadata/index.ts index f5e629b..d41ede0 100644 --- a/src/ts/@overflow/commons/context/pouches/util/metadata/index.ts +++ b/src/ts/@loafer/pouches/util/metadata/index.ts @@ -1,2 +1 @@ export * from './inject'; -export * from './pouch'; diff --git a/src/ts/@loafer/pouches/util/metadata/inject.ts b/src/ts/@loafer/pouches/util/metadata/inject.ts new file mode 100644 index 0000000..7072436 --- /dev/null +++ b/src/ts/@loafer/pouches/util/metadata/inject.ts @@ -0,0 +1,8 @@ +import getClassMetadata from '@loafer/core/util/metadata/getClassMetadata'; + +import { POUCH_INJECT_DEFINITION } from '@loafer/pouches/constants'; +import InjectDefinition from '@loafer/pouches/definition/InjectDefinition'; + +export const getInjectDefinition = + (target: Object, isCreate: boolean = false) => + getClassMetadata(target, POUCH_INJECT_DEFINITION, InjectDefinition, isCreate); diff --git a/src/ts/@overflow/apikey/redux/saga/read.ts b/src/ts/@overflow/apikey/redux/saga/read.ts deleted file mode 100644 index da03379..0000000 --- a/src/ts/@overflow/apikey/redux/saga/read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import ApiKey from '../../api/model/ApiKey'; -import ApiKeyService from '../../api/service/ApiKeyService'; -import * as ReadActions from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {domain} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let apiKeyService = AppContext.getInstance().getPouch(ApiKeyService); - const retApikey = yield call({context: apiKeyService, fn: apiKeyService.read}, domain); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/apikey/redux/saga/regist.ts b/src/ts/@overflow/apikey/redux/saga/regist.ts deleted file mode 100644 index ac14979..0000000 --- a/src/ts/@overflow/apikey/redux/saga/regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import ApiKey from '../../api/model/ApiKey'; -import ApiKeyService from '../../api/service/ApiKeyService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {apiKey} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let apiKeyService: ApiKeyService = AppContext.getInstance().getPouch(ApiKeyService); - const retApikey = yield call({context: apiKeyService, fn: apiKeyService.regist}, apiKey); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/app/config/AppConfig.ts b/src/ts/@overflow/app/config/AppConfig.ts index 16e25e7..3d590a5 100644 --- a/src/ts/@overflow/app/config/AppConfig.ts +++ b/src/ts/@overflow/app/config/AppConfig.ts @@ -1,5 +1,5 @@ -import Configuration from '@overflow/commons/context/decorator/Configuration'; -import Pouch from '@overflow/commons/context/decorator/Pouch'; +import Configuration from '@loafer/context/decorator/Configuration'; +import Pouch from '@loafer/context/decorator/Pouch'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; diff --git a/src/ts/@overflow/app/index.tsx b/src/ts/@overflow/app/index.tsx index caa701a..81f953b 100644 --- a/src/ts/@overflow/app/index.tsx +++ b/src/ts/@overflow/app/index.tsx @@ -42,8 +42,8 @@ import { import * as injectTapEventPlugin from 'react-tap-event-plugin'; import Platform from '@overflow/commons/platform'; -import AppContext from '@overflow/commons/context/AppContext'; -import * as AppContextLifecycleActions from '@overflow/commons/context/redux/action/lifecycle'; +import AppContext from '@loafer/context/AppContext'; +import * as AppContextLifecycleActions from '@loafer/context/redux/action/lifecycle'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; import ReducerContext from '@overflow/commons/redux/ReducerContext'; import { SagaWatcher } from '@overflow/commons/redux-saga'; diff --git a/src/ts/@overflow/commons/api/Service.ts b/src/ts/@overflow/commons/api/Service.ts index 1635082..a276bed 100644 --- a/src/ts/@overflow/commons/api/Service.ts +++ b/src/ts/@overflow/commons/api/Service.ts @@ -1,4 +1,4 @@ -import Inject from '../context/pouches/decorator/Inject'; +import Inject from '@loafer/pouches/decorator/Inject'; import WebSocketRPC from '../websocket/WebSocketRPC'; abstract class Service { diff --git a/src/ts/@overflow/commons/context/AppContext.ts b/src/ts/@overflow/commons/context/AppContext.ts deleted file mode 100644 index 230b98a..0000000 --- a/src/ts/@overflow/commons/context/AppContext.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as CoreConstants from '@overflow/commons/core/constants'; -import PouchFactory from './pouches/factory/PouchFactory'; - -class AppContext { - private static _instance: AppContext; - private _pouchFactory: PouchFactory; - - public constructor() { - this._pouchFactory = new PouchFactory(); - } - - public get PouchFactory(): PouchFactory { - return this._pouchFactory; - } - - /** - * getPouch - */ - public getPouch(type: CoreConstants.Newable, ...args: any[]): T { - return this._pouchFactory.getPouch(type, args); - } - - /** - * getPouchByQualifier - */ - public getPouchByQualifier(type: CoreConstants.Newable, qualifier: string | symbol, ...args: any[]): T { - return this._pouchFactory.getPouchByQualifier(type, qualifier, args); - } - - public destroy(): void { - console.log('AppContext has been destroyed.'); - } - - public static getInstance(): AppContext { - if (undefined === AppContext._instance) { - AppContext._instance = new AppContext(); - } - return AppContext._instance; - } -} - -export default AppContext; diff --git a/src/ts/@overflow/commons/context/config/ConfigurationDefinition.ts b/src/ts/@overflow/commons/context/config/ConfigurationDefinition.ts deleted file mode 100644 index 8f5d8c3..0000000 --- a/src/ts/@overflow/commons/context/config/ConfigurationDefinition.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { POUCH_DEFAULT_QUALIFIER } from '../pouches/constants'; -import PouchConfig from '../decorator/PouchConfig'; -import * as CoreConstants from '@overflow/commons/core/constants'; - -class ConfigurationDefinition { - protected _type: Function; - protected _qualifier: string | symbol = undefined; - protected _pouchMap: Map; - - public constructor(type: Function) { - this._type = type; - this._qualifier = POUCH_DEFAULT_QUALIFIER; - } - - public get type(): Function { - return this._type; - } - - public get qualifier(): string | symbol { - return this._qualifier; - } - - public set qualifier(qualifier: string | symbol) { - this._qualifier = qualifier; - } - - public addPouch(propertyKey: string, pouchConfig: PouchConfig): void { - if (undefined === this._pouchMap) { - this._pouchMap = new Map(); - } - let returnType: any = Reflect.getMetadata(CoreConstants.DESIGN_RETURNTYPE, this._type, propertyKey); - - if (undefined === pouchConfig.type) { - pouchConfig.type = returnType; - } - - this._pouchMap.set(propertyKey, pouchConfig); - } - - public get Pouches(): Map { - return this._pouchMap; - } - -} - -export default ConfigurationDefinition; diff --git a/src/ts/@overflow/commons/context/constants/reflect.ts b/src/ts/@overflow/commons/context/constants/reflect.ts deleted file mode 100644 index 71986a5..0000000 --- a/src/ts/@overflow/commons/context/constants/reflect.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const CONTEXT_CONFIGURATION_DEFINITION = 'overflow:context/configuration_definition'; -export const CONTEXT_POUCH_DEFINITION = 'overflow:context/pouch_definition'; diff --git a/src/ts/@overflow/commons/context/decorator/Configuration.ts b/src/ts/@overflow/commons/context/decorator/Configuration.ts deleted file mode 100644 index 699888f..0000000 --- a/src/ts/@overflow/commons/context/decorator/Configuration.ts +++ /dev/null @@ -1,20 +0,0 @@ -import ConfigurationDefinition from '../config/ConfigurationDefinition'; - -import createDecorator from '../../util/decorators/createDecorator'; -import { getConfigurationDefinition } from '../util/metadata'; - -const Configuration = createDecorator('Configuration', { - classDecorator: (target: TFunction): TFunction | void => { - let configurationDefinition: ConfigurationDefinition = getConfigurationDefinition(target, false); - if (undefined !== configurationDefinition) { - throw new Error('Cannot apply @Configuration decorator multiple times.'); - } - - configurationDefinition = getConfigurationDefinition(target, true); - - return target; - }, - -}); - -export default Configuration; diff --git a/src/ts/@overflow/commons/context/decorator/Pouch.ts b/src/ts/@overflow/commons/context/decorator/Pouch.ts deleted file mode 100644 index b9de612..0000000 --- a/src/ts/@overflow/commons/context/decorator/Pouch.ts +++ /dev/null @@ -1,21 +0,0 @@ -import PouchConfig from './PouchConfig'; -import ConfigurationDefinition from '../config/ConfigurationDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; - -import { getConfigurationDefinition } from '../util/metadata'; - - -const Pouch = (pouchConfig: PouchConfig = {}) => createDecorator('Pouch', { - methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { - let configurationDefinition: ConfigurationDefinition = getConfigurationDefinition(target, false); - if (undefined === configurationDefinition) { - throw new Error('Cannot apply @Pouch decorator on the not @Configuration class.'); - } - - configurationDefinition.addPouch(propertyKey, pouchConfig); - - return descriptor; - }, -}); - -export default Pouch; diff --git a/src/ts/@overflow/commons/context/pouches/config/PouchDefinition.ts b/src/ts/@overflow/commons/context/pouches/config/PouchDefinition.ts deleted file mode 100644 index 97febdf..0000000 --- a/src/ts/@overflow/commons/context/pouches/config/PouchDefinition.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { PouchScope, POUCH_DEFAULT_QUALIFIER } from '../constants'; - -class PouchDefinition { - protected _type: Object; - protected _scope: PouchScope = PouchScope.SINGLETON; - protected _qualifier: string | symbol = undefined; - protected _postConstruct: Set = undefined; - protected _preDestroy: Set = undefined; - - public constructor(type: Object) { - this._type = type; - this._qualifier = POUCH_DEFAULT_QUALIFIER; - } - - public get type(): Object { - return this._type; - } - - public get scope(): PouchScope { - return this._scope; - } - - public set scope(scope: PouchScope) { - this._scope = scope; - } - - public get qualifier(): string | symbol { - return this._qualifier; - } - - public set qualifier(qualifier: string | symbol) { - this._qualifier = qualifier; - } - - public get postConstruct(): Set { - return this._postConstruct; - } - - public addPostConstruct(postConstruct: string): void { - if (undefined === this._postConstruct) { - this._postConstruct = new Set(); - } - this._postConstruct.add(postConstruct); - } - - public get preDestroy(): Set { - return this._preDestroy; - } - - public addPreDestroy(preDestroy: string): void { - if (undefined === this._preDestroy) { - this._preDestroy = new Set(); - } - this._preDestroy.add(preDestroy); - } - -} - -export default PouchDefinition; diff --git a/src/ts/@overflow/commons/context/pouches/constants/index.ts b/src/ts/@overflow/commons/context/pouches/constants/index.ts deleted file mode 100644 index 6d84a49..0000000 --- a/src/ts/@overflow/commons/context/pouches/constants/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './reflect'; -export * from './types'; diff --git a/src/ts/@overflow/commons/context/pouches/constants/reflect.ts b/src/ts/@overflow/commons/context/pouches/constants/reflect.ts deleted file mode 100644 index 4bf09bc..0000000 --- a/src/ts/@overflow/commons/context/pouches/constants/reflect.ts +++ /dev/null @@ -1,5 +0,0 @@ -// used to store types to be injected -export const POUCH_DEFINITION = 'loafer:pouch:definition'; - -// used to store types to be injected -export const POUCH_INJECT_DEFINITION = 'loafer:pouch:inject_definition'; diff --git a/src/ts/@overflow/commons/context/pouches/constants/types.ts b/src/ts/@overflow/commons/context/pouches/constants/types.ts deleted file mode 100644 index 04a6e25..0000000 --- a/src/ts/@overflow/commons/context/pouches/constants/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const POUCH_DEFAULT_QUALIFIER = Symbol('__QUALIFIER__'); - -export enum PouchScope { - SINGLETON, - TRANSIENT, -} - diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts b/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts deleted file mode 100644 index 954cd93..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/Inject.ts +++ /dev/null @@ -1,21 +0,0 @@ -import * as METADATA from '../constants'; -import { POUCH_DEFAULT_QUALIFIER } from '../constants'; -import InjectConfig from './InjectConfig'; -import PouchInjectDefinition from '../config/PouchInjectDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchInjectDefinition } from '../util/metadata'; - -const Inject = (injectConfig: InjectConfig = {}) => createDecorator('Inject', { - propertyDecorator: (target: Object, propertyKey: string | symbol): void => { - let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target, true); - pouchInjectDefinition.addInject(injectConfig, propertyKey); - }, - parameterDecorator: (target: Object, propertyKey: string | symbol, parameterIndex: number): void => { - let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target, true); - pouchInjectDefinition.addInject(injectConfig, propertyKey, parameterIndex); - }, - -}); - - -export default Inject; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts b/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts deleted file mode 100644 index 5ecf3c8..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/Injectable.ts +++ /dev/null @@ -1,21 +0,0 @@ -import * as METADATA from '../constants'; -import PouchDefinition from '../config/PouchDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchDefinition } from '../util/metadata'; - -const Injectable = createDecorator('Injectable', { - classDecorator: (target: TFunction): TFunction | void => { - let pouchDefinition: PouchDefinition = getPouchDefinition(target, false); - if (undefined !== pouchDefinition) { - throw new Error('Cannot apply @injectable decorator multiple times.'); - } - - pouchDefinition = getPouchDefinition(target.prototype, true); - - return target; - }, - -}); - - -export default Injectable; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/PostConstruct.ts b/src/ts/@overflow/commons/context/pouches/decorator/PostConstruct.ts deleted file mode 100644 index 89b406c..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/PostConstruct.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as METADATA from '../constants'; -import PouchDefinition from '../config/PouchDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchDefinition } from '../util/metadata'; - -const PostConstruct = createDecorator('PostConstruct', { - methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { - let pouchDefinition = getPouchDefinition(target, false); - if (undefined === pouchDefinition) { - throw new Error('Cannot apply @PostConstruct decorator on the not @Injectable class.'); - } - pouchDefinition.addPostConstruct(propertyKey); - return descriptor; - }, -}); - -export default PostConstruct; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/PreDestroy.ts b/src/ts/@overflow/commons/context/pouches/decorator/PreDestroy.ts deleted file mode 100644 index a1c5e0c..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/PreDestroy.ts +++ /dev/null @@ -1,17 +0,0 @@ -import * as METADATA from '../constants'; -import PouchDefinition from '../config/PouchDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchDefinition } from '../util/metadata'; - -const PreDestroy = createDecorator('PreDestroy', { - methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { - let pouchDefinition = getPouchDefinition(target, false); - if (undefined === pouchDefinition) { - throw new Error('Cannot apply @PreDestroy decorator on the not @Injectable class.'); - } - pouchDefinition.addPreDestroy(propertyKey); - return descriptor; - }, -}); - -export default PreDestroy; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Qualifier.ts b/src/ts/@overflow/commons/context/pouches/decorator/Qualifier.ts deleted file mode 100644 index 819fc56..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/Qualifier.ts +++ /dev/null @@ -1,21 +0,0 @@ -import * as METADATA from '../constants'; -import PouchDefinition from '../config/PouchDefinition'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchDefinition } from '../util/metadata'; - -const Qualifier = (value: string | symbol) => createDecorator('Qualifier', { - classDecorator: (target: TFunction): TFunction | void => { - let pouchDefinition = getPouchDefinition(target, false); - if (undefined === pouchDefinition) { - throw new Error('Cannot apply @Qualifier decorator on the not @Injectable class.'); - } - - if (undefined !== pouchDefinition.qualifier) { - throw new Error('Cannot apply @Qualifier decorator multiple times.'); - } - pouchDefinition.qualifier = value; - return target; - }, -}); - -export default Qualifier; diff --git a/src/ts/@overflow/commons/context/pouches/decorator/Scope.ts b/src/ts/@overflow/commons/context/pouches/decorator/Scope.ts deleted file mode 100644 index 7660731..0000000 --- a/src/ts/@overflow/commons/context/pouches/decorator/Scope.ts +++ /dev/null @@ -1,18 +0,0 @@ -import * as METADATA from '../constants'; -import PouchDefinition from '../config/PouchDefinition'; -import { PouchScope } from '../constants'; -import createDecorator from '@overflow/commons/util/decorators/createDecorator'; -import { getPouchDefinition } from '../util/metadata'; - -const Scope = (value: PouchScope = PouchScope.SINGLETON) => createDecorator('Scope', { - classDecorator: (target: TFunction): TFunction | void => { - let pouchDefinition = getPouchDefinition(target, false); - if (undefined === pouchDefinition) { - throw new Error('Cannot apply @Scope decorator on the not @Injectable class.'); - } - pouchDefinition.scope = value; - return target; - }, -}); - -export default Scope; diff --git a/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts b/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts deleted file mode 100644 index ea753d7..0000000 --- a/src/ts/@overflow/commons/context/pouches/factory/PouchFactory.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { DecoratorType, Newable } from '@overflow/commons/core/constants'; -import * as METADATA from '../constants'; - -import { - PouchScope, - POUCH_DEFAULT_QUALIFIER, -} from '../constants'; - -import PouchDefinition from '../config/PouchDefinition'; - -import PouchInjectDefinition, { - InjectItem, -} from '../config/PouchInjectDefinition'; - -import InjectConfig from '../decorator/InjectConfig'; - -class PouchFactory { - private pouchDefinitionMap: Map; - private pouchInstanceMap: Map>; - - public constructor() { - this.pouchDefinitionMap = new Map(); - this.pouchInstanceMap = new Map(); - } - - /** - * getPouch - */ - public getPouch(type: Newable, ...args: any[]): T { - let qualifier = POUCH_DEFAULT_QUALIFIER; - return this.getPouchByQualifier(type, qualifier, args); - } - - /** - * getPouchByQualifier - */ - public getPouchByQualifier(type: Newable, qualifier: string | symbol, ...args: any[]): T { - let clazz: Function = type.prototype; - - let instance = this._getPouch(clazz, qualifier, args); - - return instance; - } - - - /** - * registerPouch - */ - public registerPouch(pouch: any, qualifier: string | symbol = POUCH_DEFAULT_QUALIFIER): void { - let clazz = Object.getPrototypeOf(pouch); - this._putPouchInstance(clazz, qualifier, pouch); - } - - /** - * registerPouch - */ - public registerPouchDefinition(type: Newable, pouchDefinition: PouchDefinition): void { - let clazz: Function = type.prototype; - if (this.pouchDefinitionMap.has(clazz)) { - throw new Error(`Pouch Definition of [${clazz.name}] is already exist.`); - } - this.pouchDefinitionMap.set(clazz, pouchDefinition); - } - - protected getPouchDefinition(clazz: Function): PouchDefinition { - let pouchDefinition: PouchDefinition = this.pouchDefinitionMap.get(clazz); - if (undefined !== pouchDefinition) { - return pouchDefinition; - } - - if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, clazz) !== true) { - return null; - } - - pouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, clazz); - this.pouchDefinitionMap.set(clazz, pouchDefinition); - - return pouchDefinition; - - } - - protected getPouchInjectDefinition(clazz: Function): PouchInjectDefinition { - if (Reflect.hasOwnMetadata(METADATA.POUCH_INJECT_DEFINITION, clazz) !== true) { - return null; - } - - let pouchInjectDefinition: PouchInjectDefinition = Reflect.getMetadata(METADATA.POUCH_INJECT_DEFINITION, clazz); - - return pouchInjectDefinition; - } - - private _getPouch(clazz: Function, qualifier: string | symbol, ...args: any[]): any { - let pouchDefinition: PouchDefinition = this.getPouchDefinition(clazz); - - let instance: any; - if (null == pouchDefinition) { - if (this._hasPouchInstance(clazz, qualifier)) { - instance = this._getPouchInstance(clazz, qualifier); - } else { - instance = this._newInstance(clazz, pouchDefinition, args); - } - } else { - if (pouchDefinition.scope === PouchScope.TRANSIENT) { - instance = this._newInstance(clazz, pouchDefinition, args); - } else { - if (this._hasPouchInstance(clazz, qualifier)) { - return this._getPouchInstance(clazz, qualifier); - } - instance = this._newInstance(clazz, pouchDefinition, args); - } - } - - return instance; - } - - private _newInstance(clazz: Function, pouchDefinition: PouchDefinition, ...args: any[]): any { - let instance: any; - instance = Object.create(clazz); - instance.constructor.apply(instance, args); - - this._injectDependency(instance, clazz); - - return instance; - } - - private _injectDependency(target: object, clazz: Function): void { - if (clazz.constructor === Object) { - return; - } - - let pouchInjectDefinition: PouchInjectDefinition = this.getPouchInjectDefinition(clazz); - if (null !== pouchInjectDefinition) { - let injectors: Map = pouchInjectDefinition.injectors; - let propertyDescriptor: any; - injectors.forEach((injectItem, key, map) => { - propertyDescriptor = Object.getOwnPropertyDescriptor(target, key); - - switch (injectItem.decoratorType) { - case DecoratorType.PROPERTY: - this._injectDependencyProperty(target, clazz, key, propertyDescriptor, injectItem.propertyConfig); - break; - case DecoratorType.PARAMETER: - this._injectDependencyParameter(target, propertyDescriptor, injectItem.parameterConfigMap); - break; - default: - break; - } - }); - } - this._injectDependency(target, Object.getPrototypeOf(clazz)); - } - - private _injectDependencyProperty(target: object, clazz: Function, propertyKey: string | symbol, - propertyDescriptor: PropertyDescriptor, injectConfig: InjectConfig): void { - let instance = this.getPouch(injectConfig.type, injectConfig.qualifier); - if (injectConfig.required && undefined === instance) { - throw new Error(`Pouch which used by [${clazz.name}.${propertyKey}] is not exist in the context.`); - } - target[propertyKey] = instance; - } - - private _injectDependencyParameter(target: object, propertyDescriptor: PropertyDescriptor, - parameterConfigs: Map): void { - console.log(''); - } - - private _hasPouchInstance(clazz: Function, qualifier: string | symbol): boolean { - if (!this.pouchInstanceMap.has(clazz) || !this.pouchInstanceMap.get(clazz).has(qualifier)) { - return false; - } - return true; - } - - private _getPouchInstance(clazz: Function, qualifier: string | symbol): any { - if (!this._hasPouchInstance(clazz, qualifier)) { - return null; - } - return this.pouchInstanceMap.get(clazz).get(qualifier); - } - - private _putPouchInstance(clazz: Function, qualifier: string | symbol, instance: any): void { - let instanceMap: Map = this.pouchInstanceMap.get(clazz); - - if (undefined === instanceMap) { - instanceMap = new Map(); - this.pouchInstanceMap.set(clazz, instanceMap); - } - - instanceMap.set(qualifier, instance); - } - -} - -export default PouchFactory; diff --git a/src/ts/@overflow/commons/context/pouches/util/metadata/inject.ts b/src/ts/@overflow/commons/context/pouches/util/metadata/inject.ts deleted file mode 100644 index 1dc8dc4..0000000 --- a/src/ts/@overflow/commons/context/pouches/util/metadata/inject.ts +++ /dev/null @@ -1,8 +0,0 @@ -import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata'; - -import * as METADATA from '../../constants'; -import PouchInjectDefinition from '../../config/PouchInjectDefinition'; - -export const getPouchInjectDefinition = - (target: TFunction | Object, isCreate: boolean = false) => - getClassMetadata(target, METADATA.POUCH_INJECT_DEFINITION, PouchInjectDefinition, isCreate); diff --git a/src/ts/@overflow/commons/context/pouches/util/metadata/pouch.ts b/src/ts/@overflow/commons/context/pouches/util/metadata/pouch.ts deleted file mode 100644 index 5d66a71..0000000 --- a/src/ts/@overflow/commons/context/pouches/util/metadata/pouch.ts +++ /dev/null @@ -1,8 +0,0 @@ -import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata'; - -import * as METADATA from '../../constants'; -import PouchDefinition from '../../config/PouchDefinition'; - -export const getPouchDefinition = - (target: TFunction | Object, isCreate: boolean = false) => - getClassMetadata(target, METADATA.POUCH_DEFINITION, PouchDefinition, isCreate); diff --git a/src/ts/@overflow/commons/context/util/metadata/configuration.ts b/src/ts/@overflow/commons/context/util/metadata/configuration.ts deleted file mode 100644 index ee693ec..0000000 --- a/src/ts/@overflow/commons/context/util/metadata/configuration.ts +++ /dev/null @@ -1,9 +0,0 @@ -import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata'; - -import * as METADATA from '../../constants'; -import ConfigurationDefinition from '../../config/ConfigurationDefinition'; - -export const getConfigurationDefinition = - (target: TFunction | Object, isCreate: boolean = false) => - getClassMetadata(target, METADATA.CONTEXT_CONFIGURATION_DEFINITION, ConfigurationDefinition, isCreate); - diff --git a/src/ts/@overflow/commons/redux-saga/index.ts b/src/ts/@overflow/commons/redux-saga/index.ts deleted file mode 100644 index bed9be2..0000000 --- a/src/ts/@overflow/commons/redux-saga/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { SagaIterator } from 'redux-saga'; - -export type SagaWatcher = () => SagaIterator; diff --git a/src/ts/@overflow/commons/redux/action/asyncRequest.ts b/src/ts/@overflow/commons/redux/action/asyncRequest.ts new file mode 100644 index 0000000..2c9c772 --- /dev/null +++ b/src/ts/@overflow/commons/redux/action/asyncRequest.ts @@ -0,0 +1,22 @@ +import Action from '@overflow/commons/redux/Action'; +import AsyncRequestPayload from '../payload/AsyncRequestPayload'; + +// Action Type +export type REQUEST = '@@overflow/anync/REQUEST'; + +export const REQUEST: REQUEST = '@@overflow/anync/REQUEST'; + +// Action Creater +export type request = (service: string, method: string, requestType: string, ...args: any[]) => Action; + +export const request: request = (service: string, method: string, requestType: string, ...args: any[]): Action => { + return { + type: REQUEST, + payload: { + service: service, + method: method, + requestType: requestType, + args: args, + }, + }; +}; diff --git a/src/ts/@overflow/commons/redux/payload/AsyncRequestPayload.ts b/src/ts/@overflow/commons/redux/payload/AsyncRequestPayload.ts new file mode 100644 index 0000000..b769db1 --- /dev/null +++ b/src/ts/@overflow/commons/redux/payload/AsyncRequestPayload.ts @@ -0,0 +1,10 @@ +import Action from '@overflow/commons/redux/Action'; + +interface AsyncRequestPayload { + service: string; + method: string; + requestType: string; + args?: any[]; +} + +export default AsyncRequestPayload; diff --git a/src/ts/@overflow/member/redux/saga/signIn.ts b/src/ts/@overflow/commons/redux/saga/asyncRequest.ts similarity index 53% rename from src/ts/@overflow/member/redux/saga/signIn.ts rename to src/ts/@overflow/commons/redux/saga/asyncRequest.ts index 7ec2450..244d352 100644 --- a/src/ts/@overflow/member/redux/saga/signIn.ts +++ b/src/ts/@overflow/commons/redux/saga/asyncRequest.ts @@ -1,24 +1,21 @@ import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; +import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; -import { SagaWatcher } from '@overflow/commons/redux-saga'; - -import AppContext from '@overflow/commons/context/AppContext'; +import AppContext from '@loafer/context/AppContext'; import Action from '@overflow/commons/redux/Action'; -import Member from '../../api/model/Member'; -import MemberService from '../../api/service/MemberService'; -import * as SigninActions from '../action/signIn'; -import SigninPayload from '../payload/SignInPayload'; +import * as AsyncRequestActions from '../action/asyncRequest'; +import AsyncRequestPayload from '../payload/AsyncRequestPayload'; -function* signin(action: Action): SagaIterator { +function* request(action: Action): SagaIterator { try { - const {signinId, signinPw} = action.payload; + const {service, method, requestType, args} = action.payload; // yield put({ // type: types.SENDING_REQUEST, // payload: {sendingRequest: true}, // }); - let memberService = AppContext.getInstance().getPouch(MemberService); + let serviceInstance = AppContext.getInstance().getService(service); + const member = yield call({context: memberService, fn: memberService.signin}, signinId, signinPw); @@ -36,8 +33,8 @@ function* signin(action: Action): SagaIterator { } } -function* watchSignin(): SagaIterator { - yield takeLatest(SigninActions.REQUEST, signin); +function* watchAsyncRequest(): SagaIterator { + yield takeEvery(AsyncRequestActions.REQUEST, request); } const sagaWatchers: SagaWatcher[] = [watchSignin]; diff --git a/src/ts/@overflow/commons/util/metadata/getClassMetadata.ts b/src/ts/@overflow/commons/util/metadata/getClassMetadata.ts deleted file mode 100644 index a26d8ac..0000000 --- a/src/ts/@overflow/commons/util/metadata/getClassMetadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -export type MetadataDefinable = {new(target: Function): T}; - -const getClassMetadata = (target: TFunction | Object, - metadataKey: any, - definitionType: MetadataDefinable, - isCreate: boolean = false): DefinitionType => { - - let clazz = target instanceof Function ? target.prototype : target; - let definition: DefinitionType; - if (Reflect.hasOwnMetadata(metadataKey, clazz) !== true) { - if (!isCreate) { - return undefined; - } - definition = Object.create(definitionType.prototype); - definition.constructor.call(definition, clazz); - - Reflect.defineMetadata(metadataKey, definition, clazz); - } else { - definition = Reflect.getMetadata(metadataKey, clazz); - } - return definition; -}; - -export default getClassMetadata; diff --git a/src/ts/@overflow/discovery/redux/saga/discovery.ts b/src/ts/@overflow/discovery/redux/saga/discovery.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/saga/member_regist.ts b/src/ts/@overflow/domain/redux/saga/member_regist.ts deleted file mode 100644 index a1a77a8..0000000 --- a/src/ts/@overflow/domain/redux/saga/member_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import DomainMember from '../../api/model/DomainMember'; -import DomainMemberService from '../../api/service/DomainMemberService'; -import * as MemberRegistActions from '../action/member_regist'; -import MemberRegistPayload from '../payload/MemberRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const dm = action.payload.domainMember; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let domainMemberService = AppContext.getInstance().getPouch(DomainMemberService); - yield call({context: domainMemberService, fn: domainMemberService.regist}, dm); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(MemberRegistActions.requestSuccess()); - } catch (e) { - yield put(MemberRegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(MemberRegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/domain/redux/saga/regist.ts b/src/ts/@overflow/domain/redux/saga/regist.ts deleted file mode 100644 index 32e572d..0000000 --- a/src/ts/@overflow/domain/redux/saga/regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Domain from '../../api/model/Domain'; -import DomainService from '../../api/service/DomainService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const dm = action.payload.domain; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let domainService = AppContext.getInstance().getPouch(DomainService); - yield call({context: domainService, fn: domainService.regist}, dm); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess()); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/email/redux/saga/modify.ts b/src/ts/@overflow/email/redux/saga/modify.ts deleted file mode 100644 index 70de8b0..0000000 --- a/src/ts/@overflow/email/redux/saga/modify.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Created by geek on 17. 7. 4. - */ - -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import EmailAuth from '@overflow/email/api/model/EmailAuth'; - -import EmailAuthService from '@overflow/email/api/service/EmailAuthService'; -import * as ModifyAction from '../action/modify'; -import ModifyPayload from '../payload/ModifyPayload'; - -function* modify(action: Action): SagaIterator { - try { - const ea = action.payload.emailAuth; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let emailAuthService = AppContext.getInstance().getPouch(EmailAuthService); - const emailAuth = yield call({context: emailAuthService, fn: emailAuthService.modify}, ea); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ModifyAction.requestSuccess(emailAuth)); - } catch (e) { - yield put(ModifyAction.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchModify(): SagaIterator { - yield takeLatest(ModifyAction.REQUEST, modify); -} diff --git a/src/ts/@overflow/email/redux/saga/read.ts b/src/ts/@overflow/email/redux/saga/read.ts deleted file mode 100644 index 26f3d51..0000000 --- a/src/ts/@overflow/email/redux/saga/read.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import EmailAuth from '@overflow/email/api/model/EmailAuth'; - -import EmailAuthService from '@overflow/email/api/service/EmailAuthService'; -import * as ReadAction from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const id = action.payload.id; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let emailAuthService = AppContext.getInstance().getPouch(EmailAuthService); - const emailAuth = yield call({context: emailAuthService, fn: emailAuthService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadAction.requestSuccess(emailAuth)); - } catch (e) { - yield put(ReadAction.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadAction.REQUEST, read); -} diff --git a/src/ts/@overflow/email/redux/saga/read_by_auth_key.ts b/src/ts/@overflow/email/redux/saga/read_by_auth_key.ts deleted file mode 100644 index c656841..0000000 --- a/src/ts/@overflow/email/redux/saga/read_by_auth_key.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import EmailAuth from '@overflow/email/api/model/EmailAuth'; - -import EmailAuthService from '@overflow/email/api/service/EmailAuthService'; -import * as ReadByAuthKeyAction from '../action/read_by_auth_key'; -import ReadByAuthKeyPayload from '../payload/ReadByAuthKeyPayload'; - -function* readByAuthKey(action: Action): SagaIterator { - try { - const authKey = action.payload.authKey; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let emailAuthService = AppContext.getInstance().getPouch(EmailAuthService); - const emailAuth = yield call({context: emailAuthService, fn: emailAuthService.readByAuthKey}, authKey); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadByAuthKeyAction.requestSuccess(emailAuth)); - } catch (e) { - yield put(ReadByAuthKeyAction.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadByAuthKey(): SagaIterator { - yield takeLatest(ReadByAuthKeyAction.REQUEST, readByAuthKey); -} diff --git a/src/ts/@overflow/email/redux/saga/read_by_member.ts b/src/ts/@overflow/email/redux/saga/read_by_member.ts deleted file mode 100644 index 575e9ef..0000000 --- a/src/ts/@overflow/email/redux/saga/read_by_member.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import EmailAuth from '@overflow/email/api/model/EmailAuth'; - -import EmailAuthService from '@overflow/email/api/service/EmailAuthService'; -import * as ReadByMemberAction from '../action/read_by_member'; -import ReadByMemberPayload from '../payload/ReadByMemberPayload'; - -function* readByMember(action: Action): SagaIterator { - try { - const id = action.payload.memberId; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let emailAuthService = AppContext.getInstance().getPouch(EmailAuthService); - const emailAuths = yield call({context: emailAuthService, fn: emailAuthService.readByMember}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadByMemberAction.requestSuccess(emailAuths)); - } catch (e) { - yield put(ReadByMemberAction.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadByMember(): SagaIterator { - yield takeLatest(ReadByMemberAction.REQUEST, readByMember); -} diff --git a/src/ts/@overflow/email/redux/saga/send_email_by_member.ts b/src/ts/@overflow/email/redux/saga/send_email_by_member.ts deleted file mode 100644 index b69c956..0000000 --- a/src/ts/@overflow/email/redux/saga/send_email_by_member.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import EmailAuth from '@overflow/email/api/model/EmailAuth'; - -import EmailAuthService from '@overflow/email/api/service/EmailAuthService'; -import * as SendEmailAction from '../action/send_email_by_member'; -import SendEmailPayload from '../payload/SendEmailByMemberPayload'; - -function* sendEmail(action: Action): SagaIterator { - try { - const {memberId, email} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let emailAuthService = AppContext.getInstance().getPouch(EmailAuthService); - const emailAuth = yield call({context: emailAuthService, fn: emailAuthService.sendEmailByMember}, memberId, email); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(SendEmailAction.requestSuccess(emailAuth)); - } catch (e) { - yield put(SendEmailAction.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchSendEmail(): SagaIterator { - yield takeLatest(SendEmailAction.REQUEST, sendEmail); -} diff --git a/src/ts/@overflow/history/redux/saga/_ b/src/ts/@overflow/history/redux/saga/_ deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/infra/redux/saga/host_read.ts b/src/ts/@overflow/infra/redux/saga/host_read.ts deleted file mode 100644 index 0ca2b94..0000000 --- a/src/ts/@overflow/infra/redux/saga/host_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraHost from '../../api/model/InfraHost'; -import InfraHostService from '../../api/service/InfraHostService'; -import * as ReadActions from '../action/host_read'; -import HostReadPayload from '../payload/HostReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraHostService = AppContext.getInstance().getPouch(InfraHostService); - const retApikey = yield call({context: infraHostService, fn: infraHostService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchHostRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/host_regist.ts b/src/ts/@overflow/infra/redux/saga/host_regist.ts deleted file mode 100644 index bb54fa4..0000000 --- a/src/ts/@overflow/infra/redux/saga/host_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraHost from '../../api/model/InfraHost'; -import InfraHostService from '../../api/service/InfraHostService'; -import * as RegistActions from '../action/host_regist'; -import HostRegistPayload from '../payload/HostRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraHost} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraHostService = AppContext.getInstance().getPouch(InfraHostService); - const retApikey = yield call({context: infraHostService, fn: infraHostService.regist}, infraHost); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchHostRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/machine_read.ts b/src/ts/@overflow/infra/redux/saga/machine_read.ts deleted file mode 100644 index 503b52f..0000000 --- a/src/ts/@overflow/infra/redux/saga/machine_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraMachine from '../../api/model/InfraMachine'; -import InfraMachineService from '../../api/service/InfraMachineService'; -import * as ReadActions from '../action/machine_read'; -import MachineReadPayload from '../payload/MachineReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraMachineService = AppContext.getInstance().getPouch(InfraMachineService); - const retApikey = yield call({context: infraMachineService, fn: infraMachineService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchMachineRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/machine_regist.ts b/src/ts/@overflow/infra/redux/saga/machine_regist.ts deleted file mode 100644 index f55baa6..0000000 --- a/src/ts/@overflow/infra/redux/saga/machine_regist.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraMachine from '../../api/model/InfraMachine'; -import InfraMachineService from '../../api/service/InfraMachineService'; -import * as RegistActions from '../action/machine_regist'; -import MachineRegistPayload from '../payload/MachineRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraMachine} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - - let infraMachineService = AppContext.getInstance().getPouch(InfraMachineService); - const retApikey = yield call({context: infraMachineService, fn: infraMachineService.regist}, infraMachine); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchMachineRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_application_read.ts b/src/ts/@overflow/infra/redux/saga/os_application_read.ts deleted file mode 100644 index 590a20c..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_application_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSApplication from '../../api/model/InfraOSApplication'; -import InfraOSApplicationService from '../../api/service/InfraOSApplicationService'; -import * as ReadActions from '../action/os_application_read'; -import OSApplicationReadPayload from '../payload/OSApplicationReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSApplicationService = AppContext.getInstance().getPouch(InfraOSApplicationService); - const retApikey = yield call({context: infraOSApplicationService, fn: infraOSApplicationService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSApplicationRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_application_regist.ts b/src/ts/@overflow/infra/redux/saga/os_application_regist.ts deleted file mode 100644 index 2c8a00d..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_application_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSApplication from '../../api/model/InfraOSApplication'; -import InfraOSApplicationService from '../../api/service/InfraOSApplicationService'; -import * as RegistActions from '../action/os_application_regist'; -import OSApplicationRegistPayload from '../payload/OSApplicationRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraOSApplication} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSApplicationService = AppContext.getInstance().getPouch(InfraOSApplicationService); - const retApikey = yield call({context: infraOSApplicationService, fn: infraOSApplicationService.regist}, infraOSApplication); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSApplicationRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_daemon_read.ts b/src/ts/@overflow/infra/redux/saga/os_daemon_read.ts deleted file mode 100644 index 1ab45a9..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_daemon_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSDaemon from '../../api/model/InfraOSDaemon'; -import InfraOSDaemonService from '../../api/service/InfraOSDaemonService'; -import * as ReadActions from '../action/os_daemon_read'; -import OSDaemonReadPayload from '../payload/OSDaemonReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSDaemonService = AppContext.getInstance().getPouch(InfraOSDaemonService); - const retApikey = yield call({context: infraOSDaemonService, fn: infraOSDaemonService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSDaemonRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_daemon_regist.ts b/src/ts/@overflow/infra/redux/saga/os_daemon_regist.ts deleted file mode 100644 index ac7067f..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_daemon_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSDaemon from '../../api/model/InfraOSDaemon'; -import InfraOSDaemonService from '../../api/service/InfraOSDaemonService'; -import * as RegistActions from '../action/os_daemon_regist'; -import OSDaemonRegistPayload from '../payload/OSDaemonRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraOSDaemon} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSDaemonService = AppContext.getInstance().getPouch(InfraOSDaemonService); - const retApikey = yield call({context: infraOSDaemonService, fn: infraOSDaemonService.regist}, infraOSDaemon); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSDaemonRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_port_read.ts b/src/ts/@overflow/infra/redux/saga/os_port_read.ts deleted file mode 100644 index b8f47a2..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_port_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSPort from '../../api/model/InfraOSPort'; -import InfraOSPortService from '../../api/service/InfraOSPortService'; -import * as ReadActions from '../action/os_port_read'; -import OSPortReadPayload from '../payload/OSPortReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSPortService = AppContext.getInstance().getPouch(InfraOSPortService); - const retApikey = yield call({context: infraOSPortService, fn: infraOSPortService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSPortRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_port_regist.ts b/src/ts/@overflow/infra/redux/saga/os_port_regist.ts deleted file mode 100644 index 01bc7ee..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_port_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOSPort from '../../api/model/InfraOSPort'; -import InfraOSPortService from '../../api/service/InfraOSPortService'; -import * as RegistActions from '../action/os_port_regist'; -import OSPortRegistPayload from '../payload/OSPortRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraOSPort} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSPortService = AppContext.getInstance().getPouch(InfraOSPortService); - const retApikey = yield call({context: infraOSPortService, fn: infraOSPortService.regist}, infraOSPort); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSPortRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_read.ts b/src/ts/@overflow/infra/redux/saga/os_read.ts deleted file mode 100644 index 5b30c8b..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOS from '../../api/model/InfraOS'; -import InfraOSService from '../../api/service/InfraOSService'; -import * as ReadActions from '../action/os_read'; -import OSReadPayload from '../payload/OSReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSService = AppContext.getInstance().getPouch(InfraOSService); - const retApikey = yield call({context: infraOSService, fn: infraOSService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/os_regist.ts b/src/ts/@overflow/infra/redux/saga/os_regist.ts deleted file mode 100644 index 3cfd069..0000000 --- a/src/ts/@overflow/infra/redux/saga/os_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraOS from '../../api/model/InfraOS'; -import InfraOSService from '../../api/service/InfraOSService'; -import * as RegistActions from '../action/os_regist'; -import OSRegistPayload from '../payload/OSRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraOS} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraOSService = AppContext.getInstance().getPouch(InfraOSService); - const retApikey = yield call({context: infraOSService, fn: infraOSService.regist}, infraOS); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchOSRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/read.ts b/src/ts/@overflow/infra/redux/saga/read.ts deleted file mode 100644 index d93e47d..0000000 --- a/src/ts/@overflow/infra/redux/saga/read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Infra from '../../api/model/Infra'; -import InfraService from '../../api/service/InfraService'; -import * as ReadActions from '../action/os_read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraService = AppContext.getInstance().getPouch(InfraService); - const retApikey = yield call({context: infraService, fn: infraService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/regist.ts b/src/ts/@overflow/infra/redux/saga/regist.ts deleted file mode 100644 index b22fa04..0000000 --- a/src/ts/@overflow/infra/redux/saga/regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Infra from '../../api/model/Infra'; -import InfraService from '../../api/service/InfraService'; -import * as RegistActions from '../action/os_regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infra} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraService = AppContext.getInstance().getPouch(InfraService); - const retApikey = yield call({context: infraService, fn: infraService.regist}, infra); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/infra/redux/saga/service_read.ts b/src/ts/@overflow/infra/redux/saga/service_read.ts deleted file mode 100644 index 82591b9..0000000 --- a/src/ts/@overflow/infra/redux/saga/service_read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraService from '../../api/model/InfraService'; -import InfraServiceService from '../../api/service/InfraServiceService'; -import * as ReadActions from '../action/service_read'; -import ServiceReadPayload from '../payload/ServiceReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraServiceService = AppContext.getInstance().getPouch(InfraServiceService); - const retApikey = yield call({context: infraServiceService, fn: infraServiceService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchServiceRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/infra/redux/saga/service_regist.ts b/src/ts/@overflow/infra/redux/saga/service_regist.ts deleted file mode 100644 index 368c919..0000000 --- a/src/ts/@overflow/infra/redux/saga/service_regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import InfraService from '../../api/model/InfraService'; -import InfraServiceService from '../../api/service/InfraServiceService'; -import * as RegistActions from '../action/service_regist'; -import ServiceRegistPayload from '../payload/ServiceRegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {infraService} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let infraServiceService = AppContext.getInstance().getPouch(InfraServiceService); - const retApikey = yield call({context: infraServiceService, fn: infraServiceService.regist}, infraService); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchServiceRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/member/redux/action/signIn.ts b/src/ts/@overflow/member/redux/action/signIn.ts index dd467a4..3bdb6ff 100644 --- a/src/ts/@overflow/member/redux/action/signIn.ts +++ b/src/ts/@overflow/member/redux/action/signIn.ts @@ -1,42 +1,8 @@ -import Action from '@overflow/commons/redux/Action'; -import Member from '@overflow/member/api/model/Member'; - -import SigninPayload from '../payload/SignInPayload'; - // Action Type export type REQUEST = '@overflow/member/signin/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE'; +export type REQUEST_SUCCESS = '@overflow/member/signin/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/member/signin/REQUEST/FAILURE'; export const REQUEST: REQUEST = '@overflow/member/signin/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE'; - -// Action Creater -export type request = (signinId: string, signinPw: string) => Action; -export type requestSuccess = (member: Member) => Action; -export type requestFailure = (error: Error) => Action; - -export const request: request = (signinId: string, signinPw: string): Action => { - return { - type: REQUEST, - payload: { - signinId: signinId, - signinPw: signinPw, - }, - }; -}; - -export const requestSuccess: requestSuccess = (member: Member): Action => { - return { - type: REQUEST_SUCCESS, - payload: member, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signin/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signin/REQUEST/FAILURE'; diff --git a/src/ts/@overflow/member/redux/saga/modify.ts b/src/ts/@overflow/member/redux/saga/modify.ts deleted file mode 100644 index 4249666..0000000 --- a/src/ts/@overflow/member/redux/saga/modify.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Member from '../../api/model/Member'; -import MemberService from '../../api/service/MemberService'; -import * as ModifyActions from '../action/modify'; -import ModifyPayload from '../payload/ModifyPayload'; - -function* modify(action: Action): SagaIterator { - try { - const tempMember = action.payload.member; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let memberService = AppContext.getInstance().getPouch(MemberService); - const member = yield call({context: memberService, fn: memberService.modify}, tempMember); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ModifyActions.requestSuccess(member)); - } catch (e) { - yield put(ModifyActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchModify(): SagaIterator { - yield takeLatest(ModifyActions.REQUEST, modify); -} diff --git a/src/ts/@overflow/member/redux/saga/read.ts b/src/ts/@overflow/member/redux/saga/read.ts deleted file mode 100644 index fc66893..0000000 --- a/src/ts/@overflow/member/redux/saga/read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Member from '../../api/model/Member'; -import MemberService from '../../api/service/MemberService'; -import * as ReadActions from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const id = action.payload.id; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let memberService = AppContext.getInstance().getPouch(MemberService); - const member = yield call({context: memberService, fn: memberService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(member)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/member/redux/saga/signOut.ts b/src/ts/@overflow/member/redux/saga/signOut.ts deleted file mode 100644 index a15ae13..0000000 --- a/src/ts/@overflow/member/redux/saga/signOut.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import Member from '@overflow/member/api/model/Member'; - -import SignoutActionTypes from '../action/signOut'; -import SigninState, { defaultState as signinDefaultState } from '../state/SignIn'; - -export type reducer = (state: SigninState, action: Action) => SigninState; - -export const reducer: reducer = (state: SigninState = signinDefaultState, action: Action): SigninState => { - switch (action.type) { - case SignoutActionTypes.REQUEST_SUCCESS: - { - const aaa: SigninState = { - ...state, - isAuthenticated: true, - }; - - return aaa; - } - case SignoutActionTypes.REQUEST_FAILURE: - { - return state; - } - default: - return state; - } -}; diff --git a/src/ts/@overflow/member/redux/saga/signUp.ts b/src/ts/@overflow/member/redux/saga/signUp.ts deleted file mode 100644 index b9fed32..0000000 --- a/src/ts/@overflow/member/redux/saga/signUp.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Action from '@overflow/commons/redux/Action'; -import Member from '@overflow/member/api/model/Member'; - -import SignupActionTypes from '../action/signUp'; -import SignupState, { defaultState as signupDefaultState } from '../state/SignUp'; - -export type reducer = (state: SignupState, action: Action) => SignupState; - -export const reducer: reducer = (state: SignupState = signupDefaultState, action: Action): SignupState => { - switch (action.type) { - case SignupActionTypes.REQUEST_SUCCESS: - { - let member = (>action).payload; - - const aaa: SignupState = { - ...state, - isRegistered: true, - }; - - return aaa; - } - case SignupActionTypes.REQUEST_FAILURE: - { - return state; - } - default: - return state; - } -}; diff --git a/src/ts/@overflow/meta/redux/saga/_ b/src/ts/@overflow/meta/redux/saga/_ deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/noauthprobe/redux/saga/read.ts b/src/ts/@overflow/noauthprobe/redux/saga/read.ts deleted file mode 100644 index a05aa76..0000000 --- a/src/ts/@overflow/noauthprobe/redux/saga/read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import NoAuthProbe from '../../api/model/NoAuthProbe'; -import NoAuthProbeService from '../../api/service/NoAuthProbeService'; -import * as ReadActions from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let noAuthProbeService = AppContext.getInstance().getPouch(NoAuthProbeService); - const retApikey = yield call({context: noAuthProbeService, fn: noAuthProbeService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retApikey)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/noauthprobe/redux/saga/read_all_by_domain.ts b/src/ts/@overflow/noauthprobe/redux/saga/read_all_by_domain.ts deleted file mode 100644 index 2d4c86e..0000000 --- a/src/ts/@overflow/noauthprobe/redux/saga/read_all_by_domain.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import NoAuthProbe from '../../api/model/NoAuthProbe'; -import NoAuthProbeService from '../../api/service/NoAuthProbeService'; -import * as ReadActions from '../action/read_all_by_domain'; -import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; - -function* readAllByDomain(action: Action): SagaIterator { - try { - const {domain} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let noAuthProbeService = AppContext.getInstance().getPouch(NoAuthProbeService); - const noauthProbeList = yield call({context: noAuthProbeService, fn: noAuthProbeService.readAllByDomain}, domain); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(noauthProbeList)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllByDomain(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, readAllByDomain); -} diff --git a/src/ts/@overflow/noauthprobe/redux/saga/regist.ts b/src/ts/@overflow/noauthprobe/redux/saga/regist.ts deleted file mode 100644 index fbbf66c..0000000 --- a/src/ts/@overflow/noauthprobe/redux/saga/regist.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import NoAuthProbe from '../../api/model/NoAuthProbe'; -import NoAuthProbeService from '../../api/service/NoAuthProbeService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {noAuthProbe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let noAuthProbeService = AppContext.getInstance().getPouch(NoAuthProbeService); - const retApikey = yield call({context: noAuthProbeService, fn: noAuthProbeService.regist}, noAuthProbe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retApikey)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts b/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts deleted file mode 100644 index af789c9..0000000 --- a/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; -import { SagaWatcher } from '@overflow/commons/redux-saga'; -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; -import ProbeService from '../../api/service/ProbeService'; -import * as ReadAllByDomainActions from '../action/read_all_by_domain'; -import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; - -function* readAllByDomain(action: Action): SagaIterator { - try { - const { domain } = action.payload; - - let probeService = AppContext.getInstance().getPouch(ProbeService); - const ret = yield call({context: probeService, fn: probeService.readAllByDomain}, domain); - - yield put(ReadAllByDomainActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadAllByDomainActions.requestFailure(e)); - // tslint:disable-next-line:no-empty - } finally { - } -} - -export function* watchReadAllByDomain(): SagaIterator { - yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain); -} - -const sagaWatchers: SagaWatcher[] = [watchReadAllByDomain]; - -export default sagaWatchers; diff --git a/src/ts/@overflow/probe/redux/saga/read_by_probekey.ts b/src/ts/@overflow/probe/redux/saga/read_by_probekey.ts deleted file mode 100644 index c59ea9c..0000000 --- a/src/ts/@overflow/probe/redux/saga/read_by_probekey.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Probe from '../../api/model/Probe'; -import ProbeService from '../../api/service/ProbeService'; -import * as ReadByProbeKeyActions from '../action/read_by_probekey'; -import ReadByProbeKeyPayload from '../payload/ReadByProbeKeyPayload'; - -function* readByProbeKey(action: Action): SagaIterator { - try { - const {probeKey} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let probeService = AppContext.getInstance().getPouch(ProbeService); - const ret = yield call({context: probeService, fn: probeService.readByProbeKey}, probeKey); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadByProbeKeyActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadByProbeKeyActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadByProbeKey(): SagaIterator { - yield takeLatest(ReadByProbeKeyActions.REQUEST, readByProbeKey); -} diff --git a/src/ts/@overflow/probe/redux/saga/regist.ts b/src/ts/@overflow/probe/redux/saga/regist.ts deleted file mode 100644 index 001db2d..0000000 --- a/src/ts/@overflow/probe/redux/saga/regist.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Probe from '../../api/model/Probe'; -import ProbeService from '../../api/service/ProbeService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {probe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let probeService = AppContext.getInstance().getPouch(ProbeService); - const ret = yield call({context: probeService, fn: probeService.regist}, probe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(ret)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts b/src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts deleted file mode 100644 index 32135f0..0000000 --- a/src/ts/@overflow/probe/redux/saga/task_read_all_by_probe.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import ProbeTaskService from '../../api/service/ProbeTaskService'; -import * as TaskReadAllByProbeActions from '../action/task_read_all_by_probe'; -import TaskReadAllByProbePayload from '../payload/TaskReadAllByProbePayload'; - -function* readAllTaskByProbe(action: Action): SagaIterator { - try { - const {probe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let probeTaskService = AppContext.getInstance().getPouch(ProbeTaskService); - const ret = yield call({context: probeTaskService, fn: probeTaskService.readAllByProbe}, probe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(TaskReadAllByProbeActions.requestSuccess(ret)); - } catch (e) { - yield put(TaskReadAllByProbeActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllTaskByProbe(): SagaIterator { - yield takeLatest(TaskReadAllByProbeActions.REQUEST, readAllTaskByProbe); -} diff --git a/src/ts/@overflow/probe/redux/saga/task_regist.ts b/src/ts/@overflow/probe/redux/saga/task_regist.ts deleted file mode 100644 index 84ff7a4..0000000 --- a/src/ts/@overflow/probe/redux/saga/task_regist.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import ProbeTask from '../../api/model/ProbeTask'; -import ProbeTaskService from '../../api/service/ProbeTaskService'; -import * as TaskRegistActions from '../action/task_regist'; -import TaskRegistPayload from '../payload/TaskRegistPayload'; - -function* registTask(action: Action): SagaIterator { - try { - const {probeTask} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let probeTaskService = AppContext.getInstance().getPouch(ProbeTaskService); - const ret = yield call({context: probeTaskService, fn: probeTaskService.regist}, probeTask); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(TaskRegistActions.requestSuccess(ret)); - } catch (e) { - yield put(TaskRegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegistTask(): SagaIterator { - yield takeLatest(TaskRegistActions.REQUEST, registTask); -} diff --git a/src/ts/@overflow/sensor/redux/saga/item_read.ts b/src/ts/@overflow/sensor/redux/saga/item_read.ts deleted file mode 100644 index f949634..0000000 --- a/src/ts/@overflow/sensor/redux/saga/item_read.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import SensorItem from '../../api/model/SensorItem'; -import SensorItemService from '../../api/service/SensorItemService'; -import * as ItemReadActions from '../action/item_read'; -import ItemReadPayload from '../payload/ItemReadPayload'; - -function* readItem(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorItemService = AppContext.getInstance().getPouch(SensorItemService); - const ret = yield call({context: sensorItemService, fn: sensorItemService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ItemReadActions.requestSuccess(ret)); - } catch (e) { - yield put(ItemReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadItem(): SagaIterator { - yield takeLatest(ItemReadActions.REQUEST, readItem); -} diff --git a/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts b/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts deleted file mode 100644 index 78a4c45..0000000 --- a/src/ts/@overflow/sensor/redux/saga/item_read_by_sensor.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import SensorItem from '../../api/model/SensorItem'; -import SensorItemService from '../../api/service/SensorItemService'; -import * as ItemReadAllBySensorActions from '../action/item_read_all_by_sensor'; -import ItemReadAllBySensorActionsPayload from '../payload/ItemReadAllBySensorPayload'; - -function* readAllItemBySensor(action: Action): SagaIterator { - try { - const {sensor} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorItemService = AppContext.getInstance().getPouch(SensorItemService); - const ret = yield call({context: sensorItemService, fn: sensorItemService.readAllBySensor}, sensor); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ItemReadAllBySensorActions.requestSuccess(ret)); - } catch (e) { - yield put(ItemReadAllBySensorActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllItemBySensor(): SagaIterator { - yield takeLatest(ItemReadAllBySensorActions.REQUEST, readAllItemBySensor); -} diff --git a/src/ts/@overflow/sensor/redux/saga/item_regist.ts b/src/ts/@overflow/sensor/redux/saga/item_regist.ts deleted file mode 100644 index d485bb6..0000000 --- a/src/ts/@overflow/sensor/redux/saga/item_regist.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import SensorItem from '../../api/model/SensorItem'; -import SensorItemService from '../../api/service/SensorItemService'; -import * as ItemRegistActions from '../action/item_regist'; -import ItemRegistPayload from '../payload/ItemRegistPayload'; - -function* registItem(action: Action): SagaIterator { - try { - const {sensorItem} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorItemService = AppContext.getInstance().getPouch(SensorItemService); - const ret = yield call({context: sensorItemService, fn: sensorItemService.regist}, sensorItem); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ItemRegistActions.requestSuccess(ret)); - } catch (e) { - yield put(ItemRegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegistItem(): SagaIterator { - yield takeLatest(ItemRegistActions.REQUEST, registItem); -} diff --git a/src/ts/@overflow/sensor/redux/saga/item_remove.ts b/src/ts/@overflow/sensor/redux/saga/item_remove.ts deleted file mode 100644 index 24af218..0000000 --- a/src/ts/@overflow/sensor/redux/saga/item_remove.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import SensorItem from '../../api/model/SensorItem'; -import SensorItemService from '../../api/service/SensorItemService'; -import * as ItemRemoveActions from '../action/item_remove'; -import ItemRemovePayload from '../payload/ItemRemovePayload'; - -function* removeItem(action: Action): SagaIterator { - try { - const {sensorItem} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorItemService = AppContext.getInstance().getPouch(SensorItemService); - yield call({context: sensorItemService, fn: sensorItemService.remove}, sensorItem); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ItemRemoveActions.requestSuccess()); - } catch (e) { - yield put(ItemRemoveActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRemoveItem(): SagaIterator { - yield takeLatest(ItemRemoveActions.REQUEST, removeItem); -} diff --git a/src/ts/@overflow/sensor/redux/saga/read.ts b/src/ts/@overflow/sensor/redux/saga/read.ts deleted file mode 100644 index def367b..0000000 --- a/src/ts/@overflow/sensor/redux/saga/read.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as ReadActions from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts b/src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts deleted file mode 100644 index 0586c5e..0000000 --- a/src/ts/@overflow/sensor/redux/saga/read_all_by_domain.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as ReadAllByDomainActions from '../action/read_all_by_domain'; -import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; - -function* readAllByDomain(action: Action): SagaIterator { - try { - const {domain} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.readAllByDomain}, domain); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadAllByDomainActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadAllByDomainActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllByTarget(): SagaIterator { - yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain); -} diff --git a/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts b/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts deleted file mode 100644 index 059922c..0000000 --- a/src/ts/@overflow/sensor/redux/saga/read_all_by_probe.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as ReadAllByProbeActions from '../action/read_all_by_probe'; -import ReadAllByProbePayload from '../payload/ReadAllByProbePayload'; - -function* readAllByProbe(action: Action): SagaIterator { - try { - const {probe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.readAllByProbe}, probe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadAllByProbeActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadAllByProbeActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllByTarget(): SagaIterator { - yield takeLatest(ReadAllByProbeActions.REQUEST, readAllByProbe); -} diff --git a/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts b/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts deleted file mode 100644 index 5751d92..0000000 --- a/src/ts/@overflow/sensor/redux/saga/read_all_by_target.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as ReadAllByTargetActions from '../action/read_all_by_target'; -import ReadAllByTargetPayload from '../payload/ReadAllByTargetPayload'; - -function* readAllByTarget(action: Action): SagaIterator { - try { - const {target} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.readAllByTarget}, target); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadAllByTargetActions.requestSuccess(ret)); - } catch (e) { - yield put(ReadAllByTargetActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllByTarget(): SagaIterator { - yield takeLatest(ReadAllByTargetActions.REQUEST, readAllByTarget); -} diff --git a/src/ts/@overflow/sensor/redux/saga/regist.ts b/src/ts/@overflow/sensor/redux/saga/regist.ts deleted file mode 100644 index 7ce6a4c..0000000 --- a/src/ts/@overflow/sensor/redux/saga/regist.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {sensor} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.regist}, sensor); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(ret)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/sensor/redux/saga/remove.ts b/src/ts/@overflow/sensor/redux/saga/remove.ts deleted file mode 100644 index 94c8c29..0000000 --- a/src/ts/@overflow/sensor/redux/saga/remove.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as RemoveActions from '../action/remove'; -import RemovePayload from '../payload/RemovePayload'; - -function* remove(action: Action): SagaIterator { - try { - const {sensor} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const retSensor = yield call({context: sensorService, fn: sensorService.remove}, sensor); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RemoveActions.requestSuccess(retSensor)); - } catch (e) { - yield put(RemoveActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRemove(): SagaIterator { - yield takeLatest(RemoveActions.REQUEST, remove); -} diff --git a/src/ts/@overflow/sensor/redux/saga/start.ts b/src/ts/@overflow/sensor/redux/saga/start.ts deleted file mode 100644 index 6b1d743..0000000 --- a/src/ts/@overflow/sensor/redux/saga/start.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as StartActions from '../action/start'; -import StartPayload from '../payload/StartPayload'; - -function* start(action: Action): SagaIterator { - try { - const {sensor} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.start}, sensor); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(StartActions.requestSuccess(ret)); - } catch (e) { - yield put(StartActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchStart(): SagaIterator { - yield takeLatest(StartActions.REQUEST, start); -} diff --git a/src/ts/@overflow/sensor/redux/saga/stop.ts b/src/ts/@overflow/sensor/redux/saga/stop.ts deleted file mode 100644 index bc30a72..0000000 --- a/src/ts/@overflow/sensor/redux/saga/stop.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Sensor from '../../api/model/Sensor'; -import SensorService from '../../api/service/SensorService'; -import * as StopActions from '../action/stop'; -import StopPayload from '../payload/StopPayload'; - -function* stop(action: Action): SagaIterator { - try { - const {sensor} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let sensorService = AppContext.getInstance().getPouch(SensorService); - const ret = yield call({context: sensorService, fn: sensorService.stop}, sensor); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(StopActions.requestSuccess(ret)); - } catch (e) { - yield put(StopActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchStop(): SagaIterator { - yield takeLatest(StopActions.REQUEST, stop); -} diff --git a/src/ts/@overflow/target/redux/saga/read.ts b/src/ts/@overflow/target/redux/saga/read.ts deleted file mode 100644 index 6c39115..0000000 --- a/src/ts/@overflow/target/redux/saga/read.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Target from '../../api/model/Target'; -import TargetService from '../../api/service/TargetService'; -import * as ReadActions from '../action/read'; -import ReadPayload from '../payload/ReadPayload'; - -function* read(action: Action): SagaIterator { - try { - const {id} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - - let targetService = AppContext.getInstance().getPouch(TargetService); - const retTarget = yield call({context: targetService, fn: targetService.read}, id); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadActions.requestSuccess(retTarget)); - } catch (e) { - yield put(ReadActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRead(): SagaIterator { - yield takeLatest(ReadActions.REQUEST, read); -} diff --git a/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts b/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts deleted file mode 100644 index e583dac..0000000 --- a/src/ts/@overflow/target/redux/saga/read_all_by_probe.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Target from '../../api/model/Target'; -import TargetService from '../../api/service/TargetService'; -import * as ReadAllByProbeActions from '../action/read_all_by_probe'; -import ReadAllByProbePayload from '../payload/ReadAllByProbePayload'; - -function* readAllByProbe(action: Action): SagaIterator { - try { - const {probe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - - let targetService = AppContext.getInstance().getPouch(TargetService); - const retTargets = yield call({context: targetService, fn: targetService.readAllByProbe}, probe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(ReadAllByProbeActions.requestSuccess(retTargets)); - } catch (e) { - yield put(ReadAllByProbeActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchReadAllByProbe(): SagaIterator { - yield takeLatest(ReadAllByProbeActions.REQUEST, readAllByProbe); -} diff --git a/src/ts/@overflow/target/redux/saga/regist.ts b/src/ts/@overflow/target/redux/saga/regist.ts deleted file mode 100644 index 4531800..0000000 --- a/src/ts/@overflow/target/redux/saga/regist.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Target from '../../api/model/Target'; -import TargetService from '../../api/service/TargetService'; -import * as RegistActions from '../action/regist'; -import RegistPayload from '../payload/RegistPayload'; - -function* regist(action: Action): SagaIterator { - try { - const {target} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let targetService = AppContext.getInstance().getPouch(TargetService); - const retTarget = yield call({context: targetService, fn: targetService.regist}, target); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistActions.requestSuccess(retTarget)); - } catch (e) { - yield put(RegistActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegist(): SagaIterator { - yield takeLatest(RegistActions.REQUEST, regist); -} diff --git a/src/ts/@overflow/target/redux/saga/regist_discovered_target.ts b/src/ts/@overflow/target/redux/saga/regist_discovered_target.ts deleted file mode 100644 index 1d70878..0000000 --- a/src/ts/@overflow/target/redux/saga/regist_discovered_target.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Target from '../../api/model/Target'; -import TargetDiscoveryService from '../../api/service/TargetDiscoveryService'; -import * as RegistDiscoveredTargetActions from '../action/regist_discovered_target'; -import RegistDiscoveredTargetPayload from '../payload/RegistDiscoveredTargetPayload'; - -function* registDiscoveredTarget(action: Action): SagaIterator { - try { - const {hosts, probe} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - let targetDiscoveryService = AppContext.getInstance().getPouch(TargetDiscoveryService); - yield call({context: targetDiscoveryService, fn: targetDiscoveryService.saveAllTarget}, hosts, probe); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RegistDiscoveredTargetActions.requestSuccess()); - } catch (e) { - yield put(RegistDiscoveredTargetActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRegistDiscoveredTarget(): SagaIterator { - yield takeLatest(RegistDiscoveredTargetActions.REQUEST, registDiscoveredTarget); -} diff --git a/src/ts/@overflow/target/redux/saga/remove.ts b/src/ts/@overflow/target/redux/saga/remove.ts deleted file mode 100644 index 9012bbf..0000000 --- a/src/ts/@overflow/target/redux/saga/remove.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - -import AppContext from '@overflow/commons/context/AppContext'; -import Action from '@overflow/commons/redux/Action'; - -import Target from '../../api/model/Target'; -import TargetService from '../../api/service/TargetService'; -import * as RemoveActions from '../action/remove'; -import RemovePayload from '../payload/RemovePayload'; - -function* remove(action: Action): SagaIterator { - try { - const {target} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); - - let targetService = AppContext.getInstance().getPouch(TargetService); - yield call({context: targetService, fn: targetService.remove}, target); - - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } - yield put(RemoveActions.requestSuccess()); - } catch (e) { - yield put(RemoveActions.requestFailure(e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -export function* watchRemove(): SagaIterator { - yield takeLatest(RemoveActions.REQUEST, remove); -}