@squiz/dx-json-schema-lib
Advanced tools
Comparing version 1.80.0 to 1.80.1
# Change Log | ||
## 1.80.1 | ||
### Patch Changes | ||
- a63dfe8: Revise dependencies | ||
## 1.80.0 | ||
@@ -4,0 +10,0 @@ |
import { Input } from '@sagold/json-query'; | ||
import { JSONSchema, Draft } from '@squiz/json-schema-library'; | ||
import { AnyPrimitiveType, AnyResolvableType, TypeResolver } from './jsonTypeResolution/TypeResolver'; | ||
import { AnyPrimitiveType, AnyResolvableType, ResolverContext, TypeResolver } from './jsonTypeResolution/TypeResolver'; | ||
export declare const ComponentInputMetaSchema: MetaSchemaInput; | ||
@@ -32,4 +32,4 @@ export declare const RenderInputMetaSchema: MetaSchemaInput; | ||
*/ | ||
resolveInput(input: Input, inputSchema: JSONSchema): Promise<Input>; | ||
resolveInput(input: Input, inputSchema: JSONSchema, ctx?: ResolverContext): Promise<Input>; | ||
} | ||
export {}; |
@@ -99,3 +99,3 @@ "use strict"; | ||
*/ | ||
async resolveInput(input, inputSchema) { | ||
async resolveInput(input, inputSchema, ctx = {}) { | ||
const setters = []; | ||
@@ -121,3 +121,3 @@ this.schema.each(input, async (schema, value, pointer) => { | ||
const setResolvedData = Promise.resolve() | ||
.then(() => resolver(value)) | ||
.then(() => resolver(value, ctx)) | ||
.then((resolvedData) => (item) => json_query_1.default.set(item, pointer, resolvedData, 'replace')) | ||
@@ -124,0 +124,0 @@ .catch((e) => Promise.reject(new JsonResolutionError_1.JsonResolutionError(e, pointer, value))); |
@@ -29,3 +29,6 @@ import type { JSONSchema } from '@squiz/json-schema-library'; | ||
export type AnyResolvableType = ResolvableType<string, any>; | ||
export type Resolver<INPUT, OUTPUT> = (input: INPUT) => MaybePromise<OUTPUT>; | ||
export type ResolverContext = { | ||
baseUrl?: string; | ||
}; | ||
export type Resolver<INPUT, OUTPUT> = (input: INPUT, ctx?: ResolverContext) => MaybePromise<OUTPUT>; | ||
/** | ||
@@ -32,0 +35,0 @@ * A JSON Type Resolver class which stores the primitive and resolvable JSON Schema types and their resolvers |
import { PrimitiveType } from '../jsonTypeResolution/TypeResolver'; | ||
import type { ExifData } from 'exif'; | ||
interface SquizImageData { | ||
@@ -15,3 +16,3 @@ width: number; | ||
caption?: string; | ||
exif?: import('exif').ExifData; | ||
exif?: ExifData; | ||
imageVariations: { | ||
@@ -18,0 +19,0 @@ original: SquizImageData; |
{ | ||
"name": "@squiz/dx-json-schema-lib", | ||
"version": "1.80.0", | ||
"version": "1.80.1", | ||
"description": "", | ||
@@ -20,4 +20,2 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/exif": "0.6.3", | ||
"@types/express": "4.17.17", | ||
"@types/jest": "28.1.8", | ||
@@ -28,5 +26,3 @@ "@types/node": "20.12.12", | ||
"json-schema-to-typescript": "14.1.0", | ||
"rimraf": "5.0.7", | ||
"ts-jest": "29.0.5", | ||
"ts-loader": "9.3.1", | ||
"ts-node": "10.9.2", | ||
@@ -38,4 +34,5 @@ "typescript": "4.9.4" | ||
"@squiz/json-schema-library": "^7.4.7", | ||
"@types/exif": "^0.6.5", | ||
"ts-brand": "0.0.2" | ||
} | ||
} |
@@ -15,3 +15,3 @@ import JSONQuery, { Input } from '@sagold/json-query'; | ||
import { draft07Config } from '@squiz/json-schema-library'; | ||
import { AnyPrimitiveType, AnyResolvableType, TypeResolver } from './jsonTypeResolution/TypeResolver'; | ||
import { AnyPrimitiveType, AnyResolvableType, ResolverContext, TypeResolver } from './jsonTypeResolution/TypeResolver'; | ||
import { JsonResolutionError } from './errors/JsonResolutionError'; | ||
@@ -115,3 +115,3 @@ import { processValidationResult } from './processValidationResult'; | ||
*/ | ||
public async resolveInput(input: Input, inputSchema: JSONSchema) { | ||
public async resolveInput(input: Input, inputSchema: JSONSchema, ctx: ResolverContext = {}) { | ||
const setters: Array<Promise<(input: Input) => Input>> = []; | ||
@@ -139,3 +139,3 @@ this.schema.each( | ||
const setResolvedData = Promise.resolve() | ||
.then(() => resolver(value)) | ||
.then(() => resolver(value, ctx)) | ||
.then((resolvedData) => (item: typeof input) => JSONQuery.set(item, pointer, resolvedData, 'replace' as any)) | ||
@@ -142,0 +142,0 @@ .catch((e) => Promise.reject(new JsonResolutionError(e, pointer, value))); |
@@ -38,4 +38,8 @@ import type { JSONSchema } from '@squiz/json-schema-library'; | ||
export type Resolver<INPUT, OUTPUT> = (input: INPUT) => MaybePromise<OUTPUT>; | ||
export type ResolverContext = { | ||
baseUrl?: string; | ||
}; | ||
export type Resolver<INPUT, OUTPUT> = (input: INPUT, ctx?: ResolverContext) => MaybePromise<OUTPUT>; | ||
/** | ||
@@ -42,0 +46,0 @@ * A JSON Type Resolver class which stores the primitive and resolvable JSON Schema types and their resolvers |
import { PrimitiveType } from '../jsonTypeResolution/TypeResolver'; | ||
import type { ExifData } from 'exif'; | ||
@@ -18,3 +19,3 @@ interface SquizImageData { | ||
exif?: import('exif').ExifData; | ||
exif?: ExifData; | ||
@@ -21,0 +22,0 @@ imageVariations: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
988844
8
23799
4
+ Added@types/exif@^0.6.5
+ Added@types/exif@0.6.5(transitive)
+ Added@types/node@22.13.1(transitive)
+ Addedundici-types@6.20.0(transitive)