serverless-spy 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/README.md +15 -12
- package/cli/cli.ts +8 -1
- package/dist/releasetag.txt +1 -1
- package/extension/aws/Errors.js +124 -0
- package/extension/aws/HttpResponseStream.js +36 -0
- package/extension/aws/UserFunction.js +324 -0
- package/extension/aws/VerboseLog.js +53 -0
- package/extension/interceptor.ts +8 -7
- package/lib/cli/cli.js +7 -2
- package/lib/cli/cli.mjs +7 -2
- package/lib/cli/cli.ts +8 -1
- package/lib/extension/dist/layer/nodejs/node_modules/interceptor.js +531 -274
- package/lib/extension/dist/layer/nodejs/node_modules/interceptor.js.map +4 -4
- package/lib/listener/ServerlessSpyListener.d.ts +4 -1
- package/lib/listener/ServerlessSpyListener.js +1 -1
- package/lib/listener/ServerlessSpyListener.mjs +1 -1
- package/lib/listener/SpyHandlers.ts.d.ts +22 -0
- package/lib/listener/SpyHandlers.ts.js +1 -1
- package/lib/listener/SpyHandlers.ts.mjs +1 -1
- package/lib/src/ServerlessSpy.d.ts +1 -0
- package/lib/src/ServerlessSpy.js +20 -8
- package/lib/src/ServerlessSpy.mjs +19 -7
- package/listener/ServerlessSpyListener.ts +9 -0
- package/listener/SpyHandlers.ts.ts +50 -0
- package/package.json +1 -1
- package/doc/Contributors.md +0 -4
- package/extension/aws/Common.ts +0 -88
- package/extension/aws/Errors.ts +0 -140
- package/extension/aws/UserFunction.ts +0 -169
|
@@ -2903,10 +2903,10 @@ ${longDate}
|
|
|
2903
2903
|
${credentialScope}
|
|
2904
2904
|
${(0, util_hex_encoding_1.toHex)(hashedRequest)}`;
|
|
2905
2905
|
}
|
|
2906
|
-
getCanonicalPath({ path
|
|
2906
|
+
getCanonicalPath({ path }) {
|
|
2907
2907
|
if (this.uriEscapePath) {
|
|
2908
2908
|
const normalizedPathSegments = [];
|
|
2909
|
-
for (const pathSegment of
|
|
2909
|
+
for (const pathSegment of path.split("/")) {
|
|
2910
2910
|
if ((pathSegment === null || pathSegment === void 0 ? void 0 : pathSegment.length) === 0)
|
|
2911
2911
|
continue;
|
|
2912
2912
|
if (pathSegment === ".")
|
|
@@ -2917,11 +2917,11 @@ ${(0, util_hex_encoding_1.toHex)(hashedRequest)}`;
|
|
|
2917
2917
|
normalizedPathSegments.push(pathSegment);
|
|
2918
2918
|
}
|
|
2919
2919
|
}
|
|
2920
|
-
const normalizedPath = `${(
|
|
2920
|
+
const normalizedPath = `${(path === null || path === void 0 ? void 0 : path.startsWith("/")) ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && (path === null || path === void 0 ? void 0 : path.endsWith("/")) ? "/" : ""}`;
|
|
2921
2921
|
const doubleEncoded = encodeURIComponent(normalizedPath);
|
|
2922
2922
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
2923
2923
|
}
|
|
2924
|
-
return
|
|
2924
|
+
return path;
|
|
2925
2925
|
}
|
|
2926
2926
|
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
|
|
2927
2927
|
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
|
|
@@ -7227,14 +7227,14 @@ var require_Aws_query = __commonJS({
|
|
|
7227
7227
|
return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
|
|
7228
7228
|
};
|
|
7229
7229
|
var collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
|
|
7230
|
-
var buildHttpRpcRequest = async (context, headers,
|
|
7230
|
+
var buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
|
|
7231
7231
|
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
7232
7232
|
const contents = {
|
|
7233
7233
|
protocol,
|
|
7234
7234
|
hostname,
|
|
7235
7235
|
port,
|
|
7236
7236
|
method: "POST",
|
|
7237
|
-
path: basePath.endsWith("/") ? basePath.slice(0, -1) +
|
|
7237
|
+
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
|
|
7238
7238
|
headers
|
|
7239
7239
|
};
|
|
7240
7240
|
if (resolvedHostname !== void 0) {
|
|
@@ -8032,11 +8032,11 @@ var require_slurpFile = __commonJS({
|
|
|
8032
8032
|
var fs_1 = require("fs");
|
|
8033
8033
|
var { readFile } = fs_1.promises;
|
|
8034
8034
|
var filePromisesHash = {};
|
|
8035
|
-
var slurpFile = (
|
|
8036
|
-
if (!filePromisesHash[
|
|
8037
|
-
filePromisesHash[
|
|
8035
|
+
var slurpFile = (path) => {
|
|
8036
|
+
if (!filePromisesHash[path]) {
|
|
8037
|
+
filePromisesHash[path] = readFile(path, "utf8");
|
|
8038
8038
|
}
|
|
8039
|
-
return filePromisesHash[
|
|
8039
|
+
return filePromisesHash[path];
|
|
8040
8040
|
};
|
|
8041
8041
|
exports.slurpFile = slurpFile;
|
|
8042
8042
|
}
|
|
@@ -9967,7 +9967,7 @@ var require_node_http2_handler = __commonJS({
|
|
|
9967
9967
|
rejectOriginal(abortError);
|
|
9968
9968
|
return;
|
|
9969
9969
|
}
|
|
9970
|
-
const { hostname, method, port, protocol, path
|
|
9970
|
+
const { hostname, method, port, protocol, path, query } = request;
|
|
9971
9971
|
const authority = `${protocol}//${hostname}${port ? `:${port}` : ""}`;
|
|
9972
9972
|
const session = this.getSession(authority, disableConcurrentStreams || false);
|
|
9973
9973
|
const reject = (err) => {
|
|
@@ -9980,7 +9980,7 @@ var require_node_http2_handler = __commonJS({
|
|
|
9980
9980
|
const queryString = (0, querystring_builder_1.buildQueryString)(query || {});
|
|
9981
9981
|
const req = session.request({
|
|
9982
9982
|
...request.headers,
|
|
9983
|
-
[http2_1.constants.HTTP2_HEADER_PATH]: queryString ? `${
|
|
9983
|
+
[http2_1.constants.HTTP2_HEADER_PATH]: queryString ? `${path}?${queryString}` : path,
|
|
9984
9984
|
[http2_1.constants.HTTP2_HEADER_METHOD]: method
|
|
9985
9985
|
});
|
|
9986
9986
|
session.ref();
|
|
@@ -21142,14 +21142,14 @@ var require_Aws_json1_0 = __commonJS({
|
|
|
21142
21142
|
return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
|
|
21143
21143
|
};
|
|
21144
21144
|
var collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
|
|
21145
|
-
var buildHttpRpcRequest = async (context, headers,
|
|
21145
|
+
var buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
|
|
21146
21146
|
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
|
|
21147
21147
|
const contents = {
|
|
21148
21148
|
protocol,
|
|
21149
21149
|
hostname,
|
|
21150
21150
|
port,
|
|
21151
21151
|
method: "POST",
|
|
21152
|
-
path: basePath.endsWith("/") ? basePath.slice(0, -1) +
|
|
21152
|
+
path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
|
|
21153
21153
|
headers
|
|
21154
21154
|
};
|
|
21155
21155
|
if (resolvedHostname !== void 0) {
|
|
@@ -26272,6 +26272,373 @@ var require_dist_cjs49 = __commonJS({
|
|
|
26272
26272
|
}
|
|
26273
26273
|
});
|
|
26274
26274
|
|
|
26275
|
+
// extension/aws/Errors.js
|
|
26276
|
+
var require_Errors = __commonJS({
|
|
26277
|
+
"extension/aws/Errors.js"(exports, module2) {
|
|
26278
|
+
"use strict";
|
|
26279
|
+
var util = require("util");
|
|
26280
|
+
function _isError(obj) {
|
|
26281
|
+
return obj && obj.name && obj.message && obj.stack && typeof obj.name === "string" && typeof obj.message === "string" && typeof obj.stack === "string";
|
|
26282
|
+
}
|
|
26283
|
+
function intoError(err) {
|
|
26284
|
+
if (err instanceof Error) {
|
|
26285
|
+
return err;
|
|
26286
|
+
} else {
|
|
26287
|
+
return new Error(err);
|
|
26288
|
+
}
|
|
26289
|
+
}
|
|
26290
|
+
module2.exports.intoError = intoError;
|
|
26291
|
+
function toRapidResponse(error) {
|
|
26292
|
+
try {
|
|
26293
|
+
if (util.types.isNativeError(error) || _isError(error)) {
|
|
26294
|
+
return {
|
|
26295
|
+
errorType: error.name,
|
|
26296
|
+
errorMessage: error.message,
|
|
26297
|
+
trace: error.stack.split("\n")
|
|
26298
|
+
};
|
|
26299
|
+
} else {
|
|
26300
|
+
return {
|
|
26301
|
+
errorType: typeof error,
|
|
26302
|
+
errorMessage: error.toString(),
|
|
26303
|
+
trace: []
|
|
26304
|
+
};
|
|
26305
|
+
}
|
|
26306
|
+
} catch (_err) {
|
|
26307
|
+
return {
|
|
26308
|
+
errorType: "handled",
|
|
26309
|
+
errorMessage: "callback called with Error argument, but there was a problem while retrieving one or more of its message, name, and stack"
|
|
26310
|
+
};
|
|
26311
|
+
}
|
|
26312
|
+
}
|
|
26313
|
+
module2.exports.toRapidResponse = toRapidResponse;
|
|
26314
|
+
module2.exports.toFormatted = (error) => {
|
|
26315
|
+
try {
|
|
26316
|
+
return " " + JSON.stringify(error, (_k, v) => _withEnumerableProperties(v));
|
|
26317
|
+
} catch (err) {
|
|
26318
|
+
return " " + JSON.stringify(toRapidResponse(error));
|
|
26319
|
+
}
|
|
26320
|
+
};
|
|
26321
|
+
function _withEnumerableProperties(error) {
|
|
26322
|
+
if (error instanceof Error) {
|
|
26323
|
+
let ret = Object.assign(
|
|
26324
|
+
{
|
|
26325
|
+
errorType: error.name,
|
|
26326
|
+
errorMessage: error.message,
|
|
26327
|
+
code: error.code
|
|
26328
|
+
},
|
|
26329
|
+
error
|
|
26330
|
+
);
|
|
26331
|
+
if (typeof error.stack == "string") {
|
|
26332
|
+
ret.stack = error.stack.split("\n");
|
|
26333
|
+
}
|
|
26334
|
+
return ret;
|
|
26335
|
+
} else {
|
|
26336
|
+
return error;
|
|
26337
|
+
}
|
|
26338
|
+
}
|
|
26339
|
+
var errorClasses = [
|
|
26340
|
+
class ImportModuleError extends Error {
|
|
26341
|
+
},
|
|
26342
|
+
class HandlerNotFound extends Error {
|
|
26343
|
+
},
|
|
26344
|
+
class MalformedHandlerName extends Error {
|
|
26345
|
+
},
|
|
26346
|
+
class UserCodeSyntaxError extends Error {
|
|
26347
|
+
},
|
|
26348
|
+
class MalformedStreamingHandler extends Error {
|
|
26349
|
+
},
|
|
26350
|
+
class InvalidStreamingOperation extends Error {
|
|
26351
|
+
},
|
|
26352
|
+
class UnhandledPromiseRejection extends Error {
|
|
26353
|
+
constructor(reason, promise) {
|
|
26354
|
+
super(reason);
|
|
26355
|
+
this.reason = reason;
|
|
26356
|
+
this.promise = promise;
|
|
26357
|
+
}
|
|
26358
|
+
}
|
|
26359
|
+
];
|
|
26360
|
+
errorClasses.forEach((e) => {
|
|
26361
|
+
module2.exports[e.name] = e;
|
|
26362
|
+
e.prototype.name = `Runtime.${e.name}`;
|
|
26363
|
+
});
|
|
26364
|
+
}
|
|
26365
|
+
});
|
|
26366
|
+
|
|
26367
|
+
// extension/aws/VerboseLog.js
|
|
26368
|
+
var require_VerboseLog = __commonJS({
|
|
26369
|
+
"extension/aws/VerboseLog.js"(exports) {
|
|
26370
|
+
"use strict";
|
|
26371
|
+
var EnvVarName = "AWS_LAMBDA_RUNTIME_VERBOSE";
|
|
26372
|
+
var Tag = "RUNTIME";
|
|
26373
|
+
var Verbosity = (() => {
|
|
26374
|
+
if (!process.env[EnvVarName]) {
|
|
26375
|
+
return 0;
|
|
26376
|
+
}
|
|
26377
|
+
try {
|
|
26378
|
+
const verbosity = parseInt(process.env[EnvVarName]);
|
|
26379
|
+
return verbosity < 0 ? 0 : verbosity > 3 ? 3 : verbosity;
|
|
26380
|
+
} catch (_) {
|
|
26381
|
+
return 0;
|
|
26382
|
+
}
|
|
26383
|
+
})();
|
|
26384
|
+
exports.logger = function(category) {
|
|
26385
|
+
return {
|
|
26386
|
+
verbose: function() {
|
|
26387
|
+
if (Verbosity >= 1) {
|
|
26388
|
+
const args = [...arguments].map(
|
|
26389
|
+
(arg) => typeof arg === "function" ? arg() : arg
|
|
26390
|
+
);
|
|
26391
|
+
console.log.apply(null, [Tag, category, ...args]);
|
|
26392
|
+
}
|
|
26393
|
+
},
|
|
26394
|
+
vverbose: function() {
|
|
26395
|
+
if (Verbosity >= 2) {
|
|
26396
|
+
const args = [...arguments].map(
|
|
26397
|
+
(arg) => typeof arg === "function" ? arg() : arg
|
|
26398
|
+
);
|
|
26399
|
+
console.log.apply(null, [Tag, category, ...args]);
|
|
26400
|
+
}
|
|
26401
|
+
},
|
|
26402
|
+
vvverbose: function() {
|
|
26403
|
+
if (Verbosity >= 3) {
|
|
26404
|
+
const args = [...arguments].map(
|
|
26405
|
+
(arg) => typeof arg === "function" ? arg() : arg
|
|
26406
|
+
);
|
|
26407
|
+
console.log.apply(null, [Tag, category, ...args]);
|
|
26408
|
+
}
|
|
26409
|
+
}
|
|
26410
|
+
};
|
|
26411
|
+
};
|
|
26412
|
+
}
|
|
26413
|
+
});
|
|
26414
|
+
|
|
26415
|
+
// extension/aws/HttpResponseStream.js
|
|
26416
|
+
var require_HttpResponseStream = __commonJS({
|
|
26417
|
+
"extension/aws/HttpResponseStream.js"(exports, module2) {
|
|
26418
|
+
"use strict";
|
|
26419
|
+
var METADATA_PRELUDE_CONTENT_TYPE = "application/vnd.awslambda.http-integration-response";
|
|
26420
|
+
var DELIMITER_LEN = 8;
|
|
26421
|
+
var HttpResponseStream = class {
|
|
26422
|
+
static from(underlyingStream, prelude) {
|
|
26423
|
+
underlyingStream.setContentType(METADATA_PRELUDE_CONTENT_TYPE);
|
|
26424
|
+
const metadataPrelude = JSON.stringify(prelude);
|
|
26425
|
+
underlyingStream._onBeforeFirstWrite = (write) => {
|
|
26426
|
+
write(metadataPrelude);
|
|
26427
|
+
write(new Uint8Array(DELIMITER_LEN));
|
|
26428
|
+
};
|
|
26429
|
+
return underlyingStream;
|
|
26430
|
+
}
|
|
26431
|
+
};
|
|
26432
|
+
module2.exports.HttpResponseStream = HttpResponseStream;
|
|
26433
|
+
}
|
|
26434
|
+
});
|
|
26435
|
+
|
|
26436
|
+
// extension/aws/UserFunction.js
|
|
26437
|
+
var require_UserFunction = __commonJS({
|
|
26438
|
+
"extension/aws/UserFunction.js"(exports, module2) {
|
|
26439
|
+
"use strict";
|
|
26440
|
+
var path = require("path");
|
|
26441
|
+
var fs = require("fs");
|
|
26442
|
+
var {
|
|
26443
|
+
HandlerNotFound,
|
|
26444
|
+
MalformedHandlerName,
|
|
26445
|
+
ImportModuleError,
|
|
26446
|
+
UserCodeSyntaxError
|
|
26447
|
+
} = require_Errors();
|
|
26448
|
+
var { verbose } = require_VerboseLog().logger("LOADER");
|
|
26449
|
+
var { HttpResponseStream } = require_HttpResponseStream();
|
|
26450
|
+
var FUNCTION_EXPR = /^([^.]*)\.(.*)$/;
|
|
26451
|
+
var RELATIVE_PATH_SUBSTRING = "..";
|
|
26452
|
+
var HANDLER_STREAMING = Symbol.for("aws.lambda.runtime.handler.streaming");
|
|
26453
|
+
var HANDLER_HIGHWATERMARK = Symbol.for(
|
|
26454
|
+
"aws.lambda.runtime.handler.streaming.highWaterMark"
|
|
26455
|
+
);
|
|
26456
|
+
var STREAM_RESPONSE = "response";
|
|
26457
|
+
var NoGlobalAwsLambda = process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "1" || process.env["AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA"] === "true";
|
|
26458
|
+
function _moduleRootAndHandler(fullHandlerString) {
|
|
26459
|
+
let handlerString = path.basename(fullHandlerString);
|
|
26460
|
+
let moduleRoot = fullHandlerString.substring(
|
|
26461
|
+
0,
|
|
26462
|
+
fullHandlerString.indexOf(handlerString)
|
|
26463
|
+
);
|
|
26464
|
+
return [moduleRoot, handlerString];
|
|
26465
|
+
}
|
|
26466
|
+
function _splitHandlerString(handler2) {
|
|
26467
|
+
let match = handler2.match(FUNCTION_EXPR);
|
|
26468
|
+
if (!match || match.length != 3) {
|
|
26469
|
+
throw new MalformedHandlerName("Bad handler");
|
|
26470
|
+
}
|
|
26471
|
+
return [match[1], match[2]];
|
|
26472
|
+
}
|
|
26473
|
+
function _resolveHandler(object, nestedProperty) {
|
|
26474
|
+
return nestedProperty.split(".").reduce((nested, key) => {
|
|
26475
|
+
return nested && nested[key];
|
|
26476
|
+
}, object);
|
|
26477
|
+
}
|
|
26478
|
+
function _tryRequireFile(file, extension) {
|
|
26479
|
+
const path2 = file + (extension || "");
|
|
26480
|
+
verbose("Try loading as commonjs:", path2);
|
|
26481
|
+
return fs.existsSync(path2) ? require(path2) : void 0;
|
|
26482
|
+
}
|
|
26483
|
+
async function _tryAwaitImport(file, extension) {
|
|
26484
|
+
const path2 = file + (extension || "");
|
|
26485
|
+
verbose("Try loading as esmodule:", path2);
|
|
26486
|
+
if (fs.existsSync(path2)) {
|
|
26487
|
+
return await import(path2);
|
|
26488
|
+
}
|
|
26489
|
+
return void 0;
|
|
26490
|
+
}
|
|
26491
|
+
function _hasFolderPackageJsonTypeModule(folder) {
|
|
26492
|
+
if (folder.endsWith("/node_modules")) {
|
|
26493
|
+
return false;
|
|
26494
|
+
}
|
|
26495
|
+
const pj = path.join(folder, "/package.json");
|
|
26496
|
+
if (fs.existsSync(pj)) {
|
|
26497
|
+
try {
|
|
26498
|
+
const pkg = JSON.parse(fs.readFileSync(pj));
|
|
26499
|
+
if (pkg) {
|
|
26500
|
+
if (pkg.type === "module") {
|
|
26501
|
+
verbose("type: module detected in", pj);
|
|
26502
|
+
return true;
|
|
26503
|
+
} else {
|
|
26504
|
+
verbose("type: module not detected in", pj);
|
|
26505
|
+
return false;
|
|
26506
|
+
}
|
|
26507
|
+
}
|
|
26508
|
+
} catch (e) {
|
|
26509
|
+
console.warn(
|
|
26510
|
+
`${pj} cannot be read, it will be ignored for ES module detection purposes.`,
|
|
26511
|
+
e
|
|
26512
|
+
);
|
|
26513
|
+
return false;
|
|
26514
|
+
}
|
|
26515
|
+
}
|
|
26516
|
+
if (folder === "/") {
|
|
26517
|
+
return false;
|
|
26518
|
+
}
|
|
26519
|
+
return _hasFolderPackageJsonTypeModule(path.resolve(folder, ".."));
|
|
26520
|
+
}
|
|
26521
|
+
function _hasPackageJsonTypeModule(file) {
|
|
26522
|
+
const jsPath = file + ".js";
|
|
26523
|
+
return fs.existsSync(jsPath) ? _hasFolderPackageJsonTypeModule(path.resolve(path.dirname(jsPath))) : false;
|
|
26524
|
+
}
|
|
26525
|
+
async function _tryRequire(appRoot, moduleRoot, module3) {
|
|
26526
|
+
verbose(
|
|
26527
|
+
"Try loading as commonjs: ",
|
|
26528
|
+
module3,
|
|
26529
|
+
" with paths: ,",
|
|
26530
|
+
appRoot,
|
|
26531
|
+
moduleRoot
|
|
26532
|
+
);
|
|
26533
|
+
const lambdaStylePath = path.resolve(appRoot, moduleRoot, module3);
|
|
26534
|
+
const extensionless = _tryRequireFile(lambdaStylePath);
|
|
26535
|
+
if (extensionless) {
|
|
26536
|
+
return extensionless;
|
|
26537
|
+
}
|
|
26538
|
+
const pjHasModule = _hasPackageJsonTypeModule(lambdaStylePath);
|
|
26539
|
+
if (!pjHasModule) {
|
|
26540
|
+
const loaded2 = _tryRequireFile(lambdaStylePath, ".js");
|
|
26541
|
+
if (loaded2) {
|
|
26542
|
+
return loaded2;
|
|
26543
|
+
}
|
|
26544
|
+
}
|
|
26545
|
+
const loaded = pjHasModule && await _tryAwaitImport(lambdaStylePath, ".js") || await _tryAwaitImport(lambdaStylePath, ".mjs") || _tryRequireFile(lambdaStylePath, ".cjs");
|
|
26546
|
+
if (loaded) {
|
|
26547
|
+
return loaded;
|
|
26548
|
+
}
|
|
26549
|
+
verbose(
|
|
26550
|
+
"Try loading as commonjs: ",
|
|
26551
|
+
module3,
|
|
26552
|
+
" with path(s): ",
|
|
26553
|
+
appRoot,
|
|
26554
|
+
moduleRoot
|
|
26555
|
+
);
|
|
26556
|
+
const nodeStylePath = require.resolve(module3, {
|
|
26557
|
+
paths: [appRoot, moduleRoot]
|
|
26558
|
+
});
|
|
26559
|
+
return require(nodeStylePath);
|
|
26560
|
+
}
|
|
26561
|
+
async function _loadUserApp(appRoot, moduleRoot, module3) {
|
|
26562
|
+
if (!NoGlobalAwsLambda) {
|
|
26563
|
+
globalThis.awslambda = {
|
|
26564
|
+
streamifyResponse: (handler2, options) => {
|
|
26565
|
+
handler2[HANDLER_STREAMING] = STREAM_RESPONSE;
|
|
26566
|
+
if (typeof (options == null ? void 0 : options.highWaterMark) === "number") {
|
|
26567
|
+
handler2[HANDLER_HIGHWATERMARK] = parseInt(options.highWaterMark);
|
|
26568
|
+
}
|
|
26569
|
+
return handler2;
|
|
26570
|
+
},
|
|
26571
|
+
HttpResponseStream
|
|
26572
|
+
};
|
|
26573
|
+
}
|
|
26574
|
+
try {
|
|
26575
|
+
return await _tryRequire(appRoot, moduleRoot, module3);
|
|
26576
|
+
} catch (e) {
|
|
26577
|
+
if (e instanceof SyntaxError) {
|
|
26578
|
+
throw new UserCodeSyntaxError(e);
|
|
26579
|
+
} else if (e.code !== void 0 && e.code === "MODULE_NOT_FOUND") {
|
|
26580
|
+
verbose("globalPaths", JSON.stringify(require("module").globalPaths));
|
|
26581
|
+
throw new ImportModuleError(e);
|
|
26582
|
+
} else {
|
|
26583
|
+
throw e;
|
|
26584
|
+
}
|
|
26585
|
+
}
|
|
26586
|
+
}
|
|
26587
|
+
function _throwIfInvalidHandler(fullHandlerString) {
|
|
26588
|
+
if (fullHandlerString.includes(RELATIVE_PATH_SUBSTRING)) {
|
|
26589
|
+
throw new MalformedHandlerName(
|
|
26590
|
+
`'${fullHandlerString}' is not a valid handler name. Use absolute paths when specifying root directories in handler names.`
|
|
26591
|
+
);
|
|
26592
|
+
}
|
|
26593
|
+
}
|
|
26594
|
+
function _isHandlerStreaming(handler2) {
|
|
26595
|
+
if (typeof handler2[HANDLER_STREAMING] === "undefined" || handler2[HANDLER_STREAMING] === null || handler2[HANDLER_STREAMING] === false) {
|
|
26596
|
+
return false;
|
|
26597
|
+
}
|
|
26598
|
+
if (handler2[HANDLER_STREAMING] === STREAM_RESPONSE) {
|
|
26599
|
+
return STREAM_RESPONSE;
|
|
26600
|
+
} else {
|
|
26601
|
+
throw new MalformedStreamingHandler(
|
|
26602
|
+
"Only response streaming is supported."
|
|
26603
|
+
);
|
|
26604
|
+
}
|
|
26605
|
+
}
|
|
26606
|
+
function _highWaterMark(handler2) {
|
|
26607
|
+
if (typeof handler2[HANDLER_HIGHWATERMARK] === "undefined" || handler2[HANDLER_HIGHWATERMARK] === null || handler2[HANDLER_HIGHWATERMARK] === false) {
|
|
26608
|
+
return void 0;
|
|
26609
|
+
}
|
|
26610
|
+
const hwm = parseInt(handler2[HANDLER_HIGHWATERMARK]);
|
|
26611
|
+
return isNaN(hwm) ? void 0 : hwm;
|
|
26612
|
+
}
|
|
26613
|
+
module2.exports.load = async function(appRoot, fullHandlerString) {
|
|
26614
|
+
_throwIfInvalidHandler(fullHandlerString);
|
|
26615
|
+
let [moduleRoot, moduleAndHandler] = _moduleRootAndHandler(fullHandlerString);
|
|
26616
|
+
let [module3, handlerPath] = _splitHandlerString(moduleAndHandler);
|
|
26617
|
+
let userApp = await _loadUserApp(appRoot, moduleRoot, module3);
|
|
26618
|
+
let handlerFunc = _resolveHandler(userApp, handlerPath);
|
|
26619
|
+
if (!handlerFunc) {
|
|
26620
|
+
throw new HandlerNotFound(
|
|
26621
|
+
`${fullHandlerString} is undefined or not exported`
|
|
26622
|
+
);
|
|
26623
|
+
}
|
|
26624
|
+
if (typeof handlerFunc !== "function") {
|
|
26625
|
+
throw new HandlerNotFound(`${fullHandlerString} is not a function`);
|
|
26626
|
+
}
|
|
26627
|
+
return handlerFunc;
|
|
26628
|
+
};
|
|
26629
|
+
module2.exports.isHandlerFunction = function(value) {
|
|
26630
|
+
return typeof value === "function";
|
|
26631
|
+
};
|
|
26632
|
+
module2.exports.getHandlerMetadata = function(handlerFunc) {
|
|
26633
|
+
return {
|
|
26634
|
+
streaming: _isHandlerStreaming(handlerFunc),
|
|
26635
|
+
highWaterMark: _highWaterMark(handlerFunc)
|
|
26636
|
+
};
|
|
26637
|
+
};
|
|
26638
|
+
module2.exports.STREAM_RESPONSE = STREAM_RESPONSE;
|
|
26639
|
+
}
|
|
26640
|
+
});
|
|
26641
|
+
|
|
26275
26642
|
// extension/interceptor.ts
|
|
26276
26643
|
var interceptor_exports = {};
|
|
26277
26644
|
__export(interceptor_exports, {
|
|
@@ -26279,6 +26646,150 @@ __export(interceptor_exports, {
|
|
|
26279
26646
|
});
|
|
26280
26647
|
module.exports = __toCommonJS(interceptor_exports);
|
|
26281
26648
|
|
|
26649
|
+
// node_modules/serialize-error/error-constructors.js
|
|
26650
|
+
var list = [
|
|
26651
|
+
EvalError,
|
|
26652
|
+
RangeError,
|
|
26653
|
+
ReferenceError,
|
|
26654
|
+
SyntaxError,
|
|
26655
|
+
TypeError,
|
|
26656
|
+
URIError,
|
|
26657
|
+
globalThis.DOMException,
|
|
26658
|
+
globalThis.AssertionError,
|
|
26659
|
+
globalThis.SystemError
|
|
26660
|
+
].filter(Boolean).map(
|
|
26661
|
+
(constructor) => [constructor.name, constructor]
|
|
26662
|
+
);
|
|
26663
|
+
var errorConstructors = new Map(list);
|
|
26664
|
+
var error_constructors_default = errorConstructors;
|
|
26665
|
+
|
|
26666
|
+
// node_modules/serialize-error/index.js
|
|
26667
|
+
var commonProperties = [
|
|
26668
|
+
{
|
|
26669
|
+
property: "name",
|
|
26670
|
+
enumerable: false
|
|
26671
|
+
},
|
|
26672
|
+
{
|
|
26673
|
+
property: "message",
|
|
26674
|
+
enumerable: false
|
|
26675
|
+
},
|
|
26676
|
+
{
|
|
26677
|
+
property: "stack",
|
|
26678
|
+
enumerable: false
|
|
26679
|
+
},
|
|
26680
|
+
{
|
|
26681
|
+
property: "code",
|
|
26682
|
+
enumerable: true
|
|
26683
|
+
},
|
|
26684
|
+
{
|
|
26685
|
+
property: "cause",
|
|
26686
|
+
enumerable: false
|
|
26687
|
+
}
|
|
26688
|
+
];
|
|
26689
|
+
var toJsonWasCalled = Symbol(".toJSON was called");
|
|
26690
|
+
var toJSON = (from) => {
|
|
26691
|
+
from[toJsonWasCalled] = true;
|
|
26692
|
+
const json = from.toJSON();
|
|
26693
|
+
delete from[toJsonWasCalled];
|
|
26694
|
+
return json;
|
|
26695
|
+
};
|
|
26696
|
+
var getErrorConstructor = (name) => error_constructors_default.get(name) ?? Error;
|
|
26697
|
+
var destroyCircular = ({
|
|
26698
|
+
from,
|
|
26699
|
+
seen,
|
|
26700
|
+
to,
|
|
26701
|
+
forceEnumerable,
|
|
26702
|
+
maxDepth,
|
|
26703
|
+
depth,
|
|
26704
|
+
useToJSON,
|
|
26705
|
+
serialize
|
|
26706
|
+
}) => {
|
|
26707
|
+
if (!to) {
|
|
26708
|
+
if (Array.isArray(from)) {
|
|
26709
|
+
to = [];
|
|
26710
|
+
} else if (!serialize && isErrorLike(from)) {
|
|
26711
|
+
const Error2 = getErrorConstructor(from.name);
|
|
26712
|
+
to = new Error2();
|
|
26713
|
+
} else {
|
|
26714
|
+
to = {};
|
|
26715
|
+
}
|
|
26716
|
+
}
|
|
26717
|
+
seen.push(from);
|
|
26718
|
+
if (depth >= maxDepth) {
|
|
26719
|
+
return to;
|
|
26720
|
+
}
|
|
26721
|
+
if (useToJSON && typeof from.toJSON === "function" && from[toJsonWasCalled] !== true) {
|
|
26722
|
+
return toJSON(from);
|
|
26723
|
+
}
|
|
26724
|
+
const continueDestroyCircular = (value) => destroyCircular({
|
|
26725
|
+
from: value,
|
|
26726
|
+
seen: [...seen],
|
|
26727
|
+
forceEnumerable,
|
|
26728
|
+
maxDepth,
|
|
26729
|
+
depth,
|
|
26730
|
+
useToJSON,
|
|
26731
|
+
serialize
|
|
26732
|
+
});
|
|
26733
|
+
for (const [key, value] of Object.entries(from)) {
|
|
26734
|
+
if (typeof Buffer === "function" && Buffer.isBuffer(value)) {
|
|
26735
|
+
to[key] = "[object Buffer]";
|
|
26736
|
+
continue;
|
|
26737
|
+
}
|
|
26738
|
+
if (value !== null && typeof value === "object" && typeof value.pipe === "function") {
|
|
26739
|
+
to[key] = "[object Stream]";
|
|
26740
|
+
continue;
|
|
26741
|
+
}
|
|
26742
|
+
if (typeof value === "function") {
|
|
26743
|
+
continue;
|
|
26744
|
+
}
|
|
26745
|
+
if (!value || typeof value !== "object") {
|
|
26746
|
+
to[key] = value;
|
|
26747
|
+
continue;
|
|
26748
|
+
}
|
|
26749
|
+
if (!seen.includes(from[key])) {
|
|
26750
|
+
depth++;
|
|
26751
|
+
to[key] = continueDestroyCircular(from[key]);
|
|
26752
|
+
continue;
|
|
26753
|
+
}
|
|
26754
|
+
to[key] = "[Circular]";
|
|
26755
|
+
}
|
|
26756
|
+
for (const { property, enumerable } of commonProperties) {
|
|
26757
|
+
if (typeof from[property] !== "undefined" && from[property] !== null) {
|
|
26758
|
+
Object.defineProperty(to, property, {
|
|
26759
|
+
value: isErrorLike(from[property]) ? continueDestroyCircular(from[property]) : from[property],
|
|
26760
|
+
enumerable: forceEnumerable ? true : enumerable,
|
|
26761
|
+
configurable: true,
|
|
26762
|
+
writable: true
|
|
26763
|
+
});
|
|
26764
|
+
}
|
|
26765
|
+
}
|
|
26766
|
+
return to;
|
|
26767
|
+
};
|
|
26768
|
+
function serializeError(value, options = {}) {
|
|
26769
|
+
const {
|
|
26770
|
+
maxDepth = Number.POSITIVE_INFINITY,
|
|
26771
|
+
useToJSON = true
|
|
26772
|
+
} = options;
|
|
26773
|
+
if (typeof value === "object" && value !== null) {
|
|
26774
|
+
return destroyCircular({
|
|
26775
|
+
from: value,
|
|
26776
|
+
seen: [],
|
|
26777
|
+
forceEnumerable: true,
|
|
26778
|
+
maxDepth,
|
|
26779
|
+
depth: 0,
|
|
26780
|
+
useToJSON,
|
|
26781
|
+
serialize: true
|
|
26782
|
+
});
|
|
26783
|
+
}
|
|
26784
|
+
if (typeof value === "function") {
|
|
26785
|
+
return `[Function: ${value.name ?? "anonymous"}]`;
|
|
26786
|
+
}
|
|
26787
|
+
return value;
|
|
26788
|
+
}
|
|
26789
|
+
function isErrorLike(value) {
|
|
26790
|
+
return Boolean(value) && typeof value === "object" && "name" in value && "message" in value && "stack" in value;
|
|
26791
|
+
}
|
|
26792
|
+
|
|
26282
26793
|
// common/SpyEventSender.ts
|
|
26283
26794
|
var import_client_apigatewaymanagementapi = __toESM(require_dist_cjs44());
|
|
26284
26795
|
var import_client_dynamodb = __toESM(require_dist_cjs48());
|
|
@@ -26494,262 +27005,8 @@ var SpyEventSender = class {
|
|
|
26494
27005
|
}
|
|
26495
27006
|
};
|
|
26496
27007
|
|
|
26497
|
-
// extension/aws/UserFunction.ts
|
|
26498
|
-
var import_fs = __toESM(require("fs"));
|
|
26499
|
-
var import_path = __toESM(require("path"));
|
|
26500
|
-
|
|
26501
|
-
// extension/aws/Errors.ts
|
|
26502
|
-
var ExtendedError = class extends Error {
|
|
26503
|
-
constructor(reason) {
|
|
26504
|
-
super(reason);
|
|
26505
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
26506
|
-
}
|
|
26507
|
-
};
|
|
26508
|
-
var ImportModuleError = class extends ExtendedError {
|
|
26509
|
-
};
|
|
26510
|
-
var HandlerNotFound = class extends ExtendedError {
|
|
26511
|
-
};
|
|
26512
|
-
var MalformedHandlerName = class extends ExtendedError {
|
|
26513
|
-
};
|
|
26514
|
-
var UserCodeSyntaxError = class extends ExtendedError {
|
|
26515
|
-
};
|
|
26516
|
-
var UnhandledPromiseRejection = class extends ExtendedError {
|
|
26517
|
-
constructor(reason, promise) {
|
|
26518
|
-
super(reason);
|
|
26519
|
-
this.reason = reason;
|
|
26520
|
-
this.promise = promise;
|
|
26521
|
-
}
|
|
26522
|
-
};
|
|
26523
|
-
var errorClasses = [
|
|
26524
|
-
ImportModuleError,
|
|
26525
|
-
HandlerNotFound,
|
|
26526
|
-
MalformedHandlerName,
|
|
26527
|
-
UserCodeSyntaxError,
|
|
26528
|
-
UnhandledPromiseRejection
|
|
26529
|
-
];
|
|
26530
|
-
errorClasses.forEach((e) => {
|
|
26531
|
-
e.prototype.name = `Runtime.${e.name}`;
|
|
26532
|
-
});
|
|
26533
|
-
|
|
26534
|
-
// extension/aws/UserFunction.ts
|
|
26535
|
-
var FUNCTION_EXPR = /^([^.]*)\.(.*)$/;
|
|
26536
|
-
var RELATIVE_PATH_SUBSTRING = "..";
|
|
26537
|
-
function _moduleRootAndHandler(fullHandlerString) {
|
|
26538
|
-
const handlerString = import_path.default.basename(fullHandlerString);
|
|
26539
|
-
const moduleRoot = fullHandlerString.substring(
|
|
26540
|
-
0,
|
|
26541
|
-
fullHandlerString.indexOf(handlerString)
|
|
26542
|
-
);
|
|
26543
|
-
return [moduleRoot, handlerString];
|
|
26544
|
-
}
|
|
26545
|
-
function _splitHandlerString(handler2) {
|
|
26546
|
-
const match = handler2.match(FUNCTION_EXPR);
|
|
26547
|
-
if (!match || match.length != 3) {
|
|
26548
|
-
throw new MalformedHandlerName("Bad handler");
|
|
26549
|
-
}
|
|
26550
|
-
return [match[1], match[2]];
|
|
26551
|
-
}
|
|
26552
|
-
function _resolveHandler(object, nestedProperty) {
|
|
26553
|
-
return nestedProperty.split(".").reduce((nested, key) => {
|
|
26554
|
-
return nested && nested[key];
|
|
26555
|
-
}, object);
|
|
26556
|
-
}
|
|
26557
|
-
function _canLoadAsFile(modulePath) {
|
|
26558
|
-
return import_fs.default.existsSync(modulePath) || import_fs.default.existsSync(modulePath + ".js");
|
|
26559
|
-
}
|
|
26560
|
-
function _tryRequire(appRoot, moduleRoot, module2) {
|
|
26561
|
-
const lambdaStylePath = import_path.default.resolve(appRoot, moduleRoot, module2);
|
|
26562
|
-
if (_canLoadAsFile(lambdaStylePath)) {
|
|
26563
|
-
return require(lambdaStylePath);
|
|
26564
|
-
} else {
|
|
26565
|
-
const nodeStylePath = require.resolve(module2, {
|
|
26566
|
-
paths: [appRoot, moduleRoot]
|
|
26567
|
-
});
|
|
26568
|
-
return require(nodeStylePath);
|
|
26569
|
-
}
|
|
26570
|
-
}
|
|
26571
|
-
function _loadUserApp(appRoot, moduleRoot, module2) {
|
|
26572
|
-
try {
|
|
26573
|
-
return _tryRequire(appRoot, moduleRoot, module2);
|
|
26574
|
-
} catch (e) {
|
|
26575
|
-
if (e instanceof SyntaxError) {
|
|
26576
|
-
throw new UserCodeSyntaxError(e);
|
|
26577
|
-
} else if (e.code !== void 0 && e.code === "MODULE_NOT_FOUND") {
|
|
26578
|
-
throw new ImportModuleError(e);
|
|
26579
|
-
} else {
|
|
26580
|
-
throw e;
|
|
26581
|
-
}
|
|
26582
|
-
}
|
|
26583
|
-
}
|
|
26584
|
-
function _throwIfInvalidHandler(fullHandlerString) {
|
|
26585
|
-
if (fullHandlerString.includes(RELATIVE_PATH_SUBSTRING)) {
|
|
26586
|
-
throw new MalformedHandlerName(
|
|
26587
|
-
`'${fullHandlerString}' is not a valid handler name. Use absolute paths when specifying root directories in handler names.`
|
|
26588
|
-
);
|
|
26589
|
-
}
|
|
26590
|
-
}
|
|
26591
|
-
var load = function(appRoot, fullHandlerString) {
|
|
26592
|
-
_throwIfInvalidHandler(fullHandlerString);
|
|
26593
|
-
const [moduleRoot, moduleAndHandler] = _moduleRootAndHandler(fullHandlerString);
|
|
26594
|
-
const [module2, handlerPath] = _splitHandlerString(moduleAndHandler);
|
|
26595
|
-
const userApp = _loadUserApp(appRoot, moduleRoot, module2);
|
|
26596
|
-
const handlerFunc = _resolveHandler(userApp, handlerPath);
|
|
26597
|
-
if (!handlerFunc) {
|
|
26598
|
-
throw new HandlerNotFound(
|
|
26599
|
-
`${fullHandlerString} is undefined or not exported`
|
|
26600
|
-
);
|
|
26601
|
-
}
|
|
26602
|
-
if (typeof handlerFunc !== "function") {
|
|
26603
|
-
throw new HandlerNotFound(`${fullHandlerString} is not a function`);
|
|
26604
|
-
}
|
|
26605
|
-
return handlerFunc;
|
|
26606
|
-
};
|
|
26607
|
-
|
|
26608
|
-
// node_modules/serialize-error/error-constructors.js
|
|
26609
|
-
var list = [
|
|
26610
|
-
EvalError,
|
|
26611
|
-
RangeError,
|
|
26612
|
-
ReferenceError,
|
|
26613
|
-
SyntaxError,
|
|
26614
|
-
TypeError,
|
|
26615
|
-
URIError,
|
|
26616
|
-
globalThis.DOMException,
|
|
26617
|
-
globalThis.AssertionError,
|
|
26618
|
-
globalThis.SystemError
|
|
26619
|
-
].filter(Boolean).map(
|
|
26620
|
-
(constructor) => [constructor.name, constructor]
|
|
26621
|
-
);
|
|
26622
|
-
var errorConstructors = new Map(list);
|
|
26623
|
-
var error_constructors_default = errorConstructors;
|
|
26624
|
-
|
|
26625
|
-
// node_modules/serialize-error/index.js
|
|
26626
|
-
var commonProperties = [
|
|
26627
|
-
{
|
|
26628
|
-
property: "name",
|
|
26629
|
-
enumerable: false
|
|
26630
|
-
},
|
|
26631
|
-
{
|
|
26632
|
-
property: "message",
|
|
26633
|
-
enumerable: false
|
|
26634
|
-
},
|
|
26635
|
-
{
|
|
26636
|
-
property: "stack",
|
|
26637
|
-
enumerable: false
|
|
26638
|
-
},
|
|
26639
|
-
{
|
|
26640
|
-
property: "code",
|
|
26641
|
-
enumerable: true
|
|
26642
|
-
},
|
|
26643
|
-
{
|
|
26644
|
-
property: "cause",
|
|
26645
|
-
enumerable: false
|
|
26646
|
-
}
|
|
26647
|
-
];
|
|
26648
|
-
var toJsonWasCalled = Symbol(".toJSON was called");
|
|
26649
|
-
var toJSON = (from) => {
|
|
26650
|
-
from[toJsonWasCalled] = true;
|
|
26651
|
-
const json = from.toJSON();
|
|
26652
|
-
delete from[toJsonWasCalled];
|
|
26653
|
-
return json;
|
|
26654
|
-
};
|
|
26655
|
-
var getErrorConstructor = (name) => error_constructors_default.get(name) ?? Error;
|
|
26656
|
-
var destroyCircular = ({
|
|
26657
|
-
from,
|
|
26658
|
-
seen,
|
|
26659
|
-
to,
|
|
26660
|
-
forceEnumerable,
|
|
26661
|
-
maxDepth,
|
|
26662
|
-
depth,
|
|
26663
|
-
useToJSON,
|
|
26664
|
-
serialize
|
|
26665
|
-
}) => {
|
|
26666
|
-
if (!to) {
|
|
26667
|
-
if (Array.isArray(from)) {
|
|
26668
|
-
to = [];
|
|
26669
|
-
} else if (!serialize && isErrorLike(from)) {
|
|
26670
|
-
const Error2 = getErrorConstructor(from.name);
|
|
26671
|
-
to = new Error2();
|
|
26672
|
-
} else {
|
|
26673
|
-
to = {};
|
|
26674
|
-
}
|
|
26675
|
-
}
|
|
26676
|
-
seen.push(from);
|
|
26677
|
-
if (depth >= maxDepth) {
|
|
26678
|
-
return to;
|
|
26679
|
-
}
|
|
26680
|
-
if (useToJSON && typeof from.toJSON === "function" && from[toJsonWasCalled] !== true) {
|
|
26681
|
-
return toJSON(from);
|
|
26682
|
-
}
|
|
26683
|
-
const continueDestroyCircular = (value) => destroyCircular({
|
|
26684
|
-
from: value,
|
|
26685
|
-
seen: [...seen],
|
|
26686
|
-
forceEnumerable,
|
|
26687
|
-
maxDepth,
|
|
26688
|
-
depth,
|
|
26689
|
-
useToJSON,
|
|
26690
|
-
serialize
|
|
26691
|
-
});
|
|
26692
|
-
for (const [key, value] of Object.entries(from)) {
|
|
26693
|
-
if (typeof Buffer === "function" && Buffer.isBuffer(value)) {
|
|
26694
|
-
to[key] = "[object Buffer]";
|
|
26695
|
-
continue;
|
|
26696
|
-
}
|
|
26697
|
-
if (value !== null && typeof value === "object" && typeof value.pipe === "function") {
|
|
26698
|
-
to[key] = "[object Stream]";
|
|
26699
|
-
continue;
|
|
26700
|
-
}
|
|
26701
|
-
if (typeof value === "function") {
|
|
26702
|
-
continue;
|
|
26703
|
-
}
|
|
26704
|
-
if (!value || typeof value !== "object") {
|
|
26705
|
-
to[key] = value;
|
|
26706
|
-
continue;
|
|
26707
|
-
}
|
|
26708
|
-
if (!seen.includes(from[key])) {
|
|
26709
|
-
depth++;
|
|
26710
|
-
to[key] = continueDestroyCircular(from[key]);
|
|
26711
|
-
continue;
|
|
26712
|
-
}
|
|
26713
|
-
to[key] = "[Circular]";
|
|
26714
|
-
}
|
|
26715
|
-
for (const { property, enumerable } of commonProperties) {
|
|
26716
|
-
if (typeof from[property] !== "undefined" && from[property] !== null) {
|
|
26717
|
-
Object.defineProperty(to, property, {
|
|
26718
|
-
value: isErrorLike(from[property]) ? continueDestroyCircular(from[property]) : from[property],
|
|
26719
|
-
enumerable: forceEnumerable ? true : enumerable,
|
|
26720
|
-
configurable: true,
|
|
26721
|
-
writable: true
|
|
26722
|
-
});
|
|
26723
|
-
}
|
|
26724
|
-
}
|
|
26725
|
-
return to;
|
|
26726
|
-
};
|
|
26727
|
-
function serializeError(value, options = {}) {
|
|
26728
|
-
const {
|
|
26729
|
-
maxDepth = Number.POSITIVE_INFINITY,
|
|
26730
|
-
useToJSON = true
|
|
26731
|
-
} = options;
|
|
26732
|
-
if (typeof value === "object" && value !== null) {
|
|
26733
|
-
return destroyCircular({
|
|
26734
|
-
from: value,
|
|
26735
|
-
seen: [],
|
|
26736
|
-
forceEnumerable: true,
|
|
26737
|
-
maxDepth,
|
|
26738
|
-
depth: 0,
|
|
26739
|
-
useToJSON,
|
|
26740
|
-
serialize: true
|
|
26741
|
-
});
|
|
26742
|
-
}
|
|
26743
|
-
if (typeof value === "function") {
|
|
26744
|
-
return `[Function: ${value.name ?? "anonymous"}]`;
|
|
26745
|
-
}
|
|
26746
|
-
return value;
|
|
26747
|
-
}
|
|
26748
|
-
function isErrorLike(value) {
|
|
26749
|
-
return Boolean(value) && typeof value === "object" && "name" in value && "message" in value && "stack" in value;
|
|
26750
|
-
}
|
|
26751
|
-
|
|
26752
27008
|
// extension/interceptor.ts
|
|
27009
|
+
var import_UserFunction = __toESM(require_UserFunction());
|
|
26753
27010
|
var ORIGINAL_HANDLER_KEY = "ORIGINAL_HANDLER";
|
|
26754
27011
|
var subscribedToSQS = process.env["SSPY_SUBSCRIBED_TO_SQS" /* SSPY_SUBSCRIBED_TO_SQS */] === "true";
|
|
26755
27012
|
var debugMode = process.env["SSPY_DEBUG" /* SSPY_DEBUG */] === "true";
|
|
@@ -26766,7 +27023,7 @@ var spyEventSender = new SpyEventSender({
|
|
|
26766
27023
|
log,
|
|
26767
27024
|
logError
|
|
26768
27025
|
});
|
|
26769
|
-
var handler = (event, context, callback) => {
|
|
27026
|
+
var handler = async (event, context, callback) => {
|
|
26770
27027
|
const contextSpy = {
|
|
26771
27028
|
functionName: context.functionName,
|
|
26772
27029
|
awsRequestId: context.awsRequestId,
|
|
@@ -26788,7 +27045,7 @@ var handler = (event, context, callback) => {
|
|
|
26788
27045
|
context: contextSpy
|
|
26789
27046
|
});
|
|
26790
27047
|
promises.push(p);
|
|
26791
|
-
const originalHandler = getOriginalHandler();
|
|
27048
|
+
const originalHandler = await getOriginalHandler();
|
|
26792
27049
|
const fail = (error) => {
|
|
26793
27050
|
logError(error);
|
|
26794
27051
|
const errorSerialized = serializeError(error);
|
|
@@ -26824,7 +27081,7 @@ var handler = (event, context, callback) => {
|
|
|
26824
27081
|
try {
|
|
26825
27082
|
const result = originalHandler(event, context, newCallback);
|
|
26826
27083
|
if (isPromise(result)) {
|
|
26827
|
-
return new Promise((resolve, reject) => {
|
|
27084
|
+
return await new Promise((resolve, reject) => {
|
|
26828
27085
|
result.then(
|
|
26829
27086
|
(response) => succeed(response).then(() => {
|
|
26830
27087
|
resolve(response);
|
|
@@ -26895,11 +27152,11 @@ async function sendLambdaSpyEvent(serviceKey, data) {
|
|
|
26895
27152
|
async function sendRawSpyEvent(data) {
|
|
26896
27153
|
await spyEventSender.publishSpyEvent(data);
|
|
26897
27154
|
}
|
|
26898
|
-
function getOriginalHandler() {
|
|
27155
|
+
async function getOriginalHandler() {
|
|
26899
27156
|
log("Original handler", process.env[ORIGINAL_HANDLER_KEY]);
|
|
26900
27157
|
if (process.env[ORIGINAL_HANDLER_KEY] === void 0)
|
|
26901
27158
|
throw Error("Missing original handler");
|
|
26902
|
-
return load(
|
|
27159
|
+
return (0, import_UserFunction.load)(
|
|
26903
27160
|
process.env.LAMBDA_TASK_ROOT,
|
|
26904
27161
|
process.env[ORIGINAL_HANDLER_KEY]
|
|
26905
27162
|
);
|