node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

26
server/node_modules/yup/es/Condition.d.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import Reference from './Reference';
import { SchemaLike } from './types';
export interface ConditionBuilder<T extends SchemaLike> {
(this: T, value: any, schema: T): SchemaLike;
(v1: any, v2: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, v4: any, schema: T): SchemaLike;
}
export declare type ConditionConfig<T extends SchemaLike> = {
is: any | ((...values: any[]) => boolean);
then?: SchemaLike | ((schema: T) => SchemaLike);
otherwise?: SchemaLike | ((schema: T) => SchemaLike);
};
export declare type ConditionOptions<T extends SchemaLike> = ConditionBuilder<T> | ConditionConfig<T>;
export declare type ResolveOptions<TContext = any> = {
value?: any;
parent?: any;
context?: TContext;
};
declare class Condition<T extends SchemaLike = SchemaLike> {
refs: Reference[];
fn: ConditionBuilder<T>;
constructor(refs: Reference[], options: ConditionOptions<T>);
resolve(base: T, options: ResolveOptions): any;
}
export default Condition;

43
server/node_modules/yup/es/Condition.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
import has from 'lodash/has';
import isSchema from './util/isSchema';
class Condition {
constructor(refs, options) {
this.refs = refs;
this.refs = refs;
if (typeof options === 'function') {
this.fn = options;
return;
}
if (!has(options, 'is')) throw new TypeError('`is:` is required for `when()` conditions');
if (!options.then && !options.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
let {
is,
then,
otherwise
} = options;
let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
this.fn = function (...args) {
let options = args.pop();
let schema = args.pop();
let branch = check(...args) ? then : otherwise;
if (!branch) return undefined;
if (typeof branch === 'function') return branch(schema);
return schema.concat(branch.resolve(options));
};
}
resolve(base, options) {
let values = this.refs.map(ref => ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
let schema = this.fn.apply(base, values.concat(base, options));
if (schema === undefined || schema === base) return base;
if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
return schema.resolve(options);
}
}
export default Condition;

28
server/node_modules/yup/es/Lazy.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import type { Callback, ValidateOptions } from './types';
import type { ResolveOptions } from './Condition';
import type { AnySchema, CastOptions } from './schema';
import { TypedSchema, TypeOf } from './util/types';
declare type ContextOf<T> = T extends AnySchema<any, infer C> ? C : never;
export declare type LazyBuilder<T extends AnySchema = any> = (value: any, options: ResolveOptions) => T;
export declare function create<T extends AnySchema>(builder: LazyBuilder<T>): Lazy<T, ContextOf<T>>;
export declare type LazyReturnValue<T> = T extends Lazy<infer TSchema> ? TSchema : never;
export declare type LazyType<T> = LazyReturnValue<T> extends TypedSchema ? TypeOf<LazyReturnValue<T>> : never;
declare class Lazy<T extends AnySchema, TContext = ContextOf<T>> implements TypedSchema {
private builder;
type: "lazy";
__isYupSchema__: boolean;
readonly __inputType: T['__inputType'];
readonly __outputType: T['__outputType'];
constructor(builder: LazyBuilder<T>);
private _resolve;
resolve(options: ResolveOptions<TContext>): T;
cast(value: any, options?: CastOptions<TContext>): T['__inputType'];
validate(value: any, options?: ValidateOptions, maybeCb?: Callback): T['__outputType'];
validateSync(value: any, options?: ValidateOptions<TContext>): T['__outputType'];
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): any;
describe(): any;
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): boolean;
}
export default Lazy;

59
server/node_modules/yup/es/Lazy.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
import isSchema from './util/isSchema';
export function create(builder) {
return new Lazy(builder);
}
class Lazy {
constructor(builder) {
this.type = 'lazy';
this.__isYupSchema__ = true;
this._resolve = (value, options = {}) => {
let schema = this.builder(value, options);
if (!isSchema(schema)) throw new TypeError('lazy() functions must return a valid schema');
return schema.resolve(options);
};
this.builder = builder;
}
resolve(options) {
return this._resolve(options.value, options);
}
cast(value, options) {
return this._resolve(value, options).cast(value, options);
}
validate(value, options, maybeCb) {
// @ts-expect-error missing public callback on type
return this._resolve(value, options).validate(value, options, maybeCb);
}
validateSync(value, options) {
return this._resolve(value, options).validateSync(value, options);
}
validateAt(path, value, options) {
return this._resolve(value, options).validateAt(path, value, options);
}
validateSyncAt(path, value, options) {
return this._resolve(value, options).validateSyncAt(path, value, options);
}
describe() {
return null;
}
isValid(value, options) {
return this._resolve(value, options).isValid(value, options);
}
isValidSync(value, options) {
return this._resolve(value, options).isValidSync(value, options);
}
}
export default Lazy;

32
server/node_modules/yup/es/Reference.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import type { SchemaRefDescription } from './schema';
export declare type ReferenceOptions<TValue = unknown> = {
map?: (value: unknown) => TValue;
};
export declare function create<TValue = unknown>(key: string, options?: ReferenceOptions<TValue>): Reference<TValue>;
export default class Reference<TValue = unknown> {
readonly key: string;
readonly isContext: boolean;
readonly isValue: boolean;
readonly isSibling: boolean;
readonly path: any;
readonly getter: (data: unknown) => unknown;
readonly map?: (value: unknown) => TValue;
readonly __isYupRef: boolean;
constructor(key: string, options?: ReferenceOptions<TValue>);
getValue(value: any, parent?: {}, context?: {}): TValue;
/**
*
* @param {*} value
* @param {Object} options
* @param {Object=} options.context
* @param {Object=} options.parent
*/
cast(value: any, options?: {
parent?: {};
context?: {};
}): TValue;
resolve(): this;
describe(): SchemaRefDescription;
toString(): string;
static isRef(value: any): value is Reference;
}

63
server/node_modules/yup/es/Reference.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import { getter } from 'property-expr';
const prefixes = {
context: '$',
value: '.'
};
export function create(key, options) {
return new Reference(key, options);
}
export default class Reference {
constructor(key, options = {}) {
if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
this.key = key.trim();
if (key === '') throw new TypeError('ref must be a non-empty string');
this.isContext = this.key[0] === prefixes.context;
this.isValue = this.key[0] === prefixes.value;
this.isSibling = !this.isContext && !this.isValue;
let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
this.path = this.key.slice(prefix.length);
this.getter = this.path && getter(this.path, true);
this.map = options.map;
}
getValue(value, parent, context) {
let result = this.isContext ? context : this.isValue ? value : parent;
if (this.getter) result = this.getter(result || {});
if (this.map) result = this.map(result);
return result;
}
/**
*
* @param {*} value
* @param {Object} options
* @param {Object=} options.context
* @param {Object=} options.parent
*/
cast(value, options) {
return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
}
resolve() {
return this;
}
describe() {
return {
type: 'ref',
key: this.key
};
}
toString() {
return `Ref(${this.key})`;
}
static isRef(value) {
return value && value.__isYupRef;
}
} // @ts-ignore
Reference.prototype.__isYupRef = true;

13
server/node_modules/yup/es/ValidationError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
declare type Params = Record<string, unknown>;
export default class ValidationError extends Error {
value: any;
path?: string;
type?: string;
errors: string[];
params?: Params;
inner: ValidationError[];
static formatError(message: string | ((params: Params) => string) | unknown, params: Params): any;
static isError(err: any): err is ValidationError;
constructor(errorOrErrors: string | ValidationError | ValidationError[], value?: any, field?: string, type?: string);
}
export {};

41
server/node_modules/yup/es/ValidationError.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import printValue from './util/printValue';
import toArray from './util/toArray';
let strReg = /\$\{\s*(\w+)\s*\}/g;
export default class ValidationError extends Error {
static formatError(message, params) {
const path = params.label || params.path || 'this';
if (path !== params.path) params = _extends({}, params, {
path
});
if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
if (typeof message === 'function') return message(params);
return message;
}
static isError(err) {
return err && err.name === 'ValidationError';
}
constructor(errorOrErrors, value, field, type) {
super();
this.name = 'ValidationError';
this.value = value;
this.path = field;
this.type = type;
this.errors = [];
this.inner = [];
toArray(errorOrErrors).forEach(err => {
if (ValidationError.isError(err)) {
this.errors.push(...err.errors);
this.inner = this.inner.concat(err.inner.length ? err.inner : err);
} else {
this.errors.push(err);
}
});
this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
if (Error.captureStackTrace) Error.captureStackTrace(this, ValidationError);
}
}

66
server/node_modules/yup/es/array.d.ts generated vendored Normal file
View File

@@ -0,0 +1,66 @@
import { MixedLocale } from './locale';
import type { AnyObject, InternalOptions, Callback, Message, Maybe, Preserve, Optionals } from './types';
import type Reference from './Reference';
import { Asserts, Defined, If, Thunk, TypeOf } from './util/types';
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema';
import Lazy from './Lazy';
export declare type RejectorFn = (value: any, index: number, array: any[]) => boolean;
export declare function create<C extends AnyObject = AnyObject, T extends AnySchema | Lazy<any, any> = AnySchema>(type?: T): OptionalArraySchema<T, C, TypeOf<T>[] | undefined>;
export declare namespace create {
var prototype: ArraySchema<any, any, any, any>;
}
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> {
innerType?: T;
constructor(type?: T);
protected _typeCheck(v: any): v is NonNullable<TIn>;
private get _subType();
protected _cast(_value: any, _opts: InternalOptions<C>): any;
protected _validate(_value: any, options: InternalOptions<C> | undefined, callback: Callback): void;
clone(spec?: SchemaSpec<any>): this;
concat<TOther extends ArraySchema<any, any, any, any>>(schema: TOther): TOther;
concat(schema: any): any;
of<TInner extends AnySchema>(schema: TInner): ArraySchema<TInner>;
length(length: number | Reference<number>, message?: Message<{
length: number;
}>): this;
min(min: number | Reference<number>, message?: Message<{
min: number;
}>): this;
max(max: number | Reference<number>, message?: Message<{
max: number;
}>): this;
ensure(): RequiredArraySchema<T, C, TIn>;
compact(rejector?: RejectorFn): this;
describe(): SchemaInnerTypeDescription;
nullable(isNullable?: true): ArraySchema<T, C, TIn | null>;
nullable(isNullable: false): ArraySchema<T, C, Exclude<TIn, null>>;
defined(): DefinedArraySchema<T, C, TIn>;
required(msg?: MixedLocale['required']): RequiredArraySchema<T, C, TIn>;
}
export interface DefinedArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[] | Preserve<TIn, null>> {
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, DefinedArraySchema<T, TContext, TIn | undefined>, DefinedArraySchema<T, TContext, Defined<TIn>>>;
defined(msg?: MixedLocale['defined']): this;
required(msg?: MixedLocale['required']): RequiredArraySchema<T, TContext, TIn>;
optional(): ArraySchema<T, TContext, TIn>;
notRequired(): ArraySchema<T, TContext, TIn>;
nullable(isNullable?: true): DefinedArraySchema<T, TContext, TIn | null>;
nullable(isNullable: false): RequiredArraySchema<T, TContext, Exclude<TIn, null>>;
}
export interface RequiredArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[]> {
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, RequiredArraySchema<T, TContext, TIn | undefined>, RequiredArraySchema<T, TContext, Defined<TIn>>>;
defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>;
required(msg?: MixedLocale['required']): this;
optional(): ArraySchema<T, TContext, TIn>;
notRequired(): ArraySchema<T, TContext, TIn>;
nullable(isNullable?: true): RequiredArraySchema<T, TContext, TIn | null>;
nullable(isNullable: false): RequiredArraySchema<T, TContext, Exclude<TIn, null>>;
}
export interface OptionalArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends ArraySchema<T, TContext, TIn> {
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, ArraySchema<T, TContext, TIn | undefined>, ArraySchema<T, TContext, Defined<TIn>>>;
defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>;
required(msg?: MixedLocale['required']): RequiredArraySchema<T, TContext, TIn>;
optional(): ArraySchema<T, TContext, TIn>;
notRequired(): ArraySchema<T, TContext, TIn>;
nullable(isNullable?: true): OptionalArraySchema<T, TContext, TIn | null>;
nullable(isNullable: false): OptionalArraySchema<T, TContext, Exclude<TIn, null>>;
}

