UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.28 kB
"use strict";var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,m=(e,n)=>{for(var r in n)i(e,r,{get:n[r],enumerable:!0})},d=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of c(n))!l.call(e,t)&&t!==r&&i(e,t,{get:()=>n[t],enumerable:!(o=s(n,t))||o.enumerable});return e},g=e=>d(i({},"__esModule",{value:!0}),e),C={};m(C,{handler:()=>w}),module.exports=g(C);function f(e){let n=Object.entries(e).filter(([r])=>r.endsWith("Client")&&r!=="__Client");if(n.length==0)throw new Error("There is no *Client class in the package.");if(n.length>1)throw new Error(`There are more than one *Client classes in the package: ${n.map(r=>r[0]).join(",")}`);return n[0][1]}function h(e){return e.charAt(0).toUpperCase()+e.slice(1)}function p(e,n){let r=`${h(n)}Command`,o=Object.entries(e).find(([t])=>t.toLowerCase()===r.toLowerCase())?.[1];if(!o)throw new Error(`Unable to find command named: ${r} for action: ${n} in service package`);return o}var w=async e=>{console.log("Event: ",e);try{let n=require(`@aws-sdk/client-${e.service}`),r=f(n),o=p(n,e.action),t=new r({region:e.region,endpoint:e.endpoint}),a=new o(e.parameters??{});return await t.send(a)}catch(n){throw console.error("Error: ",n),n}};