Created 10 detailed GitHub issues covering: - Project activation and management UI (#1-2) - Worker node coordination and visualization (#3-4) - Automated GitHub repository scanning (#5) - Intelligent model-to-issue matching (#6) - Multi-model task execution system (#7) - N8N workflow integration (#8) - Hive-Bzzz P2P bridge (#9) - Peer assistance protocol (#10) Each issue includes detailed specifications, acceptance criteria, technical implementation notes, and dependency mapping. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1885 lines
74 KiB
TypeScript
1885 lines
74 KiB
TypeScript
import { PackageJsonWithMaybeDeps, JsPackageManager as JsPackageManager$1, PackageJson } from 'storybook/internal/common';
|
|
import { SupportedFrameworks, SupportedRenderers, PackageJson as PackageJson$1 } from 'storybook/internal/types';
|
|
import * as semver from 'semver';
|
|
import { Buffer } from 'node:buffer';
|
|
import { ChildProcess } from 'node:child_process';
|
|
import { Readable, Writable, Stream } from 'node:stream';
|
|
|
|
/** A list of all frameworks that are supported, but use a package outside the storybook monorepo */
|
|
type ExternalFramework = {
|
|
name: SupportedFrameworks;
|
|
packageName?: string;
|
|
frameworks?: string[];
|
|
renderer?: string;
|
|
};
|
|
declare const externalFrameworks: ExternalFramework[];
|
|
declare const SUPPORTED_RENDERERS: SupportedRenderers[];
|
|
declare enum ProjectType {
|
|
UNDETECTED = "UNDETECTED",
|
|
UNSUPPORTED = "UNSUPPORTED",
|
|
REACT = "REACT",
|
|
REACT_SCRIPTS = "REACT_SCRIPTS",
|
|
REACT_NATIVE = "REACT_NATIVE",
|
|
REACT_NATIVE_WEB = "REACT_NATIVE_WEB",
|
|
REACT_NATIVE_AND_RNW = "REACT_NATIVE_AND_RNW",
|
|
REACT_PROJECT = "REACT_PROJECT",
|
|
WEBPACK_REACT = "WEBPACK_REACT",
|
|
NEXTJS = "NEXTJS",
|
|
VUE3 = "VUE3",
|
|
NUXT = "NUXT",
|
|
ANGULAR = "ANGULAR",
|
|
EMBER = "EMBER",
|
|
WEB_COMPONENTS = "WEB_COMPONENTS",
|
|
HTML = "HTML",
|
|
QWIK = "QWIK",
|
|
PREACT = "PREACT",
|
|
SVELTE = "SVELTE",
|
|
SVELTEKIT = "SVELTEKIT",
|
|
SERVER = "SERVER",
|
|
NX = "NX",
|
|
SOLID = "SOLID"
|
|
}
|
|
declare enum CoreBuilder {
|
|
Webpack5 = "webpack5",
|
|
Vite = "vite"
|
|
}
|
|
declare enum CoreWebpackCompilers {
|
|
Babel = "babel",
|
|
SWC = "swc"
|
|
}
|
|
declare enum CommunityBuilder {
|
|
Rsbuild = "rsbuild"
|
|
}
|
|
declare const compilerNameToCoreCompiler: Record<string, CoreWebpackCompilers>;
|
|
declare const builderNameToCoreBuilder: Record<string, CoreBuilder>;
|
|
type Builder = CoreBuilder | (string & {});
|
|
declare enum SupportedLanguage {
|
|
JAVASCRIPT = "javascript",
|
|
TYPESCRIPT = "typescript"
|
|
}
|
|
type TemplateMatcher = {
|
|
files?: boolean[];
|
|
dependencies?: boolean[];
|
|
peerDependencies?: boolean[];
|
|
};
|
|
type TemplateConfiguration = {
|
|
preset: ProjectType;
|
|
/** Will be checked both against dependencies and devDependencies */
|
|
dependencies?: string[] | {
|
|
[dependency: string]: (version: string) => boolean;
|
|
};
|
|
peerDependencies?: string[] | {
|
|
[dependency: string]: (version: string) => boolean;
|
|
};
|
|
files?: string[];
|
|
matcherFunction: (matcher: TemplateMatcher) => boolean;
|
|
};
|
|
/**
|
|
* Configuration to match a storybook preset template.
|
|
*
|
|
* This has to be an array sorted in order of specificity/priority. Reason: both REACT and
|
|
* WEBPACK_REACT have react as dependency, therefore WEBPACK_REACT has to come first, as it's more
|
|
* specific.
|
|
*/
|
|
declare const supportedTemplates: TemplateConfiguration[];
|
|
declare const unsupportedTemplate: TemplateConfiguration;
|
|
declare const installableProjectTypes: string[];
|
|
|
|
declare function detectFrameworkPreset(packageJson?: PackageJsonWithMaybeDeps): ProjectType | null;
|
|
/**
|
|
* Attempts to detect which builder to use, by searching for a vite config file or webpack
|
|
* installation. If neither are found it will choose the default builder based on the project type.
|
|
*
|
|
* @returns CoreBuilder
|
|
*/
|
|
declare function detectBuilder(packageManager: JsPackageManager$1, projectType: ProjectType): Promise<any>;
|
|
declare function isStorybookInstantiated(configDir?: string): boolean;
|
|
declare function detectPnp(): Promise<boolean>;
|
|
declare function detectLanguage(packageManager: JsPackageManager$1): Promise<SupportedLanguage>;
|
|
declare function detect(packageManager: JsPackageManager$1, options?: {
|
|
force?: boolean;
|
|
html?: boolean;
|
|
}): Promise<ProjectType | null>;
|
|
|
|
declare function readFileAsJson(jsonPath: string, allowComments?: boolean): any;
|
|
declare const writeFileAsJson: (jsonPath: string, content: unknown) => boolean;
|
|
/**
|
|
* Detect if any babel dependencies need to be added to the project This is currently used by
|
|
* react-native generator
|
|
*
|
|
* @example
|
|
*
|
|
* ```ts
|
|
* const babelDependencies = await getBabelDependencies(
|
|
* packageManager,
|
|
* npmOptions,
|
|
* packageJson
|
|
* ); // you can then spread the result when using installDependencies
|
|
* installDependencies(npmOptions, [
|
|
* `@storybook/react@${storybookVersion}`,
|
|
* ...babelDependencies,
|
|
* ]);
|
|
* ```
|
|
*
|
|
* @param packageJson The current package.json so we can inspect its contents
|
|
* @returns Contains the packages and versions that need to be installed
|
|
*/
|
|
declare function getBabelDependencies(packageManager: JsPackageManager$1): Promise<string[]>;
|
|
declare function addToDevDependenciesIfNotPresent(packageJson: PackageJson, name: string, packageVersion: string): void;
|
|
declare function copyTemplate(templateRoot: string, destination?: string): void;
|
|
type CopyTemplateFilesOptions = {
|
|
packageManager: JsPackageManager$1;
|
|
templateLocation: SupportedFrameworks | SupportedRenderers;
|
|
language: SupportedLanguage;
|
|
commonAssetsDir?: string;
|
|
destination?: string;
|
|
features: string[];
|
|
};
|
|
declare const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder | CommunityBuilder>;
|
|
/**
|
|
* Return the installed version of a package, or the coerced version specifier from package.json if
|
|
* it's a dependency but not installed (e.g. in a fresh project)
|
|
*/
|
|
declare function getVersionSafe(packageManager: JsPackageManager$1, packageName: string): Promise<string | undefined>;
|
|
declare const cliStoriesTargetPath: () => Promise<"./src/stories" | "./stories">;
|
|
declare function copyTemplateFiles({ packageManager, templateLocation, language, destination, commonAssetsDir, features, }: CopyTemplateFilesOptions): Promise<void>;
|
|
declare function adjustTemplate(templatePath: string, templateData: Record<string, any>): Promise<void>;
|
|
declare function isNxProject(): Promise<string | undefined>;
|
|
declare function coerceSemver(version: string): semver.SemVer;
|
|
declare function hasStorybookDependencies(packageManager: JsPackageManager$1): boolean;
|
|
|
|
declare const ANGULAR_JSON_PATH = "angular.json";
|
|
declare const compoDocPreviewPrefix: string;
|
|
declare const promptForCompoDocs: () => Promise<boolean>;
|
|
declare class AngularJSON {
|
|
json: {
|
|
projects: Record<string, {
|
|
root: string;
|
|
projectType: string;
|
|
architect: Record<string, any>;
|
|
}>;
|
|
};
|
|
constructor();
|
|
get projects(): Record<string, {
|
|
root: string;
|
|
projectType: string;
|
|
architect: Record<string, any>;
|
|
}>;
|
|
get projectsWithoutStorybook(): string[];
|
|
get hasStorybookBuilder(): boolean;
|
|
get rootProject(): {
|
|
root: string;
|
|
projectType: string;
|
|
architect: Record<string, any>;
|
|
} | null;
|
|
getProjectSettingsByName(projectName: string): {
|
|
root: string;
|
|
projectType: string;
|
|
architect: Record<string, any>;
|
|
};
|
|
getProjectName(): Promise<any>;
|
|
addStorybookEntries({ angularProjectName, storybookFolder, useCompodoc, root, }: {
|
|
angularProjectName: string;
|
|
storybookFolder: string;
|
|
useCompodoc: boolean;
|
|
root: string;
|
|
}): void;
|
|
write(): void;
|
|
}
|
|
|
|
declare function getRendererDir(packageManager: JsPackageManager$1, renderer: SupportedFrameworks | SupportedRenderers): Promise<string>;
|
|
|
|
type StdioOption =
|
|
| 'pipe'
|
|
| 'overlapped'
|
|
| 'ipc'
|
|
| 'ignore'
|
|
| 'inherit'
|
|
| Stream
|
|
| number
|
|
| undefined;
|
|
|
|
type EncodingOption =
|
|
| 'utf8'
|
|
// eslint-disable-next-line unicorn/text-encoding-identifier-case
|
|
| 'utf-8'
|
|
| 'utf16le'
|
|
| 'utf-16le'
|
|
| 'ucs2'
|
|
| 'ucs-2'
|
|
| 'latin1'
|
|
| 'binary'
|
|
| 'ascii'
|
|
| 'hex'
|
|
| 'base64'
|
|
| 'base64url'
|
|
| 'buffer'
|
|
| null
|
|
| undefined;
|
|
type DefaultEncodingOption = 'utf8';
|
|
|
|
type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {
|
|
/**
|
|
Kill the spawned process when the parent process exits unless either:
|
|
- the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)
|
|
- the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
|
|
|
|
@default true
|
|
*/
|
|
readonly cleanup?: boolean;
|
|
|
|
/**
|
|
Prefer locally installed binaries when looking for a binary to execute.
|
|
|
|
If you `$ npm install foo`, you can then `execa('foo')`.
|
|
|
|
@default `true` with `$`, `false` otherwise
|
|
*/
|
|
readonly preferLocal?: boolean;
|
|
|
|
/**
|
|
Preferred path to find locally installed binaries in (use with `preferLocal`).
|
|
|
|
@default process.cwd()
|
|
*/
|
|
readonly localDir?: string | URL;
|
|
|
|
/**
|
|
Path to the Node.js executable to use in child processes.
|
|
|
|
This can be either an absolute path or a path relative to the `cwd` option.
|
|
|
|
Requires `preferLocal` to be `true`.
|
|
|
|
For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.
|
|
|
|
@default process.execPath
|
|
*/
|
|
readonly execPath?: string;
|
|
|
|
/**
|
|
Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.
|
|
|
|
If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.
|
|
|
|
@default true
|
|
*/
|
|
readonly buffer?: boolean;
|
|
|
|
/**
|
|
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
|
|
@default `inherit` with `$`, `pipe` otherwise
|
|
*/
|
|
readonly stdin?: StdioOption;
|
|
|
|
/**
|
|
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
|
|
@default 'pipe'
|
|
*/
|
|
readonly stdout?: StdioOption;
|
|
|
|
/**
|
|
Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).
|
|
|
|
@default 'pipe'
|
|
*/
|
|
readonly stderr?: StdioOption;
|
|
|
|
/**
|
|
Setting this to `false` resolves the promise with the error instead of rejecting it.
|
|
|
|
@default true
|
|
*/
|
|
readonly reject?: boolean;
|
|
|
|
/**
|
|
Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.
|
|
|
|
@default false
|
|
*/
|
|
readonly all?: boolean;
|
|
|
|
/**
|
|
Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.
|
|
|
|
@default true
|
|
*/
|
|
readonly stripFinalNewline?: boolean;
|
|
|
|
/**
|
|
Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
|
|
|
@default true
|
|
*/
|
|
readonly extendEnv?: boolean;
|
|
|
|
/**
|
|
Current working directory of the child process.
|
|
|
|
@default process.cwd()
|
|
*/
|
|
readonly cwd?: string | URL;
|
|
|
|
/**
|
|
Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.
|
|
|
|
@default process.env
|
|
*/
|
|
readonly env?: NodeJS.ProcessEnv;
|
|
|
|
/**
|
|
Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.
|
|
*/
|
|
readonly argv0?: string;
|
|
|
|
/**
|
|
Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
|
|
|
|
@default 'pipe'
|
|
*/
|
|
readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];
|
|
|
|
/**
|
|
Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:
|
|
- `json`: Uses `JSON.stringify()` and `JSON.parse()`.
|
|
- `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)
|
|
|
|
[More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)
|
|
|
|
@default 'json'
|
|
*/
|
|
readonly serialization?: 'json' | 'advanced';
|
|
|
|
/**
|
|
Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).
|
|
|
|
@default false
|
|
*/
|
|
readonly detached?: boolean;
|
|
|
|
/**
|
|
Sets the user identity of the process.
|
|
*/
|
|
readonly uid?: number;
|
|
|
|
/**
|
|
Sets the group identity of the process.
|
|
*/
|
|
readonly gid?: number;
|
|
|
|
/**
|
|
If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
|
|
|
We recommend against using this option since it is:
|
|
- not cross-platform, encouraging shell-specific syntax.
|
|
- slower, because of the additional shell interpretation.
|
|
- unsafe, potentially allowing command injection.
|
|
|
|
@default false
|
|
*/
|
|
readonly shell?: boolean | string;
|
|
|
|
/**
|
|
Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.
|
|
|
|
@default 'utf8'
|
|
*/
|
|
readonly encoding?: EncodingType;
|
|
|
|
/**
|
|
If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.
|
|
|
|
@default 0
|
|
*/
|
|
readonly timeout?: number;
|
|
|
|
/**
|
|
Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 100 MB.
|
|
|
|
@default 100_000_000
|
|
*/
|
|
readonly maxBuffer?: number;
|
|
|
|
/**
|
|
Signal value to be used when the spawned process will be killed.
|
|
|
|
@default 'SIGTERM'
|
|
*/
|
|
readonly killSignal?: string | number;
|
|
|
|
/**
|
|
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
|
|
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `true`.
|
|
|
|
@example
|
|
```
|
|
import {execa} from 'execa';
|
|
|
|
const abortController = new AbortController();
|
|
const subprocess = execa('node', [], {signal: abortController.signal});
|
|
|
|
setTimeout(() => {
|
|
abortController.abort();
|
|
}, 1000);
|
|
|
|
try {
|
|
await subprocess;
|
|
} catch (error) {
|
|
console.log(subprocess.killed); // true
|
|
console.log(error.isCanceled); // true
|
|
}
|
|
```
|
|
*/
|
|
readonly signal?: AbortSignal;
|
|
|
|
/**
|
|
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.
|
|
|
|
@default false
|
|
*/
|
|
readonly windowsVerbatimArguments?: boolean;
|
|
|
|
/**
|
|
On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.
|
|
|
|
@default true
|
|
*/
|
|
readonly windowsHide?: boolean;
|
|
|
|
/**
|
|
Print each command on `stderr` before executing it.
|
|
|
|
This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.
|
|
|
|
@default false
|
|
*/
|
|
readonly verbose?: boolean;
|
|
};
|
|
|
|
type StdoutStderrAll = string | Buffer | undefined;
|
|
|
|
type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {
|
|
/**
|
|
The file and arguments that were run, for logging purposes.
|
|
|
|
This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
*/
|
|
command: string;
|
|
|
|
/**
|
|
Same as `command` but escaped.
|
|
|
|
This is meant to be copy and pasted into a shell, for debugging purposes.
|
|
Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execaCommand()`.
|
|
*/
|
|
escapedCommand: string;
|
|
|
|
/**
|
|
The numeric exit code of the process that was run.
|
|
*/
|
|
exitCode: number;
|
|
|
|
/**
|
|
The output of the process on stdout.
|
|
*/
|
|
stdout: StdoutStderrType;
|
|
|
|
/**
|
|
The output of the process on stderr.
|
|
*/
|
|
stderr: StdoutStderrType;
|
|
|
|
/**
|
|
Whether the process failed to run.
|
|
*/
|
|
failed: boolean;
|
|
|
|
/**
|
|
Whether the process timed out.
|
|
*/
|
|
timedOut: boolean;
|
|
|
|
/**
|
|
Whether the process was killed.
|
|
*/
|
|
killed: boolean;
|
|
|
|
/**
|
|
The name of the signal that was used to terminate the process. For example, `SIGFPE`.
|
|
|
|
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.
|
|
*/
|
|
signal?: string;
|
|
|
|
/**
|
|
A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.
|
|
|
|
If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.
|
|
*/
|
|
signalDescription?: string;
|
|
|
|
/**
|
|
The `cwd` of the command if provided in the command options. Otherwise it is `process.cwd()`.
|
|
*/
|
|
cwd: string;
|
|
};
|
|
|
|
type ExecaSyncReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
} & ExecaReturnBase<StdoutStderrType>;
|
|
|
|
/**
|
|
Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.
|
|
|
|
The child process fails when:
|
|
- its exit code is not `0`
|
|
- it was killed with a signal
|
|
- timing out
|
|
- being canceled
|
|
- there's not enough memory or there are already too many child processes
|
|
*/
|
|
type ExecaReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
/**
|
|
The output of the process with `stdout` and `stderr` interleaved.
|
|
|
|
This is `undefined` if either:
|
|
- the `all` option is `false` (default value)
|
|
- `execaSync()` was used
|
|
*/
|
|
all?: StdoutStderrType;
|
|
|
|
/**
|
|
Whether the process was canceled.
|
|
|
|
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.
|
|
*/
|
|
isCanceled: boolean;
|
|
} & ExecaSyncReturnValue<StdoutStderrType>;
|
|
|
|
type ExecaSyncError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
/**
|
|
Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.
|
|
|
|
The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.
|
|
*/
|
|
message: string;
|
|
|
|
/**
|
|
This is the same as the `message` property except it does not include the child process stdout/stderr.
|
|
*/
|
|
shortMessage: string;
|
|
|
|
/**
|
|
Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.
|
|
|
|
This is `undefined` unless the child process exited due to an `error` event or a timeout.
|
|
*/
|
|
originalMessage?: string;
|
|
} & Error & ExecaReturnBase<StdoutStderrType>;
|
|
|
|
type ExecaError<StdoutStderrType extends StdoutStderrAll = string> = {
|
|
/**
|
|
The output of the process with `stdout` and `stderr` interleaved.
|
|
|
|
This is `undefined` if either:
|
|
- the `all` option is `false` (default value)
|
|
- `execaSync()` was used
|
|
*/
|
|
all?: StdoutStderrType;
|
|
|
|
/**
|
|
Whether the process was canceled.
|
|
*/
|
|
isCanceled: boolean;
|
|
} & ExecaSyncError<StdoutStderrType>;
|
|
|
|
type KillOptions = {
|
|
/**
|
|
Milliseconds to wait for the child process to terminate before sending `SIGKILL`.
|
|
|
|
Can be disabled with `false`.
|
|
|
|
@default 5000
|
|
*/
|
|
forceKillAfterTimeout?: number | false;
|
|
};
|
|
|
|
type ExecaChildPromise<StdoutStderrType extends StdoutStderrAll> = {
|
|
/**
|
|
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
|
|
|
|
This is `undefined` if either:
|
|
- the `all` option is `false` (the default value)
|
|
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
|
|
*/
|
|
all?: Readable;
|
|
|
|
catch<ResultType = never>(
|
|
onRejected?: (reason: ExecaError<StdoutStderrType>) => ResultType | PromiseLike<ResultType>
|
|
): Promise<ExecaReturnValue<StdoutStderrType> | ResultType>;
|
|
|
|
/**
|
|
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`. Note that this graceful termination does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events) (`SIGKILL` and `SIGTERM` has the same effect of force-killing the process immediately.) If you want to achieve graceful termination on Windows, you have to use other means, such as [`taskkill`](https://github.com/sindresorhus/taskkill).
|
|
*/
|
|
kill(signal?: string, options?: KillOptions): void;
|
|
|
|
/**
|
|
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This used to be preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. But now this is deprecated and you should either use `.kill()` or the `signal` option when creating the child process.
|
|
*/
|
|
cancel(): void;
|
|
|
|
/**
|
|
[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process's `stdout` to `target`, which can be:
|
|
- Another `execa()` return value
|
|
- A writable stream
|
|
- A file path string
|
|
|
|
If the `target` is another `execa()` return value, it is returned. Otherwise, the original `execa()` return value is returned. This allows chaining `pipeStdout()` then `await`ing the final result.
|
|
|
|
The `stdout` option] must be kept as `pipe`, its default value.
|
|
*/
|
|
pipeStdout?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
pipeStdout?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
|
|
/**
|
|
Like `pipeStdout()` but piping the child process's `stderr` instead.
|
|
|
|
The `stderr` option must be kept as `pipe`, its default value.
|
|
*/
|
|
pipeStderr?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
pipeStderr?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
|
|
/**
|
|
Combines both `pipeStdout()` and `pipeStderr()`.
|
|
|
|
Either the `stdout` option or the `stderr` option must be kept as `pipe`, their default value. Also, the `all` option must be set to `true`.
|
|
*/
|
|
pipeAll?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;
|
|
pipeAll?(target: Writable | string): ExecaChildProcess<StdoutStderrType>;
|
|
};
|
|
|
|
type ExecaChildProcess<StdoutStderrType extends StdoutStderrAll = string> = ChildProcess &
|
|
ExecaChildPromise<StdoutStderrType> &
|
|
Promise<ExecaReturnValue<StdoutStderrType>>;
|
|
|
|
type PackageJsonWithDepsAndDevDeps = PackageJson$1 & Required<Pick<PackageJson$1, 'dependencies' | 'devDependencies'>>;
|
|
|
|
type PackageMetadata = {
|
|
version: string;
|
|
location?: string;
|
|
reasons?: string[];
|
|
};
|
|
type InstallationMetadata = {
|
|
dependencies: Record<string, PackageMetadata[]>;
|
|
duplicatedDependencies: Record<string, string[]>;
|
|
infoCommand: string;
|
|
dedupeCommand: string;
|
|
};
|
|
|
|
type PackageManagerName = 'npm' | 'yarn1' | 'yarn2' | 'pnpm' | 'bun';
|
|
interface JsPackageManagerOptions {
|
|
cwd?: string;
|
|
configDir?: string;
|
|
storiesPaths?: string[];
|
|
}
|
|
type PackageJsonInfo = {
|
|
packageJsonPath: string;
|
|
operationDir: string;
|
|
packageJson: PackageJsonWithDepsAndDevDeps;
|
|
};
|
|
declare abstract class JsPackageManager {
|
|
#private;
|
|
abstract readonly type: PackageManagerName;
|
|
/** The path to the primary package.json file (contains the `storybook` dependency). */
|
|
readonly primaryPackageJson: PackageJsonInfo;
|
|
/** The paths to all package.json files in the project root. */
|
|
packageJsonPaths: string[];
|
|
/**
|
|
* The path to the Storybook instance directory. This is used to find the primary package.json
|
|
* file in a repository.
|
|
*/
|
|
readonly instanceDir: string;
|
|
/** The current working directory. */
|
|
protected readonly cwd: string;
|
|
/** Cache for latest version results to avoid repeated network calls. */
|
|
static readonly latestVersionCache: Map<string, string | null>;
|
|
/** Cache for installed version results to avoid repeated file system calls. */
|
|
static readonly installedVersionCache: Map<string, string | null>;
|
|
constructor(options?: JsPackageManagerOptions);
|
|
/** Runs arbitrary package scripts. */
|
|
abstract getRunCommand(command: string): string;
|
|
/**
|
|
* Run a command from a local or remote. Fetches a package from the registry without installing it
|
|
* as a dependency, hotloads it, and runs whatever default command binary it exposes.
|
|
*/
|
|
abstract getRemoteRunCommand(pkg: string, args: string[], specifier?: string): string;
|
|
/** Get the package.json file for a given module. */
|
|
abstract getModulePackageJSON(packageName: string): PackageJson$1 | null;
|
|
isStorybookInMonorepo(): boolean;
|
|
installDependencies(options?: {
|
|
force?: boolean;
|
|
}): Promise<void>;
|
|
dedupeDependencies(options?: {
|
|
force?: boolean;
|
|
}): Promise<void>;
|
|
/** Read the `package.json` file available in the provided directory */
|
|
static getPackageJson(packageJsonPath: string): PackageJsonWithDepsAndDevDeps;
|
|
writePackageJson(packageJson: PackageJson$1, directory?: string): void;
|
|
getAllDependencies(): Record<string, string>;
|
|
isDependencyInstalled(dependency: string): boolean;
|
|
/**
|
|
* Add dependencies to a project using `yarn add` or `npm install`.
|
|
*
|
|
* @example
|
|
*
|
|
* ```ts
|
|
* addDependencies(options, [
|
|
* `@storybook/react@${storybookVersion}`,
|
|
* `@storybook/addon-links@${linksVersion}`,
|
|
* ]);
|
|
* ```
|
|
*
|
|
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies`
|
|
* which we use to determine how we install packages.
|
|
* @param {Array} dependencies Contains a list of packages to add.
|
|
*/
|
|
addDependencies(options: {
|
|
skipInstall: true;
|
|
type: 'dependencies' | 'devDependencies' | 'peerDependencies';
|
|
writeOutputToFile?: boolean;
|
|
packageJsonInfo?: PackageJsonInfo;
|
|
} | {
|
|
skipInstall?: false;
|
|
type: 'dependencies' | 'devDependencies';
|
|
writeOutputToFile?: boolean;
|
|
packageJsonInfo?: PackageJsonInfo;
|
|
}, dependencies: string[]): Promise<void | ExecaChildProcess>;
|
|
/**
|
|
* Removing dependencies from the package.json file, which is found first starting from the
|
|
* instance root. The method does not run a package manager install like `npm install`.
|
|
*
|
|
* @example
|
|
*
|
|
* ```ts
|
|
* removeDependencies([`@storybook/react`]);
|
|
* ```
|
|
*
|
|
* @param dependencies Contains a list of packages to remove.
|
|
*/
|
|
removeDependencies(dependencies: string[]): Promise<void>;
|
|
/**
|
|
* Return an array of strings matching following format: `<package_name>@<package_latest_version>`
|
|
*
|
|
* For packages in the storybook monorepo, when the latest version is equal to the version of the
|
|
* current CLI the version is not added to the string.
|
|
*
|
|
* When a package is in the monorepo, and the version is not equal to the CLI version, the version
|
|
* is taken from the versions.ts file and added to the string.
|
|
*
|
|
* @param packages
|
|
*/
|
|
getVersionedPackages(packages: string[]): Promise<string[]>;
|
|
/**
|
|
* Return an array of string standing for the latest version of the input packages. To be able to
|
|
* identify which version goes with which package the order of the input array is keep.
|
|
*
|
|
* @param packageNames
|
|
*/
|
|
getVersions(...packageNames: string[]): Promise<string[]>;
|
|
/**
|
|
* Return the latest version of the input package available on npmjs registry. If constraint are
|
|
* provided it return the latest version matching the constraints.
|
|
*
|
|
* For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file
|
|
* directly
|
|
*
|
|
* @param packageName The name of the package
|
|
* @param constraint A valid semver constraint, example: '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
|
|
*/
|
|
getVersion(packageName: string, constraint?: string): Promise<string>;
|
|
/**
|
|
* Get the latest version of the package available on npmjs.com. If constraint is set then it
|
|
* returns a version satisfying it, otherwise the latest version available is returned.
|
|
*
|
|
* @param packageName Name of the package
|
|
* @param constraint Version range to use to constraint the returned version
|
|
*/
|
|
latestVersion(packageName: string, constraint?: string): Promise<string | null>;
|
|
/**
|
|
* Clear the latest version cache. Useful for testing or when you want to refresh version
|
|
* information.
|
|
*
|
|
* @param packageName Optional package name to clear only specific entries. If not provided,
|
|
* clears all cache.
|
|
*/
|
|
static clearLatestVersionCache(packageName?: string): void;
|
|
/**
|
|
* Clear the installed version cache for a specific package or all packages.
|
|
*
|
|
* @param packageName Optional package name to clear from cache. If not provided, clears all.
|
|
*/
|
|
clearInstalledVersionCache(packageName?: string): void;
|
|
/**
|
|
* Clear both the latest version cache and installed version cache. This should be called after
|
|
* any operation that modifies dependencies.
|
|
*/
|
|
clearAllVersionCaches(): void;
|
|
addStorybookCommandInScripts(options?: {
|
|
port: number;
|
|
preCommand?: string;
|
|
}): void;
|
|
addScripts(scripts: Record<string, string>): void;
|
|
addPackageResolutions(versions: Record<string, string>): void;
|
|
protected abstract runInstall(options?: {
|
|
force?: boolean;
|
|
}): ExecaChildProcess;
|
|
protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean, writeOutputToFile?: boolean): ExecaChildProcess;
|
|
protected abstract getResolutions(packageJson: PackageJson$1, versions: Record<string, string>): Record<string, any>;
|
|
/**
|
|
* Get the latest or all versions of the input package available on npmjs.com
|
|
*
|
|
* @param packageName Name of the package
|
|
* @param fetchAllVersions Should return
|
|
*/
|
|
protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
|
|
abstract getRegistryURL(): Promise<string | undefined>;
|
|
abstract runInternalCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
|
|
abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): string;
|
|
abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
|
|
abstract findInstallations(pattern?: string[], options?: {
|
|
depth: number;
|
|
}): Promise<InstallationMetadata | undefined>;
|
|
abstract parseErrorFromLogs(logs?: string): string;
|
|
executeCommandSync({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
|
|
command: string;
|
|
args: string[];
|
|
cwd?: string;
|
|
ignoreError?: boolean;
|
|
}): string;
|
|
/**
|
|
* Execute a command asynchronously and return the execa process. This allows you to hook into
|
|
* stdout/stderr streams and monitor the process.
|
|
*
|
|
* @example Const process = packageManager.executeCommand({ command: 'npm', args: ['install'] });
|
|
* process.stdout?.on('data', (data) => console.log(data.toString())); const result = await
|
|
* process;
|
|
*/
|
|
executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
|
|
command: string;
|
|
args: string[];
|
|
cwd?: string;
|
|
ignoreError?: boolean;
|
|
}): ExecaChildProcess;
|
|
/** Returns the installed (within node_modules or pnp zip) version of a specified package */
|
|
getInstalledVersion(packageName: string): Promise<string | null>;
|
|
isPackageInstalled(packageName: string): Promise<boolean>;
|
|
/**
|
|
* Searches for a dependency/devDependency in all package.json files and returns the version of
|
|
* the dependency.
|
|
*/
|
|
getDependencyVersion(dependency: string): string | null;
|
|
static hasStorybookDependency(packageJsonPath: string): boolean;
|
|
static hasAnyStorybookDependency(packageJsonPath: string): boolean;
|
|
/** List all package.json files starting from the given directory and stopping at the project root. */
|
|
static listAllPackageJsonPaths(instanceDir: string, storiesPaths?: string[]): string[];
|
|
static getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo;
|
|
}
|
|
|
|
type NpmOptions = Parameters<JsPackageManager['addDependencies']>[0];
|
|
|
|
declare const SUPPORTED_ESLINT_EXTENSIONS: string[];
|
|
declare const findEslintFile: (instanceDir: string) => Promise<string | undefined>;
|
|
declare const configureFlatConfig: (code: string) => Promise<string>;
|
|
declare function extractEslintInfo(packageManager: JsPackageManager$1): Promise<{
|
|
hasEslint: boolean;
|
|
isStorybookPluginInstalled: boolean;
|
|
eslintConfigFile: string | undefined;
|
|
unsupportedExtension?: string;
|
|
isFlatConfig: boolean;
|
|
}>;
|
|
declare const normalizeExtends: (existingExtends: any) => string[];
|
|
declare function configureEslintPlugin({ eslintConfigFile, packageManager, isFlatConfig, }: {
|
|
eslintConfigFile: string | undefined;
|
|
packageManager: JsPackageManager$1;
|
|
isFlatConfig: boolean;
|
|
}): Promise<void>;
|
|
declare const suggestESLintPlugin: () => Promise<boolean>;
|
|
|
|
type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
|
|
|
declare namespace util {
|
|
type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
|
export type isAny<T> = 0 extends 1 & T ? true : false;
|
|
export const assertEqual: <A, B>(val: AssertEqual<A, B>) => AssertEqual<A, B>;
|
|
export function assertIs<T>(_arg: T): void;
|
|
export function assertNever(_x: never): never;
|
|
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
|
export type MakePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
|
export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
|
|
export const getValidEnumValues: (obj: any) => any[];
|
|
export const objectValues: (obj: any) => any[];
|
|
export const objectKeys: ObjectConstructor["keys"];
|
|
export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
|
|
export type identity<T> = objectUtil.identity<T>;
|
|
export type flatten<T> = objectUtil.flatten<T>;
|
|
export type noUndefined<T> = T extends undefined ? never : T;
|
|
export const isInteger: NumberConstructor["isInteger"];
|
|
export function joinValues<T extends any[]>(array: T, separator?: string): string;
|
|
export const jsonStringifyReplacer: (_: string, value: any) => any;
|
|
export { };
|
|
}
|
|
declare namespace objectUtil {
|
|
export type MergeShapes<U, V> = keyof U & keyof V extends never ? U & V : {
|
|
[k in Exclude<keyof U, keyof V>]: U[k];
|
|
} & V;
|
|
type optionalKeys<T extends object> = {
|
|
[k in keyof T]: undefined extends T[k] ? k : never;
|
|
}[keyof T];
|
|
type requiredKeys<T extends object> = {
|
|
[k in keyof T]: undefined extends T[k] ? never : k;
|
|
}[keyof T];
|
|
export type addQuestionMarks<T extends object, _O = any> = {
|
|
[K in requiredKeys<T>]: T[K];
|
|
} & {
|
|
[K in optionalKeys<T>]?: T[K];
|
|
} & {
|
|
[k in keyof T]?: unknown;
|
|
};
|
|
export type identity<T> = T;
|
|
export type flatten<T> = identity<{
|
|
[k in keyof T]: T[k];
|
|
}>;
|
|
export type noNeverKeys<T> = {
|
|
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
|
}[keyof T];
|
|
export type noNever<T> = identity<{
|
|
[k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
|
}>;
|
|
export const mergeShapes: <U, T>(first: U, second: T) => T & U;
|
|
export type extendShape<A extends object, B extends object> = 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 { };
|
|
}
|
|
declare const ZodParsedType: {
|
|
string: "string";
|
|
number: "number";
|
|
bigint: "bigint";
|
|
boolean: "boolean";
|
|
symbol: "symbol";
|
|
undefined: "undefined";
|
|
object: "object";
|
|
function: "function";
|
|
map: "map";
|
|
nan: "nan";
|
|
integer: "integer";
|
|
float: "float";
|
|
date: "date";
|
|
null: "null";
|
|
array: "array";
|
|
unknown: "unknown";
|
|
promise: "promise";
|
|
void: "void";
|
|
never: "never";
|
|
set: "set";
|
|
};
|
|
type ZodParsedType = keyof typeof ZodParsedType;
|
|
|
|
type allKeys<T> = T extends any ? keyof T : never;
|
|
type typeToFlattenedError<T, U = string> = {
|
|
formErrors: U[];
|
|
fieldErrors: {
|
|
[P in allKeys<T>]?: U[];
|
|
};
|
|
};
|
|
declare const ZodIssueCode: {
|
|
invalid_type: "invalid_type";
|
|
invalid_literal: "invalid_literal";
|
|
custom: "custom";
|
|
invalid_union: "invalid_union";
|
|
invalid_union_discriminator: "invalid_union_discriminator";
|
|
invalid_enum_value: "invalid_enum_value";
|
|
unrecognized_keys: "unrecognized_keys";
|
|
invalid_arguments: "invalid_arguments";
|
|
invalid_return_type: "invalid_return_type";
|
|
invalid_date: "invalid_date";
|
|
invalid_string: "invalid_string";
|
|
too_small: "too_small";
|
|
too_big: "too_big";
|
|
invalid_intersection_types: "invalid_intersection_types";
|
|
not_multiple_of: "not_multiple_of";
|
|
not_finite: "not_finite";
|
|
};
|
|
type ZodIssueCode = keyof typeof ZodIssueCode;
|
|
type ZodIssueBase = {
|
|
path: (string | number)[];
|
|
message?: string;
|
|
};
|
|
interface ZodInvalidTypeIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_type;
|
|
expected: ZodParsedType;
|
|
received: ZodParsedType;
|
|
}
|
|
interface ZodInvalidLiteralIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_literal;
|
|
expected: unknown;
|
|
received: unknown;
|
|
}
|
|
interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.unrecognized_keys;
|
|
keys: string[];
|
|
}
|
|
interface ZodInvalidUnionIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_union;
|
|
unionErrors: ZodError[];
|
|
}
|
|
interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_union_discriminator;
|
|
options: Primitive[];
|
|
}
|
|
interface ZodInvalidEnumValueIssue extends ZodIssueBase {
|
|
received: string | number;
|
|
code: typeof ZodIssueCode.invalid_enum_value;
|
|
options: (string | number)[];
|
|
}
|
|
interface ZodInvalidArgumentsIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_arguments;
|
|
argumentsError: ZodError;
|
|
}
|
|
interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_return_type;
|
|
returnTypeError: ZodError;
|
|
}
|
|
interface ZodInvalidDateIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_date;
|
|
}
|
|
type StringValidation = "email" | "url" | "emoji" | "uuid" | "nanoid" | "regex" | "cuid" | "cuid2" | "ulid" | "datetime" | "date" | "time" | "duration" | "ip" | "cidr" | "base64" | "jwt" | "base64url" | {
|
|
includes: string;
|
|
position?: number;
|
|
} | {
|
|
startsWith: string;
|
|
} | {
|
|
endsWith: string;
|
|
};
|
|
interface ZodInvalidStringIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_string;
|
|
validation: StringValidation;
|
|
}
|
|
interface ZodTooSmallIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.too_small;
|
|
minimum: number | bigint;
|
|
inclusive: boolean;
|
|
exact?: boolean;
|
|
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
}
|
|
interface ZodTooBigIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.too_big;
|
|
maximum: number | bigint;
|
|
inclusive: boolean;
|
|
exact?: boolean;
|
|
type: "array" | "string" | "number" | "set" | "date" | "bigint";
|
|
}
|
|
interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.invalid_intersection_types;
|
|
}
|
|
interface ZodNotMultipleOfIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.not_multiple_of;
|
|
multipleOf: number | bigint;
|
|
}
|
|
interface ZodNotFiniteIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.not_finite;
|
|
}
|
|
interface ZodCustomIssue extends ZodIssueBase {
|
|
code: typeof ZodIssueCode.custom;
|
|
params?: {
|
|
[k: string]: any;
|
|
};
|
|
}
|
|
type ZodIssueOptionalMessage = ZodInvalidTypeIssue | ZodInvalidLiteralIssue | ZodUnrecognizedKeysIssue | ZodInvalidUnionIssue | ZodInvalidUnionDiscriminatorIssue | ZodInvalidEnumValueIssue | ZodInvalidArgumentsIssue | ZodInvalidReturnTypeIssue | ZodInvalidDateIssue | ZodInvalidStringIssue | ZodTooSmallIssue | ZodTooBigIssue | ZodInvalidIntersectionTypesIssue | ZodNotMultipleOfIssue | ZodNotFiniteIssue | ZodCustomIssue;
|
|
type ZodIssue = ZodIssueOptionalMessage & {
|
|
fatal?: boolean;
|
|
message: string;
|
|
};
|
|
type recursiveZodFormattedError<T> = T extends [any, ...any[]] ? {
|
|
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
} : T extends any[] ? {
|
|
[k: number]: ZodFormattedError<T[number]>;
|
|
} : T extends object ? {
|
|
[K in keyof T]?: ZodFormattedError<T[K]>;
|
|
} : unknown;
|
|
type ZodFormattedError<T, U = string> = {
|
|
_errors: U[];
|
|
} & recursiveZodFormattedError<NonNullable<T>>;
|
|
declare class ZodError<T = any> extends Error {
|
|
issues: ZodIssue[];
|
|
get errors(): ZodIssue[];
|
|
constructor(issues: ZodIssue[]);
|
|
format(): ZodFormattedError<T>;
|
|
format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
|
|
static create: (issues: ZodIssue[]) => ZodError<any>;
|
|
static assert(value: unknown): asserts value is ZodError;
|
|
toString(): string;
|
|
get message(): string;
|
|
get isEmpty(): boolean;
|
|
addIssue: (sub: ZodIssue) => void;
|
|
addIssues: (subs?: ZodIssue[]) => void;
|
|
flatten(): typeToFlattenedError<T>;
|
|
flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
|
|
get formErrors(): typeToFlattenedError<T, string>;
|
|
}
|
|
type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
|
|
type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
path?: (string | number)[];
|
|
fatal?: boolean;
|
|
};
|
|
type ErrorMapCtx = {
|
|
defaultError: string;
|
|
data: any;
|
|
};
|
|
type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => {
|
|
message: string;
|
|
};
|
|
|
|
type ParseParams = {
|
|
path: (string | number)[];
|
|
errorMap: ZodErrorMap;
|
|
async: boolean;
|
|
};
|
|
type ParsePathComponent = string | number;
|
|
type ParsePath = ParsePathComponent[];
|
|
interface ParseContext {
|
|
readonly common: {
|
|
readonly issues: ZodIssue[];
|
|
readonly contextualErrorMap?: ZodErrorMap;
|
|
readonly async: boolean;
|
|
};
|
|
readonly path: ParsePath;
|
|
readonly schemaErrorMap?: ZodErrorMap;
|
|
readonly parent: ParseContext | null;
|
|
readonly data: any;
|
|
readonly parsedType: ZodParsedType;
|
|
}
|
|
type ParseInput = {
|
|
data: any;
|
|
path: (string | number)[];
|
|
parent: ParseContext;
|
|
};
|
|
declare class ParseStatus {
|
|
value: "aborted" | "dirty" | "valid";
|
|
dirty(): void;
|
|
abort(): void;
|
|
static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
|
|
static mergeObjectAsync(status: ParseStatus, pairs: {
|
|
key: ParseReturnType<any>;
|
|
value: ParseReturnType<any>;
|
|
}[]): Promise<SyncParseReturnType<any>>;
|
|
static mergeObjectSync(status: ParseStatus, pairs: {
|
|
key: SyncParseReturnType<any>;
|
|
value: SyncParseReturnType<any>;
|
|
alwaysSet?: boolean;
|
|
}[]): SyncParseReturnType;
|
|
}
|
|
type INVALID = {
|
|
status: "aborted";
|
|
};
|
|
declare const INVALID: INVALID;
|
|
type DIRTY<T> = {
|
|
status: "dirty";
|
|
value: T;
|
|
};
|
|
declare const DIRTY: <T>(value: T) => DIRTY<T>;
|
|
type OK<T> = {
|
|
status: "valid";
|
|
value: T;
|
|
};
|
|
declare const OK: <T>(value: T) => OK<T>;
|
|
type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
|
type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
|
|
type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
|
|
|
|
declare namespace enumUtil {
|
|
type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
|
|
type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
|
|
type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never] ? Tuple : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
|
|
type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
|
|
export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
|
|
export { };
|
|
}
|
|
|
|
declare namespace errorUtil {
|
|
type ErrMessage = string | {
|
|
message?: string;
|
|
};
|
|
const errToObj: (message?: ErrMessage) => {
|
|
message?: string | undefined;
|
|
};
|
|
const toString: (message?: ErrMessage) => string | undefined;
|
|
}
|
|
|
|
declare namespace partialUtil {
|
|
type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape> ? ZodObject<{
|
|
[k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>>;
|
|
}, T["_def"]["unknownKeys"], T["_def"]["catchall"]> : T extends ZodArray<infer Type, infer Card> ? ZodArray<DeepPartial<Type>, Card> : T extends ZodOptional<infer Type> ? ZodOptional<DeepPartial<Type>> : T extends ZodNullable<infer Type> ? ZodNullable<DeepPartial<Type>> : T extends ZodTuple<infer Items> ? {
|
|
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
|
} extends infer PI ? PI extends ZodTupleItems ? ZodTuple<PI> : never : never : T;
|
|
}
|
|
|
|
/**
|
|
* The Standard Schema interface.
|
|
*/
|
|
type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
/**
|
|
* The Standard Schema properties.
|
|
*/
|
|
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
};
|
|
declare namespace StandardSchemaV1 {
|
|
/**
|
|
* The Standard Schema properties interface.
|
|
*/
|
|
export interface Props<Input = unknown, Output = Input> {
|
|
/**
|
|
* The version number of the standard.
|
|
*/
|
|
readonly version: 1;
|
|
/**
|
|
* The vendor name of the schema library.
|
|
*/
|
|
readonly vendor: string;
|
|
/**
|
|
* Validates unknown input values.
|
|
*/
|
|
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
/**
|
|
* Inferred types associated with the schema.
|
|
*/
|
|
readonly types?: Types<Input, Output> | undefined;
|
|
}
|
|
/**
|
|
* The result interface of the validate function.
|
|
*/
|
|
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
/**
|
|
* The result interface if validation succeeds.
|
|
*/
|
|
export interface SuccessResult<Output> {
|
|
/**
|
|
* The typed output value.
|
|
*/
|
|
readonly value: Output;
|
|
/**
|
|
* The non-existent issues.
|
|
*/
|
|
readonly issues?: undefined;
|
|
}
|
|
/**
|
|
* The result interface if validation fails.
|
|
*/
|
|
export interface FailureResult {
|
|
/**
|
|
* The issues of failed validation.
|
|
*/
|
|
readonly issues: ReadonlyArray<Issue>;
|
|
}
|
|
/**
|
|
* The issue interface of the failure output.
|
|
*/
|
|
export interface Issue {
|
|
/**
|
|
* The error message of the issue.
|
|
*/
|
|
readonly message: string;
|
|
/**
|
|
* The path of the issue, if any.
|
|
*/
|
|
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
}
|
|
/**
|
|
* The path segment interface of the issue.
|
|
*/
|
|
export interface PathSegment {
|
|
/**
|
|
* The key representing a path segment.
|
|
*/
|
|
readonly key: PropertyKey;
|
|
}
|
|
/**
|
|
* The Standard Schema types interface.
|
|
*/
|
|
export interface Types<Input = unknown, Output = Input> {
|
|
/**
|
|
* The input type of the schema.
|
|
*/
|
|
readonly input: Input;
|
|
/**
|
|
* The output type of the schema.
|
|
*/
|
|
readonly output: Output;
|
|
}
|
|
/**
|
|
* Infers the input type of a Standard Schema.
|
|
*/
|
|
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
/**
|
|
* Infers the output type of a Standard Schema.
|
|
*/
|
|
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
export { };
|
|
}
|
|
|
|
interface RefinementCtx {
|
|
addIssue: (arg: IssueData) => void;
|
|
path: (string | number)[];
|
|
}
|
|
type ZodRawShape = {
|
|
[k: string]: ZodTypeAny;
|
|
};
|
|
type ZodTypeAny = ZodType<any, any, any>;
|
|
type TypeOf<T extends ZodType<any, any, any>> = T["_output"];
|
|
type input<T extends ZodType<any, any, any>> = T["_input"];
|
|
type output<T extends ZodType<any, any, any>> = T["_output"];
|
|
|
|
type CustomErrorParams = Partial<util.Omit<ZodCustomIssue, "code">>;
|
|
interface ZodTypeDef {
|
|
errorMap?: ZodErrorMap;
|
|
description?: string;
|
|
}
|
|
type RawCreateParams = {
|
|
errorMap?: ZodErrorMap;
|
|
invalid_type_error?: string;
|
|
required_error?: string;
|
|
message?: string;
|
|
description?: string;
|
|
} | undefined;
|
|
type SafeParseSuccess<Output> = {
|
|
success: true;
|
|
data: Output;
|
|
error?: never;
|
|
};
|
|
type SafeParseError<Input> = {
|
|
success: false;
|
|
error: ZodError<Input>;
|
|
data?: never;
|
|
};
|
|
type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
|
|
declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
|
|
readonly _type: Output;
|
|
readonly _output: Output;
|
|
readonly _input: Input;
|
|
readonly _def: Def;
|
|
get description(): string | undefined;
|
|
"~standard": StandardSchemaV1.Props<Input, Output>;
|
|
abstract _parse(input: ParseInput): ParseReturnType<Output>;
|
|
_getType(input: ParseInput): string;
|
|
_getOrReturnCtx(input: ParseInput, ctx?: ParseContext | undefined): ParseContext;
|
|
_processInputParams(input: ParseInput): {
|
|
status: ParseStatus;
|
|
ctx: ParseContext;
|
|
};
|
|
_parseSync(input: ParseInput): SyncParseReturnType<Output>;
|
|
_parseAsync(input: ParseInput): AsyncParseReturnType<Output>;
|
|
parse(data: unknown, params?: Partial<ParseParams>): Output;
|
|
safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output>;
|
|
"~validate"(data: unknown): StandardSchemaV1.Result<Output> | Promise<StandardSchemaV1.Result<Output>>;
|
|
parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>;
|
|
safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
|
|
/** Alias of safeParseAsync */
|
|
spa: (data: unknown, params?: Partial<ParseParams>) => Promise<SafeParseReturnType<Input, Output>>;
|
|
refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, Input>;
|
|
refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
|
|
refinement<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, RefinedOutput, Input>;
|
|
refinement(check: (arg: Output) => boolean, refinementData: IssueData | ((arg: Output, ctx: RefinementCtx) => IssueData)): ZodEffects<this, Output, Input>;
|
|
_refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
|
|
superRefine<RefinedOutput extends Output>(refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput): ZodEffects<this, RefinedOutput, Input>;
|
|
superRefine(refinement: (arg: Output, ctx: RefinementCtx) => void): ZodEffects<this, Output, Input>;
|
|
superRefine(refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>): ZodEffects<this, Output, Input>;
|
|
constructor(def: Def);
|
|
optional(): ZodOptional<this>;
|
|
nullable(): ZodNullable<this>;
|
|
nullish(): ZodOptional<ZodNullable<this>>;
|
|
array(): ZodArray<this>;
|
|
promise(): ZodPromise<this>;
|
|
or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>;
|
|
and<T extends ZodTypeAny>(incoming: T): ZodIntersection<this, T>;
|
|
transform<NewOut>(transform: (arg: Output, ctx: RefinementCtx) => NewOut | Promise<NewOut>): ZodEffects<this, NewOut>;
|
|
default(def: util.noUndefined<Input>): ZodDefault<this>;
|
|
default(def: () => util.noUndefined<Input>): ZodDefault<this>;
|
|
brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
|
|
catch(def: Output): ZodCatch<this>;
|
|
catch(def: (ctx: {
|
|
error: ZodError;
|
|
input: Input;
|
|
}) => Output): ZodCatch<this>;
|
|
describe(description: string): this;
|
|
pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
|
|
readonly(): ZodReadonly<this>;
|
|
isOptional(): boolean;
|
|
isNullable(): boolean;
|
|
}
|
|
type ZodNumberCheck = {
|
|
kind: "min";
|
|
value: number;
|
|
inclusive: boolean;
|
|
message?: string;
|
|
} | {
|
|
kind: "max";
|
|
value: number;
|
|
inclusive: boolean;
|
|
message?: string;
|
|
} | {
|
|
kind: "int";
|
|
message?: string;
|
|
} | {
|
|
kind: "multipleOf";
|
|
value: number;
|
|
message?: string;
|
|
} | {
|
|
kind: "finite";
|
|
message?: string;
|
|
};
|
|
interface ZodNumberDef extends ZodTypeDef {
|
|
checks: ZodNumberCheck[];
|
|
typeName: ZodFirstPartyTypeKind.ZodNumber;
|
|
coerce: boolean;
|
|
}
|
|
declare class ZodNumber extends ZodType<number, ZodNumberDef, number> {
|
|
_parse(input: ParseInput): ParseReturnType<number>;
|
|
static create: (params?: RawCreateParams & {
|
|
coerce?: boolean;
|
|
}) => ZodNumber;
|
|
gte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
|
|
min: (value: number, message?: errorUtil.ErrMessage) => ZodNumber;
|
|
gt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
|
|
lte(value: number, message?: errorUtil.ErrMessage): ZodNumber;
|
|
max: (value: number, message?: errorUtil.ErrMessage) => ZodNumber;
|
|
lt(value: number, message?: errorUtil.ErrMessage): ZodNumber;
|
|
protected setLimit(kind: "min" | "max", value: number, inclusive: boolean, message?: string): ZodNumber;
|
|
_addCheck(check: ZodNumberCheck): ZodNumber;
|
|
int(message?: errorUtil.ErrMessage): ZodNumber;
|
|
positive(message?: errorUtil.ErrMessage): ZodNumber;
|
|
negative(message?: errorUtil.ErrMessage): ZodNumber;
|
|
nonpositive(message?: errorUtil.ErrMessage): ZodNumber;
|
|
nonnegative(message?: errorUtil.ErrMessage): ZodNumber;
|
|
multipleOf(value: number, message?: errorUtil.ErrMessage): ZodNumber;
|
|
step: (value: number, message?: errorUtil.ErrMessage) => ZodNumber;
|
|
finite(message?: errorUtil.ErrMessage): ZodNumber;
|
|
safe(message?: errorUtil.ErrMessage): ZodNumber;
|
|
get minValue(): number | null;
|
|
get maxValue(): number | null;
|
|
get isInt(): boolean;
|
|
get isFinite(): boolean;
|
|
}
|
|
interface ZodBooleanDef extends ZodTypeDef {
|
|
typeName: ZodFirstPartyTypeKind.ZodBoolean;
|
|
coerce: boolean;
|
|
}
|
|
declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef, boolean> {
|
|
_parse(input: ParseInput): ParseReturnType<boolean>;
|
|
static create: (params?: RawCreateParams & {
|
|
coerce?: boolean;
|
|
}) => ZodBoolean;
|
|
}
|
|
interface ZodArrayDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
type: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodArray;
|
|
exactLength: {
|
|
value: number;
|
|
message?: string;
|
|
} | null;
|
|
minLength: {
|
|
value: number;
|
|
message?: string;
|
|
} | null;
|
|
maxLength: {
|
|
value: number;
|
|
message?: string;
|
|
} | null;
|
|
}
|
|
type ArrayCardinality = "many" | "atleastone";
|
|
type arrayOutputType<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> = Cardinality extends "atleastone" ? [T["_output"], ...T["_output"][]] : T["_output"][];
|
|
declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCardinality = "many"> extends ZodType<arrayOutputType<T, Cardinality>, ZodArrayDef<T>, Cardinality extends "atleastone" ? [T["_input"], ...T["_input"][]] : T["_input"][]> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
get element(): T;
|
|
min(minLength: number, message?: errorUtil.ErrMessage): this;
|
|
max(maxLength: number, message?: errorUtil.ErrMessage): this;
|
|
length(len: number, message?: errorUtil.ErrMessage): this;
|
|
nonempty(message?: errorUtil.ErrMessage): ZodArray<T, "atleastone">;
|
|
static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodArray<T_1, "many">;
|
|
}
|
|
type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
typeName: ZodFirstPartyTypeKind.ZodObject;
|
|
shape: () => T;
|
|
catchall: Catchall;
|
|
unknownKeys: UnknownKeys;
|
|
}
|
|
type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>> & CatchallOutput<Catchall> & PassthroughType<UnknownKeys>;
|
|
type baseObjectOutputType<Shape extends ZodRawShape> = {
|
|
[k in keyof Shape]: Shape[k]["_output"];
|
|
};
|
|
type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<baseObjectInputType<Shape>> & CatchallInput<Catchall> & PassthroughType<UnknownKeys>;
|
|
type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
|
|
[k in keyof Shape]: Shape[k]["_input"];
|
|
}>;
|
|
type CatchallOutput<T extends ZodType> = ZodType extends T ? unknown : {
|
|
[k: string]: T["_output"];
|
|
};
|
|
type CatchallInput<T extends ZodType> = ZodType extends T ? unknown : {
|
|
[k: string]: T["_input"];
|
|
};
|
|
type PassthroughType<T extends UnknownKeysParam> = T extends "passthrough" ? {
|
|
[k: string]: unknown;
|
|
} : unknown;
|
|
type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T extends ZodNullable<infer U> ? ZodNullable<deoptional<U>> : T;
|
|
declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
|
|
private _cached;
|
|
_getCached(): {
|
|
shape: T;
|
|
keys: string[];
|
|
};
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
get shape(): T;
|
|
strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>;
|
|
strip(): ZodObject<T, "strip", Catchall>;
|
|
passthrough(): ZodObject<T, "passthrough", Catchall>;
|
|
/**
|
|
* @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
|
|
* If you want to pass through unknown properties, use `.passthrough()` instead.
|
|
*/
|
|
nonstrict: () => ZodObject<T, "passthrough", Catchall>;
|
|
extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
|
|
/**
|
|
* @deprecated Use `.extend` instead
|
|
* */
|
|
augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
|
|
/**
|
|
* Prior to zod@1.0.12 there was a bug in the
|
|
* inferred type of merged objects. Please
|
|
* upgrade if you are experiencing issues.
|
|
*/
|
|
merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
|
|
setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & {
|
|
[k in Key]: Schema;
|
|
}, UnknownKeys, Catchall>;
|
|
catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
|
|
pick<Mask extends util.Exactly<{
|
|
[k in keyof T]?: true;
|
|
}, Mask>>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
|
|
omit<Mask extends util.Exactly<{
|
|
[k in keyof T]?: true;
|
|
}, Mask>>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
|
|
/**
|
|
* @deprecated
|
|
*/
|
|
deepPartial(): partialUtil.DeepPartial<this>;
|
|
partial(): ZodObject<{
|
|
[k in keyof T]: ZodOptional<T[k]>;
|
|
}, UnknownKeys, Catchall>;
|
|
partial<Mask extends util.Exactly<{
|
|
[k in keyof T]?: true;
|
|
}, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
|
|
[k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
|
|
}>, UnknownKeys, Catchall>;
|
|
required(): ZodObject<{
|
|
[k in keyof T]: deoptional<T[k]>;
|
|
}, UnknownKeys, Catchall>;
|
|
required<Mask extends util.Exactly<{
|
|
[k in keyof T]?: true;
|
|
}, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
|
|
[k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
|
|
}>, UnknownKeys, Catchall>;
|
|
keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
|
|
static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any> extends infer T_2 ? { [k in keyof T_2]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; } : never, baseObjectInputType<T_1> extends infer T_3 ? { [k_1 in keyof T_3]: baseObjectInputType<T_1>[k_1]; } : never>;
|
|
static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any> extends infer T_2 ? { [k in keyof T_2]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; } : never, baseObjectInputType<T_1> extends infer T_3 ? { [k_1 in keyof T_3]: baseObjectInputType<T_1>[k_1]; } : never>;
|
|
static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any> extends infer T_2 ? { [k in keyof T_2]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; } : never, baseObjectInputType<T_1> extends infer T_3 ? { [k_1 in keyof T_3]: baseObjectInputType<T_1>[k_1]; } : never>;
|
|
}
|
|
type AnyZodObject = ZodObject<any, any, any>;
|
|
type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
|
|
interface ZodUnionDef<T extends ZodUnionOptions = Readonly<[
|
|
ZodTypeAny,
|
|
ZodTypeAny,
|
|
...ZodTypeAny[]
|
|
]>> extends ZodTypeDef {
|
|
options: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodUnion;
|
|
}
|
|
declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[number]["_output"], ZodUnionDef<T>, T[number]["_input"]> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
get options(): T;
|
|
static create: <T_1 extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T_1, params?: RawCreateParams) => ZodUnion<T_1>;
|
|
}
|
|
interface ZodIntersectionDef<T extends ZodTypeAny = ZodTypeAny, U extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
left: T;
|
|
right: U;
|
|
typeName: ZodFirstPartyTypeKind.ZodIntersection;
|
|
}
|
|
declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny> extends ZodType<T["_output"] & U["_output"], ZodIntersectionDef<T, U>, T["_input"] & U["_input"]> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
static create: <T_1 extends ZodTypeAny, U_1 extends ZodTypeAny>(left: T_1, right: U_1, params?: RawCreateParams) => ZodIntersection<T_1, U_1>;
|
|
}
|
|
type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
|
|
type AssertArray<T> = T extends any[] ? T : never;
|
|
type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
|
|
[k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_output"] : never;
|
|
}>;
|
|
type OutputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...OutputTypeOfTuple<T>, ...Rest["_output"][]] : OutputTypeOfTuple<T>;
|
|
type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
|
|
[k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_input"] : never;
|
|
}>;
|
|
type InputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...InputTypeOfTuple<T>, ...Rest["_input"][]] : InputTypeOfTuple<T>;
|
|
interface ZodTupleDef<T extends ZodTupleItems | [] = ZodTupleItems, Rest extends ZodTypeAny | null = null> extends ZodTypeDef {
|
|
items: T;
|
|
rest: Rest;
|
|
typeName: ZodFirstPartyTypeKind.ZodTuple;
|
|
}
|
|
declare class ZodTuple<T extends [ZodTypeAny, ...ZodTypeAny[]] | [] = [ZodTypeAny, ...ZodTypeAny[]], Rest extends ZodTypeAny | null = null> extends ZodType<OutputTypeOfTupleWithRest<T, Rest>, ZodTupleDef<T, Rest>, InputTypeOfTupleWithRest<T, Rest>> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
get items(): T;
|
|
rest<Rest extends ZodTypeAny>(rest: Rest): ZodTuple<T, Rest>;
|
|
static create: <T_1 extends [] | [ZodTypeAny, ...ZodTypeAny[]]>(schemas: T_1, params?: RawCreateParams) => ZodTuple<T_1, null>;
|
|
}
|
|
type EnumValues<T extends string = string> = readonly [T, ...T[]];
|
|
type Values<T extends EnumValues> = {
|
|
[k in T[number]]: k;
|
|
};
|
|
interface ZodEnumDef<T extends EnumValues = EnumValues> extends ZodTypeDef {
|
|
values: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodEnum;
|
|
}
|
|
type Writeable<T> = {
|
|
-readonly [P in keyof T]: T[P];
|
|
};
|
|
type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Values extends [infer Head, ...infer Rest] ? Head extends ToExclude ? FilterEnum<Rest, ToExclude> : [Head, ...FilterEnum<Rest, ToExclude>] : never;
|
|
type typecast<A, T> = A extends T ? A : never;
|
|
declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: RawCreateParams): ZodEnum<Writeable<T>>;
|
|
declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T, params?: RawCreateParams): ZodEnum<T>;
|
|
declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>, T[number]> {
|
|
#private;
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
get options(): T;
|
|
get enum(): Values<T>;
|
|
get Values(): Values<T>;
|
|
get Enum(): Values<T>;
|
|
extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract, newDef?: RawCreateParams): ZodEnum<Writeable<ToExtract>>;
|
|
exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude, newDef?: RawCreateParams): ZodEnum<typecast<Writeable<FilterEnum<T, ToExclude[number]>>, [string, ...string[]]>>;
|
|
static create: typeof createZodEnum;
|
|
}
|
|
interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
type: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodPromise;
|
|
}
|
|
declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
|
|
unwrap(): T;
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodPromise<T_1>;
|
|
}
|
|
type RefinementEffect<T> = {
|
|
type: "refinement";
|
|
refinement: (arg: T, ctx: RefinementCtx) => any;
|
|
};
|
|
type TransformEffect<T> = {
|
|
type: "transform";
|
|
transform: (arg: T, ctx: RefinementCtx) => any;
|
|
};
|
|
type PreprocessEffect<T> = {
|
|
type: "preprocess";
|
|
transform: (arg: T, ctx: RefinementCtx) => any;
|
|
};
|
|
type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;
|
|
interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
schema: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodEffects;
|
|
effect: Effect<any>;
|
|
}
|
|
declare class ZodEffects<T extends ZodTypeAny, Output = output<T>, Input = input<T>> extends ZodType<Output, ZodEffectsDef<T>, Input> {
|
|
innerType(): T;
|
|
sourceType(): T;
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"]>;
|
|
static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
|
|
}
|
|
|
|
interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
innerType: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodOptional;
|
|
}
|
|
declare class ZodOptional<T extends ZodTypeAny> extends ZodType<T["_output"] | undefined, ZodOptionalDef<T>, T["_input"] | undefined> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
unwrap(): T;
|
|
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodOptional<T_1>;
|
|
}
|
|
interface ZodNullableDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
innerType: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodNullable;
|
|
}
|
|
declare class ZodNullable<T extends ZodTypeAny> extends ZodType<T["_output"] | null, ZodNullableDef<T>, T["_input"] | null> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
unwrap(): T;
|
|
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodNullable<T_1>;
|
|
}
|
|
interface ZodDefaultDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
innerType: T;
|
|
defaultValue: () => util.noUndefined<T["_input"]>;
|
|
typeName: ZodFirstPartyTypeKind.ZodDefault;
|
|
}
|
|
declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodDefaultDef<T>, T["_input"] | undefined> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
removeDefault(): T;
|
|
static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
|
|
errorMap?: ZodErrorMap | undefined;
|
|
invalid_type_error?: string | undefined;
|
|
required_error?: string | undefined;
|
|
message?: string | undefined;
|
|
description?: string | undefined;
|
|
} & {
|
|
default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
|
|
}) => ZodDefault<T_1>;
|
|
}
|
|
interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
innerType: T;
|
|
catchValue: (ctx: {
|
|
error: ZodError;
|
|
input: unknown;
|
|
}) => T["_input"];
|
|
typeName: ZodFirstPartyTypeKind.ZodCatch;
|
|
}
|
|
declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
removeCatch(): T;
|
|
static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
|
|
errorMap?: ZodErrorMap | undefined;
|
|
invalid_type_error?: string | undefined;
|
|
required_error?: string | undefined;
|
|
message?: string | undefined;
|
|
description?: string | undefined;
|
|
} & {
|
|
catch: T_1["_output"] | (() => T_1["_output"]);
|
|
}) => ZodCatch<T_1>;
|
|
}
|
|
interface ZodBrandedDef<T extends ZodTypeAny> extends ZodTypeDef {
|
|
type: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodBranded;
|
|
}
|
|
declare const BRAND: unique symbol;
|
|
type BRAND<T extends string | number | symbol> = {
|
|
[BRAND]: {
|
|
[k in T]: true;
|
|
};
|
|
};
|
|
declare class ZodBranded<T extends ZodTypeAny, B extends string | number | symbol> extends ZodType<T["_output"] & BRAND<B>, ZodBrandedDef<T>, T["_input"]> {
|
|
_parse(input: ParseInput): ParseReturnType<any>;
|
|
unwrap(): T;
|
|
}
|
|
interface ZodPipelineDef<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodTypeDef {
|
|
in: A;
|
|
out: B;
|
|
typeName: ZodFirstPartyTypeKind.ZodPipeline;
|
|
}
|
|
declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends ZodType<B["_output"], ZodPipelineDef<A, B>, A["_input"]> {
|
|
_parse(input: ParseInput): ParseReturnType<any>;
|
|
static create<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodPipeline<A, B>;
|
|
}
|
|
type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
|
readonly [Symbol.toStringTag]: string;
|
|
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
|
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>;
|
|
interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
|
|
innerType: T;
|
|
typeName: ZodFirstPartyTypeKind.ZodReadonly;
|
|
}
|
|
declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
|
|
_parse(input: ParseInput): ParseReturnType<this["_output"]>;
|
|
static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodReadonly<T_1>;
|
|
unwrap(): T;
|
|
}
|
|
declare enum ZodFirstPartyTypeKind {
|
|
ZodString = "ZodString",
|
|
ZodNumber = "ZodNumber",
|
|
ZodNaN = "ZodNaN",
|
|
ZodBigInt = "ZodBigInt",
|
|
ZodBoolean = "ZodBoolean",
|
|
ZodDate = "ZodDate",
|
|
ZodSymbol = "ZodSymbol",
|
|
ZodUndefined = "ZodUndefined",
|
|
ZodNull = "ZodNull",
|
|
ZodAny = "ZodAny",
|
|
ZodUnknown = "ZodUnknown",
|
|
ZodNever = "ZodNever",
|
|
ZodVoid = "ZodVoid",
|
|
ZodArray = "ZodArray",
|
|
ZodObject = "ZodObject",
|
|
ZodUnion = "ZodUnion",
|
|
ZodDiscriminatedUnion = "ZodDiscriminatedUnion",
|
|
ZodIntersection = "ZodIntersection",
|
|
ZodTuple = "ZodTuple",
|
|
ZodRecord = "ZodRecord",
|
|
ZodMap = "ZodMap",
|
|
ZodSet = "ZodSet",
|
|
ZodFunction = "ZodFunction",
|
|
ZodLazy = "ZodLazy",
|
|
ZodLiteral = "ZodLiteral",
|
|
ZodEnum = "ZodEnum",
|
|
ZodEffects = "ZodEffects",
|
|
ZodNativeEnum = "ZodNativeEnum",
|
|
ZodOptional = "ZodOptional",
|
|
ZodNullable = "ZodNullable",
|
|
ZodDefault = "ZodDefault",
|
|
ZodCatch = "ZodCatch",
|
|
ZodPromise = "ZodPromise",
|
|
ZodBranded = "ZodBranded",
|
|
ZodPipeline = "ZodPipeline",
|
|
ZodReadonly = "ZodReadonly"
|
|
}
|
|
|
|
declare const userSettingSchema: ZodObject<{
|
|
version: ZodNumber;
|
|
userSince: ZodOptional<ZodNumber>;
|
|
init: ZodOptional<ZodObject<{
|
|
skipOnboarding: ZodOptional<ZodBoolean>;
|
|
}, "strip", ZodTypeAny, {
|
|
skipOnboarding?: boolean | undefined;
|
|
}, {
|
|
skipOnboarding?: boolean | undefined;
|
|
}>>;
|
|
}, "strip", ZodTypeAny, {
|
|
version: number;
|
|
userSince?: number | undefined;
|
|
init?: {
|
|
skipOnboarding?: boolean | undefined;
|
|
} | undefined;
|
|
}, {
|
|
version: number;
|
|
userSince?: number | undefined;
|
|
init?: {
|
|
skipOnboarding?: boolean | undefined;
|
|
} | undefined;
|
|
}>;
|
|
declare function globalSettings(filePath?: string): Promise<Settings>;
|
|
declare function _clearGlobalSettings(): void;
|
|
/**
|
|
* A class for reading and writing settings from a JSON file. Supports nested settings with dot
|
|
* notation.
|
|
*/
|
|
declare class Settings {
|
|
private filePath;
|
|
value: TypeOf<typeof userSettingSchema>;
|
|
/**
|
|
* Create a new Settings instance
|
|
*
|
|
* @param filePath Path to the JSON settings file
|
|
* @param value Loaded value of settings
|
|
*/
|
|
constructor(filePath: string, value: TypeOf<typeof userSettingSchema>);
|
|
/** Save settings to the file */
|
|
save(): Promise<void>;
|
|
}
|
|
|
|
export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CommunityBuilder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, Settings, SupportedLanguage, type TemplateConfiguration, type TemplateMatcher, _clearGlobalSettings, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, cliStoriesTargetPath, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, configureFlatConfig, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, getBabelDependencies, getRendererDir, getVersionSafe, globalSettings, hasStorybookDependencies, installableProjectTypes, isNxProject, isStorybookInstantiated, normalizeExtends, promptForCompoDocs, readFileAsJson, suggestESLintPlugin, supportedTemplates, unsupportedTemplate, writeFileAsJson };
|