@squiz/dx-json-schema-lib
Advanced tools
Comparing version 1.65.0 to 1.65.1
# Change Log | ||
## 1.65.1 | ||
### Patch Changes | ||
- 928cc88: Made children optional for formatted text nodes/tags | ||
## 1.65.0 | ||
@@ -4,0 +10,0 @@ |
@@ -32,3 +32,3 @@ /** | ||
export interface FormattedTextTag { | ||
children: WithChildrenNode; | ||
children?: WithChildrenNode; | ||
formattingOptions?: FormattingOptions; | ||
@@ -35,0 +35,0 @@ type: 'tag'; |
@@ -79,3 +79,3 @@ { | ||
}, | ||
"required": ["type", "tag", "children"] | ||
"required": ["type", "tag"] | ||
}, | ||
@@ -82,0 +82,0 @@ "ComponentNode": { |
@@ -34,2 +34,3 @@ import { Input } from '@sagold/json-query'; | ||
resolveInput(input: Input, inputSchema: JSONSchema): Promise<Input>; | ||
private assignResolvedData; | ||
protected resolveInputArray(input: Input, setters: Promise<(input: Input) => Input>[], schema: JSONSchema, value: unknown, pointer: string): Promise<void>; | ||
@@ -36,0 +37,0 @@ private isPrimitiveSchema; |
@@ -247,2 +247,17 @@ "use strict"; | ||
} | ||
assignResolvedData(input, pointer, resolvedData) { | ||
// TODO: Revert to using JSONQuery.set once https://github.com/sagold/json-query/pull/27 is resolved. | ||
// Test "should resolve multiple primitive type array items in multi-level nested array structures" confirms | ||
// desired behaviour. | ||
json_query_1.default.get(input, pointer, (unresolvedData) => { | ||
if (resolvedData === unresolvedData) { | ||
return; | ||
} | ||
for (const prop of Object.getOwnPropertyNames(unresolvedData)) { | ||
delete unresolvedData[prop]; | ||
} | ||
Object.assign(unresolvedData, resolvedData); | ||
}); | ||
return input; | ||
} | ||
async resolveInputArray(input, setters, schema, value, pointer) { | ||
@@ -262,3 +277,3 @@ const allPossibleSchemaTitles = schema.oneOf.map((o) => { | ||
.then(() => resolver(value)) | ||
.then((resolvedData) => (item) => json_query_1.default.set(item, pointer, resolvedData, 'replace')) | ||
.then((resolvedData) => (item) => this.assignResolvedData(item, pointer, resolvedData)) | ||
.catch((e) => Promise.reject(new JsonResolutionError_1.JsonResolutionError(e, pointer, value))); | ||
@@ -265,0 +280,0 @@ setters.push(setResolvedData); |
{ | ||
"name": "@squiz/dx-json-schema-lib", | ||
"version": "1.65.0", | ||
"version": "1.65.1", | ||
"description": "", | ||
@@ -23,3 +23,3 @@ "main": "lib/index.js", | ||
"@types/jest": "28.1.8", | ||
"@types/node": "18.15.2", | ||
"@types/node": "20.11.24", | ||
"dotenv": "16.0.3", | ||
@@ -26,0 +26,0 @@ "jest": "29.4.1", |
@@ -90,3 +90,3 @@ { | ||
}, | ||
"required": ["type", "tag", "children"] | ||
"required": ["type", "tag"] | ||
}, | ||
@@ -93,0 +93,0 @@ |
@@ -35,3 +35,3 @@ /* eslint-disable */ | ||
export interface FormattedTextTag { | ||
children: WithChildrenNode; | ||
children?: WithChildrenNode; | ||
formattingOptions?: FormattingOptions; | ||
@@ -38,0 +38,0 @@ type: 'tag'; |
@@ -289,2 +289,21 @@ import JSONQuery, { Input } from '@sagold/json-query'; | ||
private assignResolvedData(input: Input, pointer: string, resolvedData: unknown): Input { | ||
// TODO: Revert to using JSONQuery.set once https://github.com/sagold/json-query/pull/27 is resolved. | ||
// Test "should resolve multiple primitive type array items in multi-level nested array structures" confirms | ||
// desired behaviour. | ||
JSONQuery.get(input, pointer, (unresolvedData) => { | ||
if (resolvedData === unresolvedData) { | ||
return; | ||
} | ||
for (const prop of Object.getOwnPropertyNames(unresolvedData)) { | ||
delete unresolvedData[prop]; | ||
} | ||
Object.assign(unresolvedData, resolvedData); | ||
}); | ||
return input; | ||
} | ||
protected async resolveInputArray( | ||
@@ -310,5 +329,3 @@ input: Input, | ||
.then(() => resolver(value)) | ||
.then( | ||
(resolvedData) => (item: typeof input) => JSONQuery.set(item, pointer, resolvedData, 'replace' as any), //import issue | ||
) | ||
.then((resolvedData) => (item: typeof input) => this.assignResolvedData(item, pointer, resolvedData)) | ||
.catch((e) => Promise.reject(new JsonResolutionError(e, pointer, value))); | ||
@@ -315,0 +332,0 @@ setters.push(setResolvedData); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
891040
21681