@squiz/dx-json-schema-lib 1.2.13-alpha.2 → 1.2.13-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/jest.config.ts +7 -0
  3. package/lib/JsonValidationService.d.ts +4 -6
  4. package/lib/JsonValidationService.js +90 -28
  5. package/lib/JsonValidationService.js.map +1 -1
  6. package/lib/JsonValidationService.spec.js +276 -65
  7. package/lib/JsonValidationService.spec.js.map +1 -1
  8. package/lib/errors/SchemaValidationError.d.ts +1 -1
  9. package/lib/errors/SchemaValidationError.js +8 -1
  10. package/lib/errors/SchemaValidationError.js.map +1 -1
  11. package/lib/formatted-text/v1/formattedText.d.ts +18 -16
  12. package/lib/formatted-text/v1/formattedText.json +59 -88
  13. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.d.ts +8 -0
  14. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.js +21 -0
  15. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.js.map +1 -0
  16. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.spec.d.ts +1 -0
  17. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.spec.js +52 -0
  18. package/lib/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.spec.js.map +1 -0
  19. package/lib/index.d.ts +1 -0
  20. package/lib/index.js +1 -0
  21. package/lib/index.js.map +1 -1
  22. package/lib/manifest/v1/Draft-07.json +155 -0
  23. package/lib/manifest/v1/DxComponentInputSchema.json +11 -8
  24. package/lib/manifest/v1/DxComponentInputSchema.spec.js +23 -9
  25. package/lib/manifest/v1/DxComponentInputSchema.spec.js.map +1 -1
  26. package/lib/manifest/v1/__test__/schemas/badFunctionInputComponent.json +2 -1
  27. package/lib/manifest/v1/__test__/schemas/badNestedFunctionInput.json +2 -1
  28. package/lib/manifest/v1/__test__/schemas/nonObjectFunctionInputComponent.json +2 -1
  29. package/lib/manifest/v1/__test__/schemas/validComponentJson.json +48 -0
  30. package/lib/manifest/v1/v1.d.ts +5 -7
  31. package/lib/manifest/v1/v1.spec.js +22 -3
  32. package/lib/manifest/v1/v1.spec.js.map +1 -1
  33. package/package.json +4 -3
  34. package/src/JsonValidationService.spec.ts +379 -70
  35. package/src/JsonValidationService.ts +112 -34
  36. package/src/errors/SchemaValidationError.ts +10 -2
  37. package/src/formatted-text/v1/formattedText.json +65 -89
  38. package/src/formatted-text/v1/formattedText.ts +19 -17
  39. package/src/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.spec.ts +58 -0
  40. package/src/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.ts +36 -0
  41. package/src/index.ts +1 -0
  42. package/src/manifest/v1/Draft-07.json +155 -0
  43. package/src/manifest/v1/DxComponentInputSchema.json +11 -8
  44. package/src/manifest/v1/DxComponentInputSchema.spec.ts +63 -35
  45. package/src/manifest/v1/__test__/schemas/badFunctionInputComponent.json +2 -1
  46. package/src/manifest/v1/__test__/schemas/badNestedFunctionInput.json +2 -1
  47. package/src/manifest/v1/__test__/schemas/nonObjectFunctionInputComponent.json +2 -1
  48. package/src/manifest/v1/__test__/schemas/validComponentJson.json +48 -0
  49. package/src/manifest/v1/v1.spec.ts +37 -3
  50. package/src/manifest/v1/v1.ts +5 -7
  51. package/tsconfig.json +3 -1
  52. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"JsonValidationService.spec.js","sourceRoot":"","sources":["../src/JsonValidationService.spec.ts"],"names":[],"mappings":";;;;;AAAA,mEAAgE;AAChE,0EAAuE;AAEvE,6GAA+E;AAE/E,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,qBAA4C,CAAC;IACjD,UAAU,CAAC,GAAG,EAAE;QACd,qBAAqB,GAAG,IAAI,6CAAqB,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,yCA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AC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { IOutputError } from 'better-ajv-errors';
