UNPKG

lambda-live-debugger

Version:

Debug Lambda functions locally like it is running in the cloud

271 lines (251 loc) 11.5 kB
'use strict'; var middlewareHostHeader = require('@aws-sdk/middleware-host-header'); var middlewareLogger = require('@aws-sdk/middleware-logger'); var middlewareRecursionDetection = require('@aws-sdk/middleware-recursion-detection'); var middlewareUserAgent = require('@aws-sdk/middleware-user-agent'); var configResolver = require('@smithy/config-resolver'); var core = require('@smithy/core'); var schema = require('@smithy/core/schema'); var middlewareContentLength = require('@smithy/middleware-content-length'); var middlewareEndpoint = require('@smithy/middleware-endpoint'); var middlewareRetry = require('@smithy/middleware-retry'); var smithyClient = require('@smithy/smithy-client'); var httpAuthSchemeProvider = require('./auth/httpAuthSchemeProvider'); var runtimeConfig = require('./runtimeConfig'); var regionConfigResolver = require('@aws-sdk/region-config-resolver'); var protocolHttp = require('@smithy/protocol-http'); var schemas_0 = require('./schemas/schemas_0'); var errors = require('./models/errors'); var IoTDataPlaneServiceException = require('./models/IoTDataPlaneServiceException'); const resolveClientEndpointParameters = (options) => { return Object.assign(options, { useDualstackEndpoint: options.useDualstackEndpoint ?? false, useFipsEndpoint: options.useFipsEndpoint ?? false, defaultSigningName: "iotdata", }); }; const commonParams = { UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, Endpoint: { type: "builtInParams", name: "endpoint" }, Region: { type: "builtInParams", name: "region" }, UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, }; const getHttpAuthExtensionConfiguration = (runtimeConfig) => { const _httpAuthSchemes = runtimeConfig.httpAuthSchemes; let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider; let _credentials = runtimeConfig.credentials; return { setHttpAuthScheme(httpAuthScheme) { const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId); if (index === -1) { _httpAuthSchemes.push(httpAuthScheme); } else { _httpAuthSchemes.splice(index, 1, httpAuthScheme); } }, httpAuthSchemes() { return _httpAuthSchemes; }, setHttpAuthSchemeProvider(httpAuthSchemeProvider) { _httpAuthSchemeProvider = httpAuthSchemeProvider; }, httpAuthSchemeProvider() { return _httpAuthSchemeProvider; }, setCredentials(credentials) { _credentials = credentials; }, credentials() { return _credentials; }, }; }; const resolveHttpAuthRuntimeConfig = (config) => { return { httpAuthSchemes: config.httpAuthSchemes(), httpAuthSchemeProvider: config.httpAuthSchemeProvider(), credentials: config.credentials(), }; }; const resolveRuntimeExtensions = (runtimeConfig, extensions) => { const extensionConfiguration = Object.assign(regionConfigResolver.getAwsRegionExtensionConfiguration(runtimeConfig), smithyClient.getDefaultExtensionConfiguration(runtimeConfig), protocolHttp.getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig)); extensions.forEach((extension) => extension.configure(extensionConfiguration)); return Object.assign(runtimeConfig, regionConfigResolver.resolveAwsRegionExtensionConfiguration(extensionConfiguration), smithyClient.resolveDefaultRuntimeConfig(extensionConfiguration), protocolHttp.resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration)); }; class IoTDataPlaneClient extends smithyClient.Client { config; constructor(...[configuration]) { const _config_0 = runtimeConfig.getRuntimeConfig(configuration || {}); super(_config_0); this.initConfig = _config_0; const _config_1 = resolveClientEndpointParameters(_config_0); const _config_2 = middlewareUserAgent.resolveUserAgentConfig(_config_1); const _config_3 = middlewareRetry.resolveRetryConfig(_config_2); const _config_4 = configResolver.resolveRegionConfig(_config_3); const _config_5 = middlewareHostHeader.resolveHostHeaderConfig(_config_4); const _config_6 = middlewareEndpoint.resolveEndpointConfig(_config_5); const _config_7 = httpAuthSchemeProvider.resolveHttpAuthSchemeConfig(_config_6); const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []); this.config = _config_8; this.middlewareStack.use(schema.getSchemaSerdePlugin(this.config)); this.middlewareStack.use(middlewareUserAgent.getUserAgentPlugin(this.config)); this.middlewareStack.use(middlewareRetry.getRetryPlugin(this.config)); this.middlewareStack.use(middlewareContentLength.getContentLengthPlugin(this.config)); this.middlewareStack.use(middlewareHostHeader.getHostHeaderPlugin(this.config)); this.middlewareStack.use(middlewareLogger.getLoggerPlugin(this.config)); this.middlewareStack.use(middlewareRecursionDetection.getRecursionDetectionPlugin(this.config)); this.middlewareStack.use(core.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, { httpAuthSchemeParametersProvider: httpAuthSchemeProvider.defaultIoTDataPlaneHttpAuthSchemeParametersProvider, identityProviderConfigProvider: async (config) => new core.DefaultIdentityProviderConfig({ "aws.auth#sigv4": config.credentials, }), })); this.middlewareStack.use(core.getHttpSigningPlugin(this.config)); } destroy() { super.destroy(); } } class DeleteConnectionCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "DeleteConnection", {}) .n("IoTDataPlaneClient", "DeleteConnectionCommand") .sc(schemas_0.DeleteConnection$) .build() { } class DeleteThingShadowCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "DeleteThingShadow", {}) .n("IoTDataPlaneClient", "DeleteThingShadowCommand") .sc(schemas_0.DeleteThingShadow$) .build() { } class GetRetainedMessageCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "GetRetainedMessage", {}) .n("IoTDataPlaneClient", "GetRetainedMessageCommand") .sc(schemas_0.GetRetainedMessage$) .build() { } class GetThingShadowCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "GetThingShadow", {}) .n("IoTDataPlaneClient", "GetThingShadowCommand") .sc(schemas_0.GetThingShadow$) .build() { } class ListNamedShadowsForThingCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "ListNamedShadowsForThing", {}) .n("IoTDataPlaneClient", "ListNamedShadowsForThingCommand") .sc(schemas_0.ListNamedShadowsForThing$) .build() { } class ListRetainedMessagesCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "ListRetainedMessages", {}) .n("IoTDataPlaneClient", "ListRetainedMessagesCommand") .sc(schemas_0.ListRetainedMessages$) .build() { } class PublishCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "Publish", {}) .n("IoTDataPlaneClient", "PublishCommand") .sc(schemas_0.Publish$) .build() { } class UpdateThingShadowCommand extends smithyClient.Command .classBuilder() .ep(commonParams) .m(function (Command, cs, config, o) { return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())]; }) .s("IotMoonrakerService", "UpdateThingShadow", {}) .n("IoTDataPlaneClient", "UpdateThingShadowCommand") .sc(schemas_0.UpdateThingShadow$) .build() { } const paginateListRetainedMessages = core.createPaginator(IoTDataPlaneClient, ListRetainedMessagesCommand, "nextToken", "nextToken", "maxResults"); const commands = { DeleteConnectionCommand, DeleteThingShadowCommand, GetRetainedMessageCommand, GetThingShadowCommand, ListNamedShadowsForThingCommand, ListRetainedMessagesCommand, PublishCommand, UpdateThingShadowCommand, }; const paginators = { paginateListRetainedMessages, }; class IoTDataPlane extends IoTDataPlaneClient { } smithyClient.createAggregatedClient(commands, IoTDataPlane, { paginators }); const PayloadFormatIndicator = { UNSPECIFIED_BYTES: "UNSPECIFIED_BYTES", UTF8_DATA: "UTF8_DATA", }; exports.$Command = smithyClient.Command; exports.__Client = smithyClient.Client; exports.IoTDataPlaneServiceException = IoTDataPlaneServiceException.IoTDataPlaneServiceException; exports.DeleteConnectionCommand = DeleteConnectionCommand; exports.DeleteThingShadowCommand = DeleteThingShadowCommand; exports.GetRetainedMessageCommand = GetRetainedMessageCommand; exports.GetThingShadowCommand = GetThingShadowCommand; exports.IoTDataPlane = IoTDataPlane; exports.IoTDataPlaneClient = IoTDataPlaneClient; exports.ListNamedShadowsForThingCommand = ListNamedShadowsForThingCommand; exports.ListRetainedMessagesCommand = ListRetainedMessagesCommand; exports.PayloadFormatIndicator = PayloadFormatIndicator; exports.PublishCommand = PublishCommand; exports.UpdateThingShadowCommand = UpdateThingShadowCommand; exports.paginateListRetainedMessages = paginateListRetainedMessages; Object.prototype.hasOwnProperty.call(schemas_0, '__proto__') && !Object.prototype.hasOwnProperty.call(exports, '__proto__') && Object.defineProperty(exports, '__proto__', { enumerable: true, value: schemas_0['__proto__'] }); Object.keys(schemas_0).forEach(function (k) { if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = schemas_0[k]; }); Object.prototype.hasOwnProperty.call(errors, '__proto__') && !Object.prototype.hasOwnProperty.call(exports, '__proto__') && Object.defineProperty(exports, '__proto__', { enumerable: true, value: errors['__proto__'] }); Object.keys(errors).forEach(function (k) { if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = errors[k]; });