224
server/node_modules/yup/es/array.js generated vendored Normal file
View File

@@ -0,0 +1,224 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import isAbsent from './util/isAbsent';
import isSchema from './util/isSchema';
import printValue from './util/printValue';
import { array as locale } from './locale';
import runTests from './util/runTests';
import ValidationError from './ValidationError';
import BaseSchema from './schema';
export function create(type) {
return new ArraySchema(type);
}
export default class ArraySchema extends BaseSchema {
constructor(type) {
super({
type: 'array'
}); // `undefined` specifically means uninitialized, as opposed to
// "no subtype"
this.innerType = type;
this.withMutation(() => {
this.transform(function (values) {
if (typeof values === 'string') try {
values = JSON.parse(values);
} catch (err) {
values = null;
}
return this.isType(values) ? values : null;
});
});
}
_typeCheck(v) {
return Array.isArray(v);
}
get _subType() {
return this.innerType;
}
_cast(_value, _opts) {
const value = super._cast(_value, _opts); //should ignore nulls here
if (!this._typeCheck(value) || !this.innerType) return value;
let isChanged = false;
const castArray = value.map((v, idx) => {
const castElement = this.innerType.cast(v, _extends({}, _opts, {
path: `${_opts.path || ''}[${idx}]`
}));
if (castElement !== v) {
isChanged = true;
}
return castElement;
});
return isChanged ? castArray : value;
}
_validate(_value, options = {}, callback) {
var _options$abortEarly, _options$recursive;
let errors = [];
let sync = options.sync;
let path = options.path;
let innerType = this.innerType;
let endEarly = (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly;
let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
let originalValue = options.originalValue != null ? options.originalValue : _value;
super._validate(_value, options, (err, value) => {
if (err) {
if (!ValidationError.isError(err) || endEarly) {
return void callback(err, value);
}
errors.push(err);
}
if (!recursive || !innerType || !this._typeCheck(value)) {
callback(errors[0] || null, value);
return;
}
originalValue = originalValue || value; // #950 Ensure that sparse array empty slots are validated
let tests = new Array(value.length);
for (let idx = 0; idx < value.length; idx++) {
let item = value[idx];
let path = `${options.path || ''}[${idx}]`; // object._validate note for isStrict explanation
let innerOptions = _extends({}, options, {
path,
strict: true,
parent: value,
index: idx,
originalValue: originalValue[idx]
});
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, cb);
}
runTests({
sync,
path,
value,
errors,
endEarly,
tests
}, callback);
});
}
clone(spec) {
const next = super.clone(spec);
next.innerType = this.innerType;
return next;
}
concat(schema) {
let next = super.concat(schema);
next.innerType = this.innerType;
if (schema.innerType) next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat()
next.innerType.concat(schema.innerType) : schema.innerType;
return next;
}
of(schema) {
// FIXME: this should return a new instance of array without the default to be
let next = this.clone();
if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema)); // FIXME(ts):
next.innerType = schema;
return next;
}
length(length, message = locale.length) {
return this.test({
message,
name: 'length',
exclusive: true,
params: {
length
},
test(value) {
return isAbsent(value) || value.length === this.resolve(length);
}
});
}
min(min, message) {
message = message || locale.min;
return this.test({
message,
name: 'min',
exclusive: true,
params: {
min
},
// FIXME(ts): Array<typeof T>
test(value) {
return isAbsent(value) || value.length >= this.resolve(min);
}
});
}
max(max, message) {
message = message || locale.max;
return this.test({
message,
name: 'max',
exclusive: true,
params: {
max
},
test(value) {
return isAbsent(value) || value.length <= this.resolve(max);
}
});
}
ensure() {
return this.default(() => []).transform((val, original) => {
// We don't want to return `null` for nullable schema
if (this._typeCheck(val)) return val;
return original == null ? [] : [].concat(original);
});
}
compact(rejector) {
let reject = !rejector ? v => !!v : (v, i, a) => !rejector(v, i, a);
return this.transform(values => values != null ? values.filter(reject) : values);
}
describe() {
let base = super.describe();
if (this.innerType) base.innerType = this.innerType.describe();
return base;
}
nullable(isNullable = true) {
return super.nullable(isNullable);
}
defined() {
return super.defined();
}
required(msg) {
return super.required(msg);
}
}
create.prototype = ArraySchema.prototype; //
// Interfaces
//

42
server/node_modules/yup/es/boolean.d.ts generated vendored Normal file
View File

@@ -0,0 +1,42 @@
import BaseSchema from './schema';
import type { MixedLocale } from './locale';
import type { AnyObject, Maybe, Optionals } from './types';
import type { Defined } from './util/types';
export declare function create(): BooleanSchema<boolean | undefined, Record<string, any>, boolean | undefined>;
export declare namespace create {
var prototype: BooleanSchema<any, any, any>;
}
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
constructor();
protected _typeCheck(v: any): v is NonNullable<TType>;
isTrue(message?: string | Record<string | number | symbol, unknown> | ((params: import("./types").MessageParams) => unknown) | undefined): BooleanSchema<TType | true, TContext, true | Optionals<TOut>>;
isFalse(message?: string | Record<string | number | symbol, unknown> | ((params: import("./types").MessageParams) => unknown) | undefined): BooleanSchema<TType | false, TContext, false | Optionals<TOut>>;
}
export default interface BooleanSchema<TType extends Maybe<boolean>, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
concat<TOther extends BooleanSchema<any, any, any>>(schema: TOther): TOther;
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? BooleanSchema<TType | undefined, TContext> : BooleanSchema<Defined<TType>, TContext>;
defined(msg?: MixedLocale['defined']): DefinedBooleanSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredBooleanSchema<TType, TContext>;
optional(): BooleanSchema<TType, TContext>;
notRequired(): BooleanSchema<TType, TContext>;
nullable(isNullable?: true): BooleanSchema<TType | null>;
nullable(isNullable: false): BooleanSchema<Exclude<TType, null>>;
}
export interface DefinedBooleanSchema<TType extends Maybe<boolean>, TContext extends AnyObject = AnyObject> extends BooleanSchema<TType, TContext, Defined<TType>> {
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? BooleanSchema<TType | undefined, TContext> : BooleanSchema<Defined<TType>, TContext>;
defined(msg?: MixedLocale['defined']): DefinedBooleanSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredBooleanSchema<TType, TContext>;
optional(): BooleanSchema<TType, TContext>;
notRequired(): BooleanSchema<TType, TContext>;
nullable(isNullable?: true): DefinedBooleanSchema<TType | null>;
nullable(isNullable: false): DefinedBooleanSchema<Exclude<TType, null>>;
}
export interface RequiredBooleanSchema<TType extends Maybe<boolean>, TContext extends AnyObject = AnyObject> extends BooleanSchema<TType, TContext, NonNullable<TType>> {
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? BooleanSchema<TType | undefined, TContext> : BooleanSchema<Defined<TType>, TContext>;
defined(msg?: MixedLocale['defined']): DefinedBooleanSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredBooleanSchema<TType, TContext>;
optional(): BooleanSchema<TType, TContext>;
notRequired(): BooleanSchema<TType, TContext>;
nullable(isNullable?: true): RequiredBooleanSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredBooleanSchema<Exclude<TType, null>, TContext>;
}

62
server/node_modules/yup/es/boolean.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import BaseSchema from './schema';
import { boolean as locale } from './locale';
import isAbsent from './util/isAbsent';
export function create() {
return new BooleanSchema();
}
export default class BooleanSchema extends BaseSchema {
constructor() {
super({
type: 'boolean'
});
this.withMutation(() => {
this.transform(function (value) {
if (!this.isType(value)) {
if (/^(true|1)$/i.test(String(value))) return true;
if (/^(false|0)$/i.test(String(value))) return false;
}
return value;
});
});
}
_typeCheck(v) {
if (v instanceof Boolean) v = v.valueOf();
return typeof v === 'boolean';
}
isTrue(message = locale.isValue) {
return this.test({
message,
name: 'is-value',
exclusive: true,
params: {
value: 'true'
},
test(value) {
return isAbsent(value) || value === true;
}
});
}
isFalse(message = locale.isValue) {
return this.test({
message,
name: 'is-value',
exclusive: true,
params: {
value: 'false'
},
test(value) {
return isAbsent(value) || value === false;
}
});
}
}
create.prototype = BooleanSchema.prototype;

50
server/node_modules/yup/es/date.d.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import { MixedLocale } from './locale';
import Ref from './Reference';
import type { AnyObject, Maybe } from './types';
import type { Defined, If, Thunk } from './util/types';
import BaseSchema from './schema';
export declare function create(): DateSchema<Date | undefined, Record<string, any>, Date | undefined>;
export declare namespace create {
var prototype: DateSchema<any, any, any>;
var INVALID_DATE: Date;
}
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
static INVALID_DATE: Date;
constructor();
protected _typeCheck(v: any): v is NonNullable<TType>;
private prepareParam;
min(min: unknown | Ref<Date>, message?: import("./types").Message<{
min: string | Date;
}>): this;
max(max: unknown | Ref, message?: import("./types").Message<{
max: string | Date;
}>): this;
}
export default interface DateSchema<TType extends Maybe<Date>, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
concat<TOther extends DateSchema<any, any, any>>(schema: TOther): TOther;
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, DateSchema<TType | undefined, TContext>, DateSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedDateSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredDateSchema<TType, TContext>;
optional(): DateSchema<TType, TContext>;
notRequired(): DateSchema<TType, TContext>;
nullable(isNullable?: true): DateSchema<TType | null, TContext>;
nullable(isNullable: false): DateSchema<Exclude<TType, null>, TContext>;
}
export interface DefinedDateSchema<TType extends Maybe<Date>, TContext extends AnyObject = AnyObject> extends DateSchema<TType, TContext, Defined<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, DefinedDateSchema<TType | undefined, TContext>, DefinedDateSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): this;
required(msg?: MixedLocale['required']): RequiredDateSchema<TType, TContext>;
optional(): DateSchema<TType, TContext>;
notRequired(): DateSchema<TType, TContext>;
nullable(isNullable?: true): RequiredDateSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredDateSchema<Exclude<TType, null>, TContext>;
}
export interface RequiredDateSchema<TType extends Maybe<Date>, TContext extends AnyObject = AnyObject> extends DateSchema<TType, TContext, NonNullable<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, RequiredDateSchema<TType | undefined, TContext>, RequiredDateSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedDateSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredDateSchema<TType, TContext>;
optional(): DateSchema<TType, TContext>;
notRequired(): DateSchema<TType, TContext>;
nullable(isNullable?: true): RequiredDateSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredDateSchema<Exclude<TType, null>, TContext>;
}

84
server/node_modules/yup/es/date.js generated vendored Normal file
View File

