UNPKG

cdk-drizzle-migrate

Version:

AWS CDK construct for running Drizzle ORM migrations

1,386 lines (1,346 loc) 2.86 MB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except3, desc2) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except3) __defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // node_modules/@aws-sdk/core/dist-es/submodules/client/emitWarningIfUnsupportedVersion.js var state, emitWarningIfUnsupportedVersion; var init_emitWarningIfUnsupportedVersion = __esm({ "node_modules/@aws-sdk/core/dist-es/submodules/client/emitWarningIfUnsupportedVersion.js"() { state = { warningEmitted: false }; emitWarningIfUnsupportedVersion = (version2) => { if (version2 && !state.warningEmitted) { if (process.env.AWS_SDK_JS_NODE_VERSION_SUPPORT_WARNING_DISABLED === "true") { state.warningEmitted = true; return; } const userMajorVersion = parseInt(version2.substring(1, version2.indexOf("."))); const vv = 22; if (userMajorVersion < vv) { state.warningEmitted = true; process.emitWarning(`NodeVersionSupportWarning: The AWS SDK for JavaScript (v3) versions published after the first week of January 2027 will require node >=${vv}. You are running node ${version2}. To continue receiving updates to AWS services, bug fixes, and security updates please upgrade to node >=${vv}. More information can be found at: https://a.co/c895JFp`); } } }; } }); // node_modules/@aws-sdk/core/dist-es/submodules/client/longPollMiddleware.js var longPollMiddleware, longPollMiddlewareOptions, getLongPollPlugin; var init_longPollMiddleware = __esm({ "node_modules/@aws-sdk/core/dist-es/submodules/client/longPollMiddleware.js"() { longPollMiddleware = () => (next, context) => async (args) => { context.__retryLongPoll = true; return next(args); }; longPollMiddlewareOptions = { name: "longPollMiddleware", tags: ["RETRY"], step: "initialize", override: true }; getLongPollPlugin = (options) => ({ applyToStack: (clientStack) => { clientStack.add(longPollMiddleware(), longPollMiddlewareOptions); } }); } }); // node_modules/@aws-sdk/core/dist-es/submodules/client/setCredentialFeature.js function setCredentialFeature(credentials, feature, value) { if (!credentials.$source) { credentials.$source = {}; } credentials.$source[feature] = value; return credentials; } var init_setCredentialFeature = __esm({ "node_modules/@aws-sdk/core/dist-es/submodules/client/setCredentialFeature.js"() { } }); // node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/isStreamingPayload/isStreamingPayload.js var import_node_stream, isStreamingPayload; var init_isStreamingPayload = __esm({ "node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/isStreamingPayload/isStreamingPayload.js"() { import_node_stream = require("node:stream"); isStreamingPayload = (request) => request?.body instanceof import_node_stream.Readable || typeof ReadableStream !== "undefined" && request?.body instanceof ReadableStream; } }); // node_modules/@smithy/core/dist-es/submodules/client/middleware-stack/MiddlewareStack.js var getAllAliases, getMiddlewareNameWithAliases, constructStack, stepWeights, priorityWeights; var init_MiddlewareStack = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/middleware-stack/MiddlewareStack.js"() { getAllAliases = (name, aliases) => { const _aliases = []; if (name) { _aliases.push(name); } if (aliases) { for (const alias of aliases) { _aliases.push(alias); } } return _aliases; }; getMiddlewareNameWithAliases = (name, aliases) => { return `${name || "anonymous"}${aliases && aliases.length > 0 ? ` (a.k.a. ${aliases.join(",")})` : ""}`; }; constructStack = () => { let absoluteEntries = []; let relativeEntries = []; let identifyOnResolve = false; const entriesNameSet = /* @__PURE__ */ new Set(); const sort = (entries) => entries.sort((a5, b6) => stepWeights[b6.step] - stepWeights[a5.step] || priorityWeights[b6.priority || "normal"] - priorityWeights[a5.priority || "normal"]); const removeByName = (toRemove) => { let isRemoved = false; const filterCb = (entry) => { const aliases = getAllAliases(entry.name, entry.aliases); if (aliases.includes(toRemove)) { isRemoved = true; for (const alias of aliases) { entriesNameSet.delete(alias); } return false; } return true; }; absoluteEntries = absoluteEntries.filter(filterCb); relativeEntries = relativeEntries.filter(filterCb); return isRemoved; }; const removeByReference = (toRemove) => { let isRemoved = false; const filterCb = (entry) => { if (entry.middleware === toRemove) { isRemoved = true; for (const alias of getAllAliases(entry.name, entry.aliases)) { entriesNameSet.delete(alias); } return false; } return true; }; absoluteEntries = absoluteEntries.filter(filterCb); relativeEntries = relativeEntries.filter(filterCb); return isRemoved; }; const cloneTo = (toStack) => { absoluteEntries.forEach((entry) => { toStack.add(entry.middleware, { ...entry }); }); relativeEntries.forEach((entry) => { toStack.addRelativeTo(entry.middleware, { ...entry }); }); toStack.identifyOnResolve?.(stack.identifyOnResolve()); return toStack; }; const expandRelativeMiddlewareList = (from) => { const expandedMiddlewareList = []; from.before.forEach((entry) => { if (entry.before.length === 0 && entry.after.length === 0) { expandedMiddlewareList.push(entry); } else { expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry)); } }); expandedMiddlewareList.push(from); from.after.reverse().forEach((entry) => { if (entry.before.length === 0 && entry.after.length === 0) { expandedMiddlewareList.push(entry); } else { expandedMiddlewareList.push(...expandRelativeMiddlewareList(entry)); } }); return expandedMiddlewareList; }; const getMiddlewareList = (debug = false) => { const normalizedAbsoluteEntries = []; const normalizedRelativeEntries = []; const normalizedEntriesNameMap = {}; absoluteEntries.forEach((entry) => { const normalizedEntry = { ...entry, before: [], after: [] }; for (const alias of getAllAliases(normalizedEntry.name, normalizedEntry.aliases)) { normalizedEntriesNameMap[alias] = normalizedEntry; } normalizedAbsoluteEntries.push(normalizedEntry); }); relativeEntries.forEach((entry) => { const normalizedEntry = { ...entry, before: [], after: [] }; for (const alias of getAllAliases(normalizedEntry.name, normalizedEntry.aliases)) { normalizedEntriesNameMap[alias] = normalizedEntry; } normalizedRelativeEntries.push(normalizedEntry); }); normalizedRelativeEntries.forEach((entry) => { if (entry.toMiddleware) { const toMiddleware = normalizedEntriesNameMap[entry.toMiddleware]; if (toMiddleware === void 0) { if (debug) { return; } throw new Error(`${entry.toMiddleware} is not found when adding ${getMiddlewareNameWithAliases(entry.name, entry.aliases)} middleware ${entry.relation} ${entry.toMiddleware}`); } if (entry.relation === "after") { toMiddleware.after.push(entry); } if (entry.relation === "before") { toMiddleware.before.push(entry); } } }); const mainChain = sort(normalizedAbsoluteEntries).map(expandRelativeMiddlewareList).reduce((wholeList, expandedMiddlewareList) => { wholeList.push(...expandedMiddlewareList); return wholeList; }, []); return mainChain; }; const stack = { add: (middleware, options = {}) => { const { name, override, aliases: _aliases } = options; const entry = { step: "initialize", priority: "normal", middleware, ...options }; const aliases = getAllAliases(name, _aliases); if (aliases.length > 0) { if (aliases.some((alias) => entriesNameSet.has(alias))) { if (!override) throw new Error(`Duplicate middleware name '${getMiddlewareNameWithAliases(name, _aliases)}'`); for (const alias of aliases) { const toOverrideIndex = absoluteEntries.findIndex((entry2) => entry2.name === alias || entry2.aliases?.some((a5) => a5 === alias)); if (toOverrideIndex === -1) { continue; } const toOverride = absoluteEntries[toOverrideIndex]; if (toOverride.step !== entry.step || entry.priority !== toOverride.priority) { throw new Error(`"${getMiddlewareNameWithAliases(toOverride.name, toOverride.aliases)}" middleware with ${toOverride.priority} priority in ${toOverride.step} step cannot be overridden by "${getMiddlewareNameWithAliases(name, _aliases)}" middleware with ${entry.priority} priority in ${entry.step} step.`); } absoluteEntries.splice(toOverrideIndex, 1); } } for (const alias of aliases) { entriesNameSet.add(alias); } } absoluteEntries.push(entry); }, addRelativeTo: (middleware, options) => { const { name, override, aliases: _aliases } = options; const entry = { middleware, ...options }; const aliases = getAllAliases(name, _aliases); if (aliases.length > 0) { if (aliases.some((alias) => entriesNameSet.has(alias))) { if (!override) throw new Error(`Duplicate middleware name '${getMiddlewareNameWithAliases(name, _aliases)}'`); for (const alias of aliases) { const toOverrideIndex = relativeEntries.findIndex((entry2) => entry2.name === alias || entry2.aliases?.some((a5) => a5 === alias)); if (toOverrideIndex === -1) { continue; } const toOverride = relativeEntries[toOverrideIndex]; if (toOverride.toMiddleware !== entry.toMiddleware || toOverride.relation !== entry.relation) { throw new Error(`"${getMiddlewareNameWithAliases(toOverride.name, toOverride.aliases)}" middleware ${toOverride.relation} "${toOverride.toMiddleware}" middleware cannot be overridden by "${getMiddlewareNameWithAliases(name, _aliases)}" middleware ${entry.relation} "${entry.toMiddleware}" middleware.`); } relativeEntries.splice(toOverrideIndex, 1); } } for (const alias of aliases) { entriesNameSet.add(alias); } } relativeEntries.push(entry); }, clone: () => cloneTo(constructStack()), use: (plugin) => { plugin.applyToStack(stack); }, remove: (toRemove) => { if (typeof toRemove === "string") return removeByName(toRemove); else return removeByReference(toRemove); }, removeByTag: (toRemove) => { let isRemoved = false; const filterCb = (entry) => { const { tags, name, aliases: _aliases } = entry; if (tags && tags.includes(toRemove)) { const aliases = getAllAliases(name, _aliases); for (const alias of aliases) { entriesNameSet.delete(alias); } isRemoved = true; return false; } return true; }; absoluteEntries = absoluteEntries.filter(filterCb); relativeEntries = relativeEntries.filter(filterCb); return isRemoved; }, concat: (from) => { const cloned = cloneTo(constructStack()); cloned.use(from); cloned.identifyOnResolve(identifyOnResolve || cloned.identifyOnResolve() || (from.identifyOnResolve?.() ?? false)); return cloned; }, applyToStack: cloneTo, identify: () => { return getMiddlewareList(true).map((mw) => { const step = mw.step ?? mw.relation + " " + mw.toMiddleware; return getMiddlewareNameWithAliases(mw.name, mw.aliases) + " - " + step; }); }, identifyOnResolve(toggle) { if (typeof toggle === "boolean") identifyOnResolve = toggle; return identifyOnResolve; }, resolve: (handler, context) => { for (const middleware of getMiddlewareList().map((entry) => entry.middleware).reverse()) { handler = middleware(handler, context); } if (identifyOnResolve) { console.log(stack.identify()); } return handler; } }; return stack; }; stepWeights = { initialize: 5, serialize: 4, build: 3, finalizeRequest: 2, deserialize: 1 }; priorityWeights = { high: 3, normal: 2, low: 1 }; } }); // node_modules/@smithy/types/dist-cjs/index.js var require_dist_cjs = __commonJS({ "node_modules/@smithy/types/dist-cjs/index.js"(exports2) { "use strict"; exports2.HttpAuthLocation = void 0; (function(HttpAuthLocation) { HttpAuthLocation["HEADER"] = "header"; HttpAuthLocation["QUERY"] = "query"; })(exports2.HttpAuthLocation || (exports2.HttpAuthLocation = {})); exports2.HttpApiKeyAuthLocation = void 0; (function(HttpApiKeyAuthLocation2) { HttpApiKeyAuthLocation2["HEADER"] = "header"; HttpApiKeyAuthLocation2["QUERY"] = "query"; })(exports2.HttpApiKeyAuthLocation || (exports2.HttpApiKeyAuthLocation = {})); exports2.EndpointURLScheme = void 0; (function(EndpointURLScheme2) { EndpointURLScheme2["HTTP"] = "http"; EndpointURLScheme2["HTTPS"] = "https"; })(exports2.EndpointURLScheme || (exports2.EndpointURLScheme = {})); exports2.AlgorithmId = void 0; (function(AlgorithmId2) { AlgorithmId2["MD5"] = "md5"; AlgorithmId2["CRC32"] = "crc32"; AlgorithmId2["CRC32C"] = "crc32c"; AlgorithmId2["SHA1"] = "sha1"; AlgorithmId2["SHA256"] = "sha256"; })(exports2.AlgorithmId || (exports2.AlgorithmId = {})); var getChecksumConfiguration2 = (runtimeConfig) => { const checksumAlgorithms = []; if (runtimeConfig.sha256 !== void 0) { checksumAlgorithms.push({ algorithmId: () => exports2.AlgorithmId.SHA256, checksumConstructor: () => runtimeConfig.sha256 }); } if (runtimeConfig.md5 != void 0) { checksumAlgorithms.push({ algorithmId: () => exports2.AlgorithmId.MD5, checksumConstructor: () => runtimeConfig.md5 }); } return { addChecksumAlgorithm(algo) { checksumAlgorithms.push(algo); }, checksumAlgorithms() { return checksumAlgorithms; } }; }; var resolveChecksumRuntimeConfig2 = (clientConfig) => { const runtimeConfig = {}; clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => { runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor(); }); return runtimeConfig; }; var getDefaultClientConfiguration2 = (runtimeConfig) => { return getChecksumConfiguration2(runtimeConfig); }; var resolveDefaultRuntimeConfig2 = (config) => { return resolveChecksumRuntimeConfig2(config); }; exports2.FieldPosition = void 0; (function(FieldPosition2) { FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER"; FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER"; })(exports2.FieldPosition || (exports2.FieldPosition = {})); var SMITHY_CONTEXT_KEY3 = "__smithy_context"; exports2.IniSectionType = void 0; (function(IniSectionType4) { IniSectionType4["PROFILE"] = "profile"; IniSectionType4["SSO_SESSION"] = "sso-session"; IniSectionType4["SERVICES"] = "services"; })(exports2.IniSectionType || (exports2.IniSectionType = {})); exports2.RequestHandlerProtocol = void 0; (function(RequestHandlerProtocol) { RequestHandlerProtocol["HTTP_0_9"] = "http/0.9"; RequestHandlerProtocol["HTTP_1_0"] = "http/1.0"; RequestHandlerProtocol["TDS_8_0"] = "tds/8.0"; })(exports2.RequestHandlerProtocol || (exports2.RequestHandlerProtocol = {})); exports2.SMITHY_CONTEXT_KEY = SMITHY_CONTEXT_KEY3; exports2.getDefaultClientConfiguration = getDefaultClientConfiguration2; exports2.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig2; } }); // node_modules/@smithy/core/dist-es/submodules/transport/getSmithyContext.js var import_types, getSmithyContext; var init_getSmithyContext = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/getSmithyContext.js"() { import_types = __toESM(require_dist_cjs()); getSmithyContext = (context) => context[import_types.SMITHY_CONTEXT_KEY] || (context[import_types.SMITHY_CONTEXT_KEY] = {}); } }); // node_modules/@smithy/core/dist-es/submodules/transport/httpRequest.js function cloneQuery(query) { return Object.keys(query).reduce((carry, paramName) => { const param = query[paramName]; return { ...carry, [paramName]: Array.isArray(param) ? [...param] : param }; }, {}); } var HttpRequest; var init_httpRequest = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/httpRequest.js"() { HttpRequest = class _HttpRequest { method; protocol; hostname; port; path; query; headers; username; password; fragment; body; constructor(options) { this.method = options.method || "GET"; this.hostname = options.hostname || "localhost"; this.port = options.port; this.query = options.query || {}; this.headers = options.headers || {}; this.body = options.body; this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:"; this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/"; this.username = options.username; this.password = options.password; this.fragment = options.fragment; } static clone(request) { const cloned = new _HttpRequest({ ...request, headers: { ...request.headers } }); if (cloned.query) { cloned.query = cloneQuery(cloned.query); } return cloned; } static isInstance(request) { if (!request) { return false; } const req = request; return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object"; } clone() { return _HttpRequest.clone(this); } }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/httpResponse.js var HttpResponse; var init_httpResponse = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/httpResponse.js"() { HttpResponse = class { statusCode; reason; headers; body; constructor(options) { this.statusCode = options.statusCode; this.reason = options.reason; this.headers = options.headers || {}; this.body = options.body; } static isInstance(response) { if (!response) return false; const resp = response; return typeof resp.statusCode === "number" && typeof resp.headers === "object"; } }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/isValidHostLabel.js var VALID_HOST_LABEL_REGEX, isValidHostLabel; var init_isValidHostLabel = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/isValidHostLabel.js"() { VALID_HOST_LABEL_REGEX = new RegExp(`^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$`); isValidHostLabel = (value, allowSubDomains = false) => { if (!allowSubDomains) { return VALID_HOST_LABEL_REGEX.test(value); } const labels = value.split("."); for (const label of labels) { if (!isValidHostLabel(label)) { return false; } } return true; }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/isValidHostname.js function isValidHostname(hostname) { const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/; return hostPattern.test(hostname); } var init_isValidHostname = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/isValidHostname.js"() { } }); // node_modules/@smithy/core/dist-es/submodules/transport/normalizeProvider.js var normalizeProvider; var init_normalizeProvider = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/normalizeProvider.js"() { normalizeProvider = (input) => { if (typeof input === "function") return input; const promisified = Promise.resolve(input); return () => promisified; }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/parseQueryString.js function parseQueryString(querystring) { const query = {}; querystring = querystring.replace(/^\?/, ""); if (querystring) { for (const pair of querystring.split("&")) { let [key, value = null] = pair.split("="); key = decodeURIComponent(key); if (value) { value = decodeURIComponent(value); } if (!(key in query)) { query[key] = value; } else if (Array.isArray(query[key])) { query[key].push(value); } else { query[key] = [query[key], value]; } } } return query; } var init_parseQueryString = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/parseQueryString.js"() { } }); // node_modules/@smithy/core/dist-es/submodules/transport/parseUrl.js var parseUrl; var init_parseUrl = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/parseUrl.js"() { init_parseQueryString(); parseUrl = (url) => { if (typeof url === "string") { return parseUrl(new URL(url)); } const { hostname, pathname, port, protocol, search } = url; let query; if (search) { query = parseQueryString(search); } return { hostname, port: port ? parseInt(port) : void 0, protocol, path: pathname, query }; }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/toEndpointV1.js var toEndpointV1; var init_toEndpointV1 = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/toEndpointV1.js"() { init_parseUrl(); toEndpointV1 = (endpoint) => { if (typeof endpoint === "object") { if ("url" in endpoint) { const v1Endpoint = parseUrl(endpoint.url); if (endpoint.headers) { v1Endpoint.headers = {}; for (const name in endpoint.headers) { v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", "); } } return v1Endpoint; } return endpoint; } return parseUrl(endpoint); }; } }); // node_modules/@smithy/core/dist-es/submodules/transport/index.js var init_transport = __esm({ "node_modules/@smithy/core/dist-es/submodules/transport/index.js"() { init_getSmithyContext(); init_httpRequest(); init_httpResponse(); init_isValidHostLabel(); init_isValidHostname(); init_normalizeProvider(); init_parseQueryString(); init_parseUrl(); init_toEndpointV1(); } }); // node_modules/@smithy/core/dist-es/submodules/client/invalid-dependency/invalidFunction.js var invalidFunction; var init_invalidFunction = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/invalid-dependency/invalidFunction.js"() { invalidFunction = (message) => () => { throw new Error(message); }; } }); // node_modules/@smithy/core/dist-es/submodules/client/invalid-dependency/invalidProvider.js var invalidProvider; var init_invalidProvider = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/invalid-dependency/invalidProvider.js"() { invalidProvider = (message) => () => Promise.reject(message); } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/circularReplacer.js var getCircularReplacer; var init_circularReplacer = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/circularReplacer.js"() { getCircularReplacer = () => { const seen = /* @__PURE__ */ new WeakSet(); return (key, value) => { if (typeof value === "object" && value !== null) { if (seen.has(value)) { return "[Circular]"; } seen.add(value); } return value; }; }; } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/utils/sleep.js var sleep; var init_sleep = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/utils/sleep.js"() { sleep = (seconds) => { return new Promise((resolve3) => setTimeout(resolve3, seconds * 1e3)); }; } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/waiter.js var waiterServiceDefaults, WaiterState, checkExceptions; var init_waiter = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/waiter.js"() { init_circularReplacer(); waiterServiceDefaults = { minDelay: 2, maxDelay: 120 }; (function(WaiterState2) { WaiterState2["ABORTED"] = "ABORTED"; WaiterState2["FAILURE"] = "FAILURE"; WaiterState2["SUCCESS"] = "SUCCESS"; WaiterState2["RETRY"] = "RETRY"; WaiterState2["TIMEOUT"] = "TIMEOUT"; })(WaiterState || (WaiterState = {})); checkExceptions = (result) => { if (result.state === WaiterState.ABORTED) { const abortError = new Error(`${JSON.stringify({ ...result, reason: "Request was aborted" }, getCircularReplacer())}`); abortError.name = "AbortError"; throw abortError; } else if (result.state === WaiterState.TIMEOUT) { const timeoutError = new Error(`${JSON.stringify({ ...result, reason: "Waiter has timed out" }, getCircularReplacer())}`); timeoutError.name = "TimeoutError"; throw timeoutError; } else if (result.state !== WaiterState.SUCCESS) { throw new Error(`${JSON.stringify(result, getCircularReplacer())}`); } return result; }; } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/poller.js var runPolling, checkWarn403, createMessageFromResponse, exponentialBackoffWithJitter, randomInRange; var init_poller = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/poller.js"() { init_circularReplacer(); init_sleep(); init_waiter(); runPolling = async ({ minDelay, maxDelay, maxWaitTime, abortController, client, abortSignal }, input, acceptorChecks) => { const observedResponses = {}; const [minDelayMs, maxDelayMs] = [minDelay * 1e3, maxDelay * 1e3]; let currentAttempt = 0; const waitUntil = Date.now() + maxWaitTime * 1e3; const warn403Time = Date.now() + 6e4; let didWarn403 = false; while (true) { if (currentAttempt > 0) { const delayMs = exponentialBackoffWithJitter(minDelayMs, maxDelayMs, currentAttempt, waitUntil); if (abortController?.signal?.aborted || abortSignal?.aborted) { const message = "AbortController signal aborted."; observedResponses[message] |= 0; observedResponses[message] += 1; return { state: WaiterState.ABORTED, observedResponses }; } if (Date.now() + delayMs > waitUntil) { return { state: WaiterState.TIMEOUT, observedResponses }; } await sleep(delayMs / 1e3); } const { state: state2, reason } = await acceptorChecks(client, input); if (reason) { const message = createMessageFromResponse(reason); observedResponses[message] |= 0; observedResponses[message] += 1; } if (state2 !== WaiterState.RETRY) { return { state: state2, reason, final: reason, observedResponses }; } currentAttempt += 1; if (!didWarn403 && Date.now() >= warn403Time) { checkWarn403(observedResponses, client); didWarn403 = true; } } }; checkWarn403 = (observedResponses = {}, client) => { const orderedErrors = Object.keys(observedResponses); let maxCount = 0; let count403 = 0; for (const response of orderedErrors) { const n2 = observedResponses[response] | 0; maxCount = Math.max(n2, maxCount); if (response.startsWith("403:")) { count403 += n2; } } const clientLogger = client?.config?.logger; const warningLogger = typeof clientLogger?.warn === "function" && !clientLogger.constructor?.name?.includes?.("NoOpLogger") ? clientLogger : console; if (count403 >= 3 || orderedErrors[orderedErrors.length - 1]?.startsWith("403:")) { warningLogger.warn(`@smithy/util-waiter WARN - 403 status code encountered during waiter polling.`); } }; createMessageFromResponse = (reason) => { const status = reason?.$response?.statusCode ?? reason?.$metadata?.httpStatusCode; if (reason?.$responseBodyText) { return `${status ? status + ": " : ""}Deserialization error for body: ${reason.$responseBodyText}`; } if (status) { if (reason?.$response || reason?.message) { return `${status ?? "Unknown"}: ${reason?.message}`; } return `${status}: OK`; } return String(reason?.message ?? JSON.stringify(reason, getCircularReplacer()) ?? "Unknown"); }; exponentialBackoffWithJitter = (minDelayMs, maxDelayMs, attempt, waitUntil) => { const attemptCountCeiling = Math.log(maxDelayMs / minDelayMs) / Math.log(2) + 1; if (attempt > attemptCountCeiling) { return maxDelayMs; } const delay = minDelayMs * 2 ** (attempt - 1); const capped = Math.min(delay, maxDelayMs); const waitFor = randomInRange(minDelayMs, capped); if (Date.now() + waitFor > waitUntil) { const timeRemaining = waitUntil - Date.now(); return Math.max(0, timeRemaining - 500); } return waitFor; }; randomInRange = (min, max) => min + Math.random() * (max - min); } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/utils/validate.js var validateWaiterOptions; var init_validate = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/utils/validate.js"() { validateWaiterOptions = (options) => { if (options.maxWaitTime <= 0) { throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`); } else if (options.minDelay <= 0) { throw new Error(`WaiterConfiguration.minDelay must be greater than 0`); } else if (options.maxDelay <= 0) { throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`); } else if (options.maxWaitTime <= options.minDelay) { throw new Error(`WaiterConfiguration.maxWaitTime [${options.maxWaitTime}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`); } else if (options.maxDelay < options.minDelay) { throw new Error(`WaiterConfiguration.maxDelay [${options.maxDelay}] must be greater than WaiterConfiguration.minDelay [${options.minDelay}] for this waiter`); } }; } }); // node_modules/@smithy/core/dist-es/submodules/client/util-waiter/createWaiter.js var abortTimeout, createWaiter; var init_createWaiter = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/util-waiter/createWaiter.js"() { init_poller(); init_validate(); init_waiter(); abortTimeout = (abortSignal) => { let onAbort; const promise = new Promise((resolve3) => { onAbort = () => resolve3({ state: WaiterState.ABORTED }); if (typeof abortSignal.addEventListener === "function") { abortSignal.addEventListener("abort", onAbort); } else { abortSignal.onabort = onAbort; } }); return { clearListener() { if (typeof abortSignal.removeEventListener === "function") { abortSignal.removeEventListener("abort", onAbort); } }, aborted: promise }; }; createWaiter = async (options, input, acceptorChecks) => { const params = { ...waiterServiceDefaults, ...options }; validateWaiterOptions(params); const exitConditions = [runPolling(params, input, acceptorChecks)]; const finalize = []; if (options.abortSignal) { const { aborted, clearListener } = abortTimeout(options.abortSignal); finalize.push(clearListener); exitConditions.push(aborted); } if (options.abortController?.signal) { const { aborted, clearListener } = abortTimeout(options.abortController.signal); finalize.push(clearListener); exitConditions.push(aborted); } return Promise.race(exitConditions).then((result) => { for (const fn of finalize) { fn(); } return result; }); }; } }); // node_modules/@smithy/core/dist-es/submodules/client/smithy-client/client.js var Client; var init_client = __esm({ "node_modules/@smithy/core/dist-es/submodules/client/smithy-client/client.js"() { init_MiddlewareStack(); Client = class { config; middlewareStack = constructStack(); initConfig; handlers; constructor(config) { this.config = config; const { protocol, protocolSettings } = config; if (protocolSettings) { if (typeof protocol === "function") { config.protocol = new protocol(protocolSettings); } } } send(command, optionsOrCb, cb) { const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0; const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb; const useHandlerCache = options === void 0 && this.config.cacheMiddleware === true; let handler; if (useHandlerCache) { if (!this.handlers) { this.handlers = /* @__PURE__ */ new WeakMap(); } const handlers = this.handlers; if (handlers.has(command.constructor)) { handler = handlers.get(command.constructor); } else { handler = command.resolveMiddleware(this.middlewareStack, this.config, options); handlers.set(command.constructor, handler); } } else { delete this.handlers; handler = command.resolveMiddleware(this.middlewareStack, this.config, options); } if (callback) { handler(command).then((result) => callback(null, result.output), (err) => callback(err)).catch(() => { }); } else { return handler(command).then((result) => result.output); } } destroy() { this.config?.requestHandler?.destroy?.(); delete this.handlers; } }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/deref.js var deref; var init_deref = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/deref.js"() { deref = (schemaRef) => { if (typeof schemaRef === "function") { return schemaRef(); } return schemaRef; }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js var operation; var init_operation = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js"() { operation = (namespace, name, traits, input, output) => ({ name, namespace, traits, input, output }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js var schemaDeserializationMiddleware, findHeader; var init_schemaDeserializationMiddleware = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js"() { init_transport(); init_operation(); schemaDeserializationMiddleware = (config) => (next, context) => async (args) => { const { response } = await next(args); const { operationSchema } = getSmithyContext(context); const [, ns, n2, t, i5, o2] = operationSchema ?? []; try { const parsed = await config.protocol.deserializeResponse(operation(ns, n2, t, i5, o2), { ...config, ...context }, response); return { response, output: parsed }; } catch (error2) { Object.defineProperty(error2, "$response", { value: response, enumerable: false, writable: false, configurable: false }); if (!("$metadata" in error2)) { const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`; try { error2.message += "\n " + hint; } catch (e5) { if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") { console.warn(hint); } else { context.logger?.warn?.(hint); } } if (typeof error2.$responseBodyText !== "undefined") { if (error2.$response) { error2.$response.body = error2.$responseBodyText; } } try { if (HttpResponse.isInstance(response)) { const { headers = {}, statusCode } = response; const headerEntries = Object.entries(headers); error2.$metadata = { httpStatusCode: statusCode, requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries), extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries), cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries) }; } } catch (e5) { } } throw error2; } }; findHeader = (pattern, headers) => { return (headers.find(([k5]) => { return k5.match(pattern); }) || [void 0, void 0])[1]; }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js var schemaSerializationMiddleware; var init_schemaSerializationMiddleware = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js"() { init_transport(); init_operation(); schemaSerializationMiddleware = (config) => (next, context) => async (args) => { const { operationSchema } = getSmithyContext(context); const [, ns, n2, t, i5, o2] = operationSchema ?? []; const endpoint = context.endpointV2 ? async () => toEndpointV1(context.endpointV2) : config.endpoint; const request = await config.protocol.serializeRequest(operation(ns, n2, t, i5, o2), args.input, { ...config, ...context, endpoint }); return next({ ...args, request }); }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js function getSchemaSerdePlugin(config) { return { applyToStack: (commandStack) => { commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption); commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption); config.protocol.setSerdeContext(config); } }; } var deserializerMiddlewareOption, serializerMiddlewareOption; var init_getSchemaSerdePlugin = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js"() { init_schemaDeserializationMiddleware(); init_schemaSerializationMiddleware(); deserializerMiddlewareOption = { name: "deserializerMiddleware", step: "deserialize", tags: ["DESERIALIZER"], override: true }; serializerMiddlewareOption = { name: "serializerMiddleware", step: "serialize", tags: ["SERIALIZER"], override: true }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js var Schema; var init_Schema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js"() { Schema = class { name; namespace; traits; static assign(instance, values2) { const schema = Object.assign(instance, values2); return schema; } static [Symbol.hasInstance](lhs) { const isPrototype = this.prototype.isPrototypeOf(lhs); if (!isPrototype && typeof lhs === "object" && lhs !== null) { const list2 = lhs; return list2.symbol === this.symbol; } return isPrototype; } getName() { return this.namespace + "#" + this.name; } }; } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js var ListSchema, list; var init_ListSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js"() { init_Schema(); ListSchema = class _ListSchema extends Schema { static symbol = Symbol.for("@smithy/lis"); name; traits; valueSchema; symbol = _ListSchema.symbol; }; list = (namespace, name, traits, valueSchema) => Schema.assign(new ListSchema(), { name, namespace, traits, valueSchema }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js var MapSchema, map; var init_MapSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js"() { init_Schema(); MapSchema = class _MapSchema extends Schema { static symbol = Symbol.for("@smithy/map"); name; traits; keySchema; valueSchema; symbol = _MapSchema.symbol; }; map = (namespace, name, traits, keySchema, valueSchema) => Schema.assign(new MapSchema(), { name, namespace, traits, keySchema, valueSchema }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js var OperationSchema, op; var init_OperationSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js"() { init_Schema(); OperationSchema = class _OperationSchema extends Schema { static symbol = Symbol.for("@smithy/ope"); name; traits; input; output; symbol = _OperationSchema.symbol; }; op = (namespace, name, traits, input, output) => Schema.assign(new OperationSchema(), { name, namespace, traits, input, output }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js var StructureSchema, struct; var init_StructureSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js"() { init_Schema(); StructureSchema = class _StructureSchema extends Schema { static symbol = Symbol.for("@smithy/str"); name; traits; memberNames; memberList; symbol = _StructureSchema.symbol; }; struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), { name, namespace, traits, memberNames, memberList }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js var ErrorSchema, error; var init_ErrorSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js"() { init_Schema(); init_StructureSchema(); ErrorSchema = class _ErrorSchema extends StructureSchema { static symbol = Symbol.for("@smithy/err"); ctor; symbol = _ErrorSchema.symbol; }; error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), { name, namespace, traits, memberNames, memberList, ctor: null }); } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js function translateTraits(indicator) { if (typeof indicator === "object") { return indicator; } indicator = indicator | 0; if (traitsCache[indicator]) { return traitsCache[indicator]; } const traits = {}; let i5 = 0; for (const trait of [ "httpLabel", "idempotent", "idempotencyToken", "sensitive", "httpPayload", "httpResponseCode", "httpQueryParams" ]) { if ((indicator >> i5++ & 1) === 1) { traits[trait] = 1; } } return traitsCache[indicator] = traits; } var traitsCache; var init_translateTraits = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js"() { traitsCache = []; } }); // node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js function member(memberSchema, memberName) { if (memberSchema instanceof NormalizedSchema) { return Object.assign(memberSchema, { memberName, _isMemberSchema: true }); } const internalCtorAccess = NormalizedSchema; return new internalCtorAccess(memberSchema, memberName); } var anno, simpleSchemaCacheN, simpleSchemaCacheS, NormalizedSchema, isMemberSchema, isStaticSchema; var init_NormalizedSchema = __esm({ "node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js"() { init_deref(); init_translateTraits(); anno = { it: Symbol.for("@smithy/nor-struct-it"), ns: Symbol.for("@smithy/ns") }; simpleSchemaCacheN = []; simpleSchemaCacheS = {}; NormalizedSchema = class _NormalizedSchema { ref; memberName; static symbol = Symbol.for("@smithy/nor"); symbol = _NormalizedSchema.symbol; name; schema; _isMemberSchema; traits; memberTraits; normalizedTraits; constructor(ref, memberName) { this.ref = ref; this.memberName = memberName; const traitStack = []; let _ref = ref; let schema = ref; this._isMemberSchema = false; while (isMemberSchema(_ref)) { traitStack.push(_ref[1]); _ref = _ref[0]; schema = deref(_ref); this._isMemberSchema = true; } if (traitStack.length > 0) { this.memberTraits = {}; for (let i5 = traitStack.length - 1; i5 >= 0; --i5) { const traitSet = traitStack[i5]; Object.assign(this.memberTraits, translateTraits(traitSet)); } } else { this.memberTraits = 0; } if (schema instanceof _NormalizedSchema) { const computedMemberTraits = this.memberTraits; Object.assign(this, schema); this.memberTraits = Object.assign({}, computedMemberTraits, schema.getMemberTraits(), this.getMemberTraits()); this.normalizedTraits = void 0; this.memberName = memberName ?? schema.memberName; return; } this.schema = deref(schema); if (