cdk-insights
Version:
AWS CDK security and cost analysis tool with AI-powered insights
1,355 lines (1,341 loc) • 1.42 MB
JavaScript
#!/usr/bin/env node
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/strogger/dist/formatters/json-formatter.js
var require_json_formatter = __commonJS({
"node_modules/strogger/dist/formatters/json-formatter.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.createJsonFormatter = void 0;
var getLevelName = (level) => {
switch (level) {
case 0:
return "DEBUG";
case 1:
return "INFO";
case 2:
return "WARN";
case 3:
return "ERROR";
case 4:
return "FATAL";
default:
return "UNKNOWN";
}
};
var createJsonFormatter2 = () => {
return {
format: (entry) => {
return JSON.stringify({
timestamp: entry.timestamp,
level: getLevelName(entry.level),
message: entry.message,
...entry.context,
...entry.error && {
error: {
name: entry.error.name,
message: entry.error.message,
stack: entry.error.stack
}
},
...entry.metadata && { metadata: entry.metadata }
});
}
};
};
exports2.createJsonFormatter = createJsonFormatter2;
}
});
// node_modules/strogger/dist/types.js
var require_types = __commonJS({
"node_modules/strogger/dist/types.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.LogLevel = void 0;
var LogLevel2;
(function(LogLevel3) {
LogLevel3[LogLevel3["DEBUG"] = 0] = "DEBUG";
LogLevel3[LogLevel3["INFO"] = 1] = "INFO";
LogLevel3[LogLevel3["WARN"] = 2] = "WARN";
LogLevel3[LogLevel3["ERROR"] = 3] = "ERROR";
LogLevel3[LogLevel3["FATAL"] = 4] = "FATAL";
})(LogLevel2 || (exports2.LogLevel = LogLevel2 = {}));
}
});
// node_modules/strogger/dist/transports/base-transport.js
var require_base_transport = __commonJS({
"node_modules/strogger/dist/transports/base-transport.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.shouldLog = exports2.BaseTransport = void 0;
var types_1 = require_types();
var BaseTransport = class {
constructor() {
this.level = types_1.LogLevel.INFO;
}
setLevel(level) {
this.level = level;
}
getLevel() {
return this.level;
}
shouldLog(entryLevel) {
return entryLevel >= this.level;
}
};
exports2.BaseTransport = BaseTransport;
var shouldLog = (entryLevel, minLevel) => {
return entryLevel >= minLevel;
};
exports2.shouldLog = shouldLog;
}
});
// node_modules/strogger/dist/transports/console-transport.js
var require_console_transport = __commonJS({
"node_modules/strogger/dist/transports/console-transport.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.createConsoleTransport = void 0;
var types_1 = require_types();
var base_transport_1 = require_base_transport();
var createConsoleTransport = (options = {}) => {
let minLevel = options.level ?? types_1.LogLevel.INFO;
const formatter = options.formatter || {
format: (entry) => JSON.stringify(entry)
};
return {
log: (entry) => {
if (!(0, base_transport_1.shouldLog)(entry.level, minLevel))
return;
const formattedMessage = formatter.format(entry);
switch (entry.level) {
case types_1.LogLevel.DEBUG:
console.debug(formattedMessage);
break;
case types_1.LogLevel.INFO:
console.info(formattedMessage);
break;
case types_1.LogLevel.WARN:
console.warn(formattedMessage);
break;
case types_1.LogLevel.ERROR:
case types_1.LogLevel.FATAL:
console.error(formattedMessage);
break;
}
},
setLevel: (level) => {
minLevel = level;
},
getLevel: () => {
return minLevel;
}
};
};
exports2.createConsoleTransport = createConsoleTransport;
}
});
// node_modules/strogger/dist/utils/batching.js
var require_batching = __commonJS({
"node_modules/strogger/dist/utils/batching.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.createBatchedLogger = exports2.createBatchedTransport = void 0;
var createBatchedTransport = (transport, config = {
maxSize: 100,
maxWaitTime: 5e3,
maxBatchSize: 1024 * 1024
// 1MB
}) => {
const state2 = {
logs: [],
currentSize: 0,
lastFlush: Date.now()
};
const stats = {
totalLogs: 0,
totalBatches: 0,
averageBatchSize: 0,
lastFlushTime: 0,
pendingLogs: 0
};
const calculateBatchSize = (logs) => {
return logs.reduce((size, log2) => {
return size + JSON.stringify(log2).length;
}, 0);
};
const flush = async () => {
if (state2.logs.length === 0)
return;
const logsToSend = [...state2.logs];
state2.logs = [];
state2.currentSize = 0;
state2.lastFlush = Date.now();
if (state2.flushTimer) {
clearTimeout(state2.flushTimer);
state2.flushTimer = void 0;
}
try {
await Promise.allSettled(logsToSend.map((log2) => transport.log(log2)));
stats.totalLogs += logsToSend.length;
stats.totalBatches += 1;
stats.averageBatchSize = stats.totalLogs / stats.totalBatches;
stats.lastFlushTime = Date.now();
stats.pendingLogs = state2.logs.length;
} catch (error) {
console.error("Batch flush failed:", error);
state2.logs.unshift(...logsToSend);
state2.currentSize = calculateBatchSize(state2.logs);
}
};
const scheduleFlush = () => {
if (state2.flushTimer)
return;
state2.flushTimer = setTimeout(() => {
flush().catch(console.error);
}, config.maxWaitTime);
};
const log = async (entry) => {
const entrySize = JSON.stringify(entry).length;
if (state2.logs.length >= config.maxSize || state2.currentSize + entrySize >= config.maxBatchSize) {
await flush();
}
state2.logs.push(entry);
state2.currentSize += entrySize;
stats.pendingLogs = state2.logs.length;
if (state2.logs.length === 1) {
scheduleFlush();
}
};
const setLevel = (level) => {
transport.setLevel(level);
};
const getLevel = () => {
return transport.getLevel();
};
const getStats = () => {
return { ...stats, pendingLogs: state2.logs.length };
};
return {
log,
setLevel,
getLevel,
flush,
getStats
};
};
exports2.createBatchedTransport = createBatchedTransport;
var createBatchedLogger = (transports, config = {
maxSize: 50,
maxWaitTime: 2e3,
maxBatchSize: 512 * 1024
// 512KB
}) => {
const batchedTransports = transports.map((transport) => (0, exports2.createBatchedTransport)(transport, config));
const log = async (entry) => {
await Promise.allSettled(batchedTransports.map((transport) => transport.log(entry)));
};
const setLevel = (level) => {
for (const transport of batchedTransports) {
transport.setLevel(level);
}
};
const getLevel = () => {
return Math.min(...batchedTransports.map((t3) => t3.getLevel()));
};
const flush = async () => {
await Promise.allSettled(batchedTransports.map((transport) => transport.flush()));
};
const getStats = () => {
return batchedTransports.map((transport) => transport.getStats());
};
return {
log,
setLevel,
getLevel,
flush,
getStats
};
};
exports2.createBatchedLogger = createBatchedLogger;
}
});
// node_modules/strogger/dist/utils/enrichment.js
var require_enrichment = __commonJS({
"node_modules/strogger/dist/utils/enrichment.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.createDefaultEnrichmentMiddleware = exports2.createEnrichmentMiddleware = exports2.createLoggerInstanceEnricher = exports2.createUserEnricher = exports2.createEnvironmentEnricher = exports2.createSessionEnricher = exports2.createCorrelationEnricher = exports2.generateLoggerInstanceId = exports2.generateSpanId = exports2.generateTraceId = exports2.generateCorrelationId = void 0;
var generateCorrelationId = () => {
return `corr_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
};
exports2.generateCorrelationId = generateCorrelationId;
var generateTraceId = () => {
return Math.random().toString(16).substr(2, 32);
};
exports2.generateTraceId = generateTraceId;
var generateSpanId = () => {
return Math.random().toString(16).substr(2, 16);
};
exports2.generateSpanId = generateSpanId;
var generateLoggerInstanceId = () => {
const timestamp = Date.now();
const random = Math.random().toString(36).substr(2, 9);
const processId = process.pid || 0;
return `logger_${timestamp}_${random}_${processId}`;
};
exports2.generateLoggerInstanceId = generateLoggerInstanceId;
var createCorrelationEnricher = () => {
let currentCorrelationId;
let currentTraceId;
let currentSpanId;
return {
name: "correlation",
enrich: (context) => {
if (!context.correlationId) {
currentCorrelationId = currentCorrelationId || (0, exports2.generateCorrelationId)();
context.correlationId = currentCorrelationId;
}
if (!context.traceId) {
currentTraceId = currentTraceId || (0, exports2.generateTraceId)();
context.traceId = currentTraceId;
}
if (!context.spanId) {
currentSpanId = currentSpanId || (0, exports2.generateSpanId)();
context.spanId = currentSpanId;
}
return context;
}
};
};
exports2.createCorrelationEnricher = createCorrelationEnricher;
var createSessionEnricher = (sessionId) => {
const currentSessionId = sessionId || `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
return {
name: "session",
enrich: (context) => {
if (!context.sessionId) {
context.sessionId = currentSessionId;
}
return context;
}
};
};
exports2.createSessionEnricher = createSessionEnricher;
var createEnvironmentEnricher = (serviceName, stage) => {
return {
name: "environment",
enrich: (context) => {
if (serviceName && !context.serviceName) {
context.serviceName = serviceName;
}
if (stage && !context.stage) {
context.stage = stage;
}
return context;
}
};
};
exports2.createEnvironmentEnricher = createEnvironmentEnricher;
var createUserEnricher = (userId) => {
return {
name: "user",
enrich: (context) => {
if (userId && !context.userId) {
context.userId = userId;
}
return context;
}
};
};
exports2.createUserEnricher = createUserEnricher;
var createLoggerInstanceEnricher = (instanceId) => {
return {
name: "loggerInstance",
enrich: (context) => {
if (!context.instanceId) {
context.instanceId = instanceId;
}
return context;
}
};
};
exports2.createLoggerInstanceEnricher = createLoggerInstanceEnricher;
var createEnrichmentMiddleware = (enrichers) => {
return (context) => {
return enrichers.reduce((enrichedContext, enricher) => {
return enricher.enrich(enrichedContext);
}, { ...context });
};
};
exports2.createEnrichmentMiddleware = createEnrichmentMiddleware;
var createDefaultEnrichmentMiddleware = (serviceName, stage, sessionId, instanceId) => {
const enrichers = [
(0, exports2.createCorrelationEnricher)(),
(0, exports2.createSessionEnricher)(sessionId),
(0, exports2.createEnvironmentEnricher)(serviceName, stage)
];
if (instanceId) {
enrichers.push((0, exports2.createLoggerInstanceEnricher)(instanceId));
}
return (0, exports2.createEnrichmentMiddleware)(enrichers);
};
exports2.createDefaultEnrichmentMiddleware = createDefaultEnrichmentMiddleware;
}
});
// node_modules/zod/v3/helpers/util.cjs
var require_util = __commonJS({
"node_modules/zod/v3/helpers/util.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.getParsedType = exports2.ZodParsedType = exports2.objectUtil = exports2.util = void 0;
var util;
(function(util2) {
util2.assertEqual = (_2) => {
};
function assertIs(_arg) {
}
util2.assertIs = assertIs;
function assertNever(_x) {
throw new Error();
}
util2.assertNever = assertNever;
util2.arrayToEnum = (items) => {
const obj = {};
for (const item of items) {
obj[item] = item;
}
return obj;
};
util2.getValidEnumValues = (obj) => {
const validKeys = util2.objectKeys(obj).filter((k3) => typeof obj[obj[k3]] !== "number");
const filtered = {};
for (const k3 of validKeys) {
filtered[k3] = obj[k3];
}
return util2.objectValues(filtered);
};
util2.objectValues = (obj) => {
return util2.objectKeys(obj).map(function(e3) {
return obj[e3];
});
};
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
const keys = [];
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
keys.push(key);
}
}
return keys;
};
util2.find = (arr, checker) => {
for (const item of arr) {
if (checker(item))
return item;
}
return void 0;
};
util2.isInteger = typeof Number.isInteger === "function" ? (val2) => Number.isInteger(val2) : (val2) => typeof val2 === "number" && Number.isFinite(val2) && Math.floor(val2) === val2;
function joinValues(array, separator = " | ") {
return array.map((val2) => typeof val2 === "string" ? `'${val2}'` : val2).join(separator);
}
util2.joinValues = joinValues;
util2.jsonStringifyReplacer = (_2, value) => {
if (typeof value === "bigint") {
return value.toString();
}
return value;
};
})(util || (exports2.util = util = {}));
var objectUtil;
(function(objectUtil2) {
objectUtil2.mergeShapes = (first, second) => {
return {
...first,
...second
// second overwrites first
};
};
})(objectUtil || (exports2.objectUtil = objectUtil = {}));
exports2.ZodParsedType = util.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set"
]);
var getParsedType = (data) => {
const t3 = typeof data;
switch (t3) {
case "undefined":
return exports2.ZodParsedType.undefined;
case "string":
return exports2.ZodParsedType.string;
case "number":
return Number.isNaN(data) ? exports2.ZodParsedType.nan : exports2.ZodParsedType.number;
case "boolean":
return exports2.ZodParsedType.boolean;
case "function":
return exports2.ZodParsedType.function;
case "bigint":
return exports2.ZodParsedType.bigint;
case "symbol":
return exports2.ZodParsedType.symbol;
case "object":
if (Array.isArray(data)) {
return exports2.ZodParsedType.array;
}
if (data === null) {
return exports2.ZodParsedType.null;
}
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
return exports2.ZodParsedType.promise;
}
if (typeof Map !== "undefined" && data instanceof Map) {
return exports2.ZodParsedType.map;
}
if (typeof Set !== "undefined" && data instanceof Set) {
return exports2.ZodParsedType.set;
}
if (typeof Date !== "undefined" && data instanceof Date) {
return exports2.ZodParsedType.date;
}
return exports2.ZodParsedType.object;
default:
return exports2.ZodParsedType.unknown;
}
};
exports2.getParsedType = getParsedType;
}
});
// node_modules/zod/v3/ZodError.cjs
var require_ZodError = __commonJS({
"node_modules/zod/v3/ZodError.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.ZodError = exports2.quotelessJson = exports2.ZodIssueCode = void 0;
var util_js_1 = require_util();
exports2.ZodIssueCode = util_js_1.util.arrayToEnum([
"invalid_type",
"invalid_literal",
"custom",
"invalid_union",
"invalid_union_discriminator",
"invalid_enum_value",
"unrecognized_keys",
"invalid_arguments",
"invalid_return_type",
"invalid_date",
"invalid_string",
"too_small",
"too_big",
"invalid_intersection_types",
"not_multiple_of",
"not_finite"
]);
var quotelessJson = (obj) => {
const json = JSON.stringify(obj, null, 2);
return json.replace(/"([^"]+)":/g, "$1:");
};
exports2.quotelessJson = quotelessJson;
var ZodError = class _ZodError extends Error {
get errors() {
return this.issues;
}
constructor(issues) {
super();
this.issues = [];
this.addIssue = (sub) => {
this.issues = [...this.issues, sub];
};
this.addIssues = (subs = []) => {
this.issues = [...this.issues, ...subs];
};
const actualProto = new.target.prototype;
if (Object.setPrototypeOf) {
Object.setPrototypeOf(this, actualProto);
} else {
this.__proto__ = actualProto;
}
this.name = "ZodError";
this.issues = issues;
}
format(_mapper) {
const mapper = _mapper || function(issue) {
return issue.message;
};
const fieldErrors = { _errors: [] };
const processError = (error) => {
for (const issue of error.issues) {
if (issue.code === "invalid_union") {
issue.unionErrors.map(processError);
} else if (issue.code === "invalid_return_type") {
processError(issue.returnTypeError);
} else if (issue.code === "invalid_arguments") {
processError(issue.argumentsError);
} else if (issue.path.length === 0) {
fieldErrors._errors.push(mapper(issue));
} else {
let curr = fieldErrors;
let i3 = 0;
while (i3 < issue.path.length) {
const el = issue.path[i3];
const terminal = i3 === issue.path.length - 1;
if (!terminal) {
curr[el] = curr[el] || { _errors: [] };
} else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue));
}
curr = curr[el];
i3++;
}
}
}
};
processError(this);
return fieldErrors;
}
static assert(value) {
if (!(value instanceof _ZodError)) {
throw new Error(`Not a ZodError: ${value}`);
}
}
toString() {
return this.message;
}
get message() {
return JSON.stringify(this.issues, util_js_1.util.jsonStringifyReplacer, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(mapper = (issue) => issue.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of this.issues) {
if (sub.path.length > 0) {
const firstEl = sub.path[0];
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
fieldErrors[firstEl].push(mapper(sub));
} else {
formErrors.push(mapper(sub));
}
}
return { formErrors, fieldErrors };
}
get formErrors() {
return this.flatten();
}
};
exports2.ZodError = ZodError;
ZodError.create = (issues) => {
const error = new ZodError(issues);
return error;
};
}
});
// node_modules/zod/v3/locales/en.cjs
var require_en = __commonJS({
"node_modules/zod/v3/locales/en.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var ZodError_js_1 = require_ZodError();
var util_js_1 = require_util();
var errorMap = (issue, _ctx) => {
let message;
switch (issue.code) {
case ZodError_js_1.ZodIssueCode.invalid_type:
if (issue.received === util_js_1.ZodParsedType.undefined) {
message = "Required";
} else {
message = `Expected ${issue.expected}, received ${issue.received}`;
}
break;
case ZodError_js_1.ZodIssueCode.invalid_literal:
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_js_1.util.jsonStringifyReplacer)}`;
break;
case ZodError_js_1.ZodIssueCode.unrecognized_keys:
message = `Unrecognized key(s) in object: ${util_js_1.util.joinValues(issue.keys, ", ")}`;
break;
case ZodError_js_1.ZodIssueCode.invalid_union:
message = `Invalid input`;
break;
case ZodError_js_1.ZodIssueCode.invalid_union_discriminator:
message = `Invalid discriminator value. Expected ${util_js_1.util.joinValues(issue.options)}`;
break;
case ZodError_js_1.ZodIssueCode.invalid_enum_value:
message = `Invalid enum value. Expected ${util_js_1.util.joinValues(issue.options)}, received '${issue.received}'`;
break;
case ZodError_js_1.ZodIssueCode.invalid_arguments:
message = `Invalid function arguments`;
break;
case ZodError_js_1.ZodIssueCode.invalid_return_type:
message = `Invalid function return type`;
break;
case ZodError_js_1.ZodIssueCode.invalid_date:
message = `Invalid date`;
break;
case ZodError_js_1.ZodIssueCode.invalid_string:
if (typeof issue.validation === "object") {
if ("includes" in issue.validation) {
message = `Invalid input: must include "${issue.validation.includes}"`;
if (typeof issue.validation.position === "number") {
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
}
} else if ("startsWith" in issue.validation) {
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
} else if ("endsWith" in issue.validation) {
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
} else {
util_js_1.util.assertNever(issue.validation);
}
} else if (issue.validation !== "regex") {
message = `Invalid ${issue.validation}`;
} else {
message = "Invalid";
}
break;
case ZodError_js_1.ZodIssueCode.too_small:
if (issue.type === "array")
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
else if (issue.type === "number")
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
else if (issue.type === "bigint")
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
else if (issue.type === "date")
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
else
message = "Invalid input";
break;
case ZodError_js_1.ZodIssueCode.too_big:
if (issue.type === "array")
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
else if (issue.type === "string")
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
else if (issue.type === "number")
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
else if (issue.type === "bigint")
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
else if (issue.type === "date")
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
else
message = "Invalid input";
break;
case ZodError_js_1.ZodIssueCode.custom:
message = `Invalid input`;
break;
case ZodError_js_1.ZodIssueCode.invalid_intersection_types:
message = `Intersection results could not be merged`;
break;
case ZodError_js_1.ZodIssueCode.not_multiple_of:
message = `Number must be a multiple of ${issue.multipleOf}`;
break;
case ZodError_js_1.ZodIssueCode.not_finite:
message = "Number must be finite";
break;
default:
message = _ctx.defaultError;
util_js_1.util.assertNever(issue);
}
return { message };
};
exports2.default = errorMap;
}
});
// node_modules/zod/v3/errors.cjs
var require_errors = __commonJS({
"node_modules/zod/v3/errors.cjs"(exports2) {
"use strict";
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.defaultErrorMap = void 0;
exports2.setErrorMap = setErrorMap;
exports2.getErrorMap = getErrorMap;
var en_js_1 = __importDefault2(require_en());
exports2.defaultErrorMap = en_js_1.default;
var overrideErrorMap = en_js_1.default;
function setErrorMap(map2) {
overrideErrorMap = map2;
}
function getErrorMap() {
return overrideErrorMap;
}
}
});
// node_modules/zod/v3/helpers/parseUtil.cjs
var require_parseUtil = __commonJS({
"node_modules/zod/v3/helpers/parseUtil.cjs"(exports2) {
"use strict";
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.isAsync = exports2.isValid = exports2.isDirty = exports2.isAborted = exports2.OK = exports2.DIRTY = exports2.INVALID = exports2.ParseStatus = exports2.EMPTY_PATH = exports2.makeIssue = void 0;
exports2.addIssueToContext = addIssueToContext;
var errors_js_1 = require_errors();
var en_js_1 = __importDefault2(require_en());
var makeIssue = (params) => {
const { data, path, errorMaps, issueData } = params;
const fullPath = [...path, ...issueData.path || []];
const fullIssue = {
...issueData,
path: fullPath
};
if (issueData.message !== void 0) {
return {
...issueData,
path: fullPath,
message: issueData.message
};
}
let errorMessage = "";
const maps = errorMaps.filter((m3) => !!m3).slice().reverse();
for (const map2 of maps) {
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
}
return {
...issueData,
path: fullPath,
message: errorMessage
};
};
exports2.makeIssue = makeIssue;
exports2.EMPTY_PATH = [];
function addIssueToContext(ctx, issueData) {
const overrideMap = (0, errors_js_1.getErrorMap)();
const issue = (0, exports2.makeIssue)({
issueData,
data: ctx.data,
path: ctx.path,
errorMaps: [
ctx.common.contextualErrorMap,
// contextual error map is first priority
ctx.schemaErrorMap,
// then schema-bound map if available
overrideMap,
// then global override map
overrideMap === en_js_1.default ? void 0 : en_js_1.default
// then global default map
].filter((x3) => !!x3)
});
ctx.common.issues.push(issue);
}
var ParseStatus = class _ParseStatus {
constructor() {
this.value = "valid";
}
dirty() {
if (this.value === "valid")
this.value = "dirty";
}
abort() {
if (this.value !== "aborted")
this.value = "aborted";
}
static mergeArray(status, results) {
const arrayValue = [];
for (const s3 of results) {
if (s3.status === "aborted")
return exports2.INVALID;
if (s3.status === "dirty")
status.dirty();
arrayValue.push(s3.value);
}
return { status: status.value, value: arrayValue };
}
static async mergeObjectAsync(status, pairs) {
const syncPairs = [];
for (const pair of pairs) {
const key = await pair.key;
const value = await pair.value;
syncPairs.push({
key,
value
});
}
return _ParseStatus.mergeObjectSync(status, syncPairs);
}
static mergeObjectSync(status, pairs) {
const finalObject = {};
for (const pair of pairs) {
const { key, value } = pair;
if (key.status === "aborted")
return exports2.INVALID;
if (value.status === "aborted")
return exports2.INVALID;
if (key.status === "dirty")
status.dirty();
if (value.status === "dirty")
status.dirty();
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
finalObject[key.value] = value.value;
}
}
return { status: status.value, value: finalObject };
}
};
exports2.ParseStatus = ParseStatus;
exports2.INVALID = Object.freeze({
status: "aborted"
});
var DIRTY = (value) => ({ status: "dirty", value });
exports2.DIRTY = DIRTY;
var OK = (value) => ({ status: "valid", value });
exports2.OK = OK;
var isAborted = (x3) => x3.status === "aborted";
exports2.isAborted = isAborted;
var isDirty = (x3) => x3.status === "dirty";
exports2.isDirty = isDirty;
var isValid = (x3) => x3.status === "valid";
exports2.isValid = isValid;
var isAsync = (x3) => typeof Promise !== "undefined" && x3 instanceof Promise;
exports2.isAsync = isAsync;
}
});
// node_modules/zod/v3/helpers/typeAliases.cjs
var require_typeAliases = __commonJS({
"node_modules/zod/v3/helpers/typeAliases.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
}
});
// node_modules/zod/v3/helpers/errorUtil.cjs
var require_errorUtil = __commonJS({
"node_modules/zod/v3/helpers/errorUtil.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.errorUtil = void 0;
var errorUtil;
(function(errorUtil2) {
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
})(errorUtil || (exports2.errorUtil = errorUtil = {}));
}
});
// node_modules/zod/v3/types.cjs
var require_types2 = __commonJS({
"node_modules/zod/v3/types.cjs"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.discriminatedUnion = exports2.date = exports2.boolean = exports2.bigint = exports2.array = exports2.any = exports2.coerce = exports2.ZodFirstPartyTypeKind = exports2.late = exports2.ZodSchema = exports2.Schema = exports2.ZodReadonly = exports2.ZodPipeline = exports2.ZodBranded = exports2.BRAND = exports2.ZodNaN = exports2.ZodCatch = exports2.ZodDefault = exports2.ZodNullable = exports2.ZodOptional = exports2.ZodTransformer = exports2.ZodEffects = exports2.ZodPromise = exports2.ZodNativeEnum = exports2.ZodEnum = exports2.ZodLiteral = exports2.ZodLazy = exports2.ZodFunction = exports2.ZodSet = exports2.ZodMap = exports2.ZodRecord = exports2.ZodTuple = exports2.ZodIntersection = exports2.ZodDiscriminatedUnion = exports2.ZodUnion = exports2.ZodObject = exports2.ZodArray = exports2.ZodVoid = exports2.ZodNever = exports2.ZodUnknown = exports2.ZodAny = exports2.ZodNull = exports2.ZodUndefined = exports2.ZodSymbol = exports2.ZodDate = exports2.ZodBoolean = exports2.ZodBigInt = exports2.ZodNumber = exports2.ZodString = exports2.ZodType = void 0;
exports2.NEVER = exports2.void = exports2.unknown = exports2.union = exports2.undefined = exports2.tuple = exports2.transformer = exports2.symbol = exports2.string = exports2.strictObject = exports2.set = exports2.record = exports2.promise = exports2.preprocess = exports2.pipeline = exports2.ostring = exports2.optional = exports2.onumber = exports2.oboolean = exports2.object = exports2.number = exports2.nullable = exports2.null = exports2.never = exports2.nativeEnum = exports2.nan = exports2.map = exports2.literal = exports2.lazy = exports2.intersection = exports2.instanceof = exports2.function = exports2.enum = exports2.effect = void 0;
exports2.datetimeRegex = datetimeRegex;
exports2.custom = custom;
var ZodError_js_1 = require_ZodError();
var errors_js_1 = require_errors();
var errorUtil_js_1 = require_errorUtil();
var parseUtil_js_1 = require_parseUtil();
var util_js_1 = require_util();
var ParseInputLazyPath = class {
constructor(parent, value, path, key) {
this._cachedPath = [];
this.parent = parent;
this.data = value;
this._path = path;
this._key = key;
}
get path() {
if (!this._cachedPath.length) {
if (Array.isArray(this._key)) {
this._cachedPath.push(...this._path, ...this._key);
} else {
this._cachedPath.push(...this._path, this._key);
}
}
return this._cachedPath;
}
};
var handleResult = (ctx, result) => {
if ((0, parseUtil_js_1.isValid)(result)) {
return { success: true, data: result.value };
} else {
if (!ctx.common.issues.length) {
throw new Error("Validation failed but no issues detected.");
}
return {
success: false,
get error() {
if (this._error)
return this._error;
const error = new ZodError_js_1.ZodError(ctx.common.issues);
this._error = error;
return this._error;
}
};
}
};
function processCreateParams(params) {
if (!params)
return {};
const { errorMap, invalid_type_error, required_error, description } = params;
if (errorMap && (invalid_type_error || required_error)) {
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
}
if (errorMap)
return { errorMap, description };
const customMap = (iss, ctx) => {
const { message } = params;
if (iss.code === "invalid_enum_value") {
return { message: message ?? ctx.defaultError };
}
if (typeof ctx.data === "undefined") {
return { message: message ?? required_error ?? ctx.defaultError };
}
if (iss.code !== "invalid_type")
return { message: ctx.defaultError };
return { message: message ?? invalid_type_error ?? ctx.defaultError };
};
return { errorMap: customMap, description };
}
var ZodType = class {
get description() {
return this._def.description;
}
_getType(input) {
return (0, util_js_1.getParsedType)(input.data);
}
_getOrReturnCtx(input, ctx) {
return ctx || {
common: input.parent.common,
data: input.data,
parsedType: (0, util_js_1.getParsedType)(input.data),
schemaErrorMap: this._def.errorMap,
path: input.path,
parent: input.parent
};
}
_processInputParams(input) {
return {
status: new parseUtil_js_1.ParseStatus(),
ctx: {
common: input.parent.common,
data: input.data,
parsedType: (0, util_js_1.getParsedType)(input.data),
schemaErrorMap: this._def.errorMap,
path: input.path,
parent: input.parent
}
};
}
_parseSync(input) {
const result = this._parse(input);
if ((0, parseUtil_js_1.isAsync)(result)) {
throw new Error("Synchronous parse encountered promise.");
}
return result;
}
_parseAsync(input) {
const result = this._parse(input);
return Promise.resolve(result);
}
parse(data, params) {
const result = this.safeParse(data, params);
if (result.success)
return result.data;
throw result.error;
}
safeParse(data, params) {
const ctx = {
common: {
issues: [],
async: params?.async ?? false,
contextualErrorMap: params?.errorMap
},
path: params?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data,
parsedType: (0, util_js_1.getParsedType)(data)
};
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
return handleResult(ctx, result);
}
"~validate"(data) {
const ctx = {
common: {
issues: [],
async: !!this["~standard"].async
},
path: [],
schemaErrorMap: this._def.errorMap,
parent: null,
data,
parsedType: (0, util_js_1.getParsedType)(data)
};
if (!this["~standard"].async) {
try {
const result = this._parseSync({ data, path: [], parent: ctx });
return (0, parseUtil_js_1.isValid)(result) ? {
value: result.value
} : {
issues: ctx.common.issues
};
} catch (err) {
if (err?.message?.toLowerCase()?.includes("encountered")) {
this["~standard"].async = true;
}
ctx.common = {
issues: [],
async: true
};
}
}
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_js_1.isValid)(result) ? {
value: result.value
} : {
issues: ctx.common.issues
});
}
async parseAsync(data, params) {
const result = await this.safeParseAsync(data, params);
if (result.success)
return result.data;
throw result.error;
}
async safeParseAsync(data, params) {
const ctx = {
common: {
issues: [],
contextualErrorMap: params?.errorMap,
async: true
},
path: params?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data,
parsedType: (0, util_js_1.getParsedType)(data)
};
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
const result = await ((0, parseUtil_js_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
return handleResult(ctx, result);
}
refine(check, message) {
const getIssueProperties = (val2) => {
if (typeof message === "string" || typeof message === "undefined") {
return { message };
} else if (typeof message === "function") {
return message(val2);
} else {
return message;
}
};
return this._refinement((val2, ctx) => {
const result = check(val2);
const setError = () => ctx.addIssue({
code: ZodError_js_1.ZodIssueCode.custom,
...getIssueProperties(val2)
});
if (typeof Promise !== "undefined" && result instanceof Promise) {
return result.then((data) => {
if (!data) {
setError();
return false;
} else {
return true;
}
});
}
if (!result) {
setError();
return false;
} else {
return true;
}
});
}
refinement(check, refinementData) {
return this._refinement((val2, ctx) => {
if (!check(val2)) {
ctx.addIssue(typeof refinementData === "function" ? refinementData(val2, ctx) : refinementData);
return false;
} else {
return true;
}
});
}
_refinement(refinement) {
return new ZodEffects({
schema: this,
typeName: ZodFirstPartyTypeKind.ZodEffects,
effect: { type: "refinement", refinement }
});
}
superRefine(refinement) {
return this._refinement(refinement);
}
constructor(def) {
this.spa = this.safeParseAsync;
this._def = def;
this.parse = this.parse.bind(this);
this.safeParse = this.safeParse.bind(this);
this.parseAsync = this.parseAsync.bind(this);
this.safeParseAsync = this.safeParseAsync.bind(this);
this.spa = this.spa.bind(this);
this.refine = this.refine.bind(this);
this.refinement = this.refinement.bind(this);
this.superRefine = this.superRefine.bind(this);
this.optional = this.optional.bind(this);
this.nullable = this.nullable.bind(this);
this.nullish = this.nullish.bind(this);
this.array = this.array.bind(this);
this.promise = this.promise.bind(this);
this.or = this.or.bind(this);
this.and = this.and.bind(this);
this.transform = this.transform.bind(this);
this.brand = this.brand.bind(this);
this.default = this.default.bind(this);
this.catch = this.catch.bind(this);
this.describe = this.describe.bind(this);
this.pipe = this.pipe.bind(this);
this.readonly = this.readonly.bind(this);
this.isNullable = this.isNullable.bind(this);
this.isOptional = this.isOptional.bind(this);
this["~standard"] = {
version: 1,
vendor: "zod",
validate: (data) => this["~validate"](data)
};
}
optional() {
return ZodOptional.create(this, this._def);
}
nullable() {
return ZodNullable.create(this, this._def);
}
nullish() {
return this.nullable().optional();
}
array() {
return ZodArray.create(this);
}
promise() {
return ZodPromise.create(this, this._def);
}
or(option) {
return ZodUnion.create([this, option], this._def);
}
and(incoming) {
return ZodIntersection.create(this, incoming, this._def);
}
transform(transform) {
return new ZodEffects({
...processCreateParams(this._def),
schema: this,
typeName: ZodFirstPartyTypeKind.ZodEffects,
effect: { type: "transform", transform }
});
}
default(def) {
const defaultValueFunc = typeof def === "function" ? def : () => def;
return new ZodDefault({
...processCreateParams(this._def),
innerType: this,
defaultValue: defaultValueFunc,
typeName: ZodFirstPartyTypeKind.ZodDefault
});
}
brand() {
return new ZodBranded({
typeName: ZodFirstPartyTypeKind.ZodBranded,
type: this,
...processCreateParams(this._def)
});
}
catch(def) {
const catchValueFunc = typeof def === "function" ? def : () => def;
return new ZodCatch({
...processCreateParams(this._def),
innerType: this,
catchValue: catchValueFunc,
typeName: ZodFirstPartyTypeKind.ZodCatch
});
}
describe(description) {
const This = this.constructor;
return new This({
...this._def,
description
});
}
pipe(target) {
return ZodPipeline.create(this, target);
}
readonly() {
return ZodReadonly.create(this);
}
isOptional() {
return this.safeParse(void 0).success;
}
isNullable() {
return this.safeParse(null).success;
}
};
exports2.ZodType = ZodType;
exports2.Schema = ZodType;
exports2.ZodSchema = ZodType;
var cuidRegex = /^c[^\s-]{8,}$/i;
var cuid2Regex = /^[0-9a-z]+$/;
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
var emojiRegex;
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,