@kravc/schema 2.8.0-alpha.6 → 2.8.0-alpha.8
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/CredentialFactory.d.ts +5 -318
- package/dist/CredentialFactory.d.ts.map +1 -1
- package/dist/CredentialFactory.js +5 -317
- package/dist/CredentialFactory.js.map +1 -1
- package/dist/Schema.d.ts +15 -420
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +13 -384
- package/dist/Schema.js.map +1 -1
- package/dist/ValidationError.d.ts +3 -49
- package/dist/ValidationError.d.ts.map +1 -1
- package/dist/ValidationError.js +3 -48
- package/dist/ValidationError.js.map +1 -1
- package/dist/Validator.d.ts +6 -470
- package/dist/Validator.d.ts.map +1 -1
- package/dist/Validator.js +50 -478
- package/dist/Validator.js.map +1 -1
- package/dist/helpers/cleanupAttributes.d.ts +3 -32
- package/dist/helpers/cleanupAttributes.d.ts.map +1 -1
- package/dist/helpers/cleanupAttributes.js +1 -30
- package/dist/helpers/cleanupAttributes.js.map +1 -1
- package/dist/helpers/cleanupNulls.d.ts +1 -25
- package/dist/helpers/cleanupNulls.d.ts.map +1 -1
- package/dist/helpers/cleanupNulls.js +2 -61
- package/dist/helpers/cleanupNulls.js.map +1 -1
- package/dist/helpers/createSchemasMap.d.ts +2 -93
- package/dist/helpers/createSchemasMap.d.ts.map +1 -1
- package/dist/helpers/createSchemasMap.js +4 -162
- package/dist/helpers/createSchemasMap.js.map +1 -1
- package/dist/helpers/getReferenceIds.d.ts +1 -165
- package/dist/helpers/getReferenceIds.d.ts.map +1 -1
- package/dist/helpers/getReferenceIds.js +2 -166
- package/dist/helpers/getReferenceIds.js.map +1 -1
- package/dist/helpers/got.d.ts +2 -58
- package/dist/helpers/got.d.ts.map +1 -1
- package/dist/helpers/got.js +1 -57
- package/dist/helpers/got.js.map +1 -1
- package/dist/helpers/mapObjectProperties.d.ts +2 -144
- package/dist/helpers/mapObjectProperties.d.ts.map +1 -1
- package/dist/helpers/mapObjectProperties.js +1 -142
- package/dist/helpers/mapObjectProperties.js.map +1 -1
- package/dist/helpers/normalizeAttributes.d.ts +3 -211
- package/dist/helpers/normalizeAttributes.d.ts.map +1 -1
- package/dist/helpers/normalizeAttributes.js +1 -209
- package/dist/helpers/normalizeAttributes.js.map +1 -1
- package/dist/helpers/normalizeProperties.d.ts +1 -165
- package/dist/helpers/normalizeProperties.d.ts.map +1 -1
- package/dist/helpers/normalizeProperties.js +1 -164
- package/dist/helpers/normalizeProperties.js.map +1 -1
- package/dist/helpers/normalizeRequired.d.ts +1 -153
- package/dist/helpers/normalizeRequired.d.ts.map +1 -1
- package/dist/helpers/normalizeRequired.js +0 -151
- package/dist/helpers/normalizeRequired.js.map +1 -1
- package/dist/helpers/normalizeType.d.ts +1 -77
- package/dist/helpers/normalizeType.d.ts.map +1 -1
- package/dist/helpers/normalizeType.js +11 -139
- package/dist/helpers/normalizeType.js.map +1 -1
- package/dist/helpers/nullifyEmptyValues.d.ts +1 -135
- package/dist/helpers/nullifyEmptyValues.d.ts.map +1 -1
- package/dist/helpers/nullifyEmptyValues.js +13 -143
- package/dist/helpers/nullifyEmptyValues.js.map +1 -1
- package/dist/helpers/removeRequiredAndDefault.d.ts +2 -102
- package/dist/helpers/removeRequiredAndDefault.d.ts.map +1 -1
- package/dist/helpers/removeRequiredAndDefault.js +1 -100
- package/dist/helpers/removeRequiredAndDefault.js.map +1 -1
- package/dist/helpers/validateId.d.ts +1 -36
- package/dist/helpers/validateId.d.ts.map +1 -1
- package/dist/helpers/validateId.js +1 -36
- package/dist/helpers/validateId.js.map +1 -1
- package/dist/ld/documentLoader.d.ts +1 -1
- package/dist/ld/documentLoader.d.ts.map +1 -1
- package/dist/ld/documentLoader.js +1 -1
- package/dist/ld/documentLoader.js.map +1 -1
- package/dist/ld/getLinkedDataAttributeType.d.ts +1 -1
- package/dist/ld/getLinkedDataAttributeType.d.ts.map +1 -1
- package/dist/ld/getLinkedDataAttributeType.js +1 -1
- package/dist/ld/getLinkedDataAttributeType.js.map +1 -1
- package/dist/ld/getLinkedDataContext.d.ts +1 -1
- package/dist/ld/getLinkedDataContext.d.ts.map +1 -1
- package/dist/ld/getLinkedDataContext.js +1 -1
- package/dist/ld/getLinkedDataContext.js.map +1 -1
- package/package.json +2 -2
- package/src/CredentialFactory.ts +5 -318
- package/src/Schema.ts +17 -427
- package/src/ValidationError.ts +5 -52
- package/src/Validator.ts +19 -483
- package/src/__tests__/CredentialFactory.test.ts +1 -1
- package/src/__tests__/Schema.test.ts +3 -8
- package/src/__tests__/ValidationError.test.ts +4 -2
- package/src/__tests__/Validator.test.ts +21 -4
- package/src/helpers/__tests__/cleanupAttributes.test.ts +3 -1
- package/src/helpers/__tests__/createSchemasMap.test.ts +1 -1
- package/src/helpers/__tests__/mapObjectProperties.test.ts +2 -1
- package/src/helpers/__tests__/normalizeAttributes.test.ts +4 -2
- package/src/helpers/__tests__/normalizeProperties.test.ts +3 -1
- package/src/helpers/__tests__/normalizeRequired.test.ts +4 -9
- package/src/helpers/__tests__/nullifyEmptyValues.test.ts +43 -12
- package/src/helpers/__tests__/removeRequiredAndDefault.test.ts +3 -10
- package/src/helpers/cleanupAttributes.ts +6 -44
- package/src/helpers/cleanupNulls.ts +2 -63
- package/src/helpers/createSchemasMap.ts +4 -163
- package/src/helpers/getReferenceIds.ts +2 -173
- package/src/helpers/got.ts +3 -59
- package/src/helpers/mapObjectProperties.ts +4 -156
- package/src/helpers/normalizeAttributes.ts +7 -211
- package/src/helpers/normalizeProperties.ts +1 -172
- package/src/helpers/normalizeRequired.ts +1 -161
- package/src/helpers/normalizeType.ts +11 -139
- package/src/helpers/nullifyEmptyValues.ts +10 -145
- package/src/helpers/removeRequiredAndDefault.ts +1 -106
- package/src/helpers/validateId.ts +1 -36
- package/src/ld/documentLoader.ts +1 -1
- package/src/ld/getLinkedDataAttributeType.ts +1 -1
- package/src/ld/getLinkedDataContext.ts +1 -1
- package/src/{helpers/JsonSchema.ts → types.d.ts} +12 -16
- package/dist/helpers/JsonSchema.d.ts +0 -99
- package/dist/helpers/JsonSchema.d.ts.map +0 -1
- package/dist/helpers/JsonSchema.js +0 -3
- package/dist/helpers/JsonSchema.js.map +0 -1
|
@@ -1,105 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Recursively removes `required` and `default` attributes from a JSON schema.
|
|
5
|
-
*
|
|
6
|
-
* **Intent:**
|
|
7
|
-
* This function is designed to transform JSON schemas by stripping out validation
|
|
8
|
-
* constraints (`required`) and default values (`default`) from all properties,
|
|
9
|
-
* including nested objects and array items. This is useful for creating "pure"
|
|
10
|
-
* or "update-friendly" versions of schemas where all fields become optional and
|
|
11
|
-
* no defaults are applied.
|
|
12
|
-
*
|
|
13
|
-
* **Use Cases:**
|
|
14
|
-
* 1. **Update Schemas**: Create schemas for partial updates where all fields are optional
|
|
15
|
-
* 2. **Schema Transformation**: Prepare schemas for contexts where required/default
|
|
16
|
-
* constraints are not needed (e.g., credential generation, API transformations)
|
|
17
|
-
* 3. **Schema Normalization**: Remove validation metadata before further processing
|
|
18
|
-
*
|
|
19
|
-
* **Behavior:**
|
|
20
|
-
* - Mutates the input schema in-place by deleting `required` and `default` properties
|
|
21
|
-
* - Recursively processes nested object properties
|
|
22
|
-
* - Recursively processes array items (including nested objects within arrays)
|
|
23
|
-
* - Preserves all other schema properties (type, description, pattern, etc.)
|
|
24
|
-
* - Returns an object containing only the `properties` field
|
|
25
|
-
*
|
|
26
|
-
* **Examples:**
|
|
27
|
-
*
|
|
28
|
-
* ```typescript
|
|
29
|
-
* // Example 1: Simple object schema
|
|
30
|
-
* const schema = {
|
|
31
|
-
* type: 'object',
|
|
32
|
-
* properties: {
|
|
33
|
-
* name: { type: 'string', required: true, default: 'John' },
|
|
34
|
-
* age: { type: 'number', required: false, default: 0 }
|
|
35
|
-
* }
|
|
36
|
-
* };
|
|
37
|
-
*
|
|
38
|
-
* const result = removeRequiredAndDefault(schema);
|
|
39
|
-
* // result.properties.name: { type: 'string' } (required and default removed)
|
|
40
|
-
* // result.properties.age: { type: 'number' } (required and default removed)
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* ```typescript
|
|
44
|
-
* // Example 2: Nested objects
|
|
45
|
-
* const schema = {
|
|
46
|
-
* type: 'object',
|
|
47
|
-
* properties: {
|
|
48
|
-
* user: {
|
|
49
|
-
* type: 'object',
|
|
50
|
-
* required: true,
|
|
51
|
-
* default: {},
|
|
52
|
-
* properties: {
|
|
53
|
-
* name: { type: 'string', required: true, default: 'John' },
|
|
54
|
-
* address: {
|
|
55
|
-
* type: 'object',
|
|
56
|
-
* properties: {
|
|
57
|
-
* street: { type: 'string', required: true, default: '' }
|
|
58
|
-
* }
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* }
|
|
63
|
-
* };
|
|
64
|
-
*
|
|
65
|
-
* const result = removeRequiredAndDefault(schema);
|
|
66
|
-
* // All required and default attributes are removed at all nesting levels
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // Example 3: Arrays with object items
|
|
71
|
-
* const schema = {
|
|
72
|
-
* type: 'object',
|
|
73
|
-
* properties: {
|
|
74
|
-
* users: {
|
|
75
|
-
* type: 'array',
|
|
76
|
-
* required: true,
|
|
77
|
-
* default: [],
|
|
78
|
-
* items: {
|
|
79
|
-
* type: 'object',
|
|
80
|
-
* properties: {
|
|
81
|
-
* name: { type: 'string', required: true, default: 'John' }
|
|
82
|
-
* }
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
* }
|
|
86
|
-
* };
|
|
87
|
-
*
|
|
88
|
-
* const result = removeRequiredAndDefault(schema);
|
|
89
|
-
* // Removes required/default from array property and nested object properties
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* **Limitations:**
|
|
93
|
-
* - Only processes schemas with a `properties` field (ObjectPropertySchema)
|
|
94
|
-
* - EnumSchema is accepted as a parameter but not processed (will return empty properties)
|
|
95
|
-
* - The function mutates the input schema object
|
|
96
|
-
* - Array items that are primitives (string, number, etc.) are processed but
|
|
97
|
-
* their return values are discarded (this is intentional)
|
|
98
|
-
*
|
|
99
|
-
* @param jsonSchema - The JSON schema to process (must have a `properties` field)
|
|
100
|
-
* @returns An object containing only the `properties` field with all `required`
|
|
101
|
-
* and `default` attributes removed recursively
|
|
102
|
-
*/
|
|
3
|
+
/** Recursively removes `required` and `default` attributes from a JSON schema. */
|
|
103
4
|
const removeRequiredAndDefault = (jsonSchema) => {
|
|
104
5
|
const { properties } = jsonSchema;
|
|
105
6
|
if (!properties) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeRequiredAndDefault.js","sourceRoot":"","sources":["../../src/helpers/removeRequiredAndDefault.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"removeRequiredAndDefault.js","sourceRoot":"","sources":["../../src/helpers/removeRequiredAndDefault.ts"],"names":[],"mappings":";;AACA,kFAAkF;AAClF,MAAM,wBAAwB,GAAG,CAAC,UAAuC,EAAE,EAAE;IAC3E,MAAM,EAAE,UAAU,EAAE,GAAI,UAAmC,CAAC;IAE5D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAEvC,uDAAuD;QACvD,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACzB,OAAO,QAAQ,CAAC,OAAO,CAAC;QAExB,8DAA8D;QAC9D,MAAM,EAAE,IAAI,EAAE,GAAI,QAAuD,CAAC;QAE1E,MAAM,QAAQ,GAAG,IAAI,KAAK,QAAQ,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,KAAK,OAAO,CAAC;QAEjC,IAAI,QAAQ,EAAE,CAAC;YACb,+CAA+C;YAC/C,wBAAwB,CAAC,QAAgC,CAAC,CAAC;YAC3D,SAAS;QACX,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,EAAE,KAAK,EAAE,GAAI,QAAgC,CAAC;YACpD,IAAI,KAAK,EAAE,CAAC;gBACV,kCAAkC;gBAClC,yEAAyE;gBACzE,uEAAuE;gBACvE,0DAA0D;gBAC1D,wBAAwB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,8EAA8E;QAC9E,kCAAkC;IACpC,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC"}
|
|
@@ -1,39 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates that a value is a URL or a DID (Decentralized Identifier).
|
|
3
|
-
* Throws if the value is missing, null, undefined, or not a valid URL/DID.
|
|
4
|
-
*
|
|
5
|
-
* **Intent**
|
|
6
|
-
* Enforce that identifier-style parameters (schema IDs, credential IDs, subject
|
|
7
|
-
* references, etc.) are either resolvable URLs or W3C DIDs before they are used
|
|
8
|
-
* in Linked Data or verification flows. This prevents malformed or arbitrary
|
|
9
|
-
* strings from propagating into storage, APIs, or cryptographic operations.
|
|
10
|
-
*
|
|
11
|
-
* **Use cases**
|
|
12
|
-
* - Validating `schemaId`, `credentialId`, or similar parameters in credential
|
|
13
|
-
* and schema factories before creating or resolving documents.
|
|
14
|
-
* - Input validation for APIs that accept URI identifiers (e.g. fetch by ID).
|
|
15
|
-
* - Guarding helpers that resolve or dereference IDs (e.g. document loaders,
|
|
16
|
-
* schema registries) from invalid input.
|
|
17
|
-
*
|
|
18
|
-
* **Examples**
|
|
19
|
-
*
|
|
20
|
-
* Valid — URLs:
|
|
21
|
-
* validateId('schemaId', 'https://example.com/schemas/v1');
|
|
22
|
-
* validateId('id', 'http://example.com:8080/path?q=1');
|
|
23
|
-
*
|
|
24
|
-
* Valid — DIDs (case-insensitive `did:` prefix):
|
|
25
|
-
* validateId('subject', 'did:example:123456789');
|
|
26
|
-
* validateId('subject', 'did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK');
|
|
27
|
-
*
|
|
28
|
-
* Throws — missing or invalid:
|
|
29
|
-
* validateId('id', ''); // Error: Parameter "id" is required
|
|
30
|
-
* validateId('id', null); // Error: Parameter "id" is required
|
|
31
|
-
* validateId('id', 'not-a-uri'); // Error: Parameter "id" must be a URL, received: "not-a-uri"
|
|
32
|
-
*
|
|
33
|
-
* @param name - Parameter name used in error messages (e.g. `"schemaId"`, `"credentialId"`).
|
|
34
|
-
* @param value - The value to validate (`string`, `null`, or `undefined`).
|
|
35
|
-
* @throws {Error} When `value` is falsy, or when it is not a URL and does not start with `did:`.
|
|
36
|
-
*/
|
|
1
|
+
/** Validates that a value is a URL or a DID (Decentralized Identifier). */
|
|
37
2
|
declare const validateId: (name: string, value: string | null | undefined) => void;
|
|
38
3
|
export default validateId;
|
|
39
4
|
//# sourceMappingURL=validateId.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateId.d.ts","sourceRoot":"","sources":["../../src/helpers/validateId.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"validateId.d.ts","sourceRoot":"","sources":["../../src/helpers/validateId.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,QAAA,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,SAYjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,42 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const validator_1 = require("validator");
|
|
4
|
-
/**
|
|
5
|
-
* Validates that a value is a URL or a DID (Decentralized Identifier).
|
|
6
|
-
* Throws if the value is missing, null, undefined, or not a valid URL/DID.
|
|
7
|
-
*
|
|
8
|
-
* **Intent**
|
|
9
|
-
* Enforce that identifier-style parameters (schema IDs, credential IDs, subject
|
|
10
|
-
* references, etc.) are either resolvable URLs or W3C DIDs before they are used
|
|
11
|
-
* in Linked Data or verification flows. This prevents malformed or arbitrary
|
|
12
|
-
* strings from propagating into storage, APIs, or cryptographic operations.
|
|
13
|
-
*
|
|
14
|
-
* **Use cases**
|
|
15
|
-
* - Validating `schemaId`, `credentialId`, or similar parameters in credential
|
|
16
|
-
* and schema factories before creating or resolving documents.
|
|
17
|
-
* - Input validation for APIs that accept URI identifiers (e.g. fetch by ID).
|
|
18
|
-
* - Guarding helpers that resolve or dereference IDs (e.g. document loaders,
|
|
19
|
-
* schema registries) from invalid input.
|
|
20
|
-
*
|
|
21
|
-
* **Examples**
|
|
22
|
-
*
|
|
23
|
-
* Valid — URLs:
|
|
24
|
-
* validateId('schemaId', 'https://example.com/schemas/v1');
|
|
25
|
-
* validateId('id', 'http://example.com:8080/path?q=1');
|
|
26
|
-
*
|
|
27
|
-
* Valid — DIDs (case-insensitive `did:` prefix):
|
|
28
|
-
* validateId('subject', 'did:example:123456789');
|
|
29
|
-
* validateId('subject', 'did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK');
|
|
30
|
-
*
|
|
31
|
-
* Throws — missing or invalid:
|
|
32
|
-
* validateId('id', ''); // Error: Parameter "id" is required
|
|
33
|
-
* validateId('id', null); // Error: Parameter "id" is required
|
|
34
|
-
* validateId('id', 'not-a-uri'); // Error: Parameter "id" must be a URL, received: "not-a-uri"
|
|
35
|
-
*
|
|
36
|
-
* @param name - Parameter name used in error messages (e.g. `"schemaId"`, `"credentialId"`).
|
|
37
|
-
* @param value - The value to validate (`string`, `null`, or `undefined`).
|
|
38
|
-
* @throws {Error} When `value` is falsy, or when it is not a URL and does not start with `did:`.
|
|
39
|
-
*/
|
|
4
|
+
/** Validates that a value is a URL or a DID (Decentralized Identifier). */
|
|
40
5
|
const validateId = (name, value) => {
|
|
41
6
|
if (!value) {
|
|
42
7
|
throw new Error(`Parameter "${name}" is required`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateId.js","sourceRoot":"","sources":["../../src/helpers/validateId.ts"],"names":[],"mappings":";;AAAA,yCAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"validateId.js","sourceRoot":"","sources":["../../src/helpers/validateId.ts"],"names":[],"mappings":";;AAAA,yCAAkC;AAElC,2EAA2E;AAC3E,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,KAAgC,EAAE,EAAE;IACpE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,eAAe,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAA,iBAAK,EAAC,KAAK,CAAC,CAAC;IAErE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,+BAA+B,KAAK,GAAG,CAAC,CAAC;AAC7E,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../../src/ld/documentLoader.ts"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../../src/ld/documentLoader.ts"],"names":[],"mappings":"AAQA,iDAAiD;AACjD,QAAA,MAAM,cAAc,GAAI,aAAa,MAAM;;;;CAgB1C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -6,7 +6,7 @@ const CONTEXTS = new Map([
|
|
|
6
6
|
...security_context_1.contexts,
|
|
7
7
|
...credentials_context_1.contexts
|
|
8
8
|
]);
|
|
9
|
-
/** Returns document from the context via url */
|
|
9
|
+
/** Returns document from the context via url. */
|
|
10
10
|
const documentLoader = (documentUrl) => {
|
|
11
11
|
const contextUrl = null;
|
|
12
12
|
const [url] = documentUrl.split('#');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../../src/ld/documentLoader.ts"],"names":[],"mappings":";;AAAA,uDAAmE;AACnE,6DAAyE;AAEzE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IACvB,GAAG,2BAAmB;IACtB,GAAG,8BAAsB;CAC1B,CAAC,CAAC;AAEH,
|
|
1
|
+
{"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../../src/ld/documentLoader.ts"],"names":[],"mappings":";;AAAA,uDAAmE;AACnE,6DAAyE;AAEzE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IACvB,GAAG,2BAAmB;IACtB,GAAG,8BAAsB;CAC1B,CAAC,CAAC;AAEH,iDAAiD;AACjD,MAAM,cAAc,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC7C,MAAM,UAAU,GAAG,IAAI,CAAC;IAExB,MAAM,CAAE,GAAG,CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEnC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,WAAW,oBAAoB,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,QAAQ;QACR,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
|
|
@@ -4,7 +4,7 @@ export type PropertySchema = {
|
|
|
4
4
|
type?: string;
|
|
5
5
|
format?: string;
|
|
6
6
|
};
|
|
7
|
-
/** Returns linked data attribute type for a property schema, unless @type is defined */
|
|
7
|
+
/** Returns linked data attribute type for a property schema, unless @type is defined. */
|
|
8
8
|
declare const getLinkedDataAttributeType: (propertySchema: PropertySchema) => string | undefined;
|
|
9
9
|
export default getLinkedDataAttributeType;
|
|
10
10
|
//# sourceMappingURL=getLinkedDataAttributeType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkedDataAttributeType.d.ts","sourceRoot":"","sources":["../../src/ld/getLinkedDataAttributeType.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"getLinkedDataAttributeType.d.ts","sourceRoot":"","sources":["../../src/ld/getLinkedDataAttributeType.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,yFAAyF;AACzF,QAAA,MAAM,0BAA0B,GAAI,gBAAgB,cAAc,KAAG,MAAM,GAAG,SAiC7E,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const lodash_1 = require("lodash");
|
|
4
|
-
/** Returns linked data attribute type for a property schema, unless @type is defined */
|
|
4
|
+
/** Returns linked data attribute type for a property schema, unless @type is defined. */
|
|
5
5
|
const getLinkedDataAttributeType = (propertySchema) => {
|
|
6
6
|
const isOverriden = !!(0, lodash_1.get)(propertySchema, '@type');
|
|
7
7
|
if (isOverriden) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkedDataAttributeType.js","sourceRoot":"","sources":["../../src/ld/getLinkedDataAttributeType.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAS7B,
|
|
1
|
+
{"version":3,"file":"getLinkedDataAttributeType.js","sourceRoot":"","sources":["../../src/ld/getLinkedDataAttributeType.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAS7B,yFAAyF;AACzF,MAAM,0BAA0B,GAAG,CAAC,cAA8B,EAAsB,EAAE;IACxF,MAAM,WAAW,GAAG,CAAC,CAAC,IAAA,YAAG,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,IAAA,YAAG,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,0EAA0E;IAC1E,gEAAgE;IAChE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;IAExC,MAAM,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IACjC,MAAM,QAAQ,GAAG,IAAI,KAAK,QAAQ,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,KAAK,SAAS,CAAC;IACrC,MAAM,UAAU,GAAG,MAAM,KAAK,WAAW,CAAC;IAE1C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,OAAO;AACT,CAAC,CAAC;AAEF,kBAAe,0BAA0B,CAAC"}
|
|
@@ -13,7 +13,7 @@ type ContextHeader = {
|
|
|
13
13
|
export type LinkedDataContext = ContextHeader & {
|
|
14
14
|
[key: string]: ContextProperty | string | number | boolean | undefined;
|
|
15
15
|
};
|
|
16
|
-
/** Returns linked data context for a properties object */
|
|
16
|
+
/** Returns linked data context for a properties object. */
|
|
17
17
|
declare const getLinkedDataContext: (properties: Record<string, PropertySchema>, vocabUri: string) => LinkedDataContext;
|
|
18
18
|
export default getLinkedDataContext;
|
|
19
19
|
//# sourceMappingURL=getLinkedDataContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkedDataContext.d.ts","sourceRoot":"","sources":["../../src/ld/getLinkedDataContext.ts"],"names":[],"mappings":"AAAA,OAAmC,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE/F,YAAY,EAAE,cAAc,EAAE,CAAC;AAU/B,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACxE,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"getLinkedDataContext.d.ts","sourceRoot":"","sources":["../../src/ld/getLinkedDataContext.ts"],"names":[],"mappings":"AAAA,OAAmC,EAAE,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE/F,YAAY,EAAE,cAAc,EAAE,CAAC;AAU/B,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACxE,CAAC;AAEF,2DAA2D;AAC3D,QAAA,MAAM,oBAAoB,GAAI,YAAY,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,UAAU,MAAM,KAAG,iBAgD5F,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -10,7 +10,7 @@ const PROTECTED_PROPERTIES = [
|
|
|
10
10
|
'type',
|
|
11
11
|
'schema'
|
|
12
12
|
];
|
|
13
|
-
/** Returns linked data context for a properties object */
|
|
13
|
+
/** Returns linked data context for a properties object. */
|
|
14
14
|
const getLinkedDataContext = (properties, vocabUri) => {
|
|
15
15
|
const context = {};
|
|
16
16
|
// TODO: Add support for embedded object, array and enum.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkedDataContext.js","sourceRoot":"","sources":["../../src/ld/getLinkedDataContext.ts"],"names":[],"mappings":";;;;;AAAA,8FAA+F;AAI/F,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,MAAM,oBAAoB,GAAG;IAC3B,IAAI;IACJ,MAAM;IACN,QAAQ;CACT,CAAC;AAkBF,
|
|
1
|
+
{"version":3,"file":"getLinkedDataContext.js","sourceRoot":"","sources":["../../src/ld/getLinkedDataContext.ts"],"names":[],"mappings":";;;;;AAAA,8FAA+F;AAI/F,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,MAAM,oBAAoB,GAAG;IAC3B,IAAI;IACJ,MAAM;IACN,QAAQ;CACT,CAAC;AAkBF,2DAA2D;AAC3D,MAAM,oBAAoB,GAAG,CAAC,UAA0C,EAAE,QAAgB,EAAqB,EAAE;IAC/G,MAAM,OAAO,GAAG,EAAqC,CAAC;IAEtD,yDAAyD;IACzD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAEvC,MAAM,WAAW,GACf,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC;YAClC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEtB,IAAI,WAAW,EAAE,CAAC;YAChB,SAAS;QACX,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAE9B,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;QAEhC,IAAI,IAAI,EAAE,CAAC;YACT,SAAS;QACX,CAAC;QAED,MAAM,cAAc,GAAG,IAAA,oCAA0B,EAAC,cAAc,CAAC,CAAC;QAElE,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC;QACzC,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IAE3F,MAAM,aAAa,GAAG;QACpB,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,GAAG;QACf,YAAY,EAAE,IAAI;KACF,CAAC;IAEnB,MAAM,iBAAiB,GAAG,KAAK,KAAK,cAAc,CAAC;IAEnD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,aAAa,CAAC,MAAM,GAAG,cAAc,CAAC;IACxC,CAAC;IAED,OAAO;QACL,GAAG,aAAa;QAChB,GAAG,OAAO;KACX,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kravc/schema",
|
|
3
|
-
"version": "2.8.0-alpha.
|
|
3
|
+
"version": "2.8.0-alpha.8",
|
|
4
4
|
"description": "Advanced JSON schema manipulation and validation library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"JSON",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"lodash": "^4.17.23",
|
|
36
36
|
"security-context": "^4.0.0",
|
|
37
37
|
"validator": "^13.15.26",
|
|
38
|
-
"z-schema": "^
|
|
38
|
+
"z-schema": "^9.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@eslint/js": "^9.39.2",
|