From fec88d5f8e32d6479b65529ecb76bf8e7715b2f9 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 20 Dec 2017 22:46:21 +0900 Subject: [PATCH] ing --- .../decorator/annotation/annotation.ts | 10 +++--- .../@overflow/commons/decorator/decorator.ts | 10 +++--- .../commons/redux/decorators/reducer.ts | 4 +-- .../commons/redux/decorators/rest.ts | 6 ---- .../commons/redux/decorators/rest_api.ts | 34 +++++++++++++++++++ .../@overflow/commons/redux/decorators/rpc.ts | 6 ---- .../commons/redux/decorators/rpc_api.ts | 34 +++++++++++++++++++ src/ts/@overflow/commons/redux/lpc_reducer.ts | 7 ++++ .../redux/registry/reducer_registry.ts | 0 tslint.json | 2 +- 10 files changed, 88 insertions(+), 25 deletions(-) delete mode 100644 src/ts/@overflow/commons/redux/decorators/rest.ts create mode 100644 src/ts/@overflow/commons/redux/decorators/rest_api.ts delete mode 100644 src/ts/@overflow/commons/redux/decorators/rpc.ts create mode 100644 src/ts/@overflow/commons/redux/decorators/rpc_api.ts create mode 100644 src/ts/@overflow/commons/redux/registry/reducer_registry.ts diff --git a/src/ts/@overflow/commons/decorator/annotation/annotation.ts b/src/ts/@overflow/commons/decorator/annotation/annotation.ts index 8dbbd60..2a7be78 100644 --- a/src/ts/@overflow/commons/decorator/annotation/annotation.ts +++ b/src/ts/@overflow/commons/decorator/annotation/annotation.ts @@ -3,11 +3,11 @@ import { } from '@overflow/commons/core/type'; export interface Annotation { - classDecorator?: (target: TFunction) => TFunction | void; - propertyDecorator?: (target: Object, propertyKey: PropertyKeyType) => void; - methodDecorator?: (target: Object, propertyKey: PropertyKeyType, - descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; - parameterDecorator?: (target: Object, propertyKey: PropertyKeyType, parameterIndex: number) => void; + classDecorator?(target: TFunction): TFunction | void; + propertyDecorator?(target: Object, propertyKey: PropertyKeyType): void; + methodDecorator?(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void; + parameterDecorator?(target: Object, propertyKey: PropertyKeyType, parameterIndex: number): void; } export abstract class Annotation { diff --git a/src/ts/@overflow/commons/decorator/decorator.ts b/src/ts/@overflow/commons/decorator/decorator.ts index 4956334..c631774 100644 --- a/src/ts/@overflow/commons/decorator/decorator.ts +++ b/src/ts/@overflow/commons/decorator/decorator.ts @@ -18,17 +18,17 @@ export class Decorator { return (...decoratorArgs: any[]) => { let decoratorType: Constants.DecoratorType = Decorator._detectDecoratorType(name, annotation, decoratorArgs); // let type = typeof decoratorArgs[0] === 'function' ? decoratorArgs[0].prototype : decoratorArgs[0]; - let clazz = TypeUtil.getClass(decoratorArgs[0]); + // let clazz = TypeUtil.getClass(decoratorArgs[0]); switch(decoratorType) { case Constants.DecoratorType.CLASS: - return annotation.classDecorator.call(annotation, clazz, decoratorArgs[0]); + return annotation.classDecorator.call(annotation, decoratorArgs[0]); case Constants.DecoratorType.PROPERTY: - return annotation.propertyDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1]); + return annotation.propertyDecorator.call(annotation, decoratorArgs[0], decoratorArgs[1]); case Constants.DecoratorType.METHOD: - return annotation.methodDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); + return annotation.methodDecorator.call(annotation, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); case Constants.DecoratorType.PARAMETER: - return annotation.parameterDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); + return annotation.parameterDecorator.call(annotation, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); default: } }; diff --git a/src/ts/@overflow/commons/redux/decorators/reducer.ts b/src/ts/@overflow/commons/redux/decorators/reducer.ts index b7c685c..a0257e4 100644 --- a/src/ts/@overflow/commons/redux/decorators/reducer.ts +++ b/src/ts/@overflow/commons/redux/decorators/reducer.ts @@ -7,7 +7,7 @@ import { export interface ReducerAnnotationAttributes { - name?: string; + name: string; } export class ReducerAnnotation extends Annotation { @@ -24,7 +24,7 @@ export class ReducerAnnotation extends Annotation { } } - public classDecorator = (target: TFunction): TFunction | void => { + public classDecorator(target: TFunction): TFunction | void { console.log('Reducer'); } } diff --git a/src/ts/@overflow/commons/redux/decorators/rest.ts b/src/ts/@overflow/commons/redux/decorators/rest.ts deleted file mode 100644 index 3decf31..0000000 --- a/src/ts/@overflow/commons/redux/decorators/rest.ts +++ /dev/null @@ -1,6 +0,0 @@ - - -export function Rest(path: string): Function { - return Use(...['get', path].concat(args)); -} - diff --git a/src/ts/@overflow/commons/redux/decorators/rest_api.ts b/src/ts/@overflow/commons/redux/decorators/rest_api.ts new file mode 100644 index 0000000..bf0850e --- /dev/null +++ b/src/ts/@overflow/commons/redux/decorators/rest_api.ts @@ -0,0 +1,34 @@ +import * as TypeUtil from '@overflow/commons/core/type/util'; +import { + Annotation, + Decorator, +} from '@overflow/commons/decorator'; +import { PropertyKeyType } from '@overflow/commons/core/type'; + +export interface RestAPIAnnotationAttributes { + entryPath: string; +} + +export class RestAPIAnnotation extends Annotation { + public readonly attributes: RestAPIAnnotationAttributes; + + public constructor(entryPath: string | RestAPIAnnotationAttributes) { + super(); + if (TypeUtil.isString(entryPath)) { + this.attributes = { + entryPath: entryPath, + }; + } else { + this.attributes = entryPath; + } + } + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('RestAPI'); + } +} + +export const RestAPI = Decorator.create(RestAPIAnnotation); + +export default RestAPI; diff --git a/src/ts/@overflow/commons/redux/decorators/rpc.ts b/src/ts/@overflow/commons/redux/decorators/rpc.ts deleted file mode 100644 index c247acc..0000000 --- a/src/ts/@overflow/commons/redux/decorators/rpc.ts +++ /dev/null @@ -1,6 +0,0 @@ - - -export function RPC(method: string): Function { - return Use(...['get', path].concat(args)); -} - diff --git a/src/ts/@overflow/commons/redux/decorators/rpc_api.ts b/src/ts/@overflow/commons/redux/decorators/rpc_api.ts new file mode 100644 index 0000000..73bb59a --- /dev/null +++ b/src/ts/@overflow/commons/redux/decorators/rpc_api.ts @@ -0,0 +1,34 @@ +import * as TypeUtil from '@overflow/commons/core/type/util'; +import { + Annotation, + Decorator, +} from '@overflow/commons/decorator'; +import { PropertyKeyType } from '@overflow/commons/core/type'; + +export interface RpcAPIAnnotationAttributes { + method: string; +} + +export class RpcAPIAnnotation extends Annotation { + public readonly attributes: RpcAPIAnnotationAttributes; + + public constructor(method: string | RpcAPIAnnotationAttributes) { + super(); + if (TypeUtil.isString(method)) { + this.attributes = { + method: method, + }; + } else { + this.attributes = method; + } + } + + public methodDecorator(target: Object, propertyKey: PropertyKeyType, + descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void { + console.log('RestAPI'); + } +} + +export const RpcAPI = Decorator.create(RpcAPIAnnotation); + +export default RpcAPI; diff --git a/src/ts/@overflow/commons/redux/lpc_reducer.ts b/src/ts/@overflow/commons/redux/lpc_reducer.ts index 997a2af..8b942f0 100644 --- a/src/ts/@overflow/commons/redux/lpc_reducer.ts +++ b/src/ts/@overflow/commons/redux/lpc_reducer.ts @@ -31,5 +31,12 @@ class LPCReducer { return null; } + /** + * registerReducer + */ + public registerReducer(reducerType: any): void { + console.log(``); + + } } diff --git a/src/ts/@overflow/commons/redux/registry/reducer_registry.ts b/src/ts/@overflow/commons/redux/registry/reducer_registry.ts new file mode 100644 index 0000000..e69de29 diff --git a/tslint.json b/tslint.json index 05b0571..51a0ceb 100644 --- a/tslint.json +++ b/tslint.json @@ -51,7 +51,7 @@ "no-inferrable-types": [false], "no-internal-module": true, "no-require-imports": false, - "no-string-literal": true, + "no-string-literal": false, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true,