@squiz/dx-json-schema-lib 1.2.13-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/jest.config.ts +20 -0
- package/jsonCompiler.ts +22 -0
- package/lib/JsonValidationService.d.ts +9 -0
- package/lib/JsonValidationService.js +54 -0
- package/lib/JsonValidationService.js.map +1 -0
- package/lib/JsonValidationService.spec.d.ts +1 -0
- package/lib/JsonValidationService.spec.js +143 -0
- package/lib/JsonValidationService.spec.js.map +1 -0
- package/lib/errors/SchemaValidationError.d.ts +4 -0
- package/lib/errors/SchemaValidationError.js +12 -0
- package/lib/errors/SchemaValidationError.js.map +1 -0
- package/lib/formatted-text/v1/formattedText.d.ts +51 -0
- package/lib/formatted-text/v1/formattedText.js +9 -0
- package/lib/formatted-text/v1/formattedText.js.map +1 -0
- package/lib/formatted-text/v1/formattedText.json +134 -0
- package/lib/formatted-text/v1/formattedTextModels.d.ts +1 -0
- package/lib/formatted-text/v1/formattedTextModels.js +28 -0
- package/lib/formatted-text/v1/formattedTextModels.js.map +1 -0
- package/lib/formatted-text/v1/formattedTextSchemas.d.ts +2 -0
- package/lib/formatted-text/v1/formattedTextSchemas.js +9 -0
- package/lib/formatted-text/v1/formattedTextSchemas.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +37 -0
- package/lib/index.js.map +1 -0
- package/lib/manifest/v1/DxComponentIcons.json +2279 -0
- package/lib/manifest/v1/DxComponentInputSchema.json +20 -0
- package/lib/manifest/v1/DxComponentInputSchema.spec.d.ts +1 -0
- package/lib/manifest/v1/DxComponentInputSchema.spec.js +113 -0
- package/lib/manifest/v1/DxComponentInputSchema.spec.js.map +1 -0
- package/lib/manifest/v1/DxContentMetaSchema.json +165 -0
- package/lib/manifest/v1/__test__/schemas/badFunctionInputComponent.json +39 -0
- package/lib/manifest/v1/__test__/schemas/badNestedFunctionInput.json +39 -0
- package/lib/manifest/v1/__test__/schemas/nonObjectFunctionInputComponent.json +39 -0
- package/lib/manifest/v1/__test__/schemas/validComponent.json +40 -0
- package/lib/manifest/v1/manifestModels.d.ts +1 -0
- package/lib/manifest/v1/manifestModels.js +28 -0
- package/lib/manifest/v1/manifestModels.js.map +1 -0
- package/lib/manifest/v1/manifestSchemas.d.ts +2 -0
- package/lib/manifest/v1/manifestSchemas.js +9 -0
- package/lib/manifest/v1/manifestSchemas.js.map +1 -0
- package/lib/manifest/v1/subSchemas.d.ts +4 -0
- package/lib/manifest/v1/subSchemas.js +13 -0
- package/lib/manifest/v1/subSchemas.js.map +1 -0
- package/lib/manifest/v1/v1.d.ts +460 -0
- package/lib/manifest/v1/v1.js +9 -0
- package/lib/manifest/v1/v1.js.map +1 -0
- package/lib/manifest/v1/v1.json +362 -0
- package/lib/manifest/v1/v1.spec.d.ts +1 -0
- package/lib/manifest/v1/v1.spec.js +35 -0
- package/lib/manifest/v1/v1.spec.js.map +1 -0
- package/package.json +36 -0
- package/src/JsonValidationService.spec.ts +162 -0
- package/src/JsonValidationService.ts +54 -0
- package/src/errors/SchemaValidationError.ts +9 -0
- package/src/formatted-text/v1/formattedText.json +145 -0
- package/src/formatted-text/v1/formattedText.ts +54 -0
- package/src/formatted-text/v1/formattedTextModels.ts +1 -0
- package/src/formatted-text/v1/formattedTextSchemas.ts +3 -0
- package/src/index.ts +10 -0
- package/src/manifest/v1/DxComponentIcons.json +2279 -0
- package/src/manifest/v1/DxComponentInputSchema.json +20 -0
- package/src/manifest/v1/DxComponentInputSchema.spec.ts +136 -0
- package/src/manifest/v1/DxContentMetaSchema.json +165 -0
- package/src/manifest/v1/__test__/schemas/badFunctionInputComponent.json +39 -0
- package/src/manifest/v1/__test__/schemas/badNestedFunctionInput.json +39 -0
- package/src/manifest/v1/__test__/schemas/nonObjectFunctionInputComponent.json +39 -0
- package/src/manifest/v1/__test__/schemas/validComponent.json +40 -0
- package/src/manifest/v1/manifestModels.ts +1 -0
- package/src/manifest/v1/manifestSchemas.ts +3 -0
- package/src/manifest/v1/subSchemas.ts +5 -0
- package/src/manifest/v1/v1.json +369 -0
- package/src/manifest/v1/v1.spec.ts +39 -0
- package/src/manifest/v1/v1.ts +2731 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
import { IOutputError } from 'better-ajv-errors';
|
2
|
+
|
3
|
+
export class SchemaValidationError extends Error {
|
4
|
+
constructor(validationErrors: IOutputError[], error?: Error) {
|
5
|
+
super(`failed validation: ${validationErrors.map((e) => e.error).join(', ')}`);
|
6
|
+
this.stack = error?.stack;
|
7
|
+
this.name = 'SchemaValidationError';
|
8
|
+
}
|
9
|
+
}
|
@@ -0,0 +1,145 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
+
"type": "array",
|
4
|
+
"additionalProperties": false,
|
5
|
+
"title": "FormattedText",
|
6
|
+
|
7
|
+
"items": {
|
8
|
+
"$ref": "#/definitions/FormattedNodes"
|
9
|
+
},
|
10
|
+
|
11
|
+
"definitions": {
|
12
|
+
"FormattedNodes": {
|
13
|
+
"anyOf": [{ "$ref": "#/definitions/HigherOrderFormattedNodes" }, { "$ref": "#/definitions/BaseFormattedNodes" }]
|
14
|
+
},
|
15
|
+
|
16
|
+
"HigherOrderFormattedNodes": {
|
17
|
+
"anyOf": [
|
18
|
+
{ "$ref": "#/definitions/FormattedTextLinkToMatrixAsset" },
|
19
|
+
{ "$ref": "#/definitions/FormattedTextMatrixImage" }
|
20
|
+
]
|
21
|
+
},
|
22
|
+
|
23
|
+
"BaseFormattedNodes": {
|
24
|
+
"anyOf": [{ "$ref": "#/definitions/FormattedTextTag" }, { "$ref": "#/definitions/TextNode" }]
|
25
|
+
},
|
26
|
+
|
27
|
+
"TextNode": {
|
28
|
+
"type": "object",
|
29
|
+
"additionalProperties": false,
|
30
|
+
"properties": {
|
31
|
+
"type": { "const": "text" },
|
32
|
+
"value": { "type": "string" }
|
33
|
+
},
|
34
|
+
"required": ["type", "value"]
|
35
|
+
},
|
36
|
+
|
37
|
+
"FormattedNode": {
|
38
|
+
"type": "object",
|
39
|
+
"properties": {
|
40
|
+
"type": { "type": "string" },
|
41
|
+
"formattingOptions": {
|
42
|
+
"type": "object",
|
43
|
+
"additionalProperties": false,
|
44
|
+
"properties": {
|
45
|
+
"alignment": {
|
46
|
+
"type": "string",
|
47
|
+
"enum": ["center", "left", "right", "justify"]
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
},
|
52
|
+
"required": ["type"],
|
53
|
+
|
54
|
+
"additionalProperties": false
|
55
|
+
},
|
56
|
+
|
57
|
+
"FormattedNodeWithChildren": {
|
58
|
+
"type": "object",
|
59
|
+
"additionalProperties": false,
|
60
|
+
"allOf": [
|
61
|
+
{ "$ref": "#/definitions/FormattedNode" },
|
62
|
+
{
|
63
|
+
"type": "object",
|
64
|
+
"additionalProperties": false,
|
65
|
+
"properties": {
|
66
|
+
"children": {
|
67
|
+
"type": "array",
|
68
|
+
"items": {
|
69
|
+
"$ref": "#/definitions/FormattedNodes"
|
70
|
+
}
|
71
|
+
}
|
72
|
+
},
|
73
|
+
"required": ["children"]
|
74
|
+
}
|
75
|
+
]
|
76
|
+
},
|
77
|
+
|
78
|
+
"FormattedTextTag": {
|
79
|
+
"allOf": [
|
80
|
+
{ "$ref": "#/definitions/FormattedNodeWithChildren" },
|
81
|
+
{
|
82
|
+
"type": "object",
|
83
|
+
"additionalProperties": false,
|
84
|
+
"properties": {
|
85
|
+
"type": { "const": "tag" },
|
86
|
+
"tag": { "type": "string", "minLength": 1 },
|
87
|
+
"attributes": {
|
88
|
+
"type": "object",
|
89
|
+
"additionalProperties": { "type": "string" }
|
90
|
+
},
|
91
|
+
"font": {
|
92
|
+
"title": "FormattedNodeFontProperties",
|
93
|
+
"type": "object",
|
94
|
+
"additionalProperties": false,
|
95
|
+
"properties": {
|
96
|
+
"bold": { "type": "boolean" },
|
97
|
+
"underline": { "type": "boolean" },
|
98
|
+
"italics": { "type": "boolean" },
|
99
|
+
"color": { "type": "string" },
|
100
|
+
"size": { "type": "string" },
|
101
|
+
"fontFamily": { "type": "string" }
|
102
|
+
}
|
103
|
+
}
|
104
|
+
},
|
105
|
+
"required": ["type", "tag"]
|
106
|
+
}
|
107
|
+
]
|
108
|
+
},
|
109
|
+
|
110
|
+
"FormattedTextLinkToMatrixAsset": {
|
111
|
+
"allOf": [
|
112
|
+
{ "$ref": "#/definitions/FormattedNodeWithChildren" },
|
113
|
+
{
|
114
|
+
"type": "object",
|
115
|
+
"additionalProperties": false,
|
116
|
+
"properties": {
|
117
|
+
"type": { "const": "link-to-matrix-asset" },
|
118
|
+
"matrixIdentifier": { "type": "string", "minLength": 1 },
|
119
|
+
"matrixDomain": { "type": "string", "minLength": 1 },
|
120
|
+
"matrixAssetId": { "type": "string", "minLength": 1 },
|
121
|
+
"target": { "type": "string", "enum": ["_blank", "_self", "_parent", "_top"] }
|
122
|
+
},
|
123
|
+
"required": ["type", "matrixDomain", "matrixAssetId", "target"]
|
124
|
+
}
|
125
|
+
]
|
126
|
+
},
|
127
|
+
|
128
|
+
"FormattedTextMatrixImage": {
|
129
|
+
"allOf": [
|
130
|
+
{ "$ref": "#/definitions/FormattedNode" },
|
131
|
+
{
|
132
|
+
"type": "object",
|
133
|
+
"additionalProperties": false,
|
134
|
+
"properties": {
|
135
|
+
"type": { "const": "matrix-image" },
|
136
|
+
"matrixIdentifier": { "type": "string", "minLength": 1 },
|
137
|
+
"matrixDomain": { "type": "string", "minLength": 1 },
|
138
|
+
"matrixAssetId": { "type": "string", "minLength": 1 }
|
139
|
+
},
|
140
|
+
"required": ["type", "matrixDomain", "matrixAssetId"]
|
141
|
+
}
|
142
|
+
]
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/* tslint:disable */
|
2
|
+
/**
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
export type FormattedNodes = HigherOrderFormattedNodes | BaseFormattedNodes;
|
9
|
+
export type HigherOrderFormattedNodes = FormattedTextLinkToMatrixAsset | FormattedTextMatrixImage;
|
10
|
+
export type FormattedTextLinkToMatrixAsset = FormattedNodeWithChildren & {
|
11
|
+
type: 'link-to-matrix-asset';
|
12
|
+
matrixIdentifier?: string;
|
13
|
+
matrixDomain: string;
|
14
|
+
matrixAssetId: string;
|
15
|
+
target: '_blank' | '_self' | '_parent' | '_top';
|
16
|
+
};
|
17
|
+
export type FormattedNodeWithChildren = FormattedNode & {
|
18
|
+
children: FormattedNodes[];
|
19
|
+
};
|
20
|
+
export type FormattedTextMatrixImage = FormattedNode & {
|
21
|
+
type: 'matrix-image';
|
22
|
+
matrixIdentifier?: string;
|
23
|
+
matrixDomain: string;
|
24
|
+
matrixAssetId: string;
|
25
|
+
};
|
26
|
+
export type BaseFormattedNodes = FormattedTextTag | TextNode;
|
27
|
+
export type FormattedTextTag = FormattedNodeWithChildren & {
|
28
|
+
type: 'tag';
|
29
|
+
tag: string;
|
30
|
+
attributes?: {
|
31
|
+
[k: string]: string;
|
32
|
+
};
|
33
|
+
font?: FormattedNodeFontProperties;
|
34
|
+
};
|
35
|
+
export type FormattedText = FormattedNodes[];
|
36
|
+
|
37
|
+
export interface FormattedNode {
|
38
|
+
type: string;
|
39
|
+
formattingOptions?: {
|
40
|
+
alignment?: 'center' | 'left' | 'right' | 'justify';
|
41
|
+
};
|
42
|
+
}
|
43
|
+
export interface FormattedNodeFontProperties {
|
44
|
+
bold?: boolean;
|
45
|
+
underline?: boolean;
|
46
|
+
italics?: boolean;
|
47
|
+
color?: string;
|
48
|
+
size?: string;
|
49
|
+
fontFamily?: string;
|
50
|
+
}
|
51
|
+
export interface TextNode {
|
52
|
+
type: 'text';
|
53
|
+
value: string;
|
54
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as v1 from './formattedText';
|
package/src/index.ts
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
export * as MANIFEST_MODELS from './manifest/v1/manifestModels';
|
2
|
+
export * as MANIFEST_SCHEMAS from './manifest/v1/manifestSchemas';
|
3
|
+
|
4
|
+
export * as FORMATTED_TEXT_MODELS from './formatted-text/v1/formattedTextModels';
|
5
|
+
export * as FORMATTED_TEXT_SCHEMAS from './formatted-text/v1/formattedTextSchemas';
|
6
|
+
|
7
|
+
export * as SUB_SCHEMAS from './manifest/v1/subSchemas';
|
8
|
+
|
9
|
+
export * from './JsonValidationService';
|
10
|
+
export * from './errors/SchemaValidationError';
|