@kravc/schema 2.8.0-alpha.3 → 2.8.0-alpha.5
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/Schema.d.ts +7 -6
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Schema.ts +8 -6
- package/src/index.ts +2 -1
package/dist/Schema.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type LinkedDataType = {
|
|
|
39
39
|
'@id': string;
|
|
40
40
|
'@context': LinkedDataContext;
|
|
41
41
|
};
|
|
42
|
+
export type SchemaSource = EnumSchema | PropertiesSchema;
|
|
42
43
|
/**
|
|
43
44
|
* Schema class for defining and manipulating JSON schemas for object validation.
|
|
44
45
|
*
|
|
@@ -126,7 +127,7 @@ declare class Schema {
|
|
|
126
127
|
* // Automatically creates linkedDataType with @id and @context
|
|
127
128
|
* ```
|
|
128
129
|
*/
|
|
129
|
-
constructor(propertiesOrSchema:
|
|
130
|
+
constructor(propertiesOrSchema: Schema | SchemaSource, id?: string, url?: string);
|
|
130
131
|
/**
|
|
131
132
|
* Returns the unique identifier for this schema.
|
|
132
133
|
*
|
|
@@ -300,7 +301,7 @@ declare class Schema {
|
|
|
300
301
|
* // Both schemas have identical properties but different IDs
|
|
301
302
|
* ```
|
|
302
303
|
*/
|
|
303
|
-
clone(id
|
|
304
|
+
clone(id?: string): Schema;
|
|
304
305
|
/**
|
|
305
306
|
* Creates a schema clone without required constraints and default values.
|
|
306
307
|
*
|
|
@@ -329,7 +330,7 @@ declare class Schema {
|
|
|
329
330
|
* // All fields are optional for updates
|
|
330
331
|
* ```
|
|
331
332
|
*/
|
|
332
|
-
pure(id
|
|
333
|
+
pure(id?: string): Schema;
|
|
333
334
|
/**
|
|
334
335
|
* Creates a schema clone containing only the specified properties.
|
|
335
336
|
*
|
|
@@ -361,7 +362,7 @@ declare class Schema {
|
|
|
361
362
|
* // publicSchema only contains name and email, hiding sensitive fields
|
|
362
363
|
* ```
|
|
363
364
|
*/
|
|
364
|
-
only(propertyNames: string[], id
|
|
365
|
+
only(propertyNames: string[], id?: string): Schema;
|
|
365
366
|
/**
|
|
366
367
|
* Creates a schema clone extended with additional properties.
|
|
367
368
|
*
|
|
@@ -395,7 +396,7 @@ declare class Schema {
|
|
|
395
396
|
* // userSchema contains id, createdAt, name, and email
|
|
396
397
|
* ```
|
|
397
398
|
*/
|
|
398
|
-
extend(properties: PropertiesSchema, id
|
|
399
|
+
extend(properties: PropertiesSchema, id?: string): Schema;
|
|
399
400
|
/**
|
|
400
401
|
* Creates a new schema that wraps the current schema as a nested property.
|
|
401
402
|
*
|
|
@@ -442,7 +443,7 @@ declare class Schema {
|
|
|
442
443
|
wrap(propertyName: string, attributes: {
|
|
443
444
|
default?: string;
|
|
444
445
|
required?: boolean;
|
|
445
|
-
}, id
|
|
446
|
+
}, id?: string): Schema;
|
|
446
447
|
}
|
|
447
448
|
export default Schema;
|
|
448
449
|
//# sourceMappingURL=Schema.d.ts.map
|
package/dist/Schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,cAAM,MAAM;IACV,OAA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,MAAM,YAET;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,IAAI,UAAU,IAAI,UAAU,CAiB3B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,cAAc,+BAEjB;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM;IAIjB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM;IAahB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM;IASzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC,EAAE,MAAM;IAQhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAAE,EAAE,EAAE,CAAC,EAAE,MAAM;CAe9F;AAED,eAAe,MAAM,CAAC"}
|
package/dist/Schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../src/Schema.ts"],"names":[],"mappings":";;;;;AAAA,mCAAyC;AAEzC,sEAA8C;AAC9C,oFAA4D;AAC5D,wFAAgE;AAChE,qFAA6D;AAC7D,kGAA0E;AAS1E,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../src/Schema.ts"],"names":[],"mappings":";;;;;AAAA,mCAAyC;AAEzC,sEAA8C;AAC9C,oFAA4D;AAC5D,wFAAgE;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AC;IAC3D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,IAAI,CAAC,YAAoB,EAAE,UAAqD,EAAE,EAAW;QAC3F,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,MAAM,MAAM,GAAG;YACb,CAAC,YAAY,CAAC,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,IAAI,CAAC,MAAM;gBACvB,GAAG,CAAC,UAAU,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;aACtC;SACkB,CAAC;QAEtB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;CACF;AAED,kBAAe,MAAM,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import got from './helpers/got';
|
|
2
|
-
import Schema from './Schema';
|
|
3
2
|
import Validator from './Validator';
|
|
4
3
|
import documentLoader from './ld/documentLoader';
|
|
5
4
|
import CredentialFactory from './CredentialFactory';
|
|
5
|
+
import Schema, { type SchemaSource } from './Schema';
|
|
6
6
|
import createSchemasMap, { loadSync } from './helpers/createSchemasMap';
|
|
7
7
|
import ValidationError, { type ValidationErrorOutput } from './ValidationError';
|
|
8
8
|
export { got, Schema, loadSync, Validator, documentLoader, ValidationError, createSchemasMap, CredentialFactory };
|
|
9
|
-
export type { ValidationErrorOutput, };
|
|
9
|
+
export type { SchemaSource, ValidationErrorOutput, };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,MAAM,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,eAAe,EAAE,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EACL,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EAClB,CAAC;AAEF,YAAY,EACV,YAAY,EACZ,qBAAqB,GACtB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -39,14 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.CredentialFactory = exports.createSchemasMap = exports.ValidationError = exports.documentLoader = exports.Validator = exports.loadSync = exports.Schema = exports.got = void 0;
|
|
40
40
|
const got_1 = __importDefault(require("./helpers/got"));
|
|
41
41
|
exports.got = got_1.default;
|
|
42
|
-
const Schema_1 = __importDefault(require("./Schema"));
|
|
43
|
-
exports.Schema = Schema_1.default;
|
|
44
42
|
const Validator_1 = __importDefault(require("./Validator"));
|
|
45
43
|
exports.Validator = Validator_1.default;
|
|
46
44
|
const documentLoader_1 = __importDefault(require("./ld/documentLoader"));
|
|
47
45
|
exports.documentLoader = documentLoader_1.default;
|
|
48
46
|
const CredentialFactory_1 = __importDefault(require("./CredentialFactory"));
|
|
49
47
|
exports.CredentialFactory = CredentialFactory_1.default;
|
|
48
|
+
const Schema_1 = __importDefault(require("./Schema"));
|
|
49
|
+
exports.Schema = Schema_1.default;
|
|
50
50
|
const createSchemasMap_1 = __importStar(require("./helpers/createSchemasMap"));
|
|
51
51
|
exports.createSchemasMap = createSchemasMap_1.default;
|
|
52
52
|
Object.defineProperty(exports, "loadSync", { enumerable: true, get: function () { return createSchemasMap_1.loadSync; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAgC;AAS9B,cATK,aAAG,CASL;AARL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAgC;AAS9B,cATK,aAAG,CASL;AARL,4DAAoC;AAWlC,oBAXK,mBAAS,CAWL;AAVX,yEAAiD;AAW/C,yBAXK,wBAAc,CAWL;AAVhB,4EAAoD;AAalD,4BAbK,2BAAiB,CAaL;AAZnB,sDAAqD;AAMnD,iBANK,gBAAM,CAML;AALR,+EAAwE;AAUtE,2BAVK,0BAAgB,CAUL;AAJhB,yFANyB,2BAAQ,OAMzB;AALV,wEAAgF;AAQ9E,0BARK,yBAAe,CAQL"}
|
package/package.json
CHANGED
package/src/Schema.ts
CHANGED
|
@@ -55,6 +55,8 @@ export type LinkedDataType = {
|
|
|
55
55
|
'@context': LinkedDataContext;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export type SchemaSource = EnumSchema | PropertiesSchema;
|
|
59
|
+
|
|
58
60
|
/**
|
|
59
61
|
* Schema class for defining and manipulating JSON schemas for object validation.
|
|
60
62
|
*
|
|
@@ -143,7 +145,7 @@ class Schema {
|
|
|
143
145
|
* // Automatically creates linkedDataType with @id and @context
|
|
144
146
|
* ```
|
|
145
147
|
*/
|
|
146
|
-
constructor(propertiesOrSchema:
|
|
148
|
+
constructor(propertiesOrSchema: Schema | SchemaSource, id?: string, url?: string) {
|
|
147
149
|
this._id = id || UNDEFINED_SCHEMA_ID;
|
|
148
150
|
|
|
149
151
|
this._url = url;
|
|
@@ -394,7 +396,7 @@ class Schema {
|
|
|
394
396
|
* // Both schemas have identical properties but different IDs
|
|
395
397
|
* ```
|
|
396
398
|
*/
|
|
397
|
-
clone(id
|
|
399
|
+
clone(id?: string) {
|
|
398
400
|
return new Schema(this.source, id);
|
|
399
401
|
}
|
|
400
402
|
|
|
@@ -426,7 +428,7 @@ class Schema {
|
|
|
426
428
|
* // All fields are optional for updates
|
|
427
429
|
* ```
|
|
428
430
|
*/
|
|
429
|
-
pure(id
|
|
431
|
+
pure(id?: string) {
|
|
430
432
|
if (this.isEnum) {
|
|
431
433
|
throw new Error('The "pure" method is not supported for enum schemas.');
|
|
432
434
|
}
|
|
@@ -470,7 +472,7 @@ class Schema {
|
|
|
470
472
|
* // publicSchema only contains name and email, hiding sensitive fields
|
|
471
473
|
* ```
|
|
472
474
|
*/
|
|
473
|
-
only(propertyNames: string[], id
|
|
475
|
+
only(propertyNames: string[], id?: string) {
|
|
474
476
|
if (this.isEnum) {
|
|
475
477
|
throw new Error('The "only" method is not supported for enum schemas.');
|
|
476
478
|
}
|
|
@@ -512,7 +514,7 @@ class Schema {
|
|
|
512
514
|
* // userSchema contains id, createdAt, name, and email
|
|
513
515
|
* ```
|
|
514
516
|
*/
|
|
515
|
-
extend(properties: PropertiesSchema, id
|
|
517
|
+
extend(properties: PropertiesSchema, id?: string) {
|
|
516
518
|
if (this.isEnum) {
|
|
517
519
|
throw new Error('The "extend" method is not supported for enum schemas.');
|
|
518
520
|
}
|
|
@@ -563,7 +565,7 @@ class Schema {
|
|
|
563
565
|
* // The 'data' property has a default value and is not required
|
|
564
566
|
* ```
|
|
565
567
|
*/
|
|
566
|
-
wrap(propertyName: string, attributes: { default?: string; required?: boolean; }, id
|
|
568
|
+
wrap(propertyName: string, attributes: { default?: string; required?: boolean; }, id?: string) {
|
|
567
569
|
if (this.isEnum) {
|
|
568
570
|
throw new Error('The "wrap" method is not supported for enum schemas.');
|
|
569
571
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import got from './helpers/got';
|
|
2
|
-
import Schema from './Schema';
|
|
3
2
|
import Validator from './Validator';
|
|
4
3
|
import documentLoader from './ld/documentLoader';
|
|
5
4
|
import CredentialFactory from './CredentialFactory';
|
|
5
|
+
import Schema, { type SchemaSource } from './Schema';
|
|
6
6
|
import createSchemasMap, { loadSync } from './helpers/createSchemasMap';
|
|
7
7
|
import ValidationError, { type ValidationErrorOutput } from './ValidationError';
|
|
8
8
|
|
|
@@ -18,5 +18,6 @@ export {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export type {
|
|
21
|
+
SchemaSource,
|
|
21
22
|
ValidationErrorOutput,
|
|
22
23
|
};
|