@based/schema 0.0.5 → 0.0.6
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/parse.d.ts +2 -0
- package/dist/parse.js +9 -0
- package/dist/parse.js.map +1 -0
- package/dist/set/collections.d.ts +5 -0
- package/dist/set/collections.js +139 -0
- package/dist/set/collections.js.map +1 -0
- package/dist/set/error.d.ts +10 -0
- package/dist/set/error.js +19 -0
- package/dist/set/error.js.map +1 -0
- package/dist/set/index.js +8 -14
- package/dist/set/index.js.map +1 -1
- package/dist/set/number.d.ts +4 -0
- package/dist/set/number.js +57 -0
- package/dist/set/number.js.map +1 -0
- package/dist/set/parsers.d.ts +2 -5
- package/dist/set/parsers.js +35 -357
- package/dist/set/parsers.js.map +1 -1
- package/dist/set/references.d.ts +3 -0
- package/dist/set/references.js +81 -0
- package/dist/set/references.js.map +1 -0
- package/dist/set/rest.d.ts +5 -0
- package/dist/set/rest.js +53 -0
- package/dist/set/rest.js.map +1 -0
- package/dist/set/string.d.ts +3 -0
- package/dist/set/string.js +136 -0
- package/dist/set/string.js.map +1 -0
- package/dist/set/types.d.ts +5 -0
- package/dist/{deepPartial.js → set/types.js} +1 -1
- package/dist/set/types.js.map +1 -0
- package/dist/types.d.ts +36 -17
- package/dist/types.js.map +1 -1
- package/package.json +3 -1
- package/src/set/collections.ts +246 -0
- package/src/set/error.ts +17 -0
- package/src/set/index.ts +8 -18
- package/src/set/number.ts +78 -0
- package/src/set/parsers.ts +17 -553
- package/src/set/references.ts +107 -0
- package/src/set/rest.ts +76 -0
- package/src/set/string.ts +159 -0
- package/src/set/types.ts +19 -0
- package/src/types.ts +105 -20
- package/test/setWalker.ts +16 -7
- package/dist/deepPartial.d.ts +0 -0
- package/dist/deepPartial.js.map +0 -1
- package/dist/set/enum.d.ts +0 -2
- package/dist/set/enum.js +0 -15
- package/dist/set/enum.js.map +0 -1
- package/dist/set/fieldValidator.d.ts +0 -6
- package/dist/set/fieldValidator.js +0 -144
- package/dist/set/fieldValidator.js.map +0 -1
- package/dist/set/handleError.d.ts +0 -1
- package/dist/set/handleError.js +0 -9
- package/dist/set/handleError.js.map +0 -1
- package/dist/setWalker.d.ts +0 -11
- package/dist/setWalker.js +0 -189
- package/dist/setWalker.js.map +0 -1
- package/dist/transformers.d.ts +0 -3
- package/dist/transformers.js +0 -18
- package/dist/transformers.js.map +0 -1
- package/dist/typeWalker.d.ts +0 -3
- package/dist/typeWalker.js +0 -18
- package/dist/typeWalker.js.map +0 -1
- package/dist/validate.d.ts +0 -4
- package/dist/validate.js +0 -34
- package/dist/validate.js.map +0 -1
- package/dist/validateFields.d.ts +0 -4
- package/dist/validateFields.js +0 -34
- package/dist/validateFields.js.map +0 -1
- package/dist/validateSchema copy.d.ts +0 -4
- package/dist/validateSchema copy.js +0 -34
- package/dist/validateSchema copy.js.map +0 -1
- package/src/set/handleError.ts +0 -15
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@saulx/utils");
|
|
4
|
-
const handleError_1 = require("./handleError");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const fieldValidator = {
|
|
7
|
-
enum: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const enumValues = fieldSchema.enum;
|
|
10
|
-
for (let i = 0; i < enumValues.length; i++) {
|
|
11
|
-
if ((0, utils_1.deepEqual)(enumValues[i], value)) {
|
|
12
|
-
collect(path, i, typeSchema, fieldSchema, target);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
throw (0, handleError_1.createError)(path, target.type, 'enum', value);
|
|
17
|
-
},
|
|
18
|
-
array: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
19
|
-
// TODO: ADD OPERATORS
|
|
20
|
-
const isArray = Array.isArray(value);
|
|
21
|
-
if (!isArray) {
|
|
22
|
-
throw (0, handleError_1.createError)(path, target.type, 'array', value);
|
|
23
|
-
}
|
|
24
|
-
for (let i = 0; i < value.length; i++) {
|
|
25
|
-
(0, _1.fieldWalker)([...path, i], value[i],
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
fieldSchema.values, typeSchema, target, collect);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
object: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
31
|
-
if (typeof value !== 'object') {
|
|
32
|
-
throw (0, handleError_1.createError)(path, target.type, 'object', value);
|
|
33
|
-
}
|
|
34
|
-
const isArray = Array.isArray(value);
|
|
35
|
-
if (isArray) {
|
|
36
|
-
throw (0, handleError_1.createError)(path, target.type, 'object', value);
|
|
37
|
-
}
|
|
38
|
-
for (const key in value) {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
const propDef = fieldSchema.properties[key];
|
|
41
|
-
if (!propDef) {
|
|
42
|
-
throw (0, handleError_1.createError)([...path, key], target.type, 'object', value[key], key);
|
|
43
|
-
}
|
|
44
|
-
(0, _1.fieldWalker)([...path, key], value[key], propDef, typeSchema, target, collect);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
set: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
const parsedArray = [];
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
const fieldDef = fieldSchema.items;
|
|
52
|
-
for (let i = 0; i < value.length; i++) {
|
|
53
|
-
(0, _1.fieldWalker)([...path, i], value[i], fieldDef, typeSchema, target, (path, value) => {
|
|
54
|
-
parsedArray.push(value);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
collect(path, parsedArray, typeSchema, fieldSchema, target);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// TODO PARSE IF VALID
|
|
61
|
-
// $add / $remove
|
|
62
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
json: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
66
|
-
try {
|
|
67
|
-
const parsedValue = JSON.stringify(value);
|
|
68
|
-
collect(path, parsedValue, typeSchema, fieldSchema, target);
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
throw (0, handleError_1.createError)(path, target.type, 'json', value);
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
number: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
75
|
-
if (typeof value !== 'number') {
|
|
76
|
-
throw (0, handleError_1.createError)(path, target.type, 'number', value);
|
|
77
|
-
}
|
|
78
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
79
|
-
},
|
|
80
|
-
integer: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
81
|
-
if (typeof value !== 'number' || value - Math.floor(value) !== 0) {
|
|
82
|
-
throw (0, handleError_1.createError)(path, target.type, 'integer', value);
|
|
83
|
-
}
|
|
84
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
85
|
-
},
|
|
86
|
-
string: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
87
|
-
if (typeof value !== 'string') {
|
|
88
|
-
throw (0, handleError_1.createError)(path, target.type, 'string', value);
|
|
89
|
-
}
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
|
|
92
|
-
throw (0, handleError_1.createError)(path, target.type, 'string', value);
|
|
93
|
-
}
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
|
|
96
|
-
throw (0, handleError_1.createError)(path, target.type, 'string', value);
|
|
97
|
-
}
|
|
98
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
99
|
-
},
|
|
100
|
-
text: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
101
|
-
const valueType = typeof value;
|
|
102
|
-
if (target.$language && valueType === 'string') {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
|
|
105
|
-
throw (0, handleError_1.createError)(path, target.type, 'text', value);
|
|
106
|
-
}
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
|
|
109
|
-
throw (0, handleError_1.createError)(path, target.type, 'text', value);
|
|
110
|
-
}
|
|
111
|
-
collect(path, { [target.$language]: value }, typeSchema, fieldSchema, target);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (valueType !== 'object') {
|
|
115
|
-
throw (0, handleError_1.createError)(path, target.type, 'text', value);
|
|
116
|
-
}
|
|
117
|
-
for (const key in value) {
|
|
118
|
-
// @ts-ignore
|
|
119
|
-
if (fieldSchema.minLength && value[key].length < fieldSchema.minLength) {
|
|
120
|
-
throw (0, handleError_1.createError)([...path, key], target.type, 'text', value);
|
|
121
|
-
}
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
if (fieldSchema.maxLength && value[key].length > fieldSchema.maxLength) {
|
|
124
|
-
throw (0, handleError_1.createError)([...path, key], target.type, 'text', value);
|
|
125
|
-
}
|
|
126
|
-
if (typeof value[key] === 'object' && value[key].$delete === true) {
|
|
127
|
-
collect([...path, key], null, typeSchema, fieldSchema, target);
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (typeof value[key] !== 'string') {
|
|
131
|
-
throw (0, handleError_1.createError)([...path, key], target.type, 'text', value);
|
|
132
|
-
}
|
|
133
|
-
collect([...path, key], value[key], typeSchema, fieldSchema, target);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
references: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
137
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
138
|
-
},
|
|
139
|
-
reference: (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
140
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
exports.default = fieldValidator;
|
|
144
|
-
//# sourceMappingURL=fieldValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValidator.js","sourceRoot":"","sources":["../../src/set/fieldValidator.ts"],"names":[],"mappings":";;AAOA,wCAAwC;AACxC,+CAA2C;AAC3C,wBAA+B;AAE/B,MAAM,cAAc,GAehB;IACF,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAC9D,aAAa;QACb,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAA;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,IAAA,iBAAS,EAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE;gBACnC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;gBACjD,OAAM;aACP;SACF;QACD,MAAM,IAAA,yBAAW,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IAED,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAC/D,sBAAsB;QACtB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAA,yBAAW,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;SACrD;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,IAAA,cAAW,EACT,CAAC,GAAG,IAAI,EAA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CAAC,CAAA;IACvD,CAAC;CACF,CAAA;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createError: (path: (number | string)[], fromType: string, fieldType: string, value: any, fieldDoesNotExist?: string, msg?: string) => Error;
|
package/dist/set/handleError.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createError = void 0;
|
|
4
|
-
const createError = (path, fromType, fieldType, value, fieldDoesNotExist, msg) => {
|
|
5
|
-
const err = new Error();
|
|
6
|
-
return new Error(`Type: "${fromType}" Field: "${path.join('.')}" is not a valid value for ${fieldType}`);
|
|
7
|
-
};
|
|
8
|
-
exports.createError = createError;
|
|
9
|
-
//# sourceMappingURL=handleError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../src/set/handleError.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CACzB,IAAyB,EACzB,QAAgB,EAChB,SAAiB,EACjB,KAAU,EACV,iBAA0B,EAC1B,GAAY,EACL,EAAE;IACT,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;IACvB,OAAO,IAAI,KAAK,CACd,UAAU,QAAQ,aAAa,IAAI,CAAC,IAAI,CACtC,GAAG,CACJ,8BAA8B,SAAS,EAAE,CAC3C,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,WAAW,eAcvB"}
|
package/dist/setWalker.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaField, BasedSchemaType, BasedSchema, BasedSchemaLanguage } from './types';
|
|
2
|
-
type Target = {
|
|
3
|
-
type: string;
|
|
4
|
-
$alias?: string;
|
|
5
|
-
$id?: string;
|
|
6
|
-
$language?: BasedSchemaLanguage;
|
|
7
|
-
};
|
|
8
|
-
export declare const setWalker: (schema: BasedSchema, value: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}, collect: (path: (string | number)[], value: any, typeSchema: BasedSchemaType, fieldSchema: BasedSchemaField, target: Target) => void) => Target;
|
|
11
|
-
export {};
|
package/dist/setWalker.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setWalker = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
const utils_1 = require("@saulx/utils");
|
|
6
|
-
// collect is a pretty good place for checking if a user is allowed to set something
|
|
7
|
-
// also make collect async
|
|
8
|
-
const fieldWalker = (path, value, fieldSchema, typeSchema, target, collect) => {
|
|
9
|
-
if ('$ref' in fieldSchema) {
|
|
10
|
-
// TODO: when we have this it has to get it from the schema and redo the parsing with the correct fieldSchema
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const valueType = typeof value;
|
|
14
|
-
const valueIsObject = value && valueType === 'object';
|
|
15
|
-
if (valueIsObject && value.$delete === true) {
|
|
16
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if ('enum' in fieldSchema) {
|
|
20
|
-
const enumValues = fieldSchema.enum;
|
|
21
|
-
for (let i = 0; i < enumValues.length; i++) {
|
|
22
|
-
if ((0, utils_1.deepEqual)(enumValues[i], value)) {
|
|
23
|
-
collect(path, i, typeSchema, fieldSchema, target);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
throw new Error(`Type: "${target.type}" Field: "${path.join('.')}" is not a valid value for enum`);
|
|
28
|
-
}
|
|
29
|
-
if ('type' in fieldSchema && (0, types_1.isCollection)(fieldSchema.type)) {
|
|
30
|
-
const typeDef = fieldSchema.type;
|
|
31
|
-
const isArray = Array.isArray(value);
|
|
32
|
-
if (typeDef === 'array') {
|
|
33
|
-
if (!isArray) {
|
|
34
|
-
throw new Error(`Type: "${target.type}" Field: "${path.join('.')}" is not of type "array"`);
|
|
35
|
-
}
|
|
36
|
-
for (let i = 0; i < value.length; i++) {
|
|
37
|
-
fieldWalker([...path, i], value[i],
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
fieldSchema.values, typeSchema, target, collect);
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
else if (isArray) {
|
|
44
|
-
throw new Error(`Type: "${target.type}" Field: "${path.join('.')}" is not of type "${typeDef}"`);
|
|
45
|
-
}
|
|
46
|
-
if (valueType !== 'object') {
|
|
47
|
-
throw new Error(`Type: "${target.type}" Field: "${path.join('.')}" is not of type "${typeDef}"`);
|
|
48
|
-
}
|
|
49
|
-
for (const key in value) {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
const propDef = fieldSchema.properties[key];
|
|
52
|
-
if (!propDef) {
|
|
53
|
-
throw new Error(`Field does not exist in schema "${[...path, key].join('.')}" on type "${target.type}"`);
|
|
54
|
-
}
|
|
55
|
-
fieldWalker([...path, key], value[key], propDef, typeSchema, target, collect);
|
|
56
|
-
}
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if ('type' in fieldSchema) {
|
|
60
|
-
const typeDef = fieldSchema.type;
|
|
61
|
-
if (typeDef === 'set') {
|
|
62
|
-
if (Array.isArray(value)) {
|
|
63
|
-
const parsedArray = [];
|
|
64
|
-
const fieldDef = fieldSchema.items;
|
|
65
|
-
for (let i = 0; i < value.length; i++) {
|
|
66
|
-
fieldWalker([...path, i], value[i], fieldDef, typeSchema, target, (path, value) => {
|
|
67
|
-
parsedArray.push(value);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
collect(path, parsedArray, typeSchema, fieldSchema, target);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
// TODO PARSE IF VALID
|
|
74
|
-
// $add / $remove
|
|
75
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (typeDef === 'json') {
|
|
80
|
-
try {
|
|
81
|
-
const parsedValue = JSON.stringify(value);
|
|
82
|
-
collect(path, parsedValue, typeSchema, fieldSchema, target);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
throw new Error(`${value} cannot be parsed to json "${path.join('.')}" on type "${target.type}"`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if ((typeDef === 'number' || typeDef === 'integer') &&
|
|
90
|
-
valueType !== 'number') {
|
|
91
|
-
throw new Error(`${value} is not a number "${path.join('.')}" on type "${target.type}"`);
|
|
92
|
-
}
|
|
93
|
-
if (typeDef === 'integer' && value - Math.floor(value) !== 0) {
|
|
94
|
-
throw new Error(`${value} is not an integer "${path.join('.')}" on type "${target.type}"`);
|
|
95
|
-
}
|
|
96
|
-
if (typeDef === 'string') {
|
|
97
|
-
if (valueType !== 'string') {
|
|
98
|
-
throw new Error(`${value} is not a string "${path.join('.')}" on type "${target.type}"`);
|
|
99
|
-
}
|
|
100
|
-
if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
|
|
101
|
-
throw new Error(`${value} is smaller then minLength "${fieldSchema.minLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
102
|
-
}
|
|
103
|
-
if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
|
|
104
|
-
throw new Error(`${value} is larger then maxLength "${fieldSchema.maxLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (typeDef === 'text') {
|
|
108
|
-
if (target.$language && valueType === 'string') {
|
|
109
|
-
if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
|
|
110
|
-
throw new Error(`${value} is smaller then minLength "${fieldSchema.minLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
111
|
-
}
|
|
112
|
-
if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
|
|
113
|
-
throw new Error(`${value} is larger then maxLength "${fieldSchema.maxLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
114
|
-
}
|
|
115
|
-
collect(path, { [target.$language]: value }, typeSchema, fieldSchema, target);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (valueType !== 'object') {
|
|
119
|
-
throw new Error(`${value} is not a language object "${path.join('.')}" on type "${target.type}"`);
|
|
120
|
-
}
|
|
121
|
-
for (const key in value) {
|
|
122
|
-
if (fieldSchema.minLength &&
|
|
123
|
-
value[key].length < fieldSchema.minLength) {
|
|
124
|
-
throw new Error(`${value[key]} is smaller then minLength "${fieldSchema.minLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
125
|
-
}
|
|
126
|
-
if (fieldSchema.maxLength &&
|
|
127
|
-
value[key].length > fieldSchema.maxLength) {
|
|
128
|
-
throw new Error(`${value[key]} is larger then maxLength "${fieldSchema.maxLength}" "${path.join('.')}" on type "${target.type}"`);
|
|
129
|
-
}
|
|
130
|
-
if (typeof value[key] === 'object' && value[key].$delete === true) {
|
|
131
|
-
collect([...path, key], null, typeSchema, fieldSchema, target);
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (typeof value[key] !== 'string') {
|
|
135
|
-
throw new Error(`${value} is not a string "${[...path, key].join('.')}" on type "${target.type}"`);
|
|
136
|
-
}
|
|
137
|
-
collect([...path, key], value[key], typeSchema, fieldSchema, target);
|
|
138
|
-
}
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
collect(path, value, typeSchema, fieldSchema, target);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const setWalker = (schema, value, collect) => {
|
|
146
|
-
let type;
|
|
147
|
-
if (value.$id) {
|
|
148
|
-
type = schema.prefixToTypeMapping[value.$id.slice(0, 2)];
|
|
149
|
-
if (!type) {
|
|
150
|
-
throw new Error(`Cannot find type for $id ${value.$id}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (value.type) {
|
|
154
|
-
if (type && value.type !== type) {
|
|
155
|
-
throw new Error(`type from "$id" ${value.$id} does not match "type" field ${value.type}`);
|
|
156
|
-
}
|
|
157
|
-
type = value.type;
|
|
158
|
-
}
|
|
159
|
-
const schemaType = schema.types[type];
|
|
160
|
-
if (!schemaType) {
|
|
161
|
-
throw new Error(`Cannot find schema definition for type ${type}`);
|
|
162
|
-
}
|
|
163
|
-
const target = {
|
|
164
|
-
type,
|
|
165
|
-
};
|
|
166
|
-
if (value.$id) {
|
|
167
|
-
target.$id = value.$id;
|
|
168
|
-
}
|
|
169
|
-
else if (value.$alias) {
|
|
170
|
-
target.$alias = value.$alias;
|
|
171
|
-
}
|
|
172
|
-
for (const key in value) {
|
|
173
|
-
if (key[0] === '$') {
|
|
174
|
-
console.info('key is operator', key);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
const fieldSchema = schemaType.fields[key];
|
|
178
|
-
if (!fieldSchema) {
|
|
179
|
-
throw new Error(`Field does not exist in schema "${key}" on type "${type}"`);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
fieldWalker([key], value[key], fieldSchema, schemaType, target, collect);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return target;
|
|
187
|
-
};
|
|
188
|
-
exports.setWalker = setWalker;
|
|
189
|
-
//# sourceMappingURL=setWalker.js.map
|
package/dist/setWalker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setWalker.js","sourceRoot":"","sources":["../src/setWalker.ts"],"names":[],"mappings":";;;AAAA,mCAMgB;AAChB,wCAAwC;AAExC,oFAAoF;AACpF,0BAA0B;AAE1B,MAAM,WAAW,GAAG,CAClB,IAAyB,EACzB,KAAU,EACV,WAA6B,EAC7B,UAA2B,EAC3B,MAAc,EACd,OAMS,EACT,EAAE;IACF,IAAI,MAAM,IAAI,WAAW,EAAE;QACzB,6GAA6G;QAC7G,OAAM;KACP;IAED,MAAM,SAAS,GAAG,OAAO,KAAK,C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AAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAErC,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAA;KAClE;IAED,MAAM,MAAM,GAAW;QACrB,IAAI;KACL,CAAA;IAED,IAAI,KAAK,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;KACvB;SAAM,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;KAC7B;IAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;QACvB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;SACrC;aAAM;YACL,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC1C,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,IAAI,KAAK,CACb,mCAAmC,GAAG,cAAc,IAAI,GAAG,CAC5D,CAAA;aACF;iBAAM;gBACL,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;aACzE;SACF;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA7DY,QAAA,SAAS,aA6DrB"}
|
package/dist/transformers.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaPartial, BasedSchemaTypePartial } from './types';
|
|
2
|
-
export declare const transformField: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
|
3
|
-
export declare const transformType: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
package/dist/transformers.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformType = exports.transformField = void 0;
|
|
4
|
-
const transformField = (fromSchema, typeName, type) => {
|
|
5
|
-
if (type.prefix &&
|
|
6
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
7
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.transformField = transformField;
|
|
11
|
-
const transformType = (fromSchema, typeName, type) => {
|
|
12
|
-
if (type.prefix &&
|
|
13
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
14
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.transformType = transformType;
|
|
18
|
-
//# sourceMappingURL=transformers.js.map
|
package/dist/transformers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":";;;AAOO,MAAM,cAAc,GAAG,CAC5B,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAEM,MAAM,aAAa,GAAG,CAC3B,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,aAAa,iBAazB"}
|
package/dist/typeWalker.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaPartial, BasedSchemaTypePartial } from './types';
|
|
2
|
-
export declare const transformField: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
|
3
|
-
export declare const transformType: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
package/dist/typeWalker.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformType = exports.transformField = void 0;
|
|
4
|
-
const transformField = (fromSchema, typeName, type) => {
|
|
5
|
-
if (type.prefix &&
|
|
6
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
7
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.transformField = transformField;
|
|
11
|
-
const transformType = (fromSchema, typeName, type) => {
|
|
12
|
-
if (type.prefix &&
|
|
13
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
14
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.transformType = transformType;
|
|
18
|
-
//# sourceMappingURL=typeWalker.js.map
|
package/dist/typeWalker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeWalker.js","sourceRoot":"","sources":["../src/typeWalker.ts"],"names":[],"mappings":";;;AAOO,MAAM,cAAc,GAAG,CAC5B,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAEM,MAAM,aAAa,GAAG,CAC3B,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,aAAa,iBAazB"}
|
package/dist/validate.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaPartial, BasedSchemaFieldPartial, BasedSchemaTypePartial } from './types';
|
|
2
|
-
export declare const parseType: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
|
3
|
-
export declare const parseField: (fromSchema: BasedSchemaPartial, path: string[], field: BasedSchemaFieldPartial) => void;
|
|
4
|
-
export declare const validateSchema: (schema: BasedSchemaPartial) => BasedSchemaPartial;
|
package/dist/validate.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSchema = exports.parseField = exports.parseType = void 0;
|
|
4
|
-
const parseType = (fromSchema, typeName, type) => {
|
|
5
|
-
if (type.prefix &&
|
|
6
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
7
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.parseType = parseType;
|
|
11
|
-
const parseField = (fromSchema, path, field) => { };
|
|
12
|
-
exports.parseField = parseField;
|
|
13
|
-
const validateSchema = (schema) => {
|
|
14
|
-
// rewrite schema things like required / required: []
|
|
15
|
-
if (typeof schema !== 'object') {
|
|
16
|
-
throw new Error('Schema is not an object');
|
|
17
|
-
}
|
|
18
|
-
if (schema.languages && !Array.isArray(schema.languages)) {
|
|
19
|
-
throw new Error('Languages needs to be an array');
|
|
20
|
-
}
|
|
21
|
-
if (schema.$defs) {
|
|
22
|
-
// first defs ofc
|
|
23
|
-
}
|
|
24
|
-
if (schema.root) {
|
|
25
|
-
}
|
|
26
|
-
if (schema.types) {
|
|
27
|
-
for (const type in schema.types) {
|
|
28
|
-
(0, exports.parseType)(schema, type, schema.types[type]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return schema;
|
|
32
|
-
};
|
|
33
|
-
exports.validateSchema = validateSchema;
|
|
34
|
-
//# sourceMappingURL=validate.js.map
|
package/dist/validate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":";;;AAOO,MAAM,SAAS,GAAG,CACvB,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,SAAS,aAarB;AAEM,MAAM,UAAU,GAAG,CACxB,UAA8B,EAC9B,IAAc,EACd,KAA8B,EAC9B,EAAE,GAAE,CAAC,CAAA;AAJM,QAAA,UAAU,cAIhB;AAEA,MAAM,cAAc,GAAG,CAC5B,MAA0B,EACN,EAAE;IACtB,qDAAqD;IAErD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;KAC3C;IAED,IAAI,MAAM,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;QACxD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,iBAAiB;KAClB;IAED,IAAI,MAAM,CAAC,IAAI,EAAE;KAChB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE;YAC/B,IAAA,iBAAS,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;SAC5C;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA3BY,QAAA,cAAc,kBA2B1B"}
|
package/dist/validateFields.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaPartial, BasedSchemaFieldPartial, BasedSchemaTypePartial } from './types';
|
|
2
|
-
export declare const parseType: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
|
3
|
-
export declare const parseField: (fromSchema: BasedSchemaPartial, path: string[], field: BasedSchemaFieldPartial) => void;
|
|
4
|
-
export declare const validateSchema: (schema: BasedSchemaPartial) => BasedSchemaPartial;
|
package/dist/validateFields.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSchema = exports.parseField = exports.parseType = void 0;
|
|
4
|
-
const parseType = (fromSchema, typeName, type) => {
|
|
5
|
-
if (type.prefix &&
|
|
6
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
7
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.parseType = parseType;
|
|
11
|
-
const parseField = (fromSchema, path, field) => { };
|
|
12
|
-
exports.parseField = parseField;
|
|
13
|
-
const validateSchema = (schema) => {
|
|
14
|
-
// rewrite schema things like required / required: []
|
|
15
|
-
if (typeof schema !== 'object') {
|
|
16
|
-
throw new Error('Schema is not an object');
|
|
17
|
-
}
|
|
18
|
-
if (schema.languages && !Array.isArray(schema.languages)) {
|
|
19
|
-
throw new Error('Languages needs to be an array');
|
|
20
|
-
}
|
|
21
|
-
if (schema.$defs) {
|
|
22
|
-
// first defs ofc
|
|
23
|
-
}
|
|
24
|
-
if (schema.root) {
|
|
25
|
-
}
|
|
26
|
-
if (schema.types) {
|
|
27
|
-
for (const type in schema.types) {
|
|
28
|
-
(0, exports.parseType)(schema, type, schema.types[type]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return schema;
|
|
32
|
-
};
|
|
33
|
-
exports.validateSchema = validateSchema;
|
|
34
|
-
//# sourceMappingURL=validateFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateFields.js","sourceRoot":"","sources":["../src/validateFields.ts"],"names":[],"mappings":";;;AAOO,MAAM,SAAS,GAAG,CACvB,UAA8B,EAC9B,QAAgB,EAChB,IAA4B,EAC5B,EAAE;IACF,IACE,IAAI,CAAC,MAAM;QACX,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,EAC7D;QACA,MAAM,IAAI,KAAK,CACb,qBAAqB,IAAI,CAAC,MAAM,eAAe,QAAQ,iFAAiF,CACzI,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,SAAS,aAarB;AAEM,MAAM,UAAU,GAAG,CACxB,UAA8B,EAC9B,IAAc,EACd,KAA8B,EAC9B,EAAE,GAAE,CAAC,CAAA;AAJM,QAAA,UAAU,cAIhB;AAEA,MAAM,cAAc,GAAG,CAC5B,MAA0B,EACN,EAAE;IACtB,qDAAqD;IAErD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;KAC3C;IAED,IAAI,MAAM,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;QACxD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,iBAAiB;KAClB;IAED,IAAI,MAAM,CAAC,IAAI,EAAE;KAChB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE;YAC/B,IAAA,iBAAS,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;SAC5C;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA3BY,QAAA,cAAc,kBA2B1B"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BasedSchemaPartial, BasedSchemaFieldPartial, BasedSchemaTypePartial } from './types';
|
|
2
|
-
export declare const parseType: (fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
|
|
3
|
-
export declare const parseField: (fromSchema: BasedSchemaPartial, path: string[], field: BasedSchemaFieldPartial) => void;
|
|
4
|
-
export declare const validateSchema: (schema: BasedSchemaPartial) => BasedSchemaPartial;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateSchema = exports.parseField = exports.parseType = void 0;
|
|
4
|
-
const parseType = (fromSchema, typeName, type) => {
|
|
5
|
-
if (type.prefix &&
|
|
6
|
-
(typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
|
|
7
|
-
throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.parseType = parseType;
|
|
11
|
-
const parseField = (fromSchema, path, field) => { };
|
|
12
|
-
exports.parseField = parseField;
|
|
13
|
-
const validateSchema = (schema) => {
|
|
14
|
-
// rewrite schema things like required / required: []
|
|
15
|
-
if (typeof schema !== 'object') {
|
|
16
|
-
throw new Error('Schema is not an object');
|
|
17
|
-
}
|
|
18
|
-
if (schema.languages && !Array.isArray(schema.languages)) {
|
|
19
|
-
throw new Error('Languages needs to be an array');
|
|
20
|
-
}
|
|
21
|
-
if (schema.$defs) {
|
|
22
|
-
// first defs ofc
|
|
23
|
-
}
|
|
24
|
-
if (schema.root) {
|
|
25
|
-
}
|
|
26
|
-
if (schema.types) {
|
|
27
|
-
for (const type in schema.types) {
|
|
28
|
-
(0, exports.parseType)(schema, type, schema.types[type]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return schema;
|
|
32
|
-
};
|
|
33
|
-
exports.validateSchema = validateSchema;
|
|
34
|
-
//# sourceMappingURL=validateSchema%20copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateSchema copy.js","sour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,15 +0,0 @@
|
|
|
1
|
-
export const createError = (
|
|
2
|
-
path: (number | string)[],
|
|
3
|
-
fromType: string,
|
|
4
|
-
fieldType: string,
|
|
5
|
-
value: any,
|
|
6
|
-
fieldDoesNotExist?: string,
|
|
7
|
-
msg?: string
|
|
8
|
-
): Error => {
|
|
9
|
-
const err = new Error()
|
|
10
|
-
return new Error(
|
|
11
|
-
`Type: "${fromType}" Field: "${path.join(
|
|
12
|
-
'.'
|
|
13
|
-
)}" is not a valid value for ${fieldType}`
|
|
14
|
-
)
|
|
15
|
-
}
|