@@ -0,0 +1,84 @@
// @ts-ignore
import isoParse from './util/isodate';
import { date as locale } from './locale';
import isAbsent from './util/isAbsent';
import Ref from './Reference';
import BaseSchema from './schema';
let invalidDate = new Date('');
let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
export function create() {
return new DateSchema();
}
export default class DateSchema extends BaseSchema {
constructor() {
super({
type: 'date'
});
this.withMutation(() => {
this.transform(function (value) {
if (this.isType(value)) return value;
value = isoParse(value); // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
return !isNaN(value) ? new Date(value) : invalidDate;
});
});
}
_typeCheck(v) {
return isDate(v) && !isNaN(v.getTime());
}
prepareParam(ref, name) {
let param;
if (!Ref.isRef(ref)) {
let cast = this.cast(ref);
if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
param = cast;
} else {
param = ref;
}
return param;
}
min(min, message = locale.min) {
let limit = this.prepareParam(min, 'min');
return this.test({
message,
name: 'min',
exclusive: true,
params: {
min
},
test(value) {
return isAbsent(value) || value >= this.resolve(limit);
}
});
}
max(max, message = locale.max) {
var limit = this.prepareParam(max, 'max');
return this.test({
message,
name: 'max',
exclusive: true,
params: {
max
},
test(value) {
return isAbsent(value) || value <= this.resolve(limit);
}
});
}
}
DateSchema.INVALID_DATE = invalidDate;
create.prototype = DateSchema.prototype;
create.INVALID_DATE = invalidDate;

10
server/node_modules/yup/es/globals.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
declare module 'lodash/has' {
function has<T extends {}, Key extends PropertyKey>(
obj: T,
prop: Key,
): obj is T & Record<Key, unknown> {
return has(obj, prop);
}
export default has;
}

28
server/node_modules/yup/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import MixedSchema, { create as mixedCreate } from './mixed';
import BooleanSchema, { create as boolCreate } from './boolean';
import StringSchema, { create as stringCreate } from './string';
import NumberSchema, { create as numberCreate } from './number';
import DateSchema, { create as dateCreate } from './date';
import ObjectSchema, { AnyObject, create as objectCreate } from './object';
import ArraySchema, { create as arrayCreate } from './array';
import { create as refCreate } from './Reference';
import Lazy, { create as lazyCreate } from './Lazy';
import ValidationError from './ValidationError';
import reach from './util/reach';
import isSchema from './util/isSchema';
import setLocale from './setLocale';
import BaseSchema, { AnySchema } from './schema';
import type { TypeOf, Asserts } from './util/types';
import { Maybe } from './types';
declare function addMethod<T extends AnySchema>(schemaType: (...arg: any[]) => T, name: string, fn: (this: T, ...args: any[]) => T): void;
declare function addMethod<T extends new (...args: any) => AnySchema>(schemaType: T, name: string, fn: (this: InstanceType<T>, ...args: any[]) => InstanceType<T>): void;
declare type ObjectSchemaOf<T extends AnyObject> = ObjectSchema<{
[k in keyof T]-?: T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T[k] extends AnyObject ? // we can't use ObjectSchema<{ []: SchemaOf<T[k]> }> b/c TS produces a union of two schema
ObjectSchemaOf<T[k]> | ObjectSchemaOf<Lazy<T[k]>> : BaseSchema<Maybe<T[k]>, AnyObject, T[k]>;
}>;
declare type SchemaOf<T> = T extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T extends AnyObject ? ObjectSchemaOf<T> : BaseSchema<Maybe<T>, AnyObject, T>;
export declare type AnyObjectSchema = ObjectSchema<any, any, any, any>;
export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };
export { mixedCreate as mixed, boolCreate as bool, boolCreate as boolean, stringCreate as string, numberCreate as number, dateCreate as date, objectCreate as object, arrayCreate as array, refCreate as ref, lazyCreate as lazy, reach, isSchema, addMethod, setLocale, ValidationError, };
export { BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema, };
export type { CreateErrorOptions, TestContext, TestFunction, TestOptions, TestConfig, } from './util/createValidation';

24
server/node_modules/yup/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import MixedSchema, { create as mixedCreate } from './mixed';
import BooleanSchema, { create as boolCreate } from './boolean';
import StringSchema, { create as stringCreate } from './string';
import NumberSchema, { create as numberCreate } from './number';
import DateSchema, { create as dateCreate } from './date';
import ObjectSchema, { create as objectCreate } from './object';
import ArraySchema, { create as arrayCreate } from './array';
import { create as refCreate } from './Reference';
import { create as lazyCreate } from './Lazy';
import ValidationError from './ValidationError';
import reach from './util/reach';
import isSchema from './util/isSchema';
import setLocale from './setLocale';
import BaseSchema from './schema';
function addMethod(schemaType, name, fn) {
if (!schemaType || !isSchema(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function');
if (typeof name !== 'string') throw new TypeError('A Method name must be provided');
if (typeof fn !== 'function') throw new TypeError('Method function must be provided');
schemaType.prototype[name] = fn;
}
export { mixedCreate as mixed, boolCreate as bool, boolCreate as boolean, stringCreate as string, numberCreate as number, dateCreate as date, objectCreate as object, arrayCreate as array, refCreate as ref, lazyCreate as lazy, reach, isSchema, addMethod, setLocale, ValidationError };
export { BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema };

94
server/node_modules/yup/es/locale.d.ts generated vendored Normal file
View File

@@ -0,0 +1,94 @@
import { Message } from './types';
export interface MixedLocale {
default?: Message;
required?: Message;
oneOf?: Message<{
values: any;
}>;
notOneOf?: Message<{
values: any;
}>;
notType?: Message;
defined?: Message;
}
export interface StringLocale {
length?: Message<{
length: number;
}>;
min?: Message<{
min: number;
}>;
max?: Message<{
max: number;
}>;
matches?: Message<{
regex: RegExp;
}>;
email?: Message<{
regex: RegExp;
}>;
url?: Message<{
regex: RegExp;
}>;
uuid?: Message<{
regex: RegExp;
}>;
trim?: Message;
lowercase?: Message;
uppercase?: Message;
}
export interface NumberLocale {
min?: Message<{
min: number;
}>;
max?: Message<{
max: number;
}>;
lessThan?: Message<{
less: number;
}>;
moreThan?: Message<{
more: number;
}>;
positive?: Message<{
more: number;
}>;
negative?: Message<{
less: number;
}>;
integer?: Message;
}
export interface DateLocale {
min?: Message<{
min: Date | string;
}>;
max?: Message<{
max: Date | string;
}>;
}
export interface ObjectLocale {
noUnknown?: Message;
}
export interface ArrayLocale {
length?: Message<{
length: number;
}>;
min?: Message<{
min: number;
}>;
max?: Message<{
max: number;
}>;
}
export interface BooleanLocale {
isValue?: Message;
}
export declare let mixed: Required<MixedLocale>;
export declare let string: Required<StringLocale>;
export declare let number: Required<NumberLocale>;
export declare let date: Required<DateLocale>;
export declare let boolean: BooleanLocale;
export declare let object: Required<ObjectLocale>;
export declare let array: Required<ArrayLocale>;
declare const _default: any;
export default _default;

68
server/node_modules/yup/es/locale.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
import printValue from './util/printValue';
export let mixed = {
default: '${path} is invalid',
required: '${path} is a required field',
oneOf: '${path} must be one of the following values: ${values}',
notOneOf: '${path} must not be one of the following values: ${values}',
notType: ({
path,
type,
value,
originalValue
}) => {
let isCast = originalValue != null && originalValue !== value;
let msg = `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + (isCast ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.');
if (value === null) {
msg += `\n If "null" is intended as an empty value be sure to mark the schema as \`.nullable()\``;
}
return msg;
},
defined: '${path} must be defined'
};
export let string = {
length: '${path} must be exactly ${length} characters',
min: '${path} must be at least ${min} characters',
max: '${path} must be at most ${max} characters',
matches: '${path} must match the following: "${regex}"',
email: '${path} must be a valid email',
url: '${path} must be a valid URL',
uuid: '${path} must be a valid UUID',
trim: '${path} must be a trimmed string',
lowercase: '${path} must be a lowercase string',
uppercase: '${path} must be a upper case string'
};
export let number = {
min: '${path} must be greater than or equal to ${min}',
max: '${path} must be less than or equal to ${max}',
lessThan: '${path} must be less than ${less}',
moreThan: '${path} must be greater than ${more}',
positive: '${path} must be a positive number',
negative: '${path} must be a negative number',
integer: '${path} must be an integer'
};
export let date = {
min: '${path} field must be later than ${min}',
max: '${path} field must be at earlier than ${max}'
};
export let boolean = {
isValue: '${path} field must be ${value}'
};
export let object = {
noUnknown: '${path} field has unspecified keys: ${unknown}'
};
export let array = {
min: '${path} field must have at least ${min} items',
max: '${path} field must have less than or equal to ${max} items',
length: '${path} must be have ${length} items'
};
export default Object.assign(Object.create(null), {
mixed,
string,
number,
date,
object,
array,
boolean
});

20
server/node_modules/yup/es/mixed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import type { MixedLocale } from './locale';
import { AnyObject, Maybe, Optionals } from './types';
import type { Defined } from './util/types';
import BaseSchema from './schema';
export declare class MixedSchema<TType = any, TContext = AnyObject, TOut = TType> extends BaseSchema<TType, TContext, TOut> {
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? MixedSchema<TType | undefined, TContext> : MixedSchema<Defined<TType>, TContext>;
concat(schema: this): this;
concat<IT, IC, IO>(schema: BaseSchema<IT, IC, IO>): MixedSchema<TType | IT, TContext & IC, NonNullable<TOut> | IO | Optionals<IO>>;
defined(msg?: MixedLocale['defined']): MixedSchema<TType, TContext, Defined<TOut>>;
required(msg?: MixedLocale['required']): MixedSchema<TType, TContext, NonNullable<TOut>>;
notRequired(): MixedSchema<TType, TContext>;
nullable(isNullable?: true): MixedSchema<TType | null, TContext>;
nullable(isNullable: false): MixedSchema<Exclude<TType, null>, TContext>;
}
declare const Mixed: typeof MixedSchema;
export default Mixed;
export declare function create<TType = any>(): MixedSchema<TType | undefined, Record<string, any>, TType | undefined>;
export declare namespace create {
var prototype: MixedSchema<any, any, any>;
}

8
server/node_modules/yup/es/mixed.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import BaseSchema from './schema';
const Mixed = BaseSchema;
export default Mixed;
export function create() {
return new Mixed();
} // XXX: this is using the Base schema so that `addMethod(mixed)` works as a base class
create.prototype = Mixed.prototype;

62
server/node_modules/yup/es/number.d.ts generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import { MixedLocale } from './locale';
import type { AnyObject, Maybe, Message } from './types';
import type Reference from './Reference';
import type { Defined, If, Thunk } from './util/types';
import BaseSchema from './schema';
export declare function create(): NumberSchema<number | undefined, Record<string, any>, number | undefined>;
export declare namespace create {
var prototype: NumberSchema<any, any, any>;
}
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
constructor();
protected _typeCheck(value: any): value is NonNullable<TType>;
min(min: number | Reference<number>, message?: Message<{
min: number;
}>): this;
max(max: number | Reference<number>, message?: Message<{
max: number;
}>): this;
lessThan(less: number | Reference<number>, message?: Message<{
less: number;
}>): this;
moreThan(more: number | Reference<number>, message?: Message<{
more: number;
}>): this;
positive(msg?: Message<{
more: number;
}>): this;
negative(msg?: Message<{
less: number;
}>): this;
integer(message?: Message<{}>): this;
truncate(): this;
round(method: 'ceil' | 'floor' | 'round' | 'trunc'): this;
}
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
concat<TOther extends NumberSchema<any, any, any>>(schema: TOther): TOther;
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, NumberSchema<TType | undefined, TContext>, NumberSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedNumberSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredNumberSchema<TType, TContext>;
optional(): NumberSchema<TType, TContext>;
notRequired(): NumberSchema<TType, TContext>;
nullable(isNullable?: true): NumberSchema<TType | null, TContext>;
nullable(isNullable: false): NumberSchema<Exclude<TType, null>, TContext>;
}
export interface DefinedNumberSchema<TType extends Maybe<number>, TContext extends AnyObject = AnyObject> extends NumberSchema<TType, TContext, Defined<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, DefinedNumberSchema<TType | undefined, TContext>, DefinedNumberSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): this;
required(msg?: MixedLocale['required']): RequiredNumberSchema<TType, TContext>;
optional(): NumberSchema<TType, TContext>;
notRequired(): NumberSchema<TType, TContext>;
nullable(isNullable?: true): RequiredNumberSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredNumberSchema<Exclude<TType, null>, TContext>;
}
export interface RequiredNumberSchema<TType extends Maybe<number>, TContext extends AnyObject = AnyObject> extends NumberSchema<TType, TContext, NonNullable<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, RequiredNumberSchema<TType | undefined, TContext>, RequiredNumberSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedNumberSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredNumberSchema<TType, TContext>;
optional(): NumberSchema<TType, TContext>;
notRequired(): NumberSchema<TType, TContext>;
nullable(isNullable?: true): RequiredNumberSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredNumberSchema<Exclude<TType, null>, TContext>;
}

