From ff6eb1723ecdc8256244aab07b25955ff4d30cf2 Mon Sep 17 00:00:00 2001 From: Michael Brich Date: Sun, 9 Jun 2024 23:43:35 -0700 Subject: [PATCH] Type Fixes --- src/custom/schema/verify.ts | 3 ++- src/custom/types.ts | 7 +++---- src/schema.ts | 17 ++++++++--------- src/schema/field/type.ts | 4 ++-- src/schema/verify/value.ts | 2 +- src/verified/map.ts | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/custom/schema/verify.ts b/src/custom/schema/verify.ts index 77db746..5056528 100644 --- a/src/custom/schema/verify.ts +++ b/src/custom/schema/verify.ts @@ -28,6 +28,7 @@ import {type SchemaVerifyInit} from '../../schema/verify/init'; /** * @category Schema – Custom Type */ -export interface CustomSchemaVerify extends SchemaVerifyInit { +export interface CustomSchemaVerify + extends SchemaVerifyInit { typeId: string; } diff --git a/src/custom/types.ts b/src/custom/types.ts index d52c1a1..b4da81b 100644 --- a/src/custom/types.ts +++ b/src/custom/types.ts @@ -35,8 +35,7 @@ import {type Resettable} from '@toreda/types'; import {type CustomSchemaType} from './schema/type'; import {Schema} from '../schema'; import {type VerifiedSchema} from '../verified/schema'; -import {type VerifiedField} from '../verified/field'; -import {VerifiedMap} from '../verified/map'; +import {type VerifiedMap} from '../verified/map'; /** * Registry of a single schema's registered custom types. @@ -203,8 +202,8 @@ export class CustomTypes, VerifiedT = In return fate; } - public async verifyOnly(init: CustomSchemaVerify): Promise>> { - const fate = new Fate>(); + public async verifyOnly(init: CustomSchemaVerify): Promise>> { + const fate = new Fate>(); const schema = this.getSchema(init.typeId); diff --git a/src/schema.ts b/src/schema.ts index c4e4131..8123084 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -45,7 +45,6 @@ import {type SchemaVerifyInit} from './schema/verify/init'; import {type SchemaVerifyValue} from './schema/verify/value'; import {type VerifiedField} from './verified/field'; import {type VerifiedMap} from './verified/map'; -import {type VerifiedSchema} from './verified/schema'; /** * @category Schema @@ -177,8 +176,8 @@ export class Schema, TransformedT = Inpu value: InputT | SchemaData, tracer: Tracer, base: Log - ): Promise>> { - const fate = new Fate>(); + ): Promise | VerifiedField[]>> { + const fate = new Fate | VerifiedField[]>(); if (value === null) { if (field.types.includes('null')) { @@ -278,9 +277,9 @@ export class Schema, TransformedT = Inpu * the expected range or format (if any). */ public async verifyValue( - init: SchemaVerifyValue - ): Promise>> { - const fate = new Fate>(); + init: SchemaVerifyValue + ): Promise>> { + const fate = new Fate>(); if (this.isBuiltIn(init.fieldType)) { if (this.valueHasBuiltinType(init.fieldType, init.value)) { @@ -318,7 +317,7 @@ export class Schema, TransformedT = Inpu ); } - public async verify(init: SchemaVerifyInit): Promise> { + public async verify(init: SchemaVerifyInit): Promise> { const fate = new Fate(); if (!init) { @@ -386,8 +385,8 @@ export class Schema, TransformedT = Inpu * Verify provided data object's structure, content, and types against this schema. * @param init */ - public async verifyOnly(init: SchemaVerifyInit): Promise>> { - const fate = new Fate>(); + public async verifyOnly(init: SchemaVerifyInit): Promise>> { + const fate = new Fate>(); const currPath = init.tracer ? init.tracer : new Tracer(); // Root schemas (no parent) use their schema name as the first path item. Child schemas DO NOT diff --git a/src/schema/field/type.ts b/src/schema/field/type.ts index e21388c..a600091 100644 --- a/src/schema/field/type.ts +++ b/src/schema/field/type.ts @@ -28,7 +28,7 @@ * * @category Schema – Field */ -export type SchemaFieldType = +export type SchemaFieldType = | 'bigint[]' | 'bigint' | 'BigInt' @@ -65,4 +65,4 @@ export type SchemaFieldType = | 'url[]' | 'time' | 'time[]' - | Extract; + | Extract; diff --git a/src/schema/verify/value.ts b/src/schema/verify/value.ts index 79bdb1f..476644c 100644 --- a/src/schema/verify/value.ts +++ b/src/schema/verify/value.ts @@ -31,7 +31,7 @@ import {type SchemaData} from '../data'; /** * @category Schema */ -export interface SchemaVerifyValue { +export interface SchemaVerifyValue { fieldId: string; fieldType: SchemaFieldType; tracer: Tracer; diff --git a/src/verified/map.ts b/src/verified/map.ts index 394d061..600e249 100644 --- a/src/verified/map.ts +++ b/src/verified/map.ts @@ -30,4 +30,4 @@ import {type VerifiedField} from './field'; * * @category Schema – Transform Output */ -export type VerifiedMap = Map | null>; +export type VerifiedMap = Map | VerifiedField[] | null>;