ing
This commit is contained in:
parent
14aa79e8fc
commit
7610a40bed
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,4 +5,5 @@ dist/
|
||||||
**/.vscode
|
**/.vscode
|
||||||
.idea
|
.idea
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
.yarnclean
|
||||||
npm-debug.log
|
npm-debug.log
|
|
@ -10,7 +10,8 @@
|
||||||
"clean": "./node_modules/.bin/rimraf ./dist",
|
"clean": "./node_modules/.bin/rimraf ./dist",
|
||||||
"prepublish": "yarn run build",
|
"prepublish": "yarn run build",
|
||||||
"postpublish": "./node_modules/.bin/greenkeeper-postpublish",
|
"postpublish": "./node_modules/.bin/greenkeeper-postpublish",
|
||||||
"start": "set NODE_ENV=development && ./node_modules/.bin/webpack-dashboard -- ./node_modules/.bin/webpack-dev-server --open --progress --config ./config/webpack/webpack.config.dev.js",
|
"start": "set NODE_ENV=development && ./node_modules/.bin/webpack-dev-server --open --progress --config ./config/webpack/webpack.config.dev.js",
|
||||||
|
"start:dashboard": "set NODE_ENV=development && ./node_modules/.bin/webpack-dashboard -- ./node_modules/.bin/webpack-dev-server --open --progress --config ./config/webpack/webpack.config.dev.js",
|
||||||
"test": "yarn run jest",
|
"test": "yarn run jest",
|
||||||
"test:watch": "yarn run jest -- --watch",
|
"test:watch": "yarn run jest -- --watch",
|
||||||
"jest": "PWD=$(pwd) NODE_ENV=test ./node_modules/.bin/jest -w 1 --coverage",
|
"jest": "PWD=$(pwd) NODE_ENV=test ./node_modules/.bin/jest -w 1 --coverage",
|
||||||
|
|
15
src/ts/@overflow/app/config/AppConfig.ts
Normal file
15
src/ts/@overflow/app/config/AppConfig.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import Configuration from '@overflow/commons/context/decorator/Configuration';
|
||||||
|
import Pouch from '@overflow/commons/context/decorator/Pouch';
|
||||||
|
import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC';
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class AppConfig {
|
||||||
|
/**
|
||||||
|
* setWebsocket
|
||||||
|
*/
|
||||||
|
@Pouch()
|
||||||
|
public setWebsocket(): WebSocketRPC {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,7 +80,7 @@ class Application {
|
||||||
this.history = createHashHistory();
|
this.history = createHashHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Run(): void {
|
public static main(): void {
|
||||||
let application = new Application();
|
let application = new Application();
|
||||||
application.start();
|
application.start();
|
||||||
}
|
}
|
||||||
|
@ -245,4 +245,4 @@ class Application {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.Run();
|
Application.main();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { RouteComponentProps, RouteProps, Route, Switch, } from 'react-router-dom';
|
import { RouteComponentProps, RouteProps, Route, Switch } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Header,
|
Header,
|
||||||
Grid,
|
Grid,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
import * as CoreConstants from '@overflow/commons/core/constants';
|
||||||
import PouchFactory from './pouches/factory/PouchFactory';
|
import PouchFactory from './pouches/factory/PouchFactory';
|
||||||
import {
|
|
||||||
ClassConstructor,
|
|
||||||
} from './pouches/constants';
|
|
||||||
|
|
||||||
class AppContext {
|
class AppContext {
|
||||||
private static _instance: AppContext;
|
private static _instance: AppContext;
|
||||||
|
@ -18,14 +16,14 @@ class AppContext {
|
||||||
/**
|
/**
|
||||||
* getPouch
|
* getPouch
|
||||||
*/
|
*/
|
||||||
public getPouch<T>(type: ClassConstructor<T>, ...args: any[]): T {
|
public getPouch<T>(type: CoreConstants.Newable<T>, ...args: any[]): T {
|
||||||
return this._pouchFactory.getPouch(type, args);
|
return this._pouchFactory.getPouch(type, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPouchByQualifier
|
* getPouchByQualifier
|
||||||
*/
|
*/
|
||||||
public getPouchByQualifier<T>(type: ClassConstructor<T>, qualifier: string | symbol, ...args: any[]): T {
|
public getPouchByQualifier<T>(type: CoreConstants.Newable<T>, qualifier: string | symbol, ...args: any[]): T {
|
||||||
return this._pouchFactory.getPouchByQualifier(type, qualifier, args);
|
return this._pouchFactory.getPouchByQualifier(type, qualifier, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
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<string, PouchConfig>;
|
||||||
|
|
||||||
|
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<string, PouchConfig> {
|
||||||
|
return this._pouchMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ConfigurationDefinition;
|
1
src/ts/@overflow/commons/context/constants/index.ts
Normal file
1
src/ts/@overflow/commons/context/constants/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from './reflect';
|
2
src/ts/@overflow/commons/context/constants/reflect.ts
Normal file
2
src/ts/@overflow/commons/context/constants/reflect.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export const CONTEXT_CONFIGURATION_DEFINITION = 'overflow:context/configuration_definition';
|
||||||
|
export const CONTEXT_POUCH_DEFINITION = 'overflow:context/pouch_definition';
|
20
src/ts/@overflow/commons/context/decorator/Configuration.ts
Normal file
20
src/ts/@overflow/commons/context/decorator/Configuration.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import ConfigurationDefinition from '../config/ConfigurationDefinition';
|
||||||
|
|
||||||
|
import createDecorator from '../../util/decorators/createDecorator';
|
||||||
|
import { getConfigurationDefinition } from '../util/metadata';
|
||||||
|
|
||||||
|
const Configuration = createDecorator('Configuration', {
|
||||||
|
classDecorator: <TFunction extends Function>(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;
|
21
src/ts/@overflow/commons/context/decorator/Pouch.ts
Normal file
21
src/ts/@overflow/commons/context/decorator/Pouch.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
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<any>): TypedPropertyDescriptor<any> => {
|
||||||
|
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;
|
|
@ -0,0 +1,6 @@
|
||||||
|
interface PouchConfig {
|
||||||
|
qualifier?: string | symbol;
|
||||||
|
type?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PouchConfig;
|
|
@ -1,18 +1,18 @@
|
||||||
import { PouchScope, POUCH_DEFAULT_QUALIFIER } from '../constants';
|
import { PouchScope, POUCH_DEFAULT_QUALIFIER } from '../constants';
|
||||||
|
|
||||||
class PouchDefinition {
|
class PouchDefinition {
|
||||||
protected _type: Function;
|
protected _type: Object;
|
||||||
protected _scope: PouchScope = PouchScope.SINGLETON;
|
protected _scope: PouchScope = PouchScope.SINGLETON;
|
||||||
protected _qualifier: string | symbol;
|
protected _qualifier: string | symbol = undefined;
|
||||||
protected _postConstruct: string[] = null;
|
protected _postConstruct: Set<string> = undefined;
|
||||||
protected _preDestroy: string[] = null;
|
protected _preDestroy: Set<string> = undefined;
|
||||||
|
|
||||||
public constructor(type: Function) {
|
public constructor(type: Object) {
|
||||||
this._type = type;
|
this._type = type;
|
||||||
this._qualifier = POUCH_DEFAULT_QUALIFIER;
|
this._qualifier = POUCH_DEFAULT_QUALIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get type(): Function {
|
public get type(): Object {
|
||||||
return this._type;
|
return this._type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,26 +32,26 @@ class PouchDefinition {
|
||||||
this._qualifier = qualifier;
|
this._qualifier = qualifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get postConstruct(): string[] {
|
public get postConstruct(): Set<string> {
|
||||||
return this._postConstruct;
|
return this._postConstruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addPostConstruct(postConstruct: string): void {
|
public addPostConstruct(postConstruct: string): void {
|
||||||
if (null == this._postConstruct) {
|
if (undefined === this._postConstruct) {
|
||||||
this._postConstruct = [];
|
this._postConstruct = new Set();
|
||||||
}
|
}
|
||||||
this._postConstruct.push(postConstruct);
|
this._postConstruct.add(postConstruct);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get preDestroy(): string[] {
|
public get preDestroy(): Set<string> {
|
||||||
return this._preDestroy;
|
return this._preDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addPreDestroy(preDestroy: string): void {
|
public addPreDestroy(preDestroy: string): void {
|
||||||
if (null == this._preDestroy) {
|
if (undefined === this._preDestroy) {
|
||||||
this._preDestroy = [];
|
this._preDestroy = new Set();
|
||||||
}
|
}
|
||||||
this._preDestroy.push(preDestroy);
|
this._preDestroy.add(preDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import { DecoratorType, POUCH_DEFAULT_QUALIFIER } from '../constants';
|
import { POUCH_DEFAULT_QUALIFIER } from '../constants';
|
||||||
import InjectConfig from '../decorator/InjectConfig';
|
import InjectConfig from '../decorator/InjectConfig';
|
||||||
|
import * as CoreConstants from '@overflow/commons/core/constants';
|
||||||
|
|
||||||
export interface InjectItem {
|
export interface InjectItem {
|
||||||
decoratorType: DecoratorType;
|
decoratorType: CoreConstants.DecoratorType;
|
||||||
propertyConfig?: InjectConfig;
|
propertyConfig?: InjectConfig;
|
||||||
parameterConfigMap?: Map<number, InjectConfig>;
|
parameterConfigMap?: Map<number, InjectConfig>;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +42,7 @@ class PouchInjectDefinition {
|
||||||
|
|
||||||
private addInjectParameter(injectConfig: InjectConfig, propertyKey: string | symbol, parameterIndex: number): void {
|
private addInjectParameter(injectConfig: InjectConfig, propertyKey: string | symbol, parameterIndex: number): void {
|
||||||
let injectItem: InjectItem;
|
let injectItem: InjectItem;
|
||||||
let parameterTypes: any[] = Reflect.getMetadata(METADATA.DESIGN_PARAMTYPES, this.target, propertyKey);
|
let parameterTypes: any[] = Reflect.getMetadata(CoreConstants.DESIGN_PARAMTYPES, this.target, propertyKey);
|
||||||
|
|
||||||
if (undefined === injectConfig.type) {
|
if (undefined === injectConfig.type) {
|
||||||
injectConfig.type = parameterTypes[parameterIndex];
|
injectConfig.type = parameterTypes[parameterIndex];
|
||||||
|
@ -51,7 +52,7 @@ class PouchInjectDefinition {
|
||||||
injectItem = this.injectMap.get(propertyKey);
|
injectItem = this.injectMap.get(propertyKey);
|
||||||
} else {
|
} else {
|
||||||
injectItem = {
|
injectItem = {
|
||||||
decoratorType: DecoratorType.PARAMETER,
|
decoratorType: CoreConstants.DecoratorType.PARAMETER,
|
||||||
};
|
};
|
||||||
this.injectMap.set(propertyKey, injectItem);
|
this.injectMap.set(propertyKey, injectItem);
|
||||||
}
|
}
|
||||||
|
@ -73,14 +74,14 @@ class PouchInjectDefinition {
|
||||||
throw new Error(`Cannot apply @inject decorator on one property[${propertyKey}] multiple times.`);
|
throw new Error(`Cannot apply @inject decorator on one property[${propertyKey}] multiple times.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let propertyType: any = Reflect.getMetadata(METADATA.DESIGN_TYPE, this.target, propertyKey);
|
let propertyType: any = Reflect.getMetadata(CoreConstants.DESIGN_TYPE, this.target, propertyKey);
|
||||||
|
|
||||||
if (undefined === injectConfig.type) {
|
if (undefined === injectConfig.type) {
|
||||||
injectConfig.type = propertyType;
|
injectConfig.type = propertyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
let injectItem: InjectItem = {
|
let injectItem: InjectItem = {
|
||||||
decoratorType: DecoratorType.PROPERTY,
|
decoratorType: CoreConstants.DecoratorType.PROPERTY,
|
||||||
propertyConfig: injectConfig,
|
propertyConfig: injectConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// used to access design time types
|
|
||||||
export const DESIGN_TYPE = 'design:type';
|
|
||||||
// used to access design time types
|
|
||||||
export const DESIGN_PARAMTYPES = 'design:paramtypes';
|
|
||||||
// used to access design time types
|
|
||||||
export const DESIGN_RETURNTYPE = 'design:returntype';
|
|
||||||
|
|
||||||
|
|
||||||
// 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';
|
|
||||||
|
|
||||||
export const POUCH_DEFAULT_QUALIFIER = Symbol('__QUALIFIER__');
|
|
||||||
|
|
||||||
export enum PouchScope {
|
|
||||||
SINGLETON,
|
|
||||||
PROTOTYPE,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum DecoratorType {
|
|
||||||
CLASS,
|
|
||||||
PROPERTY,
|
|
||||||
PARAMETER,
|
|
||||||
METHOD,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ClassConstructor<T> = {new(...args: any[]): T};
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './reflect';
|
||||||
|
export * from './types';
|
|
@ -0,0 +1,5 @@
|
||||||
|
// 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';
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const POUCH_DEFAULT_QUALIFIER = Symbol('__QUALIFIER__');
|
||||||
|
|
||||||
|
export enum PouchScope {
|
||||||
|
SINGLETON,
|
||||||
|
PROTOTYPE,
|
||||||
|
}
|
||||||
|
|
|
@ -2,72 +2,20 @@ import * as METADATA from '../constants';
|
||||||
import { POUCH_DEFAULT_QUALIFIER } from '../constants';
|
import { POUCH_DEFAULT_QUALIFIER } from '../constants';
|
||||||
import InjectConfig from './InjectConfig';
|
import InjectConfig from './InjectConfig';
|
||||||
import PouchInjectDefinition from '../config/PouchInjectDefinition';
|
import PouchInjectDefinition from '../config/PouchInjectDefinition';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchInjectDefinition } from '../util/metadata';
|
||||||
|
|
||||||
const Inject = (injectConfig: InjectConfig = {}) => {
|
const Inject = (injectConfig: InjectConfig = {}) => createDecorator('Inject', {
|
||||||
return (...args: any[]) => {
|
propertyDecorator: (target: Object, propertyKey: string | symbol): void => {
|
||||||
let params = [];
|
let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target, true);
|
||||||
for (let i = 0; i < args.length; i++) {
|
|
||||||
if (args[i]) {
|
|
||||||
params.push(args[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(params.length) {
|
|
||||||
case 1:
|
|
||||||
return injectClass(injectConfig).apply(this, args);
|
|
||||||
case 2:
|
|
||||||
return injectProperty(injectConfig).apply(this, args);
|
|
||||||
case 3:
|
|
||||||
if(typeof args[2] === 'number') {
|
|
||||||
return injectParameter(injectConfig).apply(this, args);
|
|
||||||
}
|
|
||||||
return injectMethod(injectConfig).apply(this, args);
|
|
||||||
default:
|
|
||||||
throw new Error('@Inject decorators are not valid here!');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const injectClass = (injectConfig: InjectConfig = {}) => {
|
|
||||||
return <TFunction extends Function>(target: TFunction): TFunction | void => {
|
|
||||||
throw new Error('Cannot apply @Inject decorator on Class.');
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const injectProperty = (injectConfig: InjectConfig = {}) => {
|
|
||||||
return (target: Object, propertyKey: string | symbol): void => {
|
|
||||||
let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target);
|
|
||||||
pouchInjectDefinition.addInject(injectConfig, propertyKey);
|
pouchInjectDefinition.addInject(injectConfig, propertyKey);
|
||||||
};
|
},
|
||||||
};
|
parameterDecorator: (target: Object, propertyKey: string | symbol, parameterIndex: number): void => {
|
||||||
|
let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target, true);
|
||||||
const injectParameter = (injectConfig: InjectConfig = {}) => {
|
|
||||||
return (target: Object, propertyKey: string | symbol, parameterIndex: number): void => {
|
|
||||||
let pouchInjectDefinition: PouchInjectDefinition = getPouchInjectDefinition(target);
|
|
||||||
pouchInjectDefinition.addInject(injectConfig, propertyKey, parameterIndex);
|
pouchInjectDefinition.addInject(injectConfig, propertyKey, parameterIndex);
|
||||||
};
|
},
|
||||||
};
|
|
||||||
|
|
||||||
const injectMethod = (injectConfig: InjectConfig = {}) => {
|
});
|
||||||
return (target: Object, propertyKey: string | symbol,
|
|
||||||
descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> | void => {
|
|
||||||
throw new Error('Cannot apply @Inject decorator on Class.');
|
|
||||||
|
|
||||||
// return descriptor;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getPouchInjectDefinition = (target: Object) => {
|
|
||||||
let pouchInjectDefinition: PouchInjectDefinition;
|
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_INJECT_DEFINITION, target) !== true) {
|
|
||||||
pouchInjectDefinition = new PouchInjectDefinition(target);
|
|
||||||
Reflect.defineMetadata(METADATA.POUCH_INJECT_DEFINITION, pouchInjectDefinition, target);
|
|
||||||
} else {
|
|
||||||
pouchInjectDefinition = Reflect.getMetadata(METADATA.POUCH_INJECT_DEFINITION, target);
|
|
||||||
}
|
|
||||||
return pouchInjectDefinition;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Inject;
|
export default Inject;
|
||||||
|
|
|
@ -1,67 +1,21 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import PouchDefinition from '../config/PouchDefinition';
|
import PouchDefinition from '../config/PouchDefinition';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchDefinition } from '../util/metadata';
|
||||||
|
|
||||||
|
const Injectable = createDecorator('Injectable', {
|
||||||
const Injectable = (...args: any[]) => {
|
classDecorator: <TFunction extends Function>(target: TFunction): TFunction | void => {
|
||||||
let params = [];
|
let pouchDefinition: PouchDefinition = getPouchDefinition(target, false);
|
||||||
for (let i = 0; i < args.length; i++) {
|
if (undefined !== pouchDefinition) {
|
||||||
if (args[i]) {
|
throw new Error('Cannot apply @injectable decorator multiple times.');
|
||||||
params.push(args[i]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch(params.length) {
|
pouchDefinition = getPouchDefinition(target.prototype, true);
|
||||||
case 1:
|
|
||||||
return injectableClass.apply(this, args);
|
|
||||||
case 2:
|
|
||||||
return injectableProperty.apply(this, args);
|
|
||||||
case 3:
|
|
||||||
if(typeof args[2] === 'number') {
|
|
||||||
return injectableParameter.apply(this, args);
|
|
||||||
}
|
|
||||||
return injectableMethod.apply(this, args);
|
|
||||||
default:
|
|
||||||
throw new Error('@Injectable decorators are not valid here!');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
return target;
|
||||||
|
},
|
||||||
|
|
||||||
const injectableClass = <TFunction extends Function>(target: TFunction): TFunction | void => {
|
});
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) === true) {
|
|
||||||
throw new Error('Cannot apply @injectable decorator multiple times.');
|
|
||||||
}
|
|
||||||
|
|
||||||
let pouchDefinition: PouchDefinition = getPouchDefinition(target.prototype);
|
|
||||||
|
|
||||||
return target;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const injectableProperty = (target: Object, propertyKey: string | symbol): void => {
|
|
||||||
throw new Error('Cannot apply @Injectable decorator on property.');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const injectableParameter = (target: Object, propertyKey: string | symbol, parameterIndex: number): void => {
|
|
||||||
throw new Error('Cannot apply @Injectable decorator on parameter.');
|
|
||||||
};
|
|
||||||
|
|
||||||
const injectableMethod = <T>(target: Object, propertyKey: string | symbol,
|
|
||||||
descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
|
|
||||||
throw new Error('Cannot apply @Injectable decorator on method.');
|
|
||||||
// return descriptor;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getPouchDefinition = <TFunction extends Function>(target: TFunction) => {
|
|
||||||
let pouchDefinition: PouchDefinition;
|
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) !== true) {
|
|
||||||
pouchDefinition = new PouchDefinition(target);
|
|
||||||
Reflect.defineMetadata(METADATA.POUCH_DEFINITION, pouchDefinition, target);
|
|
||||||
} else {
|
|
||||||
pouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, target);
|
|
||||||
}
|
|
||||||
return pouchDefinition;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export default Injectable;
|
export default Injectable;
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import PouchDefinition from '../config/PouchDefinition';
|
import PouchDefinition from '../config/PouchDefinition';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchDefinition } from '../util/metadata';
|
||||||
|
|
||||||
const PostConstruct = (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
|
const PostConstruct = createDecorator('PostConstruct', {
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) !== true) {
|
methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
|
||||||
throw new Error('Cannot apply @PostConstruct decorator on the not @Injectable class.');
|
let pouchDefinition = getPouchDefinition(target, false);
|
||||||
}
|
if (undefined === pouchDefinition) {
|
||||||
let pouchDefinition: PouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, target);
|
throw new Error('Cannot apply @PostConstruct decorator on the not @Injectable class.');
|
||||||
pouchDefinition.addPostConstruct(propertyKey);
|
}
|
||||||
|
pouchDefinition.addPostConstruct(propertyKey);
|
||||||
return descriptor;
|
return descriptor;
|
||||||
};
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default PostConstruct;
|
export default PostConstruct;
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import PouchDefinition from '../config/PouchDefinition';
|
import PouchDefinition from '../config/PouchDefinition';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchDefinition } from '../util/metadata';
|
||||||
|
|
||||||
const PreDestroy = (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
|
const PreDestroy = createDecorator('PreDestroy', {
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) !== true) {
|
methodDecorator: (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> => {
|
||||||
throw new Error('Cannot apply @PreDestroy decorator on the not @Injectable class.');
|
let pouchDefinition = getPouchDefinition(target, false);
|
||||||
}
|
if (undefined === pouchDefinition) {
|
||||||
let pouchDefinition: PouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, target);
|
throw new Error('Cannot apply @PreDestroy decorator on the not @Injectable class.');
|
||||||
pouchDefinition.addPreDestroy(propertyKey);
|
}
|
||||||
|
pouchDefinition.addPreDestroy(propertyKey);
|
||||||
return descriptor;
|
return descriptor;
|
||||||
};
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default PreDestroy;
|
export default PreDestroy;
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import PouchDefinition from '../config/PouchDefinition';
|
import PouchDefinition from '../config/PouchDefinition';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchDefinition } from '../util/metadata';
|
||||||
|
|
||||||
const Qualifier = (value: string | symbol) => {
|
const Qualifier = (value: string | symbol) => createDecorator('Qualifier', {
|
||||||
return <TFunction extends Function>(target: TFunction): TFunction | void => {
|
classDecorator: <TFunction extends Function>(target: TFunction): TFunction | void => {
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) !== true) {
|
let pouchDefinition = getPouchDefinition(target, false);
|
||||||
|
if (undefined === pouchDefinition) {
|
||||||
throw new Error('Cannot apply @Qualifier decorator on the not @Injectable class.');
|
throw new Error('Cannot apply @Qualifier decorator on the not @Injectable class.');
|
||||||
}
|
}
|
||||||
let pouchDefinition: PouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, target);
|
|
||||||
pouchDefinition.qualifier = value;
|
|
||||||
|
|
||||||
|
if (undefined !== pouchDefinition.qualifier) {
|
||||||
|
throw new Error('Cannot apply @Qualifier decorator multiple times.');
|
||||||
|
}
|
||||||
|
pouchDefinition.qualifier = value;
|
||||||
return target;
|
return target;
|
||||||
};
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
export default Qualifier;
|
export default Qualifier;
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
import PouchDefinition from '../config/PouchDefinition';
|
import PouchDefinition from '../config/PouchDefinition';
|
||||||
import { PouchScope } from '../constants';
|
import { PouchScope } from '../constants';
|
||||||
|
import createDecorator from '@overflow/commons/util/decorators/createDecorator';
|
||||||
|
import { getPouchDefinition } from '../util/metadata';
|
||||||
|
|
||||||
const Scope = (value: PouchScope = PouchScope.SINGLETON) => {
|
const Scope = (value: PouchScope = PouchScope.SINGLETON) => createDecorator('Scope', {
|
||||||
return <TFunction extends Function>(target: TFunction): TFunction | void => {
|
classDecorator: <TFunction extends Function>(target: TFunction): TFunction | void => {
|
||||||
if (Reflect.hasOwnMetadata(METADATA.POUCH_DEFINITION, target) !== true) {
|
let pouchDefinition = getPouchDefinition(target, false);
|
||||||
|
if (undefined === pouchDefinition) {
|
||||||
throw new Error('Cannot apply @Scope decorator on the not @Injectable class.');
|
throw new Error('Cannot apply @Scope decorator on the not @Injectable class.');
|
||||||
}
|
}
|
||||||
let pouchDefinition: PouchDefinition = Reflect.getMetadata(METADATA.POUCH_DEFINITION, target);
|
|
||||||
pouchDefinition.scope = value;
|
pouchDefinition.scope = value;
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
};
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
export default Scope;
|
export default Scope;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import * as METADATA from '../constants';
|
import * as METADATA from '../constants';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ClassConstructor,
|
|
||||||
DecoratorType,
|
|
||||||
PouchScope,
|
PouchScope,
|
||||||
POUCH_DEFAULT_QUALIFIER,
|
POUCH_DEFAULT_QUALIFIER,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
|
@ -27,7 +25,7 @@ class PouchFactory {
|
||||||
/**
|
/**
|
||||||
* getPouch
|
* getPouch
|
||||||
*/
|
*/
|
||||||
public getPouch<T>(type: ClassConstructor<T>, ...args: any[]): T {
|
public getPouch<T>(type: Newable<T>, ...args: any[]): T {
|
||||||
let qualifier = POUCH_DEFAULT_QUALIFIER;
|
let qualifier = POUCH_DEFAULT_QUALIFIER;
|
||||||
return this.getPouchByQualifier(type, qualifier, args);
|
return this.getPouchByQualifier(type, qualifier, args);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +33,7 @@ class PouchFactory {
|
||||||
/**
|
/**
|
||||||
* getPouchByQualifier
|
* getPouchByQualifier
|
||||||
*/
|
*/
|
||||||
public getPouchByQualifier<T>(type: ClassConstructor<T>, qualifier: string | symbol, ...args: any[]): T {
|
public getPouchByQualifier<T>(type: Newable<T>, qualifier: string | symbol, ...args: any[]): T {
|
||||||
let clazz: Function = type.prototype;
|
let clazz: Function = type.prototype;
|
||||||
|
|
||||||
let instance = this._getPouch(clazz, qualifier, args);
|
let instance = this._getPouch(clazz, qualifier, args);
|
||||||
|
@ -55,7 +53,7 @@ class PouchFactory {
|
||||||
/**
|
/**
|
||||||
* registerPouch
|
* registerPouch
|
||||||
*/
|
*/
|
||||||
public registerPouchDefinition<T>(type: ClassConstructor<T>, pouchDefinition: PouchDefinition): void {
|
public registerPouchDefinition<T>(type: Newable<T>, pouchDefinition: PouchDefinition): void {
|
||||||
let clazz: Function = type.prototype;
|
let clazz: Function = type.prototype;
|
||||||
if (this.pouchDefinitionMap.has(clazz)) {
|
if (this.pouchDefinitionMap.has(clazz)) {
|
||||||
throw new Error(`Pouch Definition of [${clazz.name}] is already exist.`);
|
throw new Error(`Pouch Definition of [${clazz.name}] is already exist.`);
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './inject';
|
||||||
|
export * from './pouch';
|
|
@ -0,0 +1,8 @@
|
||||||
|
import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata';
|
||||||
|
|
||||||
|
import * as METADATA from '../../constants';
|
||||||
|
import PouchInjectDefinition from '../../config/PouchInjectDefinition';
|
||||||
|
|
||||||
|
export const getPouchInjectDefinition =
|
||||||
|
<TFunction extends Function>(target: TFunction | Object, isCreate: boolean = false) =>
|
||||||
|
getClassMetadata(target, METADATA.POUCH_INJECT_DEFINITION, PouchInjectDefinition, isCreate);
|
|
@ -0,0 +1,8 @@
|
||||||
|
import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata';
|
||||||
|
|
||||||
|
import * as METADATA from '../../constants';
|
||||||
|
import PouchDefinition from '../../config/PouchDefinition';
|
||||||
|
|
||||||
|
export const getPouchDefinition =
|
||||||
|
<TFunction extends Function>(target: TFunction | Object, isCreate: boolean = false) =>
|
||||||
|
getClassMetadata(target, METADATA.POUCH_DEFINITION, PouchDefinition, isCreate);
|
|
@ -0,0 +1,9 @@
|
||||||
|
import getClassMetadata from '@overflow/commons/util/metadata/getClassMetadata';
|
||||||
|
|
||||||
|
import * as METADATA from '../../constants';
|
||||||
|
import ConfigurationDefinition from '../../config/ConfigurationDefinition';
|
||||||
|
|
||||||
|
export const getConfigurationDefinition =
|
||||||
|
<TFunction extends Function>(target: TFunction | Object, isCreate: boolean = false) =>
|
||||||
|
getClassMetadata(target, METADATA.CONTEXT_CONFIGURATION_DEFINITION, ConfigurationDefinition, isCreate);
|
||||||
|
|
1
src/ts/@overflow/commons/context/util/metadata/index.ts
Normal file
1
src/ts/@overflow/commons/context/util/metadata/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export * from './configuration';
|
2
src/ts/@overflow/commons/core/constants/index.ts
Normal file
2
src/ts/@overflow/commons/core/constants/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './types';
|
||||||
|
export * from './reflect';
|
6
src/ts/@overflow/commons/core/constants/reflect.ts
Normal file
6
src/ts/@overflow/commons/core/constants/reflect.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// used to access design time types
|
||||||
|
export const DESIGN_TYPE = 'design:type';
|
||||||
|
// used to access design time parameter types
|
||||||
|
export const DESIGN_PARAMTYPES = 'design:paramtypes';
|
||||||
|
// used to access design time return type
|
||||||
|
export const DESIGN_RETURNTYPE = 'design:returntype';
|
8
src/ts/@overflow/commons/core/constants/types.ts
Normal file
8
src/ts/@overflow/commons/core/constants/types.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
export type Newable<T> = {new(...args: any[]): T};
|
||||||
|
|
||||||
|
export enum DecoratorType {
|
||||||
|
CLASS,
|
||||||
|
PROPERTY,
|
||||||
|
PARAMETER,
|
||||||
|
METHOD,
|
||||||
|
}
|
|
@ -25,11 +25,11 @@ export class TargetCreator {
|
||||||
let obj: any;
|
let obj: any;
|
||||||
|
|
||||||
obj = {
|
obj = {
|
||||||
"ip": ip,
|
'ip': ip,
|
||||||
"port": port,
|
'port': port,
|
||||||
"portType": portType,
|
'portType': portType,
|
||||||
// "targetType":"",
|
// "targetType":"",
|
||||||
"vendorName": vendorName,
|
'vendorName': vendorName,
|
||||||
// "kinds":"",
|
// "kinds":"",
|
||||||
// "version":"",
|
// "version":"",
|
||||||
};
|
};
|
||||||
|
@ -38,8 +38,8 @@ export class TargetCreator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public toString() :string {
|
public toString():string {
|
||||||
return JSON.stringify(this.list);
|
return JSON.stringify(this.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
46
src/ts/@overflow/commons/util/decorators/createDecorator.ts
Normal file
46
src/ts/@overflow/commons/util/decorators/createDecorator.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
export interface DecoratorFactory {
|
||||||
|
classDecorator?: ClassDecorator;
|
||||||
|
propertyDecorator?: PropertyDecorator;
|
||||||
|
parameterDecorator?: ParameterDecorator;
|
||||||
|
methodDecorator?: MethodDecorator;
|
||||||
|
}
|
||||||
|
|
||||||
|
const createDecorator = (name: string, decoratorFactory: DecoratorFactory) => {
|
||||||
|
return (...args: any[]) => {
|
||||||
|
let params = [];
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
if (args[i]) {
|
||||||
|
params.push(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(params.length) {
|
||||||
|
case 1:
|
||||||
|
if (undefined !== decoratorFactory.classDecorator) {
|
||||||
|
return decoratorFactory.classDecorator.apply(this, args);
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot apply @${name} decorator on Class.`);
|
||||||
|
case 2:
|
||||||
|
case 1:
|
||||||
|
if (undefined !== decoratorFactory.propertyDecorator) {
|
||||||
|
return decoratorFactory.propertyDecorator.apply(this, args);
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot apply @${name} decorator on Property.`);
|
||||||
|
case 3:
|
||||||
|
if(typeof args[2] === 'number') {
|
||||||
|
if (undefined !== decoratorFactory.parameterDecorator) {
|
||||||
|
return decoratorFactory.parameterDecorator.apply(this, args);
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot apply @${name} decorator on Parameter.`);
|
||||||
|
}
|
||||||
|
if (undefined !== decoratorFactory.methodDecorator) {
|
||||||
|
return decoratorFactory.methodDecorator.apply(this, args);
|
||||||
|
}
|
||||||
|
throw new Error(`Cannot apply @${name} decorator on Method.`);
|
||||||
|
default:
|
||||||
|
throw new Error(`@${name} decorators are not valid here!`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default createDecorator;
|
24
src/ts/@overflow/commons/util/metadata/getClassMetadata.ts
Normal file
24
src/ts/@overflow/commons/util/metadata/getClassMetadata.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
export type MetadataDefinable<T> = {new(target: Function): T};
|
||||||
|
|
||||||
|
const getClassMetadata = <TFunction extends Function, DefinitionType>(target: TFunction | Object,
|
||||||
|
metadataKey: any,
|
||||||
|
definitionType: MetadataDefinable<DefinitionType>,
|
||||||
|
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;
|
|
@ -1,54 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
const url = "http://192.168.1.209:8080/v1/overflow/services";
|
|
||||||
|
|
||||||
export class OFRest {
|
|
||||||
|
|
||||||
obj: any;
|
|
||||||
|
|
||||||
|
|
||||||
constructor(serviceName: string, methodName: string, data: any) {
|
|
||||||
|
|
||||||
this.obj = {
|
|
||||||
"serviceName": serviceName,
|
|
||||||
"methodName": methodName,
|
|
||||||
"param": {
|
|
||||||
"model": JSON.stringify(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public Call() {
|
|
||||||
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(this.obj)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public CallWithCB(callback: Function) {
|
|
||||||
fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(this.obj)
|
|
||||||
}).then(function (res) {
|
|
||||||
return res.json();
|
|
||||||
}).then(function (json) {
|
|
||||||
if (json.error != undefined) {
|
|
||||||
console.log(json.error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
callback(json);
|
|
||||||
}).catch(function (err) {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class DiscoveryTable extends React.Component<Props, State> {
|
||||||
{ key: 'telnet', text: 'Telnet', value: 'telnet' },
|
{ key: 'telnet', text: 'Telnet', value: 'telnet' },
|
||||||
{ key: 'casandra', text: 'Casandra', value: 'casandra' },
|
{ key: 'casandra', text: 'Casandra', value: 'casandra' },
|
||||||
{ key: 'mongodb', text: 'mongoDB', value: 'mongodb' },
|
{ key: 'mongodb', text: 'mongoDB', value: 'mongodb' },
|
||||||
{ key: 'rmi', text: 'RMI', value: 'rmi' }
|
{ key: 'rmi', text: 'RMI', value: 'rmi' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import InfraHost from '@overflow/infra/api/model/InfraHost';
|
||||||
import InfraMachine from '@overflow/infra/api/model/InfraMachine';
|
import InfraMachine from '@overflow/infra/api/model/InfraMachine';
|
||||||
import InfraOS from '@overflow/infra/api/model/InfraOS';
|
import InfraOS from '@overflow/infra/api/model/InfraOS';
|
||||||
|
|
||||||
import * as Utils from '@overflow/commons/utils/Utils';
|
import * as Utils from '@overflow/commons/util/Utils';
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
target?: Target;
|
target?: Target;
|
||||||
|
|
77
types/react-router-redux/index.d.ts
vendored
77
types/react-router-redux/index.d.ts
vendored
|
@ -1,77 +0,0 @@
|
||||||
// Type definitions for react-router-redux 5.0
|
|
||||||
// Project: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux
|
|
||||||
// Definitions by: Huy Nguyen <https://github.com/huy-nguyen>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
// TypeScript Version: 2.3
|
|
||||||
import {
|
|
||||||
Store,
|
|
||||||
Dispatch,
|
|
||||||
Action,
|
|
||||||
Middleware
|
|
||||||
} from 'redux';
|
|
||||||
import {
|
|
||||||
History,
|
|
||||||
Location,
|
|
||||||
Path,
|
|
||||||
LocationState,
|
|
||||||
LocationDescriptor
|
|
||||||
} from 'history';
|
|
||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
export interface ConnectedRouterProps<State> {
|
|
||||||
store?: Store<State>;
|
|
||||||
history?: History;
|
|
||||||
}
|
|
||||||
export class ConnectedRouter<State> extends React.Component<ConnectedRouterProps<State>> {}
|
|
||||||
|
|
||||||
export const LOCATION_CHANGE: string;
|
|
||||||
|
|
||||||
export interface RouterState {
|
|
||||||
location: Location | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function routerReducer(state?: RouterState, action?: RouterAction): RouterState;
|
|
||||||
|
|
||||||
export const CALL_HISTORY_METHOD: string;
|
|
||||||
|
|
||||||
export function push(location: LocationDescriptor, state?: LocationState): RouterAction;
|
|
||||||
export function replace(location: LocationDescriptor, state?: LocationState): RouterAction;
|
|
||||||
export function go(n: number): RouterAction;
|
|
||||||
export function goBack(): RouterAction;
|
|
||||||
export function goForward(): RouterAction;
|
|
||||||
|
|
||||||
export const routerActions: {
|
|
||||||
push: typeof push
|
|
||||||
replace: typeof replace
|
|
||||||
go: typeof go
|
|
||||||
goBack: typeof goBack
|
|
||||||
goForward: typeof goForward
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface LocationActionPayload {
|
|
||||||
method: string;
|
|
||||||
args?: any[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RouterAction extends Action {
|
|
||||||
type: typeof CALL_HISTORY_METHOD;
|
|
||||||
payload: LocationActionPayload;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LocationChangeAction extends Action {
|
|
||||||
type: typeof LOCATION_CHANGE;
|
|
||||||
payload: Location & {
|
|
||||||
props?: {
|
|
||||||
match: {
|
|
||||||
path: string;
|
|
||||||
url: string;
|
|
||||||
params: any;
|
|
||||||
isExact: boolean;
|
|
||||||
},
|
|
||||||
location: Location;
|
|
||||||
history: History;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function routerMiddleware(history: History): Middleware;
|
|
Loading…
Reference in New Issue
Block a user