135
server/node_modules/yup/es/number.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
import { number as locale } from './locale';
import isAbsent from './util/isAbsent';
import BaseSchema from './schema';
let isNaN = value => value != +value;
export function create() {
return new NumberSchema();
}
export default class NumberSchema extends BaseSchema {
constructor() {
super({
type: 'number'
});
this.withMutation(() => {
this.transform(function (value) {
let parsed = value;
if (typeof parsed === 'string') {
parsed = parsed.replace(/\s/g, '');
if (parsed === '') return NaN; // don't use parseFloat to avoid positives on alpha-numeric strings
parsed = +parsed;
}
if (this.isType(parsed)) return parsed;
return parseFloat(parsed);
});
});
}
_typeCheck(value) {
if (value instanceof Number) value = value.valueOf();
return typeof value === 'number' && !isNaN(value);
}
min(min, message = locale.min) {
return this.test({
message,
name: 'min',
exclusive: true,
params: {
min
},
test(value) {
return isAbsent(value) || value >= this.resolve(min);
}
});
}
max(max, message = locale.max) {
return this.test({
message,
name: 'max',
exclusive: true,
params: {
max
},
test(value) {
return isAbsent(value) || value <= this.resolve(max);
}
});
}
lessThan(less, message = locale.lessThan) {
return this.test({
message,
name: 'max',
exclusive: true,
params: {
less
},
test(value) {
return isAbsent(value) || value < this.resolve(less);
}
});
}
moreThan(more, message = locale.moreThan) {
return this.test({
message,
name: 'min',
exclusive: true,
params: {
more
},
test(value) {
return isAbsent(value) || value > this.resolve(more);
}
});
}
positive(msg = locale.positive) {
return this.moreThan(0, msg);
}
negative(msg = locale.negative) {
return this.lessThan(0, msg);
}
integer(message = locale.integer) {
return this.test({
name: 'integer',
message,
test: val => isAbsent(val) || Number.isInteger(val)
});
}
truncate() {
return this.transform(value => !isAbsent(value) ? value | 0 : value);
}
round(method) {
var _method;
var avail = ['ceil', 'floor', 'round', 'trunc'];
method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round'; // this exists for symemtry with the new Math.trunc
if (method === 'trunc') return this.truncate();
if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', '));
return this.transform(value => !isAbsent(value) ? Math[method](value) : value);
}
}
create.prototype = NumberSchema.prototype; //
// Number Interfaces
//

89
server/node_modules/yup/es/object.d.ts generated vendored Normal file
View File

@@ -0,0 +1,89 @@
import { MixedLocale } from './locale';
import { InternalOptions, Callback, Maybe, Optionals, Preserve } from './types';
import type { TypedSchema, Defined } from './util/types';
import type Reference from './Reference';
import Lazy from './Lazy';
import BaseSchema, { AnySchema, SchemaObjectDescription, SchemaSpec } from './schema';
export declare type Assign<T extends {}, U extends {}> = {
[P in keyof T]: P extends keyof U ? U[P] : T[P];
} & U;
export declare type AnyObject = Record<string, any>;
export declare type ObjectShape = Record<string, AnySchema | Reference | Lazy<any, any>>;
export declare type DefaultFromShape<Shape extends ObjectShape> = {
[K in keyof Shape]: Shape[K] extends ObjectSchema<infer TShape> ? DefaultFromShape<TShape> : Shape[K] extends {
getDefault: () => infer D;
} ? Preserve<D, undefined> extends never ? Defined<D> : Preserve<D, undefined> : undefined;
};
export declare type TypeOfShape<Shape extends ObjectShape> = {
[K in keyof Shape]: Shape[K] extends TypedSchema ? Shape[K]['__inputType'] : Shape[K] extends Reference ? unknown : never;
};
export declare type AssertsShape<Shape extends ObjectShape> = {
[K in keyof Shape]: Shape[K] extends TypedSchema ? Shape[K]['__outputType'] : Shape[K] extends Reference ? unknown : never;
};
export declare type ObjectSchemaSpec = SchemaSpec<any> & {
noUnknown?: boolean;
};
export default class ObjectSchema<TShape extends ObjectShape, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape>, TOut extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | Optionals<TIn>> extends BaseSchema<TIn, TContext, TOut> {
fields: TShape;
spec: ObjectSchemaSpec;
private _sortErrors;
private _nodes;
private _excludedEdges;
constructor(spec?: TShape);
protected _typeCheck(value: any): value is NonNullable<TIn>;
protected _cast(_value: any, options?: InternalOptions<TContext>): any;
protected _validate(_value: any, opts: InternalOptions<TContext> | undefined, callback: Callback): void;
clone(spec?: ObjectSchemaSpec): this;
concat<TOther extends ObjectSchema<any, any, any>>(schema: TOther): TOther extends ObjectSchema<infer S, infer C, infer IType> ? ObjectSchema<TShape & S, TContext & C, TypeOfShape<TShape & S> | Optionals<IType>> : never;
concat(schema: this): this;
getDefaultFromShape(): DefaultFromShape<TShape>;
protected _getDefault(): any;
shape<TNextShape extends ObjectShape>(additions: TNextShape, excludes?: [string, string][]): ObjectSchema<Assign<TShape, TNextShape>, TContext, TypeOfShape<Assign<TShape, TNextShape>> | Optionals<TIn>>;
pick(keys: string[]): any;
omit(keys: string[]): any;
from(from: string, to: keyof TShape, alias?: boolean): this;
noUnknown(noAllow?: boolean, message?: import("./types").Message<{}>): this;
unknown(allow?: boolean, message?: import("./types").Message<{}>): this;
transformKeys(fn: (key: string) => string): this;
camelCase(): this;
snakeCase(): this;
constantCase(): this;
describe(): SchemaObjectDescription;
}
export declare function create<TShape extends ObjectShape>(spec?: TShape): OptionalObjectSchema<TShape, Record<string, any>, TypeOfShape<TShape>>;
export declare namespace create {
var prototype: ObjectSchema<any, any, any, any>;
}
export interface OptionalObjectSchema<TShape extends ObjectShape, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape>> extends ObjectSchema<TShape, TContext, TIn> {
default<TNextDefault extends Maybe<AnyObject>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? ObjectSchema<TShape, TContext, TIn | undefined> : ObjectSchema<TShape, TContext, Defined<TIn>>;
defined(msg?: MixedLocale['defined']): DefinedObjectSchema<TShape, TContext, TIn>;
required(msg?: MixedLocale['required']): RequiredObjectSchema<TShape, TContext, TIn>;
optional(): this;
notRequired(): this;
nullable(isNullable?: true): OptionalObjectSchema<TShape, TContext, TIn | null>;
nullable(isNullable: false): OptionalObjectSchema<TShape, TContext, Exclude<TIn, null>>;
pick<TKey extends keyof TShape>(keys: TKey[]): OptionalObjectSchema<Pick<TShape, TKey>, TContext, TypeOfShape<Pick<TShape, TKey>> | Optionals<TIn>>;
omit<TKey extends keyof TShape>(keys: TKey[]): OptionalObjectSchema<Omit<TShape, TKey>, TContext, TypeOfShape<Omit<TShape, TKey>> | Optionals<TIn>>;
}
export interface DefinedObjectSchema<TShape extends ObjectShape, TContext extends AnyObject, TIn extends Maybe<TypeOfShape<TShape>>> extends ObjectSchema<TShape, TContext, TIn, AssertsShape<TShape> | Extract<TIn, null>> {
default<TNextDefault extends Maybe<AnyObject>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? DefinedObjectSchema<TShape, TContext, TIn | undefined> : DefinedObjectSchema<TShape, TContext, Defined<TIn>>;
defined(msg?: MixedLocale['defined']): this;
required(msg?: MixedLocale['required']): RequiredObjectSchema<TShape, TContext, TIn>;
optional(): OptionalObjectSchema<TShape, TContext, TIn>;
notRequired(): OptionalObjectSchema<TShape, TContext, TIn>;
nullable(isNullable?: true): DefinedObjectSchema<TShape, TContext, TIn | null>;
nullable(isNullable: false): DefinedObjectSchema<TShape, TContext, Exclude<TIn, null>>;
pick<TKey extends keyof TShape>(keys: TKey[]): DefinedObjectSchema<Pick<TShape, TKey>, TContext, TypeOfShape<Pick<TShape, TKey>> | Optionals<TIn>>;
omit<TKey extends keyof TShape>(keys: TKey[]): DefinedObjectSchema<Omit<TShape, TKey>, TContext, TypeOfShape<Omit<TShape, TKey>> | Optionals<TIn>>;
}
export interface RequiredObjectSchema<TShape extends ObjectShape, TContext extends AnyObject, TIn extends Maybe<TypeOfShape<TShape>>> extends ObjectSchema<TShape, TContext, TIn, AssertsShape<TShape>> {
default<TNextDefault extends Maybe<AnyObject>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? RequiredObjectSchema<TShape, TContext, TIn | undefined> : RequiredObjectSchema<TShape, TContext, Defined<TIn>>;
defined(msg?: MixedLocale['defined']): DefinedObjectSchema<TShape, TContext, TIn>;
required(msg?: MixedLocale['required']): this;
optional(): OptionalObjectSchema<TShape, TContext, TIn>;
notRequired(): OptionalObjectSchema<TShape, TContext, TIn>;
nullable(isNullable?: true): RequiredObjectSchema<TShape, TContext, TIn | null>;
nullable(isNullable: false): RequiredObjectSchema<TShape, TContext, Exclude<TIn, null>>;
pick<TKey extends keyof TShape>(keys: TKey[]): RequiredObjectSchema<Pick<TShape, TKey>, TContext, TypeOfShape<Pick<TShape, TKey>> | Optionals<TIn>>;
omit<TKey extends keyof TShape>(keys: TKey[]): RequiredObjectSchema<Omit<TShape, TKey>, TContext, TypeOfShape<Omit<TShape, TKey>> | Optionals<TIn>>;
}

352
server/node_modules/yup/es/object.js generated vendored Normal file
View File

