From 842f65660c90e78fc21bca30e1f16b13c14d6889 Mon Sep 17 00:00:00 2001 From: QA Wolf bot Date: Tue, 28 Jan 2025 14:04:37 +0000 Subject: [PATCH] Version update to v1.1.1, revision 7fe6f0e --- CHANGELOG.md | 4 + dist/index.js | 5837 +++------------------ package.json | 2 +- src/extractRelevantDataFromEvent/index.ts | 12 +- 4 files changed, 620 insertions(+), 5235 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b863871..d7f3d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.1.1 + +- Improve logging to facilitate debugging + ## v1.1.0 - Expose an `eventId` on errors diff --git a/dist/index.js b/dist/index.js index 3d066fc..44f97ea 100644 --- a/dist/index.js +++ b/dist/index.js @@ -69,7 +69,7 @@ var require_utils = __commonJS({ var require_command = __commonJS({ "../../node_modules/@actions/core/lib/command.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -80,26 +80,26 @@ var require_command = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.issue = exports2.issueCommand = void 0; - var os = __importStar2(require("os")); + var os = __importStar(require("os")); var utils_1 = require_utils(); function issueCommand(command, properties, message) { const cmd = new Command(command, properties, message); @@ -504,7 +504,7 @@ var init_esm_node = __esm({ var require_file_command = __commonJS({ "../../node_modules/@actions/core/lib/file-command.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -515,27 +515,27 @@ var require_file_command = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.prepareKeyValueMessage = exports2.issueFileCommand = void 0; - var fs = __importStar2(require("fs")); - var os = __importStar2(require("os")); + var fs = __importStar(require("fs")); + var os = __importStar(require("os")); var uuid_1 = (init_esm_node(), __toCommonJS(esm_node_exports)); var utils_1 = require_utils(); function issueFileCommand(command, message) { @@ -763,18 +763,18 @@ var require_tunnel = __commonJS({ res.statusCode ); socket.destroy(); - var error = new Error("tunneling socket could not be established, statusCode=" + res.statusCode); - error.code = "ECONNRESET"; - options.request.emit("error", error); + var error2 = new Error("tunneling socket could not be established, statusCode=" + res.statusCode); + error2.code = "ECONNRESET"; + options.request.emit("error", error2); self.removeSocket(placeholder); return; } if (head.length > 0) { debug3("got illegal response body from proxy"); socket.destroy(); - var error = new Error("got illegal response body from proxy"); - error.code = "ECONNRESET"; - options.request.emit("error", error); + var error2 = new Error("got illegal response body from proxy"); + error2.code = "ECONNRESET"; + options.request.emit("error", error2); self.removeSocket(placeholder); return; } @@ -789,9 +789,9 @@ var require_tunnel = __commonJS({ cause.message, cause.stack ); - var error = new Error("tunneling socket could not be established, cause=" + cause.message); - error.code = "ECONNRESET"; - options.request.emit("error", error); + var error2 = new Error("tunneling socket could not be established, cause=" + cause.message); + error2.code = "ECONNRESET"; + options.request.emit("error", error2); self.removeSocket(placeholder); } }; @@ -5912,7 +5912,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r throw new TypeError("Body is unusable"); } const promise = createDeferredPromise(); - const errorSteps = (error) => promise.reject(error); + const errorSteps = (error2) => promise.reject(error2); const successSteps = (data) => { try { promise.resolve(convertBytesToJSValue(data)); @@ -6198,16 +6198,16 @@ var require_request = __commonJS({ this.onError(err); } } - onError(error) { + onError(error2) { this.onFinally(); if (channels.error.hasSubscribers) { - channels.error.publish({ request: this, error }); + channels.error.publish({ request: this, error: error2 }); } if (this.aborted) { return; } this.aborted = true; - return this[kHandler].onError(error); + return this[kHandler].onError(error2); } onFinally() { if (this.errorHandler) { @@ -7079,8 +7079,8 @@ var require_RedirectHandler = __commonJS({ onUpgrade(statusCode, headers, socket) { this.handler.onUpgrade(statusCode, headers, socket); } - onError(error) { - this.handler.onError(error); + onError(error2) { + this.handler.onError(error2); } onHeaders(statusCode, headers, resume, statusText) { this.location = this.history.length >= this.maxRedirections || util2.isDisturbed(this.opts.body) ? null : parseLocation(statusCode, headers); @@ -10831,13 +10831,13 @@ var require_mock_utils = __commonJS({ if (mockDispatch2.data.callback) { mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) }; } - const { data: { statusCode, data, headers, trailers, error }, delay, persist } = mockDispatch2; + const { data: { statusCode, data, headers, trailers, error: error2 }, delay, persist } = mockDispatch2; const { timesInvoked, times } = mockDispatch2; mockDispatch2.consumed = !persist && timesInvoked >= times; mockDispatch2.pending = timesInvoked < times; - if (error !== null) { + if (error2 !== null) { deleteMockDispatch(this[kDispatches], key); - handler.onError(error); + handler.onError(error2); return true; } if (typeof delay === "number" && delay > 0) { @@ -10875,19 +10875,19 @@ var require_mock_utils = __commonJS({ if (agent.isMockActive) { try { mockDispatch.call(this, opts, handler); - } catch (error) { - if (error instanceof MockNotMatchedError) { + } catch (error2) { + if (error2 instanceof MockNotMatchedError) { const netConnect = agent[kGetNetConnect](); if (netConnect === false) { - throw new MockNotMatchedError(`${error.message}: subsequent request to origin ${origin} was not allowed (net.connect disabled)`); + throw new MockNotMatchedError(`${error2.message}: subsequent request to origin ${origin} was not allowed (net.connect disabled)`); } if (checkNetConnect(netConnect, origin)) { originalDispatch.call(this, opts, handler); } else { - throw new MockNotMatchedError(`${error.message}: subsequent request to origin ${origin} was not allowed (net.connect is not enabled for this origin)`); + throw new MockNotMatchedError(`${error2.message}: subsequent request to origin ${origin} was not allowed (net.connect is not enabled for this origin)`); } } else { - throw error; + throw error2; } } } else { @@ -11050,11 +11050,11 @@ var require_mock_interceptor = __commonJS({ /** * Mock an undici request with a defined error. */ - replyWithError(error) { - if (typeof error === "undefined") { + replyWithError(error2) { + if (typeof error2 === "undefined") { throw new InvalidArgumentError("error must be defined"); } - const newMockDispatch = addMockDispatch(this[kDispatches], this[kDispatchKey], { error }); + const newMockDispatch = addMockDispatch(this[kDispatches], this[kDispatchKey], { error: error2 }); return new MockScope(newMockDispatch); } /** @@ -13381,17 +13381,17 @@ var require_fetch = __commonJS({ this.emit("terminated", reason); } // https://fetch.spec.whatwg.org/#fetch-controller-abort - abort(error) { + abort(error2) { if (this.state !== "ongoing") { return; } this.state = "aborted"; - if (!error) { - error = new DOMException2("The operation was aborted.", "AbortError"); + if (!error2) { + error2 = new DOMException2("The operation was aborted.", "AbortError"); } - this.serializedAbortReason = error; - this.connection?.destroy(error); - this.emit("terminated", error); + this.serializedAbortReason = error2; + this.connection?.destroy(error2); + this.emit("terminated", error2); } }; function fetch(input, init = {}) { @@ -13495,13 +13495,13 @@ var require_fetch = __commonJS({ performance.markResourceTiming(timingInfo, originalURL.href, initiatorType, globalThis2, cacheState); } } - function abortFetch(p, request, responseObject, error) { - if (!error) { - error = new DOMException2("The operation was aborted.", "AbortError"); + function abortFetch(p, request, responseObject, error2) { + if (!error2) { + error2 = new DOMException2("The operation was aborted.", "AbortError"); } - p.reject(error); + p.reject(error2); if (request.body != null && isReadable(request.body?.stream)) { - request.body.stream.cancel(error).catch((err) => { + request.body.stream.cancel(error2).catch((err) => { if (err.code === "ERR_INVALID_STATE") { return; } @@ -13513,7 +13513,7 @@ var require_fetch = __commonJS({ } const response = responseObject[kState]; if (response.body != null && isReadable(response.body?.stream)) { - response.body.stream.cancel(error).catch((err) => { + response.body.stream.cancel(error2).catch((err) => { if (err.code === "ERR_INVALID_STATE") { return; } @@ -14293,13 +14293,13 @@ var require_fetch = __commonJS({ fetchParams.controller.ended = true; this.body.push(null); }, - onError(error) { + onError(error2) { if (this.abort) { fetchParams.controller.off("terminated", this.abort); } - this.body?.destroy(error); - fetchParams.controller.terminate(error); - reject(error); + this.body?.destroy(error2); + fetchParams.controller.terminate(error2); + reject(error2); }, onUpgrade(status, headersList, socket) { if (status !== 101) { @@ -14765,8 +14765,8 @@ var require_util4 = __commonJS({ } fr[kResult] = result; fireAProgressEvent("load", fr); - } catch (error) { - fr[kError] = error; + } catch (error2) { + fr[kError] = error2; fireAProgressEvent("error", fr); } if (fr[kState] !== "loading") { @@ -14775,13 +14775,13 @@ var require_util4 = __commonJS({ }); break; } - } catch (error) { + } catch (error2) { if (fr[kAborted]) { return; } queueMicrotask(() => { fr[kState] = "done"; - fr[kError] = error; + fr[kError] = error2; fireAProgressEvent("error", fr); if (fr[kState] !== "loading") { fireAProgressEvent("loadend", fr); @@ -16797,11 +16797,11 @@ var require_connection = __commonJS({ }); } } - function onSocketError(error) { + function onSocketError(error2) { const { ws } = this; ws[kReadyState] = states.CLOSING; if (channels.socketError.hasSubscribers) { - channels.socketError.publish(error); + channels.socketError.publish(error2); } this.destroy(); } @@ -17652,7 +17652,7 @@ var require_undici = __commonJS({ var require_lib = __commonJS({ "../../node_modules/@actions/http-client/lib/index.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -17667,24 +17667,24 @@ var require_lib = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -17713,10 +17713,10 @@ var require_lib = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.HttpClient = exports2.isHttps = exports2.HttpClientResponse = exports2.HttpClientError = exports2.getProxyUrl = exports2.MediaTypes = exports2.Headers = exports2.HttpCodes = void 0; - var http = __importStar2(require("http")); - var https = __importStar2(require("https")); - var pm = __importStar2(require_proxy()); - var tunnel = __importStar2(require_tunnel2()); + var http = __importStar(require("http")); + var https = __importStar(require("https")); + var pm = __importStar(require_proxy()); + var tunnel = __importStar(require_tunnel2()); var undici_1 = require_undici(); var HttpCodes; (function(HttpCodes2) { @@ -17791,8 +17791,8 @@ var require_lib = __commonJS({ this.message = message; } readBody() { - return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve) => __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on("data", (chunk) => { output = Buffer.concat([output, chunk]); @@ -17804,8 +17804,8 @@ var require_lib = __commonJS({ }); } readBodyBuffer() { - return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve) => __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { const chunks = []; this.message.on("data", (chunk) => { chunks.push(chunk); @@ -17862,42 +17862,42 @@ var require_lib = __commonJS({ } } options(requestUrl, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("OPTIONS", requestUrl, null, additionalHeaders || {}); }); } get(requestUrl, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("GET", requestUrl, null, additionalHeaders || {}); }); } del(requestUrl, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("DELETE", requestUrl, null, additionalHeaders || {}); }); } post(requestUrl, data, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("POST", requestUrl, data, additionalHeaders || {}); }); } patch(requestUrl, data, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("PATCH", requestUrl, data, additionalHeaders || {}); }); } put(requestUrl, data, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("PUT", requestUrl, data, additionalHeaders || {}); }); } head(requestUrl, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request("HEAD", requestUrl, null, additionalHeaders || {}); }); } sendStream(verb, requestUrl, stream, additionalHeaders) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.request(verb, requestUrl, stream, additionalHeaders); }); } @@ -17906,14 +17906,14 @@ var require_lib = __commonJS({ * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise */ getJson(requestUrl, additionalHeaders = {}) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); const res = yield this.get(requestUrl, additionalHeaders); return this._processResponse(res, this.requestOptions); }); } postJson(requestUrl, obj, additionalHeaders = {}) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); @@ -17922,7 +17922,7 @@ var require_lib = __commonJS({ }); } putJson(requestUrl, obj, additionalHeaders = {}) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); @@ -17931,7 +17931,7 @@ var require_lib = __commonJS({ }); } patchJson(requestUrl, obj, additionalHeaders = {}) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { const data = JSON.stringify(obj, null, 2); additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); @@ -17945,17 +17945,17 @@ var require_lib = __commonJS({ * Prefer get, del, post and patch */ request(verb, requestUrl, data, headers) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { if (this._disposed) { throw new Error("Client has already been disposed."); } const parsedUrl = new URL(requestUrl); - let info3 = this._prepareRequest(verb, parsedUrl, headers); + let info4 = this._prepareRequest(verb, parsedUrl, headers); const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; let numTries = 0; let response; do { - response = yield this.requestRaw(info3, data); + response = yield this.requestRaw(info4, data); if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { let authenticationHandler; for (const handler of this.handlers) { @@ -17965,7 +17965,7 @@ var require_lib = __commonJS({ } } if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info3, data); + return authenticationHandler.handleAuthentication(this, info4, data); } else { return response; } @@ -17988,8 +17988,8 @@ var require_lib = __commonJS({ } } } - info3 = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = yield this.requestRaw(info3, data); + info4 = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = yield this.requestRaw(info4, data); redirectsRemaining--; } if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) { @@ -18018,8 +18018,8 @@ var require_lib = __commonJS({ * @param info * @param data */ - requestRaw(info3, data) { - return __awaiter2(this, void 0, void 0, function* () { + requestRaw(info4, data) { + return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { function callbackForResult(err, res) { if (err) { @@ -18030,7 +18030,7 @@ var require_lib = __commonJS({ resolve(res); } } - this.requestRawWithCallback(info3, data, callbackForResult); + this.requestRawWithCallback(info4, data, callbackForResult); }); }); } @@ -18040,12 +18040,12 @@ var require_lib = __commonJS({ * @param data * @param onResult */ - requestRawWithCallback(info3, data, onResult) { + requestRawWithCallback(info4, data, onResult) { if (typeof data === "string") { - if (!info3.options.headers) { - info3.options.headers = {}; + if (!info4.options.headers) { + info4.options.headers = {}; } - info3.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); + info4.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); } let callbackCalled = false; function handleResult2(err, res) { @@ -18054,7 +18054,7 @@ var require_lib = __commonJS({ onResult(err, res); } } - const req = info3.httpModule.request(info3.options, (msg) => { + const req = info4.httpModule.request(info4.options, (msg) => { const res = new HttpClientResponse(msg); handleResult2(void 0, res); }); @@ -18066,7 +18066,7 @@ var require_lib = __commonJS({ if (socket) { socket.end(); } - handleResult2(new Error(`Request timeout: ${info3.options.path}`)); + handleResult2(new Error(`Request timeout: ${info4.options.path}`)); }); req.on("error", function(err) { handleResult2(err); @@ -18102,27 +18102,27 @@ var require_lib = __commonJS({ return this._getProxyAgentDispatcher(parsedUrl, proxyUrl); } _prepareRequest(method, requestUrl, headers) { - const info3 = {}; - info3.parsedUrl = requestUrl; - const usingSsl = info3.parsedUrl.protocol === "https:"; - info3.httpModule = usingSsl ? https : http; + const info4 = {}; + info4.parsedUrl = requestUrl; + const usingSsl = info4.parsedUrl.protocol === "https:"; + info4.httpModule = usingSsl ? https : http; const defaultPort = usingSsl ? 443 : 80; - info3.options = {}; - info3.options.host = info3.parsedUrl.hostname; - info3.options.port = info3.parsedUrl.port ? parseInt(info3.parsedUrl.port) : defaultPort; - info3.options.path = (info3.parsedUrl.pathname || "") + (info3.parsedUrl.search || ""); - info3.options.method = method; - info3.options.headers = this._mergeHeaders(headers); + info4.options = {}; + info4.options.host = info4.parsedUrl.hostname; + info4.options.port = info4.parsedUrl.port ? parseInt(info4.parsedUrl.port) : defaultPort; + info4.options.path = (info4.parsedUrl.pathname || "") + (info4.parsedUrl.search || ""); + info4.options.method = method; + info4.options.headers = this._mergeHeaders(headers); if (this.userAgent != null) { - info3.options.headers["user-agent"] = this.userAgent; + info4.options.headers["user-agent"] = this.userAgent; } - info3.options.agent = this._getAgent(info3.parsedUrl); + info4.options.agent = this._getAgent(info4.parsedUrl); if (this.handlers) { for (const handler of this.handlers) { - handler.prepareRequest(info3.options); + handler.prepareRequest(info4.options); } } - return info3; + return info4; } _mergeHeaders(headers) { if (this.requestOptions && this.requestOptions.headers) { @@ -18206,15 +18206,15 @@ var require_lib = __commonJS({ return proxyAgent; } _performExponentialBackoff(retryNumber) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); return new Promise((resolve) => setTimeout(() => resolve(), ms)); }); } _processResponse(res, options) { - return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, @@ -18276,7 +18276,7 @@ var require_lib = __commonJS({ var require_auth = __commonJS({ "../../node_modules/@actions/http-client/lib/auth.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18321,7 +18321,7 @@ var require_auth = __commonJS({ return false; } handleAuthentication() { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { throw new Error("not implemented"); }); } @@ -18344,7 +18344,7 @@ var require_auth = __commonJS({ return false; } handleAuthentication() { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { throw new Error("not implemented"); }); } @@ -18367,7 +18367,7 @@ var require_auth = __commonJS({ return false; } handleAuthentication() { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { throw new Error("not implemented"); }); } @@ -18380,7 +18380,7 @@ var require_auth = __commonJS({ var require_oidc_utils = __commonJS({ "../../node_modules/@actions/core/lib/oidc-utils.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18436,14 +18436,14 @@ var require_oidc_utils = __commonJS({ } static getCall(id_token_url) { var _a; - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { const httpclient = _OidcClient.createHttpClient(); - const res = yield httpclient.getJson(id_token_url).catch((error) => { + const res = yield httpclient.getJson(id_token_url).catch((error2) => { throw new Error(`Failed to get ID Token. - Error Code : ${error.statusCode} + Error Code : ${error2.statusCode} - Error Message: ${error.message}`); + Error Message: ${error2.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { @@ -18453,7 +18453,7 @@ var require_oidc_utils = __commonJS({ }); } static getIDToken(audience) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { try { let id_token_url = _OidcClient.getIDTokenUrl(); if (audience) { @@ -18464,8 +18464,8 @@ var require_oidc_utils = __commonJS({ const id_token = yield _OidcClient.getCall(id_token_url); core_1.setSecret(id_token); return id_token; - } catch (error) { - throw new Error(`Error message: ${error.message}`); + } catch (error2) { + throw new Error(`Error message: ${error2.message}`); } }); } @@ -18478,7 +18478,7 @@ var require_oidc_utils = __commonJS({ var require_summary = __commonJS({ "../../node_modules/@actions/core/lib/summary.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18523,7 +18523,7 @@ var require_summary = __commonJS({ * @returns step summary file path */ filePath() { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { if (this._filePath) { return this._filePath; } @@ -18564,7 +18564,7 @@ var require_summary = __commonJS({ * @returns {Promise} summary instance */ write(options) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite); const filePath = yield this.filePath(); const writeFunc = overwrite ? writeFile : appendFile; @@ -18578,7 +18578,7 @@ var require_summary = __commonJS({ * @returns {Summary} summary instance */ clear() { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return this.emptyBuffer().write({ overwrite: true }); }); } @@ -18772,7 +18772,7 @@ var require_summary = __commonJS({ var require_path_utils = __commonJS({ "../../node_modules/@actions/core/lib/path-utils.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -18783,26 +18783,26 @@ var require_path_utils = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = void 0; - var path = __importStar2(require("path")); + var path = __importStar(require("path")); function toPosixPath(pth) { return pth.replace(/[\\]/g, "/"); } @@ -18822,7 +18822,7 @@ var require_path_utils = __commonJS({ var require_core = __commonJS({ "../../node_modules/@actions/core/lib/core.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -18833,24 +18833,24 @@ var require_core = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18882,8 +18882,8 @@ var require_core = __commonJS({ var command_1 = require_command(); var file_command_1 = require_file_command(); var utils_1 = require_utils(); - var os = __importStar2(require("os")); - var path = __importStar2(require("path")); + var os = __importStar(require("os")); + var path = __importStar(require("path")); var oidc_utils_1 = require_oidc_utils(); var ExitCode; (function(ExitCode2) { @@ -18960,7 +18960,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); exports2.setCommandEcho = setCommandEcho; function setFailed2(message) { process.exitCode = ExitCode.Failure; - error(message); + error2(message); } exports2.setFailed = setFailed2; function isDebug() { @@ -18971,22 +18971,22 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); command_1.issueCommand("debug", {}, message); } exports2.debug = debug3; - function error(message, properties = {}) { + function error2(message, properties = {}) { command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } - exports2.error = error; - function warning(message, properties = {}) { + exports2.error = error2; + function warning2(message, properties = {}) { command_1.issueCommand("warning", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } - exports2.warning = warning; + exports2.warning = warning2; function notice(message, properties = {}) { command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); } exports2.notice = notice; - function info3(message) { + function info4(message) { process.stdout.write(message + os.EOL); } - exports2.info = info3; + exports2.info = info4; function startGroup(name) { command_1.issue("group", name); } @@ -18996,7 +18996,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports2.endGroup = endGroup; function group(name, fn) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { startGroup(name); let result; try { @@ -19021,7 +19021,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports2.getState = getState; function getIDToken(aud) { - return __awaiter2(this, void 0, void 0, function* () { + return __awaiter(this, void 0, void 0, function* () { return yield oidc_utils_1.OidcClient.getIDToken(aud); }); } @@ -19109,7 +19109,7 @@ var require_context = __commonJS({ var require_utils3 = __commonJS({ "../../node_modules/@actions/github/lib/internal/utils.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -19124,24 +19124,24 @@ var require_utils3 = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -19170,7 +19170,7 @@ var require_utils3 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getApiBaseUrl = exports2.getProxyFetch = exports2.getProxyAgentDispatcher = exports2.getProxyAgent = exports2.getAuthString = void 0; - var httpClient = __importStar2(require_lib()); + var httpClient = __importStar(require_lib()); var undici_1 = require_undici(); function getAuthString(token, options) { if (!token && !options.auth) { @@ -19193,7 +19193,7 @@ var require_utils3 = __commonJS({ exports2.getProxyAgentDispatcher = getProxyAgentDispatcher; function getProxyFetch(destinationUrl) { const httpDispatcher = getProxyAgentDispatcher(destinationUrl); - const proxyFetch = (url, opts) => __awaiter2(this, void 0, void 0, function* () { + const proxyFetch = (url, opts) => __awaiter(this, void 0, void 0, function* () { return (0, undici_1.fetch)(url, Object.assign(Object.assign({}, opts), { dispatcher: httpDispatcher })); }); return proxyFetch; @@ -19281,8 +19281,8 @@ var require_add = __commonJS({ } if (kind === "error") { hook = function(method, options) { - return Promise.resolve().then(method.bind(null, options)).catch(function(error) { - return orig(error, options); + return Promise.resolve().then(method.bind(null, options)).catch(function(error2) { + return orig(error2, options); }); }; } @@ -19375,23 +19375,23 @@ var require_before_after_hook = __commonJS({ var require_dist_node2 = __commonJS({ "../../node_modules/@octokit/endpoint/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { endpoint: () => endpoint @@ -19818,20 +19818,20 @@ var require_dist_node4 = __commonJS({ "../../node_modules/@octokit/request-error/dist-node/index.js"(exports2, module2) { "use strict"; var __create2 = Object.create; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __getProtoOf2 = Object.getPrototypeOf; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; @@ -19840,10 +19840,10 @@ var require_dist_node4 = __commonJS({ // 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 ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, + isNodeMode || !mod || !mod.__esModule ? __defProp4(target, "default", { value: mod, enumerable: true }) : target, mod )); - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { RequestError: () => RequestError @@ -19909,23 +19909,23 @@ var require_dist_node4 = __commonJS({ var require_dist_node5 = __commonJS({ "../../node_modules/@octokit/request/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { request: () => request @@ -20020,7 +20020,7 @@ var require_dist_node5 = __commonJS({ } if (status >= 400) { const data = await getResponseData(response); - const error = new import_request_error.RequestError(toErrorMessage(data), status, { + const error2 = new import_request_error.RequestError(toErrorMessage(data), status, { response: { url, status, @@ -20029,7 +20029,7 @@ var require_dist_node5 = __commonJS({ }, request: requestOptions }); - throw error; + throw error2; } return parseSuccessResponseBody ? await getResponseData(response) : response.body; }).then((data) => { @@ -20039,17 +20039,17 @@ var require_dist_node5 = __commonJS({ headers, data }; - }).catch((error) => { - if (error instanceof import_request_error.RequestError) - throw error; - else if (error.name === "AbortError") - throw error; - let message = error.message; - if (error.name === "TypeError" && "cause" in error) { - if (error.cause instanceof Error) { - message = error.cause.message; - } else if (typeof error.cause === "string") { - message = error.cause; + }).catch((error2) => { + if (error2 instanceof import_request_error.RequestError) + throw error2; + else if (error2.name === "AbortError") + throw error2; + let message = error2.message; + if (error2.name === "TypeError" && "cause" in error2) { + if (error2.cause instanceof Error) { + message = error2.cause.message; + } else if (typeof error2.cause === "string") { + message = error2.cause; } } throw new import_request_error.RequestError(message, 500, { @@ -20119,23 +20119,23 @@ var require_dist_node5 = __commonJS({ var require_dist_node6 = __commonJS({ "../../node_modules/@octokit/graphql/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { GraphqlResponseError: () => GraphqlResponseError, @@ -20257,23 +20257,23 @@ var require_dist_node6 = __commonJS({ var require_dist_node7 = __commonJS({ "../../node_modules/@octokit/auth-token/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { createTokenAuth: () => createTokenAuth @@ -20328,23 +20328,23 @@ var require_dist_node7 = __commonJS({ var require_dist_node8 = __commonJS({ "../../node_modules/@octokit/core/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { Octokit: () => Octokit @@ -20353,7 +20353,7 @@ var require_dist_node8 = __commonJS({ var import_universal_user_agent = require_dist_node(); var import_before_after_hook = require_before_after_hook(); var import_request = require_dist_node5(); - var import_graphql7 = require_dist_node6(); + var import_graphql = require_dist_node6(); var import_auth_token = require_dist_node7(); var VERSION = "5.2.0"; var noop = () => { @@ -20432,7 +20432,7 @@ var require_dist_node8 = __commonJS({ requestDefaults.headers["time-zone"] = options.timeZone; } this.request = import_request.request.defaults(requestDefaults); - this.graphql = (0, import_graphql7.withCustomRequest)(this.request).defaults(requestDefaults); + this.graphql = (0, import_graphql.withCustomRequest)(this.request).defaults(requestDefaults); this.log = Object.assign( { debug: noop, @@ -20487,23 +20487,23 @@ var require_dist_node8 = __commonJS({ var require_dist_node9 = __commonJS({ "../../node_modules/@actions/github/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { legacyRestEndpointMethods: () => legacyRestEndpointMethods, @@ -22643,23 +22643,23 @@ var require_dist_node9 = __commonJS({ var require_dist_node10 = __commonJS({ "../../node_modules/@actions/github/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js"(exports2, module2) { "use strict"; - var __defProp2 = Object.defineProperty; + var __defProp4 = Object.defineProperty; var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames2 = Object.getOwnPropertyNames; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __export2 = (target, all) => { for (var name in all) - __defProp2(target, name, { get: all[name], enumerable: true }); + __defProp4(target, name, { get: all[name], enumerable: true }); }; var __copyProps2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames2(from)) if (!__hasOwnProp2.call(to, key) && key !== except) - __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); + __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable }); } return to; }; - var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod); + var __toCommonJS2 = (mod) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod); var dist_src_exports = {}; __export2(dist_src_exports, { composePaginateRest: () => composePaginateRest, @@ -22715,9 +22715,9 @@ var require_dist_node10 = __commonJS({ /<([^>]+)>;\s*rel="next"/ ) || [])[1]; return { value: normalizedResponse }; - } catch (error) { - if (error.status !== 409) - throw error; + } catch (error2) { + if (error2.status !== 409) + throw error2; url = ""; return { value: { @@ -23022,7 +23022,7 @@ var require_dist_node10 = __commonJS({ var require_utils4 = __commonJS({ "../../node_modules/@actions/github/lib/utils.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -23037,27 +23037,27 @@ var require_utils4 = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOctokitOptions = exports2.GitHub = exports2.defaults = exports2.context = void 0; - var Context = __importStar2(require_context()); - var Utils = __importStar2(require_utils3()); + var Context = __importStar(require_context()); + var Utils = __importStar(require_utils3()); var core_1 = require_dist_node8(); var plugin_rest_endpoint_methods_1 = require_dist_node9(); var plugin_paginate_rest_1 = require_dist_node10(); @@ -23087,7 +23087,7 @@ var require_utils4 = __commonJS({ var require_github = __commonJS({ "../../node_modules/@actions/github/lib/github.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -23102,26 +23102,26 @@ var require_github = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOctokit = exports2.context = void 0; - var Context = __importStar2(require_context()); + var Context = __importStar(require_context()); var utils_1 = require_utils4(); exports2.context = new Context.Context(); function getOctokit2(token, options, ...additionalPlugins) { @@ -23186,4733 +23186,34 @@ var require_slugify = __commonJS({ } }); -// ../../node_modules/tslib/tslib.es6.mjs -var tslib_es6_exports = {}; -__export(tslib_es6_exports, { - __addDisposableResource: () => __addDisposableResource, - __assign: () => __assign, - __asyncDelegator: () => __asyncDelegator, - __asyncGenerator: () => __asyncGenerator, - __asyncValues: () => __asyncValues, - __await: () => __await, - __awaiter: () => __awaiter, - __classPrivateFieldGet: () => __classPrivateFieldGet, - __classPrivateFieldIn: () => __classPrivateFieldIn, - __classPrivateFieldSet: () => __classPrivateFieldSet, - __createBinding: () => __createBinding, - __decorate: () => __decorate, - __disposeResources: () => __disposeResources, - __esDecorate: () => __esDecorate, - __exportStar: () => __exportStar, - __extends: () => __extends, - __generator: () => __generator, - __importDefault: () => __importDefault, - __importStar: () => __importStar, - __makeTemplateObject: () => __makeTemplateObject, - __metadata: () => __metadata, - __param: () => __param, - __propKey: () => __propKey, - __read: () => __read, - __rest: () => __rest, - __runInitializers: () => __runInitializers, - __setFunctionName: () => __setFunctionName, - __spread: () => __spread, - __spreadArray: () => __spreadArray, - __spreadArrays: () => __spreadArrays, - __values: () => __values, - default: () => tslib_es6_default -}); -function __extends(d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} -function __rest(s, e) { - var t = {}; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -} -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r = Reflect.decorate(decorators, target, key, desc); - else - for (var i = decorators.length - 1; i >= 0; i--) - if (d = decorators[i]) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} -function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} -function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { - function accept(f) { - if (f !== void 0 && typeof f !== "function") - throw new TypeError("Function expected"); - return f; - } - var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; - var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; - var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); - var _, done = false; - for (var i = decorators.length - 1; i >= 0; i--) { - var context3 = {}; - for (var p in contextIn) - context3[p] = p === "access" ? {} : contextIn[p]; - for (var p in contextIn.access) - context3.access[p] = contextIn.access[p]; - context3.addInitializer = function(f) { - if (done) - throw new TypeError("Cannot add initializers after decoration has completed"); - extraInitializers.push(accept(f || null)); - }; - var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context3); - if (kind === "accessor") { - if (result === void 0) - continue; - if (result === null || typeof result !== "object") - throw new TypeError("Object expected"); - if (_ = accept(result.get)) - descriptor.get = _; - if (_ = accept(result.set)) - descriptor.set = _; - if (_ = accept(result.init)) - initializers.unshift(_); - } else if (_ = accept(result)) { - if (kind === "field") - initializers.unshift(_); - else - descriptor[key] = _; - } - } - if (target) - Object.defineProperty(target, contextIn.name, descriptor); - done = true; -} -function __runInitializers(thisArg, initializers, value) { - var useValue = arguments.length > 2; - for (var i = 0; i < initializers.length; i++) { - value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); - } - return useValue ? value : void 0; -} -function __propKey(x) { - return typeof x === "symbol" ? x : "".concat(x); -} -function __setFunctionName(f, name, prefix) { - if (typeof name === "symbol") - name = name.description ? "[".concat(name.description, "]") : ""; - return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); -} -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); -} -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { - if (t[0] & 1) - throw t[1]; - return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([n, v]); - }; - } - function step(op) { - if (f) - throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) - try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) - return t; - if (y = 0, t) - op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) - _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} -function __exportStar(m, o) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) - __createBinding(o, m, p); -} -function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) - return m.call(o); - if (o && typeof o.length === "number") - return { - next: function() { - if (o && i >= o.length) - o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) - return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) - ar.push(r.value); - } catch (error) { - e = { error }; - } finally { - try { - if (r && !r.done && (m = i["return"])) - m.call(i); - } finally { - if (e) - throw e.error; - } - } - return ar; -} -function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} -function __spreadArrays() { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) - s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; -} -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) - ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) - i[n] = function(v) { - return new Promise(function(a, b) { - q.push([n, v, a, b]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) - resume(q[0][0], q[0][1]); - } -} -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; - } : f; - } -} -function __asyncValues(o) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v2) { - resolve({ value: v2, done: d }); - }, reject); - } -} -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; -} -function __importStar(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k in mod) - if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding(result, mod, k); - } - __setModuleDefault(result, mod); - return result; -} -function __importDefault(mod) { - return mod && mod.__esModule ? mod : { default: mod }; -} -function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} -function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") - throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; -} -function __classPrivateFieldIn(state, receiver) { - if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") - throw new TypeError("Cannot use 'in' operator on non-object"); - return typeof state === "function" ? receiver === state : state.has(receiver); -} -function __addDisposableResource(env, value, async) { - if (value !== null && value !== void 0) { - if (typeof value !== "object" && typeof value !== "function") - throw new TypeError("Object expected."); - var dispose; - if (async) { - if (!Symbol.asyncDispose) - throw new TypeError("Symbol.asyncDispose is not defined."); - dispose = value[Symbol.asyncDispose]; - } - if (dispose === void 0) { - if (!Symbol.dispose) - throw new TypeError("Symbol.dispose is not defined."); - dispose = value[Symbol.dispose]; - } - if (typeof dispose !== "function") - throw new TypeError("Object not disposable."); - env.stack.push({ value, dispose, async }); - } else if (async) { - env.stack.push({ async: true }); - } - return value; -} -function __disposeResources(env) { - function fail(e) { - env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; - env.hasError = true; - } - function next() { - while (env.stack.length) { - var rec = env.stack.pop(); - try { - var result = rec.dispose && rec.dispose.call(rec.value); - if (rec.async) - return Promise.resolve(result).then(next, function(e) { - fail(e); - return next(); - }); - } catch (e) { - fail(e); - } - } - if (env.hasError) - throw env.error; - } - return next(); -} -var extendStatics, __assign, __createBinding, __setModuleDefault, _SuppressedError, tslib_es6_default; -var init_tslib_es6 = __esm({ - "../../node_modules/tslib/tslib.es6.mjs"() { - "use strict"; - extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { - d2.__proto__ = b2; - } || function(d2, b2) { - for (var p in b2) - if (Object.prototype.hasOwnProperty.call(b2, p)) - d2[p] = b2[p]; - }; - return extendStatics(d, b); - }; - __assign = function() { - __assign = Object.assign || function __assign2(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); - }; - __createBinding = Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { - return m[k]; - } }; - } - Object.defineProperty(o, k2, desc); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }; - __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - } : function(o, v) { - o["default"] = v; - }; - _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) { - var e = new Error(message); - return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; - }; - tslib_es6_default = { - __extends, - __assign, - __rest, - __decorate, - __param, - __metadata, - __awaiter, - __generator, - __createBinding, - __exportStar, - __values, - __read, - __spread, - __spreadArrays, - __spreadArray, - __await, - __asyncGenerator, - __asyncDelegator, - __asyncValues, - __makeTemplateObject, - __importStar, - __importDefault, - __classPrivateFieldGet, - __classPrivateFieldSet, - __classPrivateFieldIn, - __addDisposableResource, - __disposeResources - }; - } -}); - -// ../ci-utils/dist/string.js -var require_string = __commonJS({ - "../ci-utils/dist/string.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.stringifyUnknown = stringifyUnknown2; - function stringifyUnknown2(value) { - if (value === null || value === void 0) - return ""; - if (typeof value === "string") - return value; - if (value instanceof Error) { - if ("message" in value && typeof value.message === "string") - return value.message; - return value.toString(); - } - try { - const stringified = JSON.stringify(value); - return !stringified ? "" : stringified; - } catch { - return ""; - } - } - } -}); - -// ../ci-utils/dist/log.js -var require_log = __commonJS({ - "../ci-utils/dist/log.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.coreLogDriver = void 0; - var core_1 = require_core(); - var string_1 = require_string(); - exports2.coreLogDriver = { - error(message, error) { - (0, core_1.error)(message + (error ? ` -${(0, string_1.stringifyUnknown)(error)}` : "")); - }, - info: core_1.info, - warn: core_1.warning - }; - } -}); - -// ../../node_modules/zod/lib/helpers/util.js -var require_util8 = __commonJS({ - "../../node_modules/zod/lib/helpers/util.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.getParsedType = exports2.ZodParsedType = exports2.objectUtil = exports2.util = void 0; - var util2; - (function(util3) { - util3.assertEqual = (val) => val; - function assertIs(_arg) { - } - util3.assertIs = assertIs; - function assertNever(_x) { - throw new Error(); - } - util3.assertNever = assertNever; - util3.arrayToEnum = (items) => { - const obj = {}; - for (const item of items) { - obj[item] = item; - } - return obj; - }; - util3.getValidEnumValues = (obj) => { - const validKeys = util3.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number"); - const filtered = {}; - for (const k of validKeys) { - filtered[k] = obj[k]; - } - return util3.objectValues(filtered); - }; - util3.objectValues = (obj) => { - return util3.objectKeys(obj).map(function(e) { - return obj[e]; - }); - }; - util3.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; - }; - util3.find = (arr, checker) => { - for (const item of arr) { - if (checker(item)) - return item; - } - return void 0; - }; - util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; - function joinValues(array, separator = " | ") { - return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); - } - util3.joinValues = joinValues; - util3.jsonStringifyReplacer = (_, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }; - })(util2 = exports2.util || (exports2.util = {})); - var objectUtil2; - (function(objectUtil3) { - objectUtil3.mergeShapes = (first, second) => { - return { - ...first, - ...second - // second overwrites first - }; - }; - })(objectUtil2 = exports2.objectUtil || (exports2.objectUtil = {})); - exports2.ZodParsedType = util2.arrayToEnum([ - "string", - "nan", - "number", - "integer", - "float", - "boolean", - "date", - "bigint", - "symbol", - "function", - "undefined", - "null", - "array", - "object", - "unknown", - "promise", - "void", - "never", - "map", - "set" - ]); - var getParsedType2 = (data) => { - const t = typeof data; - switch (t) { - case "undefined": - return exports2.ZodParsedType.undefined; - case "string": - return exports2.ZodParsedType.string; - case "number": - return 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 = getParsedType2; - } -}); - -// ../../node_modules/zod/lib/ZodError.js -var require_ZodError = __commonJS({ - "../../node_modules/zod/lib/ZodError.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.ZodError = exports2.quotelessJson = exports2.ZodIssueCode = void 0; - var util_1 = require_util8(); - exports2.ZodIssueCode = util_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 quotelessJson2 = (obj) => { - const json = JSON.stringify(obj, null, 2); - return json.replace(/"([^"]+)":/g, "$1:"); - }; - exports2.quotelessJson = quotelessJson2; - var ZodError2 = class _ZodError extends Error { - 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; - } - get errors() { - return this.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 i = 0; - while (i < issue.path.length) { - const el = issue.path[i]; - const terminal = i === 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]; - i++; - } - } - } - }; - 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_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) { - fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; - fieldErrors[sub.path[0]].push(mapper(sub)); - } else { - formErrors.push(mapper(sub)); - } - } - return { formErrors, fieldErrors }; - } - get formErrors() { - return this.flatten(); - } - }; - exports2.ZodError = ZodError2; - ZodError2.create = (issues) => { - const error = new ZodError2(issues); - return error; - }; - } -}); - -// ../../node_modules/zod/lib/locales/en.js -var require_en = __commonJS({ - "../../node_modules/zod/lib/locales/en.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - var util_1 = require_util8(); - var ZodError_1 = require_ZodError(); - var errorMap2 = (issue, _ctx) => { - let message; - switch (issue.code) { - case ZodError_1.ZodIssueCode.invalid_type: - if (issue.received === util_1.ZodParsedType.undefined) { - message = "Required"; - } else { - message = `Expected ${issue.expected}, received ${issue.received}`; - } - break; - case ZodError_1.ZodIssueCode.invalid_literal: - message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; - break; - case ZodError_1.ZodIssueCode.unrecognized_keys: - message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; - break; - case ZodError_1.ZodIssueCode.invalid_union: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_union_discriminator: - message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; - break; - case ZodError_1.ZodIssueCode.invalid_enum_value: - message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; - break; - case ZodError_1.ZodIssueCode.invalid_arguments: - message = `Invalid function arguments`; - break; - case ZodError_1.ZodIssueCode.invalid_return_type: - message = `Invalid function return type`; - break; - case ZodError_1.ZodIssueCode.invalid_date: - message = `Invalid date`; - break; - case ZodError_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_1.util.assertNever(issue.validation); - } - } else if (issue.validation !== "regex") { - message = `Invalid ${issue.validation}`; - } else { - message = "Invalid"; - } - break; - case ZodError_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 === "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_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_1.ZodIssueCode.custom: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_intersection_types: - message = `Intersection results could not be merged`; - break; - case ZodError_1.ZodIssueCode.not_multiple_of: - message = `Number must be a multiple of ${issue.multipleOf}`; - break; - case ZodError_1.ZodIssueCode.not_finite: - message = "Number must be finite"; - break; - default: - message = _ctx.defaultError; - util_1.util.assertNever(issue); - } - return { message }; - }; - exports2.default = errorMap2; - } -}); - -// ../../node_modules/zod/lib/errors.js -var require_errors2 = __commonJS({ - "../../node_modules/zod/lib/errors.js"(exports2) { - "use strict"; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { - return mod && mod.__esModule ? mod : { "default": mod }; - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.getErrorMap = exports2.setErrorMap = exports2.defaultErrorMap = void 0; - var en_1 = __importDefault2(require_en()); - exports2.defaultErrorMap = en_1.default; - var overrideErrorMap2 = en_1.default; - function setErrorMap2(map) { - overrideErrorMap2 = map; - } - exports2.setErrorMap = setErrorMap2; - function getErrorMap2() { - return overrideErrorMap2; - } - exports2.getErrorMap = getErrorMap2; - } -}); - -// ../../node_modules/zod/lib/helpers/parseUtil.js -var require_parseUtil = __commonJS({ - "../../node_modules/zod/lib/helpers/parseUtil.js"(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.addIssueToContext = exports2.EMPTY_PATH = exports2.makeIssue = void 0; - var errors_1 = require_errors2(); - var en_1 = __importDefault2(require_en()); - var makeIssue2 = (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((m) => !!m).slice().reverse(); - for (const map of maps) { - errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; - } - return { - ...issueData, - path: fullPath, - message: errorMessage - }; - }; - exports2.makeIssue = makeIssue2; - exports2.EMPTY_PATH = []; - function addIssueToContext2(ctx, issueData) { - const overrideMap = (0, errors_1.getErrorMap)(); - const issue = (0, exports2.makeIssue)({ - issueData, - data: ctx.data, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - overrideMap, - overrideMap === en_1.default ? void 0 : en_1.default - // then global default map - ].filter((x) => !!x) - }); - ctx.common.issues.push(issue); - } - exports2.addIssueToContext = addIssueToContext2; - var ParseStatus2 = 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 s of results) { - if (s.status === "aborted") - return exports2.INVALID; - if (s.status === "dirty") - status.dirty(); - arrayValue.push(s.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 = ParseStatus2; - exports2.INVALID = Object.freeze({ - status: "aborted" - }); - var DIRTY2 = (value) => ({ status: "dirty", value }); - exports2.DIRTY = DIRTY2; - var OK2 = (value) => ({ status: "valid", value }); - exports2.OK = OK2; - var isAborted2 = (x) => x.status === "aborted"; - exports2.isAborted = isAborted2; - var isDirty2 = (x) => x.status === "dirty"; - exports2.isDirty = isDirty2; - var isValid2 = (x) => x.status === "valid"; - exports2.isValid = isValid2; - var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise; - exports2.isAsync = isAsync2; - } -}); - -// ../../node_modules/zod/lib/helpers/typeAliases.js -var require_typeAliases = __commonJS({ - "../../node_modules/zod/lib/helpers/typeAliases.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - } -}); - -// ../../node_modules/zod/lib/helpers/errorUtil.js -var require_errorUtil = __commonJS({ - "../../node_modules/zod/lib/helpers/errorUtil.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.errorUtil = void 0; - var errorUtil2; - (function(errorUtil3) { - errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {}; - errorUtil3.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; - })(errorUtil2 = exports2.errorUtil || (exports2.errorUtil = {})); - } -}); - -// ../../node_modules/zod/lib/types.js -var require_types = __commonJS({ - "../../node_modules/zod/lib/types.js"(exports2) { - "use strict"; - var __classPrivateFieldGet3 = exports2 && exports2.__classPrivateFieldGet || function(receiver, state, kind, f) { - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - var __classPrivateFieldSet3 = exports2 && exports2.__classPrivateFieldSet || function(receiver, state, value, kind, f) { - if (kind === "m") - throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; - }; - var _ZodEnum_cache2; - var _ZodNativeEnum_cache2; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.boolean = exports2.bigint = exports2.array = exports2.any = exports2.coerce = exports2.ZodFirstPartyTypeKind = exports2.late = exports2.ZodSchema = exports2.Schema = exports2.custom = 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.datetimeRegex = 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 = exports2.discriminatedUnion = exports2.date = void 0; - var errors_1 = require_errors2(); - var errorUtil_1 = require_errorUtil(); - var parseUtil_1 = require_parseUtil(); - var util_1 = require_util8(); - var ZodError_1 = require_ZodError(); - var ParseInputLazyPath2 = 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 (this._key instanceof Array) { - this._cachedPath.push(...this._path, ...this._key); - } else { - this._cachedPath.push(...this._path, this._key); - } - } - return this._cachedPath; - } - }; - var handleResult2 = (ctx, result) => { - if ((0, parseUtil_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_1.ZodError(ctx.common.issues); - this._error = error; - return this._error; - } - }; - } - }; - function processCreateParams2(params) { - if (!params) - return {}; - const { errorMap: errorMap2, invalid_type_error, required_error, description } = params; - if (errorMap2 && (invalid_type_error || required_error)) { - throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); - } - if (errorMap2) - return { errorMap: errorMap2, description }; - const customMap = (iss, ctx) => { - var _a, _b; - const { message } = params; - if (iss.code === "invalid_enum_value") { - return { message: message !== null && message !== void 0 ? message : ctx.defaultError }; - } - if (typeof ctx.data === "undefined") { - return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError }; - } - if (iss.code !== "invalid_type") - return { message: ctx.defaultError }; - return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError }; - }; - return { errorMap: customMap, description }; - } - var ZodType2 = class { - 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); - } - get description() { - return this._def.description; - } - _getType(input) { - return (0, util_1.getParsedType)(input.data); - } - _getOrReturnCtx(input, ctx) { - return ctx || { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - }; - } - _processInputParams(input) { - return { - status: new parseUtil_1.ParseStatus(), - ctx: { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - } - }; - } - _parseSync(input) { - const result = this._parse(input); - if ((0, parseUtil_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) { - var _a; - const ctx = { - common: { - issues: [], - async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, - contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: (0, util_1.getParsedType)(data) - }; - const result = this._parseSync({ data, path: ctx.path, parent: ctx }); - return handleResult2(ctx, result); - } - 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 === null || params === void 0 ? void 0 : params.errorMap, - async: true - }, - path: (params === null || params === void 0 ? void 0 : params.path) || [], - schemaErrorMap: this._def.errorMap, - parent: null, - data, - parsedType: (0, util_1.getParsedType)(data) - }; - const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); - const result = await ((0, parseUtil_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); - return handleResult2(ctx, result); - } - refine(check, message) { - const getIssueProperties = (val) => { - if (typeof message === "string" || typeof message === "undefined") { - return { message }; - } else if (typeof message === "function") { - return message(val); - } else { - return message; - } - }; - return this._refinement((val, ctx) => { - const result = check(val); - const setError = () => ctx.addIssue({ - code: ZodError_1.ZodIssueCode.custom, - ...getIssueProperties(val) - }); - 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((val, ctx) => { - if (!check(val)) { - ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); - return false; - } else { - return true; - } - }); - } - _refinement(refinement) { - return new ZodEffects2({ - schema: this, - typeName: ZodFirstPartyTypeKind2.ZodEffects, - effect: { type: "refinement", refinement } - }); - } - superRefine(refinement) { - return this._refinement(refinement); - } - optional() { - return ZodOptional2.create(this, this._def); - } - nullable() { - return ZodNullable2.create(this, this._def); - } - nullish() { - return this.nullable().optional(); - } - array() { - return ZodArray2.create(this, this._def); - } - promise() { - return ZodPromise2.create(this, this._def); - } - or(option) { - return ZodUnion2.create([this, option], this._def); - } - and(incoming) { - return ZodIntersection2.create(this, incoming, this._def); - } - transform(transform) { - return new ZodEffects2({ - ...processCreateParams2(this._def), - schema: this, - typeName: ZodFirstPartyTypeKind2.ZodEffects, - effect: { type: "transform", transform } - }); - } - default(def) { - const defaultValueFunc = typeof def === "function" ? def : () => def; - return new ZodDefault2({ - ...processCreateParams2(this._def), - innerType: this, - defaultValue: defaultValueFunc, - typeName: ZodFirstPartyTypeKind2.ZodDefault - }); - } - brand() { - return new ZodBranded2({ - typeName: ZodFirstPartyTypeKind2.ZodBranded, - type: this, - ...processCreateParams2(this._def) - }); - } - catch(def) { - const catchValueFunc = typeof def === "function" ? def : () => def; - return new ZodCatch2({ - ...processCreateParams2(this._def), - innerType: this, - catchValue: catchValueFunc, - typeName: ZodFirstPartyTypeKind2.ZodCatch - }); - } - describe(description) { - const This = this.constructor; - return new This({ - ...this._def, - description - }); - } - pipe(target) { - return ZodPipeline2.create(this, target); - } - readonly() { - return ZodReadonly2.create(this); - } - isOptional() { - return this.safeParse(void 0).success; - } - isNullable() { - return this.safeParse(null).success; - } - }; - exports2.ZodType = ZodType2; - exports2.Schema = ZodType2; - exports2.ZodSchema = ZodType2; - var cuidRegex2 = /^c[^\s-]{8,}$/i; - var cuid2Regex2 = /^[0-9a-z]+$/; - var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/; - var uuidRegex2 = /^[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 nanoidRegex2 = /^[a-z0-9_-]{21}$/i; - var durationRegex2 = /^[-+]?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 emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i; - var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`; - var emojiRegex2; - var ipv4Regex2 = /^(?:(?: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 ipv6Regex2 = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; - var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; - var dateRegexSource2 = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`; - var dateRegex2 = new RegExp(`^${dateRegexSource2}$`); - function timeRegexSource2(args) { - let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`; - if (args.precision) { - regex = `${regex}\\.\\d{${args.precision}}`; - } else if (args.precision == null) { - regex = `${regex}(\\.\\d+)?`; - } - return regex; - } - function timeRegex2(args) { - return new RegExp(`^${timeRegexSource2(args)}$`); - } - function datetimeRegex2(args) { - let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`; - const opts = []; - opts.push(args.local ? `Z?` : `Z`); - if (args.offset) - opts.push(`([+-]\\d{2}:?\\d{2})`); - regex = `${regex}(${opts.join("|")})`; - return new RegExp(`^${regex}$`); - } - exports2.datetimeRegex = datetimeRegex2; - function isValidIP2(ip, version4) { - if ((version4 === "v4" || !version4) && ipv4Regex2.test(ip)) { - return true; - } - if ((version4 === "v6" || !version4) && ipv6Regex2.test(ip)) { - return true; - } - return false; - } - var ZodString2 = class _ZodString extends ZodType2 { - _parse(input) { - if (this._def.coerce) { - input.data = String(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.string) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.string, - received: ctx2.parsedType - }); - return parseUtil_1.INVALID; - } - const status = new parseUtil_1.ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.length < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.length > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "length") { - const tooBig = input.data.length > check.value; - const tooSmall = input.data.length < check.value; - if (tooBig || tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - if (tooBig) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } else if (tooSmall) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: check.value, - type: "string", - inclusive: true, - exact: true, - message: check.message - }); - } - status.dirty(); - } - } else if (check.kind === "email") { - if (!emailRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "email", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "emoji") { - if (!emojiRegex2) { - emojiRegex2 = new RegExp(_emojiRegex2, "u"); - } - if (!emojiRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "emoji", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "uuid") { - if (!uuidRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "uuid", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "nanoid") { - if (!nanoidRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "nanoid", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid") { - if (!cuidRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "cuid", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "cuid2") { - if (!cuid2Regex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "cuid2", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ulid") { - if (!ulidRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "ulid", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "url") { - try { - new URL(input.data); - } catch (_a) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "url", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "regex") { - check.regex.lastIndex = 0; - const testResult = check.regex.test(input.data); - if (!testResult) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "regex", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "trim") { - input.data = input.data.trim(); - } else if (check.kind === "includes") { - if (!input.data.includes(check.value, check.position)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: { includes: check.value, position: check.position }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "toLowerCase") { - input.data = input.data.toLowerCase(); - } else if (check.kind === "toUpperCase") { - input.data = input.data.toUpperCase(); - } else if (check.kind === "startsWith") { - if (!input.data.startsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: { startsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "endsWith") { - if (!input.data.endsWith(check.value)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: { endsWith: check.value }, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "datetime") { - const regex = datetimeRegex2(check); - if (!regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: "datetime", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "date") { - const regex = dateRegex2; - if (!regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: "date", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "time") { - const regex = timeRegex2(check); - if (!regex.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_string, - validation: "time", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "duration") { - if (!durationRegex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "duration", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "ip") { - if (!isValidIP2(input.data, check.version)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "ip", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "base64") { - if (!base64Regex2.test(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - validation: "base64", - code: ZodError_1.ZodIssueCode.invalid_string, - message: check.message - }); - status.dirty(); - } - } else { - util_1.util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - _regex(regex, validation, message) { - return this.refinement((data) => regex.test(data), { - validation, - code: ZodError_1.ZodIssueCode.invalid_string, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - _addCheck(check) { - return new _ZodString({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - email(message) { - return this._addCheck({ kind: "email", ...errorUtil_1.errorUtil.errToObj(message) }); - } - url(message) { - return this._addCheck({ kind: "url", ...errorUtil_1.errorUtil.errToObj(message) }); - } - emoji(message) { - return this._addCheck({ kind: "emoji", ...errorUtil_1.errorUtil.errToObj(message) }); - } - uuid(message) { - return this._addCheck({ kind: "uuid", ...errorUtil_1.errorUtil.errToObj(message) }); - } - nanoid(message) { - return this._addCheck({ kind: "nanoid", ...errorUtil_1.errorUtil.errToObj(message) }); - } - cuid(message) { - return this._addCheck({ kind: "cuid", ...errorUtil_1.errorUtil.errToObj(message) }); - } - cuid2(message) { - return this._addCheck({ kind: "cuid2", ...errorUtil_1.errorUtil.errToObj(message) }); - } - ulid(message) { - return this._addCheck({ kind: "ulid", ...errorUtil_1.errorUtil.errToObj(message) }); - } - base64(message) { - return this._addCheck({ kind: "base64", ...errorUtil_1.errorUtil.errToObj(message) }); - } - ip(options) { - return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) }); - } - datetime(options) { - var _a, _b; - if (typeof options === "string") { - return this._addCheck({ - kind: "datetime", - precision: null, - offset: false, - local: false, - message: options - }); - } - return this._addCheck({ - kind: "datetime", - precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false, - local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false, - ...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - date(message) { - return this._addCheck({ kind: "date", message }); - } - time(options) { - if (typeof options === "string") { - return this._addCheck({ - kind: "time", - precision: null, - message: options - }); - } - return this._addCheck({ - kind: "time", - precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision, - ...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - duration(message) { - return this._addCheck({ kind: "duration", ...errorUtil_1.errorUtil.errToObj(message) }); - } - regex(regex, message) { - return this._addCheck({ - kind: "regex", - regex, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - includes(value, options) { - return this._addCheck({ - kind: "includes", - value, - position: options === null || options === void 0 ? void 0 : options.position, - ...errorUtil_1.errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message) - }); - } - startsWith(value, message) { - return this._addCheck({ - kind: "startsWith", - value, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - endsWith(value, message) { - return this._addCheck({ - kind: "endsWith", - value, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - min(minLength, message) { - return this._addCheck({ - kind: "min", - value: minLength, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - max(maxLength, message) { - return this._addCheck({ - kind: "max", - value: maxLength, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - length(len, message) { - return this._addCheck({ - kind: "length", - value: len, - ...errorUtil_1.errorUtil.errToObj(message) - }); - } - /** - * @deprecated Use z.string().min(1) instead. - * @see {@link ZodString.min} - */ - nonempty(message) { - return this.min(1, errorUtil_1.errorUtil.errToObj(message)); - } - trim() { - return new _ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "trim" }] - }); - } - toLowerCase() { - return new _ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toLowerCase" }] - }); - } - toUpperCase() { - return new _ZodString({ - ...this._def, - checks: [...this._def.checks, { kind: "toUpperCase" }] - }); - } - get isDatetime() { - return !!this._def.checks.find((ch) => ch.kind === "datetime"); - } - get isDate() { - return !!this._def.checks.find((ch) => ch.kind === "date"); - } - get isTime() { - return !!this._def.checks.find((ch) => ch.kind === "time"); - } - get isDuration() { - return !!this._def.checks.find((ch) => ch.kind === "duration"); - } - get isEmail() { - return !!this._def.checks.find((ch) => ch.kind === "email"); - } - get isURL() { - return !!this._def.checks.find((ch) => ch.kind === "url"); - } - get isEmoji() { - return !!this._def.checks.find((ch) => ch.kind === "emoji"); - } - get isUUID() { - return !!this._def.checks.find((ch) => ch.kind === "uuid"); - } - get isNANOID() { - return !!this._def.checks.find((ch) => ch.kind === "nanoid"); - } - get isCUID() { - return !!this._def.checks.find((ch) => ch.kind === "cuid"); - } - get isCUID2() { - return !!this._def.checks.find((ch) => ch.kind === "cuid2"); - } - get isULID() { - return !!this._def.checks.find((ch) => ch.kind === "ulid"); - } - get isIP() { - return !!this._def.checks.find((ch) => ch.kind === "ip"); - } - get isBase64() { - return !!this._def.checks.find((ch) => ch.kind === "base64"); - } - get minLength() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxLength() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - }; - exports2.ZodString = ZodString2; - ZodString2.create = (params) => { - var _a; - return new ZodString2({ - checks: [], - typeName: ZodFirstPartyTypeKind2.ZodString, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams2(params) - }); - }; - function floatSafeRemainder2(val, step) { - const valDecCount = (val.toString().split(".")[1] || "").length; - const stepDecCount = (step.toString().split(".")[1] || "").length; - const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; - const valInt = parseInt(val.toFixed(decCount).replace(".", "")); - const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); - return valInt % stepInt / Math.pow(10, decCount); - } - var ZodNumber2 = class _ZodNumber extends ZodType2 { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - this.step = this.multipleOf; - } - _parse(input) { - if (this._def.coerce) { - input.data = Number(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.number) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.number, - received: ctx2.parsedType - }); - return parseUtil_1.INVALID; - } - let ctx = void 0; - const status = new parseUtil_1.ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "int") { - if (!util_1.util.isInteger(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: "integer", - received: "float", - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: check.value, - type: "number", - inclusive: check.inclusive, - exact: false, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (floatSafeRemainder2(input.data, check.value) !== 0) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "finite") { - if (!Number.isFinite(input.data)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.not_finite, - message: check.message - }); - status.dirty(); - } - } else { - util_1.util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil_1.errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil_1.errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil_1.errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil_1.errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new _ZodNumber({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil_1.errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new _ZodNumber({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - int(message) { - return this._addCheck({ - kind: "int", - message: errorUtil_1.errorUtil.toString(message) - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: false, - message: errorUtil_1.errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: false, - message: errorUtil_1.errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: 0, - inclusive: true, - message: errorUtil_1.errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: 0, - inclusive: true, - message: errorUtil_1.errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil_1.errorUtil.toString(message) - }); - } - finite(message) { - return this._addCheck({ - kind: "finite", - message: errorUtil_1.errorUtil.toString(message) - }); - } - safe(message) { - return this._addCheck({ - kind: "min", - inclusive: true, - value: Number.MIN_SAFE_INTEGER, - message: errorUtil_1.errorUtil.toString(message) - })._addCheck({ - kind: "max", - inclusive: true, - value: Number.MAX_SAFE_INTEGER, - message: errorUtil_1.errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - get isInt() { - return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util_1.util.isInteger(ch.value)); - } - get isFinite() { - let max = null, min = null; - for (const ch of this._def.checks) { - if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { - return true; - } else if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } else if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return Number.isFinite(min) && Number.isFinite(max); - } - }; - exports2.ZodNumber = ZodNumber2; - ZodNumber2.create = (params) => { - return new ZodNumber2({ - checks: [], - typeName: ZodFirstPartyTypeKind2.ZodNumber, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams2(params) - }); - }; - var ZodBigInt2 = class _ZodBigInt extends ZodType2 { - constructor() { - super(...arguments); - this.min = this.gte; - this.max = this.lte; - } - _parse(input) { - if (this._def.coerce) { - input.data = BigInt(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.bigint) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.bigint, - received: ctx2.parsedType - }); - return parseUtil_1.INVALID; - } - let ctx = void 0; - const status = new parseUtil_1.ParseStatus(); - for (const check of this._def.checks) { - if (check.kind === "min") { - const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; - if (tooSmall) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - type: "bigint", - minimum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "max") { - const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; - if (tooBig) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - type: "bigint", - maximum: check.value, - inclusive: check.inclusive, - message: check.message - }); - status.dirty(); - } - } else if (check.kind === "multipleOf") { - if (input.data % check.value !== BigInt(0)) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.not_multiple_of, - multipleOf: check.value, - message: check.message - }); - status.dirty(); - } - } else { - util_1.util.assertNever(check); - } - } - return { status: status.value, value: input.data }; - } - gte(value, message) { - return this.setLimit("min", value, true, errorUtil_1.errorUtil.toString(message)); - } - gt(value, message) { - return this.setLimit("min", value, false, errorUtil_1.errorUtil.toString(message)); - } - lte(value, message) { - return this.setLimit("max", value, true, errorUtil_1.errorUtil.toString(message)); - } - lt(value, message) { - return this.setLimit("max", value, false, errorUtil_1.errorUtil.toString(message)); - } - setLimit(kind, value, inclusive, message) { - return new _ZodBigInt({ - ...this._def, - checks: [ - ...this._def.checks, - { - kind, - value, - inclusive, - message: errorUtil_1.errorUtil.toString(message) - } - ] - }); - } - _addCheck(check) { - return new _ZodBigInt({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - positive(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: false, - message: errorUtil_1.errorUtil.toString(message) - }); - } - negative(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: false, - message: errorUtil_1.errorUtil.toString(message) - }); - } - nonpositive(message) { - return this._addCheck({ - kind: "max", - value: BigInt(0), - inclusive: true, - message: errorUtil_1.errorUtil.toString(message) - }); - } - nonnegative(message) { - return this._addCheck({ - kind: "min", - value: BigInt(0), - inclusive: true, - message: errorUtil_1.errorUtil.toString(message) - }); - } - multipleOf(value, message) { - return this._addCheck({ - kind: "multipleOf", - value, - message: errorUtil_1.errorUtil.toString(message) - }); - } - get minValue() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min; - } - get maxValue() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max; - } - }; - exports2.ZodBigInt = ZodBigInt2; - ZodBigInt2.create = (params) => { - var _a; - return new ZodBigInt2({ - checks: [], - typeName: ZodFirstPartyTypeKind2.ZodBigInt, - coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, - ...processCreateParams2(params) - }); - }; - var ZodBoolean2 = class extends ZodType2 { - _parse(input) { - if (this._def.coerce) { - input.data = Boolean(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.boolean) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.boolean, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodBoolean = ZodBoolean2; - ZodBoolean2.create = (params) => { - return new ZodBoolean2({ - typeName: ZodFirstPartyTypeKind2.ZodBoolean, - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - ...processCreateParams2(params) - }); - }; - var ZodDate2 = class _ZodDate extends ZodType2 { - _parse(input) { - if (this._def.coerce) { - input.data = new Date(input.data); - } - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.date) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.date, - received: ctx2.parsedType - }); - return parseUtil_1.INVALID; - } - if (isNaN(input.data.getTime())) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_date - }); - return parseUtil_1.INVALID; - } - const status = new parseUtil_1.ParseStatus(); - let ctx = void 0; - for (const check of this._def.checks) { - if (check.kind === "min") { - if (input.data.getTime() < check.value) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - message: check.message, - inclusive: true, - exact: false, - minimum: check.value, - type: "date" - }); - status.dirty(); - } - } else if (check.kind === "max") { - if (input.data.getTime() > check.value) { - ctx = this._getOrReturnCtx(input, ctx); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - message: check.message, - inclusive: true, - exact: false, - maximum: check.value, - type: "date" - }); - status.dirty(); - } - } else { - util_1.util.assertNever(check); - } - } - return { - status: status.value, - value: new Date(input.data.getTime()) - }; - } - _addCheck(check) { - return new _ZodDate({ - ...this._def, - checks: [...this._def.checks, check] - }); - } - min(minDate, message) { - return this._addCheck({ - kind: "min", - value: minDate.getTime(), - message: errorUtil_1.errorUtil.toString(message) - }); - } - max(maxDate, message) { - return this._addCheck({ - kind: "max", - value: maxDate.getTime(), - message: errorUtil_1.errorUtil.toString(message) - }); - } - get minDate() { - let min = null; - for (const ch of this._def.checks) { - if (ch.kind === "min") { - if (min === null || ch.value > min) - min = ch.value; - } - } - return min != null ? new Date(min) : null; - } - get maxDate() { - let max = null; - for (const ch of this._def.checks) { - if (ch.kind === "max") { - if (max === null || ch.value < max) - max = ch.value; - } - } - return max != null ? new Date(max) : null; - } - }; - exports2.ZodDate = ZodDate2; - ZodDate2.create = (params) => { - return new ZodDate2({ - checks: [], - coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, - typeName: ZodFirstPartyTypeKind2.ZodDate, - ...processCreateParams2(params) - }); - }; - var ZodSymbol2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.symbol) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.symbol, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodSymbol = ZodSymbol2; - ZodSymbol2.create = (params) => { - return new ZodSymbol2({ - typeName: ZodFirstPartyTypeKind2.ZodSymbol, - ...processCreateParams2(params) - }); - }; - var ZodUndefined2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.undefined, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodUndefined = ZodUndefined2; - ZodUndefined2.create = (params) => { - return new ZodUndefined2({ - typeName: ZodFirstPartyTypeKind2.ZodUndefined, - ...processCreateParams2(params) - }); - }; - var ZodNull2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.null) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.null, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodNull = ZodNull2; - ZodNull2.create = (params) => { - return new ZodNull2({ - typeName: ZodFirstPartyTypeKind2.ZodNull, - ...processCreateParams2(params) - }); - }; - var ZodAny2 = class extends ZodType2 { - constructor() { - super(...arguments); - this._any = true; - } - _parse(input) { - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodAny = ZodAny2; - ZodAny2.create = (params) => { - return new ZodAny2({ - typeName: ZodFirstPartyTypeKind2.ZodAny, - ...processCreateParams2(params) - }); - }; - var ZodUnknown2 = class extends ZodType2 { - constructor() { - super(...arguments); - this._unknown = true; - } - _parse(input) { - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodUnknown = ZodUnknown2; - ZodUnknown2.create = (params) => { - return new ZodUnknown2({ - typeName: ZodFirstPartyTypeKind2.ZodUnknown, - ...processCreateParams2(params) - }); - }; - var ZodNever2 = class extends ZodType2 { - _parse(input) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.never, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - }; - exports2.ZodNever = ZodNever2; - ZodNever2.create = (params) => { - return new ZodNever2({ - typeName: ZodFirstPartyTypeKind2.ZodNever, - ...processCreateParams2(params) - }); - }; - var ZodVoid2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.undefined) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.void, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - }; - exports2.ZodVoid = ZodVoid2; - ZodVoid2.create = (params) => { - return new ZodVoid2({ - typeName: ZodFirstPartyTypeKind2.ZodVoid, - ...processCreateParams2(params) - }); - }; - var ZodArray2 = class _ZodArray extends ZodType2 { - _parse(input) { - const { ctx, status } = this._processInputParams(input); - const def = this._def; - if (ctx.parsedType !== util_1.ZodParsedType.array) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.array, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - if (def.exactLength !== null) { - const tooBig = ctx.data.length > def.exactLength.value; - const tooSmall = ctx.data.length < def.exactLength.value; - if (tooBig || tooSmall) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: tooBig ? ZodError_1.ZodIssueCode.too_big : ZodError_1.ZodIssueCode.too_small, - minimum: tooSmall ? def.exactLength.value : void 0, - maximum: tooBig ? def.exactLength.value : void 0, - type: "array", - inclusive: true, - exact: true, - message: def.exactLength.message - }); - status.dirty(); - } - } - if (def.minLength !== null) { - if (ctx.data.length < def.minLength.value) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: def.minLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.minLength.message - }); - status.dirty(); - } - } - if (def.maxLength !== null) { - if (ctx.data.length > def.maxLength.value) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: def.maxLength.value, - type: "array", - inclusive: true, - exact: false, - message: def.maxLength.message - }); - status.dirty(); - } - } - if (ctx.common.async) { - return Promise.all([...ctx.data].map((item, i) => { - return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i)); - })).then((result2) => { - return parseUtil_1.ParseStatus.mergeArray(status, result2); - }); - } - const result = [...ctx.data].map((item, i) => { - return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i)); - }); - return parseUtil_1.ParseStatus.mergeArray(status, result); - } - get element() { - return this._def.type; - } - min(minLength, message) { - return new _ZodArray({ - ...this._def, - minLength: { value: minLength, message: errorUtil_1.errorUtil.toString(message) } - }); - } - max(maxLength, message) { - return new _ZodArray({ - ...this._def, - maxLength: { value: maxLength, message: errorUtil_1.errorUtil.toString(message) } - }); - } - length(len, message) { - return new _ZodArray({ - ...this._def, - exactLength: { value: len, message: errorUtil_1.errorUtil.toString(message) } - }); - } - nonempty(message) { - return this.min(1, message); - } - }; - exports2.ZodArray = ZodArray2; - ZodArray2.create = (schema, params) => { - return new ZodArray2({ - type: schema, - minLength: null, - maxLength: null, - exactLength: null, - typeName: ZodFirstPartyTypeKind2.ZodArray, - ...processCreateParams2(params) - }); - }; - function deepPartialify2(schema) { - if (schema instanceof ZodObject2) { - const newShape = {}; - for (const key in schema.shape) { - const fieldSchema = schema.shape[key]; - newShape[key] = ZodOptional2.create(deepPartialify2(fieldSchema)); - } - return new ZodObject2({ - ...schema._def, - shape: () => newShape - }); - } else if (schema instanceof ZodArray2) { - return new ZodArray2({ - ...schema._def, - type: deepPartialify2(schema.element) - }); - } else if (schema instanceof ZodOptional2) { - return ZodOptional2.create(deepPartialify2(schema.unwrap())); - } else if (schema instanceof ZodNullable2) { - return ZodNullable2.create(deepPartialify2(schema.unwrap())); - } else if (schema instanceof ZodTuple2) { - return ZodTuple2.create(schema.items.map((item) => deepPartialify2(item))); - } else { - return schema; - } - } - var ZodObject2 = class _ZodObject extends ZodType2 { - constructor() { - super(...arguments); - this._cached = null; - this.nonstrict = this.passthrough; - this.augment = this.extend; - } - _getCached() { - if (this._cached !== null) - return this._cached; - const shape = this._def.shape(); - const keys = util_1.util.objectKeys(shape); - return this._cached = { shape, keys }; - } - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.object) { - const ctx2 = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx2, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.object, - received: ctx2.parsedType - }); - return parseUtil_1.INVALID; - } - const { status, ctx } = this._processInputParams(input); - const { shape, keys: shapeKeys } = this._getCached(); - const extraKeys = []; - if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) { - for (const key in ctx.data) { - if (!shapeKeys.includes(key)) { - extraKeys.push(key); - } - } - } - const pairs = []; - for (const key of shapeKeys) { - const keyValidator = shape[key]; - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (this._def.catchall instanceof ZodNever2) { - const unknownKeys = this._def.unknownKeys; - if (unknownKeys === "passthrough") { - for (const key of extraKeys) { - pairs.push({ - key: { status: "valid", value: key }, - value: { status: "valid", value: ctx.data[key] } - }); - } - } else if (unknownKeys === "strict") { - if (extraKeys.length > 0) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.unrecognized_keys, - keys: extraKeys - }); - status.dirty(); - } - } else if (unknownKeys === "strip") { - } else { - throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); - } - } else { - const catchall = this._def.catchall; - for (const key of extraKeys) { - const value = ctx.data[key]; - pairs.push({ - key: { status: "valid", value: key }, - value: catchall._parse( - new ParseInputLazyPath2(ctx, value, ctx.path, key) - //, ctx.child(key), value, getParsedType(value) - ), - alwaysSet: key in ctx.data - }); - } - } - if (ctx.common.async) { - return Promise.resolve().then(async () => { - const syncPairs = []; - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - syncPairs.push({ - key, - value, - alwaysSet: pair.alwaysSet - }); - } - return syncPairs; - }).then((syncPairs) => { - return parseUtil_1.ParseStatus.mergeObjectSync(status, syncPairs); - }); - } else { - return parseUtil_1.ParseStatus.mergeObjectSync(status, pairs); - } - } - get shape() { - return this._def.shape(); - } - strict(message) { - errorUtil_1.errorUtil.errToObj; - return new _ZodObject({ - ...this._def, - unknownKeys: "strict", - ...message !== void 0 ? { - errorMap: (issue, ctx) => { - var _a, _b, _c, _d; - const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; - if (issue.code === "unrecognized_keys") - return { - message: (_d = errorUtil_1.errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError - }; - return { - message: defaultError - }; - } - } : {} - }); - } - strip() { - return new _ZodObject({ - ...this._def, - unknownKeys: "strip" - }); - } - passthrough() { - return new _ZodObject({ - ...this._def, - unknownKeys: "passthrough" - }); - } - // const AugmentFactory = - // (def: Def) => - // ( - // augmentation: Augmentation - // ): ZodObject< - // extendShape, Augmentation>, - // Def["unknownKeys"], - // Def["catchall"] - // > => { - // return new ZodObject({ - // ...def, - // shape: () => ({ - // ...def.shape(), - // ...augmentation, - // }), - // }) as any; - // }; - extend(augmentation) { - return new _ZodObject({ - ...this._def, - shape: () => ({ - ...this._def.shape(), - ...augmentation - }) - }); - } - /** - * 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(merging) { - const merged = new _ZodObject({ - unknownKeys: merging._def.unknownKeys, - catchall: merging._def.catchall, - shape: () => ({ - ...this._def.shape(), - ...merging._def.shape() - }), - typeName: ZodFirstPartyTypeKind2.ZodObject - }); - return merged; - } - // merge< - // Incoming extends AnyZodObject, - // Augmentation extends Incoming["shape"], - // NewOutput extends { - // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation - // ? Augmentation[k]["_output"] - // : k extends keyof Output - // ? Output[k] - // : never; - // }, - // NewInput extends { - // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation - // ? Augmentation[k]["_input"] - // : k extends keyof Input - // ? Input[k] - // : never; - // } - // >( - // merging: Incoming - // ): ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"], - // NewOutput, - // NewInput - // > { - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - setKey(key, schema) { - return this.augment({ [key]: schema }); - } - // merge( - // merging: Incoming - // ): //ZodObject = (merging) => { - // ZodObject< - // extendShape>, - // Incoming["_def"]["unknownKeys"], - // Incoming["_def"]["catchall"] - // > { - // // const mergedShape = objectUtil.mergeShapes( - // // this._def.shape(), - // // merging._def.shape() - // // ); - // const merged: any = new ZodObject({ - // unknownKeys: merging._def.unknownKeys, - // catchall: merging._def.catchall, - // shape: () => - // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), - // typeName: ZodFirstPartyTypeKind.ZodObject, - // }) as any; - // return merged; - // } - catchall(index) { - return new _ZodObject({ - ...this._def, - catchall: index - }); - } - pick(mask) { - const shape = {}; - util_1.util.objectKeys(mask).forEach((key) => { - if (mask[key] && this.shape[key]) { - shape[key] = this.shape[key]; - } - }); - return new _ZodObject({ - ...this._def, - shape: () => shape - }); - } - omit(mask) { - const shape = {}; - util_1.util.objectKeys(this.shape).forEach((key) => { - if (!mask[key]) { - shape[key] = this.shape[key]; - } - }); - return new _ZodObject({ - ...this._def, - shape: () => shape - }); - } - /** - * @deprecated - */ - deepPartial() { - return deepPartialify2(this); - } - partial(mask) { - const newShape = {}; - util_1.util.objectKeys(this.shape).forEach((key) => { - const fieldSchema = this.shape[key]; - if (mask && !mask[key]) { - newShape[key] = fieldSchema; - } else { - newShape[key] = fieldSchema.optional(); - } - }); - return new _ZodObject({ - ...this._def, - shape: () => newShape - }); - } - required(mask) { - const newShape = {}; - util_1.util.objectKeys(this.shape).forEach((key) => { - if (mask && !mask[key]) { - newShape[key] = this.shape[key]; - } else { - const fieldSchema = this.shape[key]; - let newField = fieldSchema; - while (newField instanceof ZodOptional2) { - newField = newField._def.innerType; - } - newShape[key] = newField; - } - }); - return new _ZodObject({ - ...this._def, - shape: () => newShape - }); - } - keyof() { - return createZodEnum2(util_1.util.objectKeys(this.shape)); - } - }; - exports2.ZodObject = ZodObject2; - ZodObject2.create = (shape, params) => { - return new ZodObject2({ - shape: () => shape, - unknownKeys: "strip", - catchall: ZodNever2.create(), - typeName: ZodFirstPartyTypeKind2.ZodObject, - ...processCreateParams2(params) - }); - }; - ZodObject2.strictCreate = (shape, params) => { - return new ZodObject2({ - shape: () => shape, - unknownKeys: "strict", - catchall: ZodNever2.create(), - typeName: ZodFirstPartyTypeKind2.ZodObject, - ...processCreateParams2(params) - }); - }; - ZodObject2.lazycreate = (shape, params) => { - return new ZodObject2({ - shape, - unknownKeys: "strip", - catchall: ZodNever2.create(), - typeName: ZodFirstPartyTypeKind2.ZodObject, - ...processCreateParams2(params) - }); - }; - var ZodUnion2 = class extends ZodType2 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const options = this._def.options; - function handleResults(results) { - for (const result of results) { - if (result.result.status === "valid") { - return result.result; - } - } - for (const result of results) { - if (result.result.status === "dirty") { - ctx.common.issues.push(...result.ctx.common.issues); - return result.result; - } - } - const unionErrors = results.map((result) => new ZodError_1.ZodError(result.ctx.common.issues)); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_union, - unionErrors - }); - return parseUtil_1.INVALID; - } - if (ctx.common.async) { - return Promise.all(options.map(async (option) => { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - return { - result: await option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }), - ctx: childCtx - }; - })).then(handleResults); - } else { - let dirty = void 0; - const issues = []; - for (const option of options) { - const childCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - }, - parent: null - }; - const result = option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: childCtx - }); - if (result.status === "valid") { - return result; - } else if (result.status === "dirty" && !dirty) { - dirty = { result, ctx: childCtx }; - } - if (childCtx.common.issues.length) { - issues.push(childCtx.common.issues); - } - } - if (dirty) { - ctx.common.issues.push(...dirty.ctx.common.issues); - return dirty.result; - } - const unionErrors = issues.map((issues2) => new ZodError_1.ZodError(issues2)); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_union, - unionErrors - }); - return parseUtil_1.INVALID; - } - } - get options() { - return this._def.options; - } - }; - exports2.ZodUnion = ZodUnion2; - ZodUnion2.create = (types, params) => { - return new ZodUnion2({ - options: types, - typeName: ZodFirstPartyTypeKind2.ZodUnion, - ...processCreateParams2(params) - }); - }; - var getDiscriminator2 = (type) => { - if (type instanceof ZodLazy2) { - return getDiscriminator2(type.schema); - } else if (type instanceof ZodEffects2) { - return getDiscriminator2(type.innerType()); - } else if (type instanceof ZodLiteral2) { - return [type.value]; - } else if (type instanceof ZodEnum2) { - return type.options; - } else if (type instanceof ZodNativeEnum2) { - return util_1.util.objectValues(type.enum); - } else if (type instanceof ZodDefault2) { - return getDiscriminator2(type._def.innerType); - } else if (type instanceof ZodUndefined2) { - return [void 0]; - } else if (type instanceof ZodNull2) { - return [null]; - } else if (type instanceof ZodOptional2) { - return [void 0, ...getDiscriminator2(type.unwrap())]; - } else if (type instanceof ZodNullable2) { - return [null, ...getDiscriminator2(type.unwrap())]; - } else if (type instanceof ZodBranded2) { - return getDiscriminator2(type.unwrap()); - } else if (type instanceof ZodReadonly2) { - return getDiscriminator2(type.unwrap()); - } else if (type instanceof ZodCatch2) { - return getDiscriminator2(type._def.innerType); - } else { - return []; - } - }; - var ZodDiscriminatedUnion2 = class _ZodDiscriminatedUnion extends ZodType2 { - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.object) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.object, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - const discriminator = this.discriminator; - const discriminatorValue = ctx.data[discriminator]; - const option = this.optionsMap.get(discriminatorValue); - if (!option) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_union_discriminator, - options: Array.from(this.optionsMap.keys()), - path: [discriminator] - }); - return parseUtil_1.INVALID; - } - if (ctx.common.async) { - return option._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } else { - return option._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - } - } - get discriminator() { - return this._def.discriminator; - } - get options() { - return this._def.options; - } - get optionsMap() { - return this._def.optionsMap; - } - /** - * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. - * However, it only allows a union of objects, all of which need to share a discriminator property. This property must - * have a different value for each object in the union. - * @param discriminator the name of the discriminator property - * @param types an array of object schemas - * @param params - */ - static create(discriminator, options, params) { - const optionsMap = /* @__PURE__ */ new Map(); - for (const type of options) { - const discriminatorValues = getDiscriminator2(type.shape[discriminator]); - if (!discriminatorValues.length) { - throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); - } - for (const value of discriminatorValues) { - if (optionsMap.has(value)) { - throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); - } - optionsMap.set(value, type); - } - } - return new _ZodDiscriminatedUnion({ - typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion, - discriminator, - options, - optionsMap, - ...processCreateParams2(params) - }); - } - }; - exports2.ZodDiscriminatedUnion = ZodDiscriminatedUnion2; - function mergeValues2(a, b) { - const aType = (0, util_1.getParsedType)(a); - const bType = (0, util_1.getParsedType)(b); - if (a === b) { - return { valid: true, data: a }; - } else if (aType === util_1.ZodParsedType.object && bType === util_1.ZodParsedType.object) { - const bKeys = util_1.util.objectKeys(b); - const sharedKeys = util_1.util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1); - const newObj = { ...a, ...b }; - for (const key of sharedKeys) { - const sharedValue = mergeValues2(a[key], b[key]); - if (!sharedValue.valid) { - return { valid: false }; - } - newObj[key] = sharedValue.data; - } - return { valid: true, data: newObj }; - } else if (aType === util_1.ZodParsedType.array && bType === util_1.ZodParsedType.array) { - if (a.length !== b.length) { - return { valid: false }; - } - const newArray = []; - for (let index = 0; index < a.length; index++) { - const itemA = a[index]; - const itemB = b[index]; - const sharedValue = mergeValues2(itemA, itemB); - if (!sharedValue.valid) { - return { valid: false }; - } - newArray.push(sharedValue.data); - } - return { valid: true, data: newArray }; - } else if (aType === util_1.ZodParsedType.date && bType === util_1.ZodParsedType.date && +a === +b) { - return { valid: true, data: a }; - } else { - return { valid: false }; - } - } - var ZodIntersection2 = class extends ZodType2 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const handleParsed = (parsedLeft, parsedRight) => { - if ((0, parseUtil_1.isAborted)(parsedLeft) || (0, parseUtil_1.isAborted)(parsedRight)) { - return parseUtil_1.INVALID; - } - const merged = mergeValues2(parsedLeft.value, parsedRight.value); - if (!merged.valid) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_intersection_types - }); - return parseUtil_1.INVALID; - } - if ((0, parseUtil_1.isDirty)(parsedLeft) || (0, parseUtil_1.isDirty)(parsedRight)) { - status.dirty(); - } - return { status: status.value, value: merged.data }; - }; - if (ctx.common.async) { - return Promise.all([ - this._def.left._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), - this._def.right._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }) - ]).then(([left, right]) => handleParsed(left, right)); - } else { - return handleParsed(this._def.left._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }), this._def.right._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - })); - } - } - }; - exports2.ZodIntersection = ZodIntersection2; - ZodIntersection2.create = (left, right, params) => { - return new ZodIntersection2({ - left, - right, - typeName: ZodFirstPartyTypeKind2.ZodIntersection, - ...processCreateParams2(params) - }); - }; - var ZodTuple2 = class _ZodTuple extends ZodType2 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.array) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.array, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - if (ctx.data.length < this._def.items.length) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - return parseUtil_1.INVALID; - } - const rest = this._def.rest; - if (!rest && ctx.data.length > this._def.items.length) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: this._def.items.length, - inclusive: true, - exact: false, - type: "array" - }); - status.dirty(); - } - const items = [...ctx.data].map((item, itemIndex) => { - const schema = this._def.items[itemIndex] || this._def.rest; - if (!schema) - return null; - return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex)); - }).filter((x) => !!x); - if (ctx.common.async) { - return Promise.all(items).then((results) => { - return parseUtil_1.ParseStatus.mergeArray(status, results); - }); - } else { - return parseUtil_1.ParseStatus.mergeArray(status, items); - } - } - get items() { - return this._def.items; - } - rest(rest) { - return new _ZodTuple({ - ...this._def, - rest - }); - } - }; - exports2.ZodTuple = ZodTuple2; - ZodTuple2.create = (schemas, params) => { - if (!Array.isArray(schemas)) { - throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); - } - return new ZodTuple2({ - items: schemas, - typeName: ZodFirstPartyTypeKind2.ZodTuple, - rest: null, - ...processCreateParams2(params) - }); - }; - var ZodRecord2 = class _ZodRecord extends ZodType2 { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.object) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.object, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - const pairs = []; - const keyType = this._def.keyType; - const valueType = this._def.valueType; - for (const key in ctx.data) { - pairs.push({ - key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)), - value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)), - alwaysSet: key in ctx.data - }); - } - if (ctx.common.async) { - return parseUtil_1.ParseStatus.mergeObjectAsync(status, pairs); - } else { - return parseUtil_1.ParseStatus.mergeObjectSync(status, pairs); - } - } - get element() { - return this._def.valueType; - } - static create(first, second, third) { - if (second instanceof ZodType2) { - return new _ZodRecord({ - keyType: first, - valueType: second, - typeName: ZodFirstPartyTypeKind2.ZodRecord, - ...processCreateParams2(third) - }); - } - return new _ZodRecord({ - keyType: ZodString2.create(), - valueType: first, - typeName: ZodFirstPartyTypeKind2.ZodRecord, - ...processCreateParams2(second) - }); - } - }; - exports2.ZodRecord = ZodRecord2; - var ZodMap2 = class extends ZodType2 { - get keySchema() { - return this._def.keyType; - } - get valueSchema() { - return this._def.valueType; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.map) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.map, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - const keyType = this._def.keyType; - const valueType = this._def.valueType; - const pairs = [...ctx.data.entries()].map(([key, value], index) => { - return { - key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])), - value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"])) - }; - }); - if (ctx.common.async) { - const finalMap = /* @__PURE__ */ new Map(); - return Promise.resolve().then(async () => { - for (const pair of pairs) { - const key = await pair.key; - const value = await pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return parseUtil_1.INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - }); - } else { - const finalMap = /* @__PURE__ */ new Map(); - for (const pair of pairs) { - const key = pair.key; - const value = pair.value; - if (key.status === "aborted" || value.status === "aborted") { - return parseUtil_1.INVALID; - } - if (key.status === "dirty" || value.status === "dirty") { - status.dirty(); - } - finalMap.set(key.value, value.value); - } - return { status: status.value, value: finalMap }; - } - } - }; - exports2.ZodMap = ZodMap2; - ZodMap2.create = (keyType, valueType, params) => { - return new ZodMap2({ - valueType, - keyType, - typeName: ZodFirstPartyTypeKind2.ZodMap, - ...processCreateParams2(params) - }); - }; - var ZodSet2 = class _ZodSet extends ZodType2 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.set) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.set, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - const def = this._def; - if (def.minSize !== null) { - if (ctx.data.size < def.minSize.value) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_small, - minimum: def.minSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.minSize.message - }); - status.dirty(); - } - } - if (def.maxSize !== null) { - if (ctx.data.size > def.maxSize.value) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.too_big, - maximum: def.maxSize.value, - type: "set", - inclusive: true, - exact: false, - message: def.maxSize.message - }); - status.dirty(); - } - } - const valueType = this._def.valueType; - function finalizeSet(elements2) { - const parsedSet = /* @__PURE__ */ new Set(); - for (const element of elements2) { - if (element.status === "aborted") - return parseUtil_1.INVALID; - if (element.status === "dirty") - status.dirty(); - parsedSet.add(element.value); - } - return { status: status.value, value: parsedSet }; - } - const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i))); - if (ctx.common.async) { - return Promise.all(elements).then((elements2) => finalizeSet(elements2)); - } else { - return finalizeSet(elements); - } - } - min(minSize, message) { - return new _ZodSet({ - ...this._def, - minSize: { value: minSize, message: errorUtil_1.errorUtil.toString(message) } - }); - } - max(maxSize, message) { - return new _ZodSet({ - ...this._def, - maxSize: { value: maxSize, message: errorUtil_1.errorUtil.toString(message) } - }); - } - size(size, message) { - return this.min(size, message).max(size, message); - } - nonempty(message) { - return this.min(1, message); - } - }; - exports2.ZodSet = ZodSet2; - ZodSet2.create = (valueType, params) => { - return new ZodSet2({ - valueType, - minSize: null, - maxSize: null, - typeName: ZodFirstPartyTypeKind2.ZodSet, - ...processCreateParams2(params) - }); - }; - var ZodFunction2 = class _ZodFunction extends ZodType2 { - constructor() { - super(...arguments); - this.validate = this.implement; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.function) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.function, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - function makeArgsIssue(args, error) { - return (0, parseUtil_1.makeIssue)({ - data: args, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - (0, errors_1.getErrorMap)(), - errors_1.defaultErrorMap - ].filter((x) => !!x), - issueData: { - code: ZodError_1.ZodIssueCode.invalid_arguments, - argumentsError: error - } - }); - } - function makeReturnsIssue(returns, error) { - return (0, parseUtil_1.makeIssue)({ - data: returns, - path: ctx.path, - errorMaps: [ - ctx.common.contextualErrorMap, - ctx.schemaErrorMap, - (0, errors_1.getErrorMap)(), - errors_1.defaultErrorMap - ].filter((x) => !!x), - issueData: { - code: ZodError_1.ZodIssueCode.invalid_return_type, - returnTypeError: error - } - }); - } - const params = { errorMap: ctx.common.contextualErrorMap }; - const fn = ctx.data; - if (this._def.returns instanceof ZodPromise2) { - const me = this; - return (0, parseUtil_1.OK)(async function(...args) { - const error = new ZodError_1.ZodError([]); - const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; - }); - const result = await Reflect.apply(fn, this, parsedArgs); - const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; - }); - return parsedReturns; - }); - } else { - const me = this; - return (0, parseUtil_1.OK)(function(...args) { - const parsedArgs = me._def.args.safeParse(args, params); - if (!parsedArgs.success) { - throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]); - } - const result = Reflect.apply(fn, this, parsedArgs.data); - const parsedReturns = me._def.returns.safeParse(result, params); - if (!parsedReturns.success) { - throw new ZodError_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]); - } - return parsedReturns.data; - }); - } - } - parameters() { - return this._def.args; - } - returnType() { - return this._def.returns; - } - args(...items) { - return new _ZodFunction({ - ...this._def, - args: ZodTuple2.create(items).rest(ZodUnknown2.create()) - }); - } - returns(returnType) { - return new _ZodFunction({ - ...this._def, - returns: returnType - }); - } - implement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - strictImplement(func) { - const validatedFunc = this.parse(func); - return validatedFunc; - } - static create(args, returns, params) { - return new _ZodFunction({ - args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()), - returns: returns || ZodUnknown2.create(), - typeName: ZodFirstPartyTypeKind2.ZodFunction, - ...processCreateParams2(params) - }); - } - }; - exports2.ZodFunction = ZodFunction2; - var ZodLazy2 = class extends ZodType2 { - get schema() { - return this._def.getter(); - } - _parse(input) { - const { ctx } = this._processInputParams(input); - const lazySchema = this._def.getter(); - return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); - } - }; - exports2.ZodLazy = ZodLazy2; - ZodLazy2.create = (getter, params) => { - return new ZodLazy2({ - getter, - typeName: ZodFirstPartyTypeKind2.ZodLazy, - ...processCreateParams2(params) - }); - }; - var ZodLiteral2 = class extends ZodType2 { - _parse(input) { - if (input.data !== this._def.value) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - received: ctx.data, - code: ZodError_1.ZodIssueCode.invalid_literal, - expected: this._def.value - }); - return parseUtil_1.INVALID; - } - return { status: "valid", value: input.data }; - } - get value() { - return this._def.value; - } - }; - exports2.ZodLiteral = ZodLiteral2; - ZodLiteral2.create = (value, params) => { - return new ZodLiteral2({ - value, - typeName: ZodFirstPartyTypeKind2.ZodLiteral, - ...processCreateParams2(params) - }); - }; - function createZodEnum2(values, params) { - return new ZodEnum2({ - values, - typeName: ZodFirstPartyTypeKind2.ZodEnum, - ...processCreateParams2(params) - }); - } - var ZodEnum2 = class _ZodEnum extends ZodType2 { - constructor() { - super(...arguments); - _ZodEnum_cache2.set(this, void 0); - } - _parse(input) { - if (typeof input.data !== "string") { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - (0, parseUtil_1.addIssueToContext)(ctx, { - expected: util_1.util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodError_1.ZodIssueCode.invalid_type - }); - return parseUtil_1.INVALID; - } - if (!__classPrivateFieldGet3(this, _ZodEnum_cache2, "f")) { - __classPrivateFieldSet3(this, _ZodEnum_cache2, new Set(this._def.values), "f"); - } - if (!__classPrivateFieldGet3(this, _ZodEnum_cache2, "f").has(input.data)) { - const ctx = this._getOrReturnCtx(input); - const expectedValues = this._def.values; - (0, parseUtil_1.addIssueToContext)(ctx, { - received: ctx.data, - code: ZodError_1.ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - get options() { - return this._def.values; - } - get enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Values() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - get Enum() { - const enumValues = {}; - for (const val of this._def.values) { - enumValues[val] = val; - } - return enumValues; - } - extract(values, newDef = this._def) { - return _ZodEnum.create(values, { - ...this._def, - ...newDef - }); - } - exclude(values, newDef = this._def) { - return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), { - ...this._def, - ...newDef - }); - } - }; - exports2.ZodEnum = ZodEnum2; - _ZodEnum_cache2 = /* @__PURE__ */ new WeakMap(); - ZodEnum2.create = createZodEnum2; - var ZodNativeEnum2 = class extends ZodType2 { - constructor() { - super(...arguments); - _ZodNativeEnum_cache2.set(this, void 0); - } - _parse(input) { - const nativeEnumValues = util_1.util.getValidEnumValues(this._def.values); - const ctx = this._getOrReturnCtx(input); - if (ctx.parsedType !== util_1.ZodParsedType.string && ctx.parsedType !== util_1.ZodParsedType.number) { - const expectedValues = util_1.util.objectValues(nativeEnumValues); - (0, parseUtil_1.addIssueToContext)(ctx, { - expected: util_1.util.joinValues(expectedValues), - received: ctx.parsedType, - code: ZodError_1.ZodIssueCode.invalid_type - }); - return parseUtil_1.INVALID; - } - if (!__classPrivateFieldGet3(this, _ZodNativeEnum_cache2, "f")) { - __classPrivateFieldSet3(this, _ZodNativeEnum_cache2, new Set(util_1.util.getValidEnumValues(this._def.values)), "f"); - } - if (!__classPrivateFieldGet3(this, _ZodNativeEnum_cache2, "f").has(input.data)) { - const expectedValues = util_1.util.objectValues(nativeEnumValues); - (0, parseUtil_1.addIssueToContext)(ctx, { - received: ctx.data, - code: ZodError_1.ZodIssueCode.invalid_enum_value, - options: expectedValues - }); - return parseUtil_1.INVALID; - } - return (0, parseUtil_1.OK)(input.data); - } - get enum() { - return this._def.values; - } - }; - exports2.ZodNativeEnum = ZodNativeEnum2; - _ZodNativeEnum_cache2 = /* @__PURE__ */ new WeakMap(); - ZodNativeEnum2.create = (values, params) => { - return new ZodNativeEnum2({ - values, - typeName: ZodFirstPartyTypeKind2.ZodNativeEnum, - ...processCreateParams2(params) - }); - }; - var ZodPromise2 = class extends ZodType2 { - unwrap() { - return this._def.type; - } - _parse(input) { - const { ctx } = this._processInputParams(input); - if (ctx.parsedType !== util_1.ZodParsedType.promise && ctx.common.async === false) { - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.promise, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - const promisified = ctx.parsedType === util_1.ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); - return (0, parseUtil_1.OK)(promisified.then((data) => { - return this._def.type.parseAsync(data, { - path: ctx.path, - errorMap: ctx.common.contextualErrorMap - }); - })); - } - }; - exports2.ZodPromise = ZodPromise2; - ZodPromise2.create = (schema, params) => { - return new ZodPromise2({ - type: schema, - typeName: ZodFirstPartyTypeKind2.ZodPromise, - ...processCreateParams2(params) - }); - }; - var ZodEffects2 = class extends ZodType2 { - innerType() { - return this._def.schema; - } - sourceType() { - return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema; - } - _parse(input) { - const { status, ctx } = this._processInputParams(input); - const effect = this._def.effect || null; - const checkCtx = { - addIssue: (arg) => { - (0, parseUtil_1.addIssueToContext)(ctx, arg); - if (arg.fatal) { - status.abort(); - } else { - status.dirty(); - } - }, - get path() { - return ctx.path; - } - }; - checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); - if (effect.type === "preprocess") { - const processed = effect.transform(ctx.data, checkCtx); - if (ctx.common.async) { - return Promise.resolve(processed).then(async (processed2) => { - if (status.value === "aborted") - return parseUtil_1.INVALID; - const result = await this._def.schema._parseAsync({ - data: processed2, - path: ctx.path, - parent: ctx - }); - if (result.status === "aborted") - return parseUtil_1.INVALID; - if (result.status === "dirty") - return (0, parseUtil_1.DIRTY)(result.value); - if (status.value === "dirty") - return (0, parseUtil_1.DIRTY)(result.value); - return result; - }); - } else { - if (status.value === "aborted") - return parseUtil_1.INVALID; - const result = this._def.schema._parseSync({ - data: processed, - path: ctx.path, - parent: ctx - }); - if (result.status === "aborted") - return parseUtil_1.INVALID; - if (result.status === "dirty") - return (0, parseUtil_1.DIRTY)(result.value); - if (status.value === "dirty") - return (0, parseUtil_1.DIRTY)(result.value); - return result; - } - } - if (effect.type === "refinement") { - const executeRefinement = (acc) => { - const result = effect.refinement(acc, checkCtx); - if (ctx.common.async) { - return Promise.resolve(result); - } - if (result instanceof Promise) { - throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); - } - return acc; - }; - if (ctx.common.async === false) { - const inner = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inner.status === "aborted") - return parseUtil_1.INVALID; - if (inner.status === "dirty") - status.dirty(); - executeRefinement(inner.value); - return { status: status.value, value: inner.value }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { - if (inner.status === "aborted") - return parseUtil_1.INVALID; - if (inner.status === "dirty") - status.dirty(); - return executeRefinement(inner.value).then(() => { - return { status: status.value, value: inner.value }; - }); - }); - } - } - if (effect.type === "transform") { - if (ctx.common.async === false) { - const base = this._def.schema._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (!(0, parseUtil_1.isValid)(base)) - return base; - const result = effect.transform(base.value, checkCtx); - if (result instanceof Promise) { - throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); - } - return { status: status.value, value: result }; - } else { - return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => { - if (!(0, parseUtil_1.isValid)(base)) - return base; - return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })); - }); - } - } - util_1.util.assertNever(effect); - } - }; - exports2.ZodEffects = ZodEffects2; - exports2.ZodTransformer = ZodEffects2; - ZodEffects2.create = (schema, effect, params) => { - return new ZodEffects2({ - schema, - typeName: ZodFirstPartyTypeKind2.ZodEffects, - effect, - ...processCreateParams2(params) - }); - }; - ZodEffects2.createWithPreprocess = (preprocess, schema, params) => { - return new ZodEffects2({ - schema, - effect: { type: "preprocess", transform: preprocess }, - typeName: ZodFirstPartyTypeKind2.ZodEffects, - ...processCreateParams2(params) - }); - }; - var ZodOptional2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === util_1.ZodParsedType.undefined) { - return (0, parseUtil_1.OK)(void 0); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } - }; - exports2.ZodOptional = ZodOptional2; - ZodOptional2.create = (type, params) => { - return new ZodOptional2({ - innerType: type, - typeName: ZodFirstPartyTypeKind2.ZodOptional, - ...processCreateParams2(params) - }); - }; - var ZodNullable2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType === util_1.ZodParsedType.null) { - return (0, parseUtil_1.OK)(null); - } - return this._def.innerType._parse(input); - } - unwrap() { - return this._def.innerType; - } - }; - exports2.ZodNullable = ZodNullable2; - ZodNullable2.create = (type, params) => { - return new ZodNullable2({ - innerType: type, - typeName: ZodFirstPartyTypeKind2.ZodNullable, - ...processCreateParams2(params) - }); - }; - var ZodDefault2 = class extends ZodType2 { - _parse(input) { - const { ctx } = this._processInputParams(input); - let data = ctx.data; - if (ctx.parsedType === util_1.ZodParsedType.undefined) { - data = this._def.defaultValue(); - } - return this._def.innerType._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - removeDefault() { - return this._def.innerType; - } - }; - exports2.ZodDefault = ZodDefault2; - ZodDefault2.create = (type, params) => { - return new ZodDefault2({ - innerType: type, - typeName: ZodFirstPartyTypeKind2.ZodDefault, - defaultValue: typeof params.default === "function" ? params.default : () => params.default, - ...processCreateParams2(params) - }); - }; - var ZodCatch2 = class extends ZodType2 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const newCtx = { - ...ctx, - common: { - ...ctx.common, - issues: [] - } - }; - const result = this._def.innerType._parse({ - data: newCtx.data, - path: newCtx.path, - parent: { - ...newCtx - } - }); - if ((0, parseUtil_1.isAsync)(result)) { - return result.then((result2) => { - return { - status: "valid", - value: result2.status === "valid" ? result2.value : this._def.catchValue({ - get error() { - return new ZodError_1.ZodError(newCtx.common.issues); - }, - input: newCtx.data - }) - }; - }); - } else { - return { - status: "valid", - value: result.status === "valid" ? result.value : this._def.catchValue({ - get error() { - return new ZodError_1.ZodError(newCtx.common.issues); - }, - input: newCtx.data - }) - }; - } - } - removeCatch() { - return this._def.innerType; - } - }; - exports2.ZodCatch = ZodCatch2; - ZodCatch2.create = (type, params) => { - return new ZodCatch2({ - innerType: type, - typeName: ZodFirstPartyTypeKind2.ZodCatch, - catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, - ...processCreateParams2(params) - }); - }; - var ZodNaN2 = class extends ZodType2 { - _parse(input) { - const parsedType = this._getType(input); - if (parsedType !== util_1.ZodParsedType.nan) { - const ctx = this._getOrReturnCtx(input); - (0, parseUtil_1.addIssueToContext)(ctx, { - code: ZodError_1.ZodIssueCode.invalid_type, - expected: util_1.ZodParsedType.nan, - received: ctx.parsedType - }); - return parseUtil_1.INVALID; - } - return { status: "valid", value: input.data }; - } - }; - exports2.ZodNaN = ZodNaN2; - ZodNaN2.create = (params) => { - return new ZodNaN2({ - typeName: ZodFirstPartyTypeKind2.ZodNaN, - ...processCreateParams2(params) - }); - }; - exports2.BRAND = Symbol("zod_brand"); - var ZodBranded2 = class extends ZodType2 { - _parse(input) { - const { ctx } = this._processInputParams(input); - const data = ctx.data; - return this._def.type._parse({ - data, - path: ctx.path, - parent: ctx - }); - } - unwrap() { - return this._def.type; - } - }; - exports2.ZodBranded = ZodBranded2; - var ZodPipeline2 = class _ZodPipeline extends ZodType2 { - _parse(input) { - const { status, ctx } = this._processInputParams(input); - if (ctx.common.async) { - const handleAsync = async () => { - const inResult = await this._def.in._parseAsync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return parseUtil_1.INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return (0, parseUtil_1.DIRTY)(inResult.value); - } else { - return this._def.out._parseAsync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - }; - return handleAsync(); - } else { - const inResult = this._def.in._parseSync({ - data: ctx.data, - path: ctx.path, - parent: ctx - }); - if (inResult.status === "aborted") - return parseUtil_1.INVALID; - if (inResult.status === "dirty") { - status.dirty(); - return { - status: "dirty", - value: inResult.value - }; - } else { - return this._def.out._parseSync({ - data: inResult.value, - path: ctx.path, - parent: ctx - }); - } - } - } - static create(a, b) { - return new _ZodPipeline({ - in: a, - out: b, - typeName: ZodFirstPartyTypeKind2.ZodPipeline - }); - } - }; - exports2.ZodPipeline = ZodPipeline2; - var ZodReadonly2 = class extends ZodType2 { - _parse(input) { - const result = this._def.innerType._parse(input); - const freeze = (data) => { - if ((0, parseUtil_1.isValid)(data)) { - data.value = Object.freeze(data.value); - } - return data; - }; - return (0, parseUtil_1.isAsync)(result) ? result.then((data) => freeze(data)) : freeze(result); - } - unwrap() { - return this._def.innerType; - } - }; - exports2.ZodReadonly = ZodReadonly2; - ZodReadonly2.create = (type, params) => { - return new ZodReadonly2({ - innerType: type, - typeName: ZodFirstPartyTypeKind2.ZodReadonly, - ...processCreateParams2(params) - }); - }; - function custom2(check, params = {}, fatal) { - if (check) - return ZodAny2.create().superRefine((data, ctx) => { - var _a, _b; - if (!check(data)) { - const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params; - const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true; - const p2 = typeof p === "string" ? { message: p } : p; - ctx.addIssue({ code: "custom", ...p2, fatal: _fatal }); - } - }); - return ZodAny2.create(); - } - exports2.custom = custom2; - exports2.late = { - object: ZodObject2.lazycreate - }; - var ZodFirstPartyTypeKind2; - (function(ZodFirstPartyTypeKind3) { - ZodFirstPartyTypeKind3["ZodString"] = "ZodString"; - ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber"; - ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN"; - ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt"; - ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean"; - ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate"; - ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol"; - ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined"; - ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull"; - ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny"; - ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown"; - ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever"; - ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid"; - ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray"; - ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject"; - ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion"; - ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; - ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection"; - ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple"; - ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord"; - ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap"; - ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet"; - ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction"; - ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy"; - ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral"; - ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum"; - ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects"; - ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum"; - ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional"; - ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable"; - ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault"; - ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch"; - ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise"; - ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded"; - ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline"; - ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly"; - })(ZodFirstPartyTypeKind2 = exports2.ZodFirstPartyTypeKind || (exports2.ZodFirstPartyTypeKind = {})); - var instanceOfType2 = (cls, params = { - message: `Input not instance of ${cls.name}` - }) => custom2((data) => data instanceof cls, params); - exports2.instanceof = instanceOfType2; - var stringType2 = ZodString2.create; - exports2.string = stringType2; - var numberType2 = ZodNumber2.create; - exports2.number = numberType2; - var nanType2 = ZodNaN2.create; - exports2.nan = nanType2; - var bigIntType2 = ZodBigInt2.create; - exports2.bigint = bigIntType2; - var booleanType2 = ZodBoolean2.create; - exports2.boolean = booleanType2; - var dateType2 = ZodDate2.create; - exports2.date = dateType2; - var symbolType2 = ZodSymbol2.create; - exports2.symbol = symbolType2; - var undefinedType2 = ZodUndefined2.create; - exports2.undefined = undefinedType2; - var nullType2 = ZodNull2.create; - exports2.null = nullType2; - var anyType2 = ZodAny2.create; - exports2.any = anyType2; - var unknownType2 = ZodUnknown2.create; - exports2.unknown = unknownType2; - var neverType2 = ZodNever2.create; - exports2.never = neverType2; - var voidType2 = ZodVoid2.create; - exports2.void = voidType2; - var arrayType2 = ZodArray2.create; - exports2.array = arrayType2; - var objectType2 = ZodObject2.create; - exports2.object = objectType2; - var strictObjectType2 = ZodObject2.strictCreate; - exports2.strictObject = strictObjectType2; - var unionType2 = ZodUnion2.create; - exports2.union = unionType2; - var discriminatedUnionType2 = ZodDiscriminatedUnion2.create; - exports2.discriminatedUnion = discriminatedUnionType2; - var intersectionType2 = ZodIntersection2.create; - exports2.intersection = intersectionType2; - var tupleType2 = ZodTuple2.create; - exports2.tuple = tupleType2; - var recordType2 = ZodRecord2.create; - exports2.record = recordType2; - var mapType2 = ZodMap2.create; - exports2.map = mapType2; - var setType2 = ZodSet2.create; - exports2.set = setType2; - var functionType2 = ZodFunction2.create; - exports2.function = functionType2; - var lazyType2 = ZodLazy2.create; - exports2.lazy = lazyType2; - var literalType2 = ZodLiteral2.create; - exports2.literal = literalType2; - var enumType2 = ZodEnum2.create; - exports2.enum = enumType2; - var nativeEnumType2 = ZodNativeEnum2.create; - exports2.nativeEnum = nativeEnumType2; - var promiseType2 = ZodPromise2.create; - exports2.promise = promiseType2; - var effectsType2 = ZodEffects2.create; - exports2.effect = effectsType2; - exports2.transformer = effectsType2; - var optionalType2 = ZodOptional2.create; - exports2.optional = optionalType2; - var nullableType2 = ZodNullable2.create; - exports2.nullable = nullableType2; - var preprocessType2 = ZodEffects2.createWithPreprocess; - exports2.preprocess = preprocessType2; - var pipelineType2 = ZodPipeline2.create; - exports2.pipeline = pipelineType2; - var ostring2 = () => stringType2().optional(); - exports2.ostring = ostring2; - var onumber2 = () => numberType2().optional(); - exports2.onumber = onumber2; - var oboolean2 = () => booleanType2().optional(); - exports2.oboolean = oboolean2; - exports2.coerce = { - string: (arg) => ZodString2.create({ ...arg, coerce: true }), - number: (arg) => ZodNumber2.create({ ...arg, coerce: true }), - boolean: (arg) => ZodBoolean2.create({ - ...arg, - coerce: true - }), - bigint: (arg) => ZodBigInt2.create({ ...arg, coerce: true }), - date: (arg) => ZodDate2.create({ ...arg, coerce: true }) - }; - exports2.NEVER = parseUtil_1.INVALID; - } -}); - -// ../../node_modules/zod/lib/external.js -var require_external = __commonJS({ - "../../node_modules/zod/lib/external.js"(exports2) { - "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { - return m[k]; - } }); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }); - var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) - __createBinding2(exports3, m, p); - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - __exportStar2(require_errors2(), exports2); - __exportStar2(require_parseUtil(), exports2); - __exportStar2(require_typeAliases(), exports2); - __exportStar2(require_util8(), exports2); - __exportStar2(require_types(), exports2); - __exportStar2(require_ZodError(), exports2); - } -}); - -// ../../node_modules/zod/lib/index.js -var require_lib2 = __commonJS({ - "../../node_modules/zod/lib/index.js"(exports2) { - "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { - return m[k]; - } }); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - } : function(o, v) { - o["default"] = v; - }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k in mod) - if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); - } - __setModuleDefault2(result, mod); - return result; - }; - var __exportStar2 = exports2 && exports2.__exportStar || function(m, exports3) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) - __createBinding2(exports3, m, p); - }; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.z = void 0; - var z2 = __importStar2(require_external()); - exports2.z = z2; - __exportStar2(require_external(), exports2); - exports2.default = z2; - } -}); - -// ../ci-utils/dist/types.js -var require_types2 = __commonJS({ - "../ci-utils/dist/types.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - exports2.jsonEnvironmentsMappingSchema = exports2.jsonEnvironmentVariablesSchema = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - var zod_1 = tslib_1.__importDefault(require_lib2()); - var environmentVariablesSchema = zod_1.default.record(zod_1.default.string(), zod_1.default.string()); - exports2.jsonEnvironmentVariablesSchema = zod_1.default.string().transform((str, ctx) => { - try { - return JSON.parse(str); - } catch (error) { - ctx.addIssue({ - code: "custom", - message: "input is not a valid JSON-formatted string" - }); - return; - } - }).pipe(environmentVariablesSchema); - var environmentsMappingSchema = zod_1.default.array(zod_1.default.object({ - environmentAlias: zod_1.default.string(), - vcsBranch: zod_1.default.string() - })); - exports2.jsonEnvironmentsMappingSchema = zod_1.default.string().transform((str, ctx) => { - try { - return JSON.parse(str); - } catch (error) { - ctx.addIssue({ - code: "custom", - message: "input is not a valid JSON-formatted string" - }); - return; - } - }).pipe(environmentsMappingSchema); - } -}); - -// ../ci-utils/dist/index.js -var require_dist = __commonJS({ - "../ci-utils/dist/index.js"(exports2) { - "use strict"; - Object.defineProperty(exports2, "__esModule", { value: true }); - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); - tslib_1.__exportStar(require_log(), exports2); - tslib_1.__exportStar(require_string(), exports2); - tslib_1.__exportStar(require_types2(), exports2); - } -}); - // src/index.ts var core3 = __toESM(require_core()); var github3 = __toESM(require_github()); -// ../ci-sdk/dist/esm/lib/other.js +// ../ci-sdk/dist/index.mjs +var import_slugify = __toESM(require_slugify(), 1); +var __defProp2 = Object.defineProperty; +var __name = (target, value) => __defProp2(target, "name", { value, configurable: true }); function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } +__name(sleep, "sleep"); function pluralize(count) { return count === 1 ? "" : "s"; } +__name(pluralize, "pluralize"); function getBackoffMs(attemptNumber, minWaitMs = 1e3, maxWaitMs = 1e4) { return Math.min(maxWaitMs, minWaitMs * 1.2 ** attemptNumber); } -var buildFetchWithTimeout = (fetch, timeout) => async (...args) => fetch(args[0], { ...args[1], signal: AbortSignal.timeout(timeout) }); - -// ../ci-sdk/dist/esm/lib/sdk/defaults/fetch.js +__name(getBackoffMs, "getBackoffMs"); +var buildFetchWithTimeout = /* @__PURE__ */ __name((fetch, timeout) => async (...args) => fetch(args[0], { + ...args[1], + signal: AbortSignal.timeout(timeout) +}), "buildFetchWithTimeout"); var defaultFetch = globalThis.fetch; - -// ../ci-sdk/dist/esm/lib/sdk/defaults/log.js var defaultLogDriver = { - error(message, error) { - console.error(message, error); + error(message, error2) { + console.error(message, error2); }, info(message) { console.log(message); @@ -27921,17 +23222,9 @@ var defaultLogDriver = { console.warn(message); } }; - -// ../ci-sdk/dist/esm/lib/sdk/defaults/serviceBase.js var defaultServiceBase = "https://app.qawolf.com/"; - -// ../ci-sdk/dist/package.json -var version2 = "0.23.0"; - -// ../ci-sdk/dist/esm/lib/sdk/defaults/userAgent.js +var version2 = "0.23.1"; var defaultUserAgent = `ci-sdk/${version2}`; - -// ../ci-sdk/dist/esm/lib/api/log.js async function logFetchError({ log, methodName, response }) { if (response.ok) return; @@ -27960,8 +23253,7 @@ async function logFetchError({ log, methodName, response }) { const statusText = response.status >= 500 ? "Server Error" : response.statusText || "Unknown Error"; log.error(`\u274C [${methodName}] ${response.status} ${statusText}${eventIdSuffix}${messageSuffix}`); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/attemptDeploy/index.js +__name(logFetchError, "logFetchError"); async function attemptNotifyDeploy(deps, apiConfig, config) { const { fetch: localFetch, log } = deps; try { @@ -27990,7 +23282,7 @@ async function attemptNotifyDeploy(deps, apiConfig, config) { return handleErrorResponse(response, log); const data = await response.json(); return handleSuccessResponse(data, log); - } catch (error) { + } catch (error2) { log.error(`\u{1F6AB} Network error from deploy_success, aborting.`); return { abortReason: "network-error", @@ -27999,6 +23291,7 @@ async function attemptNotifyDeploy(deps, apiConfig, config) { }; } } +__name(attemptNotifyDeploy, "attemptNotifyDeploy"); async function handleErrorResponse(response, log) { const status = response.status; let abortReason; @@ -28023,6 +23316,7 @@ async function handleErrorResponse(response, log) { outcome: "aborted" }; } +__name(handleErrorResponse, "handleErrorResponse"); async function handleSuccessResponse(data, log) { const { environment, results } = data; const isPreviewDeployment = environment && !environment.isStatic; @@ -28040,16 +23334,25 @@ async function handleSuccessResponse(data, log) { }; } log.error(`\u{1F6AB} No trigger matched the request. Please contact support.`); - return { failReason: "no-matched-trigger", outcome: "failed" }; + return { + failReason: "no-matched-trigger", + outcome: "failed" + }; } if (!environment) { log.error(`\u{1F6AB} No environment matched the request. Please contact support.`); - return { failReason: "no-environment", outcome: "failed" }; + return { + failReason: "no-environment", + outcome: "failed" + }; } const failedTrigger = results.find((t) => "failure_reason" in t); if (failedTrigger) { log.error(`\u{1F6AB} Run could not be created. Reason: "${failedTrigger.failure_reason}". Please contact support.`); - return { failReason: "run-could-not-be-created", outcome: "failed" }; + return { + failReason: "run-could-not-be-created", + outcome: "failed" + }; } const duplicateSuite = results.find((t) => "duplicate_suite_id" in t); if (duplicateSuite) { @@ -28063,7 +23366,10 @@ async function handleSuccessResponse(data, log) { const successfulTrigger = results.find((t) => "created_suite_id" in t); if (!successfulTrigger) { log.error(`\u{1F6AB} No trigger matched the request. Please contact support.`); - return { failReason: "no-matched-trigger", outcome: "failed" }; + return { + failReason: "no-matched-trigger", + outcome: "failed" + }; } log.info(`\u2705 Deployment notification was successful. Run created with ID: ${successfulTrigger.created_suite_id}`); return { @@ -28072,8 +23378,7 @@ async function handleSuccessResponse(data, log) { runId: successfulTrigger.created_suite_id }; } - -// ../ci-sdk/dist/esm/lib/api/generate-signed-url-for-run-inputs-executables.js +__name(handleSuccessResponse, "handleSuccessResponse"); async function callGenerateSignedUrlForRunInputsExecutablesStorage({ apiKey, serviceBase, userAgent }, { destinationFilePath }, { fetch: localFetch, log }) { try { const response = await localFetch(new URL(`${serviceBase}/api/v0/run-inputs-executables-signed-urls?file=${encodeURIComponent(destinationFilePath)}`), { @@ -28112,8 +23417,7 @@ async function callGenerateSignedUrlForRunInputsExecutablesStorage({ apiKey, ser }; } } - -// ../ci-sdk/dist/esm/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-run-inputs-executables.js +__name(callGenerateSignedUrlForRunInputsExecutablesStorage, "callGenerateSignedUrlForRunInputsExecutablesStorage"); async function generateSignedUrlForRunInputsExecutablesStorage(deps, apiConfig, config) { const { log } = deps; if (!config.destinationFilePath) { @@ -28154,8 +23458,7 @@ async function generateSignedUrlForRunInputsExecutablesStorage(deps, apiConfig, uploadUrl: responseState.signedUrl }; } - -// ../ci-sdk/dist/esm/lib/api/generate-signed-url-for-team-storage.js +__name(generateSignedUrlForRunInputsExecutablesStorage, "generateSignedUrlForRunInputsExecutablesStorage"); async function callGenerateSignedUrlForTempTeamStorage({ apiKey, serviceBase, userAgent }, { destinationFilePath }, { fetch: localFetch, log }) { try { const response = await localFetch(new URL(`${serviceBase}/api/v0/team-storage-signed-url?file=${destinationFilePath}`), { @@ -28194,8 +23497,7 @@ async function callGenerateSignedUrlForTempTeamStorage({ apiKey, serviceBase, us }; } } - -// ../ci-sdk/dist/esm/lib/sdk/domain/generateSignedUrls/generate-signed-url-for-team-storage.js +__name(callGenerateSignedUrlForTempTeamStorage, "callGenerateSignedUrlForTempTeamStorage"); async function generateSignedUrlForTempTeamStorage(deps, apiConfig, config) { const { log } = deps; if (!config.destinationFilePath) { @@ -28236,14 +23538,10 @@ async function generateSignedUrlForTempTeamStorage(deps, apiConfig, config) { uploadUrl: responseState.signedUrl }; } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/constants.js +__name(generateSignedUrlForTempTeamStorage, "generateSignedUrlForTempTeamStorage"); var qawolfBaseUrl = "https://app.qawolf.com"; var qawolfGraphQLEndpoint = `${qawolfBaseUrl}/api/graphql`; -var qawolfDeploySuccessEndpoint = `${qawolfBaseUrl}/api/webhooks/deploy_success`; var previewDeploymentType = "qawolf-preview"; - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/createEnvironmentVariables.js async function createEnvironmentVariables(deps, apiConfig, { environmentId, variables }) { const environmentVariableRequests = Object.keys(variables).map(async (key) => { const value = variables[key]; @@ -28271,8 +23569,7 @@ async function createEnvironmentVariables(deps, apiConfig, { environmentId, vari }); await Promise.all(environmentVariableRequests); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/findOrCreateEnvironment.js +__name(createEnvironmentVariables, "createEnvironmentVariables"); async function findOrCreateEnvironment(deps, apiConfig, { baseEnvironmentId, branch, pr, qaWolfTeamId }) { const retrievalResponse = await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28416,8 +23713,7 @@ async function findOrCreateEnvironment(deps, apiConfig, { baseEnvironmentId, bra throw Error("Promotion failed"); return createionResponseJson.data.createEnvironment.id; } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/findOrCreateTrigger.js +__name(findOrCreateEnvironment, "findOrCreateEnvironment"); async function findOrCreateTrigger(deps, apiConfig, args) { const { branch, environmentId, pr, qaWolfTeamId, repositoryId, tags } = args; const triggerName = `Deployments of ${pr ? `PR #${pr.number} - ${pr.title}` : `branch ${branch}`}`; @@ -28508,8 +23804,7 @@ async function findOrCreateTrigger(deps, apiConfig, args) { deps.log.info(`Trigger created with ID: ${triggerId}`); return triggerId; } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/findRepositoryIdByName.js +__name(findOrCreateTrigger, "findOrCreateTrigger"); async function findRepositoryIdByName(deps, apiConfig, { headRepoFullName }) { const response = await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28541,8 +23836,7 @@ async function findRepositoryIdByName(deps, apiConfig, { headRepoFullName }) { return; return repositories[0].id; } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/getEnvironmentVariablesFromEnvironment.js +__name(findRepositoryIdByName, "findRepositoryIdByName"); async function getEnvironmentVariablesFromEnvironment(deps, apiConfig, { environmentId }) { const retrievalResponse = await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28572,8 +23866,7 @@ async function getEnvironmentVariablesFromEnvironment(deps, apiConfig, { environ } return JSON.parse(retrievalResponseJson.data.environment.variablesJSON); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/getTagsFromEnvironment.js +__name(getEnvironmentVariablesFromEnvironment, "getEnvironmentVariablesFromEnvironment"); async function getTagsFromGenericTriggerInEnvironment(deps, apiConfig, { environmentId }) { const retrievalResponse = await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28609,9 +23902,8 @@ async function getTagsFromGenericTriggerInEnvironment(deps, apiConfig, { environ } return retrievalResponseJson.data.environment.triggers[0]?.tags?.map((tag) => tag); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/createEnvironmentAction.js -var createEnvironmentAction = async (deps, apiConfig, { baseEnvironmentId, branch, deploymentUrl, headRepoFullName, pr, qaWolfTeamId, variables }) => { +__name(getTagsFromGenericTriggerInEnvironment, "getTagsFromGenericTriggerInEnvironment"); +var createEnvironmentAction = /* @__PURE__ */ __name(async (deps, apiConfig, { baseEnvironmentId, branch, deploymentUrl, headRepoFullName, pr, qaWolfTeamId, variables }) => { deps.log.info("Creating environment for pull request..."); const environmentId = await findOrCreateEnvironment(deps, apiConfig, { baseEnvironmentId, @@ -28630,7 +23922,9 @@ var createEnvironmentAction = async (deps, apiConfig, { baseEnvironmentId, branc const combinedEnvironmentVariables = { ...baseEnvironmentVariablesJSON, ...variables, - ...deploymentUrl ? { URL: deploymentUrl } : {} + ...deploymentUrl ? { + URL: deploymentUrl + } : {} }; deps.log.info("Creating environment variables..."); await createEnvironmentVariables(deps, apiConfig, { @@ -28656,9 +23950,7 @@ var createEnvironmentAction = async (deps, apiConfig, { baseEnvironmentId, branc repositoryId, tags }); -}; - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/deleteEnvironment.js +}, "createEnvironmentAction"); async function deleteEnvironment(deps, apiConfig, { environmentId }) { await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28681,8 +23973,7 @@ async function deleteEnvironment(deps, apiConfig, { environmentId }) { }); deps.log.info(`Environment deleted with ID: ${environmentId}`); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/getEnvironmentIdForBranch.js +__name(deleteEnvironment, "deleteEnvironment"); async function getEnvironmentIdForBranch(deps, apiConfig, branch) { const response = await deps.fetch(qawolfGraphQLEndpoint, { body: JSON.stringify({ @@ -28715,16 +24006,15 @@ async function getEnvironmentIdForBranch(deps, apiConfig, branch) { throw Error(`No environment found for branch: ${branch}`); return triggers[0].environment_id; } - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/deleteEnvironmentAction.js -var deleteEnvironmentAction = async (deps, apiConfig, { branch }) => { +__name(getEnvironmentIdForBranch, "getEnvironmentIdForBranch"); +var deleteEnvironmentAction = /* @__PURE__ */ __name(async (deps, apiConfig, { branch }) => { deps.log.info("Retrieving environment ID for deletion..."); const environmentId = await getEnvironmentIdForBranch(deps, apiConfig, branch); deps.log.info(`Deleting environment with ID: ${environmentId}`); - await deleteEnvironment(deps, apiConfig, { environmentId }); -}; - -// ../ci-sdk/dist/esm/lib/sdk/domain/legacy_previewTesting/index.js + await deleteEnvironment(deps, apiConfig, { + environmentId + }); +}, "deleteEnvironmentAction"); async function testPreview(deps, apiConfig, config) { await createEnvironmentAction(deps, apiConfig, { baseEnvironmentId: config.baseEnvironmentId, @@ -28744,11 +24034,11 @@ async function testPreview(deps, apiConfig, config) { variables: config.variables }); } +__name(testPreview, "testPreview"); async function removeEnvironment(deps, apiConfig, config) { await deleteEnvironmentAction(deps, apiConfig, config); } - -// ../ci-sdk/dist/esm/lib/api/ci-greenlight.js +__name(removeEnvironment, "removeEnvironment"); async function fetchCiGreenlightStatus({ apiKey, serviceBase, userAgent }, { runId }, { fetch: localFetch, log }) { try { const resp = await localFetch(new URL(`/api/v0/ci-greenlight/${encodeURIComponent(runId)}`, serviceBase), { @@ -28801,8 +24091,7 @@ async function fetchCiGreenlightStatus({ apiKey, serviceBase, userAgent }, { run }; } } - -// ../ci-sdk/dist/esm/lib/sdk/domain/poll-ci-greenlight.js +__name(fetchCiGreenlightStatus, "fetchCiGreenlightStatus"); var safeDefaults = { abortOnSuperseded: false, maxRetries: 10, @@ -28811,7 +24100,7 @@ var safeDefaults = { runInProgressInterval: 30 * 1e3, runUnderReviewInterval: 60 * 1e3 }; -async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = () => void 0, runId, ...pollConfig }) { +async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = /* @__PURE__ */ __name(() => void 0, "onRunStageChanged"), runId, ...pollConfig }) { let retries = 0; const { log } = deps; const { abortOnSuperseded = safeDefaults.abortOnSuperseded, maxRetries = safeDefaults.maxRetries, pollTimeout = safeDefaults.pollTimeout, retryInterval = safeDefaults.retryInterval, runInProgressInterval = safeDefaults.runInProgressInterval, runUnderReviewInterval = safeDefaults.runUnderReviewInterval } = pollConfig; @@ -28847,7 +24136,7 @@ async function pollCiGreenlightStatus(deps, apiConfig, { onRunStageChanged = () else if (responseState.errorType === "server") abortReason = "5XX-server-error"; else - responseState; + ; return { abortReason, httpStatus: responseState.httpStatus, @@ -28904,13 +24193,19 @@ NON BLOCKING BUGS:${nonBlockingBugList}` : ""}`; if (greenlight) { log.info(`\u2705 Run passed and no blocking bugs found${nonBlockingBugsCount > 0 ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(nonBlockingBugsCount)} found` : ""}. ${urlInfo}`); - return { greenlightStatus, outcome: "success" }; + return { + greenlightStatus, + outcome: "success" + }; } else { log.warn(`\u274C Run failed and ${blockingBugsCount} blocking bug${pluralize(blockingBugsCount)} found${nonBlockingBugsCount ? ` and ${nonBlockingBugsCount} non-blocking bug${pluralize(nonBlockingBugsCount)}` : ""}. See ${relevantRunWithBugsUrl} You may review the priority of certain bugs to mark these non-blocking and retry the job. ` + bugsListInText); - return { greenlightStatus, outcome: "failed" }; + return { + greenlightStatus, + outcome: "failed" + }; } } if (runStage === "canceled") { @@ -28946,9 +24241,11 @@ ${urlInfo}`); outcome: "aborted" }; } - -// ../ci-sdk/dist/esm/lib/api/graphql.js -var GraphQLBadResponseError = class extends Error { +__name(pollCiGreenlightStatus, "pollCiGreenlightStatus"); +var GraphQLBadResponseError = class GraphQLBadResponseError2 extends Error { + static { + __name(this, "GraphQLBadResponseError"); + } constructor(message) { super(message); this.name = "GraphQLBadResponseError"; @@ -28969,6 +24266,7 @@ function mapErrorCodeToAbortReason({ errorCode, log }) { return "server-error"; } } +__name(mapErrorCodeToAbortReason, "mapErrorCodeToAbortReason"); async function qawolfGraphql({ apiConfig: { apiKey, serviceBase, userAgent }, deps: { fetch: localFetch, log }, name, query: queryGql, variables }) { try { const response = await localFetch(new URL(`/api/graphql`, serviceBase), { @@ -28990,13 +24288,16 @@ async function qawolfGraphql({ apiConfig: { apiKey, serviceBase, userAgent }, de throw new GraphQLBadResponseError(`[GraphQL] Unexpected response schema. Not valid JSON body.`); } if ("errors" in rawBody) { - for (const error of rawBody.errors) - log.warn(`\u274C [GraphQL] error: ${error.message}`); + for (const error2 of rawBody.errors) + log.warn(`\u274C [GraphQL] error: ${error2.message}`); const firstError = rawBody.errors[0]; const eventId = firstError?.extensions?.eventId; const errorCode = firstError?.extensions?.code; return { - abortReason: mapErrorCodeToAbortReason({ errorCode, log }), + abortReason: mapErrorCodeToAbortReason({ + errorCode, + log + }), eventId, isGqlError: true }; @@ -29021,6 +24322,7 @@ async function qawolfGraphql({ apiConfig: { apiKey, serviceBase, userAgent }, de }; } } +__name(qawolfGraphql, "qawolfGraphql"); function logGraphQLError({ log, methodName, payload }) { const eventIdSuffix = payload.eventId ? ` (Event ID: ${payload.eventId})` : ""; switch (payload.abortReason) { @@ -29044,8 +24346,7 @@ function logGraphQLError({ log, methodName, payload }) { log.error(`\u274C [${methodName}] Unknown error. ${payload.abortReason} This is a bug${eventIdSuffix}`); } } - -// ../ci-sdk/dist/esm/lib/api/notify-vcs-branch-merge-canceled-mutation.js +__name(logGraphQLError, "logGraphQLError"); var mutationName = "notifyVCSBranchMergeCanceled"; var mutationGql = ` mutation NotifyVCSBranchMergeCanceled($headEnvironmentAlias: String!) { @@ -29064,11 +24365,9 @@ async function callNotifyVCSBranchMergeCanceledMutation(deps, apiConfig, { headE variables: { headEnvironmentAlias } - // The type coercion highlights that we don't have runtime schema validation }); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/lib/domain-failure.js +__name(callNotifyVCSBranchMergeCanceledMutation, "callNotifyVCSBranchMergeCanceledMutation"); function domainFailureToAbortResult({ log, methodName, result }) { switch (result.failureCode) { case "base-environment-not-found": @@ -29124,8 +24423,7 @@ function domainFailureToAbortResult({ log, methodName, result }) { throw Error(`[${methodName}] Unreachable code detected. This is a bug. ${result.failureCode}`); } } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/lib/retry.js +__name(domainFailureToAbortResult, "domainFailureToAbortResult"); async function retryWithExponentialBackoff({ log, maxRetries, methodName, retriableAbortReasons, runOnce }) { let attemptNumber = 0; let result; @@ -29143,8 +24441,7 @@ async function retryWithExponentialBackoff({ log, maxRetries, methodName, retria await sleep(backoffMs); } while (true); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/notify-vcs-branch-merge-canceled.js +__name(retryWithExponentialBackoff, "retryWithExponentialBackoff"); async function runNotifyVCSMergeCanceledOnce(deps, apiConfig, input) { const log = deps.log; const { headEnvironmentAlias } = input; @@ -29177,6 +24474,7 @@ async function runNotifyVCSMergeCanceledOnce(deps, apiConfig, input) { result }); } +__name(runNotifyVCSMergeCanceledOnce, "runNotifyVCSMergeCanceledOnce"); async function notifyVCSBranchMergeCanceled(deps, apiConfig, input) { const { maxRetries = 10 } = input; return retryWithExponentialBackoff({ @@ -29187,11 +24485,10 @@ async function notifyVCSBranchMergeCanceled(deps, apiConfig, input) { "network-error", "server-error" ], - runOnce: () => runNotifyVCSMergeCanceledOnce(deps, apiConfig, input) + runOnce: /* @__PURE__ */ __name(() => runNotifyVCSMergeCanceledOnce(deps, apiConfig, input), "runOnce") }); } - -// ../ci-sdk/dist/esm/lib/api/notify-vcs-branch-merge-completed-mutation.js +__name(notifyVCSBranchMergeCanceled, "notifyVCSBranchMergeCanceled"); var mutationName2 = "notifyVCSBranchMergeCompleted"; var mutationGql2 = ` mutation NotifyVCSBranchMergeCompleted($baseEnvironmentAlias: String, $headEnvironmentAlias: String!) { @@ -29211,11 +24508,9 @@ async function callNotifyVCSBranchMergeCompletedMutation(deps, apiConfig, { base baseEnvironmentAlias: baseEnvironmentAlias ?? null, headEnvironmentAlias } - // The type coercion highlights that we don't have runtime schema validation }); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/notify-vcs-branch-merge-completed.js +__name(callNotifyVCSBranchMergeCompletedMutation, "callNotifyVCSBranchMergeCompletedMutation"); async function runNotifyVCSBranchMergeCompletedOnce(deps, apiConfig, input) { const log = deps.log; const { baseEnvironmentsMapping, baseVcsBranch: vcsBaseBranch } = input; @@ -29253,6 +24548,7 @@ async function runNotifyVCSBranchMergeCompletedOnce(deps, apiConfig, input) { result }); } +__name(runNotifyVCSBranchMergeCompletedOnce, "runNotifyVCSBranchMergeCompletedOnce"); async function notifyVCSBranchMergeCompleted(deps, apiConfig, input) { const { maxRetries = 10 } = input; return retryWithExponentialBackoff({ @@ -29263,11 +24559,10 @@ async function notifyVCSBranchMergeCompleted(deps, apiConfig, input) { "network-error", "server-error" ], - runOnce: () => runNotifyVCSBranchMergeCompletedOnce(deps, apiConfig, input) + runOnce: /* @__PURE__ */ __name(() => runNotifyVCSBranchMergeCompletedOnce(deps, apiConfig, input), "runOnce") }); } - -// ../ci-sdk/dist/esm/lib/api/notify-vcs-branch-build-deployed-mutation.js +__name(notifyVCSBranchMergeCompleted, "notifyVCSBranchMergeCompleted"); var mutationName3 = "notifyVCSBranchBuildDeployed"; var mutationGql3 = ` mutation NotifyVCSBranchBuildDeployed( @@ -29319,11 +24614,9 @@ async function callNotifyVCSBranchBuildDeployedMutation(deps, apiConfig, { baseE headVcsCommitUrl: headVcsCommitUrl ?? null, pullOrMergeRequestNumber: pullOrMergeRequestNumber ?? null } - // The type coercion highlights that we don't have runtime schema validation }); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/notifyVCSBranchBuildDeployed/index.js +__name(callNotifyVCSBranchBuildDeployedMutation, "callNotifyVCSBranchBuildDeployedMutation"); async function runNotifyVCSBranchBuildDeployedOnce(deps, apiConfig, input) { const { baseEnvironmentsMapping, baseVcsBranch, concurrencyLimit, headEnvironmentAlias, headEnvironmentName, headEnvironmentVariables, headVcsBranch, headVcsCommitId, headVcsCommitUrl, pullOrMergeRequestNumber } = input; const log = deps.log; @@ -29388,6 +24681,7 @@ async function runNotifyVCSBranchBuildDeployedOnce(deps, apiConfig, input) { result }); } +__name(runNotifyVCSBranchBuildDeployedOnce, "runNotifyVCSBranchBuildDeployedOnce"); async function notifyVCSBranchBuildDeployed(deps, apiConfig, input) { const { maxRetries = 10 } = input; return retryWithExponentialBackoff({ @@ -29399,189 +24693,72 @@ async function notifyVCSBranchBuildDeployed(deps, apiConfig, input) { "server-error", "run-creation-failed" ], - runOnce: () => runNotifyVCSBranchBuildDeployedOnce(deps, apiConfig, input) + runOnce: /* @__PURE__ */ __name(() => runNotifyVCSBranchBuildDeployedOnce(deps, apiConfig, input), "runOnce") }); } - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/lib/aliases.js -var import_slugify = __toESM(require_slugify(), 1); - -// ../ci-sdk/dist/esm/lib/sdk/domain/vcsBranchTesting/index.js -function makeVCSBranchTestingSDK({ apiKey, serviceBase = defaultServiceBase, userAgent = defaultUserAgent }, { fetch = defaultFetch, log = defaultLogDriver } = {}) { - const deps = { fetch, log }; - const apiConfig = { apiKey, serviceBase, userAgent }; - return { - notifyVCSBranchBuildDeployed: notifyVCSBranchBuildDeployed.bind(null, deps, apiConfig), - notifyVCSBranchMergeCanceled: notifyVCSBranchMergeCanceled.bind(null, deps, apiConfig), - notifyVCSBranchMergeCompleted: notifyVCSBranchMergeCompleted.bind(null, deps, apiConfig) - }; -} - -// ../ci-sdk/dist/esm/lib/sdk/index.js -function makeQaWolfSdk({ apiKey, serviceBase = defaultServiceBase, userAgent = defaultUserAgent }, { fetch = defaultFetch, log = defaultLogDriver } = {}) { - if (typeof fetch !== "function") { - throw Error(`QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function. -We recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`); - } - const deps = { - // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here. - fetch: buildFetchWithTimeout(fetch, 6e4), - log - }; - const apiConfig = { apiKey, serviceBase, userAgent }; - return { - attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig), - /** - * @deprecated Use `experimental_vcsBranchTesting` instead. - */ - experimental_removeEnvironment: removeEnvironment.bind(null, deps, apiConfig), - /** - * @deprecated Use `experimental_vcsBranchTesting` instead. - */ - experimental_testPreview: testPreview.bind(null, deps, apiConfig), - experimental_vcsBranchTesting: makeVCSBranchTestingSDK(apiConfig, deps), - generateSignedUrlForRunInputsExecutablesStorage: generateSignedUrlForRunInputsExecutablesStorage.bind(null, deps, apiConfig), - generateSignedUrlForTempTeamStorage: generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig), - pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig) - }; +__name(notifyVCSBranchBuildDeployed, "notifyVCSBranchBuildDeployed"); +function pullRequestDetailsToEnvironmentAlias({ codeHostingServiceOrganization, codeHostingServiceRepositoryName, pullRequestIdentifier }) { + return arbitraryStringToEnvironmentAlias(`${codeHostingServiceOrganization}-${codeHostingServiceRepositoryName}-pr-${pullRequestIdentifier}`); } - -// src/index.ts -var import_ci_utils2 = __toESM(require_dist()); - -// package.json -var version3 = "v1.1.0"; - -// src/extractRelevantDataFromEvent/index.ts -var core = __toESM(require_core()); -var github = __toESM(require_github()); -var extractRelevantDataFromEvent = async (context3) => { - try { - switch (context3.eventName) { - case "deployment_status": - return extractRelevantDataFromDeployment(context3); - case "merge_group": - return extractRelevantDataFromMergeGroup(context3); - case "pull_request": - case "pull_request_target": - return extractRelevantDataFromPullRequest(context3); - case "push": - return extractRelevantDataFromPush(context3); - default: { - return { - branch: context3.ref?.replace("refs/heads/", ""), - sha: context3.sha - }; - } - } - } catch (error) { - core.debug(`Failed to extract event data: ${error}`); - return void 0; - } -}; -var extractRelevantDataFromPullRequest = async (context3) => { - const event = context3.payload; - return { - branch: event.pull_request.head.ref, - commitUrl: `https://github.com/${event.repository.full_name}/commit/${event.pull_request.head.sha}`, - pullRequestNumber: event.pull_request.number, - sha: event.pull_request.head.sha +__name(pullRequestDetailsToEnvironmentAlias, "pullRequestDetailsToEnvironmentAlias"); +function arbitraryStringToEnvironmentAlias(arbitraryString) { + return (0, import_slugify.default)(arbitraryString, { + lower: true + }); +} +__name(arbitraryStringToEnvironmentAlias, "arbitraryStringToEnvironmentAlias"); +function makeVCSBranchTestingSDK({ apiKey, serviceBase = defaultServiceBase, userAgent = defaultUserAgent }, { fetch = defaultFetch, log = defaultLogDriver } = {}) { + const deps = { + fetch, + log }; -}; -var extractRelevantDataFromPush = async (context3) => { - const push = context3.payload; - const pullRequestData = await fetchPullRequestData(push.after); - return { - ...typeof pullRequestData === "object" ? pullRequestData : {}, - branch: context3.ref.replace("refs/heads/", ""), - commitUrl: push.head_commit?.url, - sha: push.after + const apiConfig = { + apiKey, + serviceBase, + userAgent }; -}; -var extractRelevantDataFromMergeGroup = async (context3) => { - const mergeGroup = context3.payload; - const pullRequestData = await fetchPullRequestData( - mergeGroup.merge_group.base_sha - ); - if (typeof pullRequestData === "string") { - core.info( - `Unable to get pull request info from deployment: ${pullRequestData}` - ); - } return { - ...typeof pullRequestData === "object" ? pullRequestData : {}, - // Use the merge group's base branch/SHA - // instead of merge queue's temporary values (head_ref/head_sha) - // This ensures we track the actual PR target branch being merged - branch: mergeGroup.merge_group.base_ref.replace("refs/heads/", ""), - sha: mergeGroup.merge_group.base_sha + notifyVCSBranchBuildDeployed: notifyVCSBranchBuildDeployed.bind(null, deps, apiConfig), + notifyVCSBranchMergeCanceled: notifyVCSBranchMergeCanceled.bind(null, deps, apiConfig), + notifyVCSBranchMergeCompleted: notifyVCSBranchMergeCompleted.bind(null, deps, apiConfig) }; -}; -var extractRelevantDataFromDeployment = async (context3) => { - const event = context3.payload; - const pullRequestData = await fetchPullRequestData(event.deployment.sha); - if (typeof pullRequestData === "string") { - core.info( - `Unable to get pull request info from deployment: ${pullRequestData}` - ); +} +__name(makeVCSBranchTestingSDK, "makeVCSBranchTestingSDK"); +function makeQaWolfSdk({ apiKey, serviceBase = defaultServiceBase, userAgent = defaultUserAgent }, { fetch = defaultFetch, log = defaultLogDriver } = {}) { + if (typeof fetch !== "function") { + throw Error(`QA Wolf CI-SDK requires fetch to be defined. Make sure you are using NodeJS 18+, OR pass a fetch polyfill to the makeQaWolfSdk function. +We recommend 'undici' package for that purpose. See the Requirement section of our README for more guidance.`); } + const deps = { + // Versions of fetch may have different default timeouts. For consistency, we explicitly set it to 60 seconds here. + fetch: buildFetchWithTimeout(fetch, 6e4), + log + }; + const apiConfig = { + apiKey, + serviceBase, + userAgent + }; return { - ...typeof pullRequestData === "object" ? pullRequestData : {}, - commitUrl: `https://github.com/${event.repository.full_name}/commit/${event.deployment.sha}`, - sha: event.deployment.sha + attemptNotifyDeploy: attemptNotifyDeploy.bind(null, deps, apiConfig), + /** + * @deprecated Use `experimental_vcsBranchTesting` instead. + */ + experimental_removeEnvironment: removeEnvironment.bind(null, deps, apiConfig), + /** + * @deprecated Use `experimental_vcsBranchTesting` instead. + */ + experimental_testPreview: testPreview.bind(null, deps, apiConfig), + experimental_vcsBranchTesting: makeVCSBranchTestingSDK(apiConfig, deps), + generateSignedUrlForRunInputsExecutablesStorage: generateSignedUrlForRunInputsExecutablesStorage.bind(null, deps, apiConfig), + generateSignedUrlForTempTeamStorage: generateSignedUrlForTempTeamStorage.bind(null, deps, apiConfig), + pollCiGreenlightStatus: pollCiGreenlightStatus.bind(null, deps, apiConfig) }; -}; -async function fetchPullRequestData(sha) { - if (!process.env.GITHUB_TOKEN) - return "missing-github-token"; - const { context: context3 } = github; - const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - try { - const { data: searchData } = await octokit.rest.search.issuesAndPullRequests({ - q: `repo:${context3.repo.owner}/${context3.repo.repo} is:pr ${sha} sort:updated-desc` - }); - const sortedOpenPullRequests = searchData.items.filter( - (item) => item.pull_request && item.state === "open" - ); - if (!sortedOpenPullRequests.length) - return "no-pull-request"; - const pullRequestDetails = await Promise.all( - sortedOpenPullRequests.map( - (pr) => octokit.rest.pulls.get({ - owner: context3.repo.owner, - pull_number: pr.number, - repo: context3.repo.repo - }).then((response) => response.data) - ) - ); - const exactMatch = pullRequestDetails.find((pr) => pr.head.sha === sha); - if (exactMatch) { - core.info(`Found exact SHA = ${sha} match in PR #${exactMatch.number}`); - return { - branch: exactMatch.head.ref, - pullRequestNumber: exactMatch.number - }; - } - const mostRecent = pullRequestDetails[0]; - if (!mostRecent) - return "no-pull-request"; - core.info( - `No PR found with head SHA = ${sha}. Using most recent PR #${mostRecent.number} containing SHA = ${sha}` - ); - return { - branch: mostRecent.head.ref, - pullRequestNumber: mostRecent.number - }; - } catch (error) { - core.info(`Failed to fetch pull request data: ${error}`); - return "fail-to-fetch-pull-request-data"; - } } +__name(makeQaWolfSdk, "makeQaWolfSdk"); -// src/validateInput.ts -var core2 = __toESM(require_core()); -var github2 = __toESM(require_github()); -var import_ci_utils = __toESM(require_dist()); +// ../ci-utils/dist/index.mjs +var import_core = __toESM(require_core(), 1); // ../../node_modules/zod/lib/index.mjs var util; @@ -29764,8 +24941,8 @@ var ZodError = class _ZodError extends Error { return issue.message; }; const fieldErrors = { _errors: [] }; - const processError = (error) => { - for (const issue of error.issues) { + const processError = (error2) => { + for (const issue of error2.issues) { if (issue.code === "invalid_union") { issue.unionErrors.map(processError); } else if (issue.code === "invalid_return_type") { @@ -29827,8 +25004,8 @@ var ZodError = class _ZodError extends Error { } }; ZodError.create = (issues) => { - const error = new ZodError(issues); - return error; + const error2 = new ZodError(issues); + return error2; }; var errorMap = (issue, _ctx) => { let message; @@ -30040,14 +25217,14 @@ var isAborted = (x) => x.status === "aborted"; var isDirty = (x) => x.status === "dirty"; var isValid = (x) => x.status === "valid"; var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise; -function __classPrivateFieldGet2(receiver, state, kind, f) { +function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } -function __classPrivateFieldSet2(receiver, state, value, kind, f) { +function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) @@ -30094,8 +25271,8 @@ var handleResult = (ctx, result) => { get error() { if (this._error) return this._error; - const error = new ZodError(ctx.common.issues); - this._error = error; + const error2 = new ZodError(ctx.common.issues); + this._error = error2; return this._error; } }; @@ -32624,7 +27801,7 @@ var ZodFunction = class _ZodFunction extends ZodType { }); return INVALID; } - function makeArgsIssue(args, error) { + function makeArgsIssue(args, error2) { return makeIssue({ data: args, path: ctx.path, @@ -32636,11 +27813,11 @@ var ZodFunction = class _ZodFunction extends ZodType { ].filter((x) => !!x), issueData: { code: ZodIssueCode.invalid_arguments, - argumentsError: error + argumentsError: error2 } }); } - function makeReturnsIssue(returns, error) { + function makeReturnsIssue(returns, error2) { return makeIssue({ data: returns, path: ctx.path, @@ -32652,7 +27829,7 @@ var ZodFunction = class _ZodFunction extends ZodType { ].filter((x) => !!x), issueData: { code: ZodIssueCode.invalid_return_type, - returnTypeError: error + returnTypeError: error2 } }); } @@ -32661,15 +27838,15 @@ var ZodFunction = class _ZodFunction extends ZodType { if (this._def.returns instanceof ZodPromise) { const me = this; return OK(async function(...args) { - const error = new ZodError([]); + const error2 = new ZodError([]); const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => { - error.addIssue(makeArgsIssue(args, e)); - throw error; + error2.addIssue(makeArgsIssue(args, e)); + throw error2; }); const result = await Reflect.apply(fn, this, parsedArgs); const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => { - error.addIssue(makeReturnsIssue(result, e)); - throw error; + error2.addIssue(makeReturnsIssue(result, e)); + throw error2; }); return parsedReturns; }); @@ -32788,10 +27965,10 @@ var ZodEnum = class _ZodEnum extends ZodType { }); return INVALID; } - if (!__classPrivateFieldGet2(this, _ZodEnum_cache, "f")) { - __classPrivateFieldSet2(this, _ZodEnum_cache, new Set(this._def.values), "f"); + if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) { + __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f"); } - if (!__classPrivateFieldGet2(this, _ZodEnum_cache, "f").has(input.data)) { + if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) { const ctx = this._getOrReturnCtx(input); const expectedValues = this._def.values; addIssueToContext(ctx, { @@ -32859,10 +28036,10 @@ var ZodNativeEnum = class extends ZodType { }); return INVALID; } - if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache, "f")) { - __classPrivateFieldSet2(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f"); + if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) { + __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f"); } - if (!__classPrivateFieldGet2(this, _ZodNativeEnum_cache, "f").has(input.data)) { + if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) { const expectedValues = util.objectValues(nativeEnumValues); addIssueToContext(ctx, { received: ctx.data, @@ -33503,6 +28680,202 @@ var z = /* @__PURE__ */ Object.freeze({ ZodError }); +// ../ci-utils/dist/index.mjs +var __defProp3 = Object.defineProperty; +var __name2 = (target, value) => __defProp3(target, "name", { value, configurable: true }); +function stringifyUnknown(value) { + if (value === null || value === void 0) + return ""; + if (typeof value === "string") + return value; + if (value instanceof Error) { + if ("message" in value && typeof value.message === "string") + return value.message; + return value.toString(); + } + try { + const stringified = JSON.stringify(value); + return !stringified ? "" : stringified; + } catch { + return ""; + } +} +__name2(stringifyUnknown, "stringifyUnknown"); +var coreLogDriver = { + error(message, error$1) { + (0, import_core.error)(message + (error$1 ? ` +${stringifyUnknown(error$1)}` : "")); + }, + info: import_core.info, + warn: import_core.warning +}; +var environmentVariablesSchema = z.record(z.string(), z.string()); +var jsonEnvironmentVariablesSchema = z.string().transform((str, ctx) => { + try { + return JSON.parse(str); + } catch (error2) { + ctx.addIssue({ + code: "custom", + message: "input is not a valid JSON-formatted string" + }); + return; + } +}).pipe(environmentVariablesSchema); +var environmentsMappingSchema = z.array(z.object({ + environmentAlias: z.string(), + vcsBranch: z.string() +})); +var jsonEnvironmentsMappingSchema = z.string().transform((str, ctx) => { + try { + return JSON.parse(str); + } catch (error2) { + ctx.addIssue({ + code: "custom", + message: "input is not a valid JSON-formatted string" + }); + return; + } +}).pipe(environmentsMappingSchema); + +// package.json +var version3 = "v1.1.1"; + +// src/extractRelevantDataFromEvent/index.ts +var core = __toESM(require_core()); +var github = __toESM(require_github()); +var extractRelevantDataFromEvent = async (context3) => { + try { + switch (context3.eventName) { + case "deployment_status": + return extractRelevantDataFromDeployment(context3); + case "merge_group": + return extractRelevantDataFromMergeGroup(context3); + case "pull_request": + case "pull_request_target": + return extractRelevantDataFromPullRequest(context3); + case "push": + return extractRelevantDataFromPush(context3); + default: { + return { + branch: context3.ref?.replace("refs/heads/", ""), + sha: context3.sha + }; + } + } + } catch (error2) { + core.debug(`Failed to extract event data: ${error2}`); + return void 0; + } +}; +var extractRelevantDataFromPullRequest = async (context3) => { + const event = context3.payload; + return { + branch: event.pull_request.head.ref, + commitUrl: `https://github.com/${event.repository.full_name}/commit/${event.pull_request.head.sha}`, + pullRequestNumber: event.pull_request.number, + sha: event.pull_request.head.sha + }; +}; +var extractRelevantDataFromPush = async (context3) => { + const push = context3.payload; + const pullRequestData = await fetchPullRequestData(push.after); + return { + ...typeof pullRequestData === "object" ? pullRequestData : {}, + branch: context3.ref.replace("refs/heads/", ""), + commitUrl: push.head_commit?.url, + sha: push.after + }; +}; +var extractRelevantDataFromMergeGroup = async (context3) => { + const mergeGroup = context3.payload; + const pullRequestData = await fetchPullRequestData( + mergeGroup.merge_group.base_sha + ); + if (typeof pullRequestData === "string") { + core.info( + `Unable to get pull request info from deployment: ${pullRequestData}` + ); + } + return { + ...typeof pullRequestData === "object" ? pullRequestData : {}, + // Use the merge group's base branch/SHA + // instead of merge queue's temporary values (head_ref/head_sha) + // This ensures we track the actual PR target branch being merged + branch: mergeGroup.merge_group.base_ref.replace("refs/heads/", ""), + sha: mergeGroup.merge_group.base_sha + }; +}; +var extractRelevantDataFromDeployment = async (context3) => { + const event = context3.payload; + const pullRequestData = await fetchPullRequestData(event.deployment.sha); + if (typeof pullRequestData === "string") { + core.info( + `Unable to get pull request info from deployment: ${pullRequestData}` + ); + } + return { + ...typeof pullRequestData === "object" ? pullRequestData : {}, + commitUrl: `https://github.com/${event.repository.full_name}/commit/${event.deployment.sha}`, + sha: event.deployment.sha + }; +}; +async function fetchPullRequestData(sha) { + if (!process.env.GITHUB_TOKEN) { + core.info("GITHUB_TOKEN is missing, skipping pull request data extraction"); + return "missing-github-token"; + } + const { context: context3 } = github; + const octokit = github.getOctokit(process.env.GITHUB_TOKEN); + try { + const { data: searchData } = await octokit.rest.search.issuesAndPullRequests({ + q: `repo:${context3.repo.owner}/${context3.repo.repo} is:pr ${sha} sort:updated-desc` + }); + const sortedOpenPullRequests = searchData.items.filter( + (item) => item.pull_request && item.state === "open" + ); + if (!sortedOpenPullRequests.length) { + core.info( + `No open pull requests found for sha = ${sha}. This is only an issue if you're running this action on a PR.` + ); + return "no-pull-request"; + } + const pullRequestDetails = await Promise.all( + sortedOpenPullRequests.map( + (pr) => octokit.rest.pulls.get({ + owner: context3.repo.owner, + pull_number: pr.number, + repo: context3.repo.repo + }).then((response) => response.data) + ) + ); + const exactMatch = pullRequestDetails.find((pr) => pr.head.sha === sha); + if (exactMatch) { + core.info(`Found exact SHA = ${sha} match in PR #${exactMatch.number}`); + return { + branch: exactMatch.head.ref, + pullRequestNumber: exactMatch.number + }; + } + const mostRecent = pullRequestDetails[0]; + if (!mostRecent) + return "no-pull-request"; + core.info( + `No PR found with head SHA = ${sha}. Using most recent PR #${mostRecent.number} containing SHA = ${sha}` + ); + return { + branch: mostRecent.head.ref, + pullRequestNumber: mostRecent.number + }; + } catch (error2) { + core.info(`Failed to fetch pull request data: ${error2}`); + return "fail-to-fetch-pull-request-data"; + } +} + +// src/validateInput.ts +var core2 = __toESM(require_core()); +var github2 = __toESM(require_github()); + // src/types.ts var urlSchema = z.string().url(); @@ -33563,7 +28936,7 @@ function validateInput(relevantEventData) { validatedDeploymentUrl = result.data; } if (environmentVariablesInput) { - const result = import_ci_utils.jsonEnvironmentVariablesSchema.safeParse( + const result = jsonEnvironmentVariablesSchema.safeParse( environmentVariablesInput ); if (!result.success) { @@ -33618,7 +28991,7 @@ async function runGitHubAction() { }, { // Replace default log driver with core logging. - log: import_ci_utils2.coreLogDriver + log: coreLogDriver } ); core3.info("Attempting to notify QA Wolf of deployment."); @@ -33639,9 +29012,9 @@ async function runGitHubAction() { core3.setOutput("environment-id", environmentId); core3.setOutput("run-id", runId); } -runGitHubAction().catch((error) => { +runGitHubAction().catch((error2) => { core3.setFailed( - `Action failed with reason: ${(0, import_ci_utils2.stringifyUnknown)(error) ?? "Unknown error"}` + `Action failed with reason: ${stringifyUnknown(error2) ?? "Unknown error"}` ); }); /*! Bundled license information: diff --git a/package.json b/package.json index e40622d..ebd9b52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qawolf/notify-qawolf-on-deploy-action", - "version": "v1.1.0", + "version": "v1.1.1", "type": "commonjs", "main": "dist/index.js", "engines": { diff --git a/src/extractRelevantDataFromEvent/index.ts b/src/extractRelevantDataFromEvent/index.ts index b025f55..10fb6cb 100644 --- a/src/extractRelevantDataFromEvent/index.ts +++ b/src/extractRelevantDataFromEvent/index.ts @@ -114,7 +114,10 @@ async function fetchPullRequestData( | "fail-to-fetch-pull-request-data" | "missing-github-token" > { - if (!process.env.GITHUB_TOKEN) return "missing-github-token"; + if (!process.env.GITHUB_TOKEN) { + core.info("GITHUB_TOKEN is missing, skipping pull request data extraction"); + return "missing-github-token"; + } const { context } = github; const octokit = github.getOctokit(process.env.GITHUB_TOKEN); @@ -130,7 +133,12 @@ async function fetchPullRequestData( (item) => item.pull_request && item.state === "open", ); - if (!sortedOpenPullRequests.length) return "no-pull-request"; + if (!sortedOpenPullRequests.length) { + core.info( + `No open pull requests found for sha = ${sha}. This is only an issue if you're running this action on a PR.`, + ); + return "no-pull-request"; + } // Fetch all PR details in parallel const pullRequestDetails = await Promise.all(