@balena/sbvr-types
Advanced tools
Comparing version 7.0.10 to 7.1.0-build-accept-date-4c894f752ef39b567901a165029961f3d75cca74-1
@@ -7,2 +7,8 @@ # Change Log | ||
# v7.1.0 | ||
## (2024-06-03) | ||
* Accept `Date` for the write types of `Date Time`/`Date`/`Time` [Pagan Gazzard] | ||
* Export typescript read/write types for each sbvr type [Pagan Gazzard] | ||
# v7.0.10 | ||
@@ -9,0 +15,0 @@ ## (2024-04-09) |
@@ -25,2 +25,25 @@ import type { SbvrType } from './type-utils'; | ||
export { WebResource as WebResourceType } from './types/web-resource'; | ||
export type Types = { | ||
'Big Integer': BigInteger.Types; | ||
'Big Serial': BigSerial.Types; | ||
Boolean: Boolean.Types; | ||
'Case Insensitive Text': CaseInsensitiveText.Types; | ||
Color: Color.Types; | ||
ConceptType: ConceptType.Types; | ||
Date: Date.Types; | ||
'Date Time': DateTime.Types; | ||
File: File.Types; | ||
ForeignKey: ForeignKey.Types; | ||
Hashed: Hashed.Types; | ||
Integer: Integer.Types; | ||
Interval: Interval.Types; | ||
JSON: JSON.Types; | ||
Real: Real.Types; | ||
Serial: Serial.Types; | ||
SHA: SHA.Types; | ||
'Short Text': ShortText.Types; | ||
Text: Text.Types; | ||
Time: Time.Types; | ||
WebResource: WebResource.Types; | ||
}; | ||
declare const _default: { | ||
@@ -27,0 +50,0 @@ 'Big Integer': typeof BigInteger; |
@@ -19,2 +19,6 @@ export interface DatabaseTypeFn { | ||
} | ||
export interface TsTypes<Read, Write> { | ||
Read: Read; | ||
Write: Write; | ||
} | ||
export type FetchProcessing<Read> = (data: unknown) => Read | null | undefined; | ||
@@ -21,0 +25,0 @@ export interface Validate<Write, DbWrite> { |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -25,3 +25,3 @@ export declare const nativeFactTypes: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,5 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,7 +10,6 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = boolean; | ||
type WriteType = boolean | 0 | 1; | ||
export type Types = TypeUtils.TsTypes<boolean, boolean | 0 | 1>; | ||
type DbWriteType = boolean; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,5 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -11,3 +11,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = { | ||
type ColorObj = { | ||
r: number; | ||
@@ -18,3 +18,3 @@ g: number; | ||
}; | ||
type WriteType = number | ReadType; | ||
export type Types = TypeUtils.TsTypes<ColorObj, number | ColorObj>; | ||
type DbWriteType = number; | ||
@@ -29,4 +29,4 @@ export declare const nativeProperties: { | ||
}; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -25,3 +25,3 @@ export declare const nativeFactTypes: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,6 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = string; | ||
type WriteType = string | number; | ||
export type Types = TypeUtils.TsTypes<string, string | number | Date>; | ||
type DbWriteType = Date; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const nativeFactTypes: { | ||
@@ -24,3 +23,3 @@ 'Date Time': { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,6 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = string; | ||
type WriteType = string | number; | ||
export type Types = TypeUtils.TsTypes<string, string | number | Date>; | ||
type DbWriteType = Date; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const nativeFactTypes: { | ||
@@ -21,3 +20,3 @@ Date: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -11,5 +11,5 @@ /// <reference types="node" /> | ||
}; | ||
type WriteType = Buffer | string; | ||
export type Types = TypeUtils.TsTypes<Buffer, Buffer | string>; | ||
type DbWriteType = Buffer; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -25,3 +25,3 @@ export declare const nativeFactTypes: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -11,6 +11,6 @@ import type * as Bcrypt from 'bcrypt'; | ||
}; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export declare const compare: typeof Bcrypt.compare; | ||
export {}; |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -25,3 +25,3 @@ export declare const nativeFactTypes: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,5 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -18,11 +18,10 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = { | ||
export type Types = TypeUtils.TsTypes<{ | ||
[key: string]: JSON; | ||
} | JSON[]; | ||
type WriteType = { | ||
} | JSON[], { | ||
[key: string]: JSONable; | ||
} | JSONable[]; | ||
} | JSONable[]>; | ||
type DbWriteType = string; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -25,3 +25,3 @@ export declare const nativeFactTypes: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,5 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,7 +10,7 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export declare const validateSync: (value: string) => string; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export declare const compare: (value: string, result: string) => Promise<boolean>; | ||
export {}; |
@@ -10,5 +10,5 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,3 +10,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
@@ -26,3 +26,3 @@ export declare const nativeProperties: { | ||
}; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -10,7 +10,6 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = string; | ||
type WriteType = number | string; | ||
export type Types = TypeUtils.TsTypes<string, number | string | Date>; | ||
type DbWriteType = string; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
@@ -20,4 +20,3 @@ import * as TypeUtils from '../type-utils'; | ||
}; | ||
type ReadType = WebResource; | ||
type WriteType = WebResource; | ||
export type Types = TypeUtils.TsTypes<WebResource, WebResource>; | ||
type DbWriteType = string; | ||
@@ -34,4 +33,4 @@ export declare const nativeProperties: { | ||
}; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<ReadType>; | ||
export declare const validate: TypeUtils.Validate<WriteType, DbWriteType>; | ||
export declare const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']>; | ||
export declare const validate: TypeUtils.Validate<Types['Write'], DbWriteType>; | ||
export {}; |
{ | ||
"name": "@balena/sbvr-types", | ||
"version": "7.0.10", | ||
"version": "7.1.0-build-accept-date-4c894f752ef39b567901a165029961f3d75cca74-1", | ||
"description": "SBVR type definitions.", | ||
@@ -54,4 +54,4 @@ "main": "out", | ||
"versionist": { | ||
"publishedAt": "2024-04-09T10:21:20.009Z" | ||
"publishedAt": "2024-06-03T18:04:24.694Z" | ||
} | ||
} |
@@ -29,2 +29,27 @@ import type { SbvrType } from './type-utils'; | ||
export type Types = { | ||
'Big Integer': BigInteger.Types; | ||
'Big Serial': BigSerial.Types; | ||
// eslint-disable-next-line id-denylist | ||
Boolean: Boolean.Types; | ||
'Case Insensitive Text': CaseInsensitiveText.Types; | ||
Color: Color.Types; | ||
ConceptType: ConceptType.Types; | ||
Date: Date.Types; | ||
'Date Time': DateTime.Types; | ||
File: File.Types; | ||
ForeignKey: ForeignKey.Types; | ||
Hashed: Hashed.Types; | ||
Integer: Integer.Types; | ||
Interval: Interval.Types; | ||
JSON: JSON.Types; | ||
Real: Real.Types; | ||
Serial: Serial.Types; | ||
SHA: SHA.Types; | ||
'Short Text': ShortText.Types; | ||
Text: Text.Types; | ||
Time: Time.Types; | ||
WebResource: WebResource.Types; | ||
}; | ||
export default { | ||
@@ -54,2 +79,4 @@ 'Big Integer': BigInteger, | ||
} satisfies { | ||
[fieldType in keyof Types]: SbvrType; | ||
} & { | ||
Hashed: SbvrType & { | ||
@@ -62,3 +89,2 @@ compare: (str: string, hash: string) => Promise<boolean>; | ||
}; | ||
[fieldType: string]: SbvrType; | ||
}; |
@@ -19,2 +19,6 @@ export interface DatabaseTypeFn { | ||
} | ||
export interface TsTypes<Read, Write> { | ||
Read: Read; | ||
Write: Write; | ||
} | ||
@@ -21,0 +25,0 @@ export type FetchProcessing<Read> = (data: unknown) => Read | null | undefined; |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -21,3 +21,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -26,6 +26,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -19,11 +19,11 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = boolean; | ||
type WriteType = boolean | 0 | 1; | ||
export type Types = TypeUtils.TsTypes<boolean, boolean | 0 | 1>; | ||
type DbWriteType = boolean; | ||
// `BOOLEAN` on sqlite/websql is just an alias for `INTEGER` hence the `=== 1` check | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => | ||
data === true || data === 1; | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => data === true || data === 1; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((originalValue) => { | ||
@@ -30,0 +30,0 @@ // We use Number rather than parseInt as it deals with booleans and will return NaN for things like "a1" |
@@ -12,6 +12,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.text(); |
@@ -19,3 +19,3 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = { | ||
type ColorObj = { | ||
r: number; | ||
@@ -26,3 +26,3 @@ g: number; | ||
}; | ||
type WriteType = number | ReadType; | ||
export type Types = TypeUtils.TsTypes<ColorObj, number | ColorObj>; | ||
type DbWriteType = number; | ||
@@ -51,3 +51,5 @@ | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
if (typeof data !== 'number') { | ||
@@ -66,3 +68,3 @@ throw new Error('Fetched color is not an integer: ' + typeof data); | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((value) => { | ||
@@ -69,0 +71,0 @@ let processedValue: number; |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -21,3 +21,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -12,7 +12,8 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = string; | ||
type WriteType = string | number; | ||
export type Types = TypeUtils.TsTypes<string, string | number | Date>; | ||
type DbWriteType = Date; | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
if (data == null) { | ||
@@ -43,3 +44,3 @@ return data; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.date; |
@@ -12,7 +12,8 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = string; | ||
type WriteType = string | number; | ||
export type Types = TypeUtils.TsTypes<string, string | number | Date>; | ||
type DbWriteType = Date; | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
if (data == null) { | ||
@@ -39,3 +40,3 @@ return data; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.date; |
@@ -11,6 +11,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = Buffer | string; | ||
export type Types = TypeUtils.TsTypes<Buffer, Buffer | string>; | ||
type DbWriteType = Buffer; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((value) => { | ||
@@ -17,0 +17,0 @@ if (Buffer.isBuffer(value)) { |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -21,3 +21,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -21,6 +21,6 @@ import type * as Bcrypt from 'bcrypt'; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired(async (value) => { | ||
@@ -27,0 +27,0 @@ if (typeof value !== 'string') { |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -21,3 +21,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -12,6 +12,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -23,7 +23,11 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = { [key: string]: JSON } | JSON[]; | ||
type WriteType = { [key: string]: JSONable } | JSONable[]; | ||
export type Types = TypeUtils.TsTypes< | ||
{ [key: string]: JSON } | JSON[], | ||
{ [key: string]: JSONable } | JSONable[] | ||
>; | ||
type DbWriteType = string; | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
if (typeof data === 'string') { | ||
@@ -35,3 +39,3 @@ return JSON.parse(data); | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((value) => { | ||
@@ -38,0 +42,0 @@ // Disallow primitives |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
@@ -21,3 +21,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((value) => { | ||
@@ -24,0 +24,0 @@ const processedValue = parseFloat(value); |
@@ -26,6 +26,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = number; | ||
export type Types = TypeUtils.TsTypes<number, number>; | ||
type DbWriteType = number; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.integer; |
@@ -33,3 +33,3 @@ // We are using the P-H-C storing format: | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
@@ -39,3 +39,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired((value) => { | ||
@@ -42,0 +42,0 @@ if (typeof value !== 'string') { |
@@ -12,6 +12,6 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.text(255); |
@@ -12,3 +12,3 @@ import * as TypeUtils from '../type-utils'; | ||
type WriteType = string; | ||
export type Types = TypeUtils.TsTypes<string, string>; | ||
type DbWriteType = string; | ||
@@ -31,3 +31,3 @@ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.text(); |
@@ -12,7 +12,8 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = string; | ||
type WriteType = number | string; | ||
export type Types = TypeUtils.TsTypes<string, number | string | Date>; | ||
type DbWriteType = string; | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
if (data != null) { | ||
@@ -25,15 +26,13 @@ // We append the date of the epoch so that we can parse this as a valid date. | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = (async ( | ||
value, | ||
required, | ||
) => { | ||
const date = await TypeUtils.validate.date(value, required); | ||
if (date == null) { | ||
return date; | ||
} | ||
return date.toLocaleTimeString(); | ||
}) as { | ||
(value: WriteType, required: true): Promise<DbWriteType>; | ||
(value: WriteType, required: false): Promise<DbWriteType | null>; | ||
(value: WriteType, required: boolean): Promise<DbWriteType | null>; | ||
}; | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
(async (value, required) => { | ||
const date = await TypeUtils.validate.date(value, required); | ||
if (date == null) { | ||
return date; | ||
} | ||
return date.toLocaleTimeString(); | ||
}) as { | ||
(value: Types['Write'], required: true): Promise<DbWriteType>; | ||
(value: Types['Write'], required: false): Promise<DbWriteType | null>; | ||
(value: Types['Write'], required: boolean): Promise<DbWriteType | null>; | ||
}; |
@@ -35,4 +35,3 @@ import * as TypeUtils from '../type-utils'; | ||
type ReadType = WebResource; | ||
type WriteType = WebResource; | ||
export type Types = TypeUtils.TsTypes<WebResource, WebResource>; | ||
type DbWriteType = string; | ||
@@ -94,3 +93,5 @@ | ||
*/ | ||
export const fetchProcessing: TypeUtils.FetchProcessing<ReadType> = (data) => { | ||
export const fetchProcessing: TypeUtils.FetchProcessing<Types['Read']> = ( | ||
data, | ||
) => { | ||
let refData: WebResource; | ||
@@ -128,3 +129,3 @@ if (data === null) { | ||
*/ | ||
export const validate: TypeUtils.Validate<WriteType, DbWriteType> = | ||
export const validate: TypeUtils.Validate<Types['Write'], DbWriteType> = | ||
TypeUtils.validate.checkRequired(async (value: WebResource) => { | ||
@@ -131,0 +132,0 @@ if (typeof value !== 'object') { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
148260
2284
2