@@ -0,0 +1,352 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import has from 'lodash/has';
import snakeCase from 'lodash/snakeCase';
import camelCase from 'lodash/camelCase';
import mapKeys from 'lodash/mapKeys';
import mapValues from 'lodash/mapValues';
import { getter } from 'property-expr';
import { object as locale } from './locale';
import sortFields from './util/sortFields';
import sortByKeyOrder from './util/sortByKeyOrder';
import runTests from './util/runTests';
import ValidationError from './ValidationError';
import BaseSchema from './schema';
let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
function unknown(ctx, value) {
let known = Object.keys(ctx.fields);
return Object.keys(value).filter(key => known.indexOf(key) === -1);
}
const defaultSort = sortByKeyOrder([]);
export default class ObjectSchema extends BaseSchema {
constructor(spec) {
super({
type: 'object'
});
this.fields = Object.create(null);
this._sortErrors = defaultSort;
this._nodes = [];
this._excludedEdges = [];
this.withMutation(() => {
this.transform(function coerce(value) {
if (typeof value === 'string') {
try {
value = JSON.parse(value);
} catch (err) {
value = null;
}
}
if (this.isType(value)) return value;
return null;
});
if (spec) {
this.shape(spec);
}
});
}
_typeCheck(value) {
return isObject(value) || typeof value === 'function';
}
_cast(_value, options = {}) {
var _options$stripUnknown;
let value = super._cast(_value, options); //should ignore nulls here
if (value === undefined) return this.getDefault();
if (!this._typeCheck(value)) return value;
let fields = this.fields;
let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
let props = this._nodes.concat(Object.keys(value).filter(v => this._nodes.indexOf(v) === -1));
let intermediateValue = {}; // is filled during the transform below
let innerOptions = _extends({}, options, {
parent: intermediateValue,
__validating: options.__validating || false
});
let isChanged = false;
for (const prop of props) {
let field = fields[prop];
let exists = has(value, prop);
if (field) {
let fieldValue;
let inputValue = value[prop]; // safe to mutate since this is fired in sequence
innerOptions.path = (options.path ? `${options.path}.` : '') + prop; // innerOptions.value = value[prop];
field = field.resolve({
value: inputValue,
context: options.context,
parent: intermediateValue
});
let fieldSpec = 'spec' in field ? field.spec : undefined;
let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
if (fieldSpec == null ? void 0 : fieldSpec.strip) {
isChanged = isChanged || prop in value;
continue;
}
fieldValue = !options.__validating || !strict ? // TODO: use _cast, this is double resolving
field.cast(value[prop], innerOptions) : value[prop];
if (fieldValue !== undefined) {
intermediateValue[prop] = fieldValue;
}
} else if (exists && !strip) {
intermediateValue[prop] = value[prop];
}
if (intermediateValue[prop] !== value[prop]) {
isChanged = true;
}
}
return isChanged ? intermediateValue : value;
}
_validate(_value, opts = {}, callback) {
let errors = [];
let {
sync,
from = [],
originalValue = _value,
abortEarly = this.spec.abortEarly,
recursive = this.spec.recursive
} = opts;
from = [{
schema: this,
value: originalValue
}, ...from]; // this flag is needed for handling `strict` correctly in the context of
// validation vs just casting. e.g strict() on a field is only used when validating
opts.__validating = true;
opts.originalValue = originalValue;
opts.from = from;
super._validate(_value, opts, (err, value) => {
if (err) {
if (!ValidationError.isError(err) || abortEarly) {
return void callback(err, value);
}
errors.push(err);
}
if (!recursive || !isObject(value)) {
callback(errors[0] || null, value);
return;
}
originalValue = originalValue || value;
let tests = this._nodes.map(key => (_, cb) => {
let path = key.indexOf('.') === -1 ? (opts.path ? `${opts.path}.` : '') + key : `${opts.path || ''}["${key}"]`;
let field = this.fields[key];
if (field && 'validate' in field) {
field.validate(value[key], _extends({}, opts, {
// @ts-ignore
path,
from,
// inner fields are always strict:
// 1. this isn't strict so the casting will also have cast inner values
// 2. this is strict in which case the nested values weren't cast either
strict: true,
parent: value,
originalValue: originalValue[key]
}), cb);
return;
}
cb(null);
});
runTests({
sync,
tests,
value,
errors,
endEarly: abortEarly,
sort: this._sortErrors,
path: opts.path
}, callback);
});
}
clone(spec) {
const next = super.clone(spec);
next.fields = _extends({}, this.fields);
next._nodes = this._nodes;
next._excludedEdges = this._excludedEdges;
next._sortErrors = this._sortErrors;
return next;
}
concat(schema) {
let next = super.concat(schema);
let nextFields = next.fields;
for (let [field, schemaOrRef] of Object.entries(this.fields)) {
const target = nextFields[field];
if (target === undefined) {
nextFields[field] = schemaOrRef;
} else if (target instanceof BaseSchema && schemaOrRef instanceof BaseSchema) {
nextFields[field] = schemaOrRef.concat(target);
}
}
return next.withMutation(() => next.shape(nextFields));
}
getDefaultFromShape() {
let dft = {};
this._nodes.forEach(key => {
const field = this.fields[key];
dft[key] = 'default' in field ? field.getDefault() : undefined;
});
return dft;
}
_getDefault() {
if ('default' in this.spec) {
return super._getDefault();
} // if there is no default set invent one
if (!this._nodes.length) {
return undefined;
}
return this.getDefaultFromShape();
}
shape(additions, excludes = []) {
let next = this.clone();
let fields = Object.assign(next.fields, additions);
next.fields = fields;
next._sortErrors = sortByKeyOrder(Object.keys(fields));
if (excludes.length) {
if (!Array.isArray(excludes[0])) excludes = [excludes];
let keys = excludes.map(([first, second]) => `${first}-${second}`);
next._excludedEdges = next._excludedEdges.concat(keys);
}
next._nodes = sortFields(fields, next._excludedEdges);
return next;
}
pick(keys) {
const picked = {};
for (const key of keys) {
if (this.fields[key]) picked[key] = this.fields[key];
}
return this.clone().withMutation(next => {
next.fields = {};
return next.shape(picked);
});
}
omit(keys) {
const next = this.clone();
const fields = next.fields;
next.fields = {};
for (const key of keys) {
delete fields[key];
}
return next.withMutation(() => next.shape(fields));
}
from(from, to, alias) {
let fromGetter = getter(from, true);
return this.transform(obj => {
if (obj == null) return obj;
let newObj = obj;
if (has(obj, from)) {
newObj = _extends({}, obj);
if (!alias) delete newObj[from];
newObj[to] = fromGetter(obj);
}
return newObj;
});
}
noUnknown(noAllow = true, message = locale.noUnknown) {
if (typeof noAllow === 'string') {
message = noAllow;
noAllow = true;
}
let next = this.test({
name: 'noUnknown',
exclusive: true,
message: message,
test(value) {
if (value == null) return true;
const unknownKeys = unknown(this.schema, value);
return !noAllow || unknownKeys.length === 0 || this.createError({
params: {
unknown: unknownKeys.join(', ')
}
});
}
});
next.spec.noUnknown = noAllow;
return next;
}
unknown(allow = true, message = locale.noUnknown) {
return this.noUnknown(!allow, message);
}
transformKeys(fn) {
return this.transform(obj => obj && mapKeys(obj, (_, key) => fn(key)));
}
camelCase() {
return this.transformKeys(camelCase);
}
snakeCase() {
return this.transformKeys(snakeCase);
}
constantCase() {
return this.transformKeys(key => snakeCase(key).toUpperCase());
}
describe() {
let base = super.describe();
base.fields = mapValues(this.fields, value => value.describe());
return base;
}
}
export function create(spec) {
return new ObjectSchema(spec);
}
create.prototype = ObjectSchema.prototype;

143
server/node_modules/yup/es/schema.d.ts generated vendored Normal file
View File

@@ -0,0 +1,143 @@
import { ConditionOptions, ResolveOptions } from './Condition';
import { TestFunction, Test, TestConfig } from './util/createValidation';
import { ValidateOptions, TransformFunction, Message, Callback, InternalOptions, Maybe, ExtraParams, AnyObject } from './types';
import type { Asserts, Thunk } from './util/types';
import ReferenceSet from './util/ReferenceSet';
import Reference from './Reference';
export declare type SchemaSpec<TDefault> = {
nullable: boolean;
presence: 'required' | 'defined' | 'optional';
default?: TDefault | (() => TDefault);
abortEarly?: boolean;
strip?: boolean;
strict?: boolean;
recursive?: boolean;
label?: string | undefined;
meta?: any;
};
export declare type SchemaOptions<TDefault> = {
type?: string;
spec?: SchemaSpec<TDefault>;
};
export declare type AnySchema<Type = any, TContext = any, TOut = any> = BaseSchema<Type, TContext, TOut>;
export interface CastOptions<TContext = {}> {
parent?: any;
context?: TContext;
assert?: boolean;
stripUnknown?: boolean;
path?: string;
}
export interface SchemaRefDescription {
type: 'ref';
key: string;
}
export interface SchemaInnerTypeDescription extends SchemaDescription {
innerType?: SchemaFieldDescription;
}
export interface SchemaObjectDescription extends SchemaDescription {
fields: Record<string, SchemaFieldDescription>;
}
export declare type SchemaFieldDescription = SchemaDescription | SchemaRefDescription | SchemaObjectDescription | SchemaInnerTypeDescription;
export interface SchemaDescription {
type: string;
label?: string;
meta: object;
oneOf: unknown[];
notOneOf: unknown[];
tests: Array<{
name?: string;
params: ExtraParams | undefined;
}>;
}
export default abstract class BaseSchema<TCast = any, TContext = AnyObject, TOutput = any> {
readonly type: string;
readonly __inputType: TCast;
readonly __outputType: TOutput;
readonly __isYupSchema__: boolean;
readonly deps: readonly string[];
tests: Test[];
transforms: TransformFunction<AnySchema>[];
private conditions;
private _mutate?;
private _typeError?;
private _whitelistError?;
private _blacklistError?;
protected _whitelist: ReferenceSet;
protected _blacklist: ReferenceSet;
protected exclusiveTests: Record<string, boolean>;
spec: SchemaSpec<any>;
constructor(options?: SchemaOptions<any>);
get _type(): string;
protected _typeCheck(_value: any): _value is NonNullable<TCast>;
clone(spec?: Partial<SchemaSpec<any>>): this;
label(label: string): this;
meta(): Record<string, unknown> | undefined;
meta(obj: Record<string, unknown>): this;
withMutation<T>(fn: (schema: this) => T): T;
concat(schema: this): this;
concat(schema: AnySchema): AnySchema;
isType(v: any): boolean;
resolve(options: ResolveOptions): this;
/**
*
* @param {*} value
* @param {Object} options
* @param {*=} options.parent
* @param {*=} options.context
*/
cast(value: any, options?: CastOptions<TContext>): TCast;
protected _cast(rawValue: any, _options: CastOptions<TContext>): any;
protected _validate(_value: any, options: InternalOptions<TContext> | undefined, cb: Callback): void;
validate(value: any, options?: ValidateOptions<TContext>): Promise<this['__outputType']>;
validateSync(value: any, options?: ValidateOptions<TContext>): this['__outputType'];
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): value is Asserts<this>;
protected _getDefault(): any;
getDefault(options?: ResolveOptions): TCast;
default(def: Thunk<any>): any;
strict(isStrict?: boolean): this;
protected _isPresent(value: unknown): boolean;
defined(message?: Message<{}>): any;
required(message?: Message<{}>): any;
notRequired(): any;
nullable(isNullable?: true): any;
nullable(isNullable: false): any;
transform(fn: TransformFunction<this>): this;
/**
* Adds a test function to the schema's queue of tests.
* tests can be exclusive or non-exclusive.
*
* - exclusive tests, will replace any existing tests of the same name.
* - non-exclusive: can be stacked
*
* If a non-exclusive test is added to a schema with an exclusive test of the same name
* the exclusive test is removed and further tests of the same name will be stacked.
*
* If an exclusive test is added to a schema with non-exclusive tests of the same name
* the previous tests are removed and further tests of the same name will replace each other.
*/
test(options: TestConfig<TCast, TContext>): this;
test(test: TestFunction<TCast, TContext>): this;
test(name: string, test: TestFunction<TCast, TContext>): this;
test(name: string, message: Message, test: TestFunction<TCast, TContext>): this;
when(options: ConditionOptions<this>): this;
when(keys: string | string[], options: ConditionOptions<this>): this;
typeError(message: Message): this;
oneOf<U extends TCast>(enums: Array<Maybe<U> | Reference>, message?: Message<{
values: any;
}>): this;
notOneOf<U extends TCast>(enums: Array<Maybe<U> | Reference>, message?: Message<{
values: any;
}>): this;
strip(strip?: boolean): this;
describe(): SchemaDescription;
}
export default interface BaseSchema<TCast, TContext, TOutput> {
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<TOutput>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): TOutput;
equals: BaseSchema['oneOf'];
is: BaseSchema['oneOf'];
not: BaseSchema['notOneOf'];
nope: BaseSchema['notOneOf'];
optional(): any;
}

