@allgemein/schema-api 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +34 -0
- package/api/IBaseRef.d.ts +44 -0
- package/api/IBaseRef.js +4 -0
- package/api/IBaseRef.js.map +1 -0
- package/api/IBuildOptions.d.ts +31 -0
- package/api/IBuildOptions.js +4 -0
- package/api/IBuildOptions.js.map +1 -0
- package/api/IClassRef.d.ts +24 -0
- package/api/IClassRef.js +13 -0
- package/api/IClassRef.js.map +1 -0
- package/api/IEntityRef.d.ts +16 -0
- package/api/IEntityRef.js +11 -0
- package/api/IEntityRef.js.map +1 -0
- package/api/IJsonSchema.d.ts +11 -0
- package/api/IJsonSchema.js +26 -0
- package/api/IJsonSchema.js.map +1 -0
- package/api/ILookupRegistry.d.ts +60 -0
- package/api/ILookupRegistry.js +17 -0
- package/api/ILookupRegistry.js.map +1 -0
- package/api/IPropertyExtentions.d.ts +8 -0
- package/api/IPropertyExtentions.js +5 -0
- package/api/IPropertyExtentions.js.map +1 -0
- package/api/IPropertyRef.d.ts +28 -0
- package/api/IPropertyRef.js +13 -0
- package/api/IPropertyRef.js.map +1 -0
- package/api/ISchemaRef.d.ts +8 -0
- package/api/ISchemaRef.js +4 -0
- package/api/ISchemaRef.js.map +1 -0
- package/api/ISerializeSupport.d.ts +11 -0
- package/api/ISerializeSupport.js +26 -0
- package/api/ISerializeSupport.js.map +1 -0
- package/browser.d.ts +62 -0
- package/browser.js +117 -0
- package/browser.js.map +1 -0
- package/decorators/Embeddable.d.ts +2 -0
- package/decorators/Embeddable.js +14 -0
- package/decorators/Embeddable.js.map +1 -0
- package/decorators/Entity.d.ts +2 -0
- package/decorators/Entity.js +14 -0
- package/decorators/Entity.js.map +1 -0
- package/decorators/Namespace.d.ts +1 -0
- package/decorators/Namespace.js +20 -0
- package/decorators/Namespace.js.map +1 -0
- package/decorators/Property.d.ts +3 -0
- package/decorators/Property.js +59 -0
- package/decorators/Property.js.map +1 -0
- package/decorators/PropertyOf.d.ts +2 -0
- package/decorators/PropertyOf.js +28 -0
- package/decorators/PropertyOf.js.map +1 -0
- package/decorators/Schema.d.ts +2 -0
- package/decorators/Schema.js +14 -0
- package/decorators/Schema.js.map +1 -0
- package/decorators/validate/Hostname.d.ts +6 -0
- package/decorators/validate/Hostname.js +38 -0
- package/decorators/validate/Hostname.js.map +1 -0
- package/decorators/validate/Ip4.d.ts +6 -0
- package/decorators/validate/Ip4.js +37 -0
- package/decorators/validate/Ip4.js.map +1 -0
- package/decorators/validate/Ip6.d.ts +5 -0
- package/decorators/validate/Ip6.js +37 -0
- package/decorators/validate/Ip6.js.map +1 -0
- package/decorators/validate/IsEmail.d.ts +5 -0
- package/decorators/validate/IsEmail.js +37 -0
- package/decorators/validate/IsEmail.js.map +1 -0
- package/decorators/validate/IsNotEmpty.d.ts +5 -0
- package/decorators/validate/IsNotEmpty.js +36 -0
- package/decorators/validate/IsNotEmpty.js.map +1 -0
- package/decorators/validate/MaxLength.d.ts +6 -0
- package/decorators/validate/MaxLength.js +34 -0
- package/decorators/validate/MaxLength.js.map +1 -0
- package/decorators/validate/MinLength.d.ts +6 -0
- package/decorators/validate/MinLength.js +34 -0
- package/decorators/validate/MinLength.js.map +1 -0
- package/decorators/validate/Regex.d.ts +7 -0
- package/decorators/validate/Regex.js +46 -0
- package/decorators/validate/Regex.js.map +1 -0
- package/decorators/validate/Required.d.ts +5 -0
- package/decorators/validate/Required.js +34 -0
- package/decorators/validate/Required.js.map +1 -0
- package/decorators/validate/index.d.ts +9 -0
- package/decorators/validate/index.js +21 -0
- package/decorators/validate/index.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/lib/AbstractRef.d.ts +26 -0
- package/lib/AbstractRef.js +126 -0
- package/lib/AbstractRef.js.map +1 -0
- package/lib/AnnotationsHelper.d.ts +7 -0
- package/lib/AnnotationsHelper.js +97 -0
- package/lib/AnnotationsHelper.js.map +1 -0
- package/lib/ClassRef.d.ts +120 -0
- package/lib/ClassRef.js +319 -0
- package/lib/ClassRef.js.map +1 -0
- package/lib/Constants.d.ts +45 -0
- package/lib/Constants.js +65 -0
- package/lib/Constants.js.map +1 -0
- package/lib/DataContainer.d.ts +31 -0
- package/lib/DataContainer.js +148 -0
- package/lib/DataContainer.js.map +1 -0
- package/lib/LookupRegistry.d.ts +36 -0
- package/lib/LookupRegistry.js +106 -0
- package/lib/LookupRegistry.js.map +1 -0
- package/lib/SchemaRef.d.ts +14 -0
- package/lib/SchemaRef.js +51 -0
- package/lib/SchemaRef.js.map +1 -0
- package/lib/SchemaUtils.d.ts +39 -0
- package/lib/SchemaUtils.js +129 -0
- package/lib/SchemaUtils.js.map +1 -0
- package/lib/json-schema/Constants.d.ts +2 -0
- package/lib/json-schema/Constants.js +7 -0
- package/lib/json-schema/Constants.js.map +1 -0
- package/lib/json-schema/IJsonSchemaSerializeOptions.d.ts +40 -0
- package/lib/json-schema/IJsonSchemaSerializeOptions.js +4 -0
- package/lib/json-schema/IJsonSchemaSerializeOptions.js.map +1 -0
- package/lib/json-schema/IJsonSchemaSerializer.d.ts +7 -0
- package/lib/json-schema/IJsonSchemaSerializer.js +4 -0
- package/lib/json-schema/IJsonSchemaSerializer.js.map +1 -0
- package/lib/json-schema/IJsonSchemaUnserializeOptions.d.ts +41 -0
- package/lib/json-schema/IJsonSchemaUnserializeOptions.js +4 -0
- package/lib/json-schema/IJsonSchemaUnserializeOptions.js.map +1 -0
- package/lib/json-schema/IJsonSchemaUnserializer.d.ts +5 -0
- package/lib/json-schema/IJsonSchemaUnserializer.js +4 -0
- package/lib/json-schema/IJsonSchemaUnserializer.js.map +1 -0
- package/lib/json-schema/IParseOptions.d.ts +16 -0
- package/lib/json-schema/IParseOptions.js +6 -0
- package/lib/json-schema/IParseOptions.js.map +1 -0
- package/lib/json-schema/JsonSchema.d.ts +22 -0
- package/lib/json-schema/JsonSchema.js +109 -0
- package/lib/json-schema/JsonSchema.js.map +1 -0
- package/lib/json-schema/JsonSchema7.d.ts +16 -0
- package/lib/json-schema/JsonSchema7.js +22 -0
- package/lib/json-schema/JsonSchema7.js.map +1 -0
- package/lib/json-schema/JsonSchema7Serializer.d.ts +42 -0
- package/lib/json-schema/JsonSchema7Serializer.js +438 -0
- package/lib/json-schema/JsonSchema7Serializer.js.map +1 -0
- package/lib/json-schema/JsonSchema7Unserializer.d.ts +60 -0
- package/lib/json-schema/JsonSchema7Unserializer.js +499 -0
- package/lib/json-schema/JsonSchema7Unserializer.js.map +1 -0
- package/lib/options/IAbstractOptions.d.ts +19 -0
- package/lib/options/IAbstractOptions.js +4 -0
- package/lib/options/IAbstractOptions.js.map +1 -0
- package/lib/options/IAttributeOptions.d.ts +7 -0
- package/lib/options/IAttributeOptions.js +4 -0
- package/lib/options/IAttributeOptions.js.map +1 -0
- package/lib/options/IEntityOptions.d.ts +4 -0
- package/lib/options/IEntityOptions.js +4 -0
- package/lib/options/IEntityOptions.js.map +1 -0
- package/lib/options/IObjectOptions.d.ts +4 -0
- package/lib/options/IObjectOptions.js +4 -0
- package/lib/options/IObjectOptions.js.map +1 -0
- package/lib/options/IPropertyOptions.d.ts +24 -0
- package/lib/options/IPropertyOptions.js +4 -0
- package/lib/options/IPropertyOptions.js.map +1 -0
- package/lib/options/ISchemaOptions.d.ts +4 -0
- package/lib/options/ISchemaOptions.js +4 -0
- package/lib/options/ISchemaOptions.js.map +1 -0
- package/lib/registry/AbstractRegistry.d.ts +91 -0
- package/lib/registry/AbstractRegistry.js +135 -0
- package/lib/registry/AbstractRegistry.js.map +1 -0
- package/lib/registry/Binding.d.ts +9 -0
- package/lib/registry/Binding.js +17 -0
- package/lib/registry/Binding.js.map +1 -0
- package/lib/registry/DefaultEntityRef.d.ts +30 -0
- package/lib/registry/DefaultEntityRef.js +60 -0
- package/lib/registry/DefaultEntityRef.js.map +1 -0
- package/lib/registry/DefaultNamespacedRegistry.d.ts +153 -0
- package/lib/registry/DefaultNamespacedRegistry.js +511 -0
- package/lib/registry/DefaultNamespacedRegistry.js.map +1 -0
- package/lib/registry/DefaultPropertyRef.d.ts +44 -0
- package/lib/registry/DefaultPropertyRef.js +175 -0
- package/lib/registry/DefaultPropertyRef.js.map +1 -0
- package/lib/registry/MetadataRegistry.d.ts +52 -0
- package/lib/registry/MetadataRegistry.js +186 -0
- package/lib/registry/MetadataRegistry.js.map +1 -0
- package/lib/registry/RegistryFactory.d.ts +43 -0
- package/lib/registry/RegistryFactory.js +109 -0
- package/lib/registry/RegistryFactory.js.map +1 -0
- package/lib/serializer/ISerializeOptions.d.ts +10 -0
- package/lib/serializer/ISerializeOptions.js +4 -0
- package/lib/serializer/ISerializeOptions.js.map +1 -0
- package/lib/serializer/ISerializer.d.ts +5 -0
- package/lib/serializer/ISerializer.js +4 -0
- package/lib/serializer/ISerializer.js.map +1 -0
- package/lib/serializer/ISerializerFactory.d.ts +13 -0
- package/lib/serializer/ISerializerFactory.js +4 -0
- package/lib/serializer/ISerializerFactory.js.map +1 -0
- package/lib/serializer/IUnserializeOptions.d.ts +14 -0
- package/lib/serializer/IUnserializeOptions.js +4 -0
- package/lib/serializer/IUnserializeOptions.js.map +1 -0
- package/lib/serializer/IUnserializer.d.ts +5 -0
- package/lib/serializer/IUnserializer.js +4 -0
- package/lib/serializer/IUnserializer.js.map +1 -0
- package/lib/serializer/SerializerRegistry.d.ts +8 -0
- package/lib/serializer/SerializerRegistry.js +20 -0
- package/lib/serializer/SerializerRegistry.js.map +1 -0
- package/lib/validation/DefaultValidator.d.ts +14 -0
- package/lib/validation/DefaultValidator.js +221 -0
- package/lib/validation/DefaultValidator.js.map +1 -0
- package/lib/validation/IValidateOptions.d.ts +4 -0
- package/lib/validation/IValidateOptions.js +4 -0
- package/lib/validation/IValidateOptions.js.map +1 -0
- package/lib/validation/IValidationError.d.ts +10 -0
- package/lib/validation/IValidationError.js +4 -0
- package/lib/validation/IValidationError.js.map +1 -0
- package/lib/validation/IValidationMessage.d.ts +4 -0
- package/lib/validation/IValidationMessage.js +4 -0
- package/lib/validation/IValidationMessage.js.map +1 -0
- package/lib/validation/IValidationOptions.d.ts +1 -0
- package/lib/validation/IValidationOptions.js +30 -0
- package/lib/validation/IValidationOptions.js.map +1 -0
- package/lib/validation/IValidationResult.d.ts +7 -0
- package/lib/validation/IValidationResult.js +4 -0
- package/lib/validation/IValidationResult.js.map +1 -0
- package/lib/validation/IValidator.d.ts +9 -0
- package/lib/validation/IValidator.js +4 -0
- package/lib/validation/IValidator.js.map +1 -0
- package/lib/validation/IValidatorEntry.d.ts +7 -0
- package/lib/validation/IValidatorEntry.js +4 -0
- package/lib/validation/IValidatorEntry.js.map +1 -0
- package/lib/validation/IValidatorHandle.d.ts +2 -0
- package/lib/validation/IValidatorHandle.js +4 -0
- package/lib/validation/IValidatorHandle.js.map +1 -0
- package/lib/validation/Validator.d.ts +17 -0
- package/lib/validation/Validator.js +54 -0
- package/lib/validation/Validator.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JS_DATA_TYPES } from '../../lib/Constants';
|
|
2
|
+
import { IAbstractOptions } from './IAbstractOptions';
|
|
3
|
+
export interface IPropertyOptions extends IAbstractOptions {
|
|
4
|
+
propertyName?: string;
|
|
5
|
+
appended?: boolean;
|
|
6
|
+
cardinality?: number | {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
};
|
|
10
|
+
format?: string;
|
|
11
|
+
type?: JS_DATA_TYPES | any;
|
|
12
|
+
/**
|
|
13
|
+
* Mark if value is representation of unique identifier
|
|
14
|
+
*/
|
|
15
|
+
identifier?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Generate automatically values for identifier
|
|
18
|
+
*/
|
|
19
|
+
generated?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Mark if property is a pattern property
|
|
22
|
+
*/
|
|
23
|
+
pattern?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/options/IPropertyOptions.ts"],"names":[],"mappings":"","file":"IPropertyOptions.js","sourcesContent":["import {JS_DATA_TYPES} from '../../lib/Constants';\nimport {IAbstractOptions} from './IAbstractOptions';\n\nexport interface IPropertyOptions extends IAbstractOptions {\n\n propertyName?: string;\n\n appended?: boolean;\n\n cardinality?: number | { min: number, max: number };\n\n format?: string;\n\n type?: JS_DATA_TYPES | any;\n\n /**\n * Mark if value is representation of unique identifier\n */\n identifier?: boolean;\n\n /**\n * Generate automatically values for identifier\n */\n generated?: boolean;\n\n /**\n * Mark if property is a pattern property\n */\n pattern?: boolean;\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/options/ISchemaOptions.ts"],"names":[],"mappings":"","file":"ISchemaOptions.js","sourcesContent":["import {IAbstractOptions} from './IAbstractOptions';\n\nexport interface ISchemaOptions extends IAbstractOptions {\n\n name: string;\n\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { METADATA_TYPE } from './../Constants';
|
|
4
|
+
import { ILookupRegistry } from '../../api/ILookupRegistry';
|
|
5
|
+
import { IEntityRef } from '../../api/IEntityRef';
|
|
6
|
+
import { IClassRef } from '../../api/IClassRef';
|
|
7
|
+
import { IPropertyRef } from '../../api/IPropertyRef';
|
|
8
|
+
import { LookupRegistry } from '../LookupRegistry';
|
|
9
|
+
import { ISchemaRef } from '../../api/ISchemaRef';
|
|
10
|
+
/**
|
|
11
|
+
* Registry for metadata of classes and there properties
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class AbstractRegistry extends EventEmitter implements ILookupRegistry {
|
|
14
|
+
protected readonly namespace: string;
|
|
15
|
+
constructor(namespace: string);
|
|
16
|
+
/**
|
|
17
|
+
* Return all registered schema references
|
|
18
|
+
*
|
|
19
|
+
* @param ref
|
|
20
|
+
* @return ISchemaRef[]
|
|
21
|
+
*/
|
|
22
|
+
getSchemaRefs<T extends ISchemaRef>(filter?: (x: ISchemaRef) => boolean): (T | ISchemaRef)[];
|
|
23
|
+
/**
|
|
24
|
+
* Return schema references for an given entity or class reference
|
|
25
|
+
*
|
|
26
|
+
* @param ref
|
|
27
|
+
* @return ISchemaRef[]
|
|
28
|
+
*/
|
|
29
|
+
getSchemaRefsFor<T extends ISchemaRef>(ref: string): T | ISchemaRef;
|
|
30
|
+
/**
|
|
31
|
+
* TODO
|
|
32
|
+
*
|
|
33
|
+
* @param filter
|
|
34
|
+
*/
|
|
35
|
+
getEntityRefs<T extends IEntityRef>(filter?: (x: IEntityRef) => boolean): (T | IEntityRef)[];
|
|
36
|
+
/**
|
|
37
|
+
* Can get get entity ref for function.
|
|
38
|
+
*
|
|
39
|
+
* @param fn
|
|
40
|
+
*/
|
|
41
|
+
getEntityRefFor<T extends IEntityRef>(fn: string | object | Function, skipNsCheck?: boolean): (T | IEntityRef);
|
|
42
|
+
/**
|
|
43
|
+
* Returns the used instance of lookup registry handler
|
|
44
|
+
*/
|
|
45
|
+
getLookupRegistry(): LookupRegistry;
|
|
46
|
+
/**
|
|
47
|
+
* Method for returning class ref
|
|
48
|
+
*
|
|
49
|
+
* @param object
|
|
50
|
+
* @param type
|
|
51
|
+
*/
|
|
52
|
+
getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef;
|
|
53
|
+
/**
|
|
54
|
+
* Returns property by name for a given class or entity ref
|
|
55
|
+
*
|
|
56
|
+
* @param filter
|
|
57
|
+
*/
|
|
58
|
+
getPropertyRef<T extends IPropertyRef>(ref: IClassRef | IEntityRef, name: string): (T | IPropertyRef);
|
|
59
|
+
/**
|
|
60
|
+
* Returns all properties for given class or entity ref
|
|
61
|
+
*
|
|
62
|
+
* @param ref
|
|
63
|
+
*/
|
|
64
|
+
getPropertyRefs<T extends IPropertyRef>(ref: IClassRef | IEntityRef): (T | IPropertyRef)[];
|
|
65
|
+
getPropertyRefsFor<T extends IPropertyRef>(fn: string | object | Function): (T | IPropertyRef)[];
|
|
66
|
+
list<X>(type: METADATA_TYPE, filter?: (x: any) => boolean): X[];
|
|
67
|
+
listEntities(filter?: (x: IEntityRef) => boolean): IEntityRef[];
|
|
68
|
+
listProperties(filter?: (x: IPropertyRef) => boolean): IPropertyRef[];
|
|
69
|
+
create<T>(context: string, options: any): T;
|
|
70
|
+
/**
|
|
71
|
+
* TODO
|
|
72
|
+
*/
|
|
73
|
+
add<T>(context: string, entry: T): T;
|
|
74
|
+
/**
|
|
75
|
+
* TODO
|
|
76
|
+
*/
|
|
77
|
+
filter<T>(context: string, search: any): T[];
|
|
78
|
+
/**
|
|
79
|
+
* TODO
|
|
80
|
+
*/
|
|
81
|
+
find<T>(context: string, search: any): T;
|
|
82
|
+
/**
|
|
83
|
+
* TODO
|
|
84
|
+
*/
|
|
85
|
+
remove<T>(context: string, search: any): T[];
|
|
86
|
+
/**
|
|
87
|
+
* reset current registry
|
|
88
|
+
*/
|
|
89
|
+
reset(): void;
|
|
90
|
+
clear(): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractRegistry = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const Constants_1 = require("./../Constants");
|
|
7
|
+
const LookupRegistry_1 = require("../LookupRegistry");
|
|
8
|
+
const base_1 = require("@allgemein/base");
|
|
9
|
+
/**
|
|
10
|
+
* Registry for metadata of classes and there properties
|
|
11
|
+
*/
|
|
12
|
+
class AbstractRegistry extends events_1.EventEmitter {
|
|
13
|
+
constructor(namespace) {
|
|
14
|
+
super();
|
|
15
|
+
this.namespace = namespace;
|
|
16
|
+
}
|
|
17
|
+
// /**
|
|
18
|
+
// * Initialize events for metadata changes on runtime
|
|
19
|
+
// */
|
|
20
|
+
// prepare() {
|
|
21
|
+
// MetadataRegistry.$().on(C_EVENT_ADD, this.onAdd.bind(this));
|
|
22
|
+
// MetadataRegistry.$().on(C_EVENT_REMOVE, this.onRemove.bind(this));
|
|
23
|
+
// MetadataRegistry.$().on(C_EVENT_UPDATE, this.onUpdate.bind(this));
|
|
24
|
+
// }
|
|
25
|
+
/**
|
|
26
|
+
* Return all registered schema references
|
|
27
|
+
*
|
|
28
|
+
* @param ref
|
|
29
|
+
* @return ISchemaRef[]
|
|
30
|
+
*/
|
|
31
|
+
getSchemaRefs(filter) {
|
|
32
|
+
throw new base_1.NotSupportedError('');
|
|
33
|
+
}
|
|
34
|
+
getSchemaRefsFor(ref) {
|
|
35
|
+
throw new base_1.NotSupportedError('');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* TODO
|
|
39
|
+
*
|
|
40
|
+
* @param filter
|
|
41
|
+
*/
|
|
42
|
+
getEntityRefs(filter) {
|
|
43
|
+
return this.filter(Constants_1.METATYPE_ENTITY, filter);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Can get get entity ref for function.
|
|
47
|
+
*
|
|
48
|
+
* @param fn
|
|
49
|
+
*/
|
|
50
|
+
getEntityRefFor(fn, skipNsCheck = true) {
|
|
51
|
+
throw new base_1.NotSupportedError('');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns the used instance of lookup registry handler
|
|
55
|
+
*/
|
|
56
|
+
getLookupRegistry() {
|
|
57
|
+
return LookupRegistry_1.LookupRegistry.$(this.namespace);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Method for returning class ref
|
|
61
|
+
*
|
|
62
|
+
* @param object
|
|
63
|
+
* @param type
|
|
64
|
+
*/
|
|
65
|
+
getClassRefFor(object, type) {
|
|
66
|
+
throw new base_1.NotSupportedError('');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns property by name for a given class or entity ref
|
|
70
|
+
*
|
|
71
|
+
* @param filter
|
|
72
|
+
*/
|
|
73
|
+
getPropertyRef(ref, name) {
|
|
74
|
+
return this.getPropertyRefs(ref).find(x => lodash_1.snakeCase(x.name) === lodash_1.snakeCase(name));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns all properties for given class or entity ref
|
|
78
|
+
*
|
|
79
|
+
* @param ref
|
|
80
|
+
*/
|
|
81
|
+
getPropertyRefs(ref) {
|
|
82
|
+
throw new base_1.NotSupportedError('');
|
|
83
|
+
}
|
|
84
|
+
getPropertyRefsFor(fn) {
|
|
85
|
+
throw new base_1.NotSupportedError('');
|
|
86
|
+
}
|
|
87
|
+
list(type, filter) {
|
|
88
|
+
return this.filter(type, filter);
|
|
89
|
+
}
|
|
90
|
+
listEntities(filter) {
|
|
91
|
+
return this.getEntityRefs(filter);
|
|
92
|
+
}
|
|
93
|
+
listProperties(filter) {
|
|
94
|
+
return this.filter(Constants_1.METATYPE_PROPERTY, filter);
|
|
95
|
+
}
|
|
96
|
+
create(context, options) {
|
|
97
|
+
throw new base_1.NotSupportedError('');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* TODO
|
|
101
|
+
*/
|
|
102
|
+
add(context, entry) {
|
|
103
|
+
return this.getLookupRegistry().add(context, entry);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* TODO
|
|
107
|
+
*/
|
|
108
|
+
filter(context, search) {
|
|
109
|
+
return this.getLookupRegistry().filter(context, search);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* TODO
|
|
113
|
+
*/
|
|
114
|
+
find(context, search) {
|
|
115
|
+
return this.getLookupRegistry().find(context, search);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* TODO
|
|
119
|
+
*/
|
|
120
|
+
remove(context, search) {
|
|
121
|
+
return this.getLookupRegistry().remove(context, search);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* reset current registry
|
|
125
|
+
*/
|
|
126
|
+
reset() {
|
|
127
|
+
this.clear();
|
|
128
|
+
}
|
|
129
|
+
clear() {
|
|
130
|
+
LookupRegistry_1.LookupRegistry.reset(this.namespace);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.AbstractRegistry = AbstractRegistry;
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=AbstractRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/registry/AbstractRegistry.ts"],"names":[],"mappings":"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","file":"AbstractRegistry.js","sourcesContent":["import {snakeCase} from 'lodash';\nimport {EventEmitter} from 'events';\nimport {METADATA_TYPE, METATYPE_ENTITY, METATYPE_PROPERTY} from './../Constants';\nimport {ILookupRegistry} from '../../api/ILookupRegistry';\nimport {IEntityRef} from '../../api/IEntityRef';\nimport {IClassRef} from '../../api/IClassRef';\nimport {IPropertyRef} from '../../api/IPropertyRef';\nimport {LookupRegistry} from '../LookupRegistry';\nimport {NotSupportedError} from '@allgemein/base';\nimport {ISchemaRef} from '../../api/ISchemaRef';\n\n\n/**\n * Registry for metadata of classes and there properties\n */\nexport abstract class AbstractRegistry extends EventEmitter implements ILookupRegistry {\n\n protected readonly namespace: string;\n\n constructor(namespace: string) {\n super();\n this.namespace = namespace;\n }\n\n\n // /**\n // * Initialize events for metadata changes on runtime\n // */\n // prepare() {\n // MetadataRegistry.$().on(C_EVENT_ADD, this.onAdd.bind(this));\n // MetadataRegistry.$().on(C_EVENT_REMOVE, this.onRemove.bind(this));\n // MetadataRegistry.$().on(C_EVENT_UPDATE, this.onUpdate.bind(this));\n // }\n\n\n /**\n * Return all registered schema references\n *\n * @param ref\n * @return ISchemaRef[]\n */\n getSchemaRefs<T extends ISchemaRef>(filter?: (x: ISchemaRef) => boolean): (T | ISchemaRef)[] {\n throw new NotSupportedError('');\n }\n\n /**\n * Return schema references for an given entity or class reference\n *\n * @param ref\n * @return ISchemaRef[]\n */\n getSchemaRefsFor<T extends ISchemaRef>(ref: string): T | ISchemaRef;\n getSchemaRefsFor<T extends ISchemaRef>(ref: string | IEntityRef | IClassRef): T | ISchemaRef | (T | ISchemaRef)[] {\n throw new NotSupportedError('');\n }\n\n /**\n * TODO\n *\n * @param filter\n */\n getEntityRefs<T extends IEntityRef>(filter?: (x: IEntityRef) => boolean): (T | IEntityRef)[] {\n return this.filter(METATYPE_ENTITY, filter);\n }\n\n /**\n * Can get get entity ref for function.\n *\n * @param fn\n */\n getEntityRefFor<T extends IEntityRef>(fn: string | object | Function, skipNsCheck: boolean = true): (T | IEntityRef) {\n throw new NotSupportedError('');\n }\n\n\n /**\n * Returns the used instance of lookup registry handler\n */\n getLookupRegistry(): LookupRegistry {\n return LookupRegistry.$(this.namespace);\n }\n\n /**\n * Method for returning class ref\n *\n * @param object\n * @param type\n */\n getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef {\n throw new NotSupportedError('');\n }\n\n /**\n * Returns property by name for a given class or entity ref\n *\n * @param filter\n */\n getPropertyRef<T extends IPropertyRef>(ref: IClassRef | IEntityRef, name: string): (T | IPropertyRef) {\n return this.getPropertyRefs<T>(ref).find(x => snakeCase(x.name) === snakeCase(name));\n }\n\n\n /**\n * Returns all properties for given class or entity ref\n *\n * @param ref\n */\n getPropertyRefs<T extends IPropertyRef>(ref: IClassRef | IEntityRef): (T | IPropertyRef)[] {\n throw new NotSupportedError('');\n }\n\n\n getPropertyRefsFor<T extends IPropertyRef>(fn: string | object | Function): (T | IPropertyRef)[] {\n throw new NotSupportedError('');\n }\n\n\n list<X>(type: METADATA_TYPE, filter?: (x: any) => boolean): X[] {\n return this.filter(type, filter);\n }\n\n\n listEntities(filter?: (x: IEntityRef) => boolean): IEntityRef[] {\n return this.getEntityRefs(filter);\n }\n\n\n listProperties(filter?: (x: IPropertyRef) => boolean): IPropertyRef[] {\n return this.filter(METATYPE_PROPERTY, filter);\n }\n\n\n create<T>(context: string, options: any): T {\n throw new NotSupportedError('');\n }\n\n /**\n * TODO\n */\n add<T>(context: string, entry: T): T {\n return this.getLookupRegistry().add(context, entry);\n }\n\n\n /**\n * TODO\n */\n filter<T>(context: string, search: any): T[] {\n return this.getLookupRegistry().filter(context, search);\n }\n\n /**\n * TODO\n */\n find<T>(context: string, search: any): T {\n return this.getLookupRegistry().find(context, search);\n }\n\n /**\n * TODO\n */\n remove<T>(context: string, search: any): T[] {\n return this.getLookupRegistry().remove(context, search);\n }\n\n /**\n * reset current registry\n */\n reset() {\n this.clear();\n }\n\n clear() {\n LookupRegistry.reset(this.namespace);\n }\n\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { METADATA_AND_BIND_TYPE } from '../Constants';
|
|
2
|
+
export declare class Binding {
|
|
3
|
+
bindingType: METADATA_AND_BIND_TYPE;
|
|
4
|
+
sourceType: METADATA_AND_BIND_TYPE;
|
|
5
|
+
source: any;
|
|
6
|
+
targetType: METADATA_AND_BIND_TYPE;
|
|
7
|
+
target: any;
|
|
8
|
+
static create(sType: METADATA_AND_BIND_TYPE, sName: any, tType: METADATA_AND_BIND_TYPE, tName: any): Binding;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Binding = void 0;
|
|
4
|
+
class Binding {
|
|
5
|
+
static create(sType, sName, tType, tName) {
|
|
6
|
+
let b = new Binding();
|
|
7
|
+
b.bindingType = [sType, tType].join('_');
|
|
8
|
+
b.sourceType = sType;
|
|
9
|
+
b.targetType = tType;
|
|
10
|
+
b.source = sName;
|
|
11
|
+
b.target = tName;
|
|
12
|
+
return b;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Binding = Binding;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/registry/Binding.ts"],"names":[],"mappings":";;;AAEA,MAAa,OAAO;IAUlB,MAAM,CAAC,MAAM,CAAC,KAA6B,EAAE,KAAU,EAAE,KAA6B,EAAE,KAAU;QAChG,IAAI,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC,WAAW,GAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjE,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;QACrB,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;QACrB,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAnBD,0BAmBC","file":"Binding.js","sourcesContent":["import {METADATA_AND_BIND_TYPE} from '../Constants';\n\nexport class Binding {\n\n bindingType: METADATA_AND_BIND_TYPE;\n\n sourceType: METADATA_AND_BIND_TYPE;\n source: any;\n\n targetType: METADATA_AND_BIND_TYPE;\n target: any;\n\n static create(sType: METADATA_AND_BIND_TYPE, sName: any, tType: METADATA_AND_BIND_TYPE, tName: any) {\n let b = new Binding();\n b.bindingType = <METADATA_AND_BIND_TYPE>[sType, tType].join('_');\n b.sourceType = sType;\n b.targetType = tType;\n b.source = sName;\n b.target = tName;\n return b;\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IEntityRef } from '../../api/IEntityRef';
|
|
2
|
+
import { AbstractRef } from '../AbstractRef';
|
|
3
|
+
import { IBuildOptions } from '../../api/IBuildOptions';
|
|
4
|
+
import { IPropertyRef } from '../../api/IPropertyRef';
|
|
5
|
+
import { METADATA_TYPE } from '../Constants';
|
|
6
|
+
import { IEntityOptions } from '../options/IEntityOptions';
|
|
7
|
+
import { IClassRef } from '../../api/IClassRef';
|
|
8
|
+
import { ILookupRegistry } from '../../api/ILookupRegistry';
|
|
9
|
+
import { SchemaRef } from '../SchemaRef';
|
|
10
|
+
export declare class DefaultEntityRef extends AbstractRef implements IEntityRef {
|
|
11
|
+
constructor(options?: IEntityOptions);
|
|
12
|
+
getSchemaRefs(): SchemaRef | SchemaRef[];
|
|
13
|
+
getRegistry(): ILookupRegistry;
|
|
14
|
+
build<T>(instance: any, options?: IBuildOptions): T;
|
|
15
|
+
create<T>(): T;
|
|
16
|
+
getPropertyRef(name: string): IPropertyRef;
|
|
17
|
+
getPropertyRefs(): IPropertyRef[];
|
|
18
|
+
id(): string;
|
|
19
|
+
getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef;
|
|
20
|
+
/**
|
|
21
|
+
* Check if an object / instance is of same type like this entity ref (same check as IClassRef.isOf).
|
|
22
|
+
*
|
|
23
|
+
* @param instance
|
|
24
|
+
*/
|
|
25
|
+
isOf(instance: any): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Return machine compatible name for the entity in snake-case style.
|
|
28
|
+
*/
|
|
29
|
+
get storingName(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultEntityRef = void 0;
|
|
4
|
+
const AbstractRef_1 = require("../AbstractRef");
|
|
5
|
+
const Constants_1 = require("../Constants");
|
|
6
|
+
const AnnotationsHelper_1 = require("../AnnotationsHelper");
|
|
7
|
+
const RegistryFactory_1 = require("./RegistryFactory");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
class DefaultEntityRef extends AbstractRef_1.AbstractRef {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super(Constants_1.METATYPE_ENTITY, options.name, options.target, options.namespace ? options.namespace : Constants_1.DEFAULT_NAMESPACE);
|
|
12
|
+
AnnotationsHelper_1.AnnotationsHelper.merge(this.object, options);
|
|
13
|
+
this.setOptions(options);
|
|
14
|
+
}
|
|
15
|
+
getSchemaRefs() {
|
|
16
|
+
return this.getRegistry().getSchemaRefsFor(this);
|
|
17
|
+
}
|
|
18
|
+
getRegistry() {
|
|
19
|
+
return RegistryFactory_1.RegistryFactory.get(this.namespace);
|
|
20
|
+
}
|
|
21
|
+
build(instance, options) {
|
|
22
|
+
return this.getClassRef().build(instance, options);
|
|
23
|
+
}
|
|
24
|
+
create() {
|
|
25
|
+
return this.getClassRef().create();
|
|
26
|
+
}
|
|
27
|
+
getPropertyRef(name) {
|
|
28
|
+
return this.getRegistry().getPropertyRef(this, name);
|
|
29
|
+
}
|
|
30
|
+
getPropertyRefs() {
|
|
31
|
+
return this.getRegistry().getPropertyRefs(this);
|
|
32
|
+
}
|
|
33
|
+
id() {
|
|
34
|
+
return [Constants_1.METATYPE_ENTITY, this.getClassRef().id()].join(Constants_1.XS_ID_SEPARATOR);
|
|
35
|
+
}
|
|
36
|
+
getClassRefFor(object, type) {
|
|
37
|
+
return this.getRegistry().getClassRefFor(object, this.metaType);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if an object / instance is of same type like this entity ref (same check as IClassRef.isOf).
|
|
41
|
+
*
|
|
42
|
+
* @param instance
|
|
43
|
+
*/
|
|
44
|
+
isOf(instance) {
|
|
45
|
+
return this.getClassRef().isOf(instance);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Return machine compatible name for the entity in snake-case style.
|
|
49
|
+
*/
|
|
50
|
+
get storingName() {
|
|
51
|
+
let name = this.getOptions('name');
|
|
52
|
+
if (!name) {
|
|
53
|
+
name = this.name;
|
|
54
|
+
}
|
|
55
|
+
return lodash_1.snakeCase(name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.DefaultEntityRef = DefaultEntityRef;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=DefaultEntityRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/registry/DefaultEntityRef.ts"],"names":[],"mappings":";;;AACA,gDAA2C;AAG3C,4CAAgG;AAGhG,4DAAuD;AAEvD,uDAAkD;AAClD,mCAAiC;AAGjC,MAAa,gBAAiB,SAAQ,yBAAW;IAG/C,YAAY,UAA0B,EAAE;QACtC,KAAK,CAAC,2BAAe,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,6BAAiB,CAAC,CAAC;QAChH,qCAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAGD,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAQ,CAAC;IAC1D,CAAC;IAED,WAAW;QACT,OAAO,iCAAe,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAI,QAAa,EAAE,OAAuB;QAC7C,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,EAAE;QACA,OAAO,CAAC,2BAAe,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,2BAAe,CAAC,CAAC;IAC1E,CAAC;IAED,cAAc,CAAC,MAAqC,EAAE,IAAmB;QACvE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,QAAa;QAChB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SAClB;QACD,OAAO,kBAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CAGF;AA/DD,4CA+DC","file":"DefaultEntityRef.js","sourcesContent":["import {IEntityRef} from '../../api/IEntityRef';\nimport {AbstractRef} from '../AbstractRef';\nimport {IBuildOptions} from '../../api/IBuildOptions';\nimport {IPropertyRef} from '../../api/IPropertyRef';\nimport {DEFAULT_NAMESPACE, METADATA_TYPE, METATYPE_ENTITY, XS_ID_SEPARATOR} from '../Constants';\nimport {IEntityOptions} from '../options/IEntityOptions';\nimport {IClassRef} from '../../api/IClassRef';\nimport {AnnotationsHelper} from '../AnnotationsHelper';\nimport {ILookupRegistry} from '../../api/ILookupRegistry';\nimport {RegistryFactory} from './RegistryFactory';\nimport {snakeCase} from 'lodash';\nimport {SchemaRef} from '../SchemaRef';\n\nexport class DefaultEntityRef extends AbstractRef implements IEntityRef {\n\n\n constructor(options: IEntityOptions = {}) {\n super(METATYPE_ENTITY, options.name, options.target, options.namespace ? options.namespace : DEFAULT_NAMESPACE);\n AnnotationsHelper.merge(this.object, options);\n this.setOptions(options);\n }\n\n\n getSchemaRefs(): SchemaRef | SchemaRef[] {\n return this.getRegistry().getSchemaRefsFor(this) as any;\n }\n\n getRegistry(): ILookupRegistry {\n return RegistryFactory.get(this.namespace);\n }\n\n build<T>(instance: any, options?: IBuildOptions): T {\n return this.getClassRef().build(instance, options);\n }\n\n create<T>(): T {\n return this.getClassRef().create();\n }\n\n getPropertyRef(name: string): IPropertyRef {\n return this.getRegistry().getPropertyRef(this, name);\n }\n\n getPropertyRefs(): IPropertyRef[] {\n return this.getRegistry().getPropertyRefs(this);\n }\n\n id(): string {\n return [METATYPE_ENTITY, this.getClassRef().id()].join(XS_ID_SEPARATOR);\n }\n\n getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef {\n return this.getRegistry().getClassRefFor(object, this.metaType);\n }\n\n /**\n * Check if an object / instance is of same type like this entity ref (same check as IClassRef.isOf).\n *\n * @param instance\n */\n isOf(instance: any): boolean {\n return this.getClassRef().isOf(instance);\n }\n\n /**\n * Return machine compatible name for the entity in snake-case style.\n */\n get storingName() {\n let name = this.getOptions('name');\n if (!name) {\n name = this.name;\n }\n return snakeCase(name);\n }\n\n\n}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { METADATA_TYPE } from './../Constants';
|
|
2
|
+
import { IPropertyOptions } from './../options/IPropertyOptions';
|
|
3
|
+
import { IEntityRef } from '../../api/IEntityRef';
|
|
4
|
+
import { IClassRef } from '../../api/IClassRef';
|
|
5
|
+
import { DefaultPropertyRef } from './DefaultPropertyRef';
|
|
6
|
+
import { IEntityOptions } from '../options/IEntityOptions';
|
|
7
|
+
import { DefaultEntityRef } from './DefaultEntityRef';
|
|
8
|
+
import { ISchemaOptions } from '../options/ISchemaOptions';
|
|
9
|
+
import { IObjectOptions } from '../options/IObjectOptions';
|
|
10
|
+
import { ISchemaRef } from '../../api/ISchemaRef';
|
|
11
|
+
import { SchemaRef } from '../SchemaRef';
|
|
12
|
+
import { AbstractRegistry } from './AbstractRegistry';
|
|
13
|
+
import { IAbstractOptions } from '../options/IAbstractOptions';
|
|
14
|
+
/**
|
|
15
|
+
* Registry which handles by default class, schema, embeddalbes and properties, which are not handled by a specialized registry.
|
|
16
|
+
*
|
|
17
|
+
* This is a space for entities and their relations, which are grouped by a give "namespace" context.
|
|
18
|
+
*
|
|
19
|
+
* How entities are passed to the registry:
|
|
20
|
+
*
|
|
21
|
+
* 1. by annotations at startup (event from metadata registry)
|
|
22
|
+
* - properties are appended first by annotation then entities follow
|
|
23
|
+
* 2. by call for getEntityRefFor
|
|
24
|
+
* 3. append during runtime by event fired through metadata registry
|
|
25
|
+
* 4. append through reload method
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export declare class DefaultNamespacedRegistry extends AbstractRegistry {
|
|
29
|
+
/**
|
|
30
|
+
* Initialize events for metadata changes on runtime
|
|
31
|
+
*/
|
|
32
|
+
prepare(): void;
|
|
33
|
+
drainAlreadyAdded(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if object has the correct namespace for this registry handle
|
|
36
|
+
*
|
|
37
|
+
* @param options
|
|
38
|
+
*/
|
|
39
|
+
validNamespace(options: IAbstractOptions): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* react on dynamically added context
|
|
42
|
+
*
|
|
43
|
+
* @param context
|
|
44
|
+
* @param entries
|
|
45
|
+
*/
|
|
46
|
+
onAdd(context: METADATA_TYPE, options: IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions): void;
|
|
47
|
+
addSchemaToEntityRef(schemaRef: string | ISchemaRef, entityRef: IEntityRef, options?: {
|
|
48
|
+
override?: boolean;
|
|
49
|
+
onlyDefault?: boolean;
|
|
50
|
+
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* react on dynamically removed context
|
|
53
|
+
*
|
|
54
|
+
* @param context
|
|
55
|
+
* @param entries
|
|
56
|
+
*/
|
|
57
|
+
onRemove(context: METADATA_TYPE, entries: (IEntityOptions | IPropertyOptions | ISchemaOptions | IObjectOptions)[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* react on dynamically update context
|
|
60
|
+
*
|
|
61
|
+
* @param context
|
|
62
|
+
* @param entries
|
|
63
|
+
*/
|
|
64
|
+
onUpdate(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Return all registered schema references
|
|
67
|
+
*
|
|
68
|
+
* @param ref
|
|
69
|
+
* @return ISchemaRef[]
|
|
70
|
+
*/
|
|
71
|
+
getSchemaRefs(filter?: (x: ISchemaRef) => boolean): SchemaRef[];
|
|
72
|
+
/**
|
|
73
|
+
* Return schema references for an given entity or class reference
|
|
74
|
+
*
|
|
75
|
+
* @param ref
|
|
76
|
+
* @return ISchemaRef[]
|
|
77
|
+
*/
|
|
78
|
+
getSchemaRefsFor(ref: string): SchemaRef;
|
|
79
|
+
/**
|
|
80
|
+
* TODO
|
|
81
|
+
*
|
|
82
|
+
* @param filter
|
|
83
|
+
*/
|
|
84
|
+
getEntities(filter?: (x: IEntityRef) => boolean): IEntityRef[];
|
|
85
|
+
/**
|
|
86
|
+
* Can get get entity ref for function.
|
|
87
|
+
*
|
|
88
|
+
* @param fn
|
|
89
|
+
*/
|
|
90
|
+
getEntityRefFor(fn: string | object | Function, skipNsCheck?: boolean): DefaultEntityRef;
|
|
91
|
+
/**
|
|
92
|
+
* Returns property by name for a given class or entity ref
|
|
93
|
+
*
|
|
94
|
+
* @param filter
|
|
95
|
+
*/
|
|
96
|
+
getPropertyRef(ref: IClassRef | IEntityRef, name: string): DefaultPropertyRef;
|
|
97
|
+
/**
|
|
98
|
+
* Returns all properties for given class or entity ref
|
|
99
|
+
*
|
|
100
|
+
* @param ref
|
|
101
|
+
*/
|
|
102
|
+
getPropertyRefs(ref: IClassRef | IEntityRef): DefaultPropertyRef[];
|
|
103
|
+
/**
|
|
104
|
+
* Create properties for class or entity ref.
|
|
105
|
+
*/
|
|
106
|
+
createPropertiesForRef(clsRef: IClassRef): DefaultPropertyRef[];
|
|
107
|
+
/**
|
|
108
|
+
* Create default property reference
|
|
109
|
+
*
|
|
110
|
+
* @param options
|
|
111
|
+
*/
|
|
112
|
+
createPropertyForOptions(options: IPropertyOptions): DefaultPropertyRef;
|
|
113
|
+
/**
|
|
114
|
+
* Create default entity reference
|
|
115
|
+
*
|
|
116
|
+
* @param options
|
|
117
|
+
*/
|
|
118
|
+
createEntityForOptions(options: IEntityOptions): DefaultEntityRef;
|
|
119
|
+
/**
|
|
120
|
+
* Create default entity reference
|
|
121
|
+
*
|
|
122
|
+
* @param options
|
|
123
|
+
*/
|
|
124
|
+
createEmbeddableForOptions(options: IObjectOptions): IClassRef;
|
|
125
|
+
/**
|
|
126
|
+
* Create default schema reference
|
|
127
|
+
*
|
|
128
|
+
* @param options
|
|
129
|
+
*/
|
|
130
|
+
createSchemaForOptions(options: ISchemaOptions): SchemaRef;
|
|
131
|
+
/**
|
|
132
|
+
* Return metadata collected in the MetadataRegistry through annotation or explizit attached data.
|
|
133
|
+
*
|
|
134
|
+
* @param context
|
|
135
|
+
* @param target
|
|
136
|
+
* @return IAbstractOptions
|
|
137
|
+
*/
|
|
138
|
+
getMetadata(context: METADATA_TYPE, target: Function | string, propertyName?: string): IAbstractOptions;
|
|
139
|
+
getPropertyRefsFor(fn: string | object | Function): DefaultPropertyRef[];
|
|
140
|
+
create<T>(context: string, options: IAbstractOptions): T;
|
|
141
|
+
/**
|
|
142
|
+
* TODO
|
|
143
|
+
*/
|
|
144
|
+
add<T>(context: string, entry: T): T;
|
|
145
|
+
/**
|
|
146
|
+
* Create default entity reference
|
|
147
|
+
*
|
|
148
|
+
* @param options
|
|
149
|
+
*/
|
|
150
|
+
addClassRef(ref: IClassRef): IClassRef;
|
|
151
|
+
getClassRefFor(object: string | Function | IClassRef, type: METADATA_TYPE): IClassRef;
|
|
152
|
+
reset(): void;
|
|
153
|
+
}
|