@kravc/schema 2.7.6 → 2.8.0-alpha.0
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/README.md +19 -14
- package/dist/CredentialFactory.d.ts +345 -0
- package/dist/CredentialFactory.d.ts.map +1 -0
- package/dist/CredentialFactory.js +381 -0
- package/dist/CredentialFactory.js.map +1 -0
- package/dist/Schema.d.ts +448 -0
- package/dist/Schema.d.ts.map +1 -0
- package/dist/Schema.js +506 -0
- package/dist/Schema.js.map +1 -0
- package/dist/ValidationError.d.ts +70 -0
- package/dist/ValidationError.d.ts.map +1 -0
- package/dist/ValidationError.js +78 -0
- package/dist/ValidationError.js.map +1 -0
- package/dist/Validator.d.ts +483 -0
- package/dist/Validator.d.ts.map +1 -0
- package/dist/Validator.js +570 -0
- package/dist/Validator.js.map +1 -0
- package/dist/helpers/JsonSchema.d.ts +99 -0
- package/dist/helpers/JsonSchema.d.ts.map +1 -0
- package/dist/helpers/JsonSchema.js +3 -0
- package/dist/helpers/JsonSchema.js.map +1 -0
- package/dist/helpers/cleanupAttributes.d.ts +34 -0
- package/dist/helpers/cleanupAttributes.d.ts.map +1 -0
- package/dist/helpers/cleanupAttributes.js +113 -0
- package/dist/helpers/cleanupAttributes.js.map +1 -0
- package/dist/helpers/cleanupNulls.d.ts +27 -0
- package/dist/helpers/cleanupNulls.d.ts.map +1 -0
- package/dist/helpers/cleanupNulls.js +96 -0
- package/dist/helpers/cleanupNulls.js.map +1 -0
- package/dist/helpers/getReferenceIds.d.ts +169 -0
- package/dist/helpers/getReferenceIds.d.ts.map +1 -0
- package/dist/helpers/getReferenceIds.js +241 -0
- package/dist/helpers/getReferenceIds.js.map +1 -0
- package/dist/helpers/got.d.ts +60 -0
- package/dist/helpers/got.d.ts.map +1 -0
- package/dist/helpers/got.js +72 -0
- package/dist/helpers/got.js.map +1 -0
- package/dist/helpers/mapObjectProperties.d.ts +150 -0
- package/dist/helpers/mapObjectProperties.d.ts.map +1 -0
- package/dist/helpers/mapObjectProperties.js +229 -0
- package/dist/helpers/mapObjectProperties.js.map +1 -0
- package/dist/helpers/normalizeAttributes.d.ts +213 -0
- package/dist/helpers/normalizeAttributes.d.ts.map +1 -0
- package/dist/helpers/normalizeAttributes.js +243 -0
- package/dist/helpers/normalizeAttributes.js.map +1 -0
- package/dist/helpers/normalizeProperties.d.ts +168 -0
- package/dist/helpers/normalizeProperties.d.ts.map +1 -0
- package/dist/helpers/normalizeProperties.js +223 -0
- package/dist/helpers/normalizeProperties.js.map +1 -0
- package/dist/helpers/normalizeRequired.d.ts +159 -0
- package/dist/helpers/normalizeRequired.d.ts.map +1 -0
- package/dist/helpers/normalizeRequired.js +206 -0
- package/dist/helpers/normalizeRequired.js.map +1 -0
- package/dist/helpers/normalizeType.d.ts +81 -0
- package/dist/helpers/normalizeType.d.ts.map +1 -0
- package/dist/helpers/normalizeType.js +210 -0
- package/dist/helpers/normalizeType.js.map +1 -0
- package/dist/helpers/nullifyEmptyValues.d.ts +139 -0
- package/dist/helpers/nullifyEmptyValues.d.ts.map +1 -0
- package/dist/helpers/nullifyEmptyValues.js +191 -0
- package/dist/helpers/nullifyEmptyValues.js.map +1 -0
- package/dist/helpers/removeRequiredAndDefault.d.ts +106 -0
- package/dist/helpers/removeRequiredAndDefault.d.ts.map +1 -0
- package/dist/helpers/removeRequiredAndDefault.js +138 -0
- package/dist/helpers/removeRequiredAndDefault.js.map +1 -0
- package/dist/helpers/validateId.d.ts +39 -0
- package/dist/helpers/validateId.d.ts.map +1 -0
- package/dist/helpers/validateId.js +51 -0
- package/dist/helpers/validateId.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/ld/documentLoader.d.ts +8 -0
- package/dist/ld/documentLoader.d.ts.map +1 -0
- package/dist/ld/documentLoader.js +24 -0
- package/dist/ld/documentLoader.js.map +1 -0
- package/dist/ld/getLinkedDataAttributeType.d.ts +10 -0
- package/dist/ld/getLinkedDataAttributeType.d.ts.map +1 -0
- package/dist/ld/getLinkedDataAttributeType.js +32 -0
- package/dist/ld/getLinkedDataAttributeType.js.map +1 -0
- package/dist/ld/getLinkedDataContext.d.ts +19 -0
- package/dist/ld/getLinkedDataContext.d.ts.map +1 -0
- package/dist/ld/getLinkedDataContext.js +50 -0
- package/dist/ld/getLinkedDataContext.js.map +1 -0
- package/eslint.config.mjs +32 -52
- package/examples/credentials/createAccountCredential.ts +27 -0
- package/examples/credentials/createMineSweeperScoreCredential.ts +115 -0
- package/examples/index.ts +7 -0
- package/examples/schemas/FavoriteItemSchema.ts +27 -0
- package/examples/{Preferences.yaml → schemas/Preferences.yaml} +2 -0
- package/examples/schemas/PreferencesSchema.ts +29 -0
- package/examples/schemas/ProfileSchema.ts +91 -0
- package/examples/schemas/Status.yaml +3 -0
- package/examples/schemas/StatusSchema.ts +12 -0
- package/jest.config.mjs +5 -0
- package/package.json +27 -20
- package/src/CredentialFactory.ts +392 -0
- package/src/Schema.ts +583 -0
- package/src/ValidationError.ts +90 -0
- package/src/Validator.ts +603 -0
- package/src/__tests__/CredentialFactory.test.ts +588 -0
- package/src/__tests__/Schema.test.ts +371 -0
- package/src/__tests__/ValidationError.test.ts +235 -0
- package/src/__tests__/Validator.test.ts +787 -0
- package/src/helpers/JsonSchema.ts +119 -0
- package/src/helpers/__tests__/cleanupAttributes.test.ts +943 -0
- package/src/helpers/__tests__/cleanupNulls.test.ts +772 -0
- package/src/helpers/__tests__/getReferenceIds.test.ts +975 -0
- package/src/helpers/__tests__/got.test.ts +193 -0
- package/src/helpers/__tests__/mapObjectProperties.test.ts +1126 -0
- package/src/helpers/__tests__/normalizeAttributes.test.ts +1435 -0
- package/src/helpers/__tests__/normalizeProperties.test.ts +727 -0
- package/src/helpers/__tests__/normalizeRequired.test.ts +669 -0
- package/src/helpers/__tests__/normalizeType.test.ts +772 -0
- package/src/helpers/__tests__/nullifyEmptyValues.test.ts +735 -0
- package/src/helpers/__tests__/removeRequiredAndDefault.test.ts +734 -0
- package/src/helpers/__tests__/validateId.test.ts +118 -0
- package/src/helpers/cleanupAttributes.ts +151 -0
- package/src/helpers/cleanupNulls.ts +106 -0
- package/src/helpers/getReferenceIds.ts +273 -0
- package/src/helpers/got.ts +73 -0
- package/src/helpers/mapObjectProperties.ts +272 -0
- package/src/helpers/normalizeAttributes.ts +247 -0
- package/src/helpers/normalizeProperties.ts +249 -0
- package/src/helpers/normalizeRequired.ts +233 -0
- package/src/helpers/normalizeType.ts +235 -0
- package/src/helpers/nullifyEmptyValues.ts +207 -0
- package/src/helpers/removeRequiredAndDefault.ts +151 -0
- package/src/helpers/validateId.ts +53 -0
- package/src/index.ts +13 -0
- package/src/ld/__tests__/documentLoader.test.ts +57 -0
- package/src/ld/__tests__/getLinkedDataAttributeType.test.ts +212 -0
- package/src/ld/__tests__/getLinkedDataContext.test.ts +378 -0
- package/src/ld/documentLoader.ts +28 -0
- package/src/ld/getLinkedDataAttributeType.ts +46 -0
- package/src/ld/getLinkedDataContext.ts +80 -0
- package/tsconfig.json +27 -0
- package/types/credentials-context.d.ts +14 -0
- package/types/security-context.d.ts +6 -0
- package/examples/Status.yaml +0 -3
- package/examples/createAccountCredential.js +0 -27
- package/examples/createMineSweeperScoreCredential.js +0 -63
- package/examples/index.js +0 -9
- package/src/CredentialFactory.js +0 -67
- package/src/CredentialFactory.spec.js +0 -131
- package/src/Schema.js +0 -104
- package/src/Schema.spec.js +0 -172
- package/src/ValidationError.js +0 -31
- package/src/Validator.js +0 -128
- package/src/Validator.spec.js +0 -355
- package/src/helpers/cleanupAttributes.js +0 -71
- package/src/helpers/cleanupNulls.js +0 -42
- package/src/helpers/getReferenceIds.js +0 -71
- package/src/helpers/mapObject.js +0 -65
- package/src/helpers/normalizeAttributes.js +0 -28
- package/src/helpers/normalizeProperties.js +0 -61
- package/src/helpers/normalizeRequired.js +0 -37
- package/src/helpers/normalizeType.js +0 -41
- package/src/helpers/nullifyEmptyValues.js +0 -57
- package/src/helpers/removeRequiredAndDefault.js +0 -30
- package/src/helpers/validateId.js +0 -19
- package/src/index.d.ts +0 -25
- package/src/index.js +0 -8
- package/src/ld/documentLoader.js +0 -25
- package/src/ld/documentLoader.spec.js +0 -12
- package/src/ld/getLinkedDataContext.js +0 -63
- package/src/ld/getLinkedDataType.js +0 -38
- /package/examples/{FavoriteItem.yaml → schemas/FavoriteItem.yaml} +0 -0
- /package/examples/{Profile.yaml → schemas/Profile.yaml} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export type EnumSchema = {
|
|
2
|
+
id?: string;
|
|
3
|
+
enum: string[] | number[];
|
|
4
|
+
type?: 'string' | 'number';
|
|
5
|
+
default?: string | number;
|
|
6
|
+
example?: string | number;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
'x-title'?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
'x-required'?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ReferencePropertySchema = {
|
|
14
|
+
$ref: string;
|
|
15
|
+
default?: string | number | Record<string, unknown>;
|
|
16
|
+
example?: string | number | Record<string, unknown>;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
'x-title'?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
'x-required'?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type StringPropertySchema = {
|
|
24
|
+
'@type'?: string;
|
|
25
|
+
type?: 'string';
|
|
26
|
+
format?: 'date' | 'date-time' | 'url' | 'email',
|
|
27
|
+
default?: string;
|
|
28
|
+
example?: string;
|
|
29
|
+
pattern?: string;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
minLength?: number;
|
|
32
|
+
maxLength?: number;
|
|
33
|
+
'x-title'?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
'x-required'?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type NumberPropertySchema = {
|
|
39
|
+
type: 'number';
|
|
40
|
+
minimum?: number;
|
|
41
|
+
maximum?: number;
|
|
42
|
+
default?: number;
|
|
43
|
+
example?: number;
|
|
44
|
+
required?: boolean;
|
|
45
|
+
'x-title'?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
'x-required'?: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type IntegerPropertySchema = {
|
|
51
|
+
type: 'integer';
|
|
52
|
+
minimum?: number;
|
|
53
|
+
maximum?: number;
|
|
54
|
+
default?: number;
|
|
55
|
+
example?: number;
|
|
56
|
+
required?: boolean;
|
|
57
|
+
'x-title'?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
'x-required'?: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type BooleanPropertySchema = {
|
|
63
|
+
type: 'boolean';
|
|
64
|
+
default?: boolean;
|
|
65
|
+
example?: boolean;
|
|
66
|
+
required?: boolean;
|
|
67
|
+
'x-title'?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
'x-required'?: boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type ObjectPropertySchema = {
|
|
73
|
+
type?: 'object';
|
|
74
|
+
default?: Record<string, unknown>;
|
|
75
|
+
example?: unknown;
|
|
76
|
+
required?: boolean;
|
|
77
|
+
properties?: PropertiesSchema;
|
|
78
|
+
'x-title'?: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
'x-required'?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type ArrayPropertySchema = {
|
|
84
|
+
type?: 'array';
|
|
85
|
+
items?: (ReferencePropertySchema | ObjectPropertySchema | StringPropertySchema | EnumSchema) & {
|
|
86
|
+
minItems?: number;
|
|
87
|
+
maxItems?: number;
|
|
88
|
+
};
|
|
89
|
+
default?: unknown[];
|
|
90
|
+
example?: unknown[];
|
|
91
|
+
required?: boolean;
|
|
92
|
+
'x-title'?: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
'x-required'?: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type PropertySchema =
|
|
98
|
+
EnumSchema |
|
|
99
|
+
ReferencePropertySchema |
|
|
100
|
+
ObjectPropertySchema |
|
|
101
|
+
ArrayPropertySchema |
|
|
102
|
+
StringPropertySchema |
|
|
103
|
+
NumberPropertySchema |
|
|
104
|
+
IntegerPropertySchema |
|
|
105
|
+
BooleanPropertySchema;
|
|
106
|
+
|
|
107
|
+
export type PropertiesSchema = Record<string, PropertySchema>;
|
|
108
|
+
|
|
109
|
+
export type ObjectSchema = {
|
|
110
|
+
id: string;
|
|
111
|
+
required?: string[];
|
|
112
|
+
properties: PropertiesSchema;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type JsonSchema = EnumSchema | ObjectSchema;
|
|
116
|
+
|
|
117
|
+
export type JsonSchemasMap = Record<string, JsonSchema>;
|
|
118
|
+
|
|
119
|
+
export type TargetObject = Record<string, unknown>;
|