560
server/node_modules/yup/es/schema.js generated vendored Normal file
View File

@@ -0,0 +1,560 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
// @ts-ignore
import cloneDeep from 'nanoclone';
import { mixed as locale } from './locale';
import Condition from './Condition';
import runTests from './util/runTests';
import createValidation from './util/createValidation';
import printValue from './util/printValue';
import Ref from './Reference';
import { getIn } from './util/reach';
import toArray from './util/toArray';
import ValidationError from './ValidationError';
import ReferenceSet from './util/ReferenceSet';
export default class BaseSchema {
constructor(options) {
this.deps = [];
this.conditions = [];
this._whitelist = new ReferenceSet();
this._blacklist = new ReferenceSet();
this.exclusiveTests = Object.create(null);
this.tests = [];
this.transforms = [];
this.withMutation(() => {
this.typeError(locale.notType);
});
this.type = (options == null ? void 0 : options.type) || 'mixed';
this.spec = _extends({
strip: false,
strict: false,
abortEarly: true,
recursive: true,
nullable: false,
presence: 'optional'
}, options == null ? void 0 : options.spec);
} // TODO: remove
get _type() {
return this.type;
}
_typeCheck(_value) {
return true;
}
clone(spec) {
if (this._mutate) {
if (spec) Object.assign(this.spec, spec);
return this;
} // if the nested value is a schema we can skip cloning, since
// they are already immutable
const next = Object.create(Object.getPrototypeOf(this)); // @ts-expect-error this is readonly
next.type = this.type;
next._typeError = this._typeError;
next._whitelistError = this._whitelistError;
next._blacklistError = this._blacklistError;
next._whitelist = this._whitelist.clone();
next._blacklist = this._blacklist.clone();
next.exclusiveTests = _extends({}, this.exclusiveTests); // @ts-expect-error this is readonly
next.deps = [...this.deps];
next.conditions = [...this.conditions];
next.tests = [...this.tests];
next.transforms = [...this.transforms];
next.spec = cloneDeep(_extends({}, this.spec, spec));
return next;
}
label(label) {
var next = this.clone();
next.spec.label = label;
return next;
}
meta(...args) {
if (args.length === 0) return this.spec.meta;
let next = this.clone();
next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
return next;
} // withContext<TContext extends AnyObject>(): BaseSchema<
// TCast,
// TContext,
// TOutput
// > {
// return this as any;
// }
withMutation(fn) {
let before = this._mutate;
this._mutate = true;
let result = fn(this);
this._mutate = before;
return result;
}
concat(schema) {
if (!schema || schema === this) return this;
if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
let base = this;
let combined = schema.clone();
const mergedSpec = _extends({}, base.spec, combined.spec); // if (combined.spec.nullable === UNSET)
// mergedSpec.nullable = base.spec.nullable;
// if (combined.spec.presence === UNSET)
// mergedSpec.presence = base.spec.presence;
combined.spec = mergedSpec;
combined._typeError || (combined._typeError = base._typeError);
combined._whitelistError || (combined._whitelistError = base._whitelistError);
combined._blacklistError || (combined._blacklistError = base._blacklistError); // manually merge the blacklist/whitelist (the other `schema` takes
// precedence in case of conflicts)
combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist); // start with the current tests
combined.tests = base.tests;
combined.exclusiveTests = base.exclusiveTests; // manually add the new tests to ensure
// the deduping logic is consistent
combined.withMutation(next => {
schema.tests.forEach(fn => {
next.test(fn.OPTIONS);
});
});
return combined;
}
isType(v) {
if (this.spec.nullable && v === null) return true;
return this._typeCheck(v);
}
resolve(options) {
let schema = this;
if (schema.conditions.length) {
let conditions = schema.conditions;
schema = schema.clone();
schema.conditions = [];
schema = conditions.reduce((schema, condition) => condition.resolve(schema, options), schema);
schema = schema.resolve(options);
}
return schema;
}
/**
*
* @param {*} value
* @param {Object} options
* @param {*=} options.parent
* @param {*=} options.context
*/
cast(value, options = {}) {
let resolvedSchema = this.resolve(_extends({
value
}, options));
let result = resolvedSchema._cast(value, options);
if (value !== undefined && options.assert !== false && resolvedSchema.isType(result) !== true) {
let formattedValue = printValue(value);
let formattedResult = printValue(result);
throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema._type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
}
return result;
}
_cast(rawValue, _options) {
let value = rawValue === undefined ? rawValue : this.transforms.reduce((value, fn) => fn.call(this, value, rawValue, this), rawValue);
if (value === undefined) {
value = this.getDefault();
}
return value;
}
_validate(_value, options = {}, cb) {
let {
sync,
path,
from = [],
originalValue = _value,
strict = this.spec.strict,
abortEarly = this.spec.abortEarly
} = options;
let value = _value;
if (!strict) {
// this._validating = true;
value = this._cast(value, _extends({
assert: false
}, options)); // this._validating = false;
} // value is cast, we can check if it meets type requirements
let args = {
value,
path,
options,
originalValue,
schema: this,
label: this.spec.label,
sync,
from
};
let initialTests = [];
if (this._typeError) initialTests.push(this._typeError);
if (this._whitelistError) initialTests.push(this._whitelistError);
if (this._blacklistError) initialTests.push(this._blacklistError);
runTests({
args,
value,
path,
sync,
tests: initialTests,
endEarly: abortEarly
}, err => {
if (err) return void cb(err, value);
runTests({
tests: this.tests,
args,
path,
sync,
value,
endEarly: abortEarly
}, cb);
});
}
validate(value, options, maybeCb) {
let schema = this.resolve(_extends({}, options, {
value
})); // callback case is for nested validations
return typeof maybeCb === 'function' ? schema._validate(value, options, maybeCb) : new Promise((resolve, reject) => schema._validate(value, options, (err, value) => {
if (err) reject(err);else resolve(value);
}));
}
validateSync(value, options) {
let schema = this.resolve(_extends({}, options, {
value
}));
let result;
schema._validate(value, _extends({}, options, {
sync: true
}), (err, value) => {
if (err) throw err;
result = value;
});
return result;
}
isValid(value, options) {
return this.validate(value, options).then(() => true, err => {
if (ValidationError.isError(err)) return false;
throw err;
});
}
isValidSync(value, options) {
try {
this.validateSync(value, options);
return true;
} catch (err) {
if (ValidationError.isError(err)) return false;
throw err;
}
}
_getDefault() {
let defaultValue = this.spec.default;
if (defaultValue == null) {
return defaultValue;
}
return typeof defaultValue === 'function' ? defaultValue.call(this) : cloneDeep(defaultValue);
}
getDefault(options) {
let schema = this.resolve(options || {});
return schema._getDefault();
}
default(def) {
if (arguments.length === 0) {
return this._getDefault();
}
let next = this.clone({
default: def
});
return next;
}
strict(isStrict = true) {
var next = this.clone();
next.spec.strict = isStrict;
return next;
}
_isPresent(value) {
return value != null;
}
defined(message = locale.defined) {
return this.test({
message,
name: 'defined',
exclusive: true,
test(value) {
return value !== undefined;
}
});
}
required(message = locale.required) {
return this.clone({
presence: 'required'
}).withMutation(s => s.test({
message,
name: 'required',
exclusive: true,
test(value) {
return this.schema._isPresent(value);
}
}));
}
notRequired() {
var next = this.clone({
presence: 'optional'
});
next.tests = next.tests.filter(test => test.OPTIONS.name !== 'required');
return next;
}
nullable(isNullable = true) {
var next = this.clone({
nullable: isNullable !== false
});
return next;
}
transform(fn) {
var next = this.clone();
next.transforms.push(fn);
return next;
}
/**
* Adds a test function to the schema's queue of tests.
* tests can be exclusive or non-exclusive.
*
* - exclusive tests, will replace any existing tests of the same name.
* - non-exclusive: can be stacked
*
* If a non-exclusive test is added to a schema with an exclusive test of the same name
* the exclusive test is removed and further tests of the same name will be stacked.
*
* If an exclusive test is added to a schema with non-exclusive tests of the same name
* the previous tests are removed and further tests of the same name will replace each other.
*/
test(...args) {
let opts;
if (args.length === 1) {
if (typeof args[0] === 'function') {
opts = {
test: args[0]
};
} else {
opts = args[0];
}
} else if (args.length === 2) {
opts = {
name: args[0],
test: args[1]
};
} else {
opts = {
name: args[0],
message: args[1],
test: args[2]
};
}
if (opts.message === undefined) opts.message = locale.default;
if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
let next = this.clone();
let validate = createValidation(opts);
let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
if (opts.exclusive) {
if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
}
if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
next.tests = next.tests.filter(fn => {
if (fn.OPTIONS.name === opts.name) {
if (isExclusive) return false;
if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
}
return true;
});
next.tests.push(validate);
return next;
}
when(keys, options) {
if (!Array.isArray(keys) && typeof keys !== 'string') {
options = keys;
keys = '.';
}
let next = this.clone();
let deps = toArray(keys).map(key => new Ref(key));
deps.forEach(dep => {
// @ts-ignore
if (dep.isSibling) next.deps.push(dep.key);
});
next.conditions.push(new Condition(deps, options));
return next;
}
typeError(message) {
var next = this.clone();
next._typeError = createValidation({
message,
name: 'typeError',
test(value) {
if (value !== undefined && !this.schema.isType(value)) return this.createError({
params: {
type: this.schema._type
}
});
return true;
}
});
return next;
}
oneOf(enums, message = locale.oneOf) {
var next = this.clone();
enums.forEach(val => {
next._whitelist.add(val);
next._blacklist.delete(val);
});
next._whitelistError = createValidation({
message,
name: 'oneOf',
test(value) {
if (value === undefined) return true;
let valids = this.schema._whitelist;
return valids.has(value, this.resolve) ? true : this.createError({
params: {
values: valids.toArray().join(', ')
}
});
}
});
return next;
}
notOneOf(enums, message = locale.notOneOf) {
var next = this.clone();
enums.forEach(val => {
next._blacklist.add(val);
next._whitelist.delete(val);
});
next._blacklistError = createValidation({
message,
name: 'notOneOf',
test(value) {
let invalids = this.schema._blacklist;
if (invalids.has(value, this.resolve)) return this.createError({
params: {
values: invalids.toArray().join(', ')
}
});
return true;
}
});
return next;
}
strip(strip = true) {
let next = this.clone();
next.spec.strip = strip;
return next;
}
describe() {
const next = this.clone();
const {
label,
meta
} = next.spec;
const description = {
meta,
label,
type: next.type,
oneOf: next._whitelist.describe(),
notOneOf: next._blacklist.describe(),
tests: next.tests.map(fn => ({
name: fn.OPTIONS.name,
params: fn.OPTIONS.params
})).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
};
return description;
}
}
// @ts-expect-error
BaseSchema.prototype.__isYupSchema__ = true;
for (const method of ['validate', 'validateSync']) BaseSchema.prototype[`${method}At`] = function (path, value, options = {}) {
const {
parent,
parentPath,
schema
} = getIn(this, path, value, options.context);
return schema[method](parent && parent[parentPath], _extends({}, options, {
parent,
path
}));
};
for (const alias of ['equals', 'is']) BaseSchema.prototype[alias] = BaseSchema.prototype.oneOf;
for (const alias of ['not', 'nope']) BaseSchema.prototype[alias] = BaseSchema.prototype.notOneOf;
BaseSchema.prototype.optional = BaseSchema.prototype.notRequired;

