diff --git a/.gitignore b/.gitignore index 68fa946..ba2407e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store .idea/ node_modules/ dist/ @@ -6,4 +7,4 @@ dist/ .idea yarn.lock .yarnclean -npm-debug.log \ No newline at end of file +npm-debug.log diff --git a/src/ts/@loafer/application/Application.ts b/src/ts/@loafer/application/Application.ts deleted file mode 100644 index addd135..0000000 --- a/src/ts/@loafer/application/Application.ts +++ /dev/null @@ -1,31 +0,0 @@ -import AnnotationConfigApplicationContext from '@loafer/context/annotation/AnnotationConfigApplicationContext'; - -import ApplicationStater from '@loafer/application/ApplicationStater'; - -class Application { - // private appContext: AppContext; - private appClass: Class; - // private appInstance: ApplicationStater; - - public constructor(clazz: Class) { - this.appClass = clazz; - } - - public run(): void { - let context: AnnotationConfigApplicationContext = new AnnotationConfigApplicationContext(); - context.register(AppConfig.prototype); - context.refresh(); - - context.getPouch('entitlement'); - } - - public static run(clazz: Class): void { - new Application(clazz).run(); - } -} - -export class AppConfig { - -} - -export default Application; diff --git a/src/ts/@loafer/application/ApplicationStater.ts b/src/ts/@loafer/application/ApplicationStater.ts deleted file mode 100644 index 3f5bca2..0000000 --- a/src/ts/@loafer/application/ApplicationStater.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface ApplicationStater { - run(): void; -} - -export default ApplicationStater; diff --git a/src/ts/@loafer/application/decorator/ApplicationConfiguration.ts b/src/ts/@loafer/application/decorator/ApplicationConfiguration.ts deleted file mode 100644 index 1ee72ba..0000000 --- a/src/ts/@loafer/application/decorator/ApplicationConfiguration.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import { - ConfigurationAnnotation, -} from '@loafer/context/decorator/Configuration'; - -export class ApplicationConfigurationAnnotation extends ConfigurationAnnotation { - public constructor(qualifier?: QualifierName) { - super(qualifier); - } - public onClassDecorator = (target: TFunction): TFunction | void => { - console.log('ApplicationConfiguration'); - } - -} - -export const ApplicationConfiguration = Decorator.create(ApplicationConfigurationAnnotation); - -export default ApplicationConfiguration; diff --git a/src/ts/@loafer/context/ApplicationContext.ts b/src/ts/@loafer/context/ApplicationContext.ts deleted file mode 100644 index 1a9ccbe..0000000 --- a/src/ts/@loafer/context/ApplicationContext.ts +++ /dev/null @@ -1,18 +0,0 @@ -// import EnvironmentCapable from '@loafer/core/env/EnvironmentCapable'; - -// import PouchFactory from '@loafer/pouches/factory/PouchFactory'; -// import DefaultPouchFactory from '@loafer/pouches/factory/implement/DefaultPouchFactory'; -// import ListablePouchFactory from '@loafer/pouches/factory/ListablePouchFactory'; -// import HierarchicalPouchFactory from '@loafer/pouches/factory/HierarchicalPouchFactory'; -// import InjectCapablePouchFactory from '@loafer/pouches/factory/config/InjectCapablePouchFactory'; - -// export interface ApplicationContext extends EnvironmentCapable, ListablePouchFactory, HierarchicalPouchFactory { -// getId?(): Identity; -// getApplicationName(): string; -// getDisplayName(): string; -// getParent?(): ApplicationContext; - -// getInjectCapablePouchFactory(): InjectCapablePouchFactory; -// } - -// export default ApplicationContext; diff --git a/src/ts/@loafer/context/ConfigurableApplicationContext.ts b/src/ts/@loafer/context/ConfigurableApplicationContext.ts deleted file mode 100644 index 1c6d7f0..0000000 --- a/src/ts/@loafer/context/ConfigurableApplicationContext.ts +++ /dev/null @@ -1,11 +0,0 @@ -// import { -// Identity, -// } from '@loafer/core/constants/types'; -// import ConfigurableEnvironment from '@loafer/core/env/ConfigurableEnvironment'; -// import ApplicationContext from '@loafer/context/ApplicationContext'; -// import Lifecycle from '@loafer/context/Lifecycle'; - -// export interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle { -// } - -// export default ConfigurableApplicationContext; diff --git a/src/ts/@loafer/context/Lifecycle.ts b/src/ts/@loafer/context/Lifecycle.ts deleted file mode 100644 index 6cceb49..0000000 --- a/src/ts/@loafer/context/Lifecycle.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface Lifecycle { - start(): void; - stop(): void; - isRunning(): boolean; -} - -export default Lifecycle; diff --git a/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts b/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts deleted file mode 100644 index 12aa16c..0000000 --- a/src/ts/@loafer/context/annotation/AnnotatedPouchDefinitionReader.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { - Assert, -} from '@loafer/core/util'; - -import { - Annotation, -} from '@loafer/core/annotation'; - -import { - PouchDefinitionRegistry, -} from '@loafer/pouches/factory/support'; - -import { - AnnotatedGenericPouchDefinition, -} from '@loafer/pouches/factory/annotation'; - - - -import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext'; - -export class AnnotatedPouchDefinitionReader { - private readonly registry: PouchDefinitionRegistry; - private pouchNameGenerator: PouchNameGenerator = new AnnotationPouchNameGenerator(); - private scopeMetadataResolver: ScopeMetadataResolver = new AnnotationScopeMetadataResolver(); - private conditionEvaluator: ConditionEvaluator; - - - public constructor(registry: PouchDefinitionRegistry, environment?: Environment) { - if (undefined === environment) { - environment = this.getOrCreateEnvironment(registry); - } - Assert.notNull(registry, 'PouchDefinitionRegistry must not be null'); - Assert.notNull(environment, 'Environment must not be null'); - this.registry = registry; - this.conditionEvaluator = new ConditionEvaluator(registry, environment, null); - AnnotationConfigUtils.registerAnnotationConfigProcessors(this.registry); - } - - /** - * Register one or more annotated classes to be processed. - *

Calls to {@code register} are idempotent; adding the same - * annotated class more than once has no additional effect. - * @param annotatedClasses one or more annotated classes, - * e.g. {@link Configuration @Configuration} classes - */ - public register(...annotatedClasses: Class[]): void { - annotatedClasses.forEach(annotatedClass => { - this.registerPouch(annotatedClass); - }); - } - /** - * Register a pouch from the given pouch class, deriving its metadata from - * class-declared annotations. - * @param annotatedClass the class of the pouch - */ - public registerPouch(annotatedClass: Class): void { - this.doRegisterPouch(annotatedClass, null, null, null); - } - - /** - * Register a pouch from the given pouch class, deriving its metadata from - * class-declared annotations. - * @param annotatedClass the class of the pouch - * @param instanceSupplier a callback for creating an instance of the pouch - * (may be {@code null}) - * @param name an explicit name for the pouch - * @param qualifiers specific qualifier annotations to consider, if any, - * in addition to qualifiers at the pouch class level - * @param definitionCustomizers one or more callbacks for customizing the - * factory's {@link PouchDefinition}, e.g. setting a lazy-init or primary flag - * @since 5.0 - */ - public doRegisterPouch(annotatedClass: Class, instanceSupplier: Supplier, name: PouchName, - qualifiers: Class[], ...definitionCustomizers: PouchDefinitionCustomizer[]): void { - - let abd: AnnotatedGenericPouchDefinition = new AnnotatedGenericPouchDefinition(annotatedClass); - if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) { - return; - } - - abd.setInstanceSupplier(instanceSupplier); - let scopeMetadata: ScopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd); - abd.setScope(scopeMetadata.getScopeName()); - let pouchName: PouchName = (name != null ? name : this.pouchNameGenerator.generatePouchName(abd, this.registry)); - - AnnotationConfigUtils.processCommonDefinitionAnnotations(abd); - if (qualifiers != null) { - qualifiers.forEach((qualifier, index) => { - if (Primary.class === qualifier) { - abd.setPrimary(true); - } - else if (Lazy.class === qualifier) { - abd.setLazyInit(true); - } - else { - abd.addQualifier(new AutowireCandidateQualifier(qualifier)); - } - }); - } - definitionCustomizers.forEach((customizer) => { - customizer.customize(abd); - }); - - let definitionHolder: PouchDefinitionHolder = new PouchDefinitionHolder(abd, pouchName); - definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry); - PouchDefinitionReaderUtils.registerPouchDefinition(definitionHolder, this.registry); - } -} - -export default AnnotatedPouchDefinitionReader; diff --git a/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts b/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts deleted file mode 100644 index 333ba7c..0000000 --- a/src/ts/@loafer/context/annotation/AnnotationConfigApplicationContext.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { - Assert, -} from '@loafer/core/util'; - -import GenericApplicationContext from '@loafer/context/support/GenericApplicationContext'; -import AnnotatedPouchDefinitionReader from '@loafer/context/annotation/AnnotatedPouchDefinitionReader'; - -export class AnnotationConfigApplicationContext extends GenericApplicationContext { - private readonly reader: AnnotatedPouchDefinitionReader; - - public register(...annotatedClasses: Class[]): void { - Assert.notEmpty(annotatedClasses, 'At least one annotated class must be specified'); - this.reader.register(annotatedClasses); - } -} - -export default AnnotationConfigApplicationContext; diff --git a/src/ts/@loafer/context/decorator/Configuration.ts b/src/ts/@loafer/context/decorator/Configuration.ts deleted file mode 100644 index 7e40255..0000000 --- a/src/ts/@loafer/context/decorator/Configuration.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import { - InjectableAnnotation, -} from '@loafer/pouches/decorator/Injectable'; - -export class ConfigurationAnnotation extends InjectableAnnotation { - public constructor(qualifier?: QualifierName) { - super(qualifier); - } - public onClassDecorator = (target: TFunction): TFunction | void => { - console.log('Configuration'); - } - -} - -export const Configuration = Decorator.create(ConfigurationAnnotation); - -export default Configuration; diff --git a/src/ts/@loafer/context/decorator/Pouch.ts b/src/ts/@loafer/context/decorator/Pouch.ts deleted file mode 100644 index f09d3f3..0000000 --- a/src/ts/@loafer/context/decorator/Pouch.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export interface PouchConfig { - qualifier?: QualifierName; - type?: Class; -} - -export class PouchAnnotation extends Annotation { - private readonly Qualifier: QualifierName; - private readonly Type: Class; - public constructor(config: PouchConfig = {}) { - super(); - this.Qualifier = config.qualifier; - this.Type = config.type; - } - - public onMethodDecorator = (target: Object, propertyKey: Identity, - descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void => { - console.log('Pouch'); - } -} - -export const Pouch = Decorator.create(PouchAnnotation); - -export default Pouch; diff --git a/src/ts/@loafer/context/support/AbstractApplicationContext.ts b/src/ts/@loafer/context/support/AbstractApplicationContext.ts deleted file mode 100644 index 0fc28a3..0000000 --- a/src/ts/@loafer/context/support/AbstractApplicationContext.ts +++ /dev/null @@ -1,5 +0,0 @@ -export abstract class AbstractApplicationContext { - -} - -export default AbstractApplicationContext; diff --git a/src/ts/@loafer/context/support/GenericApplicationContext.ts b/src/ts/@loafer/context/support/GenericApplicationContext.ts deleted file mode 100644 index 261510d..0000000 --- a/src/ts/@loafer/context/support/GenericApplicationContext.ts +++ /dev/null @@ -1,10 +0,0 @@ -import AbstractApplicationContext from '@loafer/context/support/AbstractApplicationContext'; -import PouchDefinitionRegistry from '@loafer/pouches/factory/support/PouchDefinitionRegistry'; - - - -export class GenericApplicationContext extends AbstractApplicationContext implements PouchDefinitionRegistry { - -} - -export default GenericApplicationContext; diff --git a/src/ts/@loafer/core/AliasRegistry.ts b/src/ts/@loafer/core/AliasRegistry.ts deleted file mode 100644 index 00fa9f9..0000000 --- a/src/ts/@loafer/core/AliasRegistry.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface AliasRegistry { - registerAlias(name: PouchName, alias: PouchName): void; - removeAlias(alias: PouchName): void; - isAlias(name: PouchName): boolean; - getAliases(name: PouchName): PouchName[]; -} - -export default AliasRegistry; diff --git a/src/ts/@loafer/core/AttributeAccessor.ts b/src/ts/@loafer/core/AttributeAccessor.ts deleted file mode 100644 index fc2a350..0000000 --- a/src/ts/@loafer/core/AttributeAccessor.ts +++ /dev/null @@ -1,5 +0,0 @@ - -export interface AttributeAccessor { -} - -export default AttributeAccessor; diff --git a/src/ts/@loafer/core/AttributeAccessorSupport.ts b/src/ts/@loafer/core/AttributeAccessorSupport.ts deleted file mode 100644 index 976cde1..0000000 --- a/src/ts/@loafer/core/AttributeAccessorSupport.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { - AttributeAccessor, -} from '@loafer/core'; - -export abstract class AttributeAccessorSupport implements AttributeAccessor { -} - -export default AttributeAccessorSupport; diff --git a/src/ts/@loafer/core/MethodParameter.ts b/src/ts/@loafer/core/MethodParameter.ts deleted file mode 100644 index eb629f8..0000000 --- a/src/ts/@loafer/core/MethodParameter.ts +++ /dev/null @@ -1,10 +0,0 @@ -import Executable from '@loafer/core/reflect/Executable'; -import Parameter from '@loafer/core/reflect/Parameter'; -import Method from '@loafer/core/reflect/Method'; -import Constructor from '@loafer/core/reflect/Constructor'; -import Annotation from '@loafer/core/annotation/Annotation'; - -export class MethodParameter { -} - -export default MethodParameter; diff --git a/src/ts/@loafer/core/NestedRuntimeException.ts b/src/ts/@loafer/core/NestedRuntimeException.ts deleted file mode 100644 index 12b1b22..0000000 --- a/src/ts/@loafer/core/NestedRuntimeException.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - RuntimeException, -} from '@loafer/core/lang'; - -export class NestedRuntimeException extends RuntimeException { - public constructor(message?: string) { - super(message); - } -} - -export default NestedRuntimeException; diff --git a/src/ts/@loafer/core/SimpleAliasRegistry.ts b/src/ts/@loafer/core/SimpleAliasRegistry.ts deleted file mode 100644 index 9ee4f12..0000000 --- a/src/ts/@loafer/core/SimpleAliasRegistry.ts +++ /dev/null @@ -1,7 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; - -export class SimpleAliasRegistry implements AliasRegistry { -} - -export default SimpleAliasRegistry; - diff --git a/src/ts/@loafer/core/annotation/Annotation.ts b/src/ts/@loafer/core/annotation/Annotation.ts deleted file mode 100644 index 60277f6..0000000 --- a/src/ts/@loafer/core/annotation/Annotation.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface Annotation { - onClassDecorator?: (target: TFunction) => TFunction | void; - onPropertyDecorator?: (target: Object, propertyKey: PropertyName) => void; - onMethodDecorator?: (target: Object, propertyKey: PropertyName, - descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; - onParameterDecorator?: (target: Object, propertyKey: PropertyName, parameterIndex: number) => void; -} - -export abstract class Annotation { - -} - -export default Annotation; diff --git a/src/ts/@loafer/core/annotation/index.ts b/src/ts/@loafer/core/annotation/index.ts deleted file mode 100644 index ac90322..0000000 --- a/src/ts/@loafer/core/annotation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Annotation'; diff --git a/src/ts/@loafer/core/constants/decorator.ts b/src/ts/@loafer/core/constants/decorator.ts deleted file mode 100644 index 654a13c..0000000 --- a/src/ts/@loafer/core/constants/decorator.ts +++ /dev/null @@ -1,6 +0,0 @@ -export enum DecoratorType { - CLASS, - PROPERTY, - PARAMETER, - METHOD, -} diff --git a/src/ts/@loafer/core/constants/reflect.ts b/src/ts/@loafer/core/constants/reflect.ts deleted file mode 100644 index 3bc624c..0000000 --- a/src/ts/@loafer/core/constants/reflect.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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'; - -// used to access design time return type -export const REFLECT_META = 'loafer:reflectmeta'; diff --git a/src/ts/@loafer/core/decorator/Decorator.ts b/src/ts/@loafer/core/decorator/Decorator.ts deleted file mode 100644 index ac94a52..0000000 --- a/src/ts/@loafer/core/decorator/Decorator.ts +++ /dev/null @@ -1,88 +0,0 @@ -import * as ReflectConstants from '@loafer/core/constants/reflect'; -import Reflection from '@loafer/core/reflect/Reflection'; -import Clazz from '@loafer/core/reflect/Clazz'; -import Annotation from '@loafer/core/annotation/Annotation'; -import DecoratorType from './DecoratorType'; - -export class Decorator { - public static create = (AnnotationType: Class) => { - return (...handlerArgs: any[]) => { - let annotation: Annotation = new AnnotationType(...handlerArgs); - - return (...decoratorArgs: any[]) => { - let decoratorType: DecoratorType = Decorator._detectDecoratorType(name, annotation, decoratorArgs); - let type = typeof decoratorArgs[0] === 'function' ? decoratorArgs[0].prototype : decoratorArgs[0]; - - let reflection: Reflection = Reflect.getMetadata(ReflectConstants.REFLECT_META, type); - if (undefined === reflection) { - reflection = new Reflection(type); - Reflect.defineMetadata(ReflectConstants.REFLECT_META, reflection, type); - } - let clazz: Clazz = reflection.getClass(); - - switch(decoratorType) { - case DecoratorType.CLASS: - reflection.addClassAnnotation(annotation); - return annotation.onClassDecorator.call(annotation, clazz, decoratorArgs[0]); - case DecoratorType.PROPERTY: - reflection.addPropertyAnnotation(annotation, decoratorArgs[1]); - return annotation.onPropertyDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1]); - case DecoratorType.METHOD: - reflection.addMethodAnnotation(annotation, decoratorArgs[1]); - return annotation.onMethodDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); - case DecoratorType.PARAMETER: - reflection.addParameterAnnotation(annotation, decoratorArgs[1], decoratorArgs[2]); - return annotation.onParameterDecorator.call(annotation, clazz, decoratorArgs[0], decoratorArgs[1], decoratorArgs[2]); - default: - } - }; - }; - } - - public static get = (targetType: Class) => { - let reflection: Reflection = Reflect.getMetadata(ReflectConstants.REFLECT_META, targetType); - if (undefined === reflection) { - return undefined; - } - return reflection.getClass(); - } - - private static _detectDecoratorType(name: string, annotation: any, args: any[]): DecoratorType { - let params = []; - for (let i = 0; i < args.length; i++) { - if (args[i]) { - params.push(args[i]); - } - } - const paramCount = params.length; - let decoratorType: DecoratorType; - - if (1 === paramCount) { - if ('onClassDecorator' in annotation) { - throw new Error(`Cannot apply @${name} decorator on Class.`); - } - decoratorType = DecoratorType.CLASS; - } else if (2 === paramCount) { - if ('onPropertyDecorator' in annotation) { - throw new Error(`Cannot apply @${name} decorator on Property.`); - } - decoratorType = DecoratorType.PROPERTY; - } else if (3 === paramCount) { - if(typeof args[2] === 'number') { - if ('onParameterDecorator' in annotation) { - throw new Error(`Cannot apply @${name} decorator on Parameter.`); - } - decoratorType = DecoratorType.PARAMETER; - } else { - if ('onMethodDecorator' in annotation) { - throw new Error(`Cannot apply @${name} decorator on Method.`); - } - decoratorType = DecoratorType.METHOD; - } - } else { - throw new Error(`@${name} decorator is not valid here!`); - } - - return decoratorType; - } -} diff --git a/src/ts/@loafer/core/decorator/DecoratorType.ts b/src/ts/@loafer/core/decorator/DecoratorType.ts deleted file mode 100644 index 600dd3d..0000000 --- a/src/ts/@loafer/core/decorator/DecoratorType.ts +++ /dev/null @@ -1,8 +0,0 @@ -export enum DecoratorType { - CLASS = 'Clazz', - PROPERTY = 'Property', - METHOD = 'Method', - PARAMETER = 'Parameter', -} - -export default DecoratorType; diff --git a/src/ts/@loafer/core/decorator/index.ts b/src/ts/@loafer/core/decorator/index.ts deleted file mode 100644 index 7aeca8a..0000000 --- a/src/ts/@loafer/core/decorator/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Decorator'; -export * from './DecoratorType'; diff --git a/src/ts/@loafer/core/env/ConfigurableEnvironment.ts b/src/ts/@loafer/core/env/ConfigurableEnvironment.ts deleted file mode 100644 index 7ea34ba..0000000 --- a/src/ts/@loafer/core/env/ConfigurableEnvironment.ts +++ /dev/null @@ -1,6 +0,0 @@ -import Environment from '@loafer/core/env/Environment'; - -export interface ConfigurableEnvironment extends Environment { -} - -export default Environment; diff --git a/src/ts/@loafer/core/env/ConfigurablePropertyResolver.ts b/src/ts/@loafer/core/env/ConfigurablePropertyResolver.ts deleted file mode 100644 index 6bfdac5..0000000 --- a/src/ts/@loafer/core/env/ConfigurablePropertyResolver.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PropertyResolver from '@loafer/core/env/PropertyResolver'; - -export interface ConfigurablePropertyResolver extends PropertyResolver { -} - -export default ConfigurablePropertyResolver; diff --git a/src/ts/@loafer/core/env/Environment.ts b/src/ts/@loafer/core/env/Environment.ts deleted file mode 100644 index 6a9429a..0000000 --- a/src/ts/@loafer/core/env/Environment.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PropertyResolver from '@loafer/core/env/PropertyResolver'; - -export interface Environment extends PropertyResolver { -} - -export default Environment; diff --git a/src/ts/@loafer/core/env/EnvironmentCapable.ts b/src/ts/@loafer/core/env/EnvironmentCapable.ts deleted file mode 100644 index 7a361c3..0000000 --- a/src/ts/@loafer/core/env/EnvironmentCapable.ts +++ /dev/null @@ -1,6 +0,0 @@ -import Environment from '@loafer/core/env/Environment'; - -export interface EnvironmentCapable { -} - -export default EnvironmentCapable; diff --git a/src/ts/@loafer/core/env/PropertyResolver.ts b/src/ts/@loafer/core/env/PropertyResolver.ts deleted file mode 100644 index f9096e6..0000000 --- a/src/ts/@loafer/core/env/PropertyResolver.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface PropertyResolver { -} - -export default PropertyResolver; diff --git a/src/ts/@loafer/core/index.ts b/src/ts/@loafer/core/index.ts deleted file mode 100644 index 66ef556..0000000 --- a/src/ts/@loafer/core/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './AliasRegistry'; -export * from './AttributeAccessor'; -export * from './AttributeAccessorSupport'; -export * from './NestedRuntimeException'; -export * from './SimpleAliasRegistry'; - diff --git a/src/ts/@loafer/core/lang/IllegalArgumentException.ts b/src/ts/@loafer/core/lang/IllegalArgumentException.ts deleted file mode 100644 index f684faa..0000000 --- a/src/ts/@loafer/core/lang/IllegalArgumentException.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - RuntimeException, -} from '@loafer/core/lang'; - -export class IllegalArgumentException extends RuntimeException { - public constructor(message?: string) { - super(message); - } -} - -export default IllegalArgumentException; diff --git a/src/ts/@loafer/core/lang/IllegalStateException.ts b/src/ts/@loafer/core/lang/IllegalStateException.ts deleted file mode 100644 index 8d90067..0000000 --- a/src/ts/@loafer/core/lang/IllegalStateException.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - RuntimeException, -} from '@loafer/core/lang'; - -export class IllegalStateException extends RuntimeException { - public constructor(message?: string) { - super(message); - } -} - -export default IllegalStateException; diff --git a/src/ts/@loafer/core/lang/RuntimeException.ts b/src/ts/@loafer/core/lang/RuntimeException.ts deleted file mode 100644 index 500d40c..0000000 --- a/src/ts/@loafer/core/lang/RuntimeException.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class RuntimeException extends Error { - public constructor(message?: string) { - super(message); - } -} - -export default RuntimeException; diff --git a/src/ts/@loafer/core/lang/index.ts b/src/ts/@loafer/core/lang/index.ts deleted file mode 100644 index 2c5db88..0000000 --- a/src/ts/@loafer/core/lang/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './IllegalArgumentException'; -export * from './IllegalStateException'; -export * from './RuntimeException'; diff --git a/src/ts/@loafer/core/reflect/AnnotatedElement.ts b/src/ts/@loafer/core/reflect/AnnotatedElement.ts deleted file mode 100644 index 32cb362..0000000 --- a/src/ts/@loafer/core/reflect/AnnotatedElement.ts +++ /dev/null @@ -1,29 +0,0 @@ -export abstract class AnnotatedElement { - private _annotationMap: Map, any>; - - protected constructor() { - this._annotationMap = new Map(); - } - - public getDeclaredAnnotation(type: Class): any { - return this._annotationMap.get(type); - } - public getDeclaredAnnotations(): IterableIterator { - return this._annotationMap.values(); - } - - public addAnnotation(annotation: any): void { - const type: Class = Object.getPrototypeOf(annotation); - this._annotationMap.set(type, annotation); - } - - public hasAnnotation(type: Class): boolean { - return this._annotationMap.has(type); - } - - // public abstract getAnnotation(type: Class): any; - // public abstract getAnnotations(): IterableIterator; - -} - -export default AnnotatedElement; diff --git a/src/ts/@loafer/core/reflect/Clazz.ts b/src/ts/@loafer/core/reflect/Clazz.ts deleted file mode 100644 index 6458db2..0000000 --- a/src/ts/@loafer/core/reflect/Clazz.ts +++ /dev/null @@ -1,70 +0,0 @@ -import AnnotatedElement from './AnnotatedElement'; -import Constructor from './Constructor'; -import Property from './Property'; -import Method from './Method'; - - -export class Clazz extends AnnotatedElement { - private _type: Class; - private _name: PropertyName; - private _constructor: Constructor; - private _properties: Map; - private _methodes: Map; - - public constructor(type: Class, parameterTypes: Class[]) { - super(); - this._type = type; - this._name = this._type.constructor.name; - this._constructor = new Constructor(parameterTypes); - this._properties = new Map(); - this._methodes = new Map(); - } - - public get Type(): Class { - return this._type; - } - - public get Name(): PropertyName { - return this._name; - } - - public get Constructor(): Constructor { - return this._constructor; - } - - public addProperty(propertyKey: PropertyName, type: Class): Property { - if (this._properties.has(propertyKey)) { - throw new Error(`Property[${propertyKey}:${type.constructor.name}] on Clazz[${this._name}] is exist already`); - } - let proerty = new Property(type, propertyKey); - this._properties.set(propertyKey, proerty); - return proerty; - } - - public getProperty(propertyKey: PropertyName): Property { - return this._properties.get(propertyKey); - } - - public hasProperty(propertyKey: PropertyName): boolean { - return this._properties.has(propertyKey); - } - - public addMethod(propertyKey: PropertyName, parameterTypes: Class[], returnType: Class): Method { - if (this._methodes.has(propertyKey)) { - throw new Error(`Method[${propertyKey}:${returnType.constructor.name}] on Clazz[${this._name}] is exist already`); - } - let method = new Method(propertyKey, parameterTypes, returnType); - this._methodes.set(propertyKey, method); - return method; - } - - public getMethod(propertyKey: PropertyName): Method { - return this._methodes.get(propertyKey); - } - - public hasMethod(propertyKey: PropertyName): boolean { - return this._methodes.has(propertyKey); - } -} - -export default Clazz; diff --git a/src/ts/@loafer/core/reflect/Constructor.ts b/src/ts/@loafer/core/reflect/Constructor.ts deleted file mode 100644 index cb35400..0000000 --- a/src/ts/@loafer/core/reflect/Constructor.ts +++ /dev/null @@ -1,10 +0,0 @@ -import Executable from '@loafer/core/reflect/Executable'; - -export class Constructor extends Executable { - - public constructor(parameterTypes: Class[]) { - super(parameterTypes); - } -} - -export default Constructor; diff --git a/src/ts/@loafer/core/reflect/Executable.ts b/src/ts/@loafer/core/reflect/Executable.ts deleted file mode 100644 index e8a4b38..0000000 --- a/src/ts/@loafer/core/reflect/Executable.ts +++ /dev/null @@ -1,26 +0,0 @@ -import AnnotatedElement from './AnnotatedElement'; -import Parameter from '@loafer/core/reflect/Parameter'; - -export abstract class Executable extends AnnotatedElement { - protected _parameters: Parameter[]; - - public constructor(parameterTypes: Class[]) { - super(); - - this._parameters = []; - parameterTypes.forEach((currentValue, index, array) => { - this._parameters.push(new Parameter(currentValue, index)); - }); - } - - public get Parameters(): Parameter[] { - return this._parameters; - } - - public getParameter(index: number): Parameter { - return this._parameters[index]; - } - -} - -export default Executable; diff --git a/src/ts/@loafer/core/reflect/Method.ts b/src/ts/@loafer/core/reflect/Method.ts deleted file mode 100644 index d1b9824..0000000 --- a/src/ts/@loafer/core/reflect/Method.ts +++ /dev/null @@ -1,27 +0,0 @@ -import Executable from '@loafer/core/reflect/Executable'; - - -export class Method extends Executable { - private _name: PropertyName; - private _returnType: Class; - - public constructor(name: PropertyName, parameterTypes: Class[], returnType: Class) { - super(parameterTypes); - this._name = name; - this._returnType = returnType; - } - - public get Name(): PropertyName { - return this._name; - } - public get ReturnType(): Class { - return this._returnType; - } - - public set ReturnType(returnType: Class) { - this._returnType = returnType; - } - -} - -export default Method; diff --git a/src/ts/@loafer/core/reflect/Parameter.ts b/src/ts/@loafer/core/reflect/Parameter.ts deleted file mode 100644 index edbb6d5..0000000 --- a/src/ts/@loafer/core/reflect/Parameter.ts +++ /dev/null @@ -1,25 +0,0 @@ -import AnnotatedElement from './AnnotatedElement'; -import Constructor from './Constructor'; - - -export class Parameter extends AnnotatedElement { - private _type: Class; - private _index: number; - - public constructor(type: Class, index: number) { - super(); - this._type = type; - this._index = index; - } - - public get Type(): Class { - return this._type; - } - - public get Index(): number { - return this._index; - } - -} - -export default Parameter; diff --git a/src/ts/@loafer/core/reflect/Property.ts b/src/ts/@loafer/core/reflect/Property.ts deleted file mode 100644 index 8eb410a..0000000 --- a/src/ts/@loafer/core/reflect/Property.ts +++ /dev/null @@ -1,24 +0,0 @@ -import AnnotatedElement from './AnnotatedElement'; -import Constructor from './Constructor'; - - -export class Property extends AnnotatedElement { - private _type: Class; - private _name: PropertyName; - - public constructor(type: Class, name: PropertyName) { - super(); - this._type = type; - this._name = name; - } - - public get Name(): PropertyName { - return this._name; - } - - public get Type(): Class { - return this._type; - } -} - -export default Property; diff --git a/src/ts/@loafer/core/reflect/Reflection.ts b/src/ts/@loafer/core/reflect/Reflection.ts deleted file mode 100644 index 6658252..0000000 --- a/src/ts/@loafer/core/reflect/Reflection.ts +++ /dev/null @@ -1,101 +0,0 @@ -import * as ReflectConstants from '@loafer/core/constants/reflect'; - -import AnnotatedElement from './AnnotatedElement'; -import Clazz from './Clazz'; - -export class Reflection { - private _clazz: Clazz; - - public constructor(type: Class) { - let parameterTypes: any[] = Reflect.getMetadata(ReflectConstants.DESIGN_PARAMTYPES, type.constructor); - - this._clazz = new Clazz(type, this.convertParamTypes(parameterTypes)); - } - - /** - * getClass - */ - public getClass(): Clazz { - return this._clazz; - } - - public addClassAnnotation(annotation: any): void { - let parameterTypes: any[] = Reflect.getMetadata(ReflectConstants.DESIGN_PARAMTYPES, this._clazz.Type); - - const {valid, name} = this.validateAnnotation(annotation, this._clazz); - if (!valid) { - throw new Error(`Cannot apply @${name} decorator multiple times on Class[${this._clazz.Name}].`); - } - - this._clazz.addAnnotation(annotation); - } - public addPropertyAnnotation(annotation: any, propertyKey: PropertyName): void { - let propertyType: any = Reflect.getMetadata(ReflectConstants.DESIGN_TYPE, this._clazz.Type, propertyKey); - - let property = this._clazz.getProperty(propertyKey); - if (undefined === property) { - property = this._clazz.addProperty(propertyKey, propertyType.prototype); - } - - const {valid, name} = this.validateAnnotation(annotation, property); - if (!valid) { - throw new Error(`Cannot apply @${name} decorator multiple times on Property[${this._clazz.Name}:${propertyKey}].`); - } - - property.addAnnotation(annotation); - } - public addMethodAnnotation(annotation: any, propertyKey: PropertyName): void { - let parameterTypes: any[] = Reflect.getMetadata(ReflectConstants.DESIGN_PARAMTYPES, this._clazz.Type, propertyKey); - let returnType: any = Reflect.getMetadata(ReflectConstants.DESIGN_RETURNTYPE, this._clazz.Type, propertyKey); - - let method = this._clazz.getMethod(propertyKey); - if (undefined === method) { - method = this._clazz.addMethod(propertyKey, this.convertParamTypes(parameterTypes), returnType.prototype); - } - - const {valid, name} = this.validateAnnotation(annotation, method); - if (!valid) { - throw new Error(`Cannot apply @${name} decorator multiple times on Method[${this._clazz.Name}:${propertyKey}].`); - } - - method.addAnnotation(annotation); - } - public addParameterAnnotation(annotation: any, propertyKey: PropertyName, parameterIndex: number): void { - let parameterTypes: any[] = Reflect.getMetadata(ReflectConstants.DESIGN_PARAMTYPES, this._clazz.Type, propertyKey); - let returnType: any = Reflect.getMetadata(ReflectConstants.DESIGN_RETURNTYPE, this._clazz.Type, propertyKey); - - let method = this._clazz.getMethod(propertyKey); - if (undefined === method) { - method = this._clazz.addMethod(propertyKey, this.convertParamTypes(parameterTypes), returnType.prototype); - } - - let parameter = method.getParameter(parameterIndex); - - const {valid, name} = this.validateAnnotation(annotation, parameter); - if (!valid) { -throw new Error(`Cannot apply @${name} decorator multiple times on Parameter[${this._clazz.Name}:${propertyKey}(${parameterIndex}})].`); - } - - parameter.addAnnotation(annotation); - } - - private validateAnnotation(annotation: any, element: AnnotatedElement): {valid: boolean, name: string} { - const annotationType: Class = Object.getPrototypeOf(annotation); - const name: string = annotationType.constructor.name; - - if (element.hasAnnotation(annotationType)) { - return {valid: false, name: name}; - } - return {valid: true, name: name}; - } - - private convertParamTypes(parameterTypes: any[]): Class[] { - let returnTypes: Class[] = []; - parameterTypes.forEach((currentValue, index, array) => { - returnTypes.push(currentValue.prototype); - }); - return returnTypes; - } -} - -export default Reflection; diff --git a/src/ts/@loafer/core/reflect/index.ts b/src/ts/@loafer/core/reflect/index.ts deleted file mode 100644 index f3bb7be..0000000 --- a/src/ts/@loafer/core/reflect/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './AnnotatedElement'; -export * from './Clazz'; -export * from './Constructor'; -export * from './Executable'; -export * from './Method'; -export * from './Parameter'; -export * from './Property'; -export * from './Reflection'; diff --git a/src/ts/@loafer/core/type/AnnotatedTypeMetadata.ts b/src/ts/@loafer/core/type/AnnotatedTypeMetadata.ts deleted file mode 100644 index 854f86e..0000000 --- a/src/ts/@loafer/core/type/AnnotatedTypeMetadata.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface AnnotatedTypeMetadata { -} - -export default AnnotatedTypeMetadata; diff --git a/src/ts/@loafer/core/type/AnnotationMetadata.ts b/src/ts/@loafer/core/type/AnnotationMetadata.ts deleted file mode 100644 index 3ea876c..0000000 --- a/src/ts/@loafer/core/type/AnnotationMetadata.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { -AnnotatedTypeMetadata, -ClassMetadata, -} from '@loafer/core/type'; - -export interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata { -} - -export default AnnotationMetadata; diff --git a/src/ts/@loafer/core/type/ClassMetadata.ts b/src/ts/@loafer/core/type/ClassMetadata.ts deleted file mode 100644 index a15e07a..0000000 --- a/src/ts/@loafer/core/type/ClassMetadata.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ClassMetadata { -} - -export default ClassMetadata; diff --git a/src/ts/@loafer/core/type/StandardAnnotationMetadata.ts b/src/ts/@loafer/core/type/StandardAnnotationMetadata.ts deleted file mode 100644 index 2200c8d..0000000 --- a/src/ts/@loafer/core/type/StandardAnnotationMetadata.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { -AnnotationMetadata, -StandardClassMetadata, -} from '@loafer/core/type'; - -export class StandardAnnotationMetadata extends StandardClassMetadata implements AnnotationMetadata { - /** - * Create a new {@link StandardAnnotationMetadata} wrapper for the given Class, - * providing the option to return any nested annotations or annotation arrays in the - * form of {@link org.springframework.core.annotation.AnnotationAttributes} instead - * of actual {@link Annotation} instances. - * @param introspectedClass the Class to introspect - * @param nestedAnnotationsAsMap return nested annotations and annotation arrays as - * {@link org.springframework.core.annotation.AnnotationAttributes} for compatibility - * with ASM-based {@link AnnotationMetadata} implementations - * @since 3.1.1 - */ - public constructor(introspectedClass: Class, nestedAnnotationsAsMap: boolean) { - super(introspectedClass); - this.annotations = introspectedClass.getAnnotations(); - this.nestedAnnotationsAsMap = nestedAnnotationsAsMap; - } -} - -export default StandardAnnotationMetadata; diff --git a/src/ts/@loafer/core/type/StandardClassMetadata.ts b/src/ts/@loafer/core/type/StandardClassMetadata.ts deleted file mode 100644 index 4b188a5..0000000 --- a/src/ts/@loafer/core/type/StandardClassMetadata.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { -ClassMetadata, -} from '@loafer/core/type'; - -export class StandardClassMetadata extends ClassMetadata { -} - -export default StandardClassMetadata; diff --git a/src/ts/@loafer/core/type/index.ts b/src/ts/@loafer/core/type/index.ts deleted file mode 100644 index 931551b..0000000 --- a/src/ts/@loafer/core/type/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './AnnotatedTypeMetadata'; -export * from './AnnotationMetadata'; -export * from './ClassMetadata'; -export * from './StandardAnnotationMetadata'; -export * from './StandardClassMetadata'; diff --git a/src/ts/@loafer/core/util/Assert.ts b/src/ts/@loafer/core/util/Assert.ts deleted file mode 100644 index efa055e..0000000 --- a/src/ts/@loafer/core/util/Assert.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { - IllegalStateException, - IllegalArgumentException, -} from '@loafer/core/lang'; - -import { - StringUtils, -} from '@loafer/core/util'; - -export abstract class Assert { - public static state(expression: boolean, message: string): void { - if (!expression) { - throw new IllegalStateException(message); - } - } - - public static isTrue(expression: boolean, message: string): void { - if (!expression) { - throw new IllegalArgumentException(message); - } - } - - public static isNull(object: any, message: string): void { - if (object !== null) { - throw new IllegalArgumentException(message); - } - } - - public static notNull(object: any, message: string): void { - if (object == null) { - throw new IllegalArgumentException(message); - } - } - - public static hasLength(text: string, message: string): void { - if (!StringUtils.hasLength(text)) { - throw new IllegalArgumentException(message); - } - } - - public static hasText(text: string, message: string): void { - if (!StringUtils.hasText(text)) { - throw new IllegalArgumentException(message); - } - } - - - public static doesNotContain(textToSearch: string, substring: string, message: string): void { - if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && - textToSearch.includes(substring)) { - throw new IllegalArgumentException(message); - } - } - - public static notEmpty(collection: any[] | Map | Set, message: string): void { - if (undefined === collection || null === collection) { - throw new IllegalArgumentException(message); - } - let valid = true; - if (collection instanceof Array) { - let array: any[] = collection; - if (0 === collection.length) { - valid = false; - } - } else if (collection instanceof Map) { - let map: Map = collection; - if (0 === map.size) { - valid = false; - } - } else if (collection instanceof Set) { - let set: Set = collection; - if (0 === set.size) { - valid = false; - } - } else { - valid = false; - } - if (!valid) { - throw new IllegalArgumentException(message); - } - } - - public static noNullElements(array: any[], message: string): void { - if (array !== null) { - array.forEach(element => { - if (element === null) { - throw new IllegalArgumentException(message); - } - }); - } - } - - public static isInstanceOf(type: Class, obj: any, message: string = ''): void { - Assert.notNull(type, 'Type to check against must not be null'); - if (!(obj instanceof type.constructor)) { - Assert.instanceCheckFailed(type, obj, message); - } - } - - private static instanceCheckFailed(type: Class, obj: any, message: string): void { - let className = (obj !== undefined && obj !== null ? Object.getPrototypeOf(obj).constructor.name : 'null'); - let result = ''; - let defaultMessage = true; - if (StringUtils.hasLength(message)) { - if (Assert.endsWithSeparator(message)) { - result = message + ' '; - } else { - result = Assert.messageWithTypeName(message, className); - defaultMessage = false; - } - } - if (defaultMessage) { - result = result + (`Object of class [${className}] must be an instance of ${type}`); - } - throw new IllegalArgumentException(result); - } - - private static endsWithSeparator(message: string): boolean { - return (message.endsWith(':') || message.endsWith(';') || message.endsWith(',') || message.endsWith('.')); - } - - private static messageWithTypeName(message: string, typeName: string): string { - return message + (message.endsWith(' ') ? '' : ': ') + typeName; - } - -} - -export default Assert; diff --git a/src/ts/@loafer/core/util/ObjectUtils.ts b/src/ts/@loafer/core/util/ObjectUtils.ts deleted file mode 100644 index cd33f2b..0000000 --- a/src/ts/@loafer/core/util/ObjectUtils.ts +++ /dev/null @@ -1,64 +0,0 @@ - - -export abstract class ObjectUtils { - - /** - * Determine if the given objects are equal, returning {@code true} if - * both are {@code null} or {@code false} if only one is {@code null}. - *

Compares arrays with {@code Arrays.equals}, performing an equality - * check based on the array elements rather than the array reference. - * @param o1 first Object to compare - * @param o2 second Object to compare - * @return whether the given objects are equal - * @see Object#equals(Object) - * @see java.util.Arrays#equals - */ - public static nullSafeEquals(o1: any, o2: any): boolean { - if (o1 === o2) { - return true; - } - if (o1 === undefined || o2 === undefined) { - return false; - } - if (o1 == null || o2 == null) { - return false; - } - if (Array.isArray(o1) && Array.isArray(o2)) { - return ObjectUtils.arrayEquals(o1, o2); - } - return false; - } - - /** - * Compare the given arrays with {@code Arrays.equals}, performing an equality - * check based on the array elements rather than the array reference. - * @param o1 first array to compare - * @param o2 second array to compare - * @return whether the given objects are equal - * @see #nullSafeEquals(Object, Object) - * @see java.util.Arrays#equals - */ - private static arrayEquals(o1: any, o2: any): boolean { - if (!Array.isArray(o1) || !Array.isArray(o2)) { - return false; - } - if (o1 === o2) { - return true; - } - const arr1 = >o1; - const arr2 = >o2; - - if (arr1.length !== arr2.length) { - return false; - } - arr1.forEach((value, index) => { - if (value !== arr2[index]) { - return false; - } - }); - - return true; - } -} - -export default ObjectUtils; diff --git a/src/ts/@loafer/core/util/StringUtils.ts b/src/ts/@loafer/core/util/StringUtils.ts deleted file mode 100644 index 77e10e6..0000000 --- a/src/ts/@loafer/core/util/StringUtils.ts +++ /dev/null @@ -1,223 +0,0 @@ -import { - IllegalStateException, - IllegalArgumentException, -} from '@loafer/core/lang'; - - -export abstract class StringUtils { - private static readonly FOLDER_SEPARATOR: string = '/'; - - private static readonly WINDOWS_FOLDER_SEPARATOR: string = '\\'; - - private static readonly TOP_PATH: string = '..'; - - private static readonly CURRENT_PATH: string = '.'; - - private static readonly EXTENSION_SEPARATOR: string = '.'; - - - public static isEmpty(str: any): boolean { - return (undefined === str || null === str || '' === str); - } - - public static hasLength(str: string): boolean { - return (undefined !== str && null !== str && str.length > 0); - } - - public static hasText(str: string): boolean { - if (!StringUtils.hasLength(str)) { - return false; - } - return str.trim() !== ''; - } - - public static containsWhitespace(str: string): boolean { - if (!StringUtils.hasLength(str)) { - return false; - } - - return str.replace(/^\s+|\s+$/gm, '').length === 0; - } - - public static trimWhitespace(str: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.trim(); - } - - public static trimAllWhitespace(str: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.replace(/\s/g, ''); - } - - public static trimLeadingWhitespace(str: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.replace(/^\s+/gm, ''); - } - - public static trimTrailingWhitespace(str: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.replace(/^\s+$/gm, ''); - } - - public static trimLeadingCharacter(str: string, leadingCharacter: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.replace(new RegExp('^[' + leadingCharacter + ']+'), ''); - } - - public static trimTrailingCharacter(str: string, trailingCharacter: string): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return str.replace(new RegExp('[' + trailingCharacter + ']+$'), ''); - } - - - public static startsWithIgnoreCase(str: string, prefix: string): boolean { - if (undefined === str || null === str || undefined === prefix || null === prefix) { - return false; - } - if (str.startsWith(prefix)) { - return true; - } - if (str.length < prefix.length) { - return false; - } - - const lcStr = str.substring(0, prefix.length).toLowerCase(); - const lcPrefix = prefix.toLowerCase(); - return lcStr === lcPrefix; - } - - public static endsWithIgnoreCase(str: string, suffix: string): boolean { - if (str == null || suffix == null) { - return false; - } - if (str.endsWith(suffix)) { - return true; - } - if (str.length < suffix.length) { - return false; - } - - const lcStr = str.substring(str.length - suffix.length).toLowerCase(); - const lcSuffix = suffix.toLowerCase(); - return lcStr === lcSuffix; - } - - public static substringMatch(str: string, index: number, substring: string): boolean { - return str.includes(substring); - } - - public static countOccurrencesOf(str: string, sub: string): number { - if (!StringUtils.hasLength(str) || !StringUtils.hasLength(sub)) { - return 0; - } - - return (str.match(new RegExp(sub, 'gi')) || []).length; - } - - public static replace(inString: string, oldPattern: string, newPattern: string): string { - if (!StringUtils.hasLength(inString) || !StringUtils.hasLength(oldPattern) || newPattern == null) { - return inString; - } - return inString.replace(new RegExp(oldPattern, 'g'), newPattern); - } - - public static delete(inString: string, pattern: string): string { - return StringUtils.replace(inString, pattern, ''); - } - - public static deleteAny(inString: string, charsToDelete: string): string { - if (!StringUtils.hasLength(inString) || !StringUtils.hasLength(charsToDelete)) { - return inString; - } - - return inString.replace(new RegExp('^[' + charsToDelete + ']+'), ''); - } - - - public static quote(str: string): string { - return (str !== null ? '\'' + str + '\'' : null); - } - - public static quoteIfString(obj: any): any { - return (typeof obj === 'string' ? StringUtils.quote(obj) : obj); - } - - public static unqualify(qualifiedName: string, separator: string = '.'): string { - return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1); - } - - - public static capitalize(str: string): string { - return StringUtils.changeFirstCharacterCase(str, true); - } - - public static uncapitalize(str: string): string { - return StringUtils.changeFirstCharacterCase(str, false); - } - - private static changeFirstCharacterCase(str: string, capitalize: boolean): string { - if (!StringUtils.hasLength(str)) { - return str; - } - - return capitalize ? str.charAt(0).toUpperCase() + str.slice(1) : str.charAt(0).toLowerCase() + str.slice(1); - } - - public static getFilename(path: string): string { - if (path === null) { - return null; - } - - return path.split(StringUtils.WINDOWS_FOLDER_SEPARATOR).pop().split(StringUtils.FOLDER_SEPARATOR).pop(); - } - - public static getFilenameExtension(path: string): string { - if (path == null) { - return null; - } - - return StringUtils.getFilename(path).split(StringUtils.EXTENSION_SEPARATOR).pop(); - } - - public static stripFilenameExtension(path: string): string { - if (path == null) { - return null; - } - - return path.replace(new RegExp('[' + StringUtils.EXTENSION_SEPARATOR + StringUtils.getFilenameExtension(path) + ']+$'), ''); - } - - public static applyRelativePath(path: string, relativePath: string): string { - let separatorIndex = path.lastIndexOf(StringUtils.FOLDER_SEPARATOR); - if (separatorIndex !== -1) { - let newPath = path.substring(0, separatorIndex); - if (!relativePath.startsWith(StringUtils.FOLDER_SEPARATOR)) { - newPath += StringUtils.FOLDER_SEPARATOR; - } - return newPath + relativePath; - } else { - return relativePath; - } - } - -} - -export default StringUtils; diff --git a/src/ts/@loafer/core/util/TypeUtils.ts b/src/ts/@loafer/core/util/TypeUtils.ts deleted file mode 100644 index 3ccf3d8..0000000 --- a/src/ts/@loafer/core/util/TypeUtils.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export abstract class TypeUtils { - -} - -export default TypeUtils; diff --git a/src/ts/@loafer/core/util/index.ts b/src/ts/@loafer/core/util/index.ts deleted file mode 100644 index 1bade7e..0000000 --- a/src/ts/@loafer/core/util/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './Assert'; -export * from './ObjectUtils'; -export * from './StringUtils'; -export * from './TypeUtils'; - diff --git a/src/ts/@loafer/globals.d.ts b/src/ts/@loafer/globals.d.ts deleted file mode 100644 index d5a0004..0000000 --- a/src/ts/@loafer/globals.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare type Class = {new(...args: any[]): T}; -declare type Interface = Object; -declare type Identity = T | symbol; -declare type PropertyName = Identity; -declare type QualifierName = Identity; -declare type PouchName = Identity; -declare type ValueName = Identity; diff --git a/src/ts/@loafer/pouches/Mergeable.ts b/src/ts/@loafer/pouches/Mergeable.ts deleted file mode 100644 index b0ac2bb..0000000 --- a/src/ts/@loafer/pouches/Mergeable.ts +++ /dev/null @@ -1,20 +0,0 @@ -export interface Mergeable { - /** - * Is merging enabled for this particular instance? - */ - isMergeEnabled(): boolean; - - /** - * Merge the current value set with that of the supplied object. - *

The supplied object is considered the parent, and values in - * the callee's value set must override those of the supplied object. - * @param parent the object to merge with - * @return the result of the merge operation - * @throws IllegalArgumentException if the supplied parent is {@code null} - * @exception IllegalStateException if merging is not enabled for this instance - * (i.e. {@code mergeEnabled} equals {@code false}). - */ - merge(parent: any): any; -} - -export default Mergeable; diff --git a/src/ts/@loafer/pouches/PouchMetadataAttributeAccessor.ts b/src/ts/@loafer/pouches/PouchMetadataAttributeAccessor.ts deleted file mode 100644 index 949aeef..0000000 --- a/src/ts/@loafer/pouches/PouchMetadataAttributeAccessor.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { - AttributeAccessorSupport, -} from '@loafer/core'; - -import { - PouchMetadataElement, -} from '@loafer/pouches'; - - -export class PouchMetadataAttributeAccessor extends AttributeAccessorSupport implements PouchMetadataElement { - -} - -export default PouchMetadataAttributeAccessor; diff --git a/src/ts/@loafer/pouches/PouchMetadataElement.ts b/src/ts/@loafer/pouches/PouchMetadataElement.ts deleted file mode 100644 index 31f86a7..0000000 --- a/src/ts/@loafer/pouches/PouchMetadataElement.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface PouchMetadataElement { -} - -export default PouchMetadataElement; diff --git a/src/ts/@loafer/pouches/PouchesException.ts b/src/ts/@loafer/pouches/PouchesException.ts deleted file mode 100644 index 0c72304..0000000 --- a/src/ts/@loafer/pouches/PouchesException.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - NestedRuntimeException, -} from '@loafer/core'; - -export class PouchesException extends NestedRuntimeException { - public constructor(message?: string) { - super(message); - } -} - -export default PouchesException; diff --git a/src/ts/@loafer/pouches/constants/types.ts b/src/ts/@loafer/pouches/constants/types.ts deleted file mode 100644 index 292f5c0..0000000 --- a/src/ts/@loafer/pouches/constants/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index e73df14..0000000 --- a/src/ts/@loafer/pouches/decorator/Inject.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { - Decorator, - } from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export interface InjectConfig { - qualifier?: QualifierName; - required?: boolean; - type?: Class; -} - -export class InjectAnnotation extends Annotation { - private readonly Qualifier: QualifierName; - private readonly Required: boolean; - private readonly Type: Class; - - public constructor(config: InjectConfig = {}) { - super(); - this.Qualifier = config.qualifier; - this.Required = config.required; - this.Type = config.type; - } - - public onPropertyDecorator = (target: Object, propertyKey: PropertyName): void => { - console.log('Inject'); - } - public onMethodDecorator = (target: Object, propertyKey: PropertyName, - descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void => { - console.log('Inject'); - } - public onParameterDecorator = (target: Object, propertyKey: PropertyName, parameterIndex: number): void => { - console.log('Inject'); - } - -} - -export const Inject = Decorator.create(InjectAnnotation); - -export default Inject; diff --git a/src/ts/@loafer/pouches/decorator/Injectable.ts b/src/ts/@loafer/pouches/decorator/Injectable.ts deleted file mode 100644 index edc8548..0000000 --- a/src/ts/@loafer/pouches/decorator/Injectable.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { - Decorator, - } from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export class InjectableAnnotation extends Annotation { - private readonly Qualifier: QualifierName; - - public constructor(qualifier?: QualifierName) { - super(); - this.Qualifier = qualifier; - } - public onClassDecorator = (target: TFunction): TFunction | void => { - console.log('Injectable'); - } - -} - -export const Injectable = Decorator.create(InjectableAnnotation); - -export default Injectable; diff --git a/src/ts/@loafer/pouches/decorator/PostConstruct.ts b/src/ts/@loafer/pouches/decorator/PostConstruct.ts deleted file mode 100644 index da6f9cd..0000000 --- a/src/ts/@loafer/pouches/decorator/PostConstruct.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export class PostConstructAnnotation extends Annotation { - public onMethodDecorator = (target: Object, propertyKey: PropertyName, - descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void => { - console.log('PostConstruct'); - } -} - -export const PostConstruct = Decorator.create(PostConstructAnnotation); - -export default PostConstruct; diff --git a/src/ts/@loafer/pouches/decorator/PreDestroy.ts b/src/ts/@loafer/pouches/decorator/PreDestroy.ts deleted file mode 100644 index 09f6caa..0000000 --- a/src/ts/@loafer/pouches/decorator/PreDestroy.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export class PreDestroyAnnotation extends Annotation { - public onMethodDecorator = (target: Object, propertyKey: PropertyName, - descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor | void => { - console.log('PreDestroy'); - } -} - -export const PreDestroy = Decorator.create(PreDestroyAnnotation); - -export default PreDestroy; diff --git a/src/ts/@loafer/pouches/decorator/Scope.ts b/src/ts/@loafer/pouches/decorator/Scope.ts deleted file mode 100644 index 6263844..0000000 --- a/src/ts/@loafer/pouches/decorator/Scope.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { - Decorator, - } from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export class ScopeAnnotation extends Annotation { - private readonly Qualifier: QualifierName; - - public constructor(qualifier?: QualifierName) { - super(); - this.Qualifier = qualifier; - } - public onClassDecorator = (target: TFunction): TFunction | void => { - console.log('Scope'); - } - -} - -export const Scope = Decorator.create(ScopeAnnotation); - -export default Scope; diff --git a/src/ts/@loafer/pouches/decorator/Value.ts b/src/ts/@loafer/pouches/decorator/Value.ts deleted file mode 100644 index fc1b813..0000000 --- a/src/ts/@loafer/pouches/decorator/Value.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - Decorator, -} from '@loafer/core/decorator'; - -import Annotation from '@loafer/core/annotation/Annotation'; - -export class ValueAnnotation extends Annotation { - private readonly Value: ValueName; - - public constructor(value: ValueName) { - super(); - this.Value = value; - } - - public onPropertyDecorator = (target: Object, propertyKey: PropertyName): void => { - console.log('Value'); - } - public onParameterDecorator = (target: Object, propertyKey: PropertyName, parameterIndex: number): void => { - console.log('Value'); - } - -} - -export const Value = Decorator.create(ValueAnnotation); - -export default Value; diff --git a/src/ts/@loafer/pouches/factory/DisposablePouch.ts b/src/ts/@loafer/pouches/factory/DisposablePouch.ts deleted file mode 100644 index 1be0f73..0000000 --- a/src/ts/@loafer/pouches/factory/DisposablePouch.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface DisposablePouch { -} - -export default DisposablePouch; diff --git a/src/ts/@loafer/pouches/factory/FactoryPouch.ts b/src/ts/@loafer/pouches/factory/FactoryPouch.ts deleted file mode 100644 index 0885ffe..0000000 --- a/src/ts/@loafer/pouches/factory/FactoryPouch.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface FactoryPouch { -} - -export default FactoryPouch; diff --git a/src/ts/@loafer/pouches/factory/HierarchicalPouchFactory.ts b/src/ts/@loafer/pouches/factory/HierarchicalPouchFactory.ts deleted file mode 100644 index 851e7f7..0000000 --- a/src/ts/@loafer/pouches/factory/HierarchicalPouchFactory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PouchFactory from '@loafer/pouches/factory/PouchFactory'; - -export interface HierarchicalPouchFactory extends PouchFactory { -} - -export default HierarchicalPouchFactory; diff --git a/src/ts/@loafer/pouches/factory/ListablePouchFactory.ts b/src/ts/@loafer/pouches/factory/ListablePouchFactory.ts deleted file mode 100644 index 1d45f9b..0000000 --- a/src/ts/@loafer/pouches/factory/ListablePouchFactory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PouchFactory from '@loafer/pouches/factory/PouchFactory'; - -export interface ListablePouchFactory extends PouchFactory { -} - -export default ListablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts b/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts deleted file mode 100644 index 7d6d6e2..0000000 --- a/src/ts/@loafer/pouches/factory/NoSuchPouchDefinitionException.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - PouchesException, -} from '@loafer/pouches'; - -export class NoSuchPouchDefinitionException extends PouchesException { - public constructor(message?: string) { - super(message); - } -} - -export default NoSuchPouchDefinitionException; diff --git a/src/ts/@loafer/pouches/factory/ObjectFactory.ts b/src/ts/@loafer/pouches/factory/ObjectFactory.ts deleted file mode 100644 index cc3816f..0000000 --- a/src/ts/@loafer/pouches/factory/ObjectFactory.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ObjectFactory { -} - -export default ObjectFactory; diff --git a/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts b/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts deleted file mode 100644 index 4d028c6..0000000 --- a/src/ts/@loafer/pouches/factory/PouchDefinitionStoreException.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class PouchDefinitionStoreException extends Error { - public constructor(message?: string) { - super(message); - } -} - -export default PouchDefinitionStoreException; diff --git a/src/ts/@loafer/pouches/factory/PouchFactory.ts b/src/ts/@loafer/pouches/factory/PouchFactory.ts deleted file mode 100644 index 7c90452..0000000 --- a/src/ts/@loafer/pouches/factory/PouchFactory.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export interface PouchFactory { - -} - -export default PouchFactory; diff --git a/src/ts/@loafer/pouches/factory/annotation/AnnotatedGenericPouchDefinition.ts b/src/ts/@loafer/pouches/factory/annotation/AnnotatedGenericPouchDefinition.ts deleted file mode 100644 index aa6b2ff..0000000 --- a/src/ts/@loafer/pouches/factory/annotation/AnnotatedGenericPouchDefinition.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - AnnotationMetadata, -} from '@loafer/core/type'; - - -import { - GenericPouchDefinition, -} from '@loafer/pouches/factory/support'; - -import { - AnnotatedPouchDefinition, -} from '@loafer/pouches/factory/annotation'; - - - -export class AnnotatedGenericPouchDefinition extends GenericPouchDefinition implements AnnotatedPouchDefinition { - private readonly metadata: AnnotationMetadata; - - public constructor(pouchClass: Class) { - super(); - this.PouchClass = pouchClass; - this.metadata = new StandardAnnotationMetadata(pouchClass, true); - } -} - -export default AnnotatedGenericPouchDefinition; diff --git a/src/ts/@loafer/pouches/factory/annotation/AnnotatedPouchDefinition.ts b/src/ts/@loafer/pouches/factory/annotation/AnnotatedPouchDefinition.ts deleted file mode 100644 index 049d403..0000000 --- a/src/ts/@loafer/pouches/factory/annotation/AnnotatedPouchDefinition.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - PouchDefinition, -} from '@loafer/pouches/factory/config'; - - - - -export interface AnnotatedPouchDefinition extends PouchDefinition { -} - -export default AnnotatedPouchDefinition; diff --git a/src/ts/@loafer/pouches/factory/annotation/index.ts b/src/ts/@loafer/pouches/factory/annotation/index.ts deleted file mode 100644 index cb9ed78..0000000 --- a/src/ts/@loafer/pouches/factory/annotation/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './AnnotatedPouchDefinition'; -export * from './AnnotatedGenericPouchDefinition'; diff --git a/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts b/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts deleted file mode 100644 index 969ee2a..0000000 --- a/src/ts/@loafer/pouches/factory/config/ConfigurableListablePouchFactory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PouchFactory from '@loafer/pouches/factory/PouchFactory'; - -export interface ConfigurableListablePouchFactory { -} - -export default ConfigurableListablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/config/ConfigurablePouchFactory.ts b/src/ts/@loafer/pouches/factory/config/ConfigurablePouchFactory.ts deleted file mode 100644 index cfb3446..0000000 --- a/src/ts/@loafer/pouches/factory/config/ConfigurablePouchFactory.ts +++ /dev/null @@ -1,12 +0,0 @@ -import PouchFactory from '@loafer/pouches/factory/PouchFactory'; -import HierarchicalPouchFactory from '@loafer/pouches/factory/HierarchicalPouchFactory'; -import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; -import SingletonPouchRegistry from '@loafer/pouches/factory/config/SingletonPouchRegistry'; -import PouchExpressionResolver from '@loafer/pouches/factory/config/PouchExpressionResolver'; - - - -export interface ConfigurablePouchFactory extends HierarchicalPouchFactory, SingletonPouchRegistry { -} - -export default ConfigurablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts b/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts deleted file mode 100644 index 813a398..0000000 --- a/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { - Assert, - ObjectUtils, - TypeUtils, -} from '@loafer/core/util'; - -import { - Mergeable, - PouchMetadataElement, -} from '@loafer/pouches'; - -import { - HierarchicalPouchFactory, - PouchFactory, -} from '@loafer/pouches/factory'; - -import { - PouchDefinition, - PouchExpressionResolver, - SingletonPouchRegistry, -} from '@loafer/pouches/factory/config'; - -export class ConstructorArgumentValues { - private readonly indexedArgumentValues: Map = new Map(); - private readonly genericArgumentValues: ValueHolder[] = []; - - /** - * Deep copy constructor. - * @param original the ConstructorArgumentValues to copy - */ - public constructor(original?: ConstructorArgumentValues) { - // - } - - -} - - -/** - * Holder for a constructor argument value, with an optional type - * attribute indicating the target type of the actual constructor argument. - */ -export class ValueHolder implements PouchMetadataElement { - private value: any; - private type: string; - private name: string; - private source: any; - private converted: boolean = false; - private convertedValue: any; - - /** - * Create a new ValueHolder for the given value, type and name. - * @param value the argument value - * @param type the type of the constructor argument - * @param name the name of the constructor argument - */ - public constructor( value: any, type?: string, name?: string) { - this.value = value; - this.type = type; - this.name = name; - } - - /** - * Set the value for the constructor argument. - * @see PropertyPlaceholderConfigurer - */ - public set Value(value: any) { - this.value = value; - } - - /** - * Return the value for the constructor argument. - */ - - public get Value(): any { - return this.value; - } - - /** - * Set the type of the constructor argument. - */ - public set Type(type: string) { - this.type = type; - } - - /** - * Return the type of the constructor argument. - */ - - public get Type(): string { - return this.type; - } - - /** - * Set the name of the constructor argument. - */ - public set Name(name: string) { - this.name = name; - } - - /** - * Return the name of the constructor argument. - */ - - public get Name(): string { - return this.name; - } - - /** - * Set the configuration source {@code Object} for this metadata element. - *

The exact type of the object will depend on the configuration mechanism used. - */ - public set Source(source: any) { - this.source = source; - } - - public get Source(): any { - return this.source; - } - - /** - * Return whether this holder contains a converted value already ({@code true}), - * or whether the value still needs to be converted ({@code false}). - */ - public isConverted(): boolean { - return this.converted; - } - - /** - * Set the converted value of the constructor argument, - * after processed type conversion. - */ - public set ConvertedValue(value: any) { - this.converted = (value != null); - this.convertedValue = value; - } - - /** - * Return the converted value of the constructor argument, - * after processed type conversion. - */ - public get ConvertedValue(): any { - return this.convertedValue; - } - - /** - * Determine whether the content of this ValueHolder is equal - * to the content of the given other ValueHolder. - *

Note that ValueHolder does not implement {@code equals} - * directly, to allow for multiple ValueHolder instances with the - * same content to reside in the same Set. - */ - private contentEquals(other: ValueHolder): boolean { - return (this === other || - (ObjectUtils.nullSafeEquals(this.value, other.value) && ObjectUtils.nullSafeEquals(this.type, other.type))); - } - - /** - * Create a copy of this ValueHolder: that is, an independent - * ValueHolder instance with the same contents. - */ - public copy(): ValueHolder { - let copy: ValueHolder = new ValueHolder(this.value, this.type, this.name); - copy.Source = this.Source; - return copy; - } -} - - -export default ConstructorArgumentValues; diff --git a/src/ts/@loafer/pouches/factory/config/InjectCapablePouchFactory.ts b/src/ts/@loafer/pouches/factory/config/InjectCapablePouchFactory.ts deleted file mode 100644 index 109647e..0000000 --- a/src/ts/@loafer/pouches/factory/config/InjectCapablePouchFactory.ts +++ /dev/null @@ -1,6 +0,0 @@ -import PouchFactory from '@loafer/pouches/factory/PouchFactory'; - -export interface InjectCapablePouchFactory extends PouchFactory { -} - -export default InjectCapablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts b/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts deleted file mode 100644 index 2128041..0000000 --- a/src/ts/@loafer/pouches/factory/config/PouchDefinition.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { - PouchScope, -} from '@loafer/pouches/constants/types'; - -export interface PouchDefinition { - - /** - * The name of the parent definition of this pouch definition, if any. - */ - ParentName: PouchName; - /** - * The current pouch class name of this pouch definition. - *

Note that this does not have to be the actual class name used at runtime, in - * case of a child definition overriding/inheriting the class name from its parent. - * Also, this may just be the class that a factory method is called on, or it may - * even be empty in case of a factory pouch reference that a method is called on. - * Hence, do not consider this to be the definitive pouch type at runtime but - * rather only use it for parsing purposes at the individual pouch definition level. - * @see #getParentName() - * @see #getFactoryPouchName() - * @see #getFactoryMethodName() - */ - PouchClassName: string; - /** - * Override the target scope of this pouch, specifying a new scope name. - * @see #SCOPE_SINGLETON - * @see #SCOPE_PROTOTYPE - */ - Scope: string; - /** - * Whether this pouch should be lazily initialized. - *

If {@code false}, the pouch will get instantiated on startup by pouch - * factories that perform eager initialization of singletons. - */ - LazyInit: boolean; - /** - * The names of the pouchs that this pouch depends on being initialized. - * The pouch factory will guarantee that these pouchs get initialized first. - */ - DependsOn: PouchName[]; - /** - * Whether this pouch is a candidate for getting autowired into some other pouch. - *

Note that this flag is designed to only affect type-based autowiring. - * It does not affect explicit references by name, which will get resolved even - * if the specified pouch is not marked as an autowire candidate. As a consequence, - * autowiring by name will nevertheless inject a pouch if the name matches. - */ - AutowireCandidate: boolean; - /** - * Whether this pouch is a primary autowire candidate. - *

If this value is {@code true} for exactly one pouch among multiple - * matching candidates, it will serve as a tie-breaker. - */ - Primary: boolean; - /** - * Specify the factory pouch to use, if any. - * This the name of the pouch to call the specified factory method on. - * @see #setFactoryMethodName - */ - FactoryPouchName: PouchName; - /** - * Specify a factory method, if any. This method will be invoked with - * constructor arguments, or with no arguments if none are specified. - * The method will be invoked on the specified factory pouch, if any, - * or otherwise as a static method on the local pouch class. - * @see #setFactoryPouchName - * @see #setPouchClassName - */ - FactoryMethodName: PropertyName; - /** - * Return the constructor argument values for this pouch. - *

The returned instance can be modified during pouch factory post-processing. - * @return the ConstructorArgumentValues object (never {@code null}) - */ - getConstructorArgumentValues(): ConstructorArgumentValues; - /** - * Return the property values to be applied to a new instance of the pouch. - *

The returned instance can be modified during pouch factory post-processing. - * @return the MutablePropertyValues object (never {@code null}) - */ - getPropertyValues(): MutablePropertyValues; - /** - * Return whether this a Singleton, with a single, shared instance - * returned on all calls. - * @see #SCOPE_SINGLETON - */ - isSingleton(): boolean; - - /** - * Return whether this a Prototype, with an independent instance - * returned for each call. - * @see #SCOPE_PROTOTYPE - */ - isPrototype(): boolean; - - /** - * Return whether this pouch is "abstract", that is, not meant to be instantiated. - */ - isAbstract(): boolean; - - // Read-only attributes - - /** - * Return a human-readable description of this pouch definition. - */ - getDescription(): string; - - /** - * Return a description of the resource that this pouch definition - * came from (for the purpose of showing context in case of errors). - */ - getResourceDescription(): string; - - /** - * Return the originating PouchDefinition, or {@code null} if none. - * Allows for retrieving the decorated pouch definition, if any. - *

Note that this method returns the immediate originator. Iterate through the - * originator chain to find the original PouchDefinition as defined by the user. - */ - getOriginatingPouchDefinition(): PouchDefinition; -} - -export default PouchDefinition; - diff --git a/src/ts/@loafer/pouches/factory/config/PouchExpressionContext.ts b/src/ts/@loafer/pouches/factory/config/PouchExpressionContext.ts deleted file mode 100644 index 678803e..0000000 --- a/src/ts/@loafer/pouches/factory/config/PouchExpressionContext.ts +++ /dev/null @@ -1,7 +0,0 @@ -import ConfigurablePouchFactory from '@loafer/pouches/factory/config/ConfigurablePouchFactory'; -import Scope from '@loafer/pouches/factory/config/Scope'; - -export class PouchExpressionContext { -} - -export default PouchExpressionContext; diff --git a/src/ts/@loafer/pouches/factory/config/PouchExpressionResolver.ts b/src/ts/@loafer/pouches/factory/config/PouchExpressionResolver.ts deleted file mode 100644 index 01747ea..0000000 --- a/src/ts/@loafer/pouches/factory/config/PouchExpressionResolver.ts +++ /dev/null @@ -1,7 +0,0 @@ -import PouchExpressionContext from '@loafer/pouches/factory/config/PouchExpressionContext'; - -export interface PouchExpressionResolver { - -} - -export default PouchExpressionResolver; diff --git a/src/ts/@loafer/pouches/factory/config/Scope.ts b/src/ts/@loafer/pouches/factory/config/Scope.ts deleted file mode 100644 index 50e4064..0000000 --- a/src/ts/@loafer/pouches/factory/config/Scope.ts +++ /dev/null @@ -1,7 +0,0 @@ -import ObjectFactory from '@loafer/pouches/factory/ObjectFactory'; - -export interface Scope { - -} - -export default Scope; diff --git a/src/ts/@loafer/pouches/factory/config/SingletonPouchRegistry.ts b/src/ts/@loafer/pouches/factory/config/SingletonPouchRegistry.ts deleted file mode 100644 index df8a9af..0000000 --- a/src/ts/@loafer/pouches/factory/config/SingletonPouchRegistry.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface SingletonPouchRegistry { -} - -export default SingletonPouchRegistry; diff --git a/src/ts/@loafer/pouches/factory/config/index.ts b/src/ts/@loafer/pouches/factory/config/index.ts deleted file mode 100644 index db62fc6..0000000 --- a/src/ts/@loafer/pouches/factory/config/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from './ConfigurableListablePouchFactory'; -export * from './ConfigurablePouchFactory'; -export * from './InjectCapablePouchFactory'; -export * from './PouchDefinition'; -export * from './PouchExpressionContext'; -export * from './PouchExpressionResolver'; -export * from './Scope'; -export * from './SingletonPouchRegistry'; diff --git a/src/ts/@loafer/pouches/factory/implement/AbstractPouchFactory.ts b/src/ts/@loafer/pouches/factory/implement/AbstractPouchFactory.ts deleted file mode 100644 index 560fa71..0000000 --- a/src/ts/@loafer/pouches/factory/implement/AbstractPouchFactory.ts +++ /dev/null @@ -1,93 +0,0 @@ -// import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; -// import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; -// import DefaultSingletonPouchRegistry from '@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry'; - - - -// abstract class AbstractPouchFactory extends DefaultSingletonPouchRegistry implements PouchDefinitionRegistry { -// protected pouchDefinitionMap: Map, Map, PouchDefinition>>; - -// public constructor() { -// super(); -// this.pouchDefinitionMap = new Map(); -// } - -// public registerPouchDefinition(pouchDefinition: PouchDefinition): void { -// let clazz = pouchDefinition.Clazz; -// // let qualifier = validateQualifier(clazz, pouchDefinition.Qualifier); - -// // if (this.hasPouchDefinition(qualifier, clazz)) { -// // throw new Error(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is exist already`); -// // } -// // let map = this.pouchDefinitionMap.get(qualifier); -// // if (undefined === map) { -// // map = new Map(); -// // this.pouchDefinitionMap.set(qualifier, map); -// // } -// // map.set(clazz, pouchDefinition); -// } - -// public getPouchDefinition(qualifier: Identity, clazz?: Class): PouchDefinition { -// if (!this.pouchDefinitionMap.has(qualifier)) { -// return undefined; -// } -// let map = this.pouchDefinitionMap.get(qualifier); -// let count = map.size; -// let pouchDefinition: PouchDefinition; -// try { -// pouchDefinition = this._getDefinition(map, clazz); -// } catch(e) { -// console.log(`Type of Pouch Definition[${qualifier}] cannot be specified (count:${count})`); -// } -// return pouchDefinition; -// } - -// public getPouchDefinitionByClass(clazz: Class, qualifier?: Identity): PouchDefinition { -// // const _qualifier = validateQualifier(clazz, qualifier); -// return this.getPouchDefinition(qualifier, clazz); -// } - - -// public hasPouchDefinition(qualifier: Identity, clazz?: Class): boolean { -// return undefined === this.getPouchDefinition(qualifier, clazz) ? false : true; -// } -// public hasPouchDefinitionByClass(clazz: Class, qualifier?: Identity): boolean { -// // const _qualifier = validateQualifier(clazz, qualifier); - -// return this.hasPouchDefinition(qualifier, clazz); -// } - -// public removePouchDefinition(qualifier: Identity, clazz?: Class): void { - -// if (!this.hasPouchDefinition(qualifier, clazz)) { -// console.log(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is not exist`); -// return; -// } -// this.pouchDefinitionMap.get(qualifier).delete(clazz); -// if (0 === this.pouchDefinitionMap.get(qualifier).size) { -// this.pouchDefinitionMap.delete(qualifier); -// } -// } - -// public removePouchDefinitionByClass(clazz: Class, qualifier?: Identity): void { -// // const _qualifier = validateQualifier(clazz, qualifier); -// // this.removePouchDefinition(_qualifier, clazz); -// } - - - -// private _getDefinition(map: Map, PouchDefinition>, clazz?: Class): PouchDefinition { -// if (undefined !== clazz) { -// return map.get(clazz); -// } -// const count = map.size; -// if (1 < count) { -// throw new Error('Type of Pouch Definition cannot be specified.'); -// } -// for (let value of Array.from(map.values())) { -// return value; -// } -// } -// } - -// export default AbstractPouchFactory; diff --git a/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts b/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts deleted file mode 100644 index 947e9a4..0000000 --- a/src/ts/@loafer/pouches/factory/implement/DefaultPouchFactory.ts +++ /dev/null @@ -1,110 +0,0 @@ -// import { -// PouchScope, -// } from '@loafer/pouches/constants/types'; - -// import PouchFactory from '@loafer/pouches/factory/PouchFactory'; -// import AbstractPouchFactory from '@loafer/pouches/factory/implement/AbstractPouchFactory'; -// import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; -// import PouchDefinitionRegistry from '@loafer/pouches/factory/registry/PouchDefinitionRegistry'; - -// class DefaultPouchFactory extends AbstractPouchFactory implements PouchFactory, PouchDefinitionRegistry { -// public constructor() { -// super(); -// } -// public getPouch(qualifier: Identity, clazz: Class, ...args: any[]): any { -// let pouchDefinition = this._getPouchDefinition(qualifier, clazz); -// if (undefined === pouchDefinition) { -// throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`); -// } - -// return this._getPouch(pouchDefinition, ...args); -// } -// public getPouchByClass(clazz: Class, qualifier: Identity, ...args: any[]): any { -// // let _qualifier = validateQualifier(clazz, qualifier); - -// // let pouchDefinition = this._getPouchDefinition(_qualifier, clazz); -// // if (undefined === pouchDefinition) { -// // throw new Error(`This class[${clazz.constructor.name}:${qualifier}] is not pouch.`); -// // } - -// // return this._getPouch(pouchDefinition, ...args); -// } - -// private _getPouchDefinition(qualifier: Identity, clazz: Class): PouchDefinition { -// let pouchDefinition = this.getPouchDefinition(qualifier, clazz); - -// if (undefined === pouchDefinition) { -// // pouchDefinition = this._getInjectableDefinition(clazz); -// if (undefined !== pouchDefinition) { -// this.registerPouchDefinition(pouchDefinition); -// } -// } - -// return pouchDefinition; -// } - -// private _getPouch(pouchDefinition: PouchDefinition, ...args: any[]): any { -// let instance; -// if (pouchDefinition.isSingleton()) { -// instance = this.getSingleton(pouchDefinition.Qualifier, pouchDefinition.Clazz); -// if (undefined !== instance) { -// return instance; -// } -// } -// instance = Object.create(pouchDefinition.Clazz); -// instance.constructor.apply(instance, ...args); - -// this._injectDependency(instance, pouchDefinition.Clazz); -// } - -// private _injectDependency(instance: any, clazz: Class): void { -// if (clazz.constructor === Object) { -// return; -// } - -// // let injectDefinition: InjectDefinition = this._getInjectDefinition(clazz); -// // if (undefined !== injectDefinition) { -// // let injectors: Map, InjectItem> = injectDefinition.injectors; -// // let propertyDescriptor: PropertyDescriptor; -// // injectors.forEach((injectItem, key, map) => { -// // propertyDescriptor = Object.getOwnPropertyDescriptor(clazz, key); - -// // switch (injectItem.decoratorType) { -// // case DecoratorType.PROPERTY: -// // this._injectDependencyProperty(instance, clazz, key, propertyDescriptor, injectItem.propertyConfig); -// // break; -// // case DecoratorType.PARAMETER: -// // this._injectDependencyParameter(instance, propertyDescriptor, injectItem.parameterConfigMap); -// // break; -// // default: -// // break; -// // } -// // }); -// // } -// // this._injectDependency(instance, Object.getPrototypeOf(clazz)); -// } - -// // private _injectDependencyProperty(instance: any, clazz: Class, propertyKey: Identity, -// // propertyDescriptor: PropertyDescriptor, injectConfig: InjectConfig): void { -// // let pouch = this.getPouchByClass(injectConfig.clazz, injectConfig.qualifier); -// // if (injectConfig.required && undefined === instance) { -// // throw new Error(`Pouch which used by [${clazz.constructor.name}.${propertyKey}] is not exist in the context.`); -// // } -// // instance[propertyKey] = pouch; -// // } - -// // private _injectDependencyParameter(target: object, propertyDescriptor: PropertyDescriptor, -// // parameterConfigs: Map): void { -// // console.log(''); -// // } - -// // private _getInjectableDefinition(clazz: Class): InjectableDefinition { -// // return Reflect.getMetadata(POUCH_INJECTABLE_DEFINITION, clazz); -// // } - -// // private _getInjectDefinition(clazz: Class): InjectDefinition { -// // return Reflect.getMetadata(POUCH_INJECT_DEFINITION, clazz); -// // } -// } - -// export default DefaultPouchFactory; diff --git a/src/ts/@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry.ts b/src/ts/@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry.ts deleted file mode 100644 index 50c5196..0000000 --- a/src/ts/@loafer/pouches/factory/implement/DefaultSingletonPouchRegistry.ts +++ /dev/null @@ -1,73 +0,0 @@ -import SingletonPouchRegistry from '@loafer/pouches/factory/config/SingletonPouchRegistry'; - -class DefaultSingletonPouchRegistry implements SingletonPouchRegistry { - protected singletonInstanceMap: Map, any>>; - - protected constructor() { - this.singletonInstanceMap = new Map(); - } - - public registerSingleton(pouch: any, qualifier?: QualifierName): void { - let clazz: Class = Object.getPrototypeOf(pouch); - // const _qualifier = validateQualifier(clazz, qualifier); - - // if (this._hasSingleton(_qualifier, clazz)) { - // throw new Error(`Pouch Definition[${clazz.constructor.name}:${qualifier}] is exist already`); - // } - // let map = this.singletonInstanceMap.get(_qualifier); - // if (undefined === map) { - // map = new Map(); - // this.singletonInstanceMap.set(_qualifier, map); - // } - // map.set(clazz, pouch); - } - - public getSingleton(qualifier: QualifierName, clazz?: Class): any { - return this._getSingleton(qualifier, clazz); - } - public getSingletonByClass(clazz: Class, qualifier?: QualifierName): any { - // const _qualifier = validateQualifier(clazz, qualifier); - return this._getSingleton(qualifier, clazz); - } - public hasSingleton(qualifier: QualifierName, clazz?: Class): boolean { - return this._hasSingleton(qualifier, clazz); - } - public hasSingletonByClass(clazz: Class, qualifier?: QualifierName): boolean { - // const _qualifier = validateQualifier(clazz, qualifier); - return this._hasSingleton(qualifier, clazz); - } - - - private _getSingleton(qualifier: QualifierName, clazz?: Class): T { - if (!this.singletonInstanceMap.has(qualifier)) { - return undefined; - } - let map = this.singletonInstanceMap.get(qualifier); - let instance; - try { - instance = this._getInstance(map, clazz); - } catch(e) { - throw new Error(`Type of Pouch[${qualifier}] cannot be specified(count is ${map.size}).`); - } - return instance; - } - - private _hasSingleton(qualifier: QualifierName, clazz?: Class): boolean { - return undefined === this._getSingleton(qualifier, clazz) ? false : true; - } - - private _getInstance(map: Map, any>, clazz?: Class): any { - if (undefined !== clazz) { - return map.get(clazz); - } - const count = map.size; - if (1 < count) { - throw new Error(`Type of Pouch cannot be specified(count is ${count}).`); - } - for (let value of Array.from(map.values())) { - return value; - } - } -} - -export default DefaultSingletonPouchRegistry; diff --git a/src/ts/@loafer/pouches/factory/index.ts b/src/ts/@loafer/pouches/factory/index.ts deleted file mode 100644 index 63db39b..0000000 --- a/src/ts/@loafer/pouches/factory/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export * from './FactoryPouch'; -export * from './HierarchicalPouchFactory'; -export * from './ListablePouchFactory'; - -export * from './NoSuchPouchDefinitionException'; -export * from './PouchDefinitionStoreException'; -export * from './PouchFactory'; diff --git a/src/ts/@loafer/pouches/factory/support/AbstractInjectCapablePouchFactory.ts b/src/ts/@loafer/pouches/factory/support/AbstractInjectCapablePouchFactory.ts deleted file mode 100644 index e87d481..0000000 --- a/src/ts/@loafer/pouches/factory/support/AbstractInjectCapablePouchFactory.ts +++ /dev/null @@ -1,7 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; -import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; - -export abstract class AbstractInjectCapablePouchFactory implements AliasRegistry { -} - -export default AbstractInjectCapablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/support/AbstractPouchDefinition.ts b/src/ts/@loafer/pouches/factory/support/AbstractPouchDefinition.ts deleted file mode 100644 index 00c85e3..0000000 --- a/src/ts/@loafer/pouches/factory/support/AbstractPouchDefinition.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { - PouchMetadataAttributeAccessor, -} from '@loafer/pouches'; - -import { - PouchDefinition, -} from '@loafer/pouches/factory/config'; - -export abstract class AbstractPouchDefinition extends PouchMetadataAttributeAccessor implements PouchDefinition { -} - -export default AbstractPouchDefinition; diff --git a/src/ts/@loafer/pouches/factory/support/AbstractPouchFactory.ts b/src/ts/@loafer/pouches/factory/support/AbstractPouchFactory.ts deleted file mode 100644 index 9f83ff0..0000000 --- a/src/ts/@loafer/pouches/factory/support/AbstractPouchFactory.ts +++ /dev/null @@ -1,7 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; -import FactoryPouchRegistrySupport from '@loafer/pouches/factory/support/FactoryPouchRegistrySupport'; - -export abstract class AbstractPouchFactory extends FactoryPouchRegistrySupport { -} - -export default AbstractPouchFactory; diff --git a/src/ts/@loafer/pouches/factory/support/DefaultListablePouchFactory.ts b/src/ts/@loafer/pouches/factory/support/DefaultListablePouchFactory.ts deleted file mode 100644 index eb3b9ca..0000000 --- a/src/ts/@loafer/pouches/factory/support/DefaultListablePouchFactory.ts +++ /dev/null @@ -1,7 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; -import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; - -export class DefaultListablePouchFactory implements AliasRegistry { -} - -export default DefaultListablePouchFactory; diff --git a/src/ts/@loafer/pouches/factory/support/DefaultSingletonPouchRegistry.ts b/src/ts/@loafer/pouches/factory/support/DefaultSingletonPouchRegistry.ts deleted file mode 100644 index f8e48ce..0000000 --- a/src/ts/@loafer/pouches/factory/support/DefaultSingletonPouchRegistry.ts +++ /dev/null @@ -1,10 +0,0 @@ -import SimpleAliasRegistry from '@loafer/core/SimpleAliasRegistry'; -import ObjectFactory from '@loafer/pouches/factory/ObjectFactory'; -import DisposablePouch from '@loafer/pouches/factory/DisposablePouch'; -import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; -import SingletonPouchRegistry from '@loafer/pouches/factory/config/SingletonPouchRegistry'; - -export class DefaultSingletonPouchRegistry extends SimpleAliasRegistry implements SingletonPouchRegistry { -} - -export default DefaultSingletonPouchRegistry; diff --git a/src/ts/@loafer/pouches/factory/support/FactoryPouchRegistrySupport.ts b/src/ts/@loafer/pouches/factory/support/FactoryPouchRegistrySupport.ts deleted file mode 100644 index 24f6541..0000000 --- a/src/ts/@loafer/pouches/factory/support/FactoryPouchRegistrySupport.ts +++ /dev/null @@ -1,9 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; -import FactoryPouch from '@loafer/pouches/factory/FactoryPouch'; -import DefaultSingletonPouchRegistry from '@loafer/pouches/factory/support/DefaultSingletonPouchRegistry'; - -export abstract class FactoryPouchRegistrySupport extends DefaultSingletonPouchRegistry { - -} - -export default FactoryPouchRegistrySupport; diff --git a/src/ts/@loafer/pouches/factory/support/GenericPouchDefinition.ts b/src/ts/@loafer/pouches/factory/support/GenericPouchDefinition.ts deleted file mode 100644 index 2c065a3..0000000 --- a/src/ts/@loafer/pouches/factory/support/GenericPouchDefinition.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { - AbstractPouchDefinition, -} from '@loafer/pouches/factory/support'; - -export class GenericPouchDefinition extends AbstractPouchDefinition { -} - -export default GenericPouchDefinition; diff --git a/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts b/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts deleted file mode 100644 index bc7170a..0000000 --- a/src/ts/@loafer/pouches/factory/support/PouchDefinitionRegistry.ts +++ /dev/null @@ -1,68 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; -import PouchDefinition from '@loafer/pouches/factory/config/PouchDefinition'; -import { - PouchDefinitionStoreException, - NoSuchPouchDefinitionException, -} from '@loafer/pouches/factory'; - - -export interface PouchDefinitionRegistry extends AliasRegistry { - - /** - * Register a new pouch definition with this registry. - * Must support RootPouchDefinition and ChildPouchDefinition. - * @param pouchName the name of the pouch instance to register - * @param pouchDefinition definition of the pouch instance to register - * @throws PouchDefinitionStoreException if the PouchDefinition is invalid - * or if there is already a PouchDefinition for the specified pouch name - * (and we are not allowed to override it) - * @see RootPouchDefinition - * @see ChildPouchDefinition - */ - registerPouchDefinition(pouchName: PouchName, pouchDefinition: PouchDefinition): void; - - /** - * Remove the PouchDefinition for the given name. - * @param pouchName the name of the pouch instance to register - * @throws NoSuchPouchDefinitionException if there is no such pouch definition - */ - removePouchDefinition(pouchName: PouchName): void; - - /** - * Return the PouchDefinition for the given pouch name. - * @param pouchName name of the pouch to find a definition for - * @return the PouchDefinition for the given name (never {@code null}) - * @throws NoSuchPouchDefinitionException if there is no such pouch definition - */ - getPouchDefinition(pouchName: PouchName): PouchDefinition; - - /** - * Check if this registry contains a pouch definition with the given name. - * @param pouchName the name of the pouch to look for - * @return if this registry contains a pouch definition with the given name - */ - containsPouchDefinition(pouchName: PouchName): boolean; - - /** - * Return the names of all pouchs defined in this registry. - * @return the names of all pouchs defined in this registry, - * or an empty array if none defined - */ - getPouchDefinitionNames(): PouchName[]; - - /** - * Return the number of pouchs defined in the registry. - * @return the number of pouchs defined in the registry - */ - getPouchDefinitionCount(): number; - - /** - * Determine whether the given pouch name is already in use within this registry, - * i.e. whether there is a local pouch or alias registered under this name. - * @param pouchName the name to check - * @return whether the given pouch name is already in use - */ - isPouchNameInUse(pouchName: PouchName): boolean; -} - -export default PouchDefinitionRegistry; diff --git a/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts b/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts deleted file mode 100644 index 624982a..0000000 --- a/src/ts/@loafer/pouches/factory/support/PouchNameGenerator.ts +++ /dev/null @@ -1,26 +0,0 @@ -import AliasRegistry from '@loafer/core/AliasRegistry'; - -import { - FactoryPouch, -} from '@loafer/pouches/factory'; - -import { - PouchDefinition, -} from '@loafer/pouches/factory/config'; - -import { - DefaultSingletonPouchRegistry, -} from '@loafer/pouches/factory/support'; - -export interface PouchNameGenerator { - /** - * Generate a pouch name for the given pouch definition. - * @param definition the pouch definition to generate a name for - * @param registry the pouch definition registry that the given definition - * is supposed to be registered with - * @return the generated pouch name - */ - generatePouchName(definition: PouchDefinition, registry: PouchDefinitionRegistry): PouchName; -} - -export default PouchNameGenerator; diff --git a/src/ts/@loafer/pouches/factory/support/index.ts b/src/ts/@loafer/pouches/factory/support/index.ts deleted file mode 100644 index a1404a6..0000000 --- a/src/ts/@loafer/pouches/factory/support/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './AbstractInjectCapablePouchFactory'; -export * from './AbstractPouchFactory'; -export * from './AbstractPouchDefinition'; -export * from './DefaultListablePouchFactory'; -export * from './DefaultSingletonPouchRegistry'; -export * from './FactoryPouchRegistrySupport'; -export * from './PouchDefinitionRegistry'; -export * from './GenericPouchDefinition'; - diff --git a/src/ts/@loafer/pouches/index.ts b/src/ts/@loafer/pouches/index.ts deleted file mode 100644 index 8e46387..0000000 --- a/src/ts/@loafer/pouches/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './PouchesException'; -export * from './Mergeable'; -export * from './PouchMetadataElement'; -export * from './PouchMetadataAttributeAccessor'; diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 4c77f41..6b1c0cf 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -1,8 +1,8 @@ import { ReducersMapObject } from 'redux'; -import { SagaWatcher } from '@overflow/commons/constant'; +import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import signInReducer from '@overflow/member/redux/reducer/signIn'; -import asyncRequestSagaWatchers from '@overflow/commons/redux/saga/asyncRequest'; +import AsyncRequest from '@overflow/app/redux/saga/AsyncRequest'; // Container Configuration export interface ContainerConfig { @@ -24,7 +24,7 @@ const rpcConfig: RPCConfig = { export interface ReduxConfig { state: ReduxState; reducerMaps: ReducersMapObject[]; - sagaWarchers: SagaWatcher[]; + sagaWarchers: Class[]; } export interface ReduxState { @@ -39,7 +39,7 @@ const reduxConfig: ReduxConfig = { signInReducer, ], sagaWarchers: [ - ...asyncRequestSagaWatchers, + AsyncRequest, ], }; diff --git a/src/ts/@overflow/app/index.tsx b/src/ts/@overflow/app/index.tsx index e1ac131..4146ffc 100644 --- a/src/ts/@overflow/app/index.tsx +++ b/src/ts/@overflow/app/index.tsx @@ -41,14 +41,11 @@ import { import * as injectTapEventPlugin from 'react-tap-event-plugin'; -import Application from '@loafer/application/Application'; -import ApplicationStater from '@loafer/application/ApplicationStater'; import Platform from '@overflow/commons/platform'; -import Inject from '@loafer/pouches/decorator/Inject'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; import ReducerContext from '@overflow/commons/redux/ReducerContext'; -import { SagaWatcher } from '@overflow/commons/constant'; +import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import appConfig, { Config, ReduxState } from './config'; @@ -67,7 +64,7 @@ declare global { injectTapEventPlugin(); -class OFApplication implements ApplicationStater { +class OFApplication { private static isProduction:boolean = process.env.NODE_ENV === 'production' ? true : false; private static useReduxDevTools:boolean = window.devToolsExtension && !OFApplication.isProduction ? true : false; @@ -87,7 +84,8 @@ class OFApplication implements ApplicationStater { } public static main(): void { - Application.run(OFApplication.prototype); + let app = new OFApplication(); + app.run(); } public async run(): Promise { @@ -153,9 +151,10 @@ class OFApplication implements ApplicationStater { return init; } - private * initReduxSagaWarchers(sagaWarchers: SagaWatcher[]): SagaIterator { - for (let sagaWarcher of sagaWarchers) { - yield fork(sagaWarcher); + private * initReduxSagaWarchers(sagaWarchers: Class[]): SagaIterator { + for (let Watcher of sagaWarchers) { + let instance = new Watcher(); + yield fork({context: instance, fn: instance.watch}); } } diff --git a/src/ts/@overflow/app/redux/saga/AsyncRequest.ts b/src/ts/@overflow/app/redux/saga/AsyncRequest.ts new file mode 100644 index 0000000..1fe4511 --- /dev/null +++ b/src/ts/@overflow/app/redux/saga/AsyncRequest.ts @@ -0,0 +1,43 @@ +import { SagaIterator } from 'redux-saga'; +import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; + +import Action from '@overflow/commons/redux/Action'; +import * as AsyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; + +import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; + +import AsyncRequestPayload from '@overflow/commons/redux/payload/AsyncRequestPayload'; +import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; + + +export class AsyncRequest implements SagaWatcher { + private webSocketRPC: WebSocketRPC; + + private * request(action: Action): SagaIterator { + const {service, method, requestType, args} = action.payload; + try { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // });`${service}.${method}` + // let webSocketRPC: WebSocketRPC = GetAppContext().getPouchByClass(WebSocketRPC.prototype, undefined); + let result = yield call({context: this.webSocketRPC, fn: this.webSocketRPC.Call}, `${service}.${method}`, args); + + // yield put(AsyncRequestActions.requestSuccess(requestType, result)); + } catch (e) { + yield put(AsyncRequestActions.requestFailure(requestType, e)); + } finally { + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: false}, + // }); + } + } + + public * watch(): SagaIterator { + yield takeEvery(AsyncRequestActions.REQUEST, this.request); + } + +} + +export default AsyncRequest; diff --git a/src/ts/@overflow/app/redux/saga/client.ts b/src/ts/@overflow/app/redux/saga/client.ts deleted file mode 100644 index 286bacb..0000000 --- a/src/ts/@overflow/app/redux/saga/client.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Channel, eventChannel, SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; - -function connect(): Promise { - return new Promise(resolve => { - const socket = new WebSocket('ws://localhost:3000'); - - socket.onopen = ((evt: Event): void => { - resolve(socket); - }); - - socket.onclose = ((evt: Event): void => { - console.log(''); - }); - - socket.onmessage = ((evt: MessageEvent): void => { - console.log(''); - }); - - socket.onerror = ((evt: MessageEvent): void => { - console.log(''); - }); - }); -} - -function subscribe(socket: WebSocket): Channel { - return eventChannel(emitter => { - socket.onmessage = ((evt: MessageEvent): void => { - emitter(evt.data); - }); - - return function unsubscribe(): void { - console.log(''); - }; - }); -} - -function* read(socket: WebSocket): SagaIterator { - // const channel = yield call(subscribe, socket); - // let action = yield takeEvery(channel, (action: A) => any); - // while (true) { - // let action = yield take(channel); - // yield put(action); - // } -} - -function* write(socket: WebSocket): SagaIterator { - // while (true) { - // const { payload } = yield take(`${sendMessage}`); - // socket.emit('message', payload); - // } -} - -function* flow(): SagaIterator { - const socket = yield call(connect); -} diff --git a/src/ts/@overflow/commons/api/Service.ts b/src/ts/@overflow/commons/api/Service.ts index f85872a..a751566 100644 --- a/src/ts/@overflow/commons/api/Service.ts +++ b/src/ts/@overflow/commons/api/Service.ts @@ -1,8 +1,6 @@ -import Inject from '@loafer/pouches/decorator/Inject'; import WebSocketRPC from '../websocket/WebSocketRPC'; abstract class Service { - @Inject({required: true}) private webSocketRPC: WebSocketRPC; private name: string; protected constructor(name: string) { diff --git a/src/ts/@overflow/commons/redux/saga/SagaWatcher.ts b/src/ts/@overflow/commons/redux/saga/SagaWatcher.ts new file mode 100644 index 0000000..a9f6c1c --- /dev/null +++ b/src/ts/@overflow/commons/redux/saga/SagaWatcher.ts @@ -0,0 +1,7 @@ +import { SagaIterator } from 'redux-saga'; + +export interface SagaWatcher { + watch(): SagaIterator; +} + +export default SagaWatcher; diff --git a/src/ts/@overflow/commons/redux/saga/asyncRequest.ts b/src/ts/@overflow/commons/redux/saga/asyncRequest.ts deleted file mode 100644 index 36dee53..0000000 --- a/src/ts/@overflow/commons/redux/saga/asyncRequest.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { SagaIterator } from 'redux-saga'; -import { call, Effect, fork, put, takeEvery } from 'redux-saga/effects'; - -import { SagaWatcher } from '@overflow/commons/constant'; -import Action from '@overflow/commons/redux/Action'; -import * as AsyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; - -import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; - -import AsyncRequestPayload from '../payload/AsyncRequestPayload'; - -function* request(action: Action): SagaIterator { - const {service, method, requestType, args} = action.payload; - - try { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // });`${service}.${method}` - // let webSocketRPC: WebSocketRPC = GetAppContext().getPouchByClass(WebSocketRPC.prototype, undefined); - // let result = yield call({context: webSocketRPC, fn: webSocketRPC.Call}, `${service}.${method}`, args); - - // yield put(AsyncRequestActions.requestSuccess(requestType, result)); - } catch (e) { - yield put(AsyncRequestActions.requestFailure(requestType, e)); - } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); - } -} - -function* watchAsyncRequest(): SagaIterator { - yield takeEvery(AsyncRequestActions.REQUEST, request); -} - -const sagaWatchers: SagaWatcher[] = [watchAsyncRequest]; - -export default sagaWatchers; diff --git a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts index b75d520..5ac6c52 100644 --- a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts +++ b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts @@ -10,8 +10,6 @@ import { RPCResponse, } from './protocol/rpc'; -import Injectable from '@loafer/pouches/decorator/Injectable'; - export type OnDisconnectFunc = () => void; export type OnResponseFunc = (response: any) => void; @@ -36,7 +34,6 @@ enum WebSocketReadyState { CLOSED = 3, } -@Injectable() export default class WebSocketRPC { private url: string; private connStatus: WebSocketStatus; diff --git a/src/ts/@overflow/types.d.ts b/src/ts/@overflow/types.d.ts new file mode 100644 index 0000000..eb7376e --- /dev/null +++ b/src/ts/@overflow/types.d.ts @@ -0,0 +1 @@ +declare type Class = {new(...args: any[]): T};