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cAAgB,CAC5D,MAAoB,IAAd,EAAqB,SAAW,gBALtC,KAAK,WAAW,IAAI,IAAI,iCAAiC,qDAOjE","file":"/npm/serverless-plugin-xray@2.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/serverless-plugin-xray@2.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst PLUGIN_NAME = 'serverless-plugin-xray';\n\nmodule.exports = class TracingConfigPlugin {\n    constructor(serverless, options) {\n        this.serverless = serverless;\n        this.options = options;\n        this.hooks = {\n            'package:compileEvents': this.processTracing.bind(this)\n        };\n\n        // Validate the schema, required in serverless 2.x and above\n        if (this.serverless.configSchemaHandler && this.serverless.configSchemaHandler.defineCustomProperties) {\n            this.serverless.configSchemaHandler.defineCustomProperties({\n                type: 'object',\n                properties: {\n                    [PLUGIN_NAME]: {\n                        type: 'object',\n                        properties: {\n                            tracing: { type: 'boolean' }\n                        }\n                    }\n                }\n            });\n        }\n    }\n\n    processTracing() {\n        const service = this.serverless.service;\n        this.functionResources = Object.keys(service.provider.compiledCloudFormationTemplate.Resources)\n            .reduce((acc, resourceId) => {\n                const resource = service.provider.compiledCloudFormationTemplate.Resources[resourceId];\n                if (resource.Type === \"AWS::Lambda::Function\") {\n                    if (resource.Properties) {\n                        acc[resource.Properties.FunctionName] = resource;\n                    }\n                }\n                return acc;\n            }, {});\n\n        const stage = this.options.stage;\n        const provider = service.provider || {};\n        const legacyTracing = (provider.tracing || false).toString() === 'true';\n\n        const custom = service.custom || {};\n        const pluginCustom = custom[PLUGIN_NAME] || {};\n        const tracing = (pluginCustom.tracing || false).toString() === 'true';\n        const providerLevelTracingEnabled = tracing || legacyTracing;\n\n        return Promise.all(Object.keys(service.functions).map(functionName => {\n            var func = service.functions[functionName];\n            var enabled = providerLevelTracingEnabled;\n            if (typeof func.tracing !== 'undefined') {\n                enabled = func.tracing.toString() === 'true';\n            }\n            return this.toggleTracing(func.name || `${service.service}-${stage}-${functionName}`, enabled);\n        }));\n    }\n\n    toggleTracing(functionName, isEnabled) {\n        if (!this.functionResources[functionName]) {\n            this.serverless.cli.log(`Tracing NOT SET for function \"${functionName}\" as couldn't find it in Cloud Formation template`);\n            return;\n        }\n        this.serverless.cli.log(`Tracing ${isEnabled ? 'ENABLED' : 'DISABLED'} for function \"${functionName}\"`);\n        this.functionResources[functionName].Properties.TracingConfig = {\n            Mode: isEnabled === true ? 'Active' : 'PassThrough'\n        };\n    }\n};\n"]}