WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
export function promiseTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
): Promise<T | null> {
let timeoutId: ReturnType<typeof setTimeout>;
const timeoutPromise: Promise<null> = new Promise(resolve => {
timeoutId = setTimeout(() => resolve(null), timeoutMs);
});
return Promise.race([promise, timeoutPromise]).then((result: T | null) => {
clearTimeout(timeoutId);
return result;
});
}

View File

@@ -0,0 +1,29 @@
import Agent from './agent'
import buildConnector from './connector'
import Dispatcher from './dispatcher'
import { OutgoingHttpHeaders } from './header'
export default ProxyAgent
declare class ProxyAgent extends Dispatcher {
constructor (options: ProxyAgent.Options | string)
dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
close (): Promise<void>
}
declare namespace ProxyAgent {
export interface Options extends Agent.Options {
uri: string;
/**
* @deprecated use opts.token
*/
auth?: string;
token?: string;
headers?: OutgoingHttpHeaders;
requestTls?: buildConnector.BuildOptions;
proxyTls?: buildConnector.BuildOptions;
clientFactory?(origin: URL, opts: object): Dispatcher;
proxyTunnel?: boolean;
}
}

View File

@@ -0,0 +1,66 @@
declare const colorsMap: {
readonly reset: readonly [0, 0];
readonly bold: readonly [1, 22, "\u001B[22m\u001B[1m"];
readonly dim: readonly [2, 22, "\u001B[22m\u001B[2m"];
readonly italic: readonly [3, 23];
readonly underline: readonly [4, 24];
readonly inverse: readonly [7, 27];
readonly hidden: readonly [8, 28];
readonly strikethrough: readonly [9, 29];
readonly black: readonly [30, 39];
readonly red: readonly [31, 39];
readonly green: readonly [32, 39];
readonly yellow: readonly [33, 39];
readonly blue: readonly [34, 39];
readonly magenta: readonly [35, 39];
readonly cyan: readonly [36, 39];
readonly white: readonly [37, 39];
readonly gray: readonly [90, 39];
readonly bgBlack: readonly [40, 49];
readonly bgRed: readonly [41, 49];
readonly bgGreen: readonly [42, 49];
readonly bgYellow: readonly [43, 49];
readonly bgBlue: readonly [44, 49];
readonly bgMagenta: readonly [45, 49];
readonly bgCyan: readonly [46, 49];
readonly bgWhite: readonly [47, 49];
readonly blackBright: readonly [90, 39];
readonly redBright: readonly [91, 39];
readonly greenBright: readonly [92, 39];
readonly yellowBright: readonly [93, 39];
readonly blueBright: readonly [94, 39];
readonly magentaBright: readonly [95, 39];
readonly cyanBright: readonly [96, 39];
readonly whiteBright: readonly [97, 39];
readonly bgBlackBright: readonly [100, 49];
readonly bgRedBright: readonly [101, 49];
readonly bgGreenBright: readonly [102, 49];
readonly bgYellowBright: readonly [103, 49];
readonly bgBlueBright: readonly [104, 49];
readonly bgMagentaBright: readonly [105, 49];
readonly bgCyanBright: readonly [106, 49];
readonly bgWhiteBright: readonly [107, 49];
};
interface Formatter {
(input?: unknown): string;
open: string;
close: string;
}
type ColorName = keyof typeof colorsMap;
type ColorsMethods = {
[Key in ColorName]: Formatter;
};
type Colors = ColorsMethods & {
isColorSupported: boolean;
reset: (input: unknown) => string;
};
declare function getDefaultColors(): Colors;
declare function isSupported(): boolean;
declare function createColors({ force }?: {
force?: boolean;
}): Colors;
declare const colors: Colors;
declare function disableDefaultColors(): void;
declare function enabledDefaultColors(): void;
export { type Colors, type Formatter, createColors, colors as default, disableDefaultColors, enabledDefaultColors, getDefaultColors, isSupported };

View File

@@ -0,0 +1,12 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
// npx nx generate-lib repo
Object.defineProperty(exports, "__esModule", { value: true });
exports.es2024_object = void 0;
const base_config_1 = require("./base-config");
exports.es2024_object = {
libs: [],
variables: [['ObjectConstructor', base_config_1.TYPE]],
};

View File

