Comparing version 2.0.0-alpha.1 to 2.0.1
@@ -1,2 +0,2 @@ | ||
export declare type MeaningfulTypeofExtractor = (value: any) => string | undefined; | ||
export type MeaningfulTypeofExtractor = (value: any) => string | undefined; | ||
export declare const getMeaningfulTypeofExtractor: () => MeaningfulTypeofExtractor | undefined; | ||
@@ -3,0 +3,0 @@ /** Registers a function that can determine a more human-meaningful type from a given value. Basic types (ex. `number`) are automatically |
import type { JsonValue } from '../../types/json-value'; | ||
import type { Schema } from '../../types/schema'; | ||
import type { SerDes } from '../../types/ser-des'; | ||
export declare type CustomValidationResult = { | ||
export type CustomValidationResult = { | ||
error?: string; | ||
@@ -9,3 +9,3 @@ } | { | ||
}; | ||
export declare type CustomValidation<ValueT> = (value: ValueT) => CustomValidationResult; | ||
export type CustomValidation<ValueT> = (value: ValueT) => CustomValidationResult; | ||
export interface CustomSchemaOptions<ValueT, SerializedT extends JsonValue> { | ||
@@ -12,0 +12,0 @@ serDes: SerDes<ValueT, SerializedT>; |
import type { Schema } from '../../types/schema'; | ||
/** Infers a record where the values of the original type are inferred to be the values of `Schemas` */ | ||
declare type InferRecordOfSchemasFromRecordOfValues<ObjectT extends Record<string, any>> = { | ||
type InferRecordOfSchemasFromRecordOfValues<ObjectT extends Record<string, any>> = { | ||
[KeyT in keyof ObjectT]: Schema<ObjectT[KeyT]>; | ||
}; | ||
/** Picks the fields of an object type that are never undefined */ | ||
declare type PickAlwaysDefinedValues<Base> = Pick<Base, { | ||
type PickAlwaysDefinedValues<Base> = Pick<Base, { | ||
[Key in keyof Base]: Base[Key] extends Exclude<Base[Key], undefined> ? Key : never; | ||
}[keyof Base]>; | ||
/** Picks the fields of an object type that might be undefined */ | ||
declare type PickPossiblyUndefinedValues<Base> = Omit<Base, keyof PickAlwaysDefinedValues<Base>>; | ||
type PickPossiblyUndefinedValues<Base> = Omit<Base, keyof PickAlwaysDefinedValues<Base>>; | ||
/** Converts types like `{ x: string, y: string | undefined }` to types like `{ x: string, y?: string }` */ | ||
declare type TreatUndefinedAsOptional<ObjectT extends Record<string, any>> = PickAlwaysDefinedValues<ObjectT> & Partial<PickPossiblyUndefinedValues<ObjectT>>; | ||
type TreatUndefinedAsOptional<ObjectT extends Record<string, any>> = PickAlwaysDefinedValues<ObjectT> & Partial<PickPossiblyUndefinedValues<ObjectT>>; | ||
/** Requires an object, where each key has it's own schema. */ | ||
@@ -15,0 +15,0 @@ export interface ObjectSchema<ObjectT extends Record<string, any>> extends Schema<TreatUndefinedAsOptional<ObjectT>> { |
@@ -7,3 +7,3 @@ import type { CommonSchemaMeta, PureSchema } from '../../types/pure-schema'; | ||
* of `PureSchema<ValueT>` are directly exposed */ | ||
export declare type InternalSchema<ValueT, PureSchemaT extends PureSchema<ValueT>> = PureSchemaT & SchemaFunctions<ValueT> & InternalSchemaFunctions & { | ||
export type InternalSchema<ValueT, PureSchemaT extends PureSchema<ValueT>> = PureSchemaT & SchemaFunctions<ValueT> & InternalSchemaFunctions & { | ||
/** A marker that can be used for testing if this is a YaSchema schema */ | ||
@@ -19,3 +19,3 @@ isYaSchema: true; | ||
/** A function that can be used to inject functionality into a `PureSchema`, turning it into an `InternalSchema`. */ | ||
export declare type InternalSchemaMaker = <ValueT, IncompletePureSchemaT extends Omit<PureSchema<ValueT>, keyof CommonSchemaMeta>>(pureSchema: IncompletePureSchemaT, args: InternalSchemaMakerArgs) => InternalSchema<ValueT, IncompletePureSchemaT & CommonSchemaMeta>; | ||
export type InternalSchemaMaker = <ValueT, IncompletePureSchemaT extends Omit<PureSchema<ValueT>, keyof CommonSchemaMeta>>(pureSchema: IncompletePureSchemaT, args: InternalSchemaMakerArgs) => InternalSchema<ValueT, IncompletePureSchemaT & CommonSchemaMeta>; | ||
/** Adds functions such as `validate` and `optional` and the `isYaSchema` marker */ | ||
@@ -22,0 +22,0 @@ export declare const makeInternalSchema: InternalSchemaMaker; |
@@ -9,3 +9,3 @@ import type { SchemaPreferredValidationMode, SchemaPreferredValidationModeDepth } from '../../../types/schema-preferred-validation'; | ||
*/ | ||
export declare type InternalTransformationType = 'none' | 'serialize' | 'deserialize'; | ||
export type InternalTransformationType = 'none' | 'serialize' | 'deserialize'; | ||
export interface InternalValidationOptions { | ||
@@ -37,6 +37,6 @@ transformation: InternalTransformationType; | ||
/** Synchronously validates and potentially transforms the specified value */ | ||
export declare type InternalValidator = (value: any, validatorOptions: InternalValidationOptions, path: string) => InternalValidationResult; | ||
export type InternalValidator = (value: any, validatorOptions: InternalValidationOptions, path: string) => InternalValidationResult; | ||
/** Asynchronously validates and potentially transforms the specified value */ | ||
export declare type InternalAsyncValidator = (value: any, validatorOptions: InternalValidationOptions, path: string) => Promise<InternalValidationResult> | InternalValidationResult; | ||
export declare type InternalValidationResult = { | ||
export type InternalAsyncValidator = (value: any, validatorOptions: InternalValidationOptions, path: string) => Promise<InternalValidationResult> | InternalValidationResult; | ||
export type InternalValidationResult = { | ||
error: () => string; | ||
@@ -43,0 +43,0 @@ errorPath: string; |
@@ -24,3 +24,3 @@ import type { SingleOrArray } from '../types/single-or-array'; | ||
export declare const makeNumberSubtypeArray: <T extends number>(...args: SingleOrArray<T>[]) => NumberSubtypeArray<T>; | ||
export declare type NumberSubtypeArray<T extends number> = T[] & { | ||
export type NumberSubtypeArray<T extends number> = T[] & { | ||
/** If the specified value belongs to the array returns the value as the desired type */ | ||
@@ -27,0 +27,0 @@ checked: (value: number) => T | undefined; |
@@ -24,3 +24,3 @@ import type { SingleOrArray } from '../types/single-or-array'; | ||
export declare const makeStringSubtypeArray: <T extends string>(...args: SingleOrArray<T>[]) => StringSubtypeArray<T>; | ||
export declare type StringSubtypeArray<T extends string> = T[] & { | ||
export type StringSubtypeArray<T extends string> = T[] & { | ||
/** If the specified value belongs to the array returns the value as the desired type */ | ||
@@ -27,0 +27,0 @@ checked: (value: string) => T | undefined; |
/** The built-in schema types that represent data types. This is useful for code generation tools. */ | ||
export declare const dataTypes: import("../type-utils/make-string-subtype-array").StringSubtypeArray<"string" | "number" | "boolean" | "object" | "record" | "custom" | "any" | "array" | "date" | "regex" | "restrictedNumber" | "tuple">; | ||
export declare type DataType = typeof dataTypes[0]; | ||
export type DataType = (typeof dataTypes)[0]; | ||
//# sourceMappingURL=data-types.d.ts.map |
@@ -6,3 +6,3 @@ import type { TransformationOptions } from './transformation-options'; | ||
* indicated by `errorLevel` */ | ||
export declare type DeserializationResult<T> = { | ||
export type DeserializationResult<T> = { | ||
error?: undefined; | ||
@@ -19,5 +19,5 @@ errorPath?: undefined; | ||
/** Synchronously deserializes the specified value from JSON */ | ||
export declare type Deserializer<T> = (value: any, options?: TransformationOptions & ValidationOptions) => DeserializationResult<T>; | ||
export type Deserializer<T> = (value: any, options?: TransformationOptions & ValidationOptions) => DeserializationResult<T>; | ||
/** Asynchronously deserializes the specified value from JSON */ | ||
export declare type AsyncDeserializer<T> = (value: any, options?: TransformationOptions & ValidationOptions) => Promise<DeserializationResult<T>>; | ||
export type AsyncDeserializer<T> = (value: any, options?: TransformationOptions & ValidationOptions) => Promise<DeserializationResult<T>>; | ||
//# sourceMappingURL=deserializer.d.ts.map |
/** Any JSON-compatible array value */ | ||
export declare type JsonArray = JsonValue[]; | ||
export type JsonArray = JsonValue[]; | ||
/** Any JSON-compatible object value */ | ||
export declare type JsonObject = { | ||
export type JsonObject = { | ||
[key: string]: JsonValue; | ||
}; | ||
/** Any JSON-compatible value */ | ||
export declare type JsonValue = string | number | boolean | null | JsonArray | JsonObject; | ||
export type JsonValue = string | number | boolean | null | JsonArray | JsonObject; | ||
//# sourceMappingURL=json-value.d.ts.map |
/** The built-in schema types that represent type modifiers or markers. This is useful for code generation tools. */ | ||
export declare const markerTypes: import("../type-utils/make-string-subtype-array").StringSubtypeArray<"optional" | "allOf" | "allowEmptyString" | "allowNull" | "deprecated" | "not" | "oneOf" | "root" | "upgraded">; | ||
export declare type MarkerType = typeof markerTypes[0]; | ||
export type MarkerType = (typeof markerTypes)[0]; | ||
//# sourceMappingURL=marker-types.d.ts.map |
@@ -8,3 +8,3 @@ import type { ValidationMode } from './validation-options'; | ||
*/ | ||
export declare type SchemaPreferredValidationMode = ValidationMode | 'initial' | 'inherit'; | ||
export type SchemaPreferredValidationMode = ValidationMode | 'initial' | 'inherit'; | ||
/** | ||
@@ -17,3 +17,3 @@ * The depth to apply schema-level validation preferences over. | ||
*/ | ||
export declare type SchemaPreferredValidationModeDepth = 'deep' | 'shallow'; | ||
export type SchemaPreferredValidationModeDepth = 'deep' | 'shallow'; | ||
//# sourceMappingURL=schema-preferred-validation.d.ts.map |
export declare const schemaTypes: import("../type-utils/make-string-subtype-array").StringSubtypeArray<"string" | "number" | "boolean" | "object" | "optional" | "record" | "custom" | "any" | "array" | "date" | "regex" | "restrictedNumber" | "tuple" | "allOf" | "allowEmptyString" | "allowNull" | "deprecated" | "not" | "oneOf" | "root" | "upgraded">; | ||
export declare type SchemaType = typeof schemaTypes[0]; | ||
export type SchemaType = (typeof schemaTypes)[0]; | ||
//# sourceMappingURL=schema-type.d.ts.map |
import type { PureSchema } from './pure-schema'; | ||
import type { SchemaFunctions } from './schema-functions'; | ||
/** A generic schema */ | ||
export declare type Schema<ValueT = any> = PureSchema<ValueT> & SchemaFunctions<ValueT> & { | ||
export type Schema<ValueT = any> = PureSchema<ValueT> & SchemaFunctions<ValueT> & { | ||
/** A marker that can be used for testing if this is a YaSchema schema */ | ||
@@ -6,0 +6,0 @@ isYaSchema: true; |
@@ -6,3 +6,3 @@ import type { JsonValue } from './json-value'; | ||
/** If error is undefined, the result is a success. Otherwise, there was a problem. */ | ||
export declare type SerializationResult = { | ||
export type SerializationResult = { | ||
error?: undefined; | ||
@@ -19,5 +19,5 @@ errorPath?: string; | ||
/** Synchronously serializes the specified value into JSON */ | ||
export declare type Serializer<T> = (value: T, options?: TransformationOptions & ValidationOptions) => SerializationResult; | ||
export type Serializer<T> = (value: T, options?: TransformationOptions & ValidationOptions) => SerializationResult; | ||
/** Asynchronously serializes the specified value into JSON */ | ||
export declare type AsyncSerializer<T> = (value: T, options?: TransformationOptions & ValidationOptions) => Promise<SerializationResult>; | ||
export type AsyncSerializer<T> = (value: T, options?: TransformationOptions & ValidationOptions) => Promise<SerializationResult>; | ||
//# sourceMappingURL=serializer.d.ts.map |
/** A single value or an array of values */ | ||
export declare type SingleOrArray<T> = T | T[]; | ||
export type SingleOrArray<T> = T | T[]; | ||
//# sourceMappingURL=single-or-array.d.ts.map |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare type ValidationErrorLevel = 'error' | 'warning'; | ||
export type ValidationErrorLevel = 'error' | 'warning'; | ||
//# sourceMappingURL=validation-error-level.d.ts.map |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare type ValidationMode = 'none' | 'soft' | 'hard'; | ||
export type ValidationMode = 'none' | 'soft' | 'hard'; | ||
export interface ValidationOptions { | ||
@@ -9,0 +9,0 @@ /** |
import type { ValidationErrorLevel } from './validation-error-level'; | ||
/** If error is undefined, the result is a success. Otherwise, there was a problem. */ | ||
export declare type ValidationResult = { | ||
export type ValidationResult = { | ||
error: string; | ||
@@ -13,5 +13,5 @@ errorLevel: ValidationErrorLevel; | ||
/** Synchronously validates the specified value */ | ||
export declare type Validator = (value: any) => ValidationResult; | ||
export type Validator = (value: any) => ValidationResult; | ||
/** Asynchronously validates the specified value */ | ||
export declare type AsyncValidator = (value: any) => Promise<ValidationResult>; | ||
export type AsyncValidator = (value: any) => Promise<ValidationResult>; | ||
//# sourceMappingURL=validator.d.ts.map |
{ | ||
"name": "yaschema", | ||
"version": "2.0.0-alpha.1", | ||
"version": "2.0.1", | ||
"description": "Yet another schema", | ||
@@ -18,3 +18,2 @@ "keywords": [ | ||
"scripts": { | ||
"audit": "yarn audit --moderate", | ||
"build": "tsc -p tsconfig.build.json", | ||
@@ -25,4 +24,5 @@ "build:dev": "trash dev-build && yarn build && mkdir dev-build && cp -r lib dev-build && cp package.json dev-build && (cd dev-build && echo 'package' `pwd`)", | ||
"lint": "eslint 'src/**/*.ts?(x)' --max-warnings 0", | ||
"prepublishOnly": "yarn clean && yarn test && yarn lint && yarn audit && yarn clean && yarn build && yarn generate:docs", | ||
"prepublishOnly": "yarn clean && yarn test && yarn lint && yarn test:audit && yarn clean && yarn build && yarn generate:docs", | ||
"test": "yarn test:check-circular-dependencies && yarn test:unit-tests", | ||
"test:audit": "yarn audit --level moderate; [[ $? -ge 4 ]] && exit 1 || exit 0", | ||
"test:check-circular-dependencies": "yarn build && npx madge --circular ./lib", | ||
@@ -37,23 +37,23 @@ "test:unit-tests:": "npx jest --runInBand --coverage", | ||
"devDependencies": { | ||
"@types/jest": "^28.1.7", | ||
"@types/lodash": "^4.14.184", | ||
"@typescript-eslint/eslint-plugin": "^5.33.1", | ||
"@typescript-eslint/parser": "^5.33.1", | ||
"bignumber.js": "^9.1.0", | ||
"eslint": "8.22.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-import-resolver-typescript": "^3.4.2", | ||
"@types/jest": "^29.2.5", | ||
"@types/lodash": "^4.14.191", | ||
"@typescript-eslint/eslint-plugin": "^5.48.1", | ||
"@typescript-eslint/parser": "^5.48.1", | ||
"bignumber.js": "^9.1.1", | ||
"eslint": "8.31.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-import-resolver-typescript": "^3.5.2", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-simple-import-sort": "^7.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
"jest": "28.1.3", | ||
"eslint-plugin-simple-import-sort": "^8.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.17", | ||
"jest": "29.3.1", | ||
"madge": "5.0.1", | ||
"prettier": "2.7.1", | ||
"prettier": "2.8.2", | ||
"trash-cli": "5.0.0", | ||
"ts-jest": "^28.0.8", | ||
"typedoc": "^0.23.10", | ||
"typescript": "4.7.4" | ||
"ts-jest": "^29.0.3", | ||
"typedoc": "^0.23.24", | ||
"typescript": "4.9.4" | ||
} | ||
} |
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
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
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
1
379876