@aws-cdk/integ-tests-alpha
Version:
CDK Integration Testing Constructs
1,373 lines (1,360 loc) • 2.16 MB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// ../../aws-cdk-lib/assertions/lib/matcher.ts
var matcher_exports = {};
__export(matcher_exports, {
MatchResult: () => MatchResult,
Matcher: () => Matcher
});
function* range(n) {
for (let i = 0; i < n; i++) {
yield i;
}
}
function* enumFirst(xs) {
let first = true;
for (const x of xs) {
yield [first, x];
first = false;
}
}
var Matcher, MatchResult;
var init_matcher = __esm({
"../../aws-cdk-lib/assertions/lib/matcher.ts"() {
"use strict";
Matcher = class _Matcher {
/**
* Check whether the provided object is a subtype of the `IMatcher`.
*/
static isMatcher(x) {
return x && x instanceof _Matcher;
}
};
MatchResult = class {
/**
* The target for which this result was generated.
*/
target;
failuresHere = /* @__PURE__ */ new Map();
captures = /* @__PURE__ */ new Map();
finalized = false;
innerMatchFailures = /* @__PURE__ */ new Map();
_hasFailed = false;
_failCount = 0;
_cost = 0;
constructor(target) {
this.target = target;
}
/**
* DEPRECATED
* @deprecated use recordFailure()
*/
push(matcher, path, message) {
return this.recordFailure({ matcher, path, message });
}
/**
* Record a new failure into this result at a specific path.
*/
recordFailure(failure) {
const failKey = failure.path.join(".");
let list = this.failuresHere.get(failKey);
if (!list) {
list = [];
this.failuresHere.set(failKey, list);
}
this._failCount += 1;
this._cost += failure.cost ?? 1;
list.push(failure);
this._hasFailed = true;
return this;
}
/** Whether the match is a success */
get isSuccess() {
return !this._hasFailed;
}
/** Does the result contain any failures. If not, the result is a success */
hasFailed() {
return this._hasFailed;
}
/** The number of failures */
get failCount() {
return this._failCount;
}
/** The cost of the failures so far */
get failCost() {
return this._cost;
}
/**
* Compose the results of a previous match as a subtree.
* @param id the id of the parent tree.
*/
compose(id, inner) {
if (inner.hasFailed()) {
this._hasFailed = true;
this._failCount += inner.failCount;
this._cost += inner._cost;
this.innerMatchFailures.set(id, inner);
}
inner.captures.forEach((vals, capture) => {
vals.forEach((value) => this.recordCapture({ capture, value }));
});
return this;
}
/**
* Prepare the result to be analyzed.
* This API *must* be called prior to analyzing these results.
*/
finished() {
if (this.finalized) {
return this;
}
if (this.failCount === 0) {
this.captures.forEach((vals, cap) => cap._captured.push(...vals));
}
this.finalized = true;
return this;
}
/**
* Render the failed match in a presentable way
*
* Prefer using `renderMismatch` over this method. It is left for backwards
* compatibility for test suites that expect it, but `renderMismatch()` will
* produce better output.
*/
toHumanStrings() {
const failures = new Array();
recurse(this, []);
return failures.map((r) => {
const loc = r.path.length === 0 ? "" : ` at /${r.path.join("/")}`;
return "" + r.message + loc + ` (using ${r.matcher.name} matcher)`;
});
function recurse(x, prefix) {
for (const fail of Array.from(x.failuresHere.values()).flat()) {
failures.push({
matcher: fail.matcher,
message: fail.message,
path: [...prefix, ...fail.path]
});
}
for (const [key, inner] of x.innerMatchFailures.entries()) {
recurse(inner, [...prefix, key]);
}
}
}
/**
* Do a deep render of the match result, showing the structure mismatches in context
*/
renderMismatch() {
if (!this.hasFailed()) {
return "<match>";
}
const parts = new Array();
const indents = new Array();
emitFailures(this, "");
recurse(this);
return moveMarkersToFront(parts.join("").trimEnd());
function emit(x) {
if (x === void 0) {
debugger;
}
parts.push(x.replace(/\n/g, `
${indents.join("")}`));
}
function emitFailures(r, path, scrapSet) {
for (const fail of r.failuresHere.get(path) ?? []) {
emit(`!! ${fail.message}
`);
}
scrapSet?.delete(path);
}
function recurse(r) {
const remainingFailures = new Set(Array.from(r.failuresHere.keys()).filter((x) => x !== ""));
if (Array.isArray(r.target)) {
indents.push(" ");
emit("[\n");
for (const [first, i] of enumFirst(range(r.target.length))) {
if (!first) {
emit(",\n");
}
emitFailures(r, `${i}`, remainingFailures);
const innerMatcher = r.innerMatchFailures.get(`${i}`);
if (innerMatcher) {
emitFailures(innerMatcher, "");
recurseComparingValues(innerMatcher, r.target[i]);
} else {
emit(renderAbridged(r.target[i]));
}
}
emitRemaining();
indents.pop();
emit("\n]");
return;
}
if (r.target && typeof r.target === "object") {
indents.push(" ");
emit("{\n");
const keys = Array.from(/* @__PURE__ */ new Set([
...Object.keys(r.target),
...Array.from(remainingFailures)
])).sort();
for (const [first, key] of enumFirst(keys)) {
if (!first) {
emit(",\n");
}
emitFailures(r, key, remainingFailures);
const innerMatcher = r.innerMatchFailures.get(key);
if (innerMatcher) {
emitFailures(innerMatcher, "");
emit(`${jsonify(key)}: `);
recurseComparingValues(innerMatcher, r.target[key]);
} else {
emit(`${jsonify(key)}: `);
emit(renderAbridged(r.target[key]));
}
}
emitRemaining();
indents.pop();
emit("\n}");
return;
}
emitRemaining();
emit(jsonify(r.target));
function emitRemaining() {
if (remainingFailures.size > 0) {
emit("\n");
}
for (const key of remainingFailures) {
emitFailures(r, key);
}
}
}
function recurseComparingValues(inner, actualValue) {
if (inner.target === actualValue) {
return recurse(inner);
}
emit(renderAbridged(actualValue));
emit(" <*> ");
recurse(inner);
}
function renderAbridged(x) {
if (Array.isArray(x)) {
switch (x.length) {
case 0:
return "[]";
case 1:
return `[ ${renderAbridged(x[0])} ]`;
case 2:
if (x.every((e) => ["number", "boolean", "string"].includes(typeof e))) {
return `[ ${x.map(renderAbridged).join(", ")} ]`;
}
return "[ ... ]";
default:
return "[ ... ]";
}
}
if (x && typeof x === "object") {
const keys = Object.keys(x);
switch (keys.length) {
case 0:
return "{}";
case 1:
return `{ ${JSON.stringify(keys[0])}: ${renderAbridged(x[keys[0]])} }`;
default:
return "{ ... }";
}
}
return jsonify(x);
}
function jsonify(x) {
return JSON.stringify(x) ?? "undefined";
}
function moveMarkersToFront(x) {
const re = /^(\s+)!!/gm;
return x.replace(re, (_, spaces) => `!!${spaces.substring(0, spaces.length - 2)}`);
}
}
/**
* Record a capture against in this match result.
*/
recordCapture(options) {
let values = this.captures.get(options.capture);
if (values === void 0) {
values = [];
}
values.push(options.value);
this.captures.set(options.capture, values);
}
};
}
});
// ../../aws-cdk-lib/assertions/lib/private/error.ts
var ASSERTION_ERROR_SYMBOL, AssertionError;
var init_error = __esm({
"../../aws-cdk-lib/assertions/lib/private/error.ts"() {
"use strict";
ASSERTION_ERROR_SYMBOL = Symbol.for("@aws-cdk/assertions.AssertionError");
AssertionError = class _AssertionError extends Error {
#time;
/**
* The time the error was thrown.
*/
get time() {
return this.#time;
}
get type() {
return "assertion";
}
constructor(msg) {
super(msg);
Object.setPrototypeOf(this, _AssertionError.prototype);
Object.defineProperty(this, ASSERTION_ERROR_SYMBOL, { value: true });
this.name = new.target.name;
this.#time = (/* @__PURE__ */ new Date()).toISOString();
}
};
}
});
// ../../aws-cdk-lib/assertions/lib/private/matchers/absent.ts
var AbsentMatch;
var init_absent = __esm({
"../../aws-cdk-lib/assertions/lib/private/matchers/absent.ts"() {
"use strict";
init_matcher();
AbsentMatch = class extends Matcher {
constructor(name) {
super();
this.name = name;
}
test(actual) {
const result = new MatchResult(actual);
if (actual !== void 0) {
result.recordFailure({
matcher: this,
path: [],
message: `Received ${actual}, but key should be absent`
});
}
return result;
}
};
}
});
// ../../aws-cdk-lib/assertions/lib/private/sorting.ts
function sortKeyComparator(keyFn) {
return (a, b) => {
const ak = keyFn(a);
const bk = keyFn(b);
for (let i = 0; i < ak.length && i < bk.length; i++) {
const av = ak[i];
const bv = bk[i];
let diff = 0;
if (typeof av === "number" && typeof bv === "number") {
diff = av - bv;
} else if (typeof av === "string" && typeof bv === "string") {
diff = av.localeCompare(bv);
}
if (diff !== 0) {
return diff;
}
}
return bk.length - ak.length;
};
}
var init_sorting = __esm({
"../../aws-cdk-lib/assertions/lib/private/sorting.ts"() {
"use strict";
}
});
// ../../aws-cdk-lib/assertions/lib/private/sparse-matrix.ts
var SparseMatrix;
var init_sparse_matrix = __esm({
"../../aws-cdk-lib/assertions/lib/private/sparse-matrix.ts"() {
"use strict";
SparseMatrix = class {
matrix = /* @__PURE__ */ new Map();
get(row, col) {
return this.matrix.get(row)?.get(col);
}
row(row) {
return Array.from(this.matrix.get(row)?.entries() ?? []);
}
set(row, col, value) {
let r = this.matrix.get(row);
if (!r) {
r = /* @__PURE__ */ new Map();
this.matrix.set(row, r);
}
r.set(col, value);
}
};
}
});
// ../../aws-cdk-lib/assertions/lib/private/type.ts
function getType(obj) {
return Array.isArray(obj) ? "array" : typeof obj;
}
var init_type = __esm({
"../../aws-cdk-lib/assertions/lib/private/type.ts"() {
"use strict";
}
});
// ../../aws-cdk-lib/assertions/lib/match.ts
var match_exports = {};
__export(match_exports, {
Match: () => Match
});
var Match, LiteralMatch, ArrayMatch, ObjectMatch, SerializedJson, NotMatch, AnyMatch, StringLikeRegexpMatch;
var init_match = __esm({
"../../aws-cdk-lib/assertions/lib/match.ts"() {
"use strict";
init_matcher();
init_error();
init_absent();
init_sorting();
init_sparse_matrix();
init_type();
Match = class {
/**
* Use this matcher in the place of a field's value, if the field must not be present.
*/
static absent() {
return new AbsentMatch("absent");
}
/**
* Matches the specified pattern with the array found in the same relative path of the target.
* The set of elements (or matchers) must be in the same order as would be found.
* @param pattern the pattern to match
*/
static arrayWith(pattern) {
return new ArrayMatch("arrayWith", pattern);
}
/**
* Matches the specified pattern with the array found in the same relative path of the target.
* The set of elements (or matchers) must match exactly and in order.
* @param pattern the pattern to match
*/
static arrayEquals(pattern) {
return new ArrayMatch("arrayEquals", pattern, { subsequence: false });
}
/**
* Deep exact matching of the specified pattern to the target.
* @param pattern the pattern to match
*/
static exact(pattern) {
return new LiteralMatch("exact", pattern, { partialObjects: false });
}
/**
* Matches the specified pattern to an object found in the same relative path of the target.
* The keys and their values (or matchers) must be present in the target but the target can be a superset.
* @param pattern the pattern to match
*/
static objectLike(pattern) {
return new ObjectMatch("objectLike", pattern);
}
/**
* Matches the specified pattern to an object found in the same relative path of the target.
* The keys and their values (or matchers) must match exactly with the target.
* @param pattern the pattern to match
*/
static objectEquals(pattern) {
return new ObjectMatch("objectEquals", pattern, { partial: false });
}
/**
* Matches any target which does NOT follow the specified pattern.
* @param pattern the pattern to NOT match
*/
static not(pattern) {
return new NotMatch("not", pattern);
}
/**
* Matches any string-encoded JSON and applies the specified pattern after parsing it.
* @param pattern the pattern to match after parsing the encoded JSON.
*/
static serializedJson(pattern) {
return new SerializedJson("serializedJson", pattern);
}
/**
* Matches any non-null value at the target.
*/
static anyValue() {
return new AnyMatch("anyValue");
}
/**
* Matches targets according to a regular expression
*/
static stringLikeRegexp(pattern) {
return new StringLikeRegexpMatch("stringLikeRegexp", pattern);
}
};
LiteralMatch = class extends Matcher {
constructor(name, pattern, options = {}) {
super();
this.name = name;
this.pattern = pattern;
this.partialObjects = options.partialObjects ?? false;
if (Matcher.isMatcher(this.pattern)) {
throw new AssertionError("LiteralMatch cannot directly contain another matcher. Remove the top-level matcher or nest it more deeply.");
}
}
partialObjects;
test(actual) {
if (Array.isArray(this.pattern)) {
return new ArrayMatch(this.name, this.pattern, { subsequence: false, partialObjects: this.partialObjects }).test(actual);
}
if (typeof this.pattern === "object") {
return new ObjectMatch(this.name, this.pattern, { partial: this.partialObjects }).test(actual);
}
const result = new MatchResult(actual);
if (typeof this.pattern !== typeof actual) {
result.recordFailure({
matcher: this,
path: [],
message: `Expected type ${typeof this.pattern} but received ${getType(actual)}`
});
return result;
}
if (actual !== this.pattern) {
result.recordFailure({
matcher: this,
path: [],
message: `Expected ${this.pattern} but received ${actual}`
});
}
return result;
}
};
ArrayMatch = class extends Matcher {
constructor(name, pattern, options = {}) {
super();
this.name = name;
this.pattern = pattern;
this.subsequence = options.subsequence ?? true;
this.partialObjects = options.partialObjects ?? false;
}
subsequence;
partialObjects;
test(actual) {
if (!Array.isArray(actual)) {
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Expected type array but received ${getType(actual)}`
});
}
return this.subsequence ? this.testSubsequence(actual) : this.testFullArray(actual);
}
testFullArray(actual) {
const result = new MatchResult(actual);
let i = 0;
for (; i < this.pattern.length && i < actual.length; i++) {
const patternElement = this.pattern[i];
const matcher = Matcher.isMatcher(patternElement) ? patternElement : new LiteralMatch(this.name, patternElement, { partialObjects: this.partialObjects });
const innerResult = matcher.test(actual[i]);
result.compose(`${i}`, innerResult);
}
if (i < this.pattern.length) {
result.recordFailure({
matcher: this,
message: `Not enough elements in array (expecting ${this.pattern.length}, got ${actual.length})`,
path: [`${i}`]
});
}
if (i < actual.length) {
result.recordFailure({
matcher: this,
message: `Too many elements in array (expecting ${this.pattern.length}, got ${actual.length})`,
path: [`${i}`]
});
}
return result;
}
testSubsequence(actual) {
const result = new MatchResult(actual);
let patternIdx = 0;
let actualIdx = 0;
const matches = new SparseMatrix();
while (patternIdx < this.pattern.length && actualIdx < actual.length) {
const patternElement = this.pattern[patternIdx];
const matcher = Matcher.isMatcher(patternElement) ? patternElement : new LiteralMatch(this.name, patternElement, { partialObjects: this.partialObjects });
const matcherName = matcher.name;
if (matcherName == "absent" || matcherName == "anyValue") {
throw new AssertionError(`The Matcher ${matcherName}() cannot be nested within arrayWith()`);
}
const innerResult = matcher.test(actual[actualIdx]);
matches.set(patternIdx, actualIdx, innerResult);
actualIdx++;
if (innerResult.isSuccess) {
result.compose(`${actualIdx}`, innerResult);
patternIdx++;
}
}
if (patternIdx < this.pattern.length) {
for (let spi = 0; spi < patternIdx; spi++) {
const foundMatch = matches.row(spi).find(([, r]) => r.isSuccess);
if (!foundMatch) {
continue;
}
const [index] = foundMatch;
result.compose(`${index}`, new MatchResult(actual[index]).recordFailure({
matcher: this,
message: `arrayWith pattern ${spi} matched here`,
path: [],
cost: 0
// This is an informational message so it would be unfair to assign it cost
}));
}
const failedMatches = matches.row(patternIdx);
failedMatches.sort(sortKeyComparator(([i, r]) => [r.failCost, i]));
if (failedMatches.length > 0) {
const [index, innerResult] = failedMatches[0];
result.recordFailure({
matcher: this,
message: `Could not match arrayWith pattern ${patternIdx}. This is the closest match`,
path: [`${index}`],
cost: 0
// Informational message
});
result.compose(`${index}`, innerResult);
} else {
result.recordFailure({
matcher: this,
message: `Could not match arrayWith pattern ${patternIdx}. No more elements to try`,
path: [`${actual.length}`]
});
}
}
return result;
}
};
ObjectMatch = class extends Matcher {
constructor(name, pattern, options = {}) {
super();
this.name = name;
this.pattern = pattern;
this.partial = options.partial ?? true;
}
partial;
test(actual) {
if (typeof actual !== "object" || Array.isArray(actual)) {
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Expected type object but received ${getType(actual)}`
});
}
const result = new MatchResult(actual);
if (!this.partial) {
for (const a of Object.keys(actual)) {
if (!(a in this.pattern)) {
result.recordFailure({
matcher: this,
path: [a],
message: `Unexpected key ${a}`
});
}
}
}
for (const [patternKey, patternVal] of Object.entries(this.pattern)) {
if (!(patternKey in actual) && !(patternVal instanceof AbsentMatch)) {
result.recordFailure({
matcher: this,
path: [patternKey],
message: `Missing key '${patternKey}'`
});
continue;
}
const matcher = Matcher.isMatcher(patternVal) ? patternVal : new LiteralMatch(this.name, patternVal, { partialObjects: this.partial });
const inner = matcher.test(actual[patternKey]);
result.compose(patternKey, inner);
}
return result;
}
};
SerializedJson = class extends Matcher {
constructor(name, pattern) {
super();
this.name = name;
this.pattern = pattern;
}
test(actual) {
if (getType(actual) !== "string") {
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Expected JSON as a string but found ${getType(actual)}`
});
}
let parsed;
try {
parsed = JSON.parse(actual);
} catch (err) {
if (err instanceof SyntaxError) {
return new MatchResult(actual).recordFailure({
matcher: this,
path: [],
message: `Invalid JSON string: ${actual}`
});
} else {
throw err;
}
}
const matcher = Matcher.isMatcher(this.pattern) ? this.pattern : new LiteralMatch(this.name, this.pattern);
const innerResult = matcher.test(parsed);
if (innerResult.hasFailed()) {
innerResult.recordFailure({
matcher: this,
path: [],
message: "Encoded JSON value does not match"
});
}
return innerResult;
}
};
NotMatch = class extends Matcher {
constructor(name, pattern) {
super();
this.name = name;
this.pattern = pattern;
}
test(actual) {
const matcher = Matcher.isMatcher(this.pattern) ? this.pattern : new LiteralMatch(this.name, this.pattern);
const innerResult = matcher.test(actual);
const result = new MatchResult(actual);
if (innerResult.failCount === 0) {
result.recordFailure({
matcher: this,
path: [],
message: `Found unexpected match: ${JSON.stringify(actual, void 0, 2)}`
});
}
return result;
}
};
AnyMatch = class extends Matcher {
constructor(name) {
super();
this.name = name;
}
test(actual) {
const result = new MatchResult(actual);
if (actual == null) {
result.recordFailure({
matcher: this,
path: [],
message: "Expected a value but found none"
});
}
return result;
}
};
StringLikeRegexpMatch = class extends Matcher {
constructor(name, pattern) {
super();
this.name = name;
this.pattern = pattern;
}
test(actual) {
const result = new MatchResult(actual);
const regex = new RegExp(this.pattern, "gm");
if (typeof actual !== "string") {
result.recordFailure({
matcher: this,
path: [],
message: `Expected a string, but got '${typeof actual}'`
});
}
if (!regex.test(actual)) {
result.recordFailure({
matcher: this,
path: [],
message: `String '${actual}' did not match pattern '${this.pattern}'`
});
}
return result;
}
};
}
});
// ../../aws-cdk-lib/assertions/lib/helpers-internal/index.js
var require_helpers_internal = __commonJS({
"../../aws-cdk-lib/assertions/lib/helpers-internal/index.js"(exports2) {
"use strict";
var __createBinding2 = exports2 && exports2.__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];
}));
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 });
var _noFold;
exports2.Match = void 0;
Object.defineProperty(exports2, _noFold = "Match", { enumerable: true, configurable: true, get: () => {
var value = (init_match(), __toCommonJS(match_exports)).Match;
Object.defineProperty(exports2, _noFold = "Match", { enumerable: true, configurable: true, value });
return value;
} });
exports2.Matcher = void 0;
Object.defineProperty(exports2, _noFold = "Matcher", { enumerable: true, configurable: true, get: () => {
var value = (init_matcher(), __toCommonJS(matcher_exports)).Matcher;
Object.defineProperty(exports2, _noFold = "Matcher", { enumerable: true, configurable: true, value });
return value;
} });
exports2.MatchResult = void 0;
Object.defineProperty(exports2, _noFold = "MatchResult", { enumerable: true, configurable: true, get: () => {
var value = (init_matcher(), __toCommonJS(matcher_exports)).MatchResult;
Object.defineProperty(exports2, _noFold = "MatchResult", { enumerable: true, configurable: true, value });
return value;
} });
}
});
// ../../../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, 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 });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export2(src_exports, {
AlgorithmId: () => AlgorithmId,
EndpointURLScheme: () => EndpointURLScheme,
FieldPosition: () => FieldPosition,
HttpApiKeyAuthLocation: () => HttpApiKeyAuthLocation2,
HttpAuthLocation: () => HttpAuthLocation,
IniSectionType: () => IniSectionType,
RequestHandlerProtocol: () => RequestHandlerProtocol,
SMITHY_CONTEXT_KEY: () => SMITHY_CONTEXT_KEY4,
getDefaultClientConfiguration: () => getDefaultClientConfiguration,
resolveDefaultRuntimeConfig: () => resolveDefaultRuntimeConfig
});
module2.exports = __toCommonJS2(src_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: () => "sha256",
checksumConstructor: () => runtimeConfig.sha256
});
}
if (runtimeConfig.md5 != void 0) {
checksumAlgorithms.push({
algorithmId: () => "md5",
checksumConstructor: () => runtimeConfig.md5
});
}
return {
_checksumAlgorithms: checksumAlgorithms,
addChecksumAlgorithm(algo) {
this._checksumAlgorithms.push(algo);
},
checksumAlgorithms() {
return this._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 resolveDefaultRuntimeConfig = /* @__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_KEY4 = "__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, 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 });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export2(src_exports, {
Field: () => Field,
Fields: () => Fields,
HttpRequest: () => HttpRequest7,
HttpResponse: () => HttpResponse2,
IHttpRequest: () => import_types5.HttpRequest,
getHttpHandlerExtensionConfiguration: () => getHttpHandlerExtensionConfiguration,
isValidHostname: () => isValidHostname,
resolveHttpHandlerRuntimeConfig: () => resolveHttpHandlerRuntimeConfig
});
module2.exports = __toCommonJS2(src_exports);
var getHttpHandlerExtensionConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
let httpHandler = runtimeConfig.httpHandler;
return {
setHttpHandler(handler2) {
httpHandler = handler2;
},
httpHandler() {
return httpHandler;
},
updateHttpClientConfig(key, value) {
httpHandler.updateHttpClientConfig(key, value);
},
httpHandlerConfigs() {
return httpHandler.httpHandlerConfigs();
}
};
}, "getHttpHandlerExtensionConfiguration");
var resolveHttpHandlerRuntimeConfig = /* @__PURE__ */ __name((httpHandlerExtensionConfiguration) => {
return {
httpHandler: httpHandlerExtensionConfiguration.httpHandler()
};
}, "resolveHttpHandlerRuntimeConfig");
var import_types5 = require_dist_cjs();
var _Field = class _Field {
constructor({ name, kind = import_types5.FieldPosition.HEADER, values = [] }) {
this.name = name;
this.kind = kind;
this.values = values;
}
/**
* 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(values) {
this.values = values;
}
/**
* Remove all matching entries from list.
*
* @param value Value to remove.
*/
remove(value) {
this.values = this.values.filter((v) => v !== value);
}
/**
* Get comma-delimited string.
*
* @returns String representation of {@link Field}.
*/
toString() {
return this.values.map((v) => v.includes(",") || v.includes(" ") ? `"${v}"` : v).join(", ");
}
/**
* Get string values as a list
*
* @returns Values in {@link Field} as a list.
*/
get() {
return this.values;
}
};
__name(_Field, "Field");
var Field = _Field;
var _Fields = class _Fields {
constructor({ fields = [], encoding = "utf-8" }) {
this.entries = {};
fields.forEach(this.setField.bind(this));
this.encoding = encoding;
}
/**
* 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);
}
};
__name(_Fields, "Fields");
var Fields = _Fields;
var _HttpRequest = class _HttpRequest2 {
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(request2) {
const cloned = new _HttpRequest2({
...request2,
headers: { ...request2.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(request2) {
if (!request2) {
return false;
}
const req = request2;
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 _HttpRequest2.clone(this);
}
};
__name(_HttpRequest, "HttpRequest");
var HttpRequest7 = _HttpRequest;
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 _HttpResponse = class _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";
}
};
__name(_HttpResponse, "HttpResponse");
var HttpResponse2 = _HttpResponse;
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, 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 });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export2(src_exports, {
getHostHeaderPlugin: () => getHostHeaderPlugin,
hostHeaderMiddleware: () => hostHeaderMiddleware,
hostHeaderMiddlewareOptions: () => hostHeaderMiddlewareOptions,
resolveHostHeaderConfig: () => resolveHostHeaderConfig
});
module2.exports = __toCommonJS2(src_exports);
var import_protocol_http8 = require_dist_cjs2();
function resolveHostHeaderConfig(input) {
return input;
}
__name(resolveHostHeaderConfig, "resolveHostHeaderConfig");
var hostHeaderMiddleware = /* @__PURE__ */ __name((options) => (next) => async (args) => {
if (!import_protocol_http8.HttpRequest.isInstance(args.request))
return next(args);
const { request: request2 } = args;
const { handlerProtocol = "" } = options.requestHandler.metadata || {};
if (handlerProtocol.indexOf("h2") >= 0 && !request2.headers[":authority"]) {
delete request2.headers["host"];
request2.headers[":authority"] = request2.hostname + (request2.port ? ":" + request2.port : "");
} else if (!request2.headers["host"]) {
let host = request2.hostname;
if (request2.port != null)
host += `:${request2.port}`;
request2.headers["host"] = host;
}
return next(args);
}, "hostHeaderMiddleware");
var hostHeaderMiddlewareOptions = {
name: "hostHeaderMiddleware",
step: "build",
priority: "low",
tags: ["HOST"],
override: true
};
var getHostHeaderPlugin = /* @__PURE__ */ __name((options) => ({
applyToStack: (clientStack) => {
clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
}
}), "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, 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 });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export2(src_exports, {
getLoggerPlugin: () => getLoggerPlugin,
loggerMiddleware: () => loggerMiddleware,
loggerMiddlewareOptions: () => loggerMiddlewareOptions
});
module2.exports = __toCommonJS2(src_exports);
var loggerMiddleware = /* @__PURE__ */ __name(() => (next, context) => async (args) => {
var _a, _b;
try {
const response = await next(args);
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
const { $metadata, ...outputWithoutMetadata } = response.output;
(_a = logger == null ? void 0 : logger.info) == null ? void 0 : _a.call(logger, {
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
output: outputFilterSensitiveLog(outputWithoutMetadata),
metadata: $metadata
});
return response;
} catch (error) {
const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
(_b = logger == null ? void 0 : logger.error) == null ? void 0 : _b.call(logger, {
clientName,
commandName,
input: inputFilterSensitiveLog(args.input),
error,
metadata: error.$metadata
});
throw error;
}
}, "loggerMiddleware");
var loggerMiddlewareOptions = {
name: "loggerMiddleware",
tags: ["LOGGER"],
step: "initialize",
override: true
};
var getLoggerPlugin = /* @__PURE__ */ __name((options) => ({
applyToStack: (clientStack) => {
clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
}
}), "getLoggerPlugin");
}
});
// ../../../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