build revisions and layout updates for toast
This commit is contained in:
parent
b341a3675e
commit
39235193e6
1116 changed files with 130517 additions and 12 deletions
17
node_modules/zod/src/v3/helpers/enumUtil.ts
generated
vendored
Normal file
17
node_modules/zod/src/v3/helpers/enumUtil.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export namespace enumUtil {
|
||||
type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (
|
||||
k: infer Intersection
|
||||
) => void
|
||||
? Intersection
|
||||
: never;
|
||||
|
||||
type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
|
||||
|
||||
type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never]
|
||||
? Tuple
|
||||
: UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
|
||||
|
||||
type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
|
||||
|
||||
export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
|
||||
}
|
||||
8
node_modules/zod/src/v3/helpers/errorUtil.ts
generated
vendored
Normal file
8
node_modules/zod/src/v3/helpers/errorUtil.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export namespace errorUtil {
|
||||
export type ErrMessage = string | { message?: string | undefined };
|
||||
export const errToObj = (message?: ErrMessage): { message?: string | undefined } =>
|
||||
typeof message === "string" ? { message } : message || {};
|
||||
// biome-ignore lint:
|
||||
export const toString = (message?: ErrMessage): string | undefined =>
|
||||
typeof message === "string" ? message : message?.message;
|
||||
}
|
||||
176
node_modules/zod/src/v3/helpers/parseUtil.ts
generated
vendored
Normal file
176
node_modules/zod/src/v3/helpers/parseUtil.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.js";
|
||||
import { getErrorMap } from "../errors.js";
|
||||
import defaultErrorMap from "../locales/en.js";
|
||||
import type { ZodParsedType } from "./util.js";
|
||||
|
||||
export const makeIssue = (params: {
|
||||
data: any;
|
||||
path: (string | number)[];
|
||||
errorMaps: ZodErrorMap[];
|
||||
issueData: IssueData;
|
||||
}): ZodIssue => {
|
||||
const { data, path, errorMaps, issueData } = params;
|
||||
const fullPath = [...path, ...(issueData.path || [])];
|
||||
const fullIssue = {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
};
|
||||
|
||||
if (issueData.message !== undefined) {
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: issueData.message,
|
||||
};
|
||||
}
|
||||
|
||||
let errorMessage = "";
|
||||
const maps = errorMaps
|
||||
.filter((m) => !!m)
|
||||
.slice()
|
||||
.reverse();
|
||||
for (const map of maps) {
|
||||
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
||||
}
|
||||
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: errorMessage,
|
||||
};
|
||||
};
|
||||
|
||||
export type ParseParams = {
|
||||
path: (string | number)[];
|
||||
errorMap: ZodErrorMap;
|
||||
async: boolean;
|
||||
};
|
||||
|
||||
export type ParsePathComponent = string | number;
|
||||
export type ParsePath = ParsePathComponent[];
|
||||
export const EMPTY_PATH: ParsePath = [];
|
||||
|
||||
export interface ParseContext {
|
||||
readonly common: {
|
||||
readonly issues: ZodIssue[];
|
||||
readonly contextualErrorMap?: ZodErrorMap | undefined;
|
||||
readonly async: boolean;
|
||||
};
|
||||
readonly path: ParsePath;
|
||||
readonly schemaErrorMap?: ZodErrorMap | undefined;
|
||||
readonly parent: ParseContext | null;
|
||||
readonly data: any;
|
||||
readonly parsedType: ZodParsedType;
|
||||
}
|
||||
|
||||
export type ParseInput = {
|
||||
data: any;
|
||||
path: (string | number)[];
|
||||
parent: ParseContext;
|
||||
};
|
||||
|
||||
export function addIssueToContext(ctx: ParseContext, issueData: IssueData): void {
|
||||
const overrideMap = getErrorMap();
|
||||
const issue = makeIssue({
|
||||
issueData: issueData,
|
||||
data: ctx.data,
|
||||
path: ctx.path,
|
||||
errorMaps: [
|
||||
ctx.common.contextualErrorMap, // contextual error map is first priority
|
||||
ctx.schemaErrorMap, // then schema-bound map if available
|
||||
overrideMap, // then global override map
|
||||
overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map
|
||||
].filter((x) => !!x),
|
||||
});
|
||||
ctx.common.issues.push(issue);
|
||||
}
|
||||
|
||||
export type ObjectPair = {
|
||||
key: SyncParseReturnType<any>;
|
||||
value: SyncParseReturnType<any>;
|
||||
};
|
||||
export class ParseStatus {
|
||||
value: "aborted" | "dirty" | "valid" = "valid";
|
||||
dirty(): void {
|
||||
if (this.value === "valid") this.value = "dirty";
|
||||
}
|
||||
abort(): void {
|
||||
if (this.value !== "aborted") this.value = "aborted";
|
||||
}
|
||||
|
||||
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType {
|
||||
const arrayValue: any[] = [];
|
||||
for (const s of results) {
|
||||
if (s.status === "aborted") return INVALID;
|
||||
if (s.status === "dirty") status.dirty();
|
||||
arrayValue.push(s.value);
|
||||
}
|
||||
|
||||
return { status: status.value, value: arrayValue };
|
||||
}
|
||||
|
||||
static async mergeObjectAsync(
|
||||
status: ParseStatus,
|
||||
pairs: { key: ParseReturnType<any>; value: ParseReturnType<any> }[]
|
||||
): Promise<SyncParseReturnType<any>> {
|
||||
const syncPairs: ObjectPair[] = [];
|
||||
for (const pair of pairs) {
|
||||
const key = await pair.key;
|
||||
const value = await pair.value;
|
||||
syncPairs.push({
|
||||
key,
|
||||
value,
|
||||
});
|
||||
}
|
||||
return ParseStatus.mergeObjectSync(status, syncPairs);
|
||||
}
|
||||
|
||||
static mergeObjectSync(
|
||||
status: ParseStatus,
|
||||
pairs: {
|
||||
key: SyncParseReturnType<any>;
|
||||
value: SyncParseReturnType<any>;
|
||||
alwaysSet?: boolean;
|
||||
}[]
|
||||
): SyncParseReturnType {
|
||||
const finalObject: any = {};
|
||||
for (const pair of pairs) {
|
||||
const { key, value } = pair;
|
||||
if (key.status === "aborted") return INVALID;
|
||||
if (value.status === "aborted") return INVALID;
|
||||
if (key.status === "dirty") status.dirty();
|
||||
if (value.status === "dirty") status.dirty();
|
||||
|
||||
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
||||
finalObject[key.value] = value.value;
|
||||
}
|
||||
}
|
||||
|
||||
return { status: status.value, value: finalObject };
|
||||
}
|
||||
}
|
||||
export interface ParseResult {
|
||||
status: "aborted" | "dirty" | "valid";
|
||||
data: any;
|
||||
}
|
||||
|
||||
export type INVALID = { status: "aborted" };
|
||||
export const INVALID: INVALID = Object.freeze({
|
||||
status: "aborted",
|
||||
});
|
||||
|
||||
export type DIRTY<T> = { status: "dirty"; value: T };
|
||||
export const DIRTY = <T>(value: T): DIRTY<T> => ({ status: "dirty", value });
|
||||
|
||||
export type OK<T> = { status: "valid"; value: T };
|
||||
export const OK = <T>(value: T): OK<T> => ({ status: "valid", value });
|
||||
|
||||
export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
||||
export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
|
||||
export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
|
||||
|
||||
export const isAborted = (x: ParseReturnType<any>): x is INVALID => (x as any).status === "aborted";
|
||||
export const isDirty = <T>(x: ParseReturnType<T>): x is OK<T> | DIRTY<T> => (x as any).status === "dirty";
|
||||
export const isValid = <T>(x: ParseReturnType<T>): x is OK<T> => (x as any).status === "valid";
|
||||
export const isAsync = <T>(x: ParseReturnType<T>): x is AsyncParseReturnType<T> =>
|
||||
typeof Promise !== "undefined" && x instanceof Promise;
|
||||
34
node_modules/zod/src/v3/helpers/partialUtil.ts
generated
vendored
Normal file
34
node_modules/zod/src/v3/helpers/partialUtil.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import type {
|
||||
ZodArray,
|
||||
ZodNullable,
|
||||
ZodObject,
|
||||
ZodOptional,
|
||||
ZodRawShape,
|
||||
ZodTuple,
|
||||
ZodTupleItems,
|
||||
ZodTypeAny,
|
||||
} from "../types.js";
|
||||
|
||||
export namespace partialUtil {
|
||||
export type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape>
|
||||
? ZodObject<
|
||||
{ [k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>> },
|
||||
T["_def"]["unknownKeys"],
|
||||
T["_def"]["catchall"]
|
||||
>
|
||||
: T extends ZodArray<infer Type, infer Card>
|
||||
? ZodArray<DeepPartial<Type>, Card>
|
||||
: T extends ZodOptional<infer Type>
|
||||
? ZodOptional<DeepPartial<Type>>
|
||||
: T extends ZodNullable<infer Type>
|
||||
? ZodNullable<DeepPartial<Type>>
|
||||
: T extends ZodTuple<infer Items>
|
||||
? {
|
||||
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
||||
} extends infer PI
|
||||
? PI extends ZodTupleItems
|
||||
? ZodTuple<PI>
|
||||
: never
|
||||
: never
|
||||
: T;
|
||||
}
|
||||
2
node_modules/zod/src/v3/helpers/typeAliases.ts
generated
vendored
Normal file
2
node_modules/zod/src/v3/helpers/typeAliases.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
||||
export type Scalars = Primitive | Primitive[];
|
||||
224
node_modules/zod/src/v3/helpers/util.ts
generated
vendored
Normal file
224
node_modules/zod/src/v3/helpers/util.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
export namespace util {
|
||||
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
||||
|
||||
export type isAny<T> = 0 extends 1 & T ? true : false;
|
||||
export const assertEqual = <A, B>(_: AssertEqual<A, B>): void => {};
|
||||
export function assertIs<T>(_arg: T): void {}
|
||||
export function assertNever(_x: never): never {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
||||
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
||||
export type InexactPartial<T> = { [k in keyof T]?: T[k] | undefined };
|
||||
export const arrayToEnum = <T extends string, U extends [T, ...T[]]>(items: U): { [k in U[number]]: k } => {
|
||||
const obj: any = {};
|
||||
for (const item of items) {
|
||||
obj[item] = item;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
export const getValidEnumValues = (obj: any): any[] => {
|
||||
const validKeys = objectKeys(obj).filter((k: any) => typeof obj[obj[k]] !== "number");
|
||||
const filtered: any = {};
|
||||
for (const k of validKeys) {
|
||||
filtered[k] = obj[k];
|
||||
}
|
||||
return objectValues(filtered);
|
||||
};
|
||||
|
||||
export const objectValues = (obj: any): any[] => {
|
||||
return objectKeys(obj).map(function (e) {
|
||||
return obj[e];
|
||||
});
|
||||
};
|
||||
|
||||
export const objectKeys: ObjectConstructor["keys"] =
|
||||
typeof Object.keys === "function" // eslint-disable-line ban/ban
|
||||
? (obj: any) => Object.keys(obj) // eslint-disable-line ban/ban
|
||||
: (object: any) => {
|
||||
const keys = [];
|
||||
for (const key in object) {
|
||||
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
export const find = <T>(arr: T[], checker: (arg: T) => any): T | undefined => {
|
||||
for (const item of arr) {
|
||||
if (checker(item)) return item;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export type identity<T> = objectUtil.identity<T>;
|
||||
export type flatten<T> = objectUtil.flatten<T>;
|
||||
|
||||
export type noUndefined<T> = T extends undefined ? never : T;
|
||||
|
||||
export const isInteger: NumberConstructor["isInteger"] =
|
||||
typeof Number.isInteger === "function"
|
||||
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
||||
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
||||
|
||||
export function joinValues<T extends any[]>(array: T, separator = " | "): string {
|
||||
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
||||
}
|
||||
|
||||
export const jsonStringifyReplacer = (_: string, value: any): any => {
|
||||
if (typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export namespace objectUtil {
|
||||
export type MergeShapes<U, V> =
|
||||
// fast path when there is no keys overlap
|
||||
keyof U & keyof V extends never
|
||||
? U & V
|
||||
: {
|
||||
[k in Exclude<keyof U, keyof V>]: U[k];
|
||||
} & V;
|
||||
|
||||
type optionalKeys<T extends object> = {
|
||||
[k in keyof T]: undefined extends T[k] ? k : never;
|
||||
}[keyof T];
|
||||
type requiredKeys<T extends object> = {
|
||||
[k in keyof T]: undefined extends T[k] ? never : k;
|
||||
}[keyof T];
|
||||
export type addQuestionMarks<T extends object, _O = any> = {
|
||||
[K in requiredKeys<T>]: T[K];
|
||||
} & {
|
||||
[K in optionalKeys<T>]?: T[K];
|
||||
} & { [k in keyof T]?: unknown };
|
||||
|
||||
export type identity<T> = T;
|
||||
export type flatten<T> = identity<{ [k in keyof T]: T[k] }>;
|
||||
|
||||
export type noNeverKeys<T> = {
|
||||
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
||||
}[keyof T];
|
||||
|
||||
export type noNever<T> = identity<{
|
||||
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
||||
}>;
|
||||
|
||||
export const mergeShapes = <U, T>(first: U, second: T): T & U => {
|
||||
return {
|
||||
...first,
|
||||
...second, // second overwrites first
|
||||
};
|
||||
};
|
||||
|
||||
export type extendShape<A extends object, B extends object> = keyof A & keyof B extends never // fast path when there is no keys overlap
|
||||
? A & B
|
||||
: {
|
||||
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
||||
} & {
|
||||
[K in keyof B]: B[K];
|
||||
};
|
||||
}
|
||||
|
||||
export const ZodParsedType: {
|
||||
string: "string";
|
||||
nan: "nan";
|
||||
number: "number";
|
||||
integer: "integer";
|
||||
float: "float";
|
||||
boolean: "boolean";
|
||||
date: "date";
|
||||
bigint: "bigint";
|
||||
symbol: "symbol";
|
||||
function: "function";
|
||||
undefined: "undefined";
|
||||
null: "null";
|
||||
array: "array";
|
||||
object: "object";
|
||||
unknown: "unknown";
|
||||
promise: "promise";
|
||||
void: "void";
|
||||
never: "never";
|
||||
map: "map";
|
||||
set: "set";
|
||||
} = util.arrayToEnum([
|
||||
"string",
|
||||
"nan",
|
||||
"number",
|
||||
"integer",
|
||||
"float",
|
||||
"boolean",
|
||||
"date",
|
||||
"bigint",
|
||||
"symbol",
|
||||
"function",
|
||||
"undefined",
|
||||
"null",
|
||||
"array",
|
||||
"object",
|
||||
"unknown",
|
||||
"promise",
|
||||
"void",
|
||||
"never",
|
||||
"map",
|
||||
"set",
|
||||
]);
|
||||
|
||||
export type ZodParsedType = keyof typeof ZodParsedType;
|
||||
|
||||
export const getParsedType = (data: any): ZodParsedType => {
|
||||
const t = typeof data;
|
||||
|
||||
switch (t) {
|
||||
case "undefined":
|
||||
return ZodParsedType.undefined;
|
||||
|
||||
case "string":
|
||||
return ZodParsedType.string;
|
||||
|
||||
case "number":
|
||||
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
||||
|
||||
case "boolean":
|
||||
return ZodParsedType.boolean;
|
||||
|
||||
case "function":
|
||||
return ZodParsedType.function;
|
||||
|
||||
case "bigint":
|
||||
return ZodParsedType.bigint;
|
||||
|
||||
case "symbol":
|
||||
return ZodParsedType.symbol;
|
||||
|
||||
case "object":
|
||||
if (Array.isArray(data)) {
|
||||
return ZodParsedType.array;
|
||||
}
|
||||
if (data === null) {
|
||||
return ZodParsedType.null;
|
||||
}
|
||||
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
||||
return ZodParsedType.promise;
|
||||
}
|
||||
if (typeof Map !== "undefined" && data instanceof Map) {
|
||||
return ZodParsedType.map;
|
||||
}
|
||||
if (typeof Set !== "undefined" && data instanceof Set) {
|
||||
return ZodParsedType.set;
|
||||
}
|
||||
if (typeof Date !== "undefined" && data instanceof Date) {
|
||||
return ZodParsedType.date;
|
||||
}
|
||||
return ZodParsedType.object;
|
||||
|
||||
default:
|
||||
return ZodParsedType.unknown;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue