UNPKG

serverless-spy

Version:

CDK-based library for writing elegant integration tests on AWS serverless architecture and an additional web console to monitor events in real time.

1,428 lines (1,406 loc) 1.67 MB
"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); // extension/aws/Errors.js var require_Errors = __commonJS({ "extension/aws/Errors.js"(exports2, module2) { "use strict"; var util = require("util"); function _isError(obj) { return obj && obj.name && obj.message && obj.stack && typeof obj.name === "string" && typeof obj.message === "string" && typeof obj.stack === "string"; } function intoError(err) { if (err instanceof Error) { return err; } else { return new Error(err); } } module2.exports.intoError = intoError; function toRapidResponse(error) { try { if (util.types.isNativeError(error) || _isError(error)) { return { errorType: error.name, errorMessage: error.message, trace: error.stack.split("\n") }; } else { return { errorType: typeof error, errorMessage: error.toString(), trace: [] }; } } catch (_err) { return { errorType: "handled", errorMessage: "callback called with Error argument, but there was a problem while retrieving one or more of its message, name, and stack" }; } } module2.exports.toRapidResponse = toRapidResponse; module2.exports.toFormatted = (error) => { try { return " " + JSON.stringify(error, (_k, v) => _withEnumerableProperties(v)); } catch (err) { return " " + JSON.stringify(toRapidResponse(error)); } }; function _withEnumerableProperties(error) { if (error instanceof Error) { let ret = Object.assign( { errorType: error.name, errorMessage: error.message, code: error.code }, error ); if (typeof error.stack == "string") { ret.stack = error.stack.split("\n"); } return ret; } else { return error; } } var errorClasses = [ class ImportModuleError extends Error { }, class HandlerNotFound extends Error { }, class MalformedHandlerName extends Error { }, class UserCodeSyntaxError extends Error { }, class MalformedStreamingHandler extends Error { }, class InvalidStreamingOperation extends Error { }, class UnhandledPromiseRejection extends Error { constructor(reason, promise) { super(reason); this.reason = reason; this.promise = promise; } } ]; errorClasses.forEach((e) => { module2.exports[e.name] = e; e.prototype.name = `Runtime.${e.name}`; }); } }); // extension/aws/VerboseLog.js var require_VerboseLog = __commonJS({ "extension/aws/VerboseLog.js"(exports2) { "use strict"; var EnvVarName = "AWS_LAMBDA_RUNTIME_VERBOSE"; var Tag = "RUNTIME"; var Verbosity = (() => { if (!process.env[EnvVarName]) { return 0; } try { const verbosity = parseInt(process.env[EnvVarName]); return verbosity < 0 ? 0 : verbosity > 3 ? 3 : verbosity; } catch (_) { return 0; } })(); exports2.logger = function(category) { return { verbose: function() { if (Verbosity >= 1) { const args = [...arguments].map( (arg) => typeof arg === "function" ? arg() : arg ); console.log.apply(null, [Tag, category, ...args]); } }, vverbose: function() { if (Verbosity >= 2) { const args = [...arguments].map( (arg) => typeof arg === "function" ? arg() : arg ); console.log.apply(null, [Tag, category, ...args]); } }, vvverbose: function() { if (Verbosity >= 3) { const args = [...arguments].map( (arg) => typeof arg === "function" ? arg() : arg ); console.log.apply(null, [Tag, category, ...args]); } } }; }; } }); // extension/aws/HttpResponseStream.js var require_HttpResponseStream = __commonJS({ "extension/aws/HttpResponseStream.js"(exports2, module2) { "use strict"; var METADATA_PRELUDE_CONTENT_TYPE = "application/vnd.awslambda.http-integration-response"; var DELIMITER_LEN = 8; var HttpResponseStream = class { static from(underlyingStream, prelude) { underlyingStream.setContentType(METADATA_PRELUDE_CONTENT_TYPE); const metadataPrelude = JSON.stringify(prelude); underlyingStream._onBeforeFirstWrite = (write) => { write(metadataPrelude); write(new Uint8Array(DELIMITER_LEN)); }; return underlyingStream; } }; module2.exports.HttpResponseStream = HttpResponseStream; } }); // extension/aws/UserFunction.js var require_UserFunction = __commonJS({ "extension/aws/UserFunction.js"(exports2, module2) { "use strict"; var path = require("path"); var fs = require("fs"); var { HandlerNotFound, MalformedHandlerName, ImportModuleError, UserCodeSyntaxError } = require_Errors(); var { verbose } = require_VerboseLog().logger("LOADER"); var { HttpResponseStream } = require_HttpResponseStream(); var FUNCTION_EXPR = /^([^.]*)\.(.*)$/; var RELATIVE_PATH_SUBSTRING = ".."; var HANDLER_STREAMING = Symbol.for("aws.lambda.runtime.handler.streaming"); var HANDLER_HIGHWATERMARK = Symbol.for( "aws.lambda.runtime.handler.streaming.highWaterMark" ); var STREAM_RESPONSE = "response"; var NoGlobalAwsLambda = process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "1" || process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "true"; function _moduleRootAndHandler(fullHandlerString) { let handlerString = path.basename(fullHandlerString); let moduleRoot = fullHandlerString.substring( 0, fullHandlerString.indexOf(handlerString) ); return [moduleRoot, handlerString]; } function _splitHandlerString(handler2) { let match = handler2.match(FUNCTION_EXPR); if (!match || match.length != 3) { throw new MalformedHandlerName("Bad handler"); } return [match[1], match[2]]; } function _resolveHandler(object, nestedProperty) { return nestedProperty.split(".").reduce((nested, key) => { return nested && nested[key]; }, object); } function _tryRequireFile(file, extension) { const path2 = file + (extension || ""); verbose("Try loading as commonjs:", path2); return fs.existsSync(path2) ? require(path2) : void 0; } async function _tryAwaitImport(file, extension) { const path2 = file + (extension || ""); verbose("Try loading as esmodule:", path2); if (fs.existsSync(path2)) { return await import(path2); } return void 0; } function _hasFolderPackageJsonTypeModule(folder) { if (folder.endsWith("/node_modules")) { return false; } const pj = path.join(folder, "/package.json"); if (fs.existsSync(pj)) { try { const pkg = JSON.parse(fs.readFileSync(pj)); if (pkg) { if (pkg.type === "module") { verbose("type: module detected in", pj); return true; } else { verbose("type: module not detected in", pj); return false; } } } catch (e) { console.warn( `${pj} cannot be read, it will be ignored for ES module detection purposes.`, e ); return false; } } if (folder === "/") { return false; } return _hasFolderPackageJsonTypeModule(path.resolve(folder, "..")); } function _hasPackageJsonTypeModule(file) { const jsPath = file + ".js"; return fs.existsSync(jsPath) ? _hasFolderPackageJsonTypeModule(path.resolve(path.dirname(jsPath))) : false; } async function _tryRequire(appRoot, moduleRoot, module3) { verbose( "Try loading as commonjs: ", module3, " with paths: ,", appRoot, moduleRoot ); const lambdaStylePath = path.resolve(appRoot, moduleRoot, module3); const extensionless = _tryRequireFile(lambdaStylePath); if (extensionless) { return extensionless; } const pjHasModule = _hasPackageJsonTypeModule(lambdaStylePath); if (!pjHasModule) { const loaded2 = _tryRequireFile(lambdaStylePath, ".js"); if (loaded2) { return loaded2; } } const loaded = pjHasModule && await _tryAwaitImport(lambdaStylePath, ".js") || await _tryAwaitImport(lambdaStylePath, ".mjs") || _tryRequireFile(lambdaStylePath, ".cjs"); if (loaded) { return loaded; } verbose( "Try loading as commonjs: ", module3, " with path(s): ", appRoot, moduleRoot ); const nodeStylePath = require.resolve(module3, { paths: [appRoot, moduleRoot] }); return require(nodeStylePath); } async function _loadUserApp(appRoot, moduleRoot, module3) { if (!NoGlobalAwsLambda) { globalThis.awslambda = { streamifyResponse: (handler2, options) => { handler2[HANDLER_STREAMING] = STREAM_RESPONSE; if (typeof options?.highWaterMark === "number") { handler2[HANDLER_HIGHWATERMARK] = parseInt(options.highWaterMark); } return handler2; }, HttpResponseStream }; } try { return await _tryRequire(appRoot, moduleRoot, module3); } catch (e) { if (e instanceof SyntaxError) { throw new UserCodeSyntaxError(e); } else if (e.code !== void 0 && e.code === "MODULE_NOT_FOUND") { verbose("globalPaths", JSON.stringify(require("module").globalPaths)); throw new ImportModuleError(e); } else { throw e; } } } function _throwIfInvalidHandler(fullHandlerString) { if (fullHandlerString.includes(RELATIVE_PATH_SUBSTRING)) { throw new MalformedHandlerName( `'${fullHandlerString}' is not a valid handler name. Use absolute paths when specifying root directories in handler names.` ); } } function _isHandlerStreaming(handler2) { if (typeof handler2[HANDLER_STREAMING] === "undefined" || handler2[HANDLER_STREAMING] === null || handler2[HANDLER_STREAMING] === false) { return false; } if (handler2[HANDLER_STREAMING] === STREAM_RESPONSE) { return STREAM_RESPONSE; } else { throw new MalformedStreamingHandler( "Only response streaming is supported." ); } } function _highWaterMark(handler2) { if (typeof handler2[HANDLER_HIGHWATERMARK] === "undefined" || handler2[HANDLER_HIGHWATERMARK] === null || handler2[HANDLER_HIGHWATERMARK] === false) { return void 0; } const hwm = parseInt(handler2[HANDLER_HIGHWATERMARK]); return isNaN(hwm) ? void 0 : hwm; } module2.exports.load = async function(appRoot, fullHandlerString) { _throwIfInvalidHandler(fullHandlerString); let [moduleRoot, moduleAndHandler] = _moduleRootAndHandler(fullHandlerString); let [module3, handlerPath] = _splitHandlerString(moduleAndHandler); let userApp = await _loadUserApp(appRoot, moduleRoot, module3); let handlerFunc = _resolveHandler(userApp, handlerPath); if (!handlerFunc) { throw new HandlerNotFound( `${fullHandlerString} is undefined or not exported` ); } if (typeof handlerFunc !== "function") { throw new HandlerNotFound(`${fullHandlerString} is not a function`); } return handlerFunc; }; module2.exports.isHandlerFunction = function(value) { return typeof value === "function"; }; module2.exports.getHandlerMetadata = function(handlerFunc) { return { streaming: _isHandlerStreaming(handlerFunc), highWaterMark: _highWaterMark(handlerFunc) }; }; module2.exports.STREAM_RESPONSE = STREAM_RESPONSE; } }); // node_modules/@aws-sdk/util-dynamodb/dist-cjs/index.js var require_dist_cjs = __commonJS({ "node_modules/@aws-sdk/util-dynamodb/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, { NumberValueImpl: () => NumberValue, convertToAttr: () => convertToAttr, convertToNative: () => convertToNative, marshall: () => marshall, unmarshall: () => unmarshall2 }); module2.exports = __toCommonJS2(src_exports); var _NumberValue = class _NumberValue2 { /** * This class does not validate that your string input is a valid number. * * @param value - a precise number, or any BigInt or string, or AttributeValue. */ constructor(value) { if (typeof value === "object" && "N" in value) { this.value = String(value.N); } else { this.value = String(value); } const valueOf = typeof value.valueOf() === "number" ? value.valueOf() : 0; const imprecise = valueOf > Number.MAX_SAFE_INTEGER || valueOf < Number.MIN_SAFE_INTEGER || Math.abs(valueOf) === Infinity || Number.isNaN(valueOf); if (imprecise) { throw new Error( `NumberValue should not be initialized with an imprecise number=${valueOf}. Use a string instead.` ); } } /** * This class does not validate that your string input is a valid number. * * @param value - a precise number, or any BigInt or string, or AttributeValue. */ static from(value) { return new _NumberValue2(value); } /** * @returns the AttributeValue form for DynamoDB. */ toAttributeValue() { return { N: this.toString() }; } /** * @returns BigInt representation. * * @throws SyntaxError if the string representation is not convertable to a BigInt. */ toBigInt() { const stringValue = this.toString(); return BigInt(stringValue); } /** * @override * * @returns string representation. This is the canonical format in DynamoDB. */ toString() { return String(this.value); } /** * @override */ valueOf() { return this.toString(); } }; __name(_NumberValue, "NumberValue"); var NumberValue = _NumberValue; var convertToAttr = /* @__PURE__ */ __name((data, options) => { var _a, _b, _c, _d, _e, _f; if (data === void 0) { throw new Error(`Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.`); } else if (data === null && typeof data === "object") { return convertToNullAttr(); } else if (Array.isArray(data)) { return convertToListAttr(data, options); } else if (((_a = data == null ? void 0 : data.constructor) == null ? void 0 : _a.name) === "Set") { return convertToSetAttr(data, options); } else if (((_b = data == null ? void 0 : data.constructor) == null ? void 0 : _b.name) === "Map") { return convertToMapAttrFromIterable(data, options); } else if (((_c = data == null ? void 0 : data.constructor) == null ? void 0 : _c.name) === "Object" || // for object which is result of Object.create(null), which doesn't have constructor defined !data.constructor && typeof data === "object") { return convertToMapAttrFromEnumerableProps(data, options); } else if (isBinary(data)) { if (data.length === 0 && (options == null ? void 0 : options.convertEmptyValues)) { return convertToNullAttr(); } return convertToBinaryAttr(data); } else if (typeof data === "boolean" || ((_d = data == null ? void 0 : data.constructor) == null ? void 0 : _d.name) === "Boolean") { return { BOOL: data.valueOf() }; } else if (typeof data === "number" || ((_e = data == null ? void 0 : data.constructor) == null ? void 0 : _e.name) === "Number") { return convertToNumberAttr(data, options); } else if (data instanceof NumberValue) { return data.toAttributeValue(); } else if (typeof data === "bigint") { return convertToBigIntAttr(data); } else if (typeof data === "string" || ((_f = data == null ? void 0 : data.constructor) == null ? void 0 : _f.name) === "String") { if (data.length === 0 && (options == null ? void 0 : options.convertEmptyValues)) { return convertToNullAttr(); } return convertToStringAttr(data); } else if ((options == null ? void 0 : options.convertClassInstanceToMap) && typeof data === "object") { return convertToMapAttrFromEnumerableProps(data, options); } throw new Error( `Unsupported type passed: ${data}. Pass options.convertClassInstanceToMap=true to marshall typeof object as map attribute.` ); }, "convertToAttr"); var convertToListAttr = /* @__PURE__ */ __name((data, options) => ({ L: data.filter( (item) => typeof item !== "function" && (!(options == null ? void 0 : options.removeUndefinedValues) || (options == null ? void 0 : options.removeUndefinedValues) && item !== void 0) ).map((item) => convertToAttr(item, options)) }), "convertToListAttr"); var convertToSetAttr = /* @__PURE__ */ __name((set, options) => { const setToOperate = (options == null ? void 0 : options.removeUndefinedValues) ? new Set([...set].filter((value) => value !== void 0)) : set; if (!(options == null ? void 0 : options.removeUndefinedValues) && setToOperate.has(void 0)) { throw new Error(`Pass options.removeUndefinedValues=true to remove undefined values from map/array/set.`); } if (setToOperate.size === 0) { if (options == null ? void 0 : options.convertEmptyValues) { return convertToNullAttr(); } throw new Error(`Pass a non-empty set, or options.convertEmptyValues=true.`); } const item = setToOperate.values().next().value; if (item instanceof NumberValue) { return { NS: Array.from(setToOperate).map((_) => _.toString()) }; } else if (typeof item === "number") { return { NS: Array.from(setToOperate).map((num) => convertToNumberAttr(num, options)).map((item2) => item2.N) }; } else if (typeof item === "bigint") { return { NS: Array.from(setToOperate).map(convertToBigIntAttr).map((item2) => item2.N) }; } else if (typeof item === "string") { return { SS: Array.from(setToOperate).map(convertToStringAttr).map((item2) => item2.S) }; } else if (isBinary(item)) { return { // Do not alter binary data passed https://github.com/aws/aws-sdk-js-v3/issues/1530 // @ts-expect-error Type 'ArrayBuffer' is not assignable to type 'Uint8Array' BS: Array.from(setToOperate).map(convertToBinaryAttr).map((item2) => item2.B) }; } else { throw new Error(`Only Number Set (NS), Binary Set (BS) or String Set (SS) are allowed.`); } }, "convertToSetAttr"); var convertToMapAttrFromIterable = /* @__PURE__ */ __name((data, options) => ({ M: ((data2) => { const map = {}; for (const [key, value] of data2) { if (typeof value !== "function" && (value !== void 0 || !(options == null ? void 0 : options.removeUndefinedValues))) { map[key] = convertToAttr(value, options); } } return map; })(data) }), "convertToMapAttrFromIterable"); var convertToMapAttrFromEnumerableProps = /* @__PURE__ */ __name((data, options) => ({ M: ((data2) => { const map = {}; for (const key in data2) { const value = data2[key]; if (typeof value !== "function" && (value !== void 0 || !(options == null ? void 0 : options.removeUndefinedValues))) { map[key] = convertToAttr(value, options); } } return map; })(data) }), "convertToMapAttrFromEnumerableProps"); var convertToNullAttr = /* @__PURE__ */ __name(() => ({ NULL: true }), "convertToNullAttr"); var convertToBinaryAttr = /* @__PURE__ */ __name((data) => ({ B: data }), "convertToBinaryAttr"); var convertToStringAttr = /* @__PURE__ */ __name((data) => ({ S: data.toString() }), "convertToStringAttr"); var convertToBigIntAttr = /* @__PURE__ */ __name((data) => ({ N: data.toString() }), "convertToBigIntAttr"); var validateBigIntAndThrow = /* @__PURE__ */ __name((errorPrefix) => { throw new Error(`${errorPrefix} Use NumberValue from @aws-sdk/lib-dynamodb.`); }, "validateBigIntAndThrow"); var convertToNumberAttr = /* @__PURE__ */ __name((num, options) => { if ([Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY].map((val2) => val2.toString()).includes(num.toString())) { throw new Error(`Special numeric value ${num.toString()} is not allowed`); } else if (!(options == null ? void 0 : options.allowImpreciseNumbers)) { if (num > Number.MAX_SAFE_INTEGER) { validateBigIntAndThrow(`Number ${num.toString()} is greater than Number.MAX_SAFE_INTEGER.`); } else if (num < Number.MIN_SAFE_INTEGER) { validateBigIntAndThrow(`Number ${num.toString()} is lesser than Number.MIN_SAFE_INTEGER.`); } } return { N: num.toString() }; }, "convertToNumberAttr"); var isBinary = /* @__PURE__ */ __name((data) => { const binaryTypes = [ "ArrayBuffer", "Blob", "Buffer", "DataView", "File", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array" ]; if (data == null ? void 0 : data.constructor) { return binaryTypes.includes(data.constructor.name); } return false; }, "isBinary"); var convertToNative = /* @__PURE__ */ __name((data, options) => { for (const [key, value] of Object.entries(data)) { if (value !== void 0) { switch (key) { case "NULL": return null; case "BOOL": return Boolean(value); case "N": return convertNumber(value, options); case "B": return convertBinary(value); case "S": return convertString(value); case "L": return convertList(value, options); case "M": return convertMap(value, options); case "NS": return new Set(value.map((item) => convertNumber(item, options))); case "BS": return new Set(value.map(convertBinary)); case "SS": return new Set(value.map(convertString)); default: throw new Error(`Unsupported type passed: ${key}`); } } } throw new Error(`No value defined: ${JSON.stringify(data)}`); }, "convertToNative"); var convertNumber = /* @__PURE__ */ __name((numString, options) => { if (typeof (options == null ? void 0 : options.wrapNumbers) === "function") { return options == null ? void 0 : options.wrapNumbers(numString); } if (options == null ? void 0 : options.wrapNumbers) { return NumberValue.from(numString); } const num = Number(numString); const infinityValues = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]; const isLargeFiniteNumber = (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) && !infinityValues.includes(num); if (isLargeFiniteNumber) { if (typeof BigInt === "function") { try { return BigInt(numString); } catch (error) { throw new Error(`${numString} can't be converted to BigInt. Set options.wrapNumbers to get string value.`); } } else { throw new Error(`${numString} is outside SAFE_INTEGER bounds. Set options.wrapNumbers to get string value.`); } } return num; }, "convertNumber"); var convertString = /* @__PURE__ */ __name((stringValue) => stringValue, "convertString"); var convertBinary = /* @__PURE__ */ __name((binaryValue) => binaryValue, "convertBinary"); var convertList = /* @__PURE__ */ __name((list2, options) => list2.map((item) => convertToNative(item, options)), "convertList"); var convertMap = /* @__PURE__ */ __name((map, options) => Object.entries(map).reduce( (acc, [key, value]) => (acc[key] = convertToNative(value, options), acc), {} ), "convertMap"); function marshall(data, options) { const attributeValue = convertToAttr(data, options); const [key, value] = Object.entries(attributeValue)[0]; switch (key) { case "M": case "L": return (options == null ? void 0 : options.convertTopLevelContainer) ? attributeValue : value; case "SS": case "NS": case "BS": case "S": case "N": case "B": case "NULL": case "BOOL": case "$unknown": default: return attributeValue; } } __name(marshall, "marshall"); var unmarshall2 = /* @__PURE__ */ __name((data, options) => { if (options == null ? void 0 : options.convertWithoutMapWrapper) { return convertToNative(data, options); } return convertToNative({ M: data }, options); }, "unmarshall"); } }); // node_modules/uuid/dist/esm-node/rng.js function rng() { if (poolPtr > rnds8Pool.length - 16) { import_crypto.default.randomFillSync(rnds8Pool); poolPtr = 0; } return rnds8Pool.slice(poolPtr, poolPtr += 16); } var import_crypto, rnds8Pool, poolPtr; var init_rng = __esm({ "node_modules/uuid/dist/esm-node/rng.js"() { import_crypto = __toESM(require("crypto")); rnds8Pool = new Uint8Array(256); poolPtr = rnds8Pool.length; } }); // node_modules/uuid/dist/esm-node/regex.js var regex_default; var init_regex = __esm({ "node_modules/uuid/dist/esm-node/regex.js"() { regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; } }); // node_modules/uuid/dist/esm-node/validate.js function validate(uuid) { return typeof uuid === "string" && regex_default.test(uuid); } var validate_default; var init_validate = __esm({ "node_modules/uuid/dist/esm-node/validate.js"() { init_regex(); validate_default = validate; } }); // node_modules/uuid/dist/esm-node/stringify.js function unsafeStringify(arr, offset = 0) { return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; } function stringify(arr, offset = 0) { const uuid = unsafeStringify(arr, offset); if (!validate_default(uuid)) { throw TypeError("Stringified UUID is invalid"); } return uuid; } var byteToHex, stringify_default; var init_stringify = __esm({ "node_modules/uuid/dist/esm-node/stringify.js"() { init_validate(); byteToHex = []; for (let i = 0; i < 256; ++i) { byteToHex.push((i + 256).toString(16).slice(1)); } stringify_default = stringify; } }); // node_modules/uuid/dist/esm-node/v1.js function v1(options, buf, offset) { let i = buf && offset || 0; const b = buf || new Array(16); options = options || {}; let node = options.node || _nodeId; let clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq; if (node == null || clockseq == null) { const seedBytes = options.random || (options.rng || rng)(); if (node == null) { node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; } if (clockseq == null) { clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383; } } let msecs = options.msecs !== void 0 ? options.msecs : Date.now(); let nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1; const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4; if (dt < 0 && options.clockseq === void 0) { clockseq = clockseq + 1 & 16383; } if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) { nsecs = 0; } if (nsecs >= 1e4) { throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); } _lastMSecs = msecs; _lastNSecs = nsecs; _clockseq = clockseq; msecs += 122192928e5; const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296; b[i++] = tl >>> 24 & 255; b[i++] = tl >>> 16 & 255; b[i++] = tl >>> 8 & 255; b[i++] = tl & 255; const tmh = msecs / 4294967296 * 1e4 & 268435455; b[i++] = tmh >>> 8 & 255; b[i++] = tmh & 255; b[i++] = tmh >>> 24 & 15 | 16; b[i++] = tmh >>> 16 & 255; b[i++] = clockseq >>> 8 | 128; b[i++] = clockseq & 255; for (let n = 0; n < 6; ++n) { b[i + n] = node[n]; } return buf || unsafeStringify(b); } var _nodeId, _clockseq, _lastMSecs, _lastNSecs, v1_default; var init_v1 = __esm({ "node_modules/uuid/dist/esm-node/v1.js"() { init_rng(); init_stringify(); _lastMSecs = 0; _lastNSecs = 0; v1_default = v1; } }); // node_modules/uuid/dist/esm-node/parse.js function parse(uuid) { if (!validate_default(uuid)) { throw TypeError("Invalid UUID"); } let v; const arr = new Uint8Array(16); arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; arr[1] = v >>> 16 & 255; arr[2] = v >>> 8 & 255; arr[3] = v & 255; arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; arr[5] = v & 255; arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; arr[7] = v & 255; arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; arr[9] = v & 255; arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255; arr[11] = v / 4294967296 & 255; arr[12] = v >>> 24 & 255; arr[13] = v >>> 16 & 255; arr[14] = v >>> 8 & 255; arr[15] = v & 255; return arr; } var parse_default; var init_parse = __esm({ "node_modules/uuid/dist/esm-node/parse.js"() { init_validate(); parse_default = parse; } }); // node_modules/uuid/dist/esm-node/v35.js function stringToBytes(str) { str = unescape(encodeURIComponent(str)); const bytes = []; for (let i = 0; i < str.length; ++i) { bytes.push(str.charCodeAt(i)); } return bytes; } function v35(name, version2, hashfunc) { function generateUUID(value, namespace, buf, offset) { var _namespace; if (typeof value === "string") { value = stringToBytes(value); } if (typeof namespace === "string") { namespace = parse_default(namespace); } if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)"); } let bytes = new Uint8Array(16 + value.length); bytes.set(namespace); bytes.set(value, namespace.length); bytes = hashfunc(bytes); bytes[6] = bytes[6] & 15 | version2; bytes[8] = bytes[8] & 63 | 128; if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = bytes[i]; } return buf; } return unsafeStringify(bytes); } try { generateUUID.name = name; } catch (err) { } generateUUID.DNS = DNS; generateUUID.URL = URL2; return generateUUID; } var DNS, URL2; var init_v35 = __esm({ "node_modules/uuid/dist/esm-node/v35.js"() { init_stringify(); init_parse(); DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"; URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"; } }); // node_modules/uuid/dist/esm-node/md5.js function md5(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === "string") { bytes = Buffer.from(bytes, "utf8"); } return import_crypto2.default.createHash("md5").update(bytes).digest(); } var import_crypto2, md5_default; var init_md5 = __esm({ "node_modules/uuid/dist/esm-node/md5.js"() { import_crypto2 = __toESM(require("crypto")); md5_default = md5; } }); // node_modules/uuid/dist/esm-node/v3.js var v3, v3_default; var init_v3 = __esm({ "node_modules/uuid/dist/esm-node/v3.js"() { init_v35(); init_md5(); v3 = v35("v3", 48, md5_default); v3_default = v3; } }); // node_modules/uuid/dist/esm-node/native.js var import_crypto3, native_default; var init_native = __esm({ "node_modules/uuid/dist/esm-node/native.js"() { import_crypto3 = __toESM(require("crypto")); native_default = { randomUUID: import_crypto3.default.randomUUID }; } }); // node_modules/uuid/dist/esm-node/v4.js function v4(options, buf, offset) { if (native_default.randomUUID && !buf && !options) { return native_default.randomUUID(); } options = options || {}; const rnds = options.random || (options.rng || rng)(); rnds[6] = rnds[6] & 15 | 64; rnds[8] = rnds[8] & 63 | 128; if (buf) { offset = offset || 0; for (let i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return unsafeStringify(rnds); } var v4_default; var init_v4 = __esm({ "node_modules/uuid/dist/esm-node/v4.js"() { init_native(); init_rng(); init_stringify(); v4_default = v4; } }); // node_modules/uuid/dist/esm-node/sha1.js function sha1(bytes) { if (Array.isArray(bytes)) { bytes = Buffer.from(bytes); } else if (typeof bytes === "string") { bytes = Buffer.from(bytes, "utf8"); } return import_crypto4.default.createHash("sha1").update(bytes).digest(); } var import_crypto4, sha1_default; var init_sha1 = __esm({ "node_modules/uuid/dist/esm-node/sha1.js"() { import_crypto4 = __toESM(require("crypto")); sha1_default = sha1; } }); // node_modules/uuid/dist/esm-node/v5.js var v5, v5_default; var init_v5 = __esm({ "node_modules/uuid/dist/esm-node/v5.js"() { init_v35(); init_sha1(); v5 = v35("v5", 80, sha1_default); v5_default = v5; } }); // node_modules/uuid/dist/esm-node/nil.js var nil_default; var init_nil = __esm({ "node_modules/uuid/dist/esm-node/nil.js"() { nil_default = "00000000-0000-0000-0000-000000000000"; } }); // node_modules/uuid/dist/esm-node/version.js function version(uuid) { if (!validate_default(uuid)) { throw TypeError("Invalid UUID"); } return parseInt(uuid.slice(14, 15), 16); } var version_default; var init_version = __esm({ "node_modules/uuid/dist/esm-node/version.js"() { init_validate(); version_default = version; } }); // node_modules/uuid/dist/esm-node/index.js var esm_node_exports = {}; __export(esm_node_exports, { NIL: () => nil_default, parse: () => parse_default, stringify: () => stringify_default, v1: () => v1_default, v3: () => v3_default, v4: () => v4_default, v5: () => v5_default, validate: () => validate_default, version: () => version_default }); var init_esm_node = __esm({ "node_modules/uuid/dist/esm-node/index.js"() { init_v1(); init_v3(); init_v4(); init_v5(); init_nil(); init_version(); init_validate(); init_stringify(); init_parse(); } }); // node_modules/tslib/tslib.es6.mjs var tslib_es6_exports = {}; __export(tslib_es6_exports, { __addDisposableResource: () => __addDisposableResource, __assign: () => __assign, __asyncDelegator: () => __asyncDelegator, __asyncGenerator: () => __asyncGenerator, __asyncValues: () => __asyncValues, __await: () => __await, __awaiter: () => __awaiter, __classPrivateFieldGet: () => __classPrivateFieldGet, __classPrivateFieldIn: () => __classPrivateFieldIn, __classPrivateFieldSet: () => __classPrivateFieldSet, __createBinding: () => __createBinding, __decorate: () => __decorate, __disposeResources: () => __disposeResources, __esDecorate: () => __esDecorate, __exportStar: () => __exportStar, __extends: () => __extends, __generator: () => __generator, __importDefault: () => __importDefault, __importStar: () => __importStar, __makeTemplateObject: () => __makeTemplateObject, __metadata: () => __metadata, __param: () => __param, __propKey: () => __propKey, __read: () => __read, __rest: () => __rest, __rewriteRelativeImportExtension: () => __rewriteRelativeImportExtension, __runInitializers: () => __runInitializers, __setFunctionName: () => __setFunctionName, __spread: () => __spread, __spreadArray: () => __spreadArray, __spreadArrays: () => __spreadArrays, __values: () => __values, default: () => tslib_es6_default }); function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; } function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function(f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; } function __runInitializers(thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; } function __propKey(x) { return typeof x === "symbol" ? x : "".concat(x); } function __setFunctionName(f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function() { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() { return this; }, i; function awaitReturn(f) { return function(v) { return Promise.resolve(v).then(f, reject); }; } function verb(n, f) { if (g[n]) { i[n] = function(v) { return new Promise(function(a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("ne