1
server/node_modules/yup/es/setLocale.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function setLocale(custom: any): void;

8
server/node_modules/yup/es/setLocale.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import locale from './locale';
export default function setLocale(custom) {
Object.keys(custom).forEach(type => {
Object.keys(custom[type]).forEach(method => {
locale[type][method] = custom[type][method];
});
});
}

73
server/node_modules/yup/es/string.d.ts generated vendored Normal file
View File

@@ -0,0 +1,73 @@
import { MixedLocale } from './locale';
import type Reference from './Reference';
import type { Message, Maybe, AnyObject } from './types';
import type { Defined, If, Thunk } from './util/types';
import BaseSchema from './schema';
export declare type MatchOptions = {
excludeEmptyString?: boolean;
message: Message<{
regex: RegExp;
}>;
name?: string;
};
export declare function create(): StringSchema<string | undefined, Record<string, any>, string | undefined>;
export declare namespace create {
var prototype: StringSchema<any, any, any>;
}
export default class StringSchema<TType extends Maybe<string> = string | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
constructor();
protected _typeCheck(value: any): value is NonNullable<TType>;
protected _isPresent(value: any): boolean;
length(length: number | Reference<number>, message?: Message<{
length: number;
}>): this;
min(min: number | Reference<number>, message?: Message<{
min: number;
}>): this;
max(max: number | Reference<number>, message?: Message<{
max: number;
}>): this;
matches(regex: RegExp, options?: MatchOptions | MatchOptions['message']): this;
email(message?: Message<{
regex: RegExp;
}>): this;
url(message?: Message<{
regex: RegExp;
}>): this;
uuid(message?: Message<{
regex: RegExp;
}>): this;
ensure(): StringSchema<NonNullable<TType>>;
trim(message?: Message<{}>): this;
lowercase(message?: Message<{}>): this;
uppercase(message?: Message<{}>): this;
}
export interface DefinedStringSchema<TType extends Maybe<string>, TContext extends AnyObject = AnyObject> extends StringSchema<TType, TContext, Defined<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, DefinedStringSchema<TType | undefined, TContext>, DefinedStringSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): this;
required(msg?: MixedLocale['required']): RequiredStringSchema<TType, TContext>;
optional(): StringSchema<TType, TContext>;
notRequired(): StringSchema<TType, TContext>;
nullable(isNullable?: true): RequiredStringSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredStringSchema<Exclude<TType, null>, TContext>;
}
export interface RequiredStringSchema<TType extends Maybe<string>, TContext extends AnyObject = AnyObject> extends StringSchema<TType, TContext, NonNullable<TType>> {
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, RequiredStringSchema<TType | undefined, TContext>, RequiredStringSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedStringSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredStringSchema<TType, TContext>;
optional(): StringSchema<TType, TContext>;
notRequired(): StringSchema<TType, TContext>;
nullable(isNullable?: true): RequiredStringSchema<TType | null, TContext>;
nullable(isNullable: false): RequiredStringSchema<Exclude<TType, null>, TContext>;
}
export default interface StringSchema<TType extends Maybe<string> = string | undefined, TContext extends AnyObject = AnyObject, TOut extends TType = TType> extends BaseSchema<TType, TContext, TOut> {
concat<TOther extends StringSchema<any, any, any>>(schema: TOther): TOther;
default<D extends Maybe<TType>>(def: Thunk<D>): If<D, StringSchema<TType | undefined, TContext>, StringSchema<Defined<TType>, TContext>>;
defined(msg?: MixedLocale['defined']): DefinedStringSchema<TType, TContext>;
required(msg?: MixedLocale['required']): RequiredStringSchema<TType, TContext>;
optional(): StringSchema<TType, TContext>;
notRequired(): StringSchema<TType, TContext>;
nullable(isNullable?: true): StringSchema<TType | null, TContext>;
nullable(isNullable: false): StringSchema<Exclude<TType, null>, TContext>;
withContext<TNextContext extends TContext>(): StringSchema<Exclude<TType, null>, TNextContext>;
}

175
server/node_modules/yup/es/string.js generated vendored Normal file
View File

@@ -0,0 +1,175 @@
import { string as locale } from './locale';
import isAbsent from './util/isAbsent';
import BaseSchema from './schema'; // eslint-disable-next-line
let rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-next-line
let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; // eslint-disable-next-line
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
let isTrimmed = value => isAbsent(value) || value === value.trim();
let objStringTag = {}.toString();
export function create() {
return new StringSchema();
}
export default class StringSchema extends BaseSchema {
constructor() {
super({
type: 'string'
});
this.withMutation(() => {
this.transform(function (value) {
if (this.isType(value)) return value;
if (Array.isArray(value)) return value;
const strValue = value != null && value.toString ? value.toString() : value;
if (strValue === objStringTag) return value;
return strValue;
});
});
}
_typeCheck(value) {
if (value instanceof String) value = value.valueOf();
return typeof value === 'string';
}
_isPresent(value) {
return super._isPresent(value) && !!value.length;
}
length(length, message = locale.length) {
return this.test({
message,
name: 'length',
exclusive: true,
params: {
length
},
test(value) {
return isAbsent(value) || value.length === this.resolve(length);
}
});
}
min(min, message = locale.min) {
return this.test({
message,
name: 'min',
exclusive: true,
params: {
min
},
test(value) {
return isAbsent(value) || value.length >= this.resolve(min);
}
});
}
max(max, message = locale.max) {
return this.test({
name: 'max',
exclusive: true,
message,
params: {
max
},
test(value) {
return isAbsent(value) || value.length <= this.resolve(max);
}
});
}
matches(regex, options) {
let excludeEmptyString = false;
let message;
let name;
if (options) {
if (typeof options === 'object') {
({
excludeEmptyString = false,
message,
name
} = options);
} else {
message = options;
}
}
return this.test({
name: name || 'matches',
message: message || locale.matches,
params: {
regex
},
test: value => isAbsent(value) || value === '' && excludeEmptyString || value.search(regex) !== -1
});
}
email(message = locale.email) {
return this.matches(rEmail, {
name: 'email',
message,
excludeEmptyString: true
});
}
url(message = locale.url) {
return this.matches(rUrl, {
name: 'url',
message,
excludeEmptyString: true
});
}
uuid(message = locale.uuid) {
return this.matches(rUUID, {
name: 'uuid',
message,
excludeEmptyString: false
});
} //-- transforms --
ensure() {
return this.default('').transform(val => val === null ? '' : val);
}
trim(message = locale.trim) {
return this.transform(val => val != null ? val.trim() : val).test({
message,
name: 'trim',
test: isTrimmed
});
}
lowercase(message = locale.lowercase) {
return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
message,
name: 'string_case',
exclusive: true,
test: value => isAbsent(value) || value === value.toLowerCase()
});
}
uppercase(message = locale.uppercase) {
return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
message,
name: 'string_case',
exclusive: true,
test: value => isAbsent(value) || value === value.toUpperCase()
});
}
}
create.prototype = StringSchema.prototype; //
// String Interfaces
//

52
server/node_modules/yup/es/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import type { AnySchema } from './schema';
import type Lazy from './Lazy';
export declare type AnyObject = Record<string, any>;
export declare type SchemaLike = AnySchema | Lazy<any>;
export declare type Callback<T = any> = (err: Error | null, value?: T) => void;
export declare type TransformFunction<T extends AnySchema> = (this: T, value: any, originalValue: any, schema: T) => any;
export interface ValidateOptions<TContext = {}> {
/**
* Only validate the input, and skip and coercion or transformation. Default - false
*/
strict?: boolean;
/**
* Return from validation methods on the first error rather than after all validations run. Default - true
*/
abortEarly?: boolean;
/**
* Remove unspecified keys from objects. Default - false
*/
stripUnknown?: boolean;
/**
* When false validations will not descend into nested schema (relevant for objects or arrays). Default - true
*/
recursive?: boolean;
/**
* Any context needed for validating schema conditions (see: when())
*/
context?: TContext;
}
export interface InternalOptions<TContext = {}> extends ValidateOptions<TContext> {
__validating?: boolean;
originalValue?: any;
parent?: any;
path?: string;
sync?: boolean;
from?: {
schema: AnySchema;
value: any;
}[];
}
export interface MessageParams {
path: string;
value: any;
originalValue: any;
label: string;
type: string;
}
export declare type Message<Extra extends Record<string, unknown> = {}> = string | ((params: Extra & MessageParams) => unknown) | Record<PropertyKey, unknown>;
export declare type ExtraParams = Record<string, unknown>;
export declare type AnyMessageParams = MessageParams & ExtraParams;
export declare type Maybe<T> = T | null | undefined;
export declare type Preserve<T, U> = T extends U ? U : never;
export declare type Optionals<T> = Extract<T, null | undefined>;

0
server/node_modules/yup/es/types.js generated vendored Normal file
View File

14
server/node_modules/yup/es/util/ReferenceSet.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import Reference from '../Reference';
export default class ReferenceSet {
list: Set<unknown>;
refs: Map<string, Reference>;
constructor();
get size(): number;
describe(): unknown[];
toArray(): unknown[];
add(value: unknown): void;
delete(value: unknown): void;
has(value: unknown, resolve: (v: unknown) => unknown): boolean;
clone(): ReferenceSet;
merge(newItems: ReferenceSet, removeItems: ReferenceSet): ReferenceSet;
}

60
server/node_modules/yup/es/util/ReferenceSet.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
import Reference from '../Reference';
export default class ReferenceSet {
constructor() {
this.list = new Set();
this.refs = new Map();
}
get size() {
return this.list.size + this.refs.size;
}
describe() {
const description = [];
for (const item of this.list) description.push(item);
for (const [, ref] of this.refs) description.push(ref.describe());
return description;
}
toArray() {
return Array.from(this.list).concat(Array.from(this.refs.values()));
}
add(value) {
Reference.isRef(value) ? this.refs.set(value.key, value) : this.list.add(value);
}
delete(value) {
Reference.isRef(value) ? this.refs.delete(value.key) : this.list.delete(value);
}
has(value, resolve) {
if (this.list.has(value)) return true;
let item,
values = this.refs.values();
while (item = values.next(), !item.done) if (resolve(item.value) === value) return true;
return false;
}
clone() {
const next = new ReferenceSet();
next.list = new Set(this.list);
next.refs = new Map(this.refs);
return next;
}
merge(newItems, removeItems) {
const next = this.clone();
newItems.list.forEach(value => next.add(value));
newItems.refs.forEach(value => next.add(value));
removeItems.list.forEach(value => next.delete(value));
removeItems.refs.forEach(value => next.delete(value));
return next;
}
}

