@storm-software/git-tools
Version:
Tools for managing Git repositories within a Nx workspace.
1,642 lines (1,626 loc) • 123 kB
JavaScript
import { DEFAULT_MONOREPO_COMMIT_QUESTIONS } from './chunk-OMWWQPRY.js';
import { DEFAULT_COMMIT_TYPES } from './chunk-4T5NCWMG.js';
import { writeWarning, formatLogMessage, writeTrace, getLogLevel, LogLevel, getLogLevelLabel } from './chunk-65JOK2FH.js';
import defu3 from 'defu';
import { existsSync } from 'fs';
import { readNxJson } from 'nx/src/config/nx-json';
import { findMatchingProjects } from 'nx/src/utils/find-matching-projects';
import { loadConfig } from 'c12';
import { existsSync as existsSync$1 } from 'node:fs';
import { join } from 'node:path';
import { readFile } from 'node:fs/promises';
import axios2 from 'axios';
import DefaultChangelogRenderer from 'nx/release/changelog-renderer';
import { DEFAULT_CONVENTIONAL_COMMITS_CONFIG } from 'nx/src/command-line/release/config/conventional-commits';
import { major } from 'semver';
import '@nx/devkit';
import 'chalk';
import 'nx/src/command-line/release/utils/print-changes';
import 'nx/src/command-line/release/utils/shared';
import 'nx/src/tasks-runner/utils';
import 'prettier';
import 'node:child_process';
import 'node:os';
import 'nx/src/command-line/release/utils/remote-release-clients/github';
import 'yaml';
import 'nx/src/command-line/release/utils/exec-command.js';
import 'nx/src/command-line/release/utils/git';
import 'nx/src/tasks-runner/utils.js';
// ../config-tools/src/utilities/correct-paths.ts
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
function normalizeWindowsPath(input = "") {
if (!input) {
return input;
}
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
}
var _UNC_REGEX = /^[/\\]{2}/;
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
var correctPaths = function(path) {
if (!path || path.length === 0) {
return ".";
}
path = normalizeWindowsPath(path);
const isUNCPath = path?.match(_UNC_REGEX);
const isPathAbsolute = isAbsolute(path);
const trailingSeparator = path[path.length - 1] === "/";
path = normalizeString(path, !isPathAbsolute);
if (path.length === 0) {
if (isPathAbsolute) {
return "/";
}
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) {
path += "/";
}
if (_DRIVE_LETTER_RE.test(path)) {
path += "/";
}
if (isUNCPath) {
if (!isPathAbsolute) {
return `//./${path}`;
}
return `//${path}`;
}
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
};
var joinPaths = function(...segments) {
let path = "";
for (const seg of segments) {
if (!seg) {
continue;
}
if (path.length > 0) {
const pathTrailing = path[path.length - 1] === "/";
const segLeading = seg[0] === "/";
const both = pathTrailing && segLeading;
if (both) {
path += seg.slice(1);
} else {
path += pathTrailing || segLeading ? seg : `/${seg}`;
}
} else {
path += seg;
}
}
return correctPaths(path);
};
function normalizeString(path, allowAboveRoot) {
let res = "";
let lastSegmentLength = 0;
let lastSlash = -1;
let dots = 0;
let char = null;
for (let index = 0; index <= path.length; ++index) {
if (index < path.length) {
char = path[index];
} else if (char === "/") {
break;
} else {
char = "/";
}
if (char === "/") {
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
if (res.length > 2) {
const lastSlashIndex = res.lastIndexOf("/");
if (lastSlashIndex === -1) {
res = "";
lastSegmentLength = 0;
} else {
res = res.slice(0, lastSlashIndex);
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
}
lastSlash = index;
dots = 0;
continue;
} else if (res.length > 0) {
res = "";
lastSegmentLength = 0;
lastSlash = index;
dots = 0;
continue;
}
}
if (allowAboveRoot) {
res += res.length > 0 ? "/.." : "..";
lastSegmentLength = 2;
}
} else {
if (res.length > 0) {
res += `/${path.slice(lastSlash + 1, index)}`;
} else {
res = path.slice(lastSlash + 1, index);
}
lastSegmentLength = index - lastSlash - 1;
}
lastSlash = index;
dots = 0;
} else if (char === "." && dots !== -1) {
++dots;
} else {
dots = -1;
}
}
return res;
}
var isAbsolute = function(p) {
return _IS_ABSOLUTE_RE.test(p);
};
// ../package-constants/src/tags.ts
var ProjectTagConstants = {
Language: {
TAG_ID: "language",
TYPESCRIPT: "typescript",
RUST: "rust"
}};
var formatProjectTag = (variant, value) => {
return `${variant}:${value}`;
};
var hasProjectTag = (project, variant) => {
project.tags = project.tags ?? [];
const prefix = formatProjectTag(variant, "");
return project.tags.some(
(tag) => tag.startsWith(prefix) && tag.length > prefix.length
);
};
var getProjectTag = (project, variant) => {
if (!hasProjectTag(project, variant)) {
return void 0;
}
project.tags = project.tags ?? [];
const prefix = formatProjectTag(variant, "");
const tag = project.tags.find((tag2) => tag2.startsWith(prefix));
return tag?.replace(prefix, "");
};
var isEqualProjectTag = (project, variant, value) => {
const tag = getProjectTag(project, variant);
return !!(tag && tag?.toUpperCase() === value.toUpperCase());
};
// src/utilities/omit.ts
function omit(obj, keys) {
const result = { ...obj };
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key && key in result) {
delete result[key];
}
}
return result;
}
var MAX_PATH_SEARCH_DEPTH = 30;
var depth = 0;
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
const _startPath = startPath ?? process.cwd();
if (endDirectoryNames.some(
(endDirName) => existsSync$1(join(_startPath, endDirName))
)) {
return _startPath;
}
if (endFileNames.some((endFileName) => existsSync$1(join(_startPath, endFileName)))) {
return _startPath;
}
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
const parent = join(_startPath, "..");
return findFolderUp(parent, endFileNames, endDirectoryNames);
}
return void 0;
}
// ../config-tools/src/utilities/find-workspace-root.ts
var rootFiles = [
"storm-workspace.json",
"storm-workspace.yaml",
"storm-workspace.yml",
"storm-workspace.js",
"storm-workspace.ts",
".storm-workspace.json",
".storm-workspace.yaml",
".storm-workspace.yml",
".storm-workspace.js",
".storm-workspace.ts",
"lerna.json",
"nx.json",
"turbo.json",
"npm-workspace.json",
"yarn-workspace.json",
"pnpm-workspace.json",
"npm-workspace.yaml",
"yarn-workspace.yaml",
"pnpm-workspace.yaml",
"npm-workspace.yml",
"yarn-workspace.yml",
"pnpm-workspace.yml",
"npm-lock.json",
"yarn-lock.json",
"pnpm-lock.json",
"npm-lock.yaml",
"yarn-lock.yaml",
"pnpm-lock.yaml",
"npm-lock.yml",
"yarn-lock.yml",
"pnpm-lock.yml",
"bun.lockb"
];
var rootDirectories = [
".storm-workspace",
".nx",
".git",
".github",
".vscode",
".verdaccio"
];
function findWorkspaceRootSafe(pathInsideMonorepo) {
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
return correctPaths(
process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
);
}
return correctPaths(
findFolderUp(
pathInsideMonorepo ?? process.cwd(),
rootFiles,
rootDirectories
)
);
}
function findWorkspaceRoot(pathInsideMonorepo) {
const result = findWorkspaceRootSafe(pathInsideMonorepo);
if (!result) {
throw new Error(
`Cannot find workspace root upwards from known path. Files search list includes:
${rootFiles.join(
"\n"
)}
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
);
}
return result;
}
// ../config/src/constants.ts
var STORM_DEFAULT_DOCS = "https://docs.stormsoftware.com";
var STORM_DEFAULT_HOMEPAGE = "https://stormsoftware.com";
var STORM_DEFAULT_LICENSING = "https://stormsoftware.com/license";
var STORM_DEFAULT_LICENSE = "Apache-2.0";
var STORM_DEFAULT_ERROR_CODES_FILE = "tools/errors/codes.json";
var STORM_DEFAULT_BANNER_ALT = "The workspace's banner image";
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
var _a;
// @__NO_SIDE_EFFECTS__
function $constructor(name, initializer2, params) {
function init(inst, def) {
if (!inst._zod) {
Object.defineProperty(inst, "_zod", {
value: {
def,
constr: _,
traits: /* @__PURE__ */ new Set()
},
enumerable: false
});
}
if (inst._zod.traits.has(name)) {
return;
}
inst._zod.traits.add(name);
initializer2(inst, def);
const proto = _.prototype;
const keys = Object.keys(proto);
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
if (!(k in inst)) {
inst[k] = proto[k].bind(inst);
}
}
}
const Parent = params?.Parent ?? Object;
class Definition extends Parent {
}
Object.defineProperty(Definition, "name", { value: name });
function _(def) {
var _a3;
const inst = params?.Parent ? new Definition() : this;
init(inst, def);
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
for (const fn of inst._zod.deferred) {
fn();
}
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, {
value: (inst) => {
if (params?.Parent && inst instanceof params.Parent)
return true;
return inst?._zod?.traits?.has(name);
}
});
Object.defineProperty(_, "name", { value: name });
return _;
}
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
var globalConfig = globalThis.__zod_globalConfig;
function config(newConfig) {
return globalConfig;
}
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
function getEnumValues(entries) {
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
return values;
}
function jsonStringifyReplacer(_, value) {
if (typeof value === "bigint")
return value.toString();
return value;
}
function cached(getter) {
return {
get value() {
{
const value = getter();
Object.defineProperty(this, "value", { value });
return value;
}
}
};
}
function nullish(input) {
return input === null || input === void 0;
}
function cleanRegex(source) {
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
return source.slice(start, end);
}
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
function defineLazy(object2, key, getter) {
let value = void 0;
Object.defineProperty(object2, key, {
get() {
if (value === EVALUATING) {
return void 0;
}
if (value === void 0) {
value = EVALUATING;
value = getter();
}
return value;
},
set(v) {
Object.defineProperty(object2, key, {
value: v
// configurable: true,
});
},
configurable: true
});
}
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
};
function isObject(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
function isPlainObject(o) {
if (isObject(o) === false)
return false;
const ctor = o.constructor;
if (ctor === void 0)
return true;
if (typeof ctor !== "function")
return true;
const prot = ctor.prototype;
if (isObject(prot) === false)
return false;
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
return false;
}
return true;
}
function shallowClone(o) {
if (isPlainObject(o))
return { ...o };
if (Array.isArray(o))
return [...o];
if (o instanceof Map)
return new Map(o);
if (o instanceof Set)
return new Set(o);
return o;
}
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
function escapeRegex(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(inst, def, params) {
const cl = new inst._zod.constr(def ?? inst._zod.def);
if (!def || params?.parent)
cl._zod.parent = inst;
return cl;
}
function normalizeParams(_params) {
const params = _params;
if (!params)
return {};
if (typeof params === "string")
return { error: () => params };
if (params?.message !== void 0) {
if (params?.error !== void 0)
throw new Error("Cannot specify both `message` and `error` params");
params.error = params.message;
}
delete params.message;
if (typeof params.error === "string")
return { ...params, error: () => params.error };
return params;
}
function optionalKeys(shape) {
return Object.keys(shape).filter((k) => {
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
});
}
function aborted(x, startIndex = 0) {
if (x.aborted === true)
return true;
for (let i = startIndex; i < x.issues.length; i++) {
if (x.issues[i]?.continue !== true) {
return true;
}
}
return false;
}
function explicitlyAborted(x, startIndex = 0) {
if (x.aborted === true)
return true;
for (let i = startIndex; i < x.issues.length; i++) {
if (x.issues[i]?.continue === false) {
return true;
}
}
return false;
}
function prefixIssues(path, issues) {
return issues.map((iss) => {
var _a3;
(_a3 = iss).path ?? (_a3.path = []);
iss.path.unshift(path);
return iss;
});
}
function unwrapMessage(message) {
return typeof message === "string" ? message : message?.message;
}
function finalizeIssue(iss, ctx, config2) {
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
rest.path ?? (rest.path = []);
rest.message = message;
if (ctx?.reportInput) {
rest.input = _input;
}
return rest;
}
function getLengthableOrigin(input) {
if (Array.isArray(input))
return "array";
if (typeof input === "string")
return "string";
return "unknown";
}
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
var initializer = (inst, def) => {
inst.name = "$ZodError";
Object.defineProperty(inst, "_zod", {
value: inst._zod,
enumerable: false
});
Object.defineProperty(inst, "issues", {
value: def,
enumerable: false
});
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
Object.defineProperty(inst, "toString", {
value: () => inst.message,
enumerable: false
});
};
var $ZodError = $constructor("$ZodError", initializer);
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
var _parse = (_Err) => (schema, value, _ctx, _params) => {
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
const result = schema._zod.run({ value, issues: [] }, ctx);
if (result instanceof Promise) {
throw new $ZodAsyncError();
}
if (result.issues.length) {
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, _params?.callee);
throw e;
}
return result.value;
};
var parse = /* @__PURE__ */ _parse($ZodRealError);
var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
let result = schema._zod.run({ value, issues: [] }, ctx);
if (result instanceof Promise)
result = await result;
if (result.issues.length) {
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, params?.callee);
throw e;
}
return result.value;
};
var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
var _safeParse = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
const result = schema._zod.run({ value, issues: [] }, ctx);
if (result instanceof Promise) {
throw new $ZodAsyncError();
}
return result.issues.length ? {
success: false,
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
} : { success: true, data: result.value };
};
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
let result = schema._zod.run({ value, issues: [] }, ctx);
if (result instanceof Promise)
result = await result;
return result.issues.length ? {
success: false,
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
} : { success: true, data: result.value };
};
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
var httpProtocol = /^https?$/;
var string = (params) => {
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
return new RegExp(`^${regex}$`);
};
var number = /^-?\d+(?:\.\d+)?$/;
var boolean = /^(?:true|false)$/i;
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
var _a3;
inst._zod ?? (inst._zod = {});
inst._zod.def = def;
(_a3 = inst._zod).onattach ?? (_a3.onattach = []);
});
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
var _a3;
$ZodCheck.init(inst, def);
(_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
const val = payload.value;
return !nullish(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst2) => {
const bag = inst2._zod.bag;
bag.minimum = def.length;
bag.maximum = def.length;
bag.length = def.length;
});
inst._zod.check = (payload) => {
const input = payload.value;
const length = input.length;
if (length === def.length)
return;
const origin = getLengthableOrigin(input);
const tooBig = length > def.length;
payload.issues.push({
origin,
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
inclusive: true,
exact: true,
input: payload.value,
inst,
continue: !def.abort
});
};
});
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
var _a3, _b;
$ZodCheck.init(inst, def);
inst._zod.onattach.push((inst2) => {
const bag = inst2._zod.bag;
bag.format = def.format;
if (def.pattern) {
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(def.pattern);
}
});
if (def.pattern)
(_a3 = inst._zod).check ?? (_a3.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value))
return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: def.format,
input: payload.value,
...def.pattern ? { pattern: def.pattern.toString() } : {},
inst,
continue: !def.abort
});
});
else
(_b = inst._zod).check ?? (_b.check = () => {
});
});
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
$ZodCheckStringFormat.init(inst, def);
inst._zod.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value))
return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: payload.value,
pattern: def.pattern.toString(),
inst,
continue: !def.abort
});
};
});
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
$ZodCheck.init(inst, def);
inst._zod.check = (payload) => {
payload.value = def.tx(payload.value);
};
});
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
var version = {
major: 4,
minor: 4,
patch: 3
};
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
var _a3;
inst ?? (inst = {});
inst._zod.def = def;
inst._zod.bag = inst._zod.bag || {};
inst._zod.version = version;
const checks = [...inst._zod.def.checks ?? []];
if (inst._zod.traits.has("$ZodCheck")) {
checks.unshift(inst);
}
for (const ch of checks) {
for (const fn of ch._zod.onattach) {
fn(inst);
}
}
if (checks.length === 0) {
(_a3 = inst._zod).deferred ?? (_a3.deferred = []);
inst._zod.deferred?.push(() => {
inst._zod.run = inst._zod.parse;
});
} else {
const runChecks = (payload, checks2, ctx) => {
let isAborted = aborted(payload);
let asyncResult;
for (const ch of checks2) {
if (ch._zod.def.when) {
if (explicitlyAborted(payload))
continue;
const shouldRun = ch._zod.def.when(payload);
if (!shouldRun)
continue;
} else if (isAborted) {
continue;
}
const currLen = payload.issues.length;
const _ = ch._zod.check(payload);
if (_ instanceof Promise && ctx?.async === false) {
throw new $ZodAsyncError();
}
if (asyncResult || _ instanceof Promise) {
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
await _;
const nextLen = payload.issues.length;
if (nextLen === currLen)
return;
if (!isAborted)
isAborted = aborted(payload, currLen);
});
} else {
const nextLen = payload.issues.length;
if (nextLen === currLen)
continue;
if (!isAborted)
isAborted = aborted(payload, currLen);
}
}
if (asyncResult) {
return asyncResult.then(() => {
return payload;
});
}
return payload;
};
const handleCanaryResult = (canary, payload, ctx) => {
if (aborted(canary)) {
canary.aborted = true;
return canary;
}
const checkResult = runChecks(payload, checks, ctx);
if (checkResult instanceof Promise) {
if (ctx.async === false)
throw new $ZodAsyncError();
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
}
return inst._zod.parse(checkResult, ctx);
};
inst._zod.run = (payload, ctx) => {
if (ctx.skipChecks) {
return inst._zod.parse(payload, ctx);
}
if (ctx.direction === "backward") {
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
if (canary instanceof Promise) {
return canary.then((canary2) => {
return handleCanaryResult(canary2, payload, ctx);
});
}
return handleCanaryResult(canary, payload, ctx);
}
const result = inst._zod.parse(payload, ctx);
if (result instanceof Promise) {
if (ctx.async === false)
throw new $ZodAsyncError();
return result.then((result2) => runChecks(result2, checks, ctx));
}
return runChecks(result, checks, ctx);
};
}
defineLazy(inst, "~standard", () => ({
validate: (value) => {
try {
const r = safeParse(inst, value);
return r.success ? { value: r.data } : { issues: r.error?.issues };
} catch (_) {
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
}
},
vendor: "zod",
version: 1
}));
});
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
inst._zod.parse = (payload, _) => {
if (def.coerce)
try {
payload.value = String(payload.value);
} catch (_2) {
}
if (typeof payload.value === "string")
return payload;
payload.issues.push({
expected: "string",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
$ZodCheckStringFormat.init(inst, def);
$ZodString.init(inst, def);
});
var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
try {
const trimmed = payload.value.trim();
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
if (!/^https?:\/\//i.test(trimmed)) {
payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: payload.value,
inst,
continue: !def.abort
});
return;
}
}
const url2 = new URL(trimmed);
if (def.hostname) {
def.hostname.lastIndex = 0;
if (!def.hostname.test(url2.hostname)) {
payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: def.hostname.source,
input: payload.value,
inst,
continue: !def.abort
});
}
}
if (def.protocol) {
def.protocol.lastIndex = 0;
if (!def.protocol.test(url2.protocol.endsWith(":") ? url2.protocol.slice(0, -1) : url2.protocol)) {
payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: def.protocol.source,
input: payload.value,
inst,
continue: !def.abort
});
}
}
if (def.normalize) {
payload.value = url2.href;
} else {
payload.value = trimmed;
}
return;
} catch (_) {
payload.issues.push({
code: "invalid_format",
format: "url",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = boolean;
inst._zod.parse = (payload, _ctx) => {
if (def.coerce)
try {
payload.value = Boolean(payload.value);
} catch (_) {
}
const input = payload.value;
if (typeof input === "boolean")
return payload;
payload.issues.push({
expected: "boolean",
code: "invalid_type",
input,
inst
});
return payload;
};
});
var $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload) => payload;
});
function handleArrayResult(result, final, index) {
if (result.issues.length) {
final.issues.push(...prefixIssues(index, result.issues));
}
final.value[index] = result.value;
}
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!Array.isArray(input)) {
payload.issues.push({
expected: "array",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = Array(input.length);
const proms = [];
for (let i = 0; i < input.length; i++) {
const item = input[i];
const result = def.element._zod.run({
value: item,
issues: []
}, ctx);
if (result instanceof Promise) {
proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
} else {
handleArrayResult(result, payload, i);
}
}
if (proms.length) {
return Promise.all(proms).then(() => payload);
}
return payload;
};
});
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
const isPresent = key in input;
if (result.issues.length) {
if (isOptionalIn && isOptionalOut && !isPresent) {
return;
}
final.issues.push(...prefixIssues(key, result.issues));
}
if (!isPresent && !isOptionalIn) {
if (!result.issues.length) {
final.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [key]
});
}
return;
}
if (result.value === void 0) {
if (isPresent) {
final.value[key] = void 0;
}
} else {
final.value[key] = result.value;
}
}
function normalizeDef(def) {
const keys = Object.keys(def.shape);
for (const k of keys) {
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
}
}
const okeys = optionalKeys(def.shape);
return {
...def,
keys,
keySet: new Set(keys),
numKeys: keys.length,
optionalKeys: new Set(okeys)
};
}
function handleCatchall(proms, input, payload, ctx, def, inst) {
const unrecognized = [];
const keySet = def.keySet;
const _catchall = def.catchall._zod;
const t = _catchall.def.type;
const isOptionalIn = _catchall.optin === "optional";
const isOptionalOut = _catchall.optout === "optional";
for (const key in input) {
if (key === "__proto__")
continue;
if (keySet.has(key))
continue;
if (t === "never") {
unrecognized.push(key);
continue;
}
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
if (r instanceof Promise) {
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
} else {
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
}
}
if (unrecognized.length) {
payload.issues.push({
code: "unrecognized_keys",
keys: unrecognized,
input,
inst
});
}
if (!proms.length)
return payload;
return Promise.all(proms).then(() => {
return payload;
});
}
var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
$ZodType.init(inst, def);
const desc = Object.getOwnPropertyDescriptor(def, "shape");
if (!desc?.get) {
const sh = def.shape;
Object.defineProperty(def, "shape", {
get: () => {
const newSh = { ...sh };
Object.defineProperty(def, "shape", {
value: newSh
});
return newSh;
}
});
}
const _normalized = cached(() => normalizeDef(def));
defineLazy(inst._zod, "propValues", () => {
const shape = def.shape;
const propValues = {};
for (const key in shape) {
const field = shape[key]._zod;
if (field.values) {
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
for (const v of field.values)
propValues[key].add(v);
}
}
return propValues;
});
const isObject2 = isObject;
const catchall = def.catchall;
let value;
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject2(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = {};
const proms = [];
const shape = value.shape;
for (const key of value.keys) {
const el = shape[key];
const isOptionalIn = el._zod.optin === "optional";
const isOptionalOut = el._zod.optout === "optional";
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
if (r instanceof Promise) {
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
} else {
handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
}
}
if (!catchall) {
return proms.length ? Promise.all(proms).then(() => payload) : payload;
}
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
};
});
function handleUnionResults(results, final, inst, ctx) {
for (const result of results) {
if (result.issues.length === 0) {
final.value = result.value;
return final;
}
}
const nonaborted = results.filter((r) => !aborted(r));
if (nonaborted.length === 1) {
final.value = nonaborted[0].value;
return nonaborted[0];
}
final.issues.push({
code: "invalid_union",
input: final.value,
inst,
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
});
return final;
}
var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
defineLazy(inst._zod, "values", () => {
if (def.options.every((o) => o._zod.values)) {
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
}
return void 0;
});
defineLazy(inst._zod, "pattern", () => {
if (def.options.every((o) => o._zod.pattern)) {
const patterns = def.options.map((o) => o._zod.pattern);
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
}
return void 0;
});
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
inst._zod.parse = (payload, ctx) => {
if (first) {
return first(payload, ctx);
}
let async = false;
const results = [];
for (const option of def.options) {
const result = option._zod.run({
value: payload.value,
issues: []
}, ctx);
if (result instanceof Promise) {
results.push(result);
async = true;
} else {
if (result.issues.length === 0)
return result;
results.push(result);
}
}
if (!async)
return handleUnionResults(results, payload, inst, ctx);
return Promise.all(results).then((results2) => {
return handleUnionResults(results2, payload, inst, ctx);
});
};
});
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!isPlainObject(input)) {
payload.issues.push({
expected: "record",
code: "invalid_type",
input,
inst
});
return payload;
}
const proms = [];
const values = def.keyType._zod.values;
if (values) {
payload.value = {};
const recordKeys = /* @__PURE__ */ new Set();
for (const key of values) {
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
recordKeys.add(typeof key === "number" ? key.toString() : key);
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
if (keyResult instanceof Promise) {
throw new Error("Async schemas not supported in object keys currently");
}
if (keyResult.issues.length) {
payload.issues.push({
code: "invalid_key",
origin: "record",
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
input: key,
path: [key],
inst
});
continue;
}
const outKey = keyResult.value;
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
if (result instanceof Promise) {
proms.push(result.then((result2) => {
if (result2.issues.length) {
payload.issues.push(...prefixIssues(key, result2.issues));
}
payload.value[outKey] = result2.value;
}));
} else {
if (result.issues.length) {
payload.issues.push(...prefixIssues(key, result.issues));
}
payload.value[outKey] = result.value;
}
}
}
let unrecognized;
for (const key in input) {
if (!recordKeys.has(key)) {
unrecognized = unrecognized ?? [];
unrecognized.push(key);
}
}
if (unrecognized && unrecognized.length > 0) {
payload.issues.push({
code: "unrecognized_keys",
input,
inst,
keys: unrecognized
});
}
} else {
payload.value = {};
for (const key of Reflect.ownKeys(input)) {
if (key === "__proto__")
continue;
if (!Object.prototype.propertyIsEnumerable.call(input, key))
continue;
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
if (keyResult instanceof Promise) {
throw new Error("Async schemas not supported in object keys currently");
}
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
if (checkNumericKey) {
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
if (retryResult instanceof Promise) {
throw new Error("Async schemas not supported in object keys currently");
}
if (retryResult.issues.length === 0) {
keyResult = retryResult;
}
}
if (keyResult.issues.length) {
if (def.mode === "loose") {
payload.value[key] = input[key];
} else {
payload.issues.push({
code: "invalid_key",
origin: "record",
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
input: key,
path: [key],
inst
});
}
continue;
}
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
if (result instanceof Promise) {
proms.push(result.then((result2) => {
if (result2.issues.length) {
payload.issues.push(...prefixIssues(key, result2.issues));
}
payload.value[keyResult.value] = result2.value;
}));
} else {
if (result.issues.length) {
payload.issues.push(...prefixIssues(key, result.issues));
}
payload.value[keyResult.value] = result.value;
}
}
}
if (proms.length) {
return Promise.all(proms).then(() => payload);
}
return payload;
};
});
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
$ZodType.init(inst, def);
const values = getEnumValues(def.entries);
const valuesSet = new Set(values);
inst._zod.values = valuesSet;
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (valuesSet.has(input)) {
return payload;
}
payload.issues.push({
code: "invalid_value",
values,
input,
inst
});
return payload;
};
});
var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
$ZodType.init(inst, def);
if (def.values.length === 0) {
throw new Error("Cannot create literal schema with no valid values");
}
const values = new Set(def.values);
inst._zod.values = values;
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (values.has(input)) {
return payload;
}
payload.issues.push({
code: "invalid_value",
values: def.values,
input,
inst
});
return payload;
};
});
function handleOptionalResult(result, input) {
if (input === void 0 && (result.issues.length || result.fallback)) {
return { issues: [], value: void 0 };
}
return result;
}
var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
inst._zod.optout = "optional";
defineLazy(inst._zod, "values", () => {
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
});
defineLazy(inst._zod, "pattern", () => {
const pattern = def.innerType._zod.pattern;
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
});
inst._zod.parse = (payload, ctx) => {
if (def.innerType._zod.optin === "optional") {
const input = payload.value;
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise)
return result.then((r) => handleOptionalResult(r, input));
return handleOptionalResult(result, input);
}
if (payload.value === void 0) {
return payload;
}
return def.innerType._zod.run(payload, ctx);
};
});
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
defineLazy(inst._zod, "pattern", () => {
const pattern = def.innerType._zod.pattern;
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
});
defineLazy(inst._zod, "values", () => {
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
});
inst._zod.parse = (payload, ctx) => {
if (payload.value === null)
return payload;
return def.innerType._zod.run(payload, ctx);
};
});
var $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") {
return def.innerType._zod.run(payload, ctx);
}
if (payload.value === void 0) {
payload.value = def.defaultValue;
return payload;
}
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) {
return result.then((result2) => handleDefaultResult(result2, def));
}
return handleDefaultResult(result, def);
};
});
function handleDefaultResult(payload, def) {
if (payload.value === void 0) {
payload.value = def.defaultValue;
}
return payload;
}
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
var _a2;
var $ZodRegistry = class {
constructor() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
}
add(schema, ..._meta) {
const meta2 = _meta[0];
this._map.set(schema, meta2);
if (meta2 && typeof meta2 === "object" && "id" in meta2) {
this._idmap.set(meta2.id, schema);
}
return this;
}
clear() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
return this;
}
remove(schema) {
const meta2 = this._map.get(schema);
if (meta2 && typeof meta2 === "object" && "id" in meta2) {
this._idmap.delete(meta2.id);
}
this._map.delete(schema);
return this;
}
get(schema) {
const p = schema._zod.parent;
if (p) {
const pm = { ...this.get(p) ?? {} };
delete pm.id;
const f = { ...pm, ...this._map.get(schema) };
return Object.keys(f).length ? f : void 0;
}
return this._map.get(schema);
}
has(schema) {
return this._map.has(schema);
}
};
function registry() {
return new $ZodRegistry();
}
(_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
// @__NO_SIDE_EFFECTS__
function _string(Class, params) {
return new Class({
type: "string",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _url(Class, params) {
return new Class({
type: "string",
format: "url",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _boolean(Class, params) {
return new Class({
type: "boolean",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _any(Class) {
return new Class({
type: "any"
});
}
// @__NO_SIDE_EFFECTS__
function _length(length, params) {
return new $ZodCheckLengthEquals({
check: "length_equals",
...normalizeParams(params),
length
});
}
// @__NO_SIDE_EFFECTS__
function _regex(pattern, params) {
return new $ZodCheckRegex({
check: "string_format",
format: "regex",
...normalizeParams(params),
pattern
});
}
// @__NO_SIDE_EFFECTS__
function _overwrite(tx) {
return new $ZodCheckOverwrite({
check: "overwrite",
tx
});
}
// @__NO_SIDE_EFFECTS__
function _trim() {
return /* @__PURE__ */ _overwrite((input) => input.trim());
}
// @__NO_SIDE_EFFECTS__
function _toLowerCase() {
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
}
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/mini/schemas.js
var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
if (!inst._zod)
throw new Error("Uninitialized schema in ZodMiniType.");
$ZodType.init(inst, def);
inst.def = def;
inst.type = def.type;
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
inst.safeParse = (data, params) => safeParse(inst, data, params);
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
inst.check = (...checks) => {
return inst.clone({
...def,
checks: [
...def.checks ?? [],
...checks.map((ch) => typeof ch === "function" ? {
_zod: { check: ch, def: { check: "custom" }, onattach: [] }
} : ch)
]
}, { parent: true });
};
inst.with = inst.check;
inst.clone = (_def, params) => clone(inst, _def, params);
inst.brand = () => inst;
inst.register = ((reg, meta2) => {
reg.add(inst, meta2);
return inst;
});
inst.apply = (fn) => fn(inst);
});
var ZodMiniString = /* @__PURE__ */ $constructor("ZodMiniString", (inst, def) => {
$ZodString.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function string2(params) {
return _string(ZodMiniString, params);
}
var ZodMiniStringFormat = /* @__PURE__ */ $constructor("ZodMiniStringFormat", (inst, def) => {
$ZodStringFormat.init(inst, def);
ZodMiniString.init(inst, def);
});
var ZodMiniURL = /* @__PURE__ */ $constructor("ZodMiniURL", (inst, def) => {
$ZodURL.init(inst, def);
ZodMiniStringFormat.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function url(params) {
return _url(ZodMiniURL, params);
}
var ZodMiniBoolean = /* @__PURE__ */ $constructor("ZodMiniBoolean", (inst, def) => {
$ZodBoolean.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function boolean2(params) {
return _boolean(ZodMiniBoolean, params);
}
var ZodMiniAny = /* @__PURE__ */ $constructor("ZodMiniAny", (inst, def) => {
$ZodAny.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function any() {
return _any(ZodMiniAny);
}
var ZodMiniArray = /* @__PURE__ */ $constructor("ZodMiniArray", (inst, def) => {
$ZodArray.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function array(element, params) {
return new ZodMiniArray({
type: "array",
element,
...normalizeParams(params)
});
}
var ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
$ZodObject.init(inst, def);
ZodMiniType.init(inst, def);
defineLazy(inst, "shape", () => def.shape);
});
// @__NO_SIDE_EFFECTS__
function object(shape, params) {
const def = {
type: "object",
shape: shape ?? {},
...normalizeParams(params)
};
return new ZodMiniObject(def);
}
var ZodMiniUnion = /* @__PURE__ */ $constructor("ZodMiniUnion", (inst, def) => {
$ZodUnion.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function union(options, params) {
return new ZodMiniUnion({
type: "union",
options,
...normalizeParams(params)
});
}
var ZodMiniRecord = /* @__PURE__ */ $constructor("ZodMiniRecord", (inst, def) => {
$ZodRecord.init(inst, def);
ZodMiniType.init(inst, def);
});
// @__NO_SIDE_EFFECTS__
function record(keyType, valueType, params) {
if (!valueType || !valueType._zod) {
return ne