2
2
  export declare class SchemaValidationError extends Error {
3
- constructor(validationErrors: IOutputError[], error?: Error);
3
+ constructor(validationErrors: IOutputError[] | string, error?: Error);
4
4
  }
@@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaValidationError = void 0;
4
4
  class SchemaValidationError extends Error {
5
5
  constructor(validationErrors, error) {
6
- super(`failed validation: ${validationErrors.map((e) => e.error).join(', ')}`);
6
+ let message;
7
+ if (typeof validationErrors != 'string') {
8
+ message = validationErrors.map((e) => e.error).join(', ');
9
+ }
10
+ else {
11
+ message = validationErrors;
12
+ }
13
+ super(`failed validation: ${message}`);
7
14
  this.stack = error === null || error === void 0 ? void 0 : error.stack;
8
15
  this.name = 'SchemaValidationError';
9
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaValidationError.js","sourceRoot":"","sources":["../../src/errors/SchemaValidationError.ts"],"names":[],"mappings":";;;AAEA,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,gBAAgC,EAAE,KAAa;QACzD,KAAK,CAAC,sBAAsB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/E,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAND,sDAMC"}
1
+ {"version":3,"file":"SchemaValidationError.js","sourceRoot":"","sources":["../../src/errors/SchemaValidationError.ts"],"names":[],"mappings":";;;AAEA,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,gBAAyC,EAAE,KAAa;QAClE,IAAI,OAAe,CAAC;QAEpB,IAAI,OAAO,gBAAgB,IAAI,QAAQ,EAAE;YACvC,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC3D;aAAM;YACL,OAAO,GAAG,gBAAgB,CAAC;SAC5B;QAED,KAAK,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAdD,sDAcC"}
@@ -5,37 +5,38 @@
5
5
  */
6
6
  export type FormattedNodes = HigherOrderFormattedNodes | BaseFormattedNodes;
7
7
  export type HigherOrderFormattedNodes = FormattedTextLinkToMatrixAsset | FormattedTextMatrixImage;
8
- export type FormattedTextLinkToMatrixAsset = FormattedNodeWithChildren & {
8
+ export type WithChildrenNode = FormattedNodes[];
9
+ export type BaseFormattedNodes = FormattedTextTag | TextNode;
10
+ export type FormattedText = FormattedNodes[];
11
+ export interface FormattedTextLinkToMatrixAsset {
12
+ children: WithChildrenNode;
13
+ formattingOptions?: FormattingOptions;
9
14
  type: 'link-to-matrix-asset';
10
15
  matrixIdentifier?: string;
11
16
  matrixDomain: string;
12
17
  matrixAssetId: string;
13
18
  target: '_blank' | '_self' | '_parent' | '_top';
14
- };
15
- export type FormattedNodeWithChildren = FormattedNode & {
16
- children: FormattedNodes[];
17
- };
18
- export type FormattedTextMatrixImage = FormattedNode & {
19
+ }
20
+ export interface FormattingOptions {
21
+ alignment?: 'center' | 'left' | 'right' | 'justify';
22
+ [k: string]: unknown;
23
+ }
24
+ export interface FormattedTextMatrixImage {
19
25
  type: 'matrix-image';
20
26
  matrixIdentifier?: string;
21
27
  matrixDomain: string;
22
28
  matrixAssetId: string;
23
- };
24
- export type BaseFormattedNodes = FormattedTextTag | TextNode;
25
- export type FormattedTextTag = FormattedNodeWithChildren & {
29
+ formattingOptions?: FormattingOptions;
30
+ }
31
+ export interface FormattedTextTag {
32
+ children: WithChildrenNode;
33
+ formattingOptions?: FormattingOptions;
26
34
  type: 'tag';
27
35
  tag: string;
28
36
  attributes?: {
29
37
  [k: string]: string;
30
38
  };
31
39
  font?: FormattedNodeFontProperties;
32
- };
33
- export type FormattedText = FormattedNodes[];
34
- export interface FormattedNode {
35
- type: string;
36
- formattingOptions?: {
37
- alignment?: 'center' | 'left' | 'right' | 'justify';
38
- };
39
40
  }
40
41
  export interface FormattedNodeFontProperties {
41
42
  bold?: boolean;
@@ -44,6 +45,7 @@ export interface FormattedNodeFontProperties {
44
45
  color?: string;
45
46
  size?: string;
46
47
  fontFamily?: string;
48
+ [k: string]: unknown;
47
49
  }
48
50
  export interface TextNode {
49
51
  type: 'text';
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "type": "array",
4
- "additionalProperties": false,
5
4
  "title": "FormattedText",
6
5
  "items": {
7
6
  "$ref": "#/definitions/FormattedNodes"
@@ -28,107 +27,79 @@
28
27
  },
29
28
  "required": ["type", "value"]
30
29
  },
31
- "FormattedNode": {
30
+ "FormattingOptions": {
32
31
  "type": "object",
33
32
  "properties": {
34
- "type": { "type": "string" },
35
- "formattingOptions": {
36
- "type": "object",
37
- "additionalProperties": false,
38
- "properties": {
39
- "alignment": {
40
- "type": "string",
41
- "enum": ["center", "left", "right", "justify"]
42
- }
43
- }
33
+ "alignment": {
34
+ "type": "string",
35
+ "enum": ["center", "left", "right", "justify"]
44
36
  }
45
- },
46
- "required": ["type"],
47
- "additionalProperties": false
37
+ }
48
38
  },
49
- "FormattedNodeWithChildren": {
39
+ "WithChildrenNode": {
40
+ "type": "array",
41
+ "items": {
42
+ "$ref": "#/definitions/FormattedNodes"
43
+ }
44
+ },
45
+ "FormattedTextTag": {
50
46
  "type": "object",
51
47
  "additionalProperties": false,
52
- "allOf": [
53
- { "$ref": "#/definitions/FormattedNode" },
54
- {
48
+ "properties": {
49
+ "children": {
50
+ "$ref": "#/definitions/WithChildrenNode"
51
+ },
52
+ "formattingOptions": { "$ref": "#/definitions/FormattingOptions" },
53
+ "type": { "const": "tag" },
54
+ "tag": { "type": "string", "minLength": 1 },
55
+ "attributes": {
55
56
  "type": "object",
56
- "additionalProperties": false,
57
- "properties": {
58
- "children": {
59
- "type": "array",
60
- "items": {
61
- "$ref": "#/definitions/FormattedNodes"
62
- }
63
- }
64
- },
65
- "required": ["children"]
66
- }
67
- ]
68
- },
69
- "FormattedTextTag": {
70
- "allOf": [
71
- { "$ref": "#/definitions/FormattedNodeWithChildren" },
72
- {
57
+ "additionalProperties": {
58
+ "type": "string"
59
+ }
60
+ },
61
+ "font": {
62
+ "title": "FormattedNodeFontProperties",
73
63
  "type": "object",
74
- "additionalProperties": false,
75
64
  "properties": {
76
- "type": { "const": "tag" },
77
- "tag": { "type": "string", "minLength": 1 },
78
- "attributes": {
79
- "type": "object",
80
- "additionalProperties": { "type": "string" }
81
- },
82
- "font": {
83
- "title": "FormattedNodeFontProperties",
84
- "type": "object",
85
- "additionalProperties": false,
86
- "properties": {
87
- "bold": { "type": "boolean" },
88
- "underline": { "type": "boolean" },
89
- "italics": { "type": "boolean" },
90
- "color": { "type": "string" },
91
- "size": { "type": "string" },
92
- "fontFamily": { "type": "string" }
93
- }
94
- }
95
- },
96
- "required": ["type", "tag"]
65
+ "bold": { "type": "boolean" },
66
+ "underline": { "type": "boolean" },
67
+ "italics": { "type": "boolean" },
68
+ "color": { "type": "string" },
69
+ "size": { "type": "string" },
70
+ "fontFamily": { "type": "string" }
71
+ }
97
72
  }
98
- ]
73
+ },
74
+ "required": ["type", "tag", "children"]
99
75
  },
100
76
  "FormattedTextLinkToMatrixAsset": {
101
- "allOf": [
102
- { "$ref": "#/definitions/FormattedNodeWithChildren" },
103
- {
104
- "type": "object",
105
- "additionalProperties": false,
106
- "properties": {
107
- "type": { "const": "link-to-matrix-asset" },
108
- "matrixIdentifier": { "type": "string", "minLength": 1 },
109
- "matrixDomain": { "type": "string", "minLength": 1 },
110
- "matrixAssetId": { "type": "string", "minLength": 1 },
111
- "target": { "type": "string", "enum": ["_blank", "_self", "_parent", "_top"] }
112
- },
113
- "required": ["type", "matrixDomain", "matrixAssetId", "target"]
114
- }
115
- ]
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "properties": {
80
+ "children": {
81
+ "$ref": "#/definitions/WithChildrenNode"
82
+ },
83
+ "formattingOptions": { "$ref": "#/definitions/FormattingOptions" },
84
+ "type": { "const": "link-to-matrix-asset" },
85
+ "matrixIdentifier": { "type": "string", "minLength": 1 },
86
+ "matrixDomain": { "type": "string", "minLength": 1 },
87
+ "matrixAssetId": { "type": "string", "minLength": 1 },
88
+ "target": { "type": "string", "enum": ["_blank", "_self", "_parent", "_top"] }
89
+ },
90
+ "required": ["type", "matrixDomain", "matrixAssetId", "target", "children"]
116
91
  },
117
92
  "FormattedTextMatrixImage": {
118
- "allOf": [
119
- { "$ref": "#/definitions/FormattedNode" },
120
- {
121
- "type": "object",
122
- "additionalProperties": false,
123
- "properties": {
124
- "type": { "const": "matrix-image" },
125
- "matrixIdentifier": { "type": "string", "minLength": 1 },
126
- "matrixDomain": { "type": "string", "minLength": 1 },
127
- "matrixAssetId": { "type": "string", "minLength": 1 }
128
- },
129
- "required": ["type", "matrixDomain", "matrixAssetId"]
130
- }
131
- ]
93
+ "type": "object",
94
+ "additionalProperties": false,
95
+ "properties": {
96
+ "type": { "const": "matrix-image" },
97
+ "matrixIdentifier": { "type": "string", "minLength": 1 },
98
+ "matrixDomain": { "type": "string", "minLength": 1 },
99
+ "matrixAssetId": { "type": "string", "minLength": 1 },
100
+ "formattingOptions": { "$ref": "#/definitions/FormattingOptions" }
101
+ },
102
+ "required": ["type", "matrixDomain", "matrixAssetId"]
132
103
  }
133
104
  }
134
105
  }
@@ -0,0 +1,8 @@
1
+ import { BaseFormattedNodes, FormattedNodes, HigherOrderFormattedNodes } from './formattedText';
2
+ export interface FormattedNodeWithChildren {
3
+ children: FormattedNodes[];
4
+ }
5
+ export type HigherOrderFormattedNodesMap = {
6
+ [key in HigherOrderFormattedNodes['type']]: (node: HigherOrderFormattedNodes) => Promise<BaseFormattedNodes>;
7
+ };
8
+ export declare function higherOrderFormattedTextToBaseFormattedText(node: FormattedNodes, resolvers: HigherOrderFormattedNodesMap): Promise<FormattedNodes>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.higherOrderFormattedTextToBaseFormattedText = void 0;
4
+ async function higherOrderFormattedTextToBaseFormattedText(node, resolvers) {
5
+ if (node.type in resolvers && nodeIsHigherOrder(node)) {
6
+ return await resolvers[node.type](node);
7
+ }
8
+ if (hasChildren(node)) {
9
+ const updatedChildren = await Promise.all(node.children.map((child) => higherOrderFormattedTextToBaseFormattedText(child, resolvers)));
10
+ return { ...node, children: updatedChildren };
11
+ }
12
+ return node;
13
+ }
14
+ exports.higherOrderFormattedTextToBaseFormattedText = higherOrderFormattedTextToBaseFormattedText;
15
+ function hasChildren(node) {
16
+ return node && typeof node == 'object' && 'children' in node && Array.isArray(node.children);
17
+ }
18
+ function nodeIsHigherOrder(node) {
19
+ return node.type === 'link-to-matrix-asset' || node.type === 'matrix-image';
20
+ }
21
+ //# sourceMappingURL=higherOrderFormattedTextToBaseFormattedText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"higherOrderFormattedTextToBaseFormattedText.js","sourceRoot":"","sources":["../../../src/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.ts"],"names":[],"mappings":";;;AAUO,KAAK,UAAU,2CAA2C,CAC/D,IAAoB,EACpB,SAAuC;IAEvC,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QACrD,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;KACzC;IAED,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;QACrB,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,2CAA2C,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAC5F,CAAC;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;KAC/C;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAjBD,kGAiBC;AAED,SAAS,WAAW,CAAC,IAAS;IAC5B,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,QAAQ,IAAI,UAAU,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAoB;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,sBAAsB,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const higherOrderFormattedTextToBaseFormattedText_1 = require("./higherOrderFormattedTextToBaseFormattedText");
4
+ describe('higherOrderFormattedTextToBaseFormattedText', () => {
5
+ const mockResolvers = {
6
+ 'link-to-matrix-asset': jest.fn((node) => {
7
+ return Promise.resolve({ type: 'text', value: `Link to asset ${node.matrixAssetId}` });
8
+ }),
9
+ 'matrix-image': jest.fn((node) => {
10
+ return Promise.resolve({ type: 'text', value: `Image ${node.matrixAssetId}` });
11
+ }),
12
+ };
13
+ const testFormattedNodes = {
14
+ tag: 'p',
15
+ type: 'tag',
16
+ children: [
17
+ { type: 'text', value: 'This is some ' },
18
+ {
19
+ type: 'link-to-matrix-asset',
20
+ matrixIdentifier: 'abc123',
21
+ matrixDomain: 'example.com',
22
+ matrixAssetId: '12345',
23
+ target: '_blank',
24
+ children: [{ type: 'text', value: 'linked text' }],
25
+ },
26
+ { type: 'text', value: ' with an image ' },
27
+ {
28
+ type: 'matrix-image',
29
+ matrixIdentifier: 'abc123',
30
+ matrixDomain: 'example.com',
31
+ matrixAssetId: '54321',
32
+ },
33
+ { type: 'text', value: '.' },
34
+ ],
35
+ };
36
+ const expectedFormattedNodes = {
37
+ tag: 'p',
38
+ type: 'tag',
39
+ children: [
40
+ { type: 'text', value: 'This is some ' },
41
+ { type: 'text', value: 'Link to asset 12345' },
42
+ { type: 'text', value: ' with an image ' },
43
+ { type: 'text', value: 'Image 54321' },
44
+ { type: 'text', value: '.' },
45
+ ],
46
+ };
47
+ it('should replace higher order nodes with their resolved counterparts', async () => {
48
+ const result = await (0, higherOrderFormattedTextToBaseFormattedText_1.higherOrderFormattedTextToBaseFormattedText)(testFormattedNodes, mockResolvers);
49
+ expect(result).toEqual(expectedFormattedNodes);
50
+ });
51
+ });
52
+ //# sourceMappingURL=higherOrderFormattedTextToBaseFormattedText.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"higherOrderFormattedTextToBaseFormattedText.spec.js","sourceRoot":"","sources":["../../../src/formatted-text/v1/higherOrderFormattedTextToBaseFormattedText.spec.ts"],"names":[],"mappings":";;AACA,+GAGuD;AAEvD,QAAQ,CAAC,6CAA6C,EAAE,GAAG,EAAE;IAC3D,MAAM,aAAa,GAAiC;QAClD,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAA+B,EAAE,EAAE;YAClE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACzF,CAAC,CAAC;QACF,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,IAA+B,EAAE,EAAE;YAC1D,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK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,yFAA2C,EAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QAEpG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * as MANIFEST_MODELS from './manifest/v1/manifestModels';
2
2
  export * as MANIFEST_SCHEMAS from './manifest/v1/manifestSchemas';
3
3
  export * as FORMATTED_TEXT_MODELS from './formatted-text/v1/formattedTextModels';
4
4
  export * as FORMATTED_TEXT_SCHEMAS from './formatted-text/v1/formattedTextSchemas';
5
+ export * from './formatted-text/v1/higherOrderFormattedTextToBaseFormattedText';
5
6
  export * as SUB_SCHEMAS from './manifest/v1/subSchemas';
6
7
  export * from './JsonValidationService';
7
8
  export * from './errors/SchemaValidationError';
package/lib/index.js CHANGED
@@ -31,6 +31,7 @@ exports.MANIFEST_MODELS = __importStar(require("./manifest/v1/manifestModels"));
31
31
  exports.MANIFEST_SCHEMAS = __importStar(require("./manifest/v1/manifestSchemas"));
32
32
  exports.FORMATTED_TEXT_MODELS = __importStar(require("./formatted-text/v1/formattedTextModels"));
33
33
  exports.FORMATTED_TEXT_SCHEMAS = __importStar(require("./formatted-text/v1/formattedTextSchemas"));
34
+ __exportStar(require("./formatted-text/v1/higherOrderFormattedTextToBaseFormattedText"), exports);
34
35
  exports.SUB_SCHEMAS = __importStar(require("./manifest/v1/subSchemas"));
35
36
  __exportStar(require("./JsonValidationService"), exports);
36
37
  __exportStar(require("./errors/SchemaValidationError"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAAgE;AAChE,kFAAkE;AAElE,iGAAiF;AACjF,mGAAmF;AAEnF,wEAAwD;AAExD,0DAAwC;AACxC,iEAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAAgE;AAChE,kFAAkE;AAElE,iGAAiF;AACjF,mGAAmF;AACnF,kGAAgF;AAEhF,wEAAwD;AAExD,0DAAwC;AACxC,iEAA+C"}
@@ -0,0 +1,155 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "http://json-schema.org/draft-07/schema#",
4
+ "title": "Core schema meta-schema",
5
+ "definitions": {
6
+ "schemaArray": {
7
+ "type": "array",
8
+ "minItems": 1,
9
+ "items": { "$ref": "#" }
10
+ },
11
+ "nonNegativeInteger": {
12
+ "type": "integer",
13
+ "minimum": 0
14
+ },
15
+ "nonNegativeIntegerDefault0": {
16
+ "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }, { "default": 0 }]
17
+ },
18
+ "simpleTypes": {
19
+ "enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
20
+ },
21
+ "stringArray": {
22
+ "type": "array",
23
+ "items": { "type": "string" },
24
+ "uniqueItems": true,
25
+ "default": []
26
+ }
27
+ },
28
+ "type": ["object", "boolean"],
29
+ "properties": {
30
+ "$id": {
31
+ "type": "string",
32
+ "format": "uri-reference"
33
+ },
34
+ "$schema": {
35
+ "type": "string",
36
+ "format": "uri"
37
+ },
38
+ "$ref": {
39
+ "type": "string",
40
+ "format": "uri-reference"
41
+ },
42
+ "$comment": {
43
+ "type": "string"
44
+ },
45
+ "title": {
46
+ "type": "string"
47
+ },
48
+ "description": {
49
+ "type": "string"
50
+ },
51
+ "default": true,
52
+ "readOnly": {
53
+ "type": "boolean",
54
+ "default": false
55
+ },
56
+ "writeOnly": {
57
+ "type": "boolean",
58
+ "default": false
59
+ },
60
+ "examples": {
61
+ "type": "array",
62
+ "items": true
63
+ },
64
+ "multipleOf": {
65
+ "type": "number",
66
+ "exclusiveMinimum": 0
67
+ },
68
+ "maximum": {
69
+ "type": "number"
70
+ },
71
+ "exclusiveMaximum": {
72
+ "type": "number"
73
+ },
74
+ "minimum": {
75
+ "type": "number"
76
+ },
77
+ "exclusiveMinimum": {
78
+ "type": "number"
79
+ },
80
+ "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
81
+ "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
82
+ "pattern": {
83
+ "type": "string",
84
+ "format": "regex"
85
+ },
86
+ "additionalItems": { "$ref": "#" },
87
+ "items": {
88
+ "anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/schemaArray" }],
89
+ "default": true
90
+ },
91
+ "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
92
+ "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
93
+ "uniqueItems": {
94
+ "type": "boolean",
95
+ "default": false
96
+ },
97
+ "contains": { "$ref": "#" },
98
+ "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
99
+ "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
100
+ "required": { "$ref": "#/definitions/stringArray" },
101
+ "additionalProperties": { "$ref": "#" },
102
+ "definitions": {
103
+ "type": "object",
104
+ "additionalProperties": { "$ref": "#" },
105
+ "default": {}
106
+ },
107
+ "properties": {
108
+ "type": "object",
109
+ "additionalProperties": { "$ref": "#" },
110
+ "default": {}
111
+ },
112
+ "patternProperties": {
113
+ "type": "object",
114
+ "additionalProperties": { "$ref": "#" },
115
+ "propertyNames": { "format": "regex" },
116
+ "default": {}
117
+ },
118
+ "dependencies": {
119
+ "type": "object",
120
+ "additionalProperties": {
121
+ "anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/stringArray" }]
122
+ }
123
+ },
124
+ "propertyNames": { "$ref": "#" },
125
+ "const": true,
126
+ "enum": {
127
+ "type": "array",
128
+ "items": true,
129
+ "minItems": 1,
130
+ "uniqueItems": true
131
+ },
132
+ "type": {
133
+ "anyOf": [
134
+ { "$ref": "#/definitions/simpleTypes" },
135
+ {
136
+ "type": "array",
137
+ "items": { "$ref": "#/definitions/simpleTypes" },
138
+ "minItems": 1,
139
+ "uniqueItems": true
140
+ }
141
+ ]
142
+ },
143
+ "format": { "type": "string" },
144
+ "contentMediaType": { "type": "string" },
145
+ "contentEncoding": { "type": "string" },
146
+ "if": { "$ref": "#" },
147
+ "then": { "$ref": "#" },
148
+ "else": { "$ref": "#" },
149
+ "allOf": { "$ref": "#/definitions/schemaArray" },
150
+ "anyOf": { "$ref": "#/definitions/schemaArray" },
151
+ "oneOf": { "$ref": "#/definitions/schemaArray" },
152
+ "not": { "$ref": "#" }
153
+ },
154
+ "default": true
155
+ }
@@ -4,17 +4,20 @@
4
4
  "title": "DxComponentInputSchema",
5
5
  "description": "Input schema for a DxComponent",
6
6
  "type": "object",
7
- "properties": {
8
- "type": {
9
- "const": "object"
10
- },
11
- "additionalProperties": {
12
- "default": false
13
- }
14
- },
15
7
  "allOf": [
16
8
  {
17
9
  "$ref": "DxContentMetaSchema.json"
10
+ },
11
+ {
12
+ "type": "object",
13
+ "properties": {
14
+ "type": {
15
+ "const": "object"
16
+ },
17
+ "additionalProperties": {
18
+ "default": false
19
+ }
20
+ }
18
21
  }
19
22
  ]
20
23
  }