@@ -0,0 +1,7 @@
type AutocompletePrimitiveBaseType<T> =
T extends string ? string :
T extends number ? number :
T extends boolean ? boolean :
never
export type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>)

View File

@@ -0,0 +1,121 @@
import type { $ZodStringFormats } from "../core/checks.js";
import type * as errors from "../core/errors.js";
import * as util from "../core/util.js";
const error: () => errors.$ZodErrorMap = () => {
const Sizable: Record<string, { unit: string; subject: string }> = {
string: { unit: "merkkiä", subject: "merkkijonon" },
file: { unit: "tavua", subject: "tiedoston" },
array: { unit: "alkiota", subject: "listan" },
set: { unit: "alkiota", subject: "joukon" },
number: { unit: "", subject: "luvun" },
bigint: { unit: "", subject: "suuren kokonaisluvun" },
int: { unit: "", subject: "kokonaisluvun" },
date: { unit: "", subject: "päivämäärän" },
};
function getSizing(origin: string): { unit: string; subject: string } | null {
return Sizable[origin] ?? null;
}
const FormatDictionary: {
[k in $ZodStringFormats | (string & {})]?: string;
} = {
regex: "säännöllinen lauseke",
email: "sähköpostiosoite",
url: "URL-osoite",
emoji: "emoji",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO-aikaleima",
date: "ISO-päivämäärä",
time: "ISO-aika",
duration: "ISO-kesto",
ipv4: "IPv4-osoite",
ipv6: "IPv6-osoite",
cidrv4: "IPv4-alue",
cidrv6: "IPv6-alue",
base64: "base64-koodattu merkkijono",
base64url: "base64url-koodattu merkkijono",
json_string: "JSON-merkkijono",
e164: "E.164-luku",
jwt: "JWT",
template_literal: "templaattimerkkijono",
};
const TypeDictionary: {
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
} = {
nan: "NaN",
};
return (issue) => {
switch (issue.code) {
case "invalid_type": {
const expected = TypeDictionary[issue.expected] ?? issue.expected;
const receivedType = util.parsedType(issue.input);
const received = TypeDictionary[receivedType] ?? receivedType;
if (/^[A-Z]/.test(issue.expected)) {
return `Virheellinen tyyppi: odotettiin instanceof ${issue.expected}, oli ${received}`;
}
return `Virheellinen tyyppi: odotettiin ${expected}, oli ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Virheellinen syöte: täytyy olla ${util.stringifyPrimitive(issue.values[0])}`;
return `Virheellinen valinta: täytyy olla yksi seuraavista: ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
if (sizing) {
return `Liian suuri: ${sizing.subject} täytyy olla ${adj}${issue.maximum.toString()} ${sizing.unit}`.trim();
}
return `Liian suuri: arvon täytyy olla ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
if (sizing) {
return `Liian pieni: ${sizing.subject} täytyy olla ${adj}${issue.minimum.toString()} ${sizing.unit}`.trim();
}
return `Liian pieni: arvon täytyy olla ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with") return `Virheellinen syöte: täytyy alkaa "${_issue.prefix}"`;
if (_issue.format === "ends_with") return `Virheellinen syöte: täytyy loppua "${_issue.suffix}"`;
if (_issue.format === "includes") return `Virheellinen syöte: täytyy sisältää "${_issue.includes}"`;
if (_issue.format === "regex") {
return `Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${_issue.pattern}`;
}
return `Virheellinen ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Virheellinen luku: täytyy olla luvun ${issue.divisor} monikerta`;
case "unrecognized_keys":
return `${issue.keys.length > 1 ? "Tuntemattomat avaimet" : "Tuntematon avain"}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return "Virheellinen avain tietueessa";
case "invalid_union":
return "Virheellinen unioni";
case "invalid_element":
return "Virheellinen arvo joukossa";
default:
return `Virheellinen syöte`;
}
};
};
export default function (): { localeError: errors.$ZodErrorMap } {
return {
localeError: error(),
};
}

View File

@@ -0,0 +1,5 @@
'use strict'
const compare = require('./compare')
const eq = (a, b, loose) => compare(a, b, loose) === 0
module.exports = eq

View File

@@ -0,0 +1,4 @@
import * as z from "./external.js";
export { z };
export * from "./external.js";
export default z;

View File

@@ -0,0 +1,9 @@
import { _ as _to_primitive } from "./_to_primitive.js";
import { _ as _type_of } from "./_type_of.js";
function _to_property_key(arg) {
var key = _to_primitive(arg, "string");
return _type_of(key) === "symbol" ? key : String(key);
}
export { _to_property_key as _ };

View File

@@ -0,0 +1,119 @@
/**
* @fileoverview Rule to flag unsafe statements in finally block
* @author Onur Temizkan
*/
"use strict";
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const SENTINEL_NODE_TYPE_RETURN_THROW =
/^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
const SENTINEL_NODE_TYPE_BREAK =
/^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/u;
const SENTINEL_NODE_TYPE_CONTINUE =
/^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/u;
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../types').Rule.RuleModule} */
module.exports = {
meta: {
type: "problem",
docs: {
description: "Disallow control flow statements in `finally` blocks",
recommended: true,
url: "https://eslint.org/docs/latest/rules/no-unsafe-finally",
},
schema: [],
messages: {
unsafeUsage: "Unsafe usage of {{nodeType}}.",
},
},
create(context) {
/**
* Checks if the node is the finalizer of a TryStatement
* @param {ASTNode} node node to check.
* @returns {boolean} - true if the node is the finalizer of a TryStatement
*/
function isFinallyBlock(node) {
return (
node.parent.type === "TryStatement" &&
node.parent.finalizer === node
);
}
/**
* Climbs up the tree if the node is not a sentinel node
* @param {ASTNode} node node to check.
* @param {string} label label of the break or continue statement
* @returns {boolean} - return whether the node is a finally block or a sentinel node
*/
function isInFinallyBlock(node, label) {
let labelInside = false;
let sentinelNodeType;
if (node.type === "BreakStatement" && !node.label) {
sentinelNodeType = SENTINEL_NODE_TYPE_BREAK;
} else if (node.type === "ContinueStatement") {
sentinelNodeType = SENTINEL_NODE_TYPE_CONTINUE;
} else {
sentinelNodeType = SENTINEL_NODE_TYPE_RETURN_THROW;
}
for (
let currentNode = node;
currentNode && !sentinelNodeType.test(currentNode.type);
currentNode = currentNode.parent
) {
if (
currentNode.parent.label &&
label &&
currentNode.parent.label.name === label.name
) {
labelInside = true;
}
if (isFinallyBlock(currentNode)) {
if (label && labelInside) {
return false;
}
return true;
}
}
return false;
}
/**
* Checks whether the possibly-unsafe statement is inside a finally block.
* @param {ASTNode} node node to check.
* @returns {void}
*/
function check(node) {
if (isInFinallyBlock(node, node.label)) {
context.report({
messageId: "unsafeUsage",
data: {
nodeType: node.type,
},
node,
line: node.loc.line,
column: node.loc.column,
});
}
}
return {
ReturnStatement: check,
ThrowStatement: check,
BreakStatement: check,
ContinueStatement: check,
};
},
};

View File

@@ -0,0 +1,440 @@
// @ts-ignore TS6133
import { expect, test } from "vitest";
import * as z from "zod/v3";
import { util } from "../helpers/util.js";
import { Mocker } from "./Mocker.js";
const literalStringSchema = z.literal("asdf");
const literalNumberSchema = z.literal(12);
const literalBooleanSchema = z.literal(true);
const literalBigIntSchema = z.literal(BigInt(42));
const MySymbol = Symbol("stuff");
const literalSymbolSchema = z.literal(MySymbol);
const stringSchema = z.string();
const numberSchema = z.number();
const bigintSchema = z.bigint();
const booleanSchema = z.boolean();
const dateSchema = z.date();
const symbolSchema = z.symbol();
const nullSchema = z.null();
const undefinedSchema = z.undefined();
const stringSchemaOptional = z.string().optional();
const stringSchemaNullable = z.string().nullable();
const numberSchemaOptional = z.number().optional();
const numberSchemaNullable = z.number().nullable();
const bigintSchemaOptional = z.bigint().optional();
const bigintSchemaNullable = z.bigint().nullable();
const booleanSchemaOptional = z.boolean().optional();
const booleanSchemaNullable = z.boolean().nullable();
const dateSchemaOptional = z.date().optional();
const dateSchemaNullable = z.date().nullable();
const symbolSchemaOptional = z.symbol().optional();
const symbolSchemaNullable = z.symbol().nullable();
const val = new Mocker();
test("literal string correct", () => {
expect(literalStringSchema.parse("asdf")).toBe("asdf");
});
test("literal string incorrect", () => {
const f = () => literalStringSchema.parse("not_asdf");
expect(f).toThrow();
});
test("literal string number", () => {
const f = () => literalStringSchema.parse(123);
expect(f).toThrow();
});
test("literal string boolean", () => {
const f = () => literalStringSchema.parse(true);
expect(f).toThrow();
});
test("literal string boolean", () => {
const f = () => literalStringSchema.parse(true);
expect(f).toThrow();
});
test("literal string object", () => {
const f = () => literalStringSchema.parse({});
expect(f).toThrow();
});
test("literal number correct", () => {
expect(literalNumberSchema.parse(12)).toBe(12);
});
test("literal number incorrect", () => {
const f = () => literalNumberSchema.parse(13);
expect(f).toThrow();
});
test("literal number number", () => {
const f = () => literalNumberSchema.parse(val.string);
expect(f).toThrow();
});
test("literal number boolean", () => {
const f = () => literalNumberSchema.parse(val.boolean);
expect(f).toThrow();
});
test("literal number object", () => {
const f = () => literalStringSchema.parse({});
expect(f).toThrow();
});
test("literal boolean correct", () => {
expect(literalBooleanSchema.parse(true)).toBe(true);
});
test("literal boolean incorrect", () => {
const f = () => literalBooleanSchema.parse(false);
expect(f).toThrow();
});
test("literal boolean number", () => {
const f = () => literalBooleanSchema.parse("asdf");
expect(f).toThrow();
});
test("literal boolean boolean", () => {
const f = () => literalBooleanSchema.parse(123);
expect(f).toThrow();
});
test("literal boolean object", () => {
const f = () => literalBooleanSchema.parse({});
expect(f).toThrow();
});
test("literal bigint correct", () => {
expect(literalBigIntSchema.parse(BigInt(42))).toBe(BigInt(42));
});
test("literal bigint incorrect", () => {
const f = () => literalBigIntSchema.parse(BigInt(43));
expect(f).toThrow();
});
test("literal bigint number", () => {
const f = () => literalBigIntSchema.parse("asdf");
expect(f).toThrow();
});
test("literal bigint boolean", () => {
const f = () => literalBigIntSchema.parse(123);
expect(f).toThrow();
});
test("literal bigint object", () => {
const f = () => literalBigIntSchema.parse({});
expect(f).toThrow();
});
test("literal symbol", () => {
util.assertEqual<z.infer<typeof literalSymbolSchema>, typeof MySymbol>(true);
literalSymbolSchema.parse(MySymbol);
expect(() => literalSymbolSchema.parse(Symbol("asdf"))).toThrow();
});
test("parse stringSchema string", () => {
stringSchema.parse(val.string);
});
test("parse stringSchema number", () => {
const f = () => stringSchema.parse(val.number);
expect(f).toThrow();
});
test("parse stringSchema boolean", () => {
const f = () => stringSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse stringSchema undefined", () => {
const f = () => stringSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse stringSchema null", () => {
const f = () => stringSchema.parse(val.null);
expect(f).toThrow();
});
test("parse numberSchema string", () => {
const f = () => numberSchema.parse(val.string);
expect(f).toThrow();
});
test("parse numberSchema number", () => {
numberSchema.parse(val.number);
});
test("parse numberSchema bigint", () => {
const f = () => numberSchema.parse(val.bigint);
expect(f).toThrow();
});
test("parse numberSchema boolean", () => {
const f = () => numberSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse numberSchema undefined", () => {
const f = () => numberSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse numberSchema null", () => {
const f = () => numberSchema.parse(val.null);
expect(f).toThrow();
});
test("parse bigintSchema string", () => {
const f = () => bigintSchema.parse(val.string);
expect(f).toThrow();
});
test("parse bigintSchema number", () => {
const f = () => bigintSchema.parse(val.number);
expect(f).toThrow();
});
test("parse bigintSchema bigint", () => {
bigintSchema.parse(val.bigint);
});
test("parse bigintSchema boolean", () => {
const f = () => bigintSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse bigintSchema undefined", () => {
const f = () => bigintSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse bigintSchema null", () => {
const f = () => bigintSchema.parse(val.null);
expect(f).toThrow();
});
test("parse booleanSchema string", () => {
const f = () => booleanSchema.parse(val.string);
expect(f).toThrow();
});
test("parse booleanSchema number", () => {
const f = () => booleanSchema.parse(val.number);
expect(f).toThrow();
});
test("parse booleanSchema boolean", () => {
booleanSchema.parse(val.boolean);
});
test("parse booleanSchema undefined", () => {
const f = () => booleanSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse booleanSchema null", () => {
const f = () => booleanSchema.parse(val.null);
expect(f).toThrow();
});
// ==============
test("parse dateSchema string", () => {
const f = () => dateSchema.parse(val.string);
expect(f).toThrow();
});
test("parse dateSchema number", () => {
const f = () => dateSchema.parse(val.number);
expect(f).toThrow();
});
test("parse dateSchema boolean", () => {
const f = () => dateSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse dateSchema date", () => {
dateSchema.parse(val.date);
});
test("parse dateSchema undefined", () => {
const f = () => dateSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse dateSchema null", () => {
const f = () => dateSchema.parse(val.null);
expect(f).toThrow();
});
test("parse dateSchema invalid date", async () => {
try {
await dateSchema.parseAsync(new Date("invalid"));
} catch (err) {
expect((err as z.ZodError).issues[0].code).toEqual(z.ZodIssueCode.invalid_date);
}
});
// ==============
test("parse symbolSchema string", () => {
const f = () => symbolSchema.parse(val.string);
expect(f).toThrow();
});
test("parse symbolSchema number", () => {
const f = () => symbolSchema.parse(val.number);
expect(f).toThrow();
});
test("parse symbolSchema boolean", () => {
const f = () => symbolSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse symbolSchema date", () => {
const f = () => symbolSchema.parse(val.date);
expect(f).toThrow();
});
test("parse symbolSchema symbol", () => {
symbolSchema.parse(val.symbol);
});
test("parse symbolSchema undefined", () => {
const f = () => symbolSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse symbolSchema null", () => {
const f = () => symbolSchema.parse(val.null);
expect(f).toThrow();
});
// ==============
test("parse undefinedSchema string", () => {
const f = () => undefinedSchema.parse(val.string);
expect(f).toThrow();
});
test("parse undefinedSchema number", () => {
const f = () => undefinedSchema.parse(val.number);
expect(f).toThrow();
});
test("parse undefinedSchema boolean", () => {
const f = () => undefinedSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse undefinedSchema undefined", () => {
undefinedSchema.parse(val.undefined);
});
test("parse undefinedSchema null", () => {
const f = () => undefinedSchema.parse(val.null);
expect(f).toThrow();
});
test("parse nullSchema string", () => {
const f = () => nullSchema.parse(val.string);
expect(f).toThrow();
});
test("parse nullSchema number", () => {
const f = () => nullSchema.parse(val.number);
expect(f).toThrow();
});
test("parse nullSchema boolean", () => {
const f = () => nullSchema.parse(val.boolean);
expect(f).toThrow();
});
test("parse nullSchema undefined", () => {
const f = () => nullSchema.parse(val.undefined);
expect(f).toThrow();
});
test("parse nullSchema null", () => {
nullSchema.parse(val.null);
});
test("primitive inference", () => {
util.assertEqual<z.TypeOf<typeof literalStringSchema>, "asdf">(true);
util.assertEqual<z.TypeOf<typeof literalNumberSchema>, 12>(true);
util.assertEqual<z.TypeOf<typeof literalBooleanSchema>, true>(true);
util.assertEqual<z.TypeOf<typeof literalBigIntSchema>, bigint>(true);
util.assertEqual<z.TypeOf<typeof stringSchema>, string>(true);
util.assertEqual<z.TypeOf<typeof numberSchema>, number>(true);
util.assertEqual<z.TypeOf<typeof bigintSchema>, bigint>(true);
util.assertEqual<z.TypeOf<typeof booleanSchema>, boolean>(true);
util.assertEqual<z.TypeOf<typeof dateSchema>, Date>(true);
util.assertEqual<z.TypeOf<typeof symbolSchema>, symbol>(true);
util.assertEqual<z.TypeOf<typeof nullSchema>, null>(true);
util.assertEqual<z.TypeOf<typeof undefinedSchema>, undefined>(true);
util.assertEqual<z.TypeOf<typeof stringSchemaOptional>, string | undefined>(true);
util.assertEqual<z.TypeOf<typeof stringSchemaNullable>, string | null>(true);
util.assertEqual<z.TypeOf<typeof numberSchemaOptional>, number | undefined>(true);
util.assertEqual<z.TypeOf<typeof numberSchemaNullable>, number | null>(true);
util.assertEqual<z.TypeOf<typeof bigintSchemaOptional>, bigint | undefined>(true);
util.assertEqual<z.TypeOf<typeof bigintSchemaNullable>, bigint | null>(true);
util.assertEqual<z.TypeOf<typeof booleanSchemaOptional>, boolean | undefined>(true);
util.assertEqual<z.TypeOf<typeof booleanSchemaNullable>, boolean | null>(true);
util.assertEqual<z.TypeOf<typeof dateSchemaOptional>, Date | undefined>(true);
util.assertEqual<z.TypeOf<typeof dateSchemaNullable>, Date | null>(true);
util.assertEqual<z.TypeOf<typeof symbolSchemaOptional>, symbol | undefined>(true);
util.assertEqual<z.TypeOf<typeof symbolSchemaNullable>, symbol | null>(true);
// [
// literalStringSchemaTest,
// literalNumberSchemaTest,
// literalBooleanSchemaTest,
// literalBigIntSchemaTest,
// stringSchemaTest,
// numberSchemaTest,
// bigintSchemaTest,
// booleanSchemaTest,
// dateSchemaTest,
// symbolSchemaTest,
// nullSchemaTest,
// undefinedSchemaTest,
// stringSchemaOptionalTest,
// stringSchemaNullableTest,
// numberSchemaOptionalTest,
// numberSchemaNullableTest,
// bigintSchemaOptionalTest,
// bigintSchemaNullableTest,
// booleanSchemaOptionalTest,
// booleanSchemaNullableTest,
// dateSchemaOptionalTest,
// dateSchemaNullableTest,
// symbolSchemaOptionalTest,
// symbolSchemaNullableTest,
// ];
});
test("get literal value", () => {
expect(literalStringSchema.value).toEqual("asdf");
});
test("optional convenience method", () => {
z.ostring().parse(undefined);
z.onumber().parse(undefined);
z.oboolean().parse(undefined);
});

View File

@@ -0,0 +1 @@
{"version":3,"file":"nodeBuilderFlags.enum.d.ts","sourceRoot":"","sources":["../../src/enums/nodeBuilderFlags.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,gBAAgB;IACxB,IAAI,IAAI;IACR,YAAY,IAAS;IACrB,uBAAuB,IAAS;IAChC,kCAAkC,IAAS;IAC3C,qBAAqB,IAAS;IAC9B,mCAAmC,KAAS;IAC5C,6BAA6B,KAAS;IACtC,qBAAqB,KAAS;IAC9B,uBAAuB,MAAS;IAChC,qBAAqB,MAAS;IAC9B,kCAAkC,MAAS;IAC3C,uBAAuB,OAAU;IACjC,iCAAiC,OAAU;IAC3C,iBAAiB,OAAU;IAC3B,sBAAsB,OAAU;IAChC,kCAAkC,QAAU;IAC5C,mCAAmC,YAAU;IAC7C,eAAe,YAAU;IACzB,2BAA2B,aAAU;IACrC,iBAAiB,WAAU;IAC3B,uBAAuB,YAAU;IACjC,wBAAwB,QAAU;IAClC,qCAAqC,QAAU;IAC/C,wBAAwB,SAAU;IAClC,6BAA6B,SAAU;IACvC,eAAe,SAAU;IACzB,uBAAuB,UAAU;IACjC,uBAAuB,UAAU;IACjC,6BAA6B,WAAU;IACvC,YAAY,WAA0M;IACtN,mBAAmB,UAAU;IAC7B,WAAW,UAAU;IACrB,mBAAmB,WAAU;CAChC"}

View File

@@ -0,0 +1,83 @@
{
"name": "picomatch",
"description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
"version": "4.0.5",
"homepage": "https://github.com/micromatch/picomatch",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"funding": "https://github.com/sponsors/jonschlinkert",
"repository": "micromatch/picomatch",
"bugs": {
"url": "https://github.com/micromatch/picomatch/issues"
},
"license": "MIT",
"files": [
"index.js",
"posix.js",
"lib"
],
"sideEffects": false,
"main": "index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .",
"mocha": "mocha --reporter dot",
"test": "npm run lint && npm run mocha",
"test:ci": "npm run test:cover",
"test:cover": "nyc npm run mocha"
},
"devDependencies": {
"eslint": "^8.57.0",
"fill-range": "^7.0.1",
"gulp-format-md": "^2.0.0",
"mocha": "^10.4.0",
"nyc": "^15.1.0"
},
"keywords": [
"glob",
"match",
"picomatch"
],
"nyc": {
"reporter": [
"html",
"lcov",
"text-summary",
"cobertura"
]
},
"verb": {
"toc": {
"render": true,
"method": "preWrite",
"maxdepth": 3
},
"layout": "empty",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
},
"related": {
"list": [
"braces",
"micromatch"
]
},
"reflinks": [
"braces",
"expand-brackets",
"extglob",
"fill-range",
"micromatch",
"minimatch",
"nanomatch",
"picomatch"
]
}
}

