@xyo-network/core 2.21.12 → 2.21.13
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/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/SchemaNameValidator.d.ts +0 -73
- package/dist/cjs/SchemaNameValidator.js +0 -135
- package/dist/cjs/SchemaNameValidator.js.map +0 -1
- package/dist/esm/SchemaNameValidator.d.ts +0 -73
- package/dist/esm/SchemaNameValidator.js +0 -117
- package/dist/esm/SchemaNameValidator.js.map +0 -1
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -4,5 +4,4 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./Data"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./Hasher"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./SchemaNameValidator"), exports);
|
|
8
7
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,gDAAqB"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/sdk-js": "^2.5.9",
|
|
14
|
-
"@xyo-network/typeof": "^2.21.
|
|
14
|
+
"@xyo-network/typeof": "^2.21.13",
|
|
15
15
|
"axios": "^0.27.2",
|
|
16
16
|
"keccak256": "^1.0.6",
|
|
17
17
|
"lodash": "^4.17.21",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
},
|
|
57
57
|
"sideEffects": true,
|
|
58
58
|
"types": "dist/esm/index.d.ts",
|
|
59
|
-
"version": "2.21.
|
|
59
|
+
"version": "2.21.13",
|
|
60
60
|
"packageManager": "yarn@3.1.1"
|
|
61
61
|
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates a XYO schema structure and existence
|
|
3
|
-
*/
|
|
4
|
-
export declare class XyoSchemaNameValidator {
|
|
5
|
-
schema?: string;
|
|
6
|
-
constructor(schema?: string);
|
|
7
|
-
private _parts?;
|
|
8
|
-
/**
|
|
9
|
-
* The schema converted into a string array split on '.'
|
|
10
|
-
*
|
|
11
|
-
* @returns string[]
|
|
12
|
-
*/
|
|
13
|
-
get parts(): string[] | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Levels in the schema
|
|
16
|
-
*
|
|
17
|
-
* @returns number
|
|
18
|
-
*/
|
|
19
|
-
get levels(): number | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Checks whether the schema is all lowercase
|
|
22
|
-
*
|
|
23
|
-
* @returns boolean
|
|
24
|
-
*/
|
|
25
|
-
get isLowercase(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* Get a domain for the schema at a certain level
|
|
29
|
-
*
|
|
30
|
-
* @param level - Zero based level to check
|
|
31
|
-
* @returns string
|
|
32
|
-
*/
|
|
33
|
-
private domainLevel;
|
|
34
|
-
private _rootDomain?;
|
|
35
|
-
/**
|
|
36
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
37
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
38
|
-
* registration
|
|
39
|
-
*
|
|
40
|
-
* @returns string
|
|
41
|
-
*/
|
|
42
|
-
get rootDomain(): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the root domain validates via DNS resolution
|
|
45
|
-
*
|
|
46
|
-
* @returns boolean
|
|
47
|
-
*/
|
|
48
|
-
rootDomainExists(): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Determines how many levels of the schema's reverse domain
|
|
51
|
-
* pass DNS resolution
|
|
52
|
-
*
|
|
53
|
-
* @returns number (0 if none exist)
|
|
54
|
-
*/
|
|
55
|
-
domainExistanceDepth(): Promise<number>;
|
|
56
|
-
/**
|
|
57
|
-
* Run all the validations
|
|
58
|
-
* @param checkExistance - boolean
|
|
59
|
-
* @returns Error[]
|
|
60
|
-
*/
|
|
61
|
-
allDynamic(): Promise<Error[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Run all static validations
|
|
64
|
-
* @returns Error[]
|
|
65
|
-
*/
|
|
66
|
-
all(): Error[];
|
|
67
|
-
}
|
|
68
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
69
|
-
export declare class SchemaValidator extends XyoSchemaNameValidator {
|
|
70
|
-
}
|
|
71
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
72
|
-
export declare class XyoSchemaValidator extends XyoSchemaNameValidator {
|
|
73
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XyoSchemaValidator = exports.SchemaValidator = exports.XyoSchemaNameValidator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const lib_1 = require("./lib");
|
|
6
|
-
/**
|
|
7
|
-
* Validates a XYO schema structure and existence
|
|
8
|
-
*/
|
|
9
|
-
class XyoSchemaNameValidator {
|
|
10
|
-
constructor(schema) {
|
|
11
|
-
this.schema = schema;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The schema converted into a string array split on '.'
|
|
15
|
-
*
|
|
16
|
-
* @returns string[]
|
|
17
|
-
*/
|
|
18
|
-
get parts() {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
this._parts = (_a = this._parts) !== null && _a !== void 0 ? _a : (_b = this.schema) === null || _b === void 0 ? void 0 : _b.split('.');
|
|
21
|
-
return this._parts;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Levels in the schema
|
|
25
|
-
*
|
|
26
|
-
* @returns number
|
|
27
|
-
*/
|
|
28
|
-
get levels() {
|
|
29
|
-
var _a;
|
|
30
|
-
return (_a = this.parts) === null || _a === void 0 ? void 0 : _a.length;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Checks whether the schema is all lowercase
|
|
34
|
-
*
|
|
35
|
-
* @returns boolean
|
|
36
|
-
*/
|
|
37
|
-
get isLowercase() {
|
|
38
|
-
var _a;
|
|
39
|
-
return this.schema === ((_a = this.schema) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* Get a domain for the schema at a certain level
|
|
44
|
-
*
|
|
45
|
-
* @param level - Zero based level to check
|
|
46
|
-
* @returns string
|
|
47
|
-
*/
|
|
48
|
-
domainLevel(level) {
|
|
49
|
-
var _a;
|
|
50
|
-
return (_a = this.parts) === null || _a === void 0 ? void 0 : _a.slice(0, level + 1).reverse().join('.');
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
54
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
55
|
-
* registration
|
|
56
|
-
*
|
|
57
|
-
* @returns string
|
|
58
|
-
*/
|
|
59
|
-
get rootDomain() {
|
|
60
|
-
var _a;
|
|
61
|
-
this._rootDomain = (_a = this._rootDomain) !== null && _a !== void 0 ? _a : this.domainLevel(1);
|
|
62
|
-
return this._rootDomain;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Checks if the root domain validates via DNS resolution
|
|
66
|
-
*
|
|
67
|
-
* @returns boolean
|
|
68
|
-
*/
|
|
69
|
-
rootDomainExists() {
|
|
70
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
return yield (0, lib_1.domainExists)(this.rootDomain);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Determines how many levels of the schema's reverse domain
|
|
76
|
-
* pass DNS resolution
|
|
77
|
-
*
|
|
78
|
-
* @returns number (0 if none exist)
|
|
79
|
-
*/
|
|
80
|
-
domainExistanceDepth() {
|
|
81
|
-
var _a;
|
|
82
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const levels = (_a = this.levels) !== null && _a !== void 0 ? _a : 0;
|
|
84
|
-
let level = 0;
|
|
85
|
-
while (level < levels) {
|
|
86
|
-
if (!(yield (0, lib_1.domainExists)(this.domainLevel(level)))) {
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
level += 1;
|
|
90
|
-
}
|
|
91
|
-
return level;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Run all the validations
|
|
96
|
-
* @param checkExistance - boolean
|
|
97
|
-
* @returns Error[]
|
|
98
|
-
*/
|
|
99
|
-
allDynamic() {
|
|
100
|
-
var _a, _b;
|
|
101
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const errors = [];
|
|
103
|
-
if (((_b = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)
|
|
104
|
-
errors.push(Error('schema missing'));
|
|
105
|
-
else if (!(yield this.rootDomainExists()))
|
|
106
|
-
errors.push(Error(`schema root domain must exist [${this.rootDomain}]`));
|
|
107
|
-
return errors;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Run all static validations
|
|
112
|
-
* @returns Error[]
|
|
113
|
-
*/
|
|
114
|
-
all() {
|
|
115
|
-
var _a, _b, _c;
|
|
116
|
-
const errors = [];
|
|
117
|
-
if (((_b = (_a = this.schema) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)
|
|
118
|
-
errors.push(Error('schema missing'));
|
|
119
|
-
else if (((_c = this.levels) !== null && _c !== void 0 ? _c : 0) < 3)
|
|
120
|
-
errors.push(Error(`schema levels < 3 [${this.levels}, ${this.schema}]`));
|
|
121
|
-
else if (!this.isLowercase)
|
|
122
|
-
errors.push(Error(`schema not lowercase [${this.schema}]`));
|
|
123
|
-
return errors;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.XyoSchemaNameValidator = XyoSchemaNameValidator;
|
|
127
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
128
|
-
class SchemaValidator extends XyoSchemaNameValidator {
|
|
129
|
-
}
|
|
130
|
-
exports.SchemaValidator = SchemaValidator;
|
|
131
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
132
|
-
class XyoSchemaValidator extends XyoSchemaNameValidator {
|
|
133
|
-
}
|
|
134
|
-
exports.XyoSchemaValidator = XyoSchemaValidator;
|
|
135
|
-
//# sourceMappingURL=SchemaNameValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.js","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":";;;;AAAA,+BAAoC;AAEpC;;GAEG;AACH,MAAa,sBAAsB;IAEjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAID;;;;OAIG;IACH,IAAI,KAAK;;QACP,IAAI,CAAC,MAAM,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;;QACR,OAAO,MAAA,IAAI,CAAC,KAAK,0CAAE,MAAM,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;;QACb,OAAO,IAAI,CAAC,M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CAAC,IAAI,CAAC,KAAK,CAAC,kCAAkC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;YACnH,OAAO,MAAM,CAAA;;KACd;IAED;;;OAGG;IAEI,GAAG;;QACR,MAAM,MAAM,GAAY,EAAE,CAAA;QAC1B,IAAI,CAAC,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,mCAAI,CAAC,CAAC,KAAK,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;aACrE,IAAI,CAAC,MAAA,IAAI,CAAC,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;aACpG,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACvF,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AApHD,wDAoHC;AAED,sDAAsD;AACtD,MAAa,eAAgB,SAAQ,sBAAsB;CAAG;AAA9D,0CAA8D;AAE9D,sDAAsD;AACtD,MAAa,kBAAmB,SAAQ,sBAAsB;CAAG;AAAjE,gDAAiE"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates a XYO schema structure and existence
|
|
3
|
-
*/
|
|
4
|
-
export declare class XyoSchemaNameValidator {
|
|
5
|
-
schema?: string;
|
|
6
|
-
constructor(schema?: string);
|
|
7
|
-
private _parts?;
|
|
8
|
-
/**
|
|
9
|
-
* The schema converted into a string array split on '.'
|
|
10
|
-
*
|
|
11
|
-
* @returns string[]
|
|
12
|
-
*/
|
|
13
|
-
get parts(): string[] | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Levels in the schema
|
|
16
|
-
*
|
|
17
|
-
* @returns number
|
|
18
|
-
*/
|
|
19
|
-
get levels(): number | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Checks whether the schema is all lowercase
|
|
22
|
-
*
|
|
23
|
-
* @returns boolean
|
|
24
|
-
*/
|
|
25
|
-
get isLowercase(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* Get a domain for the schema at a certain level
|
|
29
|
-
*
|
|
30
|
-
* @param level - Zero based level to check
|
|
31
|
-
* @returns string
|
|
32
|
-
*/
|
|
33
|
-
private domainLevel;
|
|
34
|
-
private _rootDomain?;
|
|
35
|
-
/**
|
|
36
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
37
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
38
|
-
* registration
|
|
39
|
-
*
|
|
40
|
-
* @returns string
|
|
41
|
-
*/
|
|
42
|
-
get rootDomain(): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the root domain validates via DNS resolution
|
|
45
|
-
*
|
|
46
|
-
* @returns boolean
|
|
47
|
-
*/
|
|
48
|
-
rootDomainExists(): Promise<boolean>;
|
|
49
|
-
/**
|
|
50
|
-
* Determines how many levels of the schema's reverse domain
|
|
51
|
-
* pass DNS resolution
|
|
52
|
-
*
|
|
53
|
-
* @returns number (0 if none exist)
|
|
54
|
-
*/
|
|
55
|
-
domainExistanceDepth(): Promise<number>;
|
|
56
|
-
/**
|
|
57
|
-
* Run all the validations
|
|
58
|
-
* @param checkExistance - boolean
|
|
59
|
-
* @returns Error[]
|
|
60
|
-
*/
|
|
61
|
-
allDynamic(): Promise<Error[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Run all static validations
|
|
64
|
-
* @returns Error[]
|
|
65
|
-
*/
|
|
66
|
-
all(): Error[];
|
|
67
|
-
}
|
|
68
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
69
|
-
export declare class SchemaValidator extends XyoSchemaNameValidator {
|
|
70
|
-
}
|
|
71
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
72
|
-
export declare class XyoSchemaValidator extends XyoSchemaNameValidator {
|
|
73
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { domainExists } from './lib';
|
|
2
|
-
/**
|
|
3
|
-
* Validates a XYO schema structure and existence
|
|
4
|
-
*/
|
|
5
|
-
export class XyoSchemaNameValidator {
|
|
6
|
-
constructor(schema) {
|
|
7
|
-
this.schema = schema;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The schema converted into a string array split on '.'
|
|
11
|
-
*
|
|
12
|
-
* @returns string[]
|
|
13
|
-
*/
|
|
14
|
-
get parts() {
|
|
15
|
-
this._parts = this._parts ?? this.schema?.split('.');
|
|
16
|
-
return this._parts;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Levels in the schema
|
|
20
|
-
*
|
|
21
|
-
* @returns number
|
|
22
|
-
*/
|
|
23
|
-
get levels() {
|
|
24
|
-
return this.parts?.length;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Checks whether the schema is all lowercase
|
|
28
|
-
*
|
|
29
|
-
* @returns boolean
|
|
30
|
-
*/
|
|
31
|
-
get isLowercase() {
|
|
32
|
-
return this.schema === this.schema?.toLowerCase();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* Get a domain for the schema at a certain level
|
|
37
|
-
*
|
|
38
|
-
* @param level - Zero based level to check
|
|
39
|
-
* @returns string
|
|
40
|
-
*/
|
|
41
|
-
domainLevel(level) {
|
|
42
|
-
return this.parts
|
|
43
|
-
?.slice(0, level + 1)
|
|
44
|
-
.reverse()
|
|
45
|
-
.join('.');
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The rootDomain is the first two levels of the schema, in reverse order
|
|
49
|
-
* This can be used to determine who 'owns' that schema, based on domain
|
|
50
|
-
* registration
|
|
51
|
-
*
|
|
52
|
-
* @returns string
|
|
53
|
-
*/
|
|
54
|
-
get rootDomain() {
|
|
55
|
-
this._rootDomain = this._rootDomain ?? this.domainLevel(1);
|
|
56
|
-
return this._rootDomain;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Checks if the root domain validates via DNS resolution
|
|
60
|
-
*
|
|
61
|
-
* @returns boolean
|
|
62
|
-
*/
|
|
63
|
-
async rootDomainExists() {
|
|
64
|
-
return await domainExists(this.rootDomain);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Determines how many levels of the schema's reverse domain
|
|
68
|
-
* pass DNS resolution
|
|
69
|
-
*
|
|
70
|
-
* @returns number (0 if none exist)
|
|
71
|
-
*/
|
|
72
|
-
async domainExistanceDepth() {
|
|
73
|
-
const levels = this.levels ?? 0;
|
|
74
|
-
let level = 0;
|
|
75
|
-
while (level < levels) {
|
|
76
|
-
if (!(await domainExists(this.domainLevel(level)))) {
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
level += 1;
|
|
80
|
-
}
|
|
81
|
-
return level;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Run all the validations
|
|
85
|
-
* @param checkExistance - boolean
|
|
86
|
-
* @returns Error[]
|
|
87
|
-
*/
|
|
88
|
-
async allDynamic() {
|
|
89
|
-
const errors = [];
|
|
90
|
-
if ((this.schema?.length ?? 0) === 0)
|
|
91
|
-
errors.push(Error('schema missing'));
|
|
92
|
-
else if (!(await this.rootDomainExists()))
|
|
93
|
-
errors.push(Error(`schema root domain must exist [${this.rootDomain}]`));
|
|
94
|
-
return errors;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Run all static validations
|
|
98
|
-
* @returns Error[]
|
|
99
|
-
*/
|
|
100
|
-
all() {
|
|
101
|
-
const errors = [];
|
|
102
|
-
if ((this.schema?.length ?? 0) === 0)
|
|
103
|
-
errors.push(Error('schema missing'));
|
|
104
|
-
else if ((this.levels ?? 0) < 3)
|
|
105
|
-
errors.push(Error(`schema levels < 3 [${this.levels}, ${this.schema}]`));
|
|
106
|
-
else if (!this.isLowercase)
|
|
107
|
-
errors.push(Error(`schema not lowercase [${this.schema}]`));
|
|
108
|
-
return errors;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
112
|
-
export class SchemaValidator extends XyoSchemaNameValidator {
|
|
113
|
-
}
|
|
114
|
-
/** @deprectated use XyoSchemaNameValidator instead */
|
|
115
|
-
export class XyoSchemaValidator extends XyoSchemaNameValidator {
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=SchemaNameValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaNameValidator.js","sourceRoot":"","sources":["../../src/SchemaNameValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAEjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAID;;;;OAIG;IACH,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IACnD,CAAC;IAED;;;;;;OAMG;IACK,WAAW,CAAC,KAAa;QAC/B,OAAO,IAAI,CAAC,KAAK;YACf,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;aACpB,OAAO,EAAE;aACT,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,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