@orion-js/typed-model 3.11.15 → 4.0.0-alpha.2
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/dist/index.cjs +6776 -0
- package/dist/index.d.ts +495 -0
- package/dist/index.js +6748 -0
- package/package.json +24 -21
- package/LICENSE +0 -21
- package/lib/decorators/index.d.ts +0 -4
- package/lib/decorators/index.js +0 -16
- package/lib/decorators/prop.d.ts +0 -8
- package/lib/decorators/prop.js +0 -30
- package/lib/decorators/prop.test.d.ts +0 -1
- package/lib/decorators/prop.test.js +0 -26
- package/lib/decorators/resolver.d.ts +0 -5
- package/lib/decorators/resolver.js +0 -14
- package/lib/decorators/typedModel.d.ts +0 -5
- package/lib/decorators/typedModel.js +0 -16
- package/lib/decorators/typedSchema.d.ts +0 -2
- package/lib/decorators/typedSchema.js +0 -13
- package/lib/enum.test.d.ts +0 -1
- package/lib/enum.test.js +0 -29
- package/lib/errors/CannotDetermineType.d.ts +0 -3
- package/lib/errors/CannotDetermineType.js +0 -9
- package/lib/errors/CannotUseArray.d.ts +0 -3
- package/lib/errors/CannotUseArray.js +0 -9
- package/lib/errors/PropertyAlreadyExists.d.ts +0 -3
- package/lib/errors/PropertyAlreadyExists.js +0 -9
- package/lib/errors/SchemaAlreadyExists.d.ts +0 -3
- package/lib/errors/SchemaAlreadyExists.js +0 -9
- package/lib/errors/index.d.ts +0 -4
- package/lib/errors/index.js +0 -16
- package/lib/factories/cloneSchemaClass.d.ts +0 -23
- package/lib/factories/cloneSchemaClass.js +0 -28
- package/lib/factories/cloneSchemaClass.test.d.ts +0 -1
- package/lib/factories/cloneSchemaClass.test.js +0 -38
- package/lib/factories/getModelForClass.d.ts +0 -3
- package/lib/factories/getModelForClass.js +0 -62
- package/lib/factories/getModelForClass.test.d.ts +0 -1
- package/lib/factories/getModelForClass.test.js +0 -59
- package/lib/factories/getSchemaForClass.d.ts +0 -3
- package/lib/factories/getSchemaForClass.js +0 -8
- package/lib/factories/helpers/processSchemaForProp.d.ts +0 -4
- package/lib/factories/helpers/processSchemaForProp.js +0 -65
- package/lib/factories/index.d.ts +0 -3
- package/lib/factories/index.js +0 -15
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -14
- package/lib/index.test.d.ts +0 -1
- package/lib/index.test.js +0 -682
- package/lib/schema.test.d.ts +0 -1
- package/lib/schema.test.js +0 -94
- package/lib/storage/metadataStorage.d.ts +0 -28
- package/lib/storage/metadataStorage.js +0 -55
- package/lib/utils/interfaces.d.ts +0 -3
- package/lib/utils/interfaces.js +0 -2
- package/lib/utils/isClass.d.ts +0 -1
- package/lib/utils/isClass.js +0 -6
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSchemaForClassRecursive = exports.processSchemaForProp = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
8
|
-
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
9
|
-
const metadataStorage_1 = require("../../storage/metadataStorage");
|
|
10
|
-
const isClass_1 = require("../../utils/isClass");
|
|
11
|
-
function isPrimitive(type) {
|
|
12
|
-
return [Boolean, Number, String, Date].includes(type);
|
|
13
|
-
}
|
|
14
|
-
function processSchemaForProp(prop) {
|
|
15
|
-
if (typeof prop.type?.type === 'function') {
|
|
16
|
-
return processSchemaForProp(prop.type);
|
|
17
|
-
}
|
|
18
|
-
if (Array.isArray(prop.type)) {
|
|
19
|
-
return prop.type.length > 0
|
|
20
|
-
? { ...prop, type: [processSchemaForProp(prop.type[0])] }
|
|
21
|
-
: prop;
|
|
22
|
-
}
|
|
23
|
-
if (typeof prop.type !== 'function') {
|
|
24
|
-
if ((0, isPlainObject_1.default)(prop.type)) {
|
|
25
|
-
const subschema = {};
|
|
26
|
-
Object.keys(prop.type).forEach(key => {
|
|
27
|
-
subschema[key] = processSchemaForProp({ type: prop.type[key] });
|
|
28
|
-
});
|
|
29
|
-
return { ...prop, type: subschema };
|
|
30
|
-
}
|
|
31
|
-
return prop;
|
|
32
|
-
}
|
|
33
|
-
if (isPrimitive(prop.type)) {
|
|
34
|
-
return prop;
|
|
35
|
-
}
|
|
36
|
-
if ((0, isClass_1.isClass)(prop.type)) {
|
|
37
|
-
const schema = getSchemaForClassRecursive(prop.type);
|
|
38
|
-
return {
|
|
39
|
-
...prop,
|
|
40
|
-
type: schema
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return prop;
|
|
44
|
-
}
|
|
45
|
-
exports.processSchemaForProp = processSchemaForProp;
|
|
46
|
-
function getSchemaForClassRecursive(target) {
|
|
47
|
-
const schema = {};
|
|
48
|
-
let parent = target;
|
|
49
|
-
while (parent.prototype) {
|
|
50
|
-
if (parent === Function.prototype) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
const props = metadataStorage_1.MetadataStorage.getSchemaProps(parent);
|
|
54
|
-
if (!props) {
|
|
55
|
-
parent = Object.getPrototypeOf(parent);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
Object.keys(props).forEach(key => {
|
|
59
|
-
schema[key] = processSchemaForProp(props[key]);
|
|
60
|
-
});
|
|
61
|
-
parent = Object.getPrototypeOf(parent);
|
|
62
|
-
}
|
|
63
|
-
return schema;
|
|
64
|
-
}
|
|
65
|
-
exports.getSchemaForClassRecursive = getSchemaForClassRecursive;
|
package/lib/factories/index.d.ts
DELETED
package/lib/factories/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./getSchemaForClass"), exports);
|
|
14
|
-
__exportStar(require("./getModelForClass"), exports);
|
|
15
|
-
__exportStar(require("./cloneSchemaClass"), exports);
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./decorators"), exports);
|
|
14
|
-
__exportStar(require("./factories"), exports);
|
package/lib/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|