cdk-drizzle-migrate
Version:
AWS CDK construct for running Drizzle ORM migrations
1,185 lines (1,163 loc) • 2.86 MB
JavaScript
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/@smithy/types/dist-cjs/index.js
var require_dist_cjs = __commonJS({
"node_modules/@smithy/types/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
AlgorithmId: () => AlgorithmId,
EndpointURLScheme: () => EndpointURLScheme,
FieldPosition: () => FieldPosition,
HttpApiKeyAuthLocation: () => HttpApiKeyAuthLocation2,
HttpAuthLocation: () => HttpAuthLocation,
IniSectionType: () => IniSectionType,
RequestHandlerProtocol: () => RequestHandlerProtocol,
SMITHY_CONTEXT_KEY: () => SMITHY_CONTEXT_KEY2,
getDefaultClientConfiguration: () => getDefaultClientConfiguration,
resolveDefaultRuntimeConfig: () => resolveDefaultRuntimeConfig3
});
module2.exports = __toCommonJS2(index_exports);
var HttpAuthLocation = /* @__PURE__ */ ((HttpAuthLocation2) => {
HttpAuthLocation2["HEADER"] = "header";
HttpAuthLocation2["QUERY"] = "query";
return HttpAuthLocation2;
})(HttpAuthLocation || {});
var HttpApiKeyAuthLocation2 = /* @__PURE__ */ ((HttpApiKeyAuthLocation22) => {
HttpApiKeyAuthLocation22["HEADER"] = "header";
HttpApiKeyAuthLocation22["QUERY"] = "query";
return HttpApiKeyAuthLocation22;
})(HttpApiKeyAuthLocation2 || {});
var EndpointURLScheme = /* @__PURE__ */ ((EndpointURLScheme2) => {
EndpointURLScheme2["HTTP"] = "http";
EndpointURLScheme2["HTTPS"] = "https";
return EndpointURLScheme2;
})(EndpointURLScheme || {});
var AlgorithmId = /* @__PURE__ */ ((AlgorithmId2) => {
AlgorithmId2["MD5"] = "md5";
AlgorithmId2["CRC32"] = "crc32";
AlgorithmId2["CRC32C"] = "crc32c";
AlgorithmId2["SHA1"] = "sha1";
AlgorithmId2["SHA256"] = "sha256";
return AlgorithmId2;
})(AlgorithmId || {});
var getChecksumConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
const checksumAlgorithms = [];
if (runtimeConfig.sha256 !== void 0) {
checksumAlgorithms.push({
algorithmId: /* @__PURE__ */ __name(() => "sha256", "algorithmId"),
checksumConstructor: /* @__PURE__ */ __name(() => runtimeConfig.sha256, "checksumConstructor")
});
}
if (runtimeConfig.md5 != void 0) {
checksumAlgorithms.push({
algorithmId: /* @__PURE__ */ __name(() => "md5", "algorithmId"),
checksumConstructor: /* @__PURE__ */ __name(() => runtimeConfig.md5, "checksumConstructor")
});
}
return {
addChecksumAlgorithm(algo) {
checksumAlgorithms.push(algo);
},
checksumAlgorithms() {
return checksumAlgorithms;
}
};
}, "getChecksumConfiguration");
var resolveChecksumRuntimeConfig = /* @__PURE__ */ __name((clientConfig) => {
const runtimeConfig = {};
clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => {
runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor();
});
return runtimeConfig;
}, "resolveChecksumRuntimeConfig");
var getDefaultClientConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
return getChecksumConfiguration(runtimeConfig);
}, "getDefaultClientConfiguration");
var resolveDefaultRuntimeConfig3 = /* @__PURE__ */ __name((config) => {
return resolveChecksumRuntimeConfig(config);
}, "resolveDefaultRuntimeConfig");
var FieldPosition = /* @__PURE__ */ ((FieldPosition2) => {
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
return FieldPosition2;
})(FieldPosition || {});
var SMITHY_CONTEXT_KEY2 = "__smithy_context";
var IniSectionType = /* @__PURE__ */ ((IniSectionType2) => {
IniSectionType2["PROFILE"] = "profile";
IniSectionType2["SSO_SESSION"] = "sso-session";
IniSectionType2["SERVICES"] = "services";
return IniSectionType2;
})(IniSectionType || {});
var RequestHandlerProtocol = /* @__PURE__ */ ((RequestHandlerProtocol2) => {
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
return RequestHandlerProtocol2;
})(RequestHandlerProtocol || {});
}
});
// node_modules/@smithy/protocol-http/dist-cjs/index.js
var require_dist_cjs2 = __commonJS({
"node_modules/@smithy/protocol-http/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
Field: () => Field,
Fields: () => Fields,
HttpRequest: () => HttpRequest10,
HttpResponse: () => HttpResponse4,
IHttpRequest: () => import_types5.HttpRequest,
getHttpHandlerExtensionConfiguration: () => getHttpHandlerExtensionConfiguration3,
isValidHostname: () => isValidHostname,
resolveHttpHandlerRuntimeConfig: () => resolveHttpHandlerRuntimeConfig3
});
module2.exports = __toCommonJS2(index_exports);
var getHttpHandlerExtensionConfiguration3 = /* @__PURE__ */ __name((runtimeConfig) => {
return {
setHttpHandler(handler) {
runtimeConfig.httpHandler = handler;
},
httpHandler() {
return runtimeConfig.httpHandler;
},
updateHttpClientConfig(key, value) {
runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);
},
httpHandlerConfigs() {
return runtimeConfig.httpHandler.httpHandlerConfigs();
}
};
}, "getHttpHandlerExtensionConfiguration");
var resolveHttpHandlerRuntimeConfig3 = /* @__PURE__ */ __name((httpHandlerExtensionConfiguration) => {
return {
httpHandler: httpHandlerExtensionConfiguration.httpHandler()
};
}, "resolveHttpHandlerRuntimeConfig");
var import_types5 = require_dist_cjs();
var Field = class {
static {
__name(this, "Field");
}
constructor({ name, kind = import_types5.FieldPosition.HEADER, values: values2 = [] }) {
this.name = name;
this.kind = kind;
this.values = values2;
}
/**
* Appends a value to the field.
*
* @param value The value to append.
*/
add(value) {
this.values.push(value);
}
/**
* Overwrite existing field values.
*
* @param values The new field values.
*/
set(values2) {
this.values = values2;
}
/**
* Remove all matching entries from list.
*
* @param value Value to remove.
*/
remove(value) {
this.values = this.values.filter((v6) => v6 !== value);
}
/**
* Get comma-delimited string.
*
* @returns String representation of {@link Field}.
*/
toString() {
return this.values.map((v6) => v6.includes(",") || v6.includes(" ") ? `"${v6}"` : v6).join(", ");
}
/**
* Get string values as a list
*
* @returns Values in {@link Field} as a list.
*/
get() {
return this.values;
}
};
var Fields = class {
constructor({ fields = [], encoding = "utf-8" }) {
this.entries = {};
fields.forEach(this.setField.bind(this));
this.encoding = encoding;
}
static {
__name(this, "Fields");
}
/**
* Set entry for a {@link Field} name. The `name`
* attribute will be used to key the collection.
*
* @param field The {@link Field} to set.
*/
setField(field) {
this.entries[field.name.toLowerCase()] = field;
}
/**
* Retrieve {@link Field} entry by name.
*
* @param name The name of the {@link Field} entry
* to retrieve
* @returns The {@link Field} if it exists.
*/
getField(name) {
return this.entries[name.toLowerCase()];
}
/**
* Delete entry from collection.
*
* @param name Name of the entry to delete.
*/
removeField(name) {
delete this.entries[name.toLowerCase()];
}
/**
* Helper function for retrieving specific types of fields.
* Used to grab all headers or all trailers.
*
* @param kind {@link FieldPosition} of entries to retrieve.
* @returns The {@link Field} entries with the specified
* {@link FieldPosition}.
*/
getByType(kind) {
return Object.values(this.entries).filter((field) => field.kind === kind);
}
};
var HttpRequest10 = class _HttpRequest {
static {
__name(this, "HttpRequest");
}
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;
}
/**
* Note: this does not deep-clone the body.
*/
static clone(request) {
const cloned = new _HttpRequest({
...request,
headers: { ...request.headers }
});
if (cloned.query) {
cloned.query = cloneQuery(cloned.query);
}
return cloned;
}
/**
* This method only actually asserts that request is the interface {@link IHttpRequest},
* and not necessarily this concrete class. Left in place for API stability.
*
* Do not call instance methods on the input of this function, and
* do not assume it has the HttpRequest prototype.
*/
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";
}
/**
* @deprecated use static HttpRequest.clone(request) instead. It's not safe to call
* this method because {@link HttpRequest.isInstance} incorrectly
* asserts that IHttpRequest (interface) objects are of type HttpRequest (class).
*/
clone() {
return _HttpRequest.clone(this);
}
};
function cloneQuery(query) {
return Object.keys(query).reduce((carry, paramName) => {
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [...param] : param
};
}, {});
}
__name(cloneQuery, "cloneQuery");
var HttpResponse4 = class {
static {
__name(this, "HttpResponse");
}
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";
}
};
function isValidHostname(hostname) {
const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/;
return hostPattern.test(hostname);
}
__name(isValidHostname, "isValidHostname");
}
});
// node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js
var require_dist_cjs3 = __commonJS({
"node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js"(exports2, module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
getHostHeaderPlugin: () => getHostHeaderPlugin3,
hostHeaderMiddleware: () => hostHeaderMiddleware,
hostHeaderMiddlewareOptions: () => hostHeaderMiddlewareOptions,
resolveHostHeaderConfig: () => resolveHostHeaderConfig3
});
module2.exports = __toCommonJS2(index_exports);
var import_protocol_http15 = require_dist_cjs2();
function resolveHostHeaderConfig3(input) {
return input;
}
__name(resolveHostHeaderConfig3, "resolveHostHeaderConfig");
var hostHeaderMiddleware = /* @__PURE__ */ __name((options) => (next) => async (args) => {
if (!import_protocol_http15.HttpRequest.isInstance(args.request)) return next(args);
const { request } = args;
const { handlerProtocol = "" } = options.requestHandler.metadata || {};
if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
delete request.headers["host"];
request.headers[":authority"] = request.hostname + (request.port ? ":" + request.port : "");
} else if (!request.headers["host"]) {
let host = request.hostname;
if (request.port != null) host += `:${request.port}`;
request.headers["host"] = host;
}
return next(args);
}, "hostHeaderMiddleware");
var hostHeaderMiddlewareOptions = {
name: "hostHeaderMiddleware",
step: "build",
priority: "low",
tags: ["HOST"],
override: true
};
var getHostHeaderPlugin3 = /* @__PURE__ */ __name((options) => ({
applyToStack: /* @__PURE__ */ __name((clientStack) => {
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
}, "applyToStack")
}), "getHostHeaderPlugin");
}
});
// node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js
var require_dist_cjs4 = __commonJS({
"node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js"(exports2, module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
getLoggerPlugin: () => getLoggerPlugin3,
loggerMiddleware: () => loggerMiddleware,
loggerMiddlewareOptions: () => loggerMiddlewareOptions
});
module2.exports = __toCommonJS2(index_exports);
var loggerMiddleware = /* @__PURE__ */ __name(() => (next, context) => async (args) => {
try {
const response = await next(args);
const { clientName, commandName, logger: logger3, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
const { $metadata, ...outputWithoutMetadata } = response.output;
logger3?.info?.({
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
output: outputFilterSensitiveLog(outputWithoutMetadata),
metadata: $metadata
});
return response;
} catch (error2) {
const { clientName, commandName, logger: logger3, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
logger3?.error?.({
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
error: error2,
metadata: error2.$metadata
});
throw error2;
}
}, "loggerMiddleware");
var loggerMiddlewareOptions = {
name: "loggerMiddleware",
tags: ["LOGGER"],
step: "initialize",
override: true
};
var getLoggerPlugin3 = /* @__PURE__ */ __name((options) => ({
applyToStack: /* @__PURE__ */ __name((clientStack) => {
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
}, "applyToStack")
}), "getLoggerPlugin");
}
});
// node_modules/@aws/lambda-invoke-store/dist/invoke-store.js
var require_invoke_store = __commonJS({
"node_modules/@aws/lambda-invoke-store/dist/invoke-store.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.InvokeStore = void 0;
var async_hooks_1 = require("async_hooks");
var noGlobalAwsLambda = process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "1" || process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "true";
if (!noGlobalAwsLambda) {
globalThis.awslambda = globalThis.awslambda || {};
}
var PROTECTED_KEYS = {
REQUEST_ID: Symbol("_AWS_LAMBDA_REQUEST_ID"),
X_RAY_TRACE_ID: Symbol("_AWS_LAMBDA_X_RAY_TRACE_ID")
};
var InvokeStoreImpl = class {
static storage = new async_hooks_1.AsyncLocalStorage();
// Protected keys for Lambda context fields
static PROTECTED_KEYS = PROTECTED_KEYS;
/**
* Initialize and run code within an invoke context
*/
static run(context, fn) {
return this.storage.run({ ...context }, fn);
}
/**
* Get the complete current context
*/
static getContext() {
return this.storage.getStore();
}
/**
* Get a specific value from the context by key
*/
static get(key) {
const context = this.storage.getStore();
return context?.[key];
}
/**
* Set a custom value in the current context
* Protected Lambda context fields cannot be overwritten
*/
static set(key, value) {
if (this.isProtectedKey(key)) {
throw new Error(`Cannot modify protected Lambda context field`);
}
const context = this.storage.getStore();
if (context) {
context[key] = value;
}
}
/**
* Get the current request ID
*/
static getRequestId() {
return this.get(this.PROTECTED_KEYS.REQUEST_ID) ?? "-";
}
/**
* Get the current X-ray trace ID
*/
static getXRayTraceId() {
return this.get(this.PROTECTED_KEYS.X_RAY_TRACE_ID);
}
/**
* Check if we're currently within an invoke context
*/
static hasContext() {
return this.storage.getStore() !== void 0;
}
/**
* Check if a key is protected (readonly Lambda context field)
*/
static isProtectedKey(key) {
return key === this.PROTECTED_KEYS.REQUEST_ID || key === this.PROTECTED_KEYS.X_RAY_TRACE_ID;
}
};
var instance;
if (!noGlobalAwsLambda && globalThis.awslambda?.InvokeStore) {
instance = globalThis.awslambda.InvokeStore;
} else {
instance = InvokeStoreImpl;
if (!noGlobalAwsLambda && globalThis.awslambda) {
globalThis.awslambda.InvokeStore = instance;
}
}
exports2.InvokeStore = instance;
}
});
// node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/recursionDetectionMiddleware.js
var require_recursionDetectionMiddleware = __commonJS({
"node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/recursionDetectionMiddleware.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.recursionDetectionMiddleware = void 0;
var lambda_invoke_store_1 = require_invoke_store();
var protocol_http_1 = require_dist_cjs2();
var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
var ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
var recursionDetectionMiddleware2 = () => (next) => async (args) => {
const { request } = args;
if (!protocol_http_1.HttpRequest.isInstance(request)) {
return next(args);
}
const traceIdHeader = Object.keys(request.headers ?? {}).find((h3) => h3.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ?? TRACE_ID_HEADER_NAME;
if (request.headers.hasOwnProperty(traceIdHeader)) {
return next(args);
}
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
const traceIdFromEnv = process.env[ENV_TRACE_ID];
const traceIdFromInvokeStore = lambda_invoke_store_1.InvokeStore.getXRayTraceId();
const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
request.headers[TRACE_ID_HEADER_NAME] = traceId;
}
return next({
...args,
request
});
};
exports2.recursionDetectionMiddleware = recursionDetectionMiddleware2;
}
});
// node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js
var require_dist_cjs5 = __commonJS({
"node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js"(exports2, module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps2(target, mod, "default"), secondTarget && __copyProps2(secondTarget, mod, "default"));
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
getRecursionDetectionPlugin: () => getRecursionDetectionPlugin3
});
module2.exports = __toCommonJS2(index_exports);
var recursionDetectionMiddlewareOptions = {
step: "build",
tags: ["RECURSION_DETECTION"],
name: "recursionDetectionMiddleware",
override: true,
priority: "low"
};
var import_recursionDetectionMiddleware = require_recursionDetectionMiddleware();
var getRecursionDetectionPlugin3 = /* @__PURE__ */ __name((options) => ({
applyToStack: /* @__PURE__ */ __name((clientStack) => {
clientStack.add((0, import_recursionDetectionMiddleware.recursionDetectionMiddleware)(), recursionDetectionMiddlewareOptions);
}, "applyToStack")
}), "getRecursionDetectionPlugin");
__reExport(index_exports, require_recursionDetectionMiddleware(), module2.exports);
}
});
// node_modules/@smithy/core/dist-es/getSmithyContext.js
var import_types, getSmithyContext;
var init_getSmithyContext = __esm({
"node_modules/@smithy/core/dist-es/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/util-middleware/dist-cjs/index.js
var require_dist_cjs6 = __commonJS({
"node_modules/@smithy/util-middleware/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
getSmithyContext: () => getSmithyContext9,
normalizeProvider: () => normalizeProvider4
});
module2.exports = __toCommonJS2(index_exports);
var import_types5 = require_dist_cjs();
var getSmithyContext9 = /* @__PURE__ */ __name((context) => context[import_types5.SMITHY_CONTEXT_KEY] || (context[import_types5.SMITHY_CONTEXT_KEY] = {}), "getSmithyContext");
var normalizeProvider4 = /* @__PURE__ */ __name((input) => {
if (typeof input === "function") return input;
const promisified = Promise.resolve(input);
return () => promisified;
}, "normalizeProvider");
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js
var resolveAuthOptions;
var init_resolveAuthOptions = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/resolveAuthOptions.js"() {
resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
if (!authSchemePreference || authSchemePreference.length === 0) {
return candidateAuthOptions;
}
const preferredAuthOptions = [];
for (const preferredSchemeName of authSchemePreference) {
for (const candidateAuthOption of candidateAuthOptions) {
const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
if (candidateAuthSchemeName === preferredSchemeName) {
preferredAuthOptions.push(candidateAuthOption);
}
}
}
for (const candidateAuthOption of candidateAuthOptions) {
if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
preferredAuthOptions.push(candidateAuthOption);
}
}
return preferredAuthOptions;
};
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js
function convertHttpAuthSchemesToMap(httpAuthSchemes) {
const map3 = /* @__PURE__ */ new Map();
for (const scheme of httpAuthSchemes) {
map3.set(scheme.schemeId, scheme);
}
return map3;
}
var import_util_middleware, httpAuthSchemeMiddleware;
var init_httpAuthSchemeMiddleware = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js"() {
import_util_middleware = __toESM(require_dist_cjs6());
init_resolveAuthOptions();
httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
const smithyContext = (0, import_util_middleware.getSmithyContext)(context);
const failureReasons = [];
for (const option of resolvedOptions) {
const scheme = authSchemes.get(option.schemeId);
if (!scheme) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
continue;
}
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
if (!identityProvider) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
continue;
}
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
smithyContext.selectedHttpAuthScheme = {
httpAuthOption: option,
identity: await identityProvider(option.identityProperties),
signer: scheme.signer
};
break;
}
if (!smithyContext.selectedHttpAuthScheme) {
throw new Error(failureReasons.join("\n"));
}
return next(args);
};
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js
var httpAuthSchemeEndpointRuleSetMiddlewareOptions, getHttpAuthSchemeEndpointRuleSetPlugin;
var init_getHttpAuthSchemeEndpointRuleSetPlugin = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js"() {
init_httpAuthSchemeMiddleware();
httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: "endpointV2Middleware"
};
getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider }) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}), httpAuthSchemeEndpointRuleSetMiddlewareOptions);
}
});
}
});
// node_modules/@smithy/middleware-serde/dist-cjs/index.js
var require_dist_cjs7 = __commonJS({
"node_modules/@smithy/middleware-serde/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
deserializerMiddleware: () => deserializerMiddleware,
deserializerMiddlewareOption: () => deserializerMiddlewareOption2,
getSerdePlugin: () => getSerdePlugin4,
serializerMiddleware: () => serializerMiddleware,
serializerMiddlewareOption: () => serializerMiddlewareOption3
});
module2.exports = __toCommonJS2(index_exports);
var import_protocol_http15 = require_dist_cjs2();
var deserializerMiddleware = /* @__PURE__ */ __name((options, deserializer) => (next, context) => async (args) => {
const { response } = await next(args);
try {
const parsed = await deserializer(response, options);
return {
response,
output: parsed
};
} catch (error2) {
Object.defineProperty(error2, "$response", {
value: response
});
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 (e3) {
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 (import_protocol_http15.HttpResponse.isInstance(response)) {
const { headers = {} } = response;
const headerEntries = Object.entries(headers);
error2.$metadata = {
httpStatusCode: response.statusCode,
requestId: findHeader2(/^x-[\w-]+-request-?id$/, headerEntries),
extendedRequestId: findHeader2(/^x-[\w-]+-id-2$/, headerEntries),
cfId: findHeader2(/^x-[\w-]+-cf-id$/, headerEntries)
};
}
} catch (e3) {
}
}
throw error2;
}
}, "deserializerMiddleware");
var findHeader2 = /* @__PURE__ */ __name((pattern, headers) => {
return (headers.find(([k3]) => {
return k3.match(pattern);
}) || [void 0, void 0])[1];
}, "findHeader");
var serializerMiddleware = /* @__PURE__ */ __name((options, serializer) => (next, context) => async (args) => {
const endpointConfig = options;
const endpoint = context.endpointV2?.url && endpointConfig.urlParser ? async () => endpointConfig.urlParser(context.endpointV2.url) : endpointConfig.endpoint;
if (!endpoint) {
throw new Error("No valid endpoint provider available.");
}
const request = await serializer(args.input, { ...options, endpoint });
return next({
...args,
request
});
}, "serializerMiddleware");
var deserializerMiddlewareOption2 = {
name: "deserializerMiddleware",
step: "deserialize",
tags: ["DESERIALIZER"],
override: true
};
var serializerMiddlewareOption3 = {
name: "serializerMiddleware",
step: "serialize",
tags: ["SERIALIZER"],
override: true
};
function getSerdePlugin4(config, serializer, deserializer) {
return {
applyToStack: /* @__PURE__ */ __name((commandStack) => {
commandStack.add(deserializerMiddleware(config, deserializer), deserializerMiddlewareOption2);
commandStack.add(serializerMiddleware(config, serializer), serializerMiddlewareOption3);
}, "applyToStack")
};
}
__name(getSerdePlugin4, "getSerdePlugin");
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js
var import_middleware_serde, httpAuthSchemeMiddlewareOptions, getHttpAuthSchemePlugin;
var init_getHttpAuthSchemePlugin = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js"() {
import_middleware_serde = __toESM(require_dist_cjs7());
init_httpAuthSchemeMiddleware();
httpAuthSchemeMiddlewareOptions = {
step: "serialize",
tags: ["HTTP_AUTH_SCHEME"],
name: "httpAuthSchemeMiddleware",
override: true,
relation: "before",
toMiddleware: import_middleware_serde.serializerMiddlewareOption.name
};
getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider }) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
httpAuthSchemeParametersProvider,
identityProviderConfigProvider
}), httpAuthSchemeMiddlewareOptions);
}
});
}
});
// node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/index.js
var init_middleware_http_auth_scheme = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/index.js"() {
init_httpAuthSchemeMiddleware();
init_getHttpAuthSchemeEndpointRuleSetPlugin();
init_getHttpAuthSchemePlugin();
}
});
// node_modules/@smithy/core/dist-es/middleware-http-signing/httpSigningMiddleware.js
var import_protocol_http, import_util_middleware2, defaultErrorHandler, defaultSuccessHandler, httpSigningMiddleware;
var init_httpSigningMiddleware = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-signing/httpSigningMiddleware.js"() {
import_protocol_http = __toESM(require_dist_cjs2());
import_util_middleware2 = __toESM(require_dist_cjs6());
defaultErrorHandler = (signingProperties) => (error2) => {
throw error2;
};
defaultSuccessHandler = (httpResponse, signingProperties) => {
};
httpSigningMiddleware = (config) => (next, context) => async (args) => {
if (!import_protocol_http.HttpRequest.isInstance(args.request)) {
return next(args);
}
const smithyContext = (0, import_util_middleware2.getSmithyContext)(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
}
const { httpAuthOption: { signingProperties = {} }, identity, signer } = scheme;
const output = await next({
...args,
request: await signer.sign(args.request, identity, signingProperties)
}).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
(signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
return output;
};
}
});
// node_modules/@smithy/core/dist-es/middleware-http-signing/getHttpSigningMiddleware.js
var httpSigningMiddlewareOptions, getHttpSigningPlugin;
var init_getHttpSigningMiddleware = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-signing/getHttpSigningMiddleware.js"() {
init_httpSigningMiddleware();
httpSigningMiddlewareOptions = {
step: "finalizeRequest",
tags: ["HTTP_SIGNING"],
name: "httpSigningMiddleware",
aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
override: true,
relation: "after",
toMiddleware: "retryMiddleware"
};
getHttpSigningPlugin = (config) => ({
applyToStack: (clientStack) => {
clientStack.addRelativeTo(httpSigningMiddleware(config), httpSigningMiddlewareOptions);
}
});
}
});
// node_modules/@smithy/core/dist-es/middleware-http-signing/index.js
var init_middleware_http_signing = __esm({
"node_modules/@smithy/core/dist-es/middleware-http-signing/index.js"() {
init_httpSigningMiddleware();
init_getHttpSigningMiddleware();
}
});
// node_modules/@smithy/core/dist-es/normalizeProvider.js
var normalizeProvider;
var init_normalizeProvider = __esm({
"node_modules/@smithy/core/dist-es/normalizeProvider.js"() {
normalizeProvider = (input) => {
if (typeof input === "function")
return input;
const promisified = Promise.resolve(input);
return () => promisified;
};
}
});
// node_modules/@smithy/core/dist-es/pagination/createPaginator.js
function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
return async function* paginateOperation(config, input, ...additionalArguments) {
const _input = input;
let token = config.startingToken ?? _input[inputTokenName];
let hasNext = true;
let page;
while (hasNext) {
_input[inputTokenName] = token;
if (pageSizeTokenName) {
_input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
}
if (config.client instanceof ClientCtor) {
page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
} else {
throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
}
yield page;
const prevToken = token;
token = get(page, outputTokenName);
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
return void 0;
};
}
var makePagedClientRequest, get;
var init_createPaginator = __esm({
"node_modules/@smithy/core/dist-es/pagination/createPaginator.js"() {
makePagedClientRequest = async (CommandCtor, client, input, withCommand = (_2) => _2, ...args) => {
let command = new CommandCtor(input);
command = withCommand(command) ?? command;
return await client.send(command, ...args);
};
get = (fromObject, path3) => {
let cursor2 = fromObject;
const pathComponents = path3.split(".");
for (const step of pathComponents) {
if (!cursor2 || typeof cursor2 !== "object") {
return void 0;
}
cursor2 = cursor2[step];
}
return cursor2;
};
}
});
// node_modules/@smithy/is-array-buffer/dist-cjs/index.js
var require_dist_cjs8 = __commonJS({
"node_modules/@smithy/is-array-buffer/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
isArrayBuffer: () => isArrayBuffer
});
module2.exports = __toCommonJS2(index_exports);
var isArrayBuffer = /* @__PURE__ */ __name((arg) => typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer || Object.prototype.toString.call(arg) === "[object ArrayBuffer]", "isArrayBuffer");
}
});
// node_modules/@smithy/util-buffer-from/dist-cjs/index.js
var require_dist_cjs9 = __commonJS({
"node_modules/@smithy/util-buffer-from/dist-cjs/index.js"(exports2, module2) {
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except3, desc2) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except3)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc2(from, key)) || desc2.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export2(index_exports, {
fromArrayBuffer: () => fromArrayBuffer,
fromString: () => fromString
});
module2.exports = __toCommonJS2(index_exports);
var import_is_array_buffer = require_dist_cjs8();
var import_buffer = require("buffer");
var fromArrayBuffer = /* @__PURE__ */ __name((input, offset = 0, length = input.byteLength - offset) => {
if (!(0, import_is_array_buffer.isArrayBuffer)(input)) {
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
}
return import_buffer.Buffer.from(input, offset, length);
}, "fromArrayBuffer");
var fromString = /* @__PURE__ */ __name((input, encoding) => {
if (typeof input !== "string") {
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
}
return enc