WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABILITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference lib="es2015" />
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
/// <reference lib="scripthost" />
|
||||
@@ -0,0 +1,24 @@
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
|
||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
||||
return (size = defaultSize) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i-- > 0) {
|
||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
let nanoid = (size = 21) => {
|
||||
let id = ''
|
||||
let i = size | 0
|
||||
while (i-- > 0) {
|
||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
module.exports = { nanoid, customAlphabet }
|
||||
@@ -0,0 +1,194 @@
|
||||
//#region src/filter/composable-filters.d.ts
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type PluginModuleType = 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'text' | 'base64' | 'dataurl' | 'binary' | 'empty' | (string & {});
|
||||
type FilterExpressionKind = FilterExpression['kind'];
|
||||
type FilterExpression = And | Or | Not | Id | ImporterId | ModuleType | Code | Query;
|
||||
type TopLevelFilterExpression = Include | Exclude;
|
||||
declare class And {
|
||||
kind: 'and';
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Or {
|
||||
kind: 'or';
|
||||
args: FilterExpression[];
|
||||
constructor(...args: FilterExpression[]);
|
||||
}
|
||||
declare class Not {
|
||||
kind: 'not';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
interface QueryFilterObject {
|
||||
[key: string]: StringOrRegExp | boolean;
|
||||
}
|
||||
interface IdParams {
|
||||
cleanUrl?: boolean;
|
||||
}
|
||||
declare class Id {
|
||||
kind: 'id';
|
||||
pattern: StringOrRegExp;
|
||||
params: IdParams;
|
||||
constructor(pattern: StringOrRegExp, params?: IdParams);
|
||||
}
|
||||
declare class ImporterId {
|
||||
kind: 'importerId';
|
||||
pattern: StringOrRegExp;
|
||||
params: IdParams;
|
||||
constructor(pattern: StringOrRegExp, params?: IdParams);
|
||||
}
|
||||
declare class ModuleType {
|
||||
kind: 'moduleType';
|
||||
pattern: PluginModuleType;
|
||||
constructor(pattern: PluginModuleType);
|
||||
}
|
||||
declare class Code {
|
||||
kind: 'code';
|
||||
pattern: StringOrRegExp;
|
||||
constructor(expr: StringOrRegExp);
|
||||
}
|
||||
declare class Query {
|
||||
kind: 'query';
|
||||
key: string;
|
||||
pattern: StringOrRegExp | boolean;
|
||||
constructor(key: string, pattern: StringOrRegExp | boolean);
|
||||
}
|
||||
declare class Include {
|
||||
kind: 'include';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare class Exclude {
|
||||
kind: 'exclude';
|
||||
expr: FilterExpression;
|
||||
constructor(expr: FilterExpression);
|
||||
}
|
||||
declare function and(...args: FilterExpression[]): And;
|
||||
declare function or(...args: FilterExpression[]): Or;
|
||||
declare function not(expr: FilterExpression): Not;
|
||||
declare function id(pattern: StringOrRegExp, params?: IdParams): Id;
|
||||
declare function importerId(pattern: StringOrRegExp, params?: IdParams): ImporterId;
|
||||
declare function moduleType(pattern: PluginModuleType): ModuleType;
|
||||
declare function code(pattern: StringOrRegExp): Code;
|
||||
declare function query(key: string, pattern: StringOrRegExp | boolean): Query;
|
||||
declare function include(expr: FilterExpression): Include;
|
||||
declare function exclude(expr: FilterExpression): Exclude;
|
||||
/**
|
||||
* convert a queryObject to FilterExpression like
|
||||
* ```js
|
||||
* and(query(k1, v1), query(k2, v2))
|
||||
* ```
|
||||
* @param queryFilterObject The query filter object needs to be matched.
|
||||
* @returns a `And` FilterExpression
|
||||
*/
|
||||
declare function queries(queryFilter: QueryFilterObject): And;
|
||||
declare function interpreter(exprs: TopLevelFilterExpression | TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string): boolean;
|
||||
interface InterpreterCtx {
|
||||
urlSearchParamsCache?: URLSearchParams;
|
||||
}
|
||||
declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
|
||||
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
|
||||
//#endregion
|
||||
//#region src/filter/filter-vite-plugins.d.ts
|
||||
/**
|
||||
* Filters out Vite plugins that have `apply: 'serve'` set.
|
||||
*
|
||||
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
||||
* are intended only for Vite's dev server and should be excluded from the build process.
|
||||
*
|
||||
* @param plugins - Array of plugins (can include nested arrays)
|
||||
* @returns Filtered array with serve-only plugins removed
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { defineConfig } from 'rolldown';
|
||||
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
||||
* import viteReact from '@vitejs/plugin-react';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* plugins: filterVitePlugins([
|
||||
* viteReact(),
|
||||
* {
|
||||
* name: 'dev-only',
|
||||
* apply: 'serve', // This will be filtered out
|
||||
* // ...
|
||||
* }
|
||||
* ])
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
|
||||
//#endregion
|
||||
//#region src/filter/simple-filters.d.ts
|
||||
/**
|
||||
* Constructs a RegExp that matches the exact string specified.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { exactRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: exactRegex('foo') },
|
||||
* handler(id) {} // will only be called for `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function exactRegex(str: string, flags?: string): RegExp;
|
||||
/**
|
||||
* Constructs a RegExp that matches a value that has the specified prefix.
|
||||
*
|
||||
* This is useful for plugin hook filters.
|
||||
*
|
||||
* @param str the string to match.
|
||||
* @param flags flags for the RegExp.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { prefixRegex } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* resolveId: {
|
||||
* filter: { id: prefixRegex('foo') },
|
||||
* handler(id) {} // will only be called for IDs starting with `foo`
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function prefixRegex(str: string, flags?: string): RegExp;
|
||||
type WidenString<T> = T extends string ? string : T;
|
||||
/**
|
||||
* Converts a id filter to match with an id with a query.
|
||||
*
|
||||
* @param input the id filters to convert.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
|
||||
* const plugin = {
|
||||
* name: 'plugin',
|
||||
* transform: {
|
||||
* filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
|
||||
* // The handler will be called for IDs like:
|
||||
* // - foo.js
|
||||
* // - foo.js?foo
|
||||
* // - foo.txt?foo.js
|
||||
* // - foo.ts
|
||||
* // - foo.ts?foo
|
||||
* // - foo.txt?foo.ts
|
||||
* handler(code, id) {}
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
|
||||
declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
|
||||
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
|
||||
//#endregion
|
||||
export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pasta.d.ts","sourceRoot":"","sources":["../src/pasta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,IAAI,EAAE,EAAE,KAAK,IAAI,EAAE,EAAE,MAAM,WAAW,CAAC;AACtD,kBAAkB;AAClB,eAAO,MAAM,MAAM,EAAE,OAAO,EAAO,CAAC;AACpC,kBAAkB;AAClB,eAAO,MAAM,KAAK,EAAE,OAAO,EAAO,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
var OverloadYield = require("./OverloadYield.js");
|
||||
function _awaitAsyncGenerator(e) {
|
||||
return new OverloadYield(e, 0);
|
||||
}
|
||||
module.exports = _awaitAsyncGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ast.generated.js","sourceRoot":"","sources":["../../src/ast/ast.generated.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAI9D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { NonSharedArrayBuffer } from './types.js';
|
||||
declare function parse(uuid: string): NonSharedArrayBuffer;
|
||||
export default parse;
|
||||
@@ -0,0 +1,200 @@
|
||||
import type * as checks from "./checks.cjs";
|
||||
import type { $ZodConfig } from "./core.cjs";
|
||||
import type * as errors from "./errors.cjs";
|
||||
import type * as schemas from "./schemas.cjs";
|
||||
export type JSONType = string | number | boolean | null | JSONType[] | {
|
||||
[key: string]: JSONType;
|
||||
};
|
||||
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
||||
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
|
||||
export type HashEncoding = "hex" | "base64" | "base64url";
|
||||
export type HashFormat = `${HashAlgorithm}_${HashEncoding}`;
|
||||
export type IPVersion = "v4" | "v6";
|
||||
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
||||
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
||||
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
||||
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
||||
export type AssertExtends<T, U> = T extends U ? T : never;
|
||||
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
||||
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> & InexactPartial<Pick<T, K>>;
|
||||
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
||||
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
||||
export type NoUndefined<T> = T extends undefined ? never : T;
|
||||
export type Whatever = {} | undefined | null;
|
||||
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
||||
[k: string]: unknown;
|
||||
};
|
||||
export type Mask<Keys extends PropertyKey> = {
|
||||
[K in Keys]?: true;
|
||||
};
|
||||
export type Writeable<T> = {
|
||||
-readonly [P in keyof T]: T[P];
|
||||
} & {};
|
||||
export type InexactPartial<T> = {
|
||||
[P in keyof T]?: T[P] | undefined;
|
||||
};
|
||||
export type EmptyObject = Record<string, never>;
|
||||
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
||||
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
||||
export type SomeObject = Record<PropertyKey, any>;
|
||||
export type Identity<T> = T;
|
||||
export type Flatten<T> = Identity<{
|
||||
[k in keyof T]: T[k];
|
||||
}>;
|
||||
export type Mapped<T> = {
|
||||
[k in keyof T]: T[k];
|
||||
};
|
||||
export type Prettify<T> = {
|
||||
[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 type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
||||
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
||||
} & {
|
||||
[K in keyof B]: B[K];
|
||||
}>;
|
||||
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
||||
export type AnyFunc = (...args: any[]) => any;
|
||||
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
||||
export type MaybeAsync<T> = T | Promise<T>;
|
||||
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
||||
export type OmitIndexSignature<T> = {
|
||||
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
||||
};
|
||||
export type ExtractIndexSignature<T> = {
|
||||
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
||||
};
|
||||
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
||||
export type SchemaClass<T extends schemas.SomeType> = {
|
||||
new (def: T["_zod"]["def"]): T;
|
||||
};
|
||||
export type EnumValue = string | number;
|
||||
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
||||
export type ToEnum<T extends EnumValue> = Flatten<{
|
||||
[k in T]: k;
|
||||
}>;
|
||||
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
||||
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
||||
export type Literal = string | number | bigint | boolean | null | undefined;
|
||||
export type LiteralArray = Array<Literal>;
|
||||
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
||||
export type PrimitiveArray = Array<Primitive>;
|
||||
export type HasSize = {
|
||||
size: number;
|
||||
};
|
||||
export type HasLength = {
|
||||
length: number;
|
||||
};
|
||||
export type Numeric = number | bigint | Date;
|
||||
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
||||
export type SafeParseSuccess<T> = {
|
||||
success: true;
|
||||
data: T;
|
||||
error?: never;
|
||||
};
|
||||
export type SafeParseError<T> = {
|
||||
success: false;
|
||||
data?: never;
|
||||
error: errors.$ZodError<T>;
|
||||
};
|
||||
export type PropValues = Record<string, Set<Primitive>>;
|
||||
export type PrimitiveSet = Set<Primitive>;
|
||||
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
||||
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
||||
export declare function assertIs<T>(_arg: T): void;
|
||||
export declare function assertNever(_x: never): never;
|
||||
export declare function assert<T>(_: any): asserts _ is T;
|
||||
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
||||
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
||||
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
||||
export declare function cached<T>(getter: () => T): {
|
||||
value: T;
|
||||
};
|
||||
export declare function nullish(input: any): boolean;
|
||||
export declare function cleanRegex(source: string): string;
|
||||
export declare function floatSafeRemainder(val: number, step: number): number;
|
||||
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
||||
export declare function objectClone(obj: object): any;
|
||||
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
||||
export declare function mergeDefs(...defs: Record<string, any>[]): any;
|
||||
export declare function cloneDef(schema: schemas.$ZodType): any;
|
||||
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
||||
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
||||
[k in keyof T]: Awaited<T[k]>;
|
||||
}>;
|
||||
export declare function randomString(length?: number): string;
|
||||
export declare function esc(str: string): string;
|
||||
export declare function slugify(input: string): string;
|
||||
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
||||
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
||||
export declare const allowsEval: {
|
||||
value: boolean;
|
||||
};
|
||||
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
||||
export declare function shallowClone(o: any): any;
|
||||
export declare function numKeys(data: any): number;
|
||||
export declare const getParsedType: (data: any) => ParsedTypes;
|
||||
export declare const propertyKeyTypes: Set<string>;
|
||||
export declare const primitiveTypes: Set<string>;
|
||||
export declare function escapeRegex(str: string): string;
|
||||
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
||||
parent: boolean;
|
||||
}): T;
|
||||
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
||||
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
||||
[k in keyof Omit<T, "error" | "message">]: T[k];
|
||||
} & ("error" extends keyof T ? {
|
||||
error?: Exclude<T["error"], string>;
|
||||
} : unknown)> : never;
|
||||
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
||||
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
||||
export declare function stringifyPrimitive(value: any): string;
|
||||
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
||||
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
||||
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
||||
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
||||
};
|
||||
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
||||
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
||||
};
|
||||
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
||||
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
||||
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
||||
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
||||
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
||||
export declare function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
||||
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
||||
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
||||
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
||||
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
||||
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
||||
export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
||||
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
||||
export declare function unwrapMessage(message: string | {
|
||||
message: string;
|
||||
} | undefined | null): string | undefined;
|
||||
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
||||
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
||||
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
||||
export declare function parsedType(data: unknown): errors.$ZodInvalidTypeExpected;
|
||||
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
||||
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
||||
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
||||
export declare function base64ToUint8Array(base64: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
|
||||
export declare function base64urlToUint8Array(base64url: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToBase64url(bytes: Uint8Array): string;
|
||||
export declare function hexToUint8Array(hex: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
||||
export declare abstract class Class {
|
||||
constructor(..._args: any[]);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAuBA,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,MAAM,CAA6B;IAE3C,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAStB,KAAK,IAAI,MAAM;CAIhB;AAED,qBAAa,YAAY;IACvB,GAAG,SAAK;IACR,QAAgB,MAAM,CAAS;gBAEnB,MAAM,EAAE,MAAM;IAI1B,IAAI,IAAI,MAAM;IAId,IAAI,IAAI,MAAM;IAId,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAK9B"}
|
||||
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BufferReader = void 0;
|
||||
class BufferReader {
|
||||
constructor(offset = 0) {
|
||||
this.offset = offset;
|
||||
this.buffer = Buffer.allocUnsafe(0);
|
||||
// TODO(bmc): support non-utf8 encoding?
|
||||
this.encoding = 'utf-8';
|
||||
}
|
||||
setBuffer(offset, buffer) {
|
||||
this.offset = offset;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
int16() {
|
||||
const result = this.buffer.readInt16BE(this.offset);
|
||||
this.offset += 2;
|
||||
return result;
|
||||
}
|
||||
byte() {
|
||||
const result = this.buffer[this.offset];
|
||||
this.offset++;
|
||||
return result;
|
||||
}
|
||||
int32() {
|
||||
const result = this.buffer.readInt32BE(this.offset);
|
||||
this.offset += 4;
|
||||
return result;
|
||||
}
|
||||
uint32() {
|
||||
const result = this.buffer.readUInt32BE(this.offset);
|
||||
this.offset += 4;
|
||||
return result;
|
||||
}
|
||||
string(length) {
|
||||
const result = this.buffer.toString(this.encoding, this.offset, this.offset + length);
|
||||
this.offset += length;
|
||||
return result;
|
||||
}
|
||||
cstring() {
|
||||
const start = this.offset;
|
||||
let end = start;
|
||||
// eslint-disable-next-line no-empty
|
||||
while (this.buffer[end++]) { }
|
||||
this.offset = end;
|
||||
return this.buffer.toString(this.encoding, start, end - 1);
|
||||
}
|
||||
bytes(length) {
|
||||
const result = this.buffer.slice(this.offset, this.offset + length);
|
||||
this.offset += length;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.BufferReader = BufferReader;
|
||||
//# sourceMappingURL=buffer-reader.js.map
|
||||
@@ -0,0 +1,575 @@
|
||||
// import { $ZodType } from "./schemas.js";
|
||||
import * as core from "./core.js";
|
||||
import * as regexes from "./regexes.js";
|
||||
import * as util from "./util.js";
|
||||
export const $ZodCheck = /*@__PURE__*/ core.$constructor("$ZodCheck", (inst, def) => {
|
||||
var _a;
|
||||
inst._zod ?? (inst._zod = {});
|
||||
inst._zod.def = def;
|
||||
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
||||
});
|
||||
const numericOriginMap = {
|
||||
number: "number",
|
||||
bigint: "bigint",
|
||||
object: "date",
|
||||
};
|
||||
export const $ZodCheckLessThan = /*@__PURE__*/ core.$constructor("$ZodCheckLessThan", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const origin = numericOriginMap[typeof def.value];
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
||||
if (def.value < curr) {
|
||||
if (def.inclusive)
|
||||
bag.maximum = def.value;
|
||||
else
|
||||
bag.exclusiveMaximum = def.value;
|
||||
}
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
||||
return;
|
||||
}
|
||||
payload.issues.push({
|
||||
origin,
|
||||
code: "too_big",
|
||||
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
||||
input: payload.value,
|
||||
inclusive: def.inclusive,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGreaterThan", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const origin = numericOriginMap[typeof def.value];
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
||||
if (def.value > curr) {
|
||||
if (def.inclusive)
|
||||
bag.minimum = def.value;
|
||||
else
|
||||
bag.exclusiveMinimum = def.value;
|
||||
}
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
||||
return;
|
||||
}
|
||||
payload.issues.push({
|
||||
origin,
|
||||
code: "too_small",
|
||||
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
||||
input: payload.value,
|
||||
inclusive: def.inclusive,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMultipleOf =
|
||||
/*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
inst._zod.onattach.push((inst) => {
|
||||
var _a;
|
||||
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (typeof payload.value !== typeof def.value)
|
||||
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
||||
const isMultiple = typeof payload.value === "bigint"
|
||||
? payload.value % def.value === BigInt(0)
|
||||
: util.floatSafeRemainder(payload.value, def.value) === 0;
|
||||
if (isMultiple)
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: typeof payload.value,
|
||||
code: "not_multiple_of",
|
||||
divisor: def.value,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckNumberFormat = /*@__PURE__*/ core.$constructor("$ZodCheckNumberFormat", (inst, def) => {
|
||||
$ZodCheck.init(inst, def); // no format checks
|
||||
def.format = def.format || "float64";
|
||||
const isInt = def.format?.includes("int");
|
||||
const origin = isInt ? "int" : "number";
|
||||
const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.format = def.format;
|
||||
bag.minimum = minimum;
|
||||
bag.maximum = maximum;
|
||||
if (isInt)
|
||||
bag.pattern = regexes.integer;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
if (isInt) {
|
||||
if (!Number.isInteger(input)) {
|
||||
// invalid_format issue
|
||||
// payload.issues.push({
|
||||
// expected: def.format,
|
||||
// format: def.format,
|
||||
// code: "invalid_format",
|
||||
// input,
|
||||
// inst,
|
||||
// });
|
||||
// invalid_type issue
|
||||
payload.issues.push({
|
||||
expected: origin,
|
||||
format: def.format,
|
||||
code: "invalid_type",
|
||||
continue: false,
|
||||
input,
|
||||
inst,
|
||||
});
|
||||
return;
|
||||
// not_multiple_of issue
|
||||
// payload.issues.push({
|
||||
// code: "not_multiple_of",
|
||||
// origin: "number",
|
||||
// input,
|
||||
// inst,
|
||||
// divisor: 1,
|
||||
// });
|
||||
}
|
||||
if (!Number.isSafeInteger(input)) {
|
||||
if (input > 0) {
|
||||
// too_big
|
||||
payload.issues.push({
|
||||
input,
|
||||
code: "too_big",
|
||||
maximum: Number.MAX_SAFE_INTEGER,
|
||||
note: "Integers must be within the safe integer range.",
|
||||
inst,
|
||||
origin,
|
||||
inclusive: true,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
else {
|
||||
// too_small
|
||||
payload.issues.push({
|
||||
input,
|
||||
code: "too_small",
|
||||
minimum: Number.MIN_SAFE_INTEGER,
|
||||
note: "Integers must be within the safe integer range.",
|
||||
inst,
|
||||
origin,
|
||||
inclusive: true,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (input < minimum) {
|
||||
payload.issues.push({
|
||||
origin: "number",
|
||||
input,
|
||||
code: "too_small",
|
||||
minimum,
|
||||
inclusive: true,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
if (input > maximum) {
|
||||
payload.issues.push({
|
||||
origin: "number",
|
||||
input,
|
||||
code: "too_big",
|
||||
maximum,
|
||||
inclusive: true,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
export const $ZodCheckBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
||||
$ZodCheck.init(inst, def); // no format checks
|
||||
const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.format = def.format;
|
||||
bag.minimum = minimum;
|
||||
bag.maximum = maximum;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
if (input < minimum) {
|
||||
payload.issues.push({
|
||||
origin: "bigint",
|
||||
input,
|
||||
code: "too_small",
|
||||
minimum: minimum,
|
||||
inclusive: true,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
if (input > maximum) {
|
||||
payload.issues.push({
|
||||
origin: "bigint",
|
||||
input,
|
||||
code: "too_big",
|
||||
maximum,
|
||||
inclusive: true,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMaxSize = /*@__PURE__*/ core.$constructor("$ZodCheckMaxSize", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.size !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
||||
if (def.maximum < curr)
|
||||
inst._zod.bag.maximum = def.maximum;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const size = input.size;
|
||||
if (size <= def.maximum)
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: util.getSizableOrigin(input),
|
||||
code: "too_big",
|
||||
maximum: def.maximum,
|
||||
inclusive: true,
|
||||
input,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMinSize = /*@__PURE__*/ core.$constructor("$ZodCheckMinSize", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.size !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
||||
if (def.minimum > curr)
|
||||
inst._zod.bag.minimum = def.minimum;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const size = input.size;
|
||||
if (size >= def.minimum)
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: util.getSizableOrigin(input),
|
||||
code: "too_small",
|
||||
minimum: def.minimum,
|
||||
inclusive: true,
|
||||
input,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor("$ZodCheckSizeEquals", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.size !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.minimum = def.size;
|
||||
bag.maximum = def.size;
|
||||
bag.size = def.size;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const size = input.size;
|
||||
if (size === def.size)
|
||||
return;
|
||||
const tooBig = size > def.size;
|
||||
payload.issues.push({
|
||||
origin: util.getSizableOrigin(input),
|
||||
...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
|
||||
inclusive: true,
|
||||
exact: true,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor("$ZodCheckMaxLength", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.length !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
||||
if (def.maximum < curr)
|
||||
inst._zod.bag.maximum = def.maximum;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const length = input.length;
|
||||
if (length <= def.maximum)
|
||||
return;
|
||||
const origin = util.getLengthableOrigin(input);
|
||||
payload.issues.push({
|
||||
origin,
|
||||
code: "too_big",
|
||||
maximum: def.maximum,
|
||||
inclusive: true,
|
||||
input,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor("$ZodCheckMinLength", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.length !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
||||
if (def.minimum > curr)
|
||||
inst._zod.bag.minimum = def.minimum;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const length = input.length;
|
||||
if (length >= def.minimum)
|
||||
return;
|
||||
const origin = util.getLengthableOrigin(input);
|
||||
payload.issues.push({
|
||||
origin,
|
||||
code: "too_small",
|
||||
minimum: def.minimum,
|
||||
inclusive: true,
|
||||
input,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckLengthEquals", (inst, def) => {
|
||||
var _a;
|
||||
$ZodCheck.init(inst, def);
|
||||
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
||||
const val = payload.value;
|
||||
return !util.nullish(val) && val.length !== undefined;
|
||||
});
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.minimum = def.length;
|
||||
bag.maximum = def.length;
|
||||
bag.length = def.length;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
const input = payload.value;
|
||||
const length = input.length;
|
||||
if (length === def.length)
|
||||
return;
|
||||
const origin = util.getLengthableOrigin(input);
|
||||
const tooBig = length > def.length;
|
||||
payload.issues.push({
|
||||
origin,
|
||||
...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
|
||||
inclusive: true,
|
||||
exact: true,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckStringFormat = /*@__PURE__*/ core.$constructor("$ZodCheckStringFormat", (inst, def) => {
|
||||
var _a, _b;
|
||||
$ZodCheck.init(inst, def);
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.format = def.format;
|
||||
if (def.pattern) {
|
||||
bag.patterns ?? (bag.patterns = new Set());
|
||||
bag.patterns.add(def.pattern);
|
||||
}
|
||||
});
|
||||
if (def.pattern)
|
||||
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
||||
def.pattern.lastIndex = 0;
|
||||
if (def.pattern.test(payload.value))
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: "string",
|
||||
code: "invalid_format",
|
||||
format: def.format,
|
||||
input: payload.value,
|
||||
...(def.pattern ? { pattern: def.pattern.toString() } : {}),
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
});
|
||||
else
|
||||
(_b = inst._zod).check ?? (_b.check = () => { });
|
||||
});
|
||||
export const $ZodCheckRegex = /*@__PURE__*/ core.$constructor("$ZodCheckRegex", (inst, def) => {
|
||||
$ZodCheckStringFormat.init(inst, def);
|
||||
inst._zod.check = (payload) => {
|
||||
def.pattern.lastIndex = 0;
|
||||
if (def.pattern.test(payload.value))
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: "string",
|
||||
code: "invalid_format",
|
||||
format: "regex",
|
||||
input: payload.value,
|
||||
pattern: def.pattern.toString(),
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckLowerCase = /*@__PURE__*/ core.$constructor("$ZodCheckLowerCase", (inst, def) => {
|
||||
def.pattern ?? (def.pattern = regexes.lowercase);
|
||||
$ZodCheckStringFormat.init(inst, def);
|
||||
});
|
||||
export const $ZodCheckUpperCase = /*@__PURE__*/ core.$constructor("$ZodCheckUpperCase", (inst, def) => {
|
||||
def.pattern ?? (def.pattern = regexes.uppercase);
|
||||
$ZodCheckStringFormat.init(inst, def);
|
||||
});
|
||||
export const $ZodCheckIncludes = /*@__PURE__*/ core.$constructor("$ZodCheckIncludes", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const escapedRegex = util.escapeRegex(def.includes);
|
||||
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
||||
def.pattern = pattern;
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.patterns ?? (bag.patterns = new Set());
|
||||
bag.patterns.add(pattern);
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (payload.value.includes(def.includes, def.position))
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: "string",
|
||||
code: "invalid_format",
|
||||
format: "includes",
|
||||
includes: def.includes,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckStartsWith = /*@__PURE__*/ core.$constructor("$ZodCheckStartsWith", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
|
||||
def.pattern ?? (def.pattern = pattern);
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.patterns ?? (bag.patterns = new Set());
|
||||
bag.patterns.add(pattern);
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (payload.value.startsWith(def.prefix))
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: "string",
|
||||
code: "invalid_format",
|
||||
format: "starts_with",
|
||||
prefix: def.prefix,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckEndsWith = /*@__PURE__*/ core.$constructor("$ZodCheckEndsWith", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
|
||||
def.pattern ?? (def.pattern = pattern);
|
||||
inst._zod.onattach.push((inst) => {
|
||||
const bag = inst._zod.bag;
|
||||
bag.patterns ?? (bag.patterns = new Set());
|
||||
bag.patterns.add(pattern);
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (payload.value.endsWith(def.suffix))
|
||||
return;
|
||||
payload.issues.push({
|
||||
origin: "string",
|
||||
code: "invalid_format",
|
||||
format: "ends_with",
|
||||
suffix: def.suffix,
|
||||
input: payload.value,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
///////////////////////////////////
|
||||
///// $ZodCheckProperty /////
|
||||
///////////////////////////////////
|
||||
function handleCheckPropertyResult(result, payload, property) {
|
||||
if (result.issues.length) {
|
||||
payload.issues.push(...util.prefixIssues(property, result.issues));
|
||||
}
|
||||
}
|
||||
export const $ZodCheckProperty = /*@__PURE__*/ core.$constructor("$ZodCheckProperty", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
inst._zod.check = (payload) => {
|
||||
const result = def.schema._zod.run({
|
||||
value: payload.value[def.property],
|
||||
issues: [],
|
||||
}, {});
|
||||
if (result instanceof Promise) {
|
||||
return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
|
||||
}
|
||||
handleCheckPropertyResult(result, payload, def.property);
|
||||
return;
|
||||
};
|
||||
});
|
||||
export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
const mimeSet = new Set(def.mime);
|
||||
inst._zod.onattach.push((inst) => {
|
||||
inst._zod.bag.mime = def.mime;
|
||||
});
|
||||
inst._zod.check = (payload) => {
|
||||
if (mimeSet.has(payload.value.type))
|
||||
return;
|
||||
payload.issues.push({
|
||||
code: "invalid_value",
|
||||
values: def.mime,
|
||||
input: payload.value.type,
|
||||
inst,
|
||||
continue: !def.abort,
|
||||
});
|
||||
};
|
||||
});
|
||||
export const $ZodCheckOverwrite = /*@__PURE__*/ core.$constructor("$ZodCheckOverwrite", (inst, def) => {
|
||||
$ZodCheck.init(inst, def);
|
||||
inst._zod.check = (payload) => {
|
||||
payload.value = def.tx(payload.value);
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
export declare enum TypePredicateKind {
|
||||
This = 0,
|
||||
Identifier = 1,
|
||||
AssertsThis = 2,
|
||||
AssertsIdentifier = 3
|
||||
}
|
||||
//# sourceMappingURL=typePredicateKind.enum.d.ts.map
|
||||
@@ -0,0 +1,50 @@
|
||||
import unsupportedIterableToArray from "./unsupportedIterableToArray.js";
|
||||
function _createForOfIteratorHelper(r, e) {
|
||||
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
||||
if (!t) {
|
||||
if (Array.isArray(r) || (t = unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
||||
t && (r = t);
|
||||
var _n = 0,
|
||||
F = function F() {};
|
||||
return {
|
||||
s: F,
|
||||
n: function n() {
|
||||
return _n >= r.length ? {
|
||||
done: !0
|
||||
} : {
|
||||
done: !1,
|
||||
value: r[_n++]
|
||||
};
|
||||
},
|
||||
e: function e(r) {
|
||||
throw r;
|
||||
},
|
||||
f: F
|
||||
};
|
||||
}
|
||||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
var o,
|
||||
a = !0,
|
||||
u = !1;
|
||||
return {
|
||||
s: function s() {
|
||||
t = t.call(r);
|
||||
},
|
||||
n: function n() {
|
||||
var r = t.next();
|
||||
return a = r.done, r;
|
||||
},
|
||||
e: function e(r) {
|
||||
u = !0, o = r;
|
||||
},
|
||||
f: function f() {
|
||||
try {
|
||||
a || null == t["return"] || t["return"]();
|
||||
} finally {
|
||||
if (u) throw o;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export { _createForOfIteratorHelper as default };
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha512.js","sourceRoot":"","sources":["src/sha512.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,uCASmB;AACnB,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC;AAC1D,6DAA6D;AAChD,QAAA,UAAU,GAAuB,oBAAW,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
import type { PreferOptionalChainMessageIds, PreferOptionalChainOptions } from './prefer-optional-chain-utils/PreferOptionalChainOptions';
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<PreferOptionalChainMessageIds, [PreferOptionalChainOptions], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,45 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = errSerializer
|
||||
|
||||
const { messageWithCauses, stackWithCauses, isErrorLike } = require('./err-helpers')
|
||||
const { pinoErrProto, pinoErrorSymbols } = require('./err-proto')
|
||||
const { seen } = pinoErrorSymbols
|
||||
|
||||
const { toString } = Object.prototype
|
||||
|
||||
function errSerializer (err) {
|
||||
if (!isErrorLike(err)) {
|
||||
return err
|
||||
}
|
||||
|
||||
err[seen] = undefined // tag to prevent re-looking at this
|
||||
const _err = Object.create(pinoErrProto)
|
||||
_err.type = toString.call(err.constructor) === '[object Function]'
|
||||
? err.constructor.name
|
||||
: err.name
|
||||
_err.message = messageWithCauses(err)
|
||||
_err.stack = stackWithCauses(err)
|
||||
|
||||
if (Array.isArray(err.errors)) {
|
||||
_err.aggregateErrors = err.errors.map(err => errSerializer(err))
|
||||
}
|
||||
|
||||
for (const key in err) {
|
||||
if (_err[key] === undefined) {
|
||||
const val = err[key]
|
||||
if (isErrorLike(val)) {
|
||||
// We append cause messages and stacks to _err, therefore skipping causes here
|
||||
if (key !== 'cause' && !Object.prototype.hasOwnProperty.call(val, seen)) {
|
||||
_err[key] = errSerializer(val)
|
||||
}
|
||||
} else {
|
||||
_err[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete err[seen] // clean up tag in case err is serialized again later
|
||||
_err.raw = err
|
||||
return _err
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
'use strict';
|
||||
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @summary Constructor for a Jayson Method
|
||||
* @class Method
|
||||
* @param {Function} [handler] Function to set as handler
|
||||
* @param {Object} [options]
|
||||
* @param {Function} [options.handler] Same as separate handler
|
||||
* @param {Boolean} [options.useContext=false] When true, the handler expects a context object
|
||||
* @param {Array|Object} [options.params] Defines params that the handler accepts
|
||||
*/
|
||||
const Method = function(handler, options) {
|
||||
|
||||
if(!(this instanceof Method)) {
|
||||
return new Method(handler, options);
|
||||
}
|
||||
|
||||
// only got passed options
|
||||
if(utils.isPlainObject(handler)) {
|
||||
options = handler;
|
||||
handler = null;
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
useContext: false,
|
||||
};
|
||||
|
||||
options = options || {};
|
||||
|
||||
this.options = utils.merge(defaults, options);
|
||||
this.handler = handler || options.handler;
|
||||
};
|
||||
|
||||
module.exports = Method;
|
||||
|
||||
/**
|
||||
* @summary Returns the handler function associated with this method
|
||||
* @return {Function}
|
||||
*/
|
||||
Method.prototype.getHandler = function() {
|
||||
return this.handler;
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Sets the handler function associated with this method
|
||||
* @param {Function} handler
|
||||
*/
|
||||
Method.prototype.setHandler = function(handler) {
|
||||
this.handler = handler;
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Prepare parameters for the method handler
|
||||
* @private
|
||||
*/
|
||||
Method.prototype._getHandlerParams = function(params) {
|
||||
const options = this.options;
|
||||
|
||||
const isObjectParams = !Array.isArray(params) && utils.isPlainObject(params) && params;
|
||||
const isArrayParams = Array.isArray(params);
|
||||
|
||||
switch(true) {
|
||||
|
||||
// handler always gets an array
|
||||
case options.params === Array:
|
||||
return isArrayParams ? params : utils.toArray(params);
|
||||
|
||||
// handler always gets an object
|
||||
case options.params === Object:
|
||||
return isObjectParams ? params : utils.toPlainObject(params);
|
||||
|
||||
// handler gets a list of defined properties that should always be set
|
||||
case Array.isArray(options.params): {
|
||||
const undefinedParams = Object.keys(options.params).reduce(function (out, index) {
|
||||
const key = options.params[index];
|
||||
out[key] = undefined;
|
||||
return out;
|
||||
}, {});
|
||||
return {...undefinedParams, ...utils.pick(params, Object.keys(params))};
|
||||
}
|
||||
|
||||
// handler gets a map of defined properties and their default values
|
||||
case utils.isPlainObject(options.params):
|
||||
return {...options.params, ...utils.pick(params, Object.keys(params))};
|
||||
|
||||
// give params as is
|
||||
default:
|
||||
return params;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Executes this method in the context of a server
|
||||
* @param {Server} server
|
||||
* @param {Array|Object} requestParams
|
||||
* @param {Object} [context]
|
||||
* @param {Function} callback
|
||||
*/
|
||||
Method.prototype.execute = function(server, requestParams, context, callback) {
|
||||
if(typeof(context) === 'function') {
|
||||
callback = context;
|
||||
context = {};
|
||||
}
|
||||
|
||||
if(!context) {
|
||||
context = {};
|
||||
}
|
||||
|
||||
// when useContext is true, the handler gets a context object every time
|
||||
const useContext = Boolean(this.options.useContext);
|
||||
const handler = this.getHandler();
|
||||
const params = this._getHandlerParams(requestParams);
|
||||
|
||||
const args = useContext ? [params, context, callback] : [params, callback];
|
||||
return handler.call(server, ...args);
|
||||
};
|
||||
@@ -0,0 +1,176 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
|
||||
const gtFive = z.number().gt(5);
|
||||
const gteFive = z.number().gte(-5).gte(5);
|
||||
const minFive = z.number().min(0).min(5);
|
||||
const ltFive = z.number().lte(10).lt(5);
|
||||
const lteFive = z.number().lte(5);
|
||||
const maxFive = z.number().max(10).max(5);
|
||||
const intNum = z.number().int();
|
||||
const positive = z.number().positive();
|
||||
const negative = z.number().negative();
|
||||
const nonpositive = z.number().nonpositive();
|
||||
const nonnegative = z.number().nonnegative();
|
||||
const multipleOfFive = z.number().multipleOf(5);
|
||||
const multipleOfNegativeFive = z.number().multipleOf(-5);
|
||||
const finite = z.number().finite();
|
||||
const safe = z.number().safe();
|
||||
const stepPointOne = z.number().step(0.1);
|
||||
const stepPointZeroZeroZeroOne = z.number().step(0.0001);
|
||||
const stepSixPointFour = z.number().step(6.4);
|
||||
|
||||
test("passing validations", () => {
|
||||
z.number().parse(1);
|
||||
z.number().parse(1.5);
|
||||
z.number().parse(0);
|
||||
z.number().parse(-1.5);
|
||||
z.number().parse(-1);
|
||||
z.number().parse(Number.POSITIVE_INFINITY);
|
||||
z.number().parse(Number.NEGATIVE_INFINITY);
|
||||
gtFive.parse(6);
|
||||
gtFive.parse(Number.POSITIVE_INFINITY);
|
||||
gteFive.parse(5);
|
||||
gteFive.parse(Number.POSITIVE_INFINITY);
|
||||
minFive.parse(5);
|
||||
minFive.parse(Number.POSITIVE_INFINITY);
|
||||
ltFive.parse(4);
|
||||
ltFive.parse(Number.NEGATIVE_INFINITY);
|
||||
lteFive.parse(5);
|
||||
lteFive.parse(Number.NEGATIVE_INFINITY);
|
||||
maxFive.parse(5);
|
||||
maxFive.parse(Number.NEGATIVE_INFINITY);
|
||||
intNum.parse(4);
|
||||
positive.parse(1);
|
||||
positive.parse(Number.POSITIVE_INFINITY);
|
||||
negative.parse(-1);
|
||||
negative.parse(Number.NEGATIVE_INFINITY);
|
||||
nonpositive.parse(0);
|
||||
nonpositive.parse(-1);
|
||||
nonpositive.parse(Number.NEGATIVE_INFINITY);
|
||||
nonnegative.parse(0);
|
||||
nonnegative.parse(1);
|
||||
nonnegative.parse(Number.POSITIVE_INFINITY);
|
||||
multipleOfFive.parse(15);
|
||||
multipleOfFive.parse(-15);
|
||||
multipleOfNegativeFive.parse(-15);
|
||||
multipleOfNegativeFive.parse(15);
|
||||
finite.parse(123);
|
||||
safe.parse(Number.MIN_SAFE_INTEGER);
|
||||
safe.parse(Number.MAX_SAFE_INTEGER);
|
||||
stepPointOne.parse(6);
|
||||
stepPointOne.parse(6.1);
|
||||
stepPointOne.parse(6.1);
|
||||
stepSixPointFour.parse(12.8);
|
||||
stepPointZeroZeroZeroOne.parse(3.01);
|
||||
});
|
||||
|
||||
test("failing validations", () => {
|
||||
expect(() => ltFive.parse(5)).toThrow();
|
||||
expect(() => lteFive.parse(6)).toThrow();
|
||||
expect(() => maxFive.parse(6)).toThrow();
|
||||
expect(() => gtFive.parse(5)).toThrow();
|
||||
expect(() => gteFive.parse(4)).toThrow();
|
||||
expect(() => minFive.parse(4)).toThrow();
|
||||
expect(() => intNum.parse(3.14)).toThrow();
|
||||
expect(() => positive.parse(0)).toThrow();
|
||||
expect(() => positive.parse(-1)).toThrow();
|
||||
expect(() => negative.parse(0)).toThrow();
|
||||
expect(() => negative.parse(1)).toThrow();
|
||||
expect(() => nonpositive.parse(1)).toThrow();
|
||||
expect(() => nonnegative.parse(-1)).toThrow();
|
||||
expect(() => multipleOfFive.parse(7.5)).toThrow();
|
||||
expect(() => multipleOfFive.parse(-7.5)).toThrow();
|
||||
expect(() => multipleOfNegativeFive.parse(-7.5)).toThrow();
|
||||
expect(() => multipleOfNegativeFive.parse(7.5)).toThrow();
|
||||
expect(() => finite.parse(Number.POSITIVE_INFINITY)).toThrow();
|
||||
expect(() => finite.parse(Number.NEGATIVE_INFINITY)).toThrow();
|
||||
expect(() => safe.parse(Number.MIN_SAFE_INTEGER - 1)).toThrow();
|
||||
expect(() => safe.parse(Number.MAX_SAFE_INTEGER + 1)).toThrow();
|
||||
|
||||
expect(() => stepPointOne.parse(6.11)).toThrow();
|
||||
expect(() => stepPointOne.parse(6.1000000001)).toThrow();
|
||||
expect(() => stepSixPointFour.parse(6.41)).toThrow();
|
||||
});
|
||||
|
||||
test("parse NaN", () => {
|
||||
expect(() => z.number().parse(Number.NaN)).toThrow();
|
||||
});
|
||||
|
||||
test("min max getters", () => {
|
||||
expect(z.number().minValue).toBeNull;
|
||||
expect(ltFive.minValue).toBeNull;
|
||||
expect(lteFive.minValue).toBeNull;
|
||||
expect(maxFive.minValue).toBeNull;
|
||||
expect(negative.minValue).toBeNull;
|
||||
expect(nonpositive.minValue).toBeNull;
|
||||
expect(intNum.minValue).toBeNull;
|
||||
expect(multipleOfFive.minValue).toBeNull;
|
||||
expect(finite.minValue).toBeNull;
|
||||
expect(gtFive.minValue).toEqual(5);
|
||||
expect(gteFive.minValue).toEqual(5);
|
||||
expect(minFive.minValue).toEqual(5);
|
||||
expect(minFive.min(10).minValue).toEqual(10);
|
||||
expect(positive.minValue).toEqual(0);
|
||||
expect(nonnegative.minValue).toEqual(0);
|
||||
expect(safe.minValue).toEqual(Number.MIN_SAFE_INTEGER);
|
||||
|
||||
expect(z.number().maxValue).toBeNull;
|
||||
expect(gtFive.maxValue).toBeNull;
|
||||
expect(gteFive.maxValue).toBeNull;
|
||||
expect(minFive.maxValue).toBeNull;
|
||||
expect(positive.maxValue).toBeNull;
|
||||
expect(nonnegative.maxValue).toBeNull;
|
||||
expect(intNum.minValue).toBeNull;
|
||||
expect(multipleOfFive.minValue).toBeNull;
|
||||
expect(finite.minValue).toBeNull;
|
||||
expect(ltFive.maxValue).toEqual(5);
|
||||
expect(lteFive.maxValue).toEqual(5);
|
||||
expect(maxFive.maxValue).toEqual(5);
|
||||
expect(maxFive.max(1).maxValue).toEqual(1);
|
||||
expect(negative.maxValue).toEqual(0);
|
||||
expect(nonpositive.maxValue).toEqual(0);
|
||||
expect(safe.maxValue).toEqual(Number.MAX_SAFE_INTEGER);
|
||||
});
|
||||
|
||||
test("int getter", () => {
|
||||
expect(z.number().isInt).toEqual(false);
|
||||
expect(z.number().multipleOf(1.5).isInt).toEqual(false);
|
||||
expect(gtFive.isInt).toEqual(false);
|
||||
expect(gteFive.isInt).toEqual(false);
|
||||
expect(minFive.isInt).toEqual(false);
|
||||
expect(positive.isInt).toEqual(false);
|
||||
expect(nonnegative.isInt).toEqual(false);
|
||||
expect(finite.isInt).toEqual(false);
|
||||
expect(ltFive.isInt).toEqual(false);
|
||||
expect(lteFive.isInt).toEqual(false);
|
||||
expect(maxFive.isInt).toEqual(false);
|
||||
expect(negative.isInt).toEqual(false);
|
||||
expect(nonpositive.isInt).toEqual(false);
|
||||
expect(safe.isInt).toEqual(false);
|
||||
|
||||
expect(intNum.isInt).toEqual(true);
|
||||
expect(multipleOfFive.isInt).toEqual(true);
|
||||
});
|
||||
|
||||
test("finite getter", () => {
|
||||
expect(z.number().isFinite).toEqual(false);
|
||||
expect(gtFive.isFinite).toEqual(false);
|
||||
expect(gteFive.isFinite).toEqual(false);
|
||||
expect(minFive.isFinite).toEqual(false);
|
||||
expect(positive.isFinite).toEqual(false);
|
||||
expect(nonnegative.isFinite).toEqual(false);
|
||||
expect(ltFive.isFinite).toEqual(false);
|
||||
expect(lteFive.isFinite).toEqual(false);
|
||||
expect(maxFive.isFinite).toEqual(false);
|
||||
expect(negative.isFinite).toEqual(false);
|
||||
expect(nonpositive.isFinite).toEqual(false);
|
||||
|
||||
expect(finite.isFinite).toEqual(true);
|
||||
expect(intNum.isFinite).toEqual(true);
|
||||
expect(multipleOfFive.isFinite).toEqual(true);
|
||||
expect(z.number().min(5).max(10).isFinite).toEqual(true);
|
||||
expect(safe.isFinite).toEqual(true);
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const pino = require('../..')
|
||||
const transport = pino.transport({
|
||||
target: 'pino/file'
|
||||
})
|
||||
const logger = pino(transport)
|
||||
|
||||
transport.on('ready', function () {
|
||||
logger.info('Hello')
|
||||
process.exit(0)
|
||||
})
|
||||
@@ -0,0 +1,37 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
interface RegExpMatchArray {
|
||||
groups?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface RegExpExecArray {
|
||||
groups?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression.
|
||||
* Default is false. Read-only.
|
||||
*/
|
||||
readonly dotAll: boolean;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { expect, test } from "vitest";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
declare module "zod/v4" {
|
||||
interface ZodType {
|
||||
/** @deprecated */
|
||||
_classic(): string;
|
||||
}
|
||||
}
|
||||
|
||||
test("prototype extension", () => {
|
||||
z.ZodType.prototype._classic = function () {
|
||||
return "_classic";
|
||||
};
|
||||
|
||||
// should pass
|
||||
const result = z.string()._classic();
|
||||
expect(result).toBe("_classic");
|
||||
// expectTypeOf<typeof result>().toEqualTypeOf<string>();
|
||||
|
||||
// clean up
|
||||
z.ZodType.prototype._classic = undefined;
|
||||
});
|
||||
Reference in New Issue
Block a user