View File

@@ -0,0 +1,26 @@
/*! *****************************************************************************
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="es2020.intl" />
interface Number {
/**
* Converts a number to a string by using the current or specified locale.
* @param locales A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions): string;
}

View File

@@ -0,0 +1,22 @@
import * as core from "../core/index.cjs";
import * as schemas from "./schemas.cjs";
export interface ZodISODateTime extends schemas.ZodStringFormat {
_zod: core.$ZodISODateTimeInternals;
}
export declare const ZodISODateTime: core.$constructor<ZodISODateTime>;
export declare function datetime(params?: string | core.$ZodISODateTimeParams): ZodISODateTime;
export interface ZodISODate extends schemas.ZodStringFormat {
_zod: core.$ZodISODateInternals;
}
export declare const ZodISODate: core.$constructor<ZodISODate>;
export declare function date(params?: string | core.$ZodISODateParams): ZodISODate;
export interface ZodISOTime extends schemas.ZodStringFormat {
_zod: core.$ZodISOTimeInternals;
}
export declare const ZodISOTime: core.$constructor<ZodISOTime>;
export declare function time(params?: string | core.$ZodISOTimeParams): ZodISOTime;
export interface ZodISODuration extends schemas.ZodStringFormat {
_zod: core.$ZodISODurationInternals;
}
export declare const ZodISODuration: core.$constructor<ZodISODuration>;
export declare function duration(params?: string | core.$ZodISODurationParams): ZodISODuration;

View File

@@ -0,0 +1,21 @@
// @ts-ignore TS6133
import { test } from "vitest";
import type { ZodFirstPartySchemaTypes, ZodFirstPartyTypeKind } from "zod/v3";
import { util } from "../helpers/util.js";
test("Identify missing [ZodFirstPartySchemaTypes]", () => {
type ZodFirstPartySchemaForType<T extends ZodFirstPartyTypeKind> = ZodFirstPartySchemaTypes extends infer Schema
? Schema extends { _def: { typeName: T } }
? Schema
: never
: never;
type ZodMappedTypes = {
[key in ZodFirstPartyTypeKind]: ZodFirstPartySchemaForType<key>;
};
type ZodFirstPartySchemaTypesMissingFromUnion = keyof {
[key in keyof ZodMappedTypes as ZodMappedTypes[key] extends { _def: never } ? key : never]: unknown;
};
util.assertEqual<ZodFirstPartySchemaTypesMissingFromUnion, never>(true);
});

View File

@@ -0,0 +1,31 @@
{
"name": "json-stringify-safe",
"version": "5.0.1",
"description": "Like JSON.stringify, but doesn't blow up on circular refs.",
"keywords": [
"json",
"stringify",
"circular",
"safe"
],
"homepage": "https://github.com/isaacs/json-stringify-safe",
"bugs": "https://github.com/isaacs/json-stringify-safe/issues",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"contributors": [
"Andri Möll <andri@dot.ee> (http://themoll.com)"
],
"license": "ISC",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/json-stringify-safe"
},
"main": "stringify.js",
"scripts": {
"test": "node test.js"
},
"devDependencies": {
"mocha": ">= 2.1.0 < 3",
"must": ">= 0.12 < 0.13",
"sinon": ">= 1.12.2 < 2"
}
}

View File

@@ -0,0 +1,163 @@
"use strict";
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const api_1 = require("../common/api");
class MessageBuffer extends api_1.AbstractMessageBuffer {
static emptyBuffer = Buffer.allocUnsafe(0);
constructor(encoding = 'utf-8') {
super(encoding);
}
emptyBuffer() {
return MessageBuffer.emptyBuffer;
}
fromString(value, encoding) {
return Buffer.from(value, encoding);
}
toString(value, encoding) {
if (value instanceof Buffer) {
return value.toString(encoding);
}
else {
return new util_1.TextDecoder(encoding).decode(value);
}
}
asNative(buffer, length) {
if (length === undefined) {
return buffer instanceof Buffer ? buffer : Buffer.from(buffer);
}
else {
return buffer instanceof Buffer ? buffer.slice(0, length) : Buffer.from(buffer, 0, length);
}
}
allocNative(length) {
return Buffer.allocUnsafe(length);
}
}
class ReadableStreamWrapper {
stream;
constructor(stream) {
this.stream = stream;
}
onClose(listener) {
this.stream.on('close', listener);
return api_1.Disposable.create(() => this.stream.off('close', listener));
}
onError(listener) {
this.stream.on('error', listener);
return api_1.Disposable.create(() => this.stream.off('error', listener));
}
onEnd(listener) {
this.stream.on('end', listener);
return api_1.Disposable.create(() => this.stream.off('end', listener));
}
onData(listener) {
this.stream.on('data', listener);
return api_1.Disposable.create(() => this.stream.off('data', listener));
}
}
class WritableStreamWrapper {
stream;
constructor(stream) {
this.stream = stream;
}
onClose(listener) {
this.stream.on('close', listener);
return api_1.Disposable.create(() => this.stream.off('close', listener));
}
onError(listener) {
this.stream.on('error', listener);
return api_1.Disposable.create(() => this.stream.off('error', listener));
}
onEnd(listener) {
this.stream.on('end', listener);
return api_1.Disposable.create(() => this.stream.off('end', listener));
}
write(data, encoding) {
return new Promise((resolve, reject) => {
const callback = (error) => {
if (error === undefined || error === null) {
resolve();
}
else {
reject(error);
}
};
if (typeof data === 'string') {
this.stream.write(data, encoding, callback);
}
else {
this.stream.write(data, callback);
}
});
}
end() {
this.stream.end();
}
}
const _ril = Object.freeze({
messageBuffer: Object.freeze({
create: (encoding) => new MessageBuffer(encoding)
}),
applicationJson: Object.freeze({
encoder: Object.freeze({
name: 'application/json',
encode: (msg, options) => {
try {
return Promise.resolve(Buffer.from(JSON.stringify(msg, undefined, 0), options.charset));
}
catch (err) {
return Promise.reject(err);
}
}
}),
decoder: Object.freeze({
name: 'application/json',
decode: (buffer, options) => {
try {
if (buffer instanceof Buffer) {
return Promise.resolve(JSON.parse(buffer.toString(options.charset)));
}
else {
return Promise.resolve(JSON.parse(new util_1.TextDecoder(options.charset).decode(buffer)));
}
}
catch (err) {
return Promise.reject(err);
}
}
})
}),
stream: Object.freeze({
asReadableStream: (stream) => new ReadableStreamWrapper(stream),
asWritableStream: (stream) => new WritableStreamWrapper(stream)
}),
console: console,
timer: Object.freeze({
setTimeout(callback, ms, ...args) {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
},
setImmediate(callback, ...args) {
const handle = setImmediate(callback, ...args);
return { dispose: () => clearImmediate(handle) };
},
setInterval(callback, ms, ...args) {
const handle = setInterval(callback, ms, ...args);
return { dispose: () => clearInterval(handle) };
}
})
});
function RIL() {
return _ril;
}
(function (RIL) {
function install() {
api_1.RAL.install(_ril);
}
RIL.install = install;
})(RIL || (RIL = {}));
exports.default = RIL;