52
server/node_modules/yup/es/util/createValidation.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import ValidationError from '../ValidationError';
import { ValidateOptions, Message, InternalOptions, Callback, ExtraParams } from '../types';
import Reference from '../Reference';
import type { AnySchema } from '../schema';
export declare type CreateErrorOptions = {
path?: string;
message?: Message<any>;
params?: ExtraParams;
type?: string;
};
export declare type TestContext<TContext = {}> = {
path: string;
options: ValidateOptions<TContext>;
parent: any;
schema: any;
resolve: <T>(value: T | Reference<T>) => T;
createError: (params?: CreateErrorOptions) => ValidationError;
};
export declare type TestFunction<T = unknown, TContext = {}> = (this: TestContext<TContext>, value: T, context: TestContext<TContext>) => boolean | ValidationError | Promise<boolean | ValidationError>;
export declare type TestOptions<TSchema extends AnySchema = AnySchema> = {
value: any;
path?: string;
label?: string;
options: InternalOptions;
originalValue: any;
schema: TSchema;
sync?: boolean;
};
export declare type TestConfig<TValue = unknown, TContext = {}> = {
name?: string;
message?: Message<any>;
test: TestFunction<TValue, TContext>;
params?: ExtraParams;
exclusive?: boolean;
};
export declare type Test = ((opts: TestOptions, cb: Callback) => void) & {
OPTIONS: TestConfig;
};
export default function createValidation(config: {
name?: string;
test: TestFunction;
params?: ExtraParams;
message?: Message<any>;
}): {
<TSchema extends AnySchema<any, any, any> = AnySchema<any, any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
OPTIONS: {
name?: string | undefined;
test: TestFunction;
params?: Record<string, unknown> | undefined;
message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined;
};
};

89
server/node_modules/yup/es/util/createValidation.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import mapValues from 'lodash/mapValues';
import ValidationError from '../ValidationError';
import Ref from '../Reference';
export default function createValidation(config) {
function validate(_ref, cb) {
let {
value,
path = '',
label,
options,
originalValue,
sync
} = _ref,
rest = _objectWithoutPropertiesLoose(_ref, ["value", "path", "label", "options", "originalValue", "sync"]);
const {
name,
test,
params,
message
} = config;
let {
parent,
context
} = options;
function resolve(item) {
return Ref.isRef(item) ? item.getValue(value, parent, context) : item;
}
function createError(overrides = {}) {
const nextParams = mapValues(_extends({
value,
originalValue,
label,
path: overrides.path || path
}, params, overrides.params), resolve);
const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name);
error.params = nextParams;
return error;
}
let ctx = _extends({
path,
parent,
type: name,
createError,
resolve,
options,
originalValue
}, rest);
if (!sync) {
try {
Promise.resolve(test.call(ctx, value, ctx)).then(validOrError => {
if (ValidationError.isError(validOrError)) cb(validOrError);else if (!validOrError) cb(createError());else cb(null, validOrError);
});
} catch (err) {
cb(err);
}
return;
}
let result;
try {
var _ref2;
result = test.call(ctx, value, ctx);
if (typeof ((_ref2 = result) == null ? void 0 : _ref2.then) === 'function') {
throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
}
} catch (err) {
cb(err);
return;
}
if (ValidationError.isError(result)) cb(result);else if (!result) cb(createError());else cb(null, result);
}
validate.OPTIONS = config;
return validate;
}

2
server/node_modules/yup/es/util/isAbsent.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const _default: (value: any) => value is null | undefined;
export default _default;

1
server/node_modules/yup/es/util/isAbsent.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export default (value => value == null);

3
server/node_modules/yup/es/util/isSchema.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import type { SchemaLike } from '../types';
declare const _default: (obj: any) => obj is SchemaLike;
export default _default;

1
server/node_modules/yup/es/util/isSchema.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export default (obj => obj && obj.__isYupSchema__);

1
server/node_modules/yup/es/util/isodate.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function parseIsoDate(date: any): number;

39
server/node_modules/yup/es/util/isodate.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/* eslint-disable */
/**
*
* Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
* NON-CONFORMANT EDITION.
* © 2011 Colin Snover <http://zetafleet.com>
* Released under MIT license.
*/
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
var isoReg = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
export default function parseIsoDate(date) {
var numericKeys = [1, 4, 5, 6, 7, 10, 11],
minutesOffset = 0,
timestamp,
struct;
if (struct = isoReg.exec(date)) {
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
for (var i = 0, k; k = numericKeys[i]; ++i) struct[k] = +struct[k] || 0; // allow undefined days and months
struct[2] = (+struct[2] || 1) - 1;
struct[3] = +struct[3] || 1; // allow arbitrary sub-second precision beyond milliseconds
struct[7] = struct[7] ? String(struct[7]).substr(0, 3) : 0; // timestamps without timezone identifiers should be considered local time
if ((struct[8] === undefined || struct[8] === '') && (struct[9] === undefined || struct[9] === '')) timestamp = +new Date(struct[1], struct[2], struct[3], struct[4], struct[5], struct[6], struct[7]);else {
if (struct[8] !== 'Z' && struct[9] !== undefined) {
minutesOffset = struct[10] * 60 + struct[11];
if (struct[9] === '+') minutesOffset = 0 - minutesOffset;
}
timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);
}
} else timestamp = Date.parse ? Date.parse(date) : NaN;
return timestamp;
}

1
server/node_modules/yup/es/util/printValue.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function printValue(value: any, quoteStrings?: boolean): any;

35
server/node_modules/yup/es/util/printValue.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
const toString = Object.prototype.toString;
const errorToString = Error.prototype.toString;
const regExpToString = RegExp.prototype.toString;
const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
function printNumber(val) {
if (val != +val) return 'NaN';
const isNegativeZero = val === 0 && 1 / val < 0;
return isNegativeZero ? '-0' : '' + val;
}
function printSimpleValue(val, quoteStrings = false) {
if (val == null || val === true || val === false) return '' + val;
const typeOf = typeof val;
if (typeOf === 'number') return printNumber(val);
if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
const tag = toString.call(val).slice(8, -1);
if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
if (tag === 'RegExp') return regExpToString.call(val);
return null;
}
export default function printValue(value, quoteStrings) {
let result = printSimpleValue(value, quoteStrings);
if (result !== null) return result;
return JSON.stringify(value, function (key, value) {
let result = printSimpleValue(this[key], quoteStrings);
if (result !== null) return result;
return value;
}, 2);
}

7
server/node_modules/yup/es/util/reach.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export declare function getIn(schema: any, path: string, value?: any, context?: any): {
parent: any;
parentPath: string;
schema: any;
};
declare const reach: (obj: {}, path: string, value?: any, context?: any) => any;
export default reach;

56
server/node_modules/yup/es/util/reach.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import { forEach } from 'property-expr';
let trim = part => part.substr(0, part.length - 1).substr(1);
export function getIn(schema, path, value, context = value) {
let parent, lastPart, lastPartDebug; // root path: ''
if (!path) return {
parent,
parentPath: path,
schema
};
forEach(path, (_part, isBracket, isArray) => {
let part = isBracket ? trim(_part) : _part;
schema = schema.resolve({
context,
parent,
value
});
if (schema.innerType) {
let idx = isArray ? parseInt(part, 10) : 0;
if (value && idx >= value.length) {
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
}
parent = value;
value = value && value[idx];
schema = schema.innerType;
} // sometimes the array index part of a path doesn't exist: "nested.arr.child"
// in these cases the current part is the next schema and should be processed
// in this iteration. For cases where the index signature is included this
// check will fail and we'll handle the `child` part on the next iteration like normal
if (!isArray) {
if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema._type}")`);
parent = value;
value = value && value[part];
schema = schema.fields[part];
}
lastPart = part;
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
});
return {
schema,
parent,
parentPath: lastPart
};
}
const reach = (obj, path, value, context) => getIn(obj, path, value, context).schema;
export default reach;

15
server/node_modules/yup/es/util/runTests.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import ValidationError from '../ValidationError';
import { TestOptions } from './createValidation';
import { Callback } from '../types';
export declare type RunTest = (opts: TestOptions, cb: Callback) => void;
export declare type TestRunOptions = {
endEarly?: boolean;
tests: RunTest[];
args?: TestOptions;
errors?: ValidationError[];
sort?: (a: ValidationError, b: ValidationError) => number;
path?: string;
value: any;
sync?: boolean;
};
export default function runTests(options: TestRunOptions, cb: Callback): void;

62
server/node_modules/yup/es/util/runTests.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import ValidationError from '../ValidationError';
const once = cb => {
let fired = false;
return (...args) => {
if (fired) return;
fired = true;
cb(...args);
};
};
export default function runTests(options, cb) {
let {
endEarly,
tests,
args,
value,
errors,
sort,
path
} = options;
let callback = once(cb);
let count = tests.length;
const nestedErrors = [];
errors = errors ? errors : [];
if (!count) return errors.length ? callback(new ValidationError(errors, value, path)) : callback(null, value);
for (let i = 0; i < tests.length; i++) {
const test = tests[i];
test(args, function finishTestRun(err) {
if (err) {
// always return early for non validation errors
if (!ValidationError.isError(err)) {
return callback(err, value);
}
if (endEarly) {
err.value = value;
return callback(err, value);
}
nestedErrors.push(err);
}
if (--count <= 0) {
if (nestedErrors.length) {
if (sort) nestedErrors.sort(sort); //show parent errors after the nested ones: name.first, name
if (errors.length) nestedErrors.push(...errors);
errors = nestedErrors;
}
if (errors.length) {
callback(new ValidationError(errors, value, path), value);
return;
}
callback(null, value);
}
});
}
}

2
server/node_modules/yup/es/util/sortByKeyOrder.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import ValidationError from '../ValidationError';
export default function sortByKeyOrder(keys: string[]): (a: ValidationError, b: ValidationError) => number;

18
server/node_modules/yup/es/util/sortByKeyOrder.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
function findIndex(arr, err) {
let idx = Infinity;
arr.some((key, ii) => {
var _err$path;
if (((_err$path = err.path) == null ? void 0 : _err$path.indexOf(key)) !== -1) {
idx = ii;
return true;
}
});
return idx;
}
export default function sortByKeyOrder(keys) {
return (a, b) => {
return findIndex(keys, a) - findIndex(keys, b);
};
}

2
server/node_modules/yup/es/util/sortFields.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { ObjectShape } from '../object';
export default function sortFields(fields: ObjectShape, excludes?: readonly string[]): string[];

24
server/node_modules/yup/es/util/sortFields.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import has from 'lodash/has'; // @ts-expect-error
import toposort from 'toposort';
import { split } from 'property-expr';
import Ref from '../Reference';
import isSchema from './isSchema';
export default function sortFields(fields, excludes = []) {
let edges = [];
let nodes = [];
function addNode(depPath, key) {
var node = split(depPath)[0];
if (!~nodes.indexOf(node)) nodes.push(node);
if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
}
for (const key in fields) if (has(fields, key)) {
let value = fields[key];
if (!~nodes.indexOf(key)) nodes.push(key);
if (Ref.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
}
return toposort.array(nodes, edges).reverse();
}

1
server/node_modules/yup/es/util/toArray.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function toArray<T>(value?: null | T | T[]): T[];

3
server/node_modules/yup/es/util/toArray.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function toArray(value) {
return value == null ? [] : [].concat(value);
}

9
server/node_modules/yup/es/util/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export declare type Defined<T> = T extends undefined ? never : T;
export declare type TypedSchema = {
__inputType: any;
__outputType: any;
};
export declare type TypeOf<TSchema extends TypedSchema> = TSchema['__inputType'];
export declare type Asserts<TSchema extends TypedSchema> = TSchema['__outputType'];
export declare type Thunk<T> = T | (() => T);
export declare type If<T, Y, N> = T extends undefined ? Y : N;

0
server/node_modules/yup/es/util/types.js generated vendored Normal file
View File