@allgemein/schema-api 1.5.29 → 1.5.31
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/browser.d.ts +5 -5
- package/browser.js +23 -32
- package/browser.js.map +1 -1
- package/lib/DataContainer.js +1 -1
- package/lib/DataContainer.js.map +1 -1
- package/lib/LookupRegistry.js +6 -6
- package/lib/LookupRegistry.js.map +1 -1
- package/lib/json-schema/JsonSchema7Unserializer.js +13 -11
- package/lib/json-schema/JsonSchema7Unserializer.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { IBaseRef } from './api/IBaseRef';
|
|
2
2
|
export { IBuildOptions } from './api/IBuildOptions';
|
|
3
|
-
export { IClassRef } from './api/IClassRef';
|
|
4
|
-
export { IEntityRef } from './api/IEntityRef';
|
|
5
|
-
export { ILookupRegistry } from './api/ILookupRegistry';
|
|
3
|
+
export { IClassRef, isClassRef } from './api/IClassRef';
|
|
4
|
+
export { IEntityRef, isEntityRef } from './api/IEntityRef';
|
|
5
|
+
export { ILookupRegistry, isLookupRegistry } from './api/ILookupRegistry';
|
|
6
6
|
export { IPropertyExtentions } from './api/IPropertyExtentions';
|
|
7
|
-
export { IPropertyRef } from './api/IPropertyRef';
|
|
7
|
+
export { IPropertyRef, isPropertyRef } from './api/IPropertyRef';
|
|
8
8
|
export { ISchemaRef } from './api/ISchemaRef';
|
|
9
9
|
export { IJsonSchema, supportsJsonSchemaExport, supportsJsonSchema, supportsJsonSchemaImport } from './api/IJsonSchema';
|
|
10
10
|
export { Entity } from './decorators/Entity';
|
|
@@ -26,7 +26,7 @@ export { AbstractRef } from './lib/AbstractRef';
|
|
|
26
26
|
export { AbstractRegistry } from './lib/registry/AbstractRegistry';
|
|
27
27
|
export { AnnotationsHelper } from './lib/AnnotationsHelper';
|
|
28
28
|
export { ClassRef } from './lib/ClassRef';
|
|
29
|
-
export
|
|
29
|
+
export * from './lib/Constants';
|
|
30
30
|
export { DataContainer } from './lib/DataContainer';
|
|
31
31
|
export { DRAFT_07 } from './lib/json-schema/Constants';
|
|
32
32
|
export { IJsonSchemaSerializeOptions } from './lib/json-schema/IJsonSchemaSerializeOptions';
|
package/browser.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.getClassName =
|
|
13
|
+
exports.Validator = exports.DefaultValidator = exports.SchemaUtils = exports.SchemaRef = exports.Binding = exports.RegistryFactory = exports.MetadataRegistry = exports.DefaultPropertyRef = exports.DefaultNamespacedRegistry = exports.DefaultEntityRef = exports.LookupRegistry = exports.JsonSchema7Unserializer = exports.JsonSchema7Serializer = exports.JSON_SCHEMA_7_TYPES = exports.hasClassPropertiesInDefinition = exports.hasClassInDefinition = exports.JsonSchema = exports.DRAFT_07 = exports.DataContainer = exports.ClassRef = exports.AnnotationsHelper = exports.AbstractRegistry = exports.AbstractRef = exports.IsNotEmpty = exports.MaxLength = exports.MinLength = exports.Required = exports.Regex = exports.MAIL_REGEX = exports.IsEmail = exports.IP6_REGEX = exports.Ip6 = exports.IP4_REGEX = exports.Ip4 = exports.HOSTNAME_RFC952_REGEX = exports.HOSTNAME_RFC1034_REGEX = exports.Hostname = exports.Namespace = exports.Schema = exports.PropertyOf = exports.Embeddable = exports.Property = exports.Entity = exports.supportsJsonSchemaImport = exports.supportsJsonSchema = exports.supportsJsonSchemaExport = exports.isPropertyRef = exports.isLookupRegistry = exports.isEntityRef = exports.isClassRef = void 0;
|
|
14
|
+
exports.getClassName = void 0;
|
|
15
|
+
var IClassRef_1 = require("./api/IClassRef");
|
|
16
|
+
Object.defineProperty(exports, "isClassRef", { enumerable: true, get: function () { return IClassRef_1.isClassRef; } });
|
|
17
|
+
var IEntityRef_1 = require("./api/IEntityRef");
|
|
18
|
+
Object.defineProperty(exports, "isEntityRef", { enumerable: true, get: function () { return IEntityRef_1.isEntityRef; } });
|
|
19
|
+
var ILookupRegistry_1 = require("./api/ILookupRegistry");
|
|
20
|
+
Object.defineProperty(exports, "isLookupRegistry", { enumerable: true, get: function () { return ILookupRegistry_1.isLookupRegistry; } });
|
|
21
|
+
var IPropertyRef_1 = require("./api/IPropertyRef");
|
|
22
|
+
Object.defineProperty(exports, "isPropertyRef", { enumerable: true, get: function () { return IPropertyRef_1.isPropertyRef; } });
|
|
5
23
|
var IJsonSchema_1 = require("./api/IJsonSchema");
|
|
6
24
|
Object.defineProperty(exports, "supportsJsonSchemaExport", { enumerable: true, get: function () { return IJsonSchema_1.supportsJsonSchemaExport; } });
|
|
7
25
|
Object.defineProperty(exports, "supportsJsonSchema", { enumerable: true, get: function () { return IJsonSchema_1.supportsJsonSchema; } });
|
|
@@ -49,38 +67,11 @@ var AnnotationsHelper_1 = require("./lib/AnnotationsHelper");
|
|
|
49
67
|
Object.defineProperty(exports, "AnnotationsHelper", { enumerable: true, get: function () { return AnnotationsHelper_1.AnnotationsHelper; } });
|
|
50
68
|
var ClassRef_1 = require("./lib/ClassRef");
|
|
51
69
|
Object.defineProperty(exports, "ClassRef", { enumerable: true, get: function () { return ClassRef_1.ClassRef; } });
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(exports, "METATYPE_SCHEMA", { enumerable: true, get: function () { return Constants_1.METATYPE_SCHEMA; } });
|
|
54
|
-
Object.defineProperty(exports, "METATYPE_ENTITY", { enumerable: true, get: function () { return Constants_1.METATYPE_ENTITY; } });
|
|
55
|
-
Object.defineProperty(exports, "METATYPE_PROPERTY", { enumerable: true, get: function () { return Constants_1.METATYPE_PROPERTY; } });
|
|
56
|
-
Object.defineProperty(exports, "METATYPE_CLASS_REF", { enumerable: true, get: function () { return Constants_1.METATYPE_CLASS_REF; } });
|
|
57
|
-
Object.defineProperty(exports, "METATYPE_NAMESPACE", { enumerable: true, get: function () { return Constants_1.METATYPE_NAMESPACE; } });
|
|
58
|
-
Object.defineProperty(exports, "DEFAULT_NAMESPACE", { enumerable: true, get: function () { return Constants_1.DEFAULT_NAMESPACE; } });
|
|
59
|
-
Object.defineProperty(exports, "XS_ANNOTATION_OPTIONS_CACHE", { enumerable: true, get: function () { return Constants_1.XS_ANNOTATION_OPTIONS_CACHE; } });
|
|
60
|
-
Object.defineProperty(exports, "__CLASS__", { enumerable: true, get: function () { return Constants_1.__CLASS__; } });
|
|
61
|
-
Object.defineProperty(exports, "__NS__", { enumerable: true, get: function () { return Constants_1.__NS__; } });
|
|
62
|
-
Object.defineProperty(exports, "C_EVENT_ADD", { enumerable: true, get: function () { return Constants_1.C_EVENT_ADD; } });
|
|
63
|
-
Object.defineProperty(exports, "C_EVENT_REMOVE", { enumerable: true, get: function () { return Constants_1.C_EVENT_REMOVE; } });
|
|
64
|
-
Object.defineProperty(exports, "C_EVENT_UPDATE", { enumerable: true, get: function () { return Constants_1.C_EVENT_UPDATE; } });
|
|
65
|
-
Object.defineProperty(exports, "C_PROP_NAME", { enumerable: true, get: function () { return Constants_1.C_PROP_NAME; } });
|
|
66
|
-
Object.defineProperty(exports, "GLOBAL_NAMESPACE", { enumerable: true, get: function () { return Constants_1.GLOBAL_NAMESPACE; } });
|
|
67
|
-
Object.defineProperty(exports, "JS_DATA_TYPES", { enumerable: true, get: function () { return Constants_1.JS_DATA_TYPES; } });
|
|
68
|
-
Object.defineProperty(exports, "JS_PRIMATIVE_TYPES", { enumerable: true, get: function () { return Constants_1.JS_PRIMATIVE_TYPES; } });
|
|
69
|
-
Object.defineProperty(exports, "METADATA_REGISTRY", { enumerable: true, get: function () { return Constants_1.METADATA_REGISTRY; } });
|
|
70
|
-
Object.defineProperty(exports, "METATYPE_EMBEDDABLE", { enumerable: true, get: function () { return Constants_1.METATYPE_EMBEDDABLE; } });
|
|
71
|
-
Object.defineProperty(exports, "OPT_CREAT_AND_COPY", { enumerable: true, get: function () { return Constants_1.OPT_CREAT_AND_COPY; } });
|
|
72
|
-
Object.defineProperty(exports, "REFLECT_DESIGN_TYPE", { enumerable: true, get: function () { return Constants_1.REFLECT_DESIGN_TYPE; } });
|
|
73
|
-
Object.defineProperty(exports, "STATE_KEY", { enumerable: true, get: function () { return Constants_1.STATE_KEY; } });
|
|
74
|
-
Object.defineProperty(exports, "T_STRING", { enumerable: true, get: function () { return Constants_1.T_STRING; } });
|
|
75
|
-
Object.defineProperty(exports, "XS_DEFAULT_CLASSES", { enumerable: true, get: function () { return Constants_1.XS_DEFAULT_CLASSES; } });
|
|
76
|
-
Object.defineProperty(exports, "XS_DEFAULT_SCHEMA", { enumerable: true, get: function () { return Constants_1.XS_DEFAULT_SCHEMA; } });
|
|
77
|
-
Object.defineProperty(exports, "XS_ID_SEPARATOR", { enumerable: true, get: function () { return Constants_1.XS_ID_SEPARATOR; } });
|
|
78
|
-
Object.defineProperty(exports, "BINDING_SCHEMA_ENTITY", { enumerable: true, get: function () { return Constants_1.BINDING_SCHEMA_ENTITY; } });
|
|
79
|
-
Object.defineProperty(exports, "BINDING_SCHEMA_CLASS_REF", { enumerable: true, get: function () { return Constants_1.BINDING_SCHEMA_CLASS_REF; } });
|
|
70
|
+
__exportStar(require("./lib/Constants"), exports);
|
|
80
71
|
var DataContainer_1 = require("./lib/DataContainer");
|
|
81
72
|
Object.defineProperty(exports, "DataContainer", { enumerable: true, get: function () { return DataContainer_1.DataContainer; } });
|
|
82
|
-
var
|
|
83
|
-
Object.defineProperty(exports, "DRAFT_07", { enumerable: true, get: function () { return
|
|
73
|
+
var Constants_1 = require("./lib/json-schema/Constants");
|
|
74
|
+
Object.defineProperty(exports, "DRAFT_07", { enumerable: true, get: function () { return Constants_1.DRAFT_07; } });
|
|
84
75
|
var JsonSchema_1 = require("./lib/json-schema/JsonSchema");
|
|
85
76
|
Object.defineProperty(exports, "JsonSchema", { enumerable: true, get: function () { return JsonSchema_1.JsonSchema; } });
|
|
86
77
|
var JsonSchema7_1 = require("./lib/json-schema/JsonSchema7");
|
package/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,6CAAsD;AAAnC,uGAAA,UAAU,OAAA;AAC7B,+CAAyD;AAArC,yGAAA,WAAW,OAAA;AAC/B,yDAAwE;AAA/C,mHAAA,gBAAgB,OAAA;AAEzC,mDAA+D;AAAzC,6GAAA,aAAa,OAAA;AAEnC,iDAK2B;AAHzB,uHAAA,wBAAwB,OAAA;AACxB,iHAAA,kBAAkB,OAAA;AAClB,uHAAA,wBAAwB,OAAA;AAG1B,8CAA2C;AAAnC,gGAAA,MAAM,OAAA;AACd,kDAA+C;AAAvC,oGAAA,QAAQ,OAAA;AAChB,sDAAmD;AAA3C,wGAAA,UAAU,OAAA;AAClB,sDAAmD;AAA3C,wGAAA,UAAU,OAAA;AAClB,8CAA2C;AAAnC,gGAAA,MAAM,OAAA;AACd,oDAAiD;AAAzC,sGAAA,SAAS,OAAA;AAEjB,2DAKwC;AAJtC,oGAAA,QAAQ,OAAA;AACR,kHAAA,sBAAsB,OAAA;AAEtB,iHAAA,qBAAqB,OAAA;AAGvB,iDAAsE;AAA9D,0FAAA,GAAG,OAAA;AAAE,gGAAA,SAAS,OAAA;AACtB,iDAAsE;AAA9D,0FAAA,GA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,wDAAwE;AAAhE,sGAAA,SAAS,OAAA;AACjB,6CAA6C;AAArC,yGAAA,YAAY,OAAA","file":"browser.js","sourcesContent":["export {IBaseRef} from './api/IBaseRef';\nexport {IBuildOptions} from './api/IBuildOptions';\nexport {IClassRef, isClassRef} from './api/IClassRef';\nexport {IEntityRef, isEntityRef} from './api/IEntityRef';\nexport {ILookupRegistry, isLookupRegistry} from './api/ILookupRegistry';\nexport {IPropertyExtentions} from './api/IPropertyExtentions';\nexport {IPropertyRef, isPropertyRef} from './api/IPropertyRef';\nexport {ISchemaRef} from './api/ISchemaRef';\nexport {\n IJsonSchema,\n supportsJsonSchemaExport,\n supportsJsonSchema,\n supportsJsonSchemaImport\n} from './api/IJsonSchema';\n\nexport {Entity} from './decorators/Entity';\nexport {Property} from './decorators/Property';\nexport {Embeddable} from './decorators/Embeddable';\nexport {PropertyOf} from './decorators/PropertyOf';\nexport {Schema} from './decorators/Schema';\nexport {Namespace} from './decorators/Namespace';\n\nexport {\n Hostname,\n HOSTNAME_RFC1034_REGEX,\n IHostnameOptions,\n HOSTNAME_RFC952_REGEX\n} from './decorators/validate/Hostname';\n\nexport {Ip4, IP4_REGEX, IIp4Options} from './decorators/validate/Ip4';\nexport {Ip6, IP6_REGEX, IIp6Options} from './decorators/validate/Ip6';\nexport {IsEmail, MAIL_REGEX, IIsEmailOptions} from './decorators/validate/IsEmail';\nexport {Regex, IRegexOptions} from './decorators/validate/Regex';\nexport {Required, IRequiredOptions} from './decorators/validate/Required';\nexport {MinLength, IMinLengthOptions} from './decorators/validate/MinLength';\nexport {MaxLength, IMaxLengthOptions} from './decorators/validate/MaxLength';\nexport {IsNotEmpty, IIsNotEmptyOptions} from './decorators/validate/IsNotEmpty';\n\nexport {AbstractRef} from './lib/AbstractRef';\nexport {AbstractRegistry} from './lib/registry/AbstractRegistry';\n\nexport {AnnotationsHelper} from './lib/AnnotationsHelper';\nexport {ClassRef} from './lib/ClassRef';\nexport * from './lib/Constants';\n\nexport {DataContainer} from './lib/DataContainer';\nexport {DRAFT_07} from './lib/json-schema/Constants';\nexport {IJsonSchemaSerializeOptions} from './lib/json-schema/IJsonSchemaSerializeOptions';\nexport {IJsonSchemaSerializer} from './lib/json-schema/IJsonSchemaSerializer';\nexport {IJsonSchemaUnserializeOptions} from './lib/json-schema/IJsonSchemaUnserializeOptions';\nexport {IJsonSchemaUnserializer} from './lib/json-schema/IJsonSchemaUnserializer';\nexport {IParseOptions} from './lib/json-schema/IParseOptions';\nexport {JsonSchema} from './lib/json-schema/JsonSchema';\n\nexport {\n IJsonSchema7,\n IJsonSchema7Definition,\n hasClassInDefinition,\n hasClassPropertiesInDefinition,\n IJsonSchema7TypeName,\n JSON_SCHEMA_7_TYPES\n} from './lib/json-schema/JsonSchema7';\n\nexport {JsonSchema7Serializer} from './lib/json-schema/JsonSchema7Serializer';\nexport {JsonSchema7Unserializer} from './lib/json-schema/JsonSchema7Unserializer';\nexport {LookupRegistry} from './lib/LookupRegistry';\nexport {INamedOptions} from './lib/options/INamedOptions';\nexport {IAbstractOptions} from './lib/options/IAbstractOptions';\nexport {IAttributeOptions} from './lib/options/IAttributeOptions';\nexport {IEntityOptions} from './lib/options/IEntityOptions';\nexport {IObjectOptions} from './lib/options/IObjectOptions';\nexport {IPropertyOptions} from './lib/options/IPropertyOptions';\nexport {ISchemaOptions} from './lib/options/ISchemaOptions';\n\nexport {DefaultEntityRef} from './lib/registry/DefaultEntityRef';\nexport {DefaultNamespacedRegistry} from './lib/registry/DefaultNamespacedRegistry';\nexport {DefaultPropertyRef} from './lib/registry/DefaultPropertyRef';\nexport {MetadataRegistry} from './lib/registry/MetadataRegistry';\nexport {RegistryFactory} from './lib/registry/RegistryFactory';\nexport {Binding} from './lib/registry/Binding';\nexport {SchemaRef} from './lib/SchemaRef';\nexport {SchemaUtils} from './lib/SchemaUtils';\nexport {DefaultValidator} from './lib/validation/DefaultValidator';\nexport {IValidateOptions} from './lib/validation/IValidateOptions';\nexport {IValidatorEntry} from './lib/validation/IValidatorEntry';\nexport {IValidationError} from './lib/validation/IValidationError';\nexport {IValidationMessage} from './lib/validation/IValidationMessage';\nexport {IValidationResult} from './lib/validation/IValidationResult';\nexport {IValidator} from './lib/validation/IValidator';\nexport {Validator, validate_function} from './lib/validation/Validator';\nexport {getClassName} from './lib/functions';\n"],"sourceRoot":"."}
|
package/lib/DataContainer.js
CHANGED
|
@@ -105,7 +105,7 @@ class DataContainer {
|
|
|
105
105
|
(0, lodash_1.keys)(this.validation).forEach(key => {
|
|
106
106
|
if (this.validation[key]) {
|
|
107
107
|
const valid = this.validation[key];
|
|
108
|
-
const found =
|
|
108
|
+
const found = this.errors.find(x => x.property === key);
|
|
109
109
|
valid.messages = [];
|
|
110
110
|
if (found) {
|
|
111
111
|
valid.valid = false;
|
package/lib/DataContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/DataContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/DataContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAmF;AAGnF,2CAAsC;AAOtC,sDAAiD;AACjD,yCAAoC;AACpC,0CAA2C;AAE3C;;GAEG;AACH,MAAa,aAAa;IAwBxB,YAAY,QAAW,EAAE,QAAmD;QAT5E,WAAM,GAAuB,EAAE,CAAC;QAEhC,eAAU,GAAuC,EAAE,CAAC;QAQlD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,GAAG,GAAG,IAAA,mBAAU,EAAmB,QAAS,CAAC,eAAe,CAAC,CAAC,CAAC;gBAChD,QAAS,CAAC,eAAe,CAAC,QAAe,CAAC,CAAC,CAAC,CAAC,QAAsB,CAAC;SACzF;aAAM;YACL,MAAM,KAAK,GAAG,iBAAU,CAAC,WAAW,CAAC,QAAe,CAAC,CAAC;YACtD,IAAI,CAAC,GAAG,GAAG,mBAAQ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,CAAC;YAEjC,IAAI,IAAA,kBAAS,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;gBACvC,IAAA,YAAG,EAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,YAAG,EAAM,IAAI,CAAC,QAAQ,EAAE,qBAAS,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAGD,WAAW;QACT,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;;AA7JH,sCA8JC;AA5JQ,kBAAI,GAAa;IACtB,aAAa;IACb,WAAW;IACX,oBAAoB;IACpB,QAAQ;CACT,CAAC","file":"DataContainer.js","sourcesContent":["import {get, has, isBoolean, isEmpty, isFunction, keys, remove, set} from 'lodash';\n\n\nimport {STATE_KEY} from './Constants';\nimport {IValidationError} from './validation/IValidationError';\nimport {IValidationResult} from './validation/IValidationResult';\nimport {ILookupRegistry} from '../api/ILookupRegistry';\nimport {IEntityRef} from '../api/IEntityRef';\nimport {IClassRef} from '../api/IClassRef';\nimport {IValidationMessage} from './validation/IValidationMessage';\nimport {Validator} from './validation/Validator';\nimport {ClassRef} from './ClassRef';\nimport {ClassUtils} from '@allgemein/base';\n\n/**\n * Container for validation of object\n */\nexport class DataContainer<T> {\n\n static keys: string[] = [\n 'isValidated',\n 'isSuccess',\n 'isSuccessValidated',\n 'errors'\n ];\n\n isValidated: boolean;\n\n isSuccess: boolean;\n\n isSuccessValidated: boolean;\n\n errors: IValidationError[] = [];\n\n validation: { [k: string]: IValidationResult } = {};\n\n instance: T;\n\n ref: IEntityRef | IClassRef;\n\n\n constructor(instance: T, registry?: ILookupRegistry | IEntityRef | IClassRef) {\n this.instance = instance;\n if (registry) {\n this.ref = isFunction((<ILookupRegistry>registry).getEntityRefFor) ?\n (<ILookupRegistry>registry).getEntityRefFor(instance as any) : registry as IEntityRef;\n } else {\n const clazz = ClassUtils.getFunction(instance as any);\n this.ref = ClassRef.get(clazz) as IClassRef;\n }\n if (!this.ref) {\n throw new Error('none definition found for instance ' + JSON.stringify(instance));\n }\n\n const properties = this.ref.getPropertyRefs();\n for (const property of properties) {\n this.validation[property.name] = {\n key: property.name,\n valid: false,\n checked: false,\n messages: []\n };\n }\n ;\n }\n\n\n addError(e: IValidationError) {\n if (!has(e, 'type')) {\n e.type = 'error';\n }\n this.errors.push(e);\n }\n\n\n hasErrors() {\n return this.errors.length > 0;\n }\n\n\n checked(str: string) {\n if (this.validation[str]) {\n return this.validation[str].checked;\n }\n return false;\n }\n\n\n value(str: string) {\n const wrap = {};\n Object.defineProperty(wrap, str, {\n get: () => {\n return this.instance[str];\n },\n set: (y: any) => {\n this.instance[str] = y;\n }\n });\n return wrap[str];\n }\n\n\n valid(str: string) {\n if (this.validation[str]) {\n return this.validation[str].valid;\n }\n return false;\n }\n\n\n messages(str: string): IValidationMessage[] {\n if (this.validation[str] && this.validation[str].messages) {\n return this.validation[str].messages;\n }\n return [];\n\n }\n\n\n async validate(): Promise<boolean> {\n this.isValidated = true;\n remove(this.errors, error => error.type === 'validate');\n let results: IValidationError[] = [];\n try {\n results = <IValidationError[]>await Validator.validate(this.instance as any, this.ref);\n } catch (e) {\n console.error(e);\n }\n\n results.map(r => this.errors.push({\n property: r.property,\n value: r.value,\n constraints: r.constraints,\n type: 'validate'\n }));\n this.isSuccessValidated = true;\n keys(this.validation).forEach(key => {\n if (this.validation[key]) {\n const valid = this.validation[key];\n const found = this.errors.find(x => x.property === key);\n valid.messages = [];\n if (found) {\n valid.valid = false;\n Object.keys(found.constraints).forEach(c => {\n valid.messages.push({type: c, content: found.constraints[c]});\n });\n } else {\n valid.valid = true;\n }\n this.isSuccessValidated = this.isSuccessValidated && valid.valid;\n valid.checked = true;\n }\n });\n\n return this.isSuccessValidated;\n }\n\n\n applyState() {\n const $state: any = {};\n DataContainer.keys.forEach(k => {\n const value = get(this, k, null);\n\n if (isBoolean(value) || !isEmpty(value)) {\n set($state, k, value);\n }\n });\n\n set(<any>this.instance, STATE_KEY, $state);\n }\n\n\n resetErrors() {\n this.errors = [];\n }\n}\n"],"sourceRoot":".."}
|
package/lib/LookupRegistry.js
CHANGED
|
@@ -46,25 +46,25 @@ class LookupRegistry {
|
|
|
46
46
|
if (!(0, lodash_1.has)(this._entries, context)) {
|
|
47
47
|
this._entries[context] = [];
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return this._entries[context].filter(search);
|
|
50
50
|
}
|
|
51
51
|
find(context, search) {
|
|
52
52
|
if (!(0, lodash_1.has)(this._entries, context)) {
|
|
53
53
|
this._entries[context] = [];
|
|
54
54
|
}
|
|
55
|
-
return
|
|
55
|
+
return this._entries[context].find(search);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* return lookup registry namespaces
|
|
59
59
|
*/
|
|
60
60
|
static getRegistryNamespaces() {
|
|
61
|
-
return
|
|
61
|
+
return Object.keys(this.$self);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* return lookup registries
|
|
65
65
|
*/
|
|
66
66
|
static getLookupRegistries() {
|
|
67
|
-
return
|
|
67
|
+
return Object.keys(this.$self).map(x => this.$self[x]);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* search in all registries
|
|
@@ -73,7 +73,7 @@ class LookupRegistry {
|
|
|
73
73
|
* @param search
|
|
74
74
|
*/
|
|
75
75
|
static find(context, search) {
|
|
76
|
-
const registryNames =
|
|
76
|
+
const registryNames = this.getRegistryNamespaces();
|
|
77
77
|
for (const registryName of registryNames) {
|
|
78
78
|
const found = this.$self[registryName].find(context, search);
|
|
79
79
|
if (found) {
|
|
@@ -90,7 +90,7 @@ class LookupRegistry {
|
|
|
90
90
|
*/
|
|
91
91
|
static filter(context, search) {
|
|
92
92
|
const results = [];
|
|
93
|
-
const namespaces =
|
|
93
|
+
const namespaces = Object.keys(this.$self);
|
|
94
94
|
for (const namespace of namespaces) {
|
|
95
95
|
const found = this.$self[namespace].filter(context, search);
|
|
96
96
|
if (!(0, lodash_1.isEmpty)(found)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/LookupRegistry.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/LookupRegistry.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAE5C,2CAA8C;AAE9C,MAAa,cAAc;IAQzB,YAAY,SAAiB;QAJrB,cAAS,GAAW,6BAAiB,CAAC;QAEtC,aAAQ,GAAiC,EAAE,CAAC;QAGlD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,YAAoB,6BAAiB;QAChD,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAC9B;IACH,CAAC;IAED,MAAM,CAAC,CAAC,CAAC,YAAoB,6BAAiB;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;YAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,cAAc,CAAC,SAAS,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;YAChC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAI,OAAe,EAAE,KAAQ;QAC9B,IAAI,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,Q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AAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAI,OAAe,EAAE,MAAW;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;YACxC,MAAM,KAAK,GAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAI,OAAe,EAAE,MAAW;QAC3C,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,MAAM,KAAK,GAAQ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACjE,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;gBACnB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;aACxB;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;;AAjHH,wCAoHC;AAlHgB,oBAAK,GAA4C,EAAE,CAAC","file":"LookupRegistry.js","sourcesContent":["import {has, isEmpty, remove} from 'lodash';\n\nimport {DEFAULT_NAMESPACE} from './Constants';\n\nexport class LookupRegistry {\n\n private static $self: { [namespace: string]: LookupRegistry } = {};\n\n private namespace: string = DEFAULT_NAMESPACE;\n\n private _entries: { [context: string]: any[] } = {};\n\n constructor(namespace: string) {\n this.namespace = namespace;\n }\n\n getNamespace(): string {\n return this.namespace;\n }\n\n static reset(namespace: string = DEFAULT_NAMESPACE): void {\n if (this.$self[namespace]) {\n delete this.$self[namespace];\n }\n }\n\n static $(namespace: string = DEFAULT_NAMESPACE): LookupRegistry {\n if (!this.$self[namespace]) {\n this.$self[namespace] = new LookupRegistry(namespace);\n }\n return this.$self[namespace];\n }\n\n list(context: string) {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context];\n }\n\n add<T>(context: string, entry: T): T {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n this._entries[context].push(entry);\n return entry;\n }\n\n remove<T>(context: string, search: any): T[] {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return remove<T>(this._entries[context], search);\n }\n\n filter<T>(context: string, search: any): T[] {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context].filter(search);\n }\n\n find<T>(context: string, search: any): T {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context].find(search);\n }\n\n\n /**\n * return lookup registry namespaces\n */\n static getRegistryNamespaces() {\n return Object.keys(this.$self);\n }\n\n /**\n * return lookup registries\n */\n static getLookupRegistries() {\n return Object.keys(this.$self).map(x => this.$self[x]);\n }\n\n /**\n * search in all registries\n *\n * @param context\n * @param search\n */\n static find<T>(context: string, search: any): T {\n const registryNames = this.getRegistryNamespaces();\n for (const registryName of registryNames) {\n const found = <T>this.$self[registryName].find(context, search);\n if (found) {\n return found;\n }\n }\n return null;\n }\n\n /**\n * filter over all registries\n *\n * @param context\n * @param search\n */\n static filter<T>(context: string, search: any): T[] {\n const results: T[] = [];\n const namespaces = Object.keys(this.$self);\n for (const namespace of namespaces) {\n const found = <T[]>this.$self[namespace].filter(context, search);\n if (!isEmpty(found)) {\n results.push(...found);\n }\n }\n return results;\n }\n\n\n}\n\n\n"],"sourceRoot":".."}
|
|
@@ -110,17 +110,19 @@ class JsonSchema7Unserializer {
|
|
|
110
110
|
if (data.type) {
|
|
111
111
|
if (data.type === Constants_2.T_OBJECT) {
|
|
112
112
|
ret = yield this.parseTypeObject(data, options);
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
if (ret) {
|
|
114
|
+
if (options.$ref) {
|
|
115
|
+
// finish reference if waiting
|
|
116
|
+
this.reference[options.$ref] = ret;
|
|
117
|
+
delete options.$ref;
|
|
118
|
+
}
|
|
119
|
+
if (this.hasProperties(data)) {
|
|
120
|
+
yield this.parseProperties(ret, data.properties, options);
|
|
121
|
+
}
|
|
122
|
+
if (this.hasPatternProperties(data)) {
|
|
123
|
+
options.isPattern = true;
|
|
124
|
+
yield this.parseProperties(ret, data.patternProperties, options);
|
|
125
|
+
}
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/json-schema/JsonSchema7Unserializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAegB;AAIhB,2CAAqC;AAErC,6CAAwC;AACxC,iEAA4D;AAC5D,4CAUsB;AACtB,qDAA6D;AAE7D,0CAAqC;AACrC,0CAA0E;AAC1E,mEAA8D;AAC9D,mDAAkE;AAGlE,gDAA2C;AAG3C,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAEhH,MAAa,uBAAuB;IAgBlC,YAAY,IAAmC;QAd/C,YAAO,GAAW,oBAAQ,CAAC;QAM3B,cAAS,GAAgB,EAAE,CAAC;QAE5B,YAAO,GAAkC,EAAE,CAAC;QAE5C,cAAS,GAAyB,EAAE,CAAC;QAErC,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jectLike,\n isString,\n isUndefined,\n keys,\n upperFirst\n} from 'lodash';\nimport {IJsonSchema7, IJsonSchema7Definition} from './JsonSchema7';\nimport {IClassRef} from '../../api/IClassRef';\nimport {IJsonSchemaUnserializeOptions} from './IJsonSchemaUnserializeOptions';\nimport {DRAFT_07} from './Constants';\nimport {IJsonSchemaUnserializer} from './IJsonSchemaUnserializer';\nimport {JsonSchema} from './JsonSchema';\nimport {RegistryFactory} from '../registry/RegistryFactory';\nimport {\n DEFAULT_NAMESPACE,\n K_PATTERN_PROPERTY,\n METADATA_TYPE,\n METATYPE_CLASS_REF,\n METATYPE_ENTITY, METATYPE_NAMESPACE,\n METATYPE_PROPERTY,\n T_ARRAY,\n T_OBJECT,\n T_STRING\n} from '../Constants';\nimport {IEntityRef, isEntityRef} from '../../api/IEntityRef';\nimport {IEntityOptions} from '../options/IEntityOptions';\nimport {ClassRef} from '../ClassRef';\nimport {NotSupportedError, NotYetImplementedError} from '@allgemein/base';\nimport {MetadataRegistry} from '../registry/MetadataRegistry';\nimport {IParseOptions, PARSE_OPTIONS_KEYS} from './IParseOptions';\nimport {IPropertyOptions} from '../options/IPropertyOptions';\nimport {IAbstractOptions} from '../options/IAbstractOptions';\nimport {SchemaUtils} from '../SchemaUtils';\nimport {IPropertyRef} from '../../api/IPropertyRef';\n\nconst skipKeys = ['$id', 'id', 'title', 'type', 'properties', 'allOf', 'anyOf', '$schema', 'patternProperties'];\n\nexport class JsonSchema7Unserializer implements IJsonSchemaUnserializer {\n\n version: string = DRAFT_07;\n\n options: IJsonSchemaUnserializeOptions;\n\n data: IJsonSchema7;\n\n classRefs: IClassRef[] = [];\n\n fetched: { [k: string]: IJsonSchema7 } = {};\n\n reference: { [k: string]: any } = {};\n\n issues: { msg: string, level: 'error' | 'warning' | 'info' }[] = [];\n\n constructor(opts: IJsonSchemaUnserializeOptions) {\n this.options = opts;\n }\n\n uri(): string {\n return `http://json-schema.org/${DRAFT_07}/schema`;\n }\n\n\n async unserialize(data: any): Promise<IClassRef | IEntityRef | (IClassRef | IEntityRef)[]> {\n this.data = data;\n const isRoot = get(this.options, 'rootAsEntity', true);\n const opts: any = {isRoot: isRoot};\n PARSE_OPTIONS_KEYS.forEach(x => {\n if (has(this.options, x)) {\n opts[x] = this.options[x];\n }\n });\n\n const ret = this.options.return ? this.options.return : 'default';\n return this.parse(data, opts).then(refs => {\n switch (ret) {\n case 'class-refs':\n return this.classRefs;\n case 'entity-refs':\n return this.classRefs.filter(x => x.hasEntityRef()).map(x => x.getEntityRef());\n default:\n return refs;\n }\n });\n }\n\n /**\n * Return namespace if set in passed options or if used in json-schema object.\n * If no match return default namespace\n */\n getNamespace() {\n return get(this.options, 'namespace', get(this.data, 'namespace', DEFAULT_NAMESPACE));\n }\n\n /**\n * Get registry containing elements\n */\n getRegistry(ns: string = null) {\n return RegistryFactory.get(ns ? ns : this.getNamespace());\n }\n\n\n getIssues() {\n return this.issues;\n }\n\n /**\n * If collectors are defined use them before default\n *\n *\n * @param type\n * @param key\n * @param data\n * @param options\n * @private\n */\n private collectOptions(key: string, data: IJsonSchema7, options: IParseOptions = {}) {\n const type = get(options, 'metaType', METATYPE_ENTITY);\n let ret: any = null;\n if (!isUndefined(data[key]) || !isNull(data[key])) {\n ret = {};\n ret[key] = data[key];\n }\n\n if (has(this.options, 'collector') && this.options.collector.length > 0) {\n const methods = this.options.collector.filter(x => x.type === type && x.key === key);\n if (methods) {\n ret = assign(ret, ...methods.map(e => e.fn.apply(null, [key, data, options])));\n }\n }\n return ret;\n }\n\n\n getClassRef(className: string | Function, namespace?: string) {\n if (!namespace) {\n namespace = this.getNamespace();\n }\n return ClassRef.get(className, namespace);\n }\n\n\n async parse(data: IJsonSchema7, options: IParseOptions = null): Promise<IClassRef | IEntityRef | (IClassRef | IEntityRef)[]> {\n let ret: IClassRef | IEntityRef | (IClassRef | IEntityRef)[] = null;\n if (data.type) {\n\n if (data.type === T_OBJECT) {\n ret = await this.parseTypeObject(data, options);\n if (options.$ref) {\n // finish reference if waiting\n this.reference[options.$ref] = ret;\n delete options.$ref;\n }\n\n if (this.hasProperties(data)) {\n await this.parseProperties(ret, data.properties, options);\n }\n if (this.hasPatternProperties(data)) {\n options.isPattern = true;\n await this.parseProperties(ret, data.patternProperties, options);\n }\n } else {\n throw new Error('type is not supported at this place');\n }\n\n } else if (data.$ref) {\n return this.parseRef(data, options);\n } else if (data.anyOf && options.isRoot) {\n // loading multi schema\n ret = [];\n for (const anyEntry of data.anyOf) {\n ret.push(await this.parse(anyEntry as any, options) as (IClassRef | IEntityRef));\n }\n } else if (data.definitions && keys(data.definitions).length === 0) {\n // doing nothing no entries found\n } else {\n throw new Error('no valid schema element for further parse, key with name type or $ref must be present.');\n }\n return ret;\n }\n\n async parseRef(data: any, options: IParseOptions) {\n // refers\n let ret = null;\n if (has(this.reference, data.$ref)) {\n ret = this.reference[data.$ref];\n } else {\n const res = await this.followRef(data.$ref, this.data);\n const opts = clone(options);\n opts.$ref = data.$ref;\n if (!opts.className) {\n opts.className = this.getClassNameFromRef(data.$ref);\n }\n ret = await this.parse(res, opts);\n }\n return ret;\n }\n\n\n getDefinitionsKey(data: object) {\n for (const k of keys(data)) {\n if (k !== 'properties' && isObjectLike(data[k])) {\n const exists = keys(data[k]).find(x => has(data[k][x], 'type'));\n if (exists) {\n return k;\n }\n }\n }\n return 'definition';\n }\n\n\n async followRef($ref: string, data: IJsonSchema7): Promise<any> {\n let [addr, anchor] = $ref.split('#');\n\n if (!anchor) {\n anchor = '';\n }\n\n if (isEmpty(addr)) {\n // local\n if (isEmpty(anchor)) {\n if (data.$ref) {\n return this.followRef(data.$ref, data);\n } else {\n return data;\n }\n } else if (/^\\//.test(anchor)) {\n // starts with path\n const dottedPath = anchor.substr(1).replace(/\\//, '.');\n const entry = get(data, dottedPath, null);\n if (entry) {\n return entry;\n }\n } else {\n // refs to local id\n const refHashed = '#' + anchor;\n if (data.$id === refHashed) {\n return data;\n } else {\n const defKey = this.getDefinitionsKey(data);\n if (data[defKey]) {\n for (const k of keys(data[defKey])) {\n const x = data[defKey][k] as IJsonSchema7;\n if (x && x.$id && x.$id === refHashed) {\n return x;\n }\n }\n }\n }\n }\n } else {\n // remote fetch url\n if (!this.fetched[addr]) {\n this.fetched[addr] = await JsonSchema.request(addr, {cwd: this.options.cwd});\n }\n return this.followRef('#' + anchor, this.fetched[addr]);\n }\n // TODO create exception\n throw new Error($ref + ' not found');\n }\n\n\n async parseProperties(classRef: IClassRef | IEntityRef, properties: { [propertyName: string]: IJsonSchema7Definition }, options: IParseOptions = null) {\n const _classRef = isEntityRef(classRef) ? classRef.getClassRef() : classRef;\n const propertyNames = keys(properties);\n for (const propertyName of propertyNames) {\n await this.parseProperty(_classRef, propertyName, properties[propertyName], options);\n }\n }\n\n\n async parseProperty(classRef: IClassRef | IEntityRef, propertyName: string, data: IJsonSchema7Definition, options: IParseOptions = null) {\n const _classRef = isEntityRef(classRef) ? classRef.getClassRef() : classRef;\n\n const propRefExits = _classRef.getRegistry()\n .find(METATYPE_PROPERTY,\n (x: IPropertyRef) => x.getClassRef() === _classRef && x.name === propertyName) as IPropertyRef;\n\n const propOptions: IPropertyOptions = {\n metaType: METATYPE_PROPERTY,\n propertyName: propertyName,\n target: _classRef.getClass(true),\n // default type is object\n type: T_OBJECT,\n };\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n\n if (isObjectLike(data)) {\n const parseOptions: IParseOptions = {\n isProperty: true,\n sourceRef: _classRef,\n propertyName: propertyName,\n isRoot: false,\n metaType: 'property',\n // isPattern: options.isPattern ? true : false\n };\n const dataPointer = data as IJsonSchema7;\n let collectOptions = {};\n collectOptions = this.collectAndProcess(dataPointer, collectOptions, ['type', '$ref', '$schema', '$id'], parseOptions);\n assign(propOptions, collectOptions);\n if (dataPointer.$ref) {\n const ref = await this.parse(dataPointer, parseOptions);\n propOptions.type = ref;\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n } else if (dataPointer.type) {\n await this.onTypes(dataPointer, propOptions, parseOptions);\n }\n } else {\n // boolean\n throw new NotSupportedError('passed boolean value as definition not supported');\n }\n\n if (!propRefExits || get(this.options, 'forcePropertyRefCreation', false)) {\n // remove properties key if exists\n delete propOptions.properties;\n try {\n _classRef.getRegistry().create(METATYPE_PROPERTY, propOptions);\n } catch (e) {\n this.issues.push({msg: e.message, level: 'error'})\n }\n } else if (propRefExits) {\n propRefExits.setOptions(propOptions);\n }\n\n }\n\n\n hasProperties(datapointer: any) {\n return has(datapointer, 'properties');\n }\n\n hasPatternProperties(datapointer: any) {\n return has(datapointer, 'patternProperties');\n }\n\n async onTypes(dataPointer: IJsonSchema7, propOptions: IPropertyOptions, options: IParseOptions) {\n let type = dataPointer.type as string;\n if (isString(type)) {\n type = type.toLowerCase();\n }\n switch (type) {\n case T_STRING:\n const res = this.onTypeString(dataPointer);\n assign(propOptions, res);\n break;\n case 'boolean':\n propOptions.type = 'boolean';\n break;\n case 'integer':\n propOptions.type = 'number';\n break;\n case 'number':\n propOptions.type = 'number';\n break;\n case T_OBJECT:\n propOptions.type = T_OBJECT;\n if (this.hasProperties(dataPointer) || this.hasPatternProperties(dataPointer)) {\n propOptions.type = await this.parse(dataPointer, options);\n }\n break;\n case T_ARRAY:\n // check items\n if (dataPointer.minItems || dataPointer.maxItems) {\n propOptions.cardinality = {\n min: get(dataPointer, 'minItems', 0),\n max: get(dataPointer, 'maxItems', 0),\n };\n } else {\n propOptions.cardinality = 0;\n }\n\n if (dataPointer.items) {\n\n if (isArray(dataPointer.items)) {\n throw new NotSupportedError('tuple values for array is not supported');\n } else if (isObjectLike(dataPointer.items)) {\n options.asArray = true;\n const items = dataPointer.items as IJsonSchema7;\n if (items.$ref) {\n propOptions.type = await this.parse(items as IJsonSchema7, options);\n } else if (items.type === T_OBJECT) {\n propOptions.type = items.type;\n if (this.hasProperties(items) || this.hasPatternProperties(items)) {\n propOptions.type = await this.parse(items as IJsonSchema7, options);\n }\n } else {\n propOptions.type = items.type;\n }\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n }\n }\n break;\n case 'null':\n throw new NotSupportedError('null value is not supported for property');\n }\n }\n\n\n onTypeString(dataPointer: any) {\n const propOptions: any = {};\n propOptions.type = T_STRING;\n // or date check format\n if (dataPointer.format) {\n propOptions.format = dataPointer.format;\n switch (dataPointer.format) {\n case 'date-time':\n // set date type\n propOptions.type = 'date';\n break;\n case 'date':\n // set date type\n propOptions.type = 'date';\n break;\n }\n }\n return propOptions;\n }\n\n\n async parseInherits(classRef: IClassRef, data: IJsonSchema7, key: 'allOf' | 'anyOf') {\n if (has(data, key)) {\n const values = data[key];\n if (isArray(values)) {\n for (const inheritEntry of values) {\n const extend = await this.parse(inheritEntry as IJsonSchema7, {isRoot: false}) as IClassRef;\n classRef.addExtend(extend);\n }\n } else {\n throw new NotSupportedError('only array is allowed for ' + key);\n }\n }\n }\n\n\n async parseTypeObject(data: IJsonSchema7, options: IParseOptions = null) {\n let ret: IClassRef | IEntityRef = null;\n\n const id = get(data, '$id', get(data, 'id', null));\n let metaType: METADATA_TYPE = options.isRoot || !isEmpty(id) ? METATYPE_ENTITY : METATYPE_CLASS_REF;\n\n const title = get(data, 'title', null);\n\n // get namespace or override\n const namespace = !get(this.options, 'skipNamespace', false) ?\n get(data, '$' + METATYPE_NAMESPACE, this.getNamespace()) : this.getNamespace();\n\n // check if class ref exists else create one or recreate if parse options are set\n let classRef: IClassRef = null;\n let className = null;\n if (options) {\n if (options.className) {\n className = options.className;\n }\n if (options.ref) {\n classRef = options.ref;\n className = options.ref.name;\n }\n }\n\n // title data override passed className\n if (title) {\n if (!className || !get(this.options, 'ignoreDeclared', false)) {\n className = upperFirst(camelCase(title));\n }\n }\n\n let entityName = metaType === METATYPE_ENTITY && id ? id.replace(/^#/, '') : className;\n if (!className && options?.isProperty && options.propertyName) {\n if (get(this.options, 'prependClass', false)) {\n className = [options.sourceRef.name, options.propertyName].map(x => upperFirst(camelCase(x))).join('');\n } else {\n className = upperFirst(camelCase(options.propertyName));\n }\n // pass property name as entity name if the object is declared as a property\n entityName = className;\n }\n\n if (className && !classRef) {\n const fn = get(this.options, 'forceClassRefCreation', false) ? SchemaUtils.clazz(className) : className;\n classRef = this.getClassRef(fn, namespace);\n }\n\n if (!classRef) {\n metaType = METATYPE_CLASS_REF;\n classRef = this.getClassRef(SchemaUtils.clazzAnonymous(), namespace);\n }\n\n // TODO check extentions!\n for (const inheritsKey of ['allOf', 'anyOf']) {\n if (has(data, inheritsKey)) {\n await this.parseInherits(classRef, data, inheritsKey as any);\n }\n }\n\n if (classRef) {\n // a named class ref exists\n if (!this.classRefs.find(x => x === classRef)) {\n this.classRefs.push(classRef);\n }\n\n const clazz = classRef.getClass(true);\n const refOptions: IEntityOptions = {\n name: entityName,\n namespace: this.getNamespace(),\n target: clazz\n };\n\n const collectorOptions = clone(options);\n collectorOptions.metaType = metaType;\n collectorOptions.ref = classRef;\n this.collectAndProcess(data, refOptions, skipKeys, collectorOptions);\n\n metaType = collectorOptions.metaType;\n\n let entityOptions = MetadataRegistry.$().find(metaType, (x: IAbstractOptions) => x.target === clazz);\n if (entityOptions) {\n // merge existing\n assign(entityOptions, refOptions);\n } else {\n entityOptions = refOptions;\n refOptions.metaType = METATYPE_CLASS_REF;\n const existingOptions = classRef.getOptions();\n classRef.setOptions(defaults(refOptions, existingOptions));\n }\n\n if (metaType === METATYPE_ENTITY) {\n ret = this.getRegistry(namespace).find(metaType, (x: IEntityRef) => x.getClassRef() === classRef);\n if (!ret || get(this.options, 'forceEntityRefCreation', false)) {\n try {\n ret = this.getRegistry(namespace).create(metaType, entityOptions);\n } catch (e) {\n this.issues.push({msg: e.message, level: 'error'})\n }\n }\n } else {\n ret = classRef;\n }\n\n } else {\n throw new NotYetImplementedError();\n }\n return ret;\n }\n\n\n collectAndProcess(data: IJsonSchema7,\n collectingObject: any,\n skipKeys: string[],\n collectorOptions: IParseOptions) {\n const type = get(collectorOptions, 'metaType', METATYPE_ENTITY);\n const _keys = keys(data);\n for (const key of _keys) {\n const entry = this.collectOptions(key, data, collectorOptions);\n if (skipKeys.includes(key)) {\n continue;\n }\n if (entry && isObjectLike(entry)) {\n collectingObject = assign(collectingObject, entry);\n }\n }\n if (has(this.options, 'collector') && this.options.collector.length > 0) {\n const methods = this.options.collector.filter(x => x.type === type && isUndefined(x.key));\n if (methods.length > 0) {\n collectingObject = assign(collectingObject, ...methods.map(e => e.fn.apply(null, [null, data, collectorOptions])));\n }\n }\n return collectingObject;\n }\n\n getClassNameFromRef(data: string) {\n return data.split(/#|\\//).pop();\n }\n\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/json-schema/JsonSchema7Unserializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAegB;AAIhB,2CAAqC;AAErC,6CAAwC;AACxC,iEAA4D;AAC5D,4CAUsB;AACtB,qDAA6D;AAE7D,0CAAqC;AACrC,0CAA0E;AAC1E,mEAA8D;AAC9D,mDAAkE;AAGlE,gDAA2C;AAG3C,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAEhH,MAAa,uBAAuB;IAgBlC,YAAY,IAAmC;QAd/C,YAAO,GAAW,oBAAQ,CAAC;QAM3B,cAAS,GAAgB,EAAE,CAAC;QAE5B,YAAO,GAAkC,EAAE,CAAC;QAE5C,cAAS,GAAyB,EAAE,CAAC;QAErC,WAAM,GAA2D,EAAE,CAAC;QAGlE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,GAAG;QACD,OAAO,0BAA0B,oBAAQ,SAAS,CAAC;IACrD,CAAC;IAGK,WAAW,CAAC,IAAS;;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,MAAM,MAAM,GAAG,IAAA,YAAG,EAAC,IAAI,CAAC,OAAO,E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BAAY,EAAC,KAAK,CAAC,EAAE;gBAChC,gBAAgB,GAAG,IAAA,eAAM,EAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;aACpD;SACF;QACD,IAAI,IAAA,YAAG,EAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACvE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,IAAA,oBAAW,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1F,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACtB,gBAAgB,GAAG,IAAA,eAAM,EAAC,gBAAgB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;aACpH;SACF;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,mBAAmB,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CAEF;AAhiBD,0DAgiBC","file":"JsonSchema7Unserializer.js","sourcesContent":["import {\n assign,\n camelCase,\n clone,\n defaults,\n get,\n has,\n isArray,\n isEmpty,\n isNull,\n isObjectLike,\n isString,\n isUndefined,\n keys,\n upperFirst\n} from 'lodash';\nimport {IJsonSchema7, IJsonSchema7Definition} from './JsonSchema7';\nimport {IClassRef} from '../../api/IClassRef';\nimport {IJsonSchemaUnserializeOptions} from './IJsonSchemaUnserializeOptions';\nimport {DRAFT_07} from './Constants';\nimport {IJsonSchemaUnserializer} from './IJsonSchemaUnserializer';\nimport {JsonSchema} from './JsonSchema';\nimport {RegistryFactory} from '../registry/RegistryFactory';\nimport {\n DEFAULT_NAMESPACE,\n K_PATTERN_PROPERTY,\n METADATA_TYPE,\n METATYPE_CLASS_REF,\n METATYPE_ENTITY, METATYPE_NAMESPACE,\n METATYPE_PROPERTY,\n T_ARRAY,\n T_OBJECT,\n T_STRING\n} from '../Constants';\nimport {IEntityRef, isEntityRef} from '../../api/IEntityRef';\nimport {IEntityOptions} from '../options/IEntityOptions';\nimport {ClassRef} from '../ClassRef';\nimport {NotSupportedError, NotYetImplementedError} from '@allgemein/base';\nimport {MetadataRegistry} from '../registry/MetadataRegistry';\nimport {IParseOptions, PARSE_OPTIONS_KEYS} from './IParseOptions';\nimport {IPropertyOptions} from '../options/IPropertyOptions';\nimport {IAbstractOptions} from '../options/IAbstractOptions';\nimport {SchemaUtils} from '../SchemaUtils';\nimport {IPropertyRef} from '../../api/IPropertyRef';\n\nconst skipKeys = ['$id', 'id', 'title', 'type', 'properties', 'allOf', 'anyOf', '$schema', 'patternProperties'];\n\nexport class JsonSchema7Unserializer implements IJsonSchemaUnserializer {\n\n version: string = DRAFT_07;\n\n options: IJsonSchemaUnserializeOptions;\n\n data: IJsonSchema7;\n\n classRefs: IClassRef[] = [];\n\n fetched: { [k: string]: IJsonSchema7 } = {};\n\n reference: { [k: string]: any } = {};\n\n issues: { msg: string, level: 'error' | 'warning' | 'info' }[] = [];\n\n constructor(opts: IJsonSchemaUnserializeOptions) {\n this.options = opts;\n }\n\n uri(): string {\n return `http://json-schema.org/${DRAFT_07}/schema`;\n }\n\n\n async unserialize(data: any): Promise<IClassRef | IEntityRef | (IClassRef | IEntityRef)[]> {\n this.data = data;\n const isRoot = get(this.options, 'rootAsEntity', true);\n const opts: any = {isRoot: isRoot};\n PARSE_OPTIONS_KEYS.forEach(x => {\n if (has(this.options, x)) {\n opts[x] = this.options[x];\n }\n });\n\n const ret = this.options.return ? this.options.return : 'default';\n return this.parse(data, opts).then(refs => {\n switch (ret) {\n case 'class-refs':\n return this.classRefs;\n case 'entity-refs':\n return this.classRefs.filter(x => x.hasEntityRef()).map(x => x.getEntityRef());\n default:\n return refs;\n }\n });\n }\n\n /**\n * Return namespace if set in passed options or if used in json-schema object.\n * If no match return default namespace\n */\n getNamespace() {\n return get(this.options, 'namespace', get(this.data, 'namespace', DEFAULT_NAMESPACE));\n }\n\n /**\n * Get registry containing elements\n */\n getRegistry(ns: string = null) {\n return RegistryFactory.get(ns ? ns : this.getNamespace());\n }\n\n\n getIssues() {\n return this.issues;\n }\n\n /**\n * If collectors are defined use them before default\n *\n *\n * @param type\n * @param key\n * @param data\n * @param options\n * @private\n */\n private collectOptions(key: string, data: IJsonSchema7, options: IParseOptions = {}) {\n const type = get(options, 'metaType', METATYPE_ENTITY);\n let ret: any = null;\n if (!isUndefined(data[key]) || !isNull(data[key])) {\n ret = {};\n ret[key] = data[key];\n }\n\n if (has(this.options, 'collector') && this.options.collector.length > 0) {\n const methods = this.options.collector.filter(x => x.type === type && x.key === key);\n if (methods) {\n ret = assign(ret, ...methods.map(e => e.fn.apply(null, [key, data, options])));\n }\n }\n return ret;\n }\n\n\n getClassRef(className: string | Function, namespace?: string) {\n if (!namespace) {\n namespace = this.getNamespace();\n }\n return ClassRef.get(className, namespace);\n }\n\n\n async parse(data: IJsonSchema7, options: IParseOptions = null): Promise<IClassRef | IEntityRef | (IClassRef | IEntityRef)[]> {\n let ret: IClassRef | IEntityRef | (IClassRef | IEntityRef)[] = null;\n if (data.type) {\n\n if (data.type === T_OBJECT) {\n ret = await this.parseTypeObject(data, options);\n if (ret) {\n if (options.$ref) {\n // finish reference if waiting\n this.reference[options.$ref] = ret;\n delete options.$ref;\n }\n\n if (this.hasProperties(data)) {\n await this.parseProperties(ret, data.properties, options);\n }\n if (this.hasPatternProperties(data)) {\n options.isPattern = true;\n await this.parseProperties(ret, data.patternProperties, options);\n }\n }\n } else {\n throw new Error('type is not supported at this place');\n }\n\n } else if (data.$ref) {\n return this.parseRef(data, options);\n } else if (data.anyOf && options.isRoot) {\n // loading multi schema\n ret = [];\n for (const anyEntry of data.anyOf) {\n ret.push(await this.parse(anyEntry as any, options) as (IClassRef | IEntityRef));\n }\n } else if (data.definitions && keys(data.definitions).length === 0) {\n // doing nothing no entries found\n } else {\n throw new Error('no valid schema element for further parse, key with name type or $ref must be present.');\n }\n return ret;\n }\n\n async parseRef(data: any, options: IParseOptions) {\n // refers\n let ret = null;\n if (has(this.reference, data.$ref)) {\n ret = this.reference[data.$ref];\n } else {\n const res = await this.followRef(data.$ref, this.data);\n const opts = clone(options);\n opts.$ref = data.$ref;\n if (!opts.className) {\n opts.className = this.getClassNameFromRef(data.$ref);\n }\n ret = await this.parse(res, opts);\n }\n return ret;\n }\n\n\n getDefinitionsKey(data: object) {\n for (const k of keys(data)) {\n if (k !== 'properties' && isObjectLike(data[k])) {\n const exists = keys(data[k]).find(x => has(data[k][x], 'type'));\n if (exists) {\n return k;\n }\n }\n }\n return 'definition';\n }\n\n\n async followRef($ref: string, data: IJsonSchema7): Promise<any> {\n let [addr, anchor] = $ref.split('#');\n\n if (!anchor) {\n anchor = '';\n }\n\n if (isEmpty(addr)) {\n // local\n if (isEmpty(anchor)) {\n if (data.$ref) {\n return this.followRef(data.$ref, data);\n } else {\n return data;\n }\n } else if (/^\\//.test(anchor)) {\n // starts with path\n const dottedPath = anchor.substr(1).replace(/\\//, '.');\n const entry = get(data, dottedPath, null);\n if (entry) {\n return entry;\n }\n } else {\n // refs to local id\n const refHashed = '#' + anchor;\n if (data.$id === refHashed) {\n return data;\n } else {\n const defKey = this.getDefinitionsKey(data);\n if (data[defKey]) {\n for (const k of keys(data[defKey])) {\n const x = data[defKey][k] as IJsonSchema7;\n if (x && x.$id && x.$id === refHashed) {\n return x;\n }\n }\n }\n }\n }\n } else {\n // remote fetch url\n if (!this.fetched[addr]) {\n this.fetched[addr] = await JsonSchema.request(addr, {cwd: this.options.cwd});\n }\n return this.followRef('#' + anchor, this.fetched[addr]);\n }\n // TODO create exception\n throw new Error($ref + ' not found');\n }\n\n\n async parseProperties(classRef: IClassRef | IEntityRef, properties: { [propertyName: string]: IJsonSchema7Definition }, options: IParseOptions = null) {\n const _classRef = isEntityRef(classRef) ? classRef.getClassRef() : classRef;\n const propertyNames = keys(properties);\n for (const propertyName of propertyNames) {\n await this.parseProperty(_classRef, propertyName, properties[propertyName], options);\n }\n }\n\n\n async parseProperty(classRef: IClassRef | IEntityRef, propertyName: string, data: IJsonSchema7Definition, options: IParseOptions = null) {\n const _classRef = isEntityRef(classRef) ? classRef.getClassRef() : classRef;\n\n const propRefExits = _classRef.getRegistry()\n .find(METATYPE_PROPERTY,\n (x: IPropertyRef) => x.getClassRef() === _classRef && x.name === propertyName) as IPropertyRef;\n\n const propOptions: IPropertyOptions = {\n metaType: METATYPE_PROPERTY,\n propertyName: propertyName,\n target: _classRef.getClass(true),\n // default type is object\n type: T_OBJECT,\n };\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n\n if (isObjectLike(data)) {\n const parseOptions: IParseOptions = {\n isProperty: true,\n sourceRef: _classRef,\n propertyName: propertyName,\n isRoot: false,\n metaType: 'property',\n // isPattern: options.isPattern ? true : false\n };\n const dataPointer = data as IJsonSchema7;\n let collectOptions = {};\n collectOptions = this.collectAndProcess(dataPointer, collectOptions, ['type', '$ref', '$schema', '$id'], parseOptions);\n assign(propOptions, collectOptions);\n if (dataPointer.$ref) {\n const ref = await this.parse(dataPointer, parseOptions);\n propOptions.type = ref;\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n } else if (dataPointer.type) {\n await this.onTypes(dataPointer, propOptions, parseOptions);\n }\n } else {\n // boolean\n throw new NotSupportedError('passed boolean value as definition not supported');\n }\n\n if (!propRefExits || get(this.options, 'forcePropertyRefCreation', false)) {\n // remove properties key if exists\n delete propOptions.properties;\n try {\n _classRef.getRegistry().create(METATYPE_PROPERTY, propOptions);\n } catch (e) {\n this.issues.push({msg: e.message, level: 'error'})\n }\n } else if (propRefExits) {\n propRefExits.setOptions(propOptions);\n }\n\n }\n\n\n hasProperties(datapointer: any) {\n return has(datapointer, 'properties');\n }\n\n hasPatternProperties(datapointer: any) {\n return has(datapointer, 'patternProperties');\n }\n\n async onTypes(dataPointer: IJsonSchema7, propOptions: IPropertyOptions, options: IParseOptions) {\n let type = dataPointer.type as string;\n if (isString(type)) {\n type = type.toLowerCase();\n }\n switch (type) {\n case T_STRING:\n const res = this.onTypeString(dataPointer);\n assign(propOptions, res);\n break;\n case 'boolean':\n propOptions.type = 'boolean';\n break;\n case 'integer':\n propOptions.type = 'number';\n break;\n case 'number':\n propOptions.type = 'number';\n break;\n case T_OBJECT:\n propOptions.type = T_OBJECT;\n if (this.hasProperties(dataPointer) || this.hasPatternProperties(dataPointer)) {\n propOptions.type = await this.parse(dataPointer, options);\n }\n break;\n case T_ARRAY:\n // check items\n if (dataPointer.minItems || dataPointer.maxItems) {\n propOptions.cardinality = {\n min: get(dataPointer, 'minItems', 0),\n max: get(dataPointer, 'maxItems', 0),\n };\n } else {\n propOptions.cardinality = 0;\n }\n\n if (dataPointer.items) {\n\n if (isArray(dataPointer.items)) {\n throw new NotSupportedError('tuple values for array is not supported');\n } else if (isObjectLike(dataPointer.items)) {\n options.asArray = true;\n const items = dataPointer.items as IJsonSchema7;\n if (items.$ref) {\n propOptions.type = await this.parse(items as IJsonSchema7, options);\n } else if (items.type === T_OBJECT) {\n propOptions.type = items.type;\n if (this.hasProperties(items) || this.hasPatternProperties(items)) {\n propOptions.type = await this.parse(items as IJsonSchema7, options);\n }\n } else {\n propOptions.type = items.type;\n }\n if (options.isPattern) {\n propOptions[K_PATTERN_PROPERTY] = true;\n }\n }\n }\n break;\n case 'null':\n throw new NotSupportedError('null value is not supported for property');\n }\n }\n\n\n onTypeString(dataPointer: any) {\n const propOptions: any = {};\n propOptions.type = T_STRING;\n // or date check format\n if (dataPointer.format) {\n propOptions.format = dataPointer.format;\n switch (dataPointer.format) {\n case 'date-time':\n // set date type\n propOptions.type = 'date';\n break;\n case 'date':\n // set date type\n propOptions.type = 'date';\n break;\n }\n }\n return propOptions;\n }\n\n\n async parseInherits(classRef: IClassRef, data: IJsonSchema7, key: 'allOf' | 'anyOf') {\n if (has(data, key)) {\n const values = data[key];\n if (isArray(values)) {\n for (const inheritEntry of values) {\n const extend = await this.parse(inheritEntry as IJsonSchema7, {isRoot: false}) as IClassRef;\n classRef.addExtend(extend);\n }\n } else {\n throw new NotSupportedError('only array is allowed for ' + key);\n }\n }\n }\n\n\n async parseTypeObject(data: IJsonSchema7, options: IParseOptions = null) {\n let ret: IClassRef | IEntityRef = null;\n\n const id = get(data, '$id', get(data, 'id', null));\n let metaType: METADATA_TYPE = options.isRoot || !isEmpty(id) ? METATYPE_ENTITY : METATYPE_CLASS_REF;\n\n const title = get(data, 'title', null);\n\n // get namespace or override\n const namespace = !get(this.options, 'skipNamespace', false) ?\n get(data, '$' + METATYPE_NAMESPACE, this.getNamespace()) : this.getNamespace();\n\n // check if class ref exists else create one or recreate if parse options are set\n let classRef: IClassRef = null;\n let className = null;\n if (options) {\n if (options.className) {\n className = options.className;\n }\n if (options.ref) {\n classRef = options.ref;\n className = options.ref.name;\n }\n }\n\n // title data override passed className\n if (title) {\n if (!className || !get(this.options, 'ignoreDeclared', false)) {\n className = upperFirst(camelCase(title));\n }\n }\n\n let entityName = metaType === METATYPE_ENTITY && id ? id.replace(/^#/, '') : className;\n if (!className && options?.isProperty && options.propertyName) {\n if (get(this.options, 'prependClass', false)) {\n className = [options.sourceRef.name, options.propertyName].map(x => upperFirst(camelCase(x))).join('');\n } else {\n className = upperFirst(camelCase(options.propertyName));\n }\n // pass property name as entity name if the object is declared as a property\n entityName = className;\n }\n\n if (className && !classRef) {\n const fn = get(this.options, 'forceClassRefCreation', false) ? SchemaUtils.clazz(className) : className;\n classRef = this.getClassRef(fn, namespace);\n }\n\n if (!classRef) {\n metaType = METATYPE_CLASS_REF;\n classRef = this.getClassRef(SchemaUtils.clazzAnonymous(), namespace);\n }\n\n // TODO check extentions!\n for (const inheritsKey of ['allOf', 'anyOf']) {\n if (has(data, inheritsKey)) {\n await this.parseInherits(classRef, data, inheritsKey as any);\n }\n }\n\n if (classRef) {\n // a named class ref exists\n if (!this.classRefs.find(x => x === classRef)) {\n this.classRefs.push(classRef);\n }\n\n const clazz = classRef.getClass(true);\n const refOptions: IEntityOptions = {\n name: entityName,\n namespace: this.getNamespace(),\n target: clazz\n };\n\n const collectorOptions = clone(options);\n collectorOptions.metaType = metaType;\n collectorOptions.ref = classRef;\n this.collectAndProcess(data, refOptions, skipKeys, collectorOptions);\n\n metaType = collectorOptions.metaType;\n\n let entityOptions = MetadataRegistry.$().find(metaType, (x: IAbstractOptions) => x.target === clazz);\n if (entityOptions) {\n // merge existing\n assign(entityOptions, refOptions);\n } else {\n entityOptions = refOptions;\n refOptions.metaType = METATYPE_CLASS_REF;\n const existingOptions = classRef.getOptions();\n classRef.setOptions(defaults(refOptions, existingOptions));\n }\n\n if (metaType === METATYPE_ENTITY) {\n ret = this.getRegistry(namespace).find(metaType, (x: IEntityRef) => x.getClassRef() === classRef);\n if (!ret || get(this.options, 'forceEntityRefCreation', false)) {\n try {\n ret = this.getRegistry(namespace).create(metaType, entityOptions);\n } catch (e) {\n this.issues.push({msg: e.message, level: 'error'})\n }\n }\n } else {\n ret = classRef;\n }\n\n } else {\n throw new NotYetImplementedError();\n }\n return ret;\n }\n\n\n collectAndProcess(data: IJsonSchema7,\n collectingObject: any,\n skipKeys: string[],\n collectorOptions: IParseOptions) {\n const type = get(collectorOptions, 'metaType', METATYPE_ENTITY);\n const _keys = keys(data);\n for (const key of _keys) {\n const entry = this.collectOptions(key, data, collectorOptions);\n if (skipKeys.includes(key)) {\n continue;\n }\n if (entry && isObjectLike(entry)) {\n collectingObject = assign(collectingObject, entry);\n }\n }\n if (has(this.options, 'collector') && this.options.collector.length > 0) {\n const methods = this.options.collector.filter(x => x.type === type && isUndefined(x.key));\n if (methods.length > 0) {\n collectingObject = assign(collectingObject, ...methods.map(e => e.fn.apply(null, [null, data, collectorOptions])));\n }\n }\n return collectingObject;\n }\n\n getClassNameFromRef(data: string) {\n return data.split(/#|\\//).pop();\n }\n\n}\n"],"sourceRoot":"../.."}
|