redleaf-ishell 1.0.2 → 1.0.3
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/API.cjs +1 -0
- package/API.js +1 -1
- package/LambdaSimulatorAPI.cjs +2 -0
- package/LambdaSimulatorAPI.js +1 -1
- package/OpenAPI.cjs +1 -0
- package/OpenAPI.js +1 -1
- package/aws/Kinesis.cjs +1 -0
- package/aws/Kinesis.js +1 -1
- package/chunk-4WZAN36M.js +4 -0
- package/chunk-4ZIBH32D.js +1 -0
- package/chunk-6QP54GKU.js +1 -0
- package/chunk-6W4C3JBY.js +1 -0
- package/chunk-7LZN2JAA.js +1 -0
- package/chunk-AVMTVHWW.js +2 -0
- package/chunk-INB47U4Q.js +1 -0
- package/chunk-LXIIMVCF.js +3 -0
- package/chunk-RO2W6WB2.js +2 -0
- package/chunk-S3PQMJO4.js +2 -0
- package/chunk-S5BWAMGC.js +1 -0
- package/chunk-TRA2JUZE.js +1 -0
- package/chunk-UYING5L4.js +1 -0
- package/chunk-YCH4ABT5.js +1 -0
- package/chunk-YEDXPIF7.js +1 -0
- package/chunk-ZR7NQQXZ.js +1 -0
- package/errors.cjs +1 -0
- package/errors.js +1 -1
- package/exports.cjs +7 -0
- package/exports.js +2 -1
- package/handlers/KinesisHandler.cjs +1 -0
- package/handlers/KinesisHandler.js +1 -1
- package/handlers/S3Handler.cjs +1 -0
- package/handlers/S3Handler.js +1 -1
- package/handlers/SNSHandler.cjs +1 -0
- package/handlers/SNSHandler.js +1 -1
- package/handlers/amazonConnect.cjs +1 -0
- package/handlers/amazonConnect.js +1 -1
- package/handlers/console.cjs +3 -0
- package/handlers/console.js +1 -1
- package/handlers/express.cjs +1 -0
- package/handlers/express.js +1 -1
- package/handlers/handlers.cjs +1 -0
- package/handlers/handlers.js +1 -1
- package/handlers/inputHandler.cjs +1 -0
- package/handlers/inputHandler.js +1 -1
- package/handlers/lambdaURL.cjs +1 -0
- package/handlers/lambdaURL.js +1 -1
- package/lambdaHandler.cjs +2 -0
- package/lambdaHandler.js +1 -1
- package/local.js +3 -1
- package/localCLI.js +1 -1
- package/localServer.cjs +2 -0
- package/localServer.js +1 -1
- package/notifications/NotificationChannel.cjs +1 -0
- package/notifications/NotificationChannel.js +1 -1
- package/notifications/SNSPublisher.cjs +1 -0
- package/notifications/SNSPublisher.js +1 -1
- package/package.json +1 -4
- package/response.cjs +2 -0
- package/response.js +1 -1
package/API.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var L=(o,e)=>{for(var t in e)P(o,t,{get:e[t],enumerable:!0})},E=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of S(e))!v.call(o,n)&&n!==t&&P(o,n,{get:()=>e[n],enumerable:!(r=O(e,n))||r.enumerable});return o};var $=o=>E(P({},"__esModule",{value:!0}),o);var q={};L(q,{APIInterface:()=>k});module.exports=$(q);var b=class{#e;#t;#n=200;get content(){return this.#e}get contentType(){return this.#t}get returnCode(){return this.#n}constructor(e,t){this.#e=e,this.#t=t}errorCode(e){return this.#n=e,this}},h=class extends b{constructor(e){super(e,"application/json")}};var f=class{#e;#t;#n;#r;#s;constructor(e,t,r,n="/",i={}){this.#e=e,this.#t=n.startsWith("/")?n:"/"+n,this.#n=i,this.#r=t||"API Documentation",this.#s=r||"1.0.0"}async json(){let e={openapi:"3.0.0",info:{title:this.#r,version:this.#s},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return e.paths=await this.#i(this.#e,this.#t,this.#n),e.tags=await this.#o(this.#e,this.#t),e}async#i(e,t,r,n=null){let i={},a={...r};for(let[c,s]of Object.entries(e.schema)){let d=`${t.endsWith("/")?t.slice(0,-1):t}/${c}`,A=s.method||"get",R=[...Object.entries(a).map(([p,u])=>({name:p,in:u.in||"path",required:u.required||!1,schema:{type:u.type||"string"},description:u.description||""})),...Object.entries(s.params||{}).map(([p,u])=>({name:p,in:u.in||"query",required:u.required||!1,default:u.default,schema:{type:u.type||"string"},description:u.description||""}))],I=s.responses||{200:{description:"Successful response"}},w={summary:s.summary||"",description:s.description||"",operationId:this.#a(d),tags:n?[n]:[],parameters:R,responses:I};(I[401]||I[401])&&(w.security=[{ApiKeyAuth:[]}]),s.body&&(w.requestBody={content:{"application/json":{schema:s.body}}});let N={[A.toLowerCase()]:w};if(s.api===!0&&typeof s.action=="function"){let p=null;if(s.params){p=[];for(let[m,j]of Object.entries(s.params))j.in==="path"&&(d+=`/{${m}}`),p.push(m),a[m]=j}let u=await this.#i(await s.action(p?Object.fromEntries(p.map(m=>[m,m])):{},null,{}),d,a,s.tag??null);if(s.params)for(let m of Object.keys(s.params))delete a[m];Object.assign(i,u)}else i[d]=N}return i}async#o(e,t){let r=[];for(let[n,i]of Object.entries(e.schema)){let c=`${t.endsWith("/")?t.slice(0,-1):t}/${n}`;if(i.api===!0&&typeof i.action=="function"){r.push({name:i.tag||c,description:i.description||""});let s={};if(i.params)for(let[d,A]of Object.entries(i.params))A.in==="path"&&(c+=`/{${d}}`),s[d]=d;let l=await this.#o(await i.action(s,null,{}),c);r=[...r,...l]}}return r}#a(e){return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};var y=class extends Error{#e;#t;get statusCode(){return this.#e}get name(){return this.#t}constructor(e,t,r){super(t),this.#t=e,this.#e=r}},g=class extends y{constructor(e="Not Found",t=404){super("NotFoundError",e,t)}};var x=class extends y{constructor(e="Unauthorized",t=401){super("AuthError",e,t)}};var k=class o{#e;get schema(){return this.#e}#t;#n;constructor(e={},t="API Documentation",r="Unknown"){this.#e=this.#r(e),this.#t=`${t} (${process.env.AWS_LAMBDA_FUNCTION_NAME||"Local"})`,this.#n=r}get isAPIInterface(){return!0}async execute(e,t,r,n,i={}){Array.isArray(e)||(e=[e]);let a=e.join("/"),c=await this.exrec([...e],t,r,n,i);return c?.isAPIInterface===!0?c.usage(a,this.#e[a]?.params):c}async exrec(e,t,r,n,i={}){let a=this;for(;e.length>0;){let c=e.splice(0,1)[0],s=a.#e[c];if(!s)throw new g(c+" not found");if(s.params&&Object.keys(s.params).length>0)for(let d of Object.keys(s.params))s.params[d]?.in==="path"&&(t[d]=e.splice(0,1)[0]);let l=await s.action(t,n,i);if(e.length===0)return l;if(!(l instanceof o))throw new g(c+" not found");a=l}return a}async usage(e,t={}){let r=await new f(this,this.#t,this.#n,e,t).json();return new h(r)}addHandler(e,t){this.#e[e]={method:"post",action:t}}addLambdaSimulator(e){let t=process.env.ALLOW_API?.split(",").map(n=>n.trim())||["all"];(process.env.DENY_API?.split(",").map(n=>n.trim())||[]).indexOf("lambda")>=0||t.indexOf("all")<0&&t.indexOf("lambda")<0||(this.#e.lambda={api:!0,toplevel:!0,tag:"Lambda Simulator",description:"Simulate Lambda invocation using REST API",action:e})}#r(e){let t=process.env.ALLOW_API?.split(",").map(n=>n.trim())||null,r=process.env.DENY_API?.split(",").map(n=>n.trim())||[];if(r[0]?.toLowerCase()==="all")return{};for(let n of Object.keys(e))e[n].api&&e[n].toplevel&&(t&&t.indexOf(n)<0||r.indexOf(n)>=0)&&delete e[n];return e}async resolveMethod(e){Array.isArray(e)||(e=[e]),e=[...e];let t=this.#e,r="get";for(let n=0;n<e.length;n++){let i=t[e[n]];if(!i)return r;if(i.method&&(r=i.method),n<e.length-1&&i.action)try{let a=await i.action({},null,{});if(a?.isAPIInterface)t=a.schema;else return r}catch{return r}}return r}confirmAPIKey(e,t){if(t){let r=e["x-api-key"];if(!r||r!==t)throw new x("Invalid or missing API key")}}};0&&(module.exports={APIInterface});
|
package/API.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"./chunk-INB47U4Q.js";import"./chunk-6QP54GKU.js";import"./chunk-S5BWAMGC.js";import"./chunk-S3PQMJO4.js";export{a as APIInterface};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var U=Object.create;var A=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var B=(r,t)=>{for(var n in t)A(r,n,{get:t[n],enumerable:!0})},E=(r,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of M(t))!K.call(r,s)&&s!==n&&A(r,s,{get:()=>t[s],enumerable:!(e=W(t,s))||e.enumerable});return r};var q=(r,t,n)=>(n=r!=null?U(F(r)):{},E(t||!r||!r.__esModule?A(n,"default",{value:r,enumerable:!0}):n,r)),Y=r=>E(A({},"__esModule",{value:!0}),r);var G={};B(G,{LambdaSimulatorAPI:()=>v});module.exports=Y(G);var C=class{#t;#n;#e=200;get content(){return this.#t}get contentType(){return this.#n}get returnCode(){return this.#e}constructor(t,n){this.#t=t,this.#n=n}errorCode(t){return this.#e=t,this}},h=class extends C{constructor(t){super(t,"application/json")}};var y=class{#t;#n;#e;#s;#r;constructor(t,n,e,s="/",i={}){this.#t=t,this.#n=s.startsWith("/")?s:"/"+s,this.#e=i,this.#s=n||"API Documentation",this.#r=e||"1.0.0"}async json(){let t={openapi:"3.0.0",info:{title:this.#s,version:this.#r},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return t.paths=await this.#o(this.#t,this.#n,this.#e),t.tags=await this.#i(this.#t,this.#n),t}async#o(t,n,e,s=null){let i={},o={...e};for(let[c,a]of Object.entries(t.schema)){let u=`${n.endsWith("/")?n.slice(0,-1):n}/${c}`,N=a.method||"get",$=[...Object.entries(o).map(([g,p])=>({name:g,in:p.in||"path",required:p.required||!1,schema:{type:p.type||"string"},description:p.description||""})),...Object.entries(a.params||{}).map(([g,p])=>({name:g,in:p.in||"query",required:p.required||!1,default:p.default,schema:{type:p.type||"string"},description:p.description||""}))],O=a.responses||{200:{description:"Successful response"}},j={summary:a.summary||"",description:a.description||"",operationId:this.#a(u),tags:s?[s]:[],parameters:$,responses:O};(O[401]||O[401])&&(j.security=[{ApiKeyAuth:[]}]),a.body&&(j.requestBody={content:{"application/json":{schema:a.body}}});let z={[N.toLowerCase()]:j};if(a.api===!0&&typeof a.action=="function"){let g=null;if(a.params){g=[];for(let[m,L]of Object.entries(a.params))L.in==="path"&&(u+=`/{${m}}`),g.push(m),o[m]=L}let p=await this.#o(await a.action(g?Object.fromEntries(g.map(m=>[m,m])):{},null,{}),u,o,a.tag??null);if(a.params)for(let m of Object.keys(a.params))delete o[m];Object.assign(i,p)}else i[u]=z}return i}async#i(t,n){let e=[];for(let[s,i]of Object.entries(t.schema)){let c=`${n.endsWith("/")?n.slice(0,-1):n}/${s}`;if(i.api===!0&&typeof i.action=="function"){e.push({name:i.tag||c,description:i.description||""});let a={};if(i.params)for(let[u,N]of Object.entries(i.params))N.in==="path"&&(c+=`/{${u}}`),a[u]=u;let l=await this.#i(await i.action(a,null,{}),c);e=[...e,...l]}}return e}#a(t){return t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,-1)),t.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};var f=class extends Error{#t;#n;get statusCode(){return this.#t}get name(){return this.#n}constructor(t,n,e){super(n),this.#n=t,this.#t=e}},w=class extends f{constructor(t="Not Found",n=404){super("NotFoundError",t,n)}};var S=class extends f{constructor(t="Unauthorized",n=401){super("AuthError",t,n)}};var P=class r{#t;get schema(){return this.#t}#n;#e;constructor(t={},n="API Documentation",e="Unknown"){this.#t=this.#s(t),this.#n=`${n} (${process.env.AWS_LAMBDA_FUNCTION_NAME||"Local"})`,this.#e=e}get isAPIInterface(){return!0}async execute(t,n,e,s,i={}){Array.isArray(t)||(t=[t]);let o=t.join("/"),c=await this.exrec([...t],n,e,s,i);return c?.isAPIInterface===!0?c.usage(o,this.#t[o]?.params):c}async exrec(t,n,e,s,i={}){let o=this;for(;t.length>0;){let c=t.splice(0,1)[0],a=o.#t[c];if(!a)throw new w(c+" not found");if(a.params&&Object.keys(a.params).length>0)for(let u of Object.keys(a.params))a.params[u]?.in==="path"&&(n[u]=t.splice(0,1)[0]);let l=await a.action(n,s,i);if(t.length===0)return l;if(!(l instanceof r))throw new w(c+" not found");o=l}return o}async usage(t,n={}){let e=await new y(this,this.#n,this.#e,t,n).json();return new h(e)}addHandler(t,n){this.#t[t]={method:"post",action:n}}addLambdaSimulator(t){let n=process.env.ALLOW_API?.split(",").map(s=>s.trim())||["all"];(process.env.DENY_API?.split(",").map(s=>s.trim())||[]).indexOf("lambda")>=0||n.indexOf("all")<0&&n.indexOf("lambda")<0||(this.#t.lambda={api:!0,toplevel:!0,tag:"Lambda Simulator",description:"Simulate Lambda invocation using REST API",action:t})}#s(t){let n=process.env.ALLOW_API?.split(",").map(s=>s.trim())||null,e=process.env.DENY_API?.split(",").map(s=>s.trim())||[];if(e[0]?.toLowerCase()==="all")return{};for(let s of Object.keys(t))t[s].api&&t[s].toplevel&&(n&&n.indexOf(s)<0||e.indexOf(s)>=0)&&delete t[s];return t}async resolveMethod(t){Array.isArray(t)||(t=[t]),t=[...t];let n=this.#t,e="get";for(let s=0;s<t.length;s++){let i=n[t[s]];if(!i)return e;if(i.method&&(e=i.method),s<t.length-1&&i.action)try{let o=await i.action({},null,{});if(o?.isAPIInterface)n=o.schema;else return e}catch{return e}}return e}confirmAPIKey(t,n){if(n){let e=t["x-api-key"];if(!e||e!==n)throw new S("Invalid or missing API key")}}};var d=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,n={}){return t}shortInputLog(t){let n=JSON.stringify(t);return n.length>100&&(n=n.substring(0,100)+"..."),n}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var k=class extends d{static isExpressURL(t){let n=t;if(!n?.method||!n?.requestContext)return!1;let e=n.requestContext;return!(!e?.http||!e.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let e=t.requestContext.http.path||"";e[0]==="/"&&(e=e.substring(1));let s=e.lastIndexOf(".");s>0?(this._format=e.substring(s+1),e=e.substring(0,s)):this._format="json",this._path=e.split("/"),this._headers=t.headers||{}}processResponse(t,n={}){n["Content-Type"]=t.contentType;let e=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:n,body:e}}};var R=class extends d{static isLambdaURL(t){let n=t;if(!n?.requestContext)return!1;let e=n.requestContext;if(!e?.http)return!1;let s=e.http;return!(!s?.method||!s?.path)}constructor(t){super("lambda_url");let n=t.requestContext;this._method=n.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let e=n.http.path;e[0]==="/"&&(e=e.substring(1));let s=e.lastIndexOf(".");s>0?(this._format=e.substring(s+1),e=e.substring(0,s)):this._format="json",this._path=e.split("/"),this._headers=t.headers||{}}shortInputLog(t){let n=t,e=n.requestContext;return JSON.stringify({path:e?.http?.path,method:e?.http?.method,params:n.queryStringParameters,sourceIp:e?.http?.sourceIp})}processResponse(t,n={}){let e={...n,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},s=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:e,body:s}}};var x=class extends d{static isAmazonConnect(t){let n=t;return!(n?.Name!=="ContactFlowEvent"||!n.Details||!n.Details.ContactData)}#t;get initMethod(){return this.#t}#n;get contactid(){return this.#n}#e;get systemEndpoint(){return this.#e}#s;get customerEndpoint(){return this.#s}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let n=t.Details;this._params=n.Parameters||null;let e=n.ContactData;this._params||(this._params=e.Attributes||{});let s=this._params.path||"";this._path=s.split("/");let i=e.Attributes;this._method=i?.method||"get",this.#n=e.ContactId,this.#n&&(this._params.contactid=this.#n),this.#e=e.SystemEndpoint?.Address,this.#s=e.CustomerEndpoint?.Address,this._payload=i,this.#t=e.InitiationMethod,this.#r=e.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,n={}){let e=t.content;return e.lambdaResult="Success",e}};var b=class r extends d{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(r.identifier),this._path=r.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};var _=class r extends d{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=r.identifier,this._method="post",this._params={},this._payload=r.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(n=>({eventName:n.eventName,bucket:n.s3?.bucket?.name,key:n.s3?.object?.key,size:n.s3?.object?.size}))}shortInputLog(t){let e=t?.Records?.[0],s=e?.s3?.bucket?.name??"?",i=e?.s3?.object?.key??"?";return`S3 ${e?.eventName??"event"}: s3://${s}/${i}`}};var I=class r extends d{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=r.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(e=>{try{return JSON.parse(e.Sns.Message)}catch{return e.Sns.Message}})}};var T={matchHandler(r){return R.isLambdaURL(r)?new R(r):k.isExpressURL(r)?new k(r):x.isAmazonConnect(r)?new x(r):b.isKinesis(r)?new b(r):_.isS3(r)?new _(r):I.isSNS(r)?new I(r):null}};var D=q(require("fs"),1),J=q(require("mime-types"),1),H=async(r,t)=>{let n=T.matchHandler(r);if(!n)return console.error("No handler found for input"),console.log("INPUT",JSON.stringify(r)),{statusCode:400,body:"Input not recognized"};let e={"Access-Control-Allow-Origin":"*"};if(n.method.toLowerCase()==="options"){let o=n.headers;return e={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":o["access-control-request-method"],"Access-Control-Allow-Headers":o["access-control-request-headers"]},console.log("CORS request service"),{statusCode:200,headers:e}}let s=n.path;if(s[0]==="docs"){let o,c;if(s.length>1){o=s.slice(1).join("/");let l=n.format;l?(o+="."+l,c=J.default.lookup(o)||"application/octet-stream"):c="application/octet-stream"}else o="index.html",c="text/html";o=process.cwd()+"/node_modules/redleaf-ishell/swagger/"+o;let a=D.default.readFileSync(o);return console.log("Docs file",o,a.length),{statusCode:200,headers:{...e,"Content-Type":c,"Access-Control-Allow-Origin":"*","Content-Source":"static"},body:a.toString()}}let i={...n.headers,_handler_type:n.type};try{process.env.AWS_LOG_IO==="true"?console.log("INPUT",JSON.stringify(r)):console.log(n.shortInputLog(r));let o=await t.execute(s,n.params,n.method,n.payload,i);return n.processResponse(o,e)}catch(o){if(console.log("INPUT",JSON.stringify(r)),o instanceof f)return{statusCode:o.statusCode,headers:e,body:JSON.stringify({error:o.message,type:o.name})};let c=o.message,l=n.params.stacktrace!=="false"?o.stack?.split(`
|
|
2
|
+
`).slice(1).map(u=>u.trim()):void 0;return{statusCode:500,headers:e,body:JSON.stringify({error:c,stack:l})||"Internal Application Error"}}};var v=class extends P{constructor(t,n="unknown"){super({simulate:{method:"post",summary:"Simulate a raw lambda trigger",description:"Simulate a lambda trigger for testing purposes",body:{properties:{}},action:async(e,s)=>{let i=await H(s,t);return new h(i)},tag:"Debug"}},"Lambda Simulator",n)}};0&&(module.exports={LambdaSimulatorAPI});
|
package/LambdaSimulatorAPI.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a as e}from"./chunk-INB47U4Q.js";import"./chunk-6QP54GKU.js";import{a as t}from"./chunk-AVMTVHWW.js";import"./chunk-7LZN2JAA.js";import"./chunk-ZR7NQQXZ.js";import"./chunk-YEDXPIF7.js";import"./chunk-TRA2JUZE.js";import"./chunk-UYING5L4.js";import"./chunk-4ZIBH32D.js";import"./chunk-YCH4ABT5.js";import"./chunk-6W4C3JBY.js";import"./chunk-S5BWAMGC.js";import{a as r}from"./chunk-S3PQMJO4.js";var a=class extends e{constructor(o,s="unknown"){super({simulate:{method:"post",summary:"Simulate a raw lambda trigger",description:"Simulate a lambda trigger for testing purposes",body:{properties:{}},action:async(p,m)=>{let n=await t(m,o);return new r(n)},tag:"Debug"}},"Lambda Simulator",s)}};export{a as LambdaSimulatorAPI};
|
package/OpenAPI.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var R=(a,e)=>{for(var n in e)y(a,n,{get:e[n],enumerable:!0})},O=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of b(e))!j.call(a,s)&&s!==n&&y(a,s,{get:()=>e[s],enumerable:!(o=A(e,s))||o.enumerable});return a};var N=a=>O(y({},"__esModule",{value:!0}),a);var q={};R(q,{default:()=>l});module.exports=N(q);var l=class{#e;#t;#n;#s;#i;constructor(e,n,o,s="/",i={}){this.#e=e,this.#t=s.startsWith("/")?s:"/"+s,this.#n=i,this.#s=n||"API Documentation",this.#i=o||"1.0.0"}async json(){let e={openapi:"3.0.0",info:{title:this.#s,version:this.#i},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return e.paths=await this.#r(this.#e,this.#t,this.#n),e.tags=await this.#o(this.#e,this.#t),e}async#r(e,n,o,s=null){let i={},u={...o};for(let[f,t]of Object.entries(e.schema)){let c=`${n.endsWith("/")?n.slice(0,-1):n}/${f}`,d=t.method||"get",P=[...Object.entries(u).map(([p,r])=>({name:p,in:r.in||"path",required:r.required||!1,schema:{type:r.type||"string"},description:r.description||""})),...Object.entries(t.params||{}).map(([p,r])=>({name:p,in:r.in||"query",required:r.required||!1,default:r.default,schema:{type:r.type||"string"},description:r.description||""}))],h=t.responses||{200:{description:"Successful response"}},g={summary:t.summary||"",description:t.description||"",operationId:this.#a(c),tags:s?[s]:[],parameters:P,responses:h};(h[401]||h[401])&&(g.security=[{ApiKeyAuth:[]}]),t.body&&(g.requestBody={content:{"application/json":{schema:t.body}}});let k={[d.toLowerCase()]:g};if(t.api===!0&&typeof t.action=="function"){let p=null;if(t.params){p=[];for(let[m,I]of Object.entries(t.params))I.in==="path"&&(c+=`/{${m}}`),p.push(m),u[m]=I}let r=await this.#r(await t.action(p?Object.fromEntries(p.map(m=>[m,m])):{},null,{}),c,u,t.tag??null);if(t.params)for(let m of Object.keys(t.params))delete u[m];Object.assign(i,r)}else i[c]=k}return i}async#o(e,n){let o=[];for(let[s,i]of Object.entries(e.schema)){let f=`${n.endsWith("/")?n.slice(0,-1):n}/${s}`;if(i.api===!0&&typeof i.action=="function"){o.push({name:i.tag||f,description:i.description||""});let t={};if(i.params)for(let[c,d]of Object.entries(i.params))d.in==="path"&&(f+=`/{${c}}`),t[c]=c;let w=await this.#o(await i.action(t,null,{}),f);o=[...o,...w]}}return o}#a(e){return e.startsWith("/")&&(e=e.slice(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};
|
package/OpenAPI.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a2_0x41ca57=a2_0xc700;(function(_0x37d924,_0x33b88f){const _0x16a432=a2_0xc700,_0x3e517a=_0x37d924();while(!![]){try{const _0x2760e9=parseInt(_0x16a432(0xae))/0x1+parseInt(_0x16a432(0xac))/0x2*(-parseInt(_0x16a432(0xcd))/0x3)+-parseInt(_0x16a432(0xd6))/0x4+-parseInt(_0x16a432(0xab))/0x5+-parseInt(_0x16a432(0xd5))/0x6+parseInt(_0x16a432(0xa4))/0x7*(-parseInt(_0x16a432(0xbb))/0x8)+parseInt(_0x16a432(0xbf))/0x9;if(_0x2760e9===_0x33b88f)break;else _0x3e517a['push'](_0x3e517a['shift']());}catch(_0x1d52be){_0x3e517a['push'](_0x3e517a['shift']());}}}(a2_0x257a,0x61df2));function a2_0x257a(){const _0x41167e=['tLD1swG','CMvXDwvZDejVzhK','Ec1HCgKTA2v5','C2vHCMnO','ndaX','C3rYAw5N','AhjPwg4','z2v0','mZuWse1Quu9J','seT1Egy','C2vJDxjPDhK','BLjcv0C','yxbWBhK','Cgf0Ahm','C3vTBwfYEq','mZG1mdmYmefZrKrlqq','mtb5EuTKqxq','DgfNCW','ndK2nJG4r2PKvKX5','qvbjierVy3vTzw50yxrPB24','vMvnr1O','Bwv0Ag9K','mY4WlJa','C3bSAxq','A2v5CW','kcGOlISPkYKRksSK','CxvLCNK','DgfN','vejJzLq','sfnfr3O','C3rHCNrZv2L0Aa','mti0nJG4Egvzuhnt','ChvZAa','v0fWuem','EKDMC0i','mJa2nZu1mJLrsNbfu3G','CMvZCg9UC2vZ','uKzZDgK','Dg9tDhjPBMC','Cgf0Aa','zgvZy3jPChrPB24','ms4WlJa','CgfYyw1Z','EKzrBgy','r2z4vgW','zw5KC1DPDgG','wMjIuwW','B1nuu00','u3vJy2vZC2z1BcbYzxnWB25Zzq','mJa5n2PlsfvUCW','yM9KEq','C2XPy2u','Dg9mB3DLCKnHC2u','DwHgrNC','DhLWzq','ywn0Aw9U','CMvWBgfJzq','otGYotm4Bezuyu5h','mJCWntyYmfLryLLjvW','ANnVBG','zw50CMLLCW','vM9JBLG','zNvUy3rPB24'];a2_0x257a=function(){return _0x41167e;};return a2_0x257a();}const a2_0x174eaa=(function(){let _0x20b5a0=!![];return function(_0x26df7b,_0x2f9e32){const _0x7a706a=_0x20b5a0?function(){const _0x3aa624=a2_0xc700;if(_0x2f9e32){const _0x55c3ab=_0x2f9e32[_0x3aa624(0xa8)](_0x26df7b,arguments);return _0x2f9e32=null,_0x55c3ab;}}:function(){};return _0x20b5a0=![],_0x7a706a;};}()),a2_0x21e499=a2_0x174eaa(this,function(){const _0x174946=a2_0xc700,_0xca68a={'WApPC':_0x174946(0xb5)};return a2_0x21e499[_0x174946(0xc2)]()[_0x174946(0x9f)](_0xca68a[_0x174946(0xbd)])[_0x174946(0xc2)]()['constructor'](a2_0x21e499)[_0x174946(0x9f)](_0xca68a[_0x174946(0xbd)]);});a2_0x21e499();function a2_0xc700(_0x1efc05,_0x276735){_0x1efc05=_0x1efc05-0x9d;const _0x4a7252=a2_0x257a();let _0x21e499=_0x4a7252[_0x1efc05];if(a2_0xc700['GfTPaq']===undefined){var _0x174eaa=function(_0x576b86){const _0x290273='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x17598c='',_0x11ba89='',_0x4bb68e=_0x17598c+_0x174eaa;for(let _0x4488e2=0x0,_0x4aecd5,_0x375e3c,_0x7d0c73=0x0;_0x375e3c=_0x576b86['charAt'](_0x7d0c73++);~_0x375e3c&&(_0x4aecd5=_0x4488e2%0x4?_0x4aecd5*0x40+_0x375e3c:_0x375e3c,_0x4488e2++%0x4)?_0x17598c+=_0x4bb68e['charCodeAt'](_0x7d0c73+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x4aecd5>>(-0x2*_0x4488e2&0x6)):_0x4488e2:0x0){_0x375e3c=_0x290273['indexOf'](_0x375e3c);}for(let _0x20d39a=0x0,_0x1feb22=_0x17598c['length'];_0x20d39a<_0x1feb22;_0x20d39a++){_0x11ba89+='%'+('00'+_0x17598c['charCodeAt'](_0x20d39a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x11ba89);};a2_0xc700['yQdxYR']=_0x174eaa,a2_0xc700['nVooII']={},a2_0xc700['GfTPaq']=!![];}const _0x257a43=_0x4a7252[0x0],_0xc700f7=_0x1efc05+_0x257a43,_0x40b89b=a2_0xc700['nVooII'][_0xc700f7];if(!_0x40b89b){const _0x157215=function(_0x39f567){this['bgJLzV']=_0x39f567,this['xCDCJI']=[0x1,0x0,0x0],this['aCpliU']=function(){return'newState';},this['tKRQaV']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['FQycpq']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x157215['prototype']['jqaXTO']=function(){const _0x312f54=new RegExp(this['tKRQaV']+this['FQycpq']),_0x11e148=_0x312f54['test'](this['aCpliU']['toString']())?--this['xCDCJI'][0x1]:--this['xCDCJI'][0x0];return this['SfTyWA'](_0x11e148);},_0x157215['prototype']['SfTyWA']=function(_0x67cc1d){if(!Boolean(~_0x67cc1d))return _0x67cc1d;return this['hiojzp'](this['bgJLzV']);},_0x157215['prototype']['hiojzp']=function(_0x56b645){for(let _0x27333c=0x0,_0x2f640b=this['xCDCJI']['length'];_0x27333c<_0x2f640b;_0x27333c++){this['xCDCJI']['push'](Math['round'](Math['random']())),_0x2f640b=this['xCDCJI']['length'];}return _0x56b645(this['xCDCJI'][0x0]);},new _0x157215(a2_0xc700)['jqaXTO'](),_0x21e499=a2_0xc700['yQdxYR'](_0x21e499),a2_0xc700['nVooII'][_0xc700f7]=_0x21e499;}else _0x21e499=_0x40b89b;return _0x21e499;}import{APIInterface}from'./API.js';export default class OpenAPI{#api;#path;#hparams;#title;#version;constructor(_0x122d17,_0xbd3970,_0x1ef0e2,_0x1ee7b7='/',_0x131e43={}){const _0x1ffd70=a2_0xc700,_0x2073c9={'DmMCx':_0x1ffd70(0xaf),'zGfsB':function(_0x49813a,_0x2c63f4){return _0x49813a+_0x2c63f4;},'ICagm':function(_0x1c027a,_0xe1877){return _0x1c027a||_0xe1877;},'hriXn':_0x1ffd70(0xc5)},_0x2dc905='5|1|3|4|0|2'[_0x1ffd70(0xb3)]('|');let _0x479126=0x0;while(!![]){switch(_0x2dc905[_0x479126++]){case'0':this.#title=_0xbd3970||_0x2073c9['DmMCx'];continue;case'1':if(!_0x1ee7b7[_0x1ffd70(0xba)]('/'))_0x1ee7b7=_0x2073c9[_0x1ffd70(0xbe)]('/',_0x1ee7b7);continue;case'2':this.#version=_0x2073c9['ICagm'](_0x1ef0e2,_0x2073c9[_0x1ffd70(0xa2)]);continue;case'3':this.#path=_0x1ee7b7;continue;case'4':this.#hparams=_0x131e43;continue;case'5':this.#api=_0x122d17;continue;}break;}}async[a2_0x41ca57(0xd7)](){const _0x5cd7ea=a2_0x41ca57,_0x2b1d08={'SqpqQ':_0x5cd7ea(0xb2),'oyNeB':'apiKey','VocnX':'header'},_0x42dc51={'openapi':_0x2b1d08['SqpqQ'],'info':{'title':this.#title,'version':this.#version},'components':{'securitySchemes':{'ApiKeyAuth':{'type':_0x2b1d08['oyNeB'],'in':_0x2b1d08[_0x5cd7ea(0xd9)],'name':_0x5cd7ea(0x9e)}}}};return _0x42dc51[_0x5cd7ea(0xa9)]=await this.#generatePaths(this.#api,this.#path,this.#hparams),_0x42dc51[_0x5cd7ea(0xad)]=await this.#generateTags(this.#api,this.#path),_0x42dc51;}async #generatePaths(_0x5a171f,_0x15d027,_0x2e5b17,_0x1202c8=null){const _0x2d8677=a2_0x41ca57,_0x338240={'RFsti':_0x2d8677(0xa3),'uhFFw':_0x2d8677(0xa1),'VeMGZ':_0x2d8677(0xb6),'HSEGz':'application/json','oSTSM':'object','ZbbQl':function(_0xca547d,_0x38828e){return _0xca547d===_0x38828e;},'DZRts':function(_0x1b868a,_0x3f9474){return _0x1b868a===_0x3f9474;},'HKuxf':function(_0x4cbba5,_0xb980f2){return _0x4cbba5===_0xb980f2;},'TBcfT':'path','GfxTl':function(_0x356b33,_0x2ea47a){return _0x356b33+_0x2ea47a;},'nRBWG':function(_0x501475,_0x7a6830){return _0x501475||_0x7a6830;}};let _0x5e17bd={},_0x215a4f={..._0x2e5b17};for(const _0x22d507 of Object[_0x2d8677(0xb4)](_0x5a171f)){let _0x2244c4=_0x5a171f[_0x22d507];_0x2244c4={..._0x2244c4,..._0x2e5b17};const _0x12b442=await this.#generatePaths(new APIInterface({[_0x22d507]:_0x2244c4}),_0x15d027,_0x215a4f,_0x1202c8);for(const [_0x51da2f,_0x12b7dd]of Object['entries'](_0x12b442)){_0x5e17bd[_0x51da2f]=_0x12b7dd;}}for(const [_0x4982a5,_0x2ac5bc]of Object[_0x2d8677(0xd8)](_0x5a171f['schema'])){const _0x21c282=_0x15d027[_0x2d8677(0xc9)]('/')?_0x15d027[_0x2d8677(0xcf)](0x0,-0x1):_0x15d027;let _0x46acd5=_0x21c282+'/'+_0x4982a5;const _0x574e2b=_0x2ac5bc[_0x2d8677(0xb1)]||_0x338240[_0x2d8677(0xc1)];let _0x81cdb9=[];for(const [_0x246b87,_0x40ea2f]of Object[_0x2d8677(0xd8)](_0x215a4f)){_0x81cdb9[_0x2d8677(0xbc)]({'name':_0x246b87,'in':_0x40ea2f['in']||_0x2d8677(0xc3),'required':_0x40ea2f['required']||![],'schema':{'type':_0x40ea2f['type']||_0x338240['uhFFw']},'description':_0x40ea2f[_0x2d8677(0xc4)]||''});}if(_0x2ac5bc[_0x2d8677(0xc6)])for(const [_0x156391,_0x411cb5]of Object[_0x2d8677(0xd8)](_0x2ac5bc[_0x2d8677(0xc6)])){_0x81cdb9[_0x2d8677(0xbc)]({'name':_0x156391,'in':_0x411cb5['in']||_0x338240[_0x2d8677(0xb0)],'required':_0x411cb5['required']||![],'default':_0x411cb5['default']||undefined,'schema':{'type':_0x411cb5[_0x2d8677(0xd2)]||_0x338240[_0x2d8677(0xd1)]},'description':_0x411cb5['description']||''});}const _0x16a961=_0x2ac5bc[_0x2d8677(0xc0)]||{'200':{'description':_0x2d8677(0xcc)}};let _0x29d1b6={'summary':_0x2ac5bc[_0x2d8677(0xaa)]||'','description':_0x2ac5bc[_0x2d8677(0xc4)]||'','operationId':this.#slug(_0x46acd5),'tags':_0x1202c8?[_0x1202c8]:[],'parameters':_0x81cdb9,'responses':_0x16a961};(_0x16a961[0x191]||_0x16a961[_0x2d8677(0xa0)])&&(_0x29d1b6[_0x2d8677(0xa6)]=[{'ApiKeyAuth':[]}]);if(_0x2ac5bc[_0x2d8677(0xce)]){let _0x288309=_0x338240[_0x2d8677(0xb9)];_0x29d1b6[_0x2d8677(0x9d)]={'content':{[_0x288309]:{'schema':_0x2ac5bc[_0x2d8677(0xce)]||_0x338240[_0x2d8677(0xcb)]}}};}_0x29d1b6={[_0x574e2b[_0x2d8677(0xd0)]()]:_0x29d1b6};if(_0x338240[_0x2d8677(0xca)](_0x2ac5bc['api'],!![])&&_0x338240['DZRts'](typeof _0x2ac5bc[_0x2d8677(0xd3)],_0x2d8677(0xda))){let _0x2cde3e;if(_0x2ac5bc[_0x2d8677(0xc6)]){_0x2cde3e=[];for(const [_0x294e9e,_0x227bc3]of Object[_0x2d8677(0xd8)](_0x2ac5bc[_0x2d8677(0xc6)])){_0x338240[_0x2d8677(0xa5)](_0x227bc3['in'],_0x338240[_0x2d8677(0xb8)])&&(_0x46acd5+=_0x338240[_0x2d8677(0xc8)]('/','{'+_0x294e9e+'}')),_0x2cde3e['push'](_0x294e9e),_0x215a4f[_0x294e9e]=_0x227bc3;}}else _0x2cde3e=null;let _0x5249af=await this.#generatePaths(await _0x2ac5bc[_0x2d8677(0xd3)](_0x2cde3e),_0x46acd5,_0x215a4f,_0x2ac5bc[_0x2d8677(0xb7)]);if(_0x2ac5bc[_0x2d8677(0xc6)])for(const [_0x4084a7,_0x9a3462]of Object[_0x2d8677(0xd8)](_0x2ac5bc['params'])){delete _0x215a4f[_0x4084a7];}for(const [_0x5c4b9d,_0x17d457]of Object[_0x2d8677(0xd8)](_0x338240[_0x2d8677(0xa7)](_0x5249af,{}))){_0x5e17bd[_0x5c4b9d]=_0x17d457;}}else _0x5e17bd[_0x46acd5]=_0x29d1b6;}return _0x5e17bd;}async #generateTags(_0x17665e,_0x5830b5){const _0xae29b3=a2_0x41ca57,_0x1493d8={'zFQlf':function(_0x180b2e,_0x5f3fb2){return _0x180b2e===_0x5f3fb2;},'KLROC':'function','NWuIh':_0xae29b3(0xc3),'zRshD':function(_0x4d4f26,_0x13bfe1){return _0x4d4f26+_0x13bfe1;}};let _0x324e4f=[];for(const [_0x358601,_0xf1d2cd]of Object[_0xae29b3(0xd8)](_0x17665e['schema'])){let _0x586eda=_0x5830b5+'/'+_0x358601;if(_0x1493d8[_0xae29b3(0xc7)](_0xf1d2cd['api'],!![])&&_0x1493d8[_0xae29b3(0xc7)](typeof _0xf1d2cd[_0xae29b3(0xd3)],_0x1493d8['KLROC'])){_0x324e4f[_0xae29b3(0xbc)]({'name':_0xf1d2cd[_0xae29b3(0xb7)]||_0x586eda,'description':_0xf1d2cd['description']||''});let _0x1ab793;if(_0xf1d2cd[_0xae29b3(0xc6)]){_0x1ab793=[];for(const [_0x3a8e7e,_0x27f980]of Object[_0xae29b3(0xd8)](_0xf1d2cd[_0xae29b3(0xc6)])){_0x27f980['in']===_0x1493d8[_0xae29b3(0xdb)]&&(_0x586eda+=_0x1493d8['zRshD']('/','{'+_0x3a8e7e+'}')),_0x1ab793[_0xae29b3(0xbc)](_0x3a8e7e);}}else _0x1ab793=null;let _0x534db3=await this.#generateTags(await _0xf1d2cd['action'](_0x1ab793),_0x586eda);_0x324e4f=[..._0x324e4f,..._0x534db3];}}return _0x324e4f;}#slug(_0x25b5bd){const _0x411f80=a2_0x41ca57;if(_0x25b5bd[_0x411f80(0xba)]('/'))_0x25b5bd=_0x25b5bd[_0x411f80(0xcf)](0x1);if(_0x25b5bd['endsWith']('/'))_0x25b5bd=_0x25b5bd['slice'](0x0,-0x1);return _0x25b5bd['replace'](/\//g,'_')[_0x411f80(0xd4)](/[^a-zA-Z0-9_]/g,'');}}
|
|
1
|
+
import{a}from"./chunk-6QP54GKU.js";export{a as default};
|
package/aws/Kinesis.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var R=(s,r)=>{for(var e in r)i(s,e,{get:r[e],enumerable:!0})},g=(s,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of u(r))!d.call(s,n)&&n!==e&&i(s,n,{get:()=>r[n],enumerable:!(t=a(r,n))||t.enumerable});return s};var w=s=>g(i({},"__esModule",{value:!0}),s);var h={};R(h,{KinesisRecord:()=>o,KinesisRecords:()=>c});module.exports=w(h);var c=class{#r;get records(){return this.#r}constructor(r){let e=r;this.#r=(e?.Records||[]).map(t=>new o(t))}getRecord(r){return this.#r[r]}},o=class{#r;get record(){return this.#r}constructor(r){let e=r;if(e.eventSource!=="aws:kinesis")throw new Error("Not a Kinesis record");this.#r=e}get source(){return this.#r.eventSourceARN}get name(){return this.#r.eventName}get data(){try{let e=Buffer.from(this.#r.kinesis?.data??"","base64").toString("utf-8");return JSON.parse(e)}catch(r){return console.error("Error parsing Kinesis record data",r),null}}};0&&(module.exports={KinesisRecord,KinesisRecords});
|
package/aws/Kinesis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var n=class{#r;get records(){return this.#r}constructor(r){let e=r;this.#r=(e?.Records||[]).map(o=>new s(o))}getRecord(r){return this.#r[r]}},s=class{#r;get record(){return this.#r}constructor(r){let e=r;if(e.eventSource!=="aws:kinesis")throw new Error("Not a Kinesis record");this.#r=e}get source(){return this.#r.eventSourceARN}get name(){return this.#r.eventName}get data(){try{let e=Buffer.from(this.#r.kinesis?.data??"","base64").toString("utf-8");return JSON.parse(e)}catch(r){return console.error("Error parsing Kinesis record data",r),null}}};export{s as KinesisRecord,n as KinesisRecords};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import g from"readline";var c=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(s){this.#t=s}getParam(s){return this._params[s]}processResponse(s,t={}){return s}shortInputLog(s){let t=JSON.stringify(s);return t.length>100&&(t=t.substring(0,100)+"..."),t}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var p=class a extends c{constructor(s,t,e,n){super("console"),this._path=s,this._params=t,this._method=e,this._payload=n,this._headers={_handler_type:"console"}}static parse(s){let t=a.#t(s.trim()),e=[],n={},o=null,r=0;for(;r<t.length&&!t[r].startsWith("--");)e.push(t[r]),r++;for(;r<t.length;)if(t[r].startsWith("--")){let i=t[r].slice(2);r+1<t.length&&!t[r+1].startsWith("--")?(n[i]=t[r+1],r+=2):(n[i]=!0,r++)}else{let i=t.slice(r).join(" ");try{o=JSON.parse(i)}catch{o=i}break}return{path:e,params:n,body:o}}static#t(s){let t=[],e="",n=!1,o=!1;for(let r of s)r==="'"&&!o?n=!n:r==='"'&&!n?o=!o:r===" "&&!n&&!o?e&&(t.push(e),e=""):e+=r;return e&&t.push(e),t}processResponse(s){let t=s.content;s.contentType?.startsWith("application/json")?process.stdout.write(JSON.stringify(t,null,2)+`
|
|
2
|
+
`):process.stdout.write(String(t)+`
|
|
3
|
+
`)}};var y=a=>new Promise(s=>{let t=g.createInterface({input:process.stdin,output:process.stdout,prompt:"> "});t.prompt(),t.on("line",async e=>{if(e=e.trim(),!e){t.prompt();return}if(e==="exit"||e==="quit"){t.close();return}try{let{path:n,params:o,body:r}=p.parse(e),i=await a.resolveMethod(n),h=new p(n,o,i,r),u=await a.execute([...n],o,i,r,h.headers);h.processResponse(u)}catch(n){process.stderr.write(`Error: ${n.message}
|
|
4
|
+
`)}t.prompt()}),t.on("close",s)});export{c as a,y as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-6W4C3JBY.js";var r=class extends i{static isAmazonConnect(t){let s=t;return!(s?.Name!=="ContactFlowEvent"||!s.Details||!s.Details.ContactData)}#t;get initMethod(){return this.#t}#n;get contactid(){return this.#n}#s;get systemEndpoint(){return this.#s}#e;get customerEndpoint(){return this.#e}#i;get instanceARN(){return this.#i}constructor(t){super("amazon_connect");let s=t.Details;this._params=s.Parameters||null;let n=s.ContactData;this._params||(this._params=n.Attributes||{});let o=this._params.path||"";this._path=o.split("/");let e=n.Attributes;this._method=e?.method||"get",this.#n=n.ContactId,this.#n&&(this._params.contactid=this.#n),this.#s=n.SystemEndpoint?.Address,this.#e=n.CustomerEndpoint?.Address,this._payload=e,this.#t=n.InitiationMethod,this.#i=n.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,s={}){let n=t.content;return n.lambdaResult="Success",n}};export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=class{#e;#t;#n;#s;#i;constructor(t,i,r,o="/",n={}){this.#e=t,this.#t=o.startsWith("/")?o:"/"+o,this.#n=n,this.#s=i||"API Documentation",this.#i=r||"1.0.0"}async json(){let t={openapi:"3.0.0",info:{title:this.#s,version:this.#i},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return t.paths=await this.#r(this.#e,this.#t,this.#n),t.tags=await this.#o(this.#e,this.#t),t}async#r(t,i,r,o=null){let n={},m={...r};for(let[u,e]of Object.entries(t.schema)){let a=`${i.endsWith("/")?i.slice(0,-1):i}/${u}`,f=e.method||"get",w=[...Object.entries(m).map(([c,s])=>({name:c,in:s.in||"path",required:s.required||!1,schema:{type:s.type||"string"},description:s.description||""})),...Object.entries(e.params||{}).map(([c,s])=>({name:c,in:s.in||"query",required:s.required||!1,default:s.default,schema:{type:s.type||"string"},description:s.description||""}))],l=e.responses||{200:{description:"Successful response"}},d={summary:e.summary||"",description:e.description||"",operationId:this.#a(a),tags:o?[o]:[],parameters:w,responses:l};(l[401]||l[401])&&(d.security=[{ApiKeyAuth:[]}]),e.body&&(d.requestBody={content:{"application/json":{schema:e.body}}});let I={[f.toLowerCase()]:d};if(e.api===!0&&typeof e.action=="function"){let c=null;if(e.params){c=[];for(let[p,y]of Object.entries(e.params))y.in==="path"&&(a+=`/{${p}}`),c.push(p),m[p]=y}let s=await this.#r(await e.action(c?Object.fromEntries(c.map(p=>[p,p])):{},null,{}),a,m,e.tag??null);if(e.params)for(let p of Object.keys(e.params))delete m[p];Object.assign(n,s)}else n[a]=I}return n}async#o(t,i){let r=[];for(let[o,n]of Object.entries(t.schema)){let u=`${i.endsWith("/")?i.slice(0,-1):i}/${o}`;if(n.api===!0&&typeof n.action=="function"){r.push({name:n.tag||u,description:n.description||""});let e={};if(n.params)for(let[a,f]of Object.entries(n.params))f.in==="path"&&(u+=`/{${a}}`),e[a]=a;let g=await this.#o(await n.action(e,null,{}),u);r=[...r,...g]}}return r}#a(t){return t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,-1)),t.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};export{h as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,r={}){return t}shortInputLog(t){let r=JSON.stringify(t);return r.length>100&&(r=r.substring(0,100)+"..."),r}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-ZR7NQQXZ.js";import{a as s}from"./chunk-YEDXPIF7.js";import{a}from"./chunk-TRA2JUZE.js";import{a as m}from"./chunk-UYING5L4.js";import{a as o}from"./chunk-4ZIBH32D.js";import{a as n}from"./chunk-YCH4ABT5.js";var H={matchHandler(r){return e.isLambdaURL(r)?new e(r):n.isExpressURL(r)?new n(r):o.isAmazonConnect(r)?new o(r):s.isKinesis(r)?new s(r):a.isS3(r)?new a(r):m.isSNS(r)?new m(r):null}};export{H as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i}from"./chunk-7LZN2JAA.js";import{a as l}from"./chunk-S5BWAMGC.js";import p from"fs";import f from"mime-types";var A=async(t,d)=>{let o=i.matchHandler(t);if(!o)return console.error("No handler found for input"),console.log("INPUT",JSON.stringify(t)),{statusCode:400,body:"Input not recognized"};let r={"Access-Control-Allow-Origin":"*"};if(o.method.toLowerCase()==="options"){let e=o.headers;return r={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":e["access-control-request-method"],"Access-Control-Allow-Headers":e["access-control-request-headers"]},console.log("CORS request service"),{statusCode:200,headers:r}}let n=o.path;if(n[0]==="docs"){let e,s;if(n.length>1){e=n.slice(1).join("/");let a=o.format;a?(e+="."+a,s=f.lookup(e)||"application/octet-stream"):s="application/octet-stream"}else e="index.html",s="text/html";e=process.cwd()+"/node_modules/redleaf-ishell/swagger/"+e;let c=p.readFileSync(e);return console.log("Docs file",e,c.length),{statusCode:200,headers:{...r,"Content-Type":s,"Access-Control-Allow-Origin":"*","Content-Source":"static"},body:c.toString()}}let m={...o.headers,_handler_type:o.type};try{process.env.AWS_LOG_IO==="true"?console.log("INPUT",JSON.stringify(t)):console.log(o.shortInputLog(t));let e=await d.execute(n,o.params,o.method,o.payload,m);return o.processResponse(e,r)}catch(e){if(console.log("INPUT",JSON.stringify(t)),e instanceof l)return{statusCode:e.statusCode,headers:r,body:JSON.stringify({error:e.message,type:e.name})};let s=e.message,a=o.params.stacktrace!=="false"?e.stack?.split(`
|
|
2
|
+
`).slice(1).map(g=>g.trim()):void 0;return{statusCode:500,headers:r,body:JSON.stringify({error:s,stack:a})||"Internal Application Error"}}};export{A as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-6QP54GKU.js";import{b as d,d as u}from"./chunk-S5BWAMGC.js";import{a as l}from"./chunk-S3PQMJO4.js";var g=class p{#e;get schema(){return this.#e}#n;#t;constructor(e={},n="API Documentation",r="Unknown"){this.#e=this.#r(e),this.#n=`${n} (${process.env.AWS_LAMBDA_FUNCTION_NAME||"Local"})`,this.#t=r}get isAPIInterface(){return!0}async execute(e,n,r,t,i={}){Array.isArray(e)||(e=[e]);let s=e.join("/"),o=await this.exrec([...e],n,r,t,i);return o?.isAPIInterface===!0?o.usage(s,this.#e[s]?.params):o}async exrec(e,n,r,t,i={}){let s=this;for(;e.length>0;){let o=e.splice(0,1)[0],a=s.#e[o];if(!a)throw new d(o+" not found");if(a.params&&Object.keys(a.params).length>0)for(let m of Object.keys(a.params))a.params[m]?.in==="path"&&(n[m]=e.splice(0,1)[0]);let c=await a.action(n,t,i);if(e.length===0)return c;if(!(c instanceof p))throw new d(o+" not found");s=c}return s}async usage(e,n={}){let r=await new f(this,this.#n,this.#t,e,n).json();return new l(r)}addHandler(e,n){this.#e[e]={method:"post",action:n}}addLambdaSimulator(e){let n=process.env.ALLOW_API?.split(",").map(t=>t.trim())||["all"];(process.env.DENY_API?.split(",").map(t=>t.trim())||[]).indexOf("lambda")>=0||n.indexOf("all")<0&&n.indexOf("lambda")<0||(this.#e.lambda={api:!0,toplevel:!0,tag:"Lambda Simulator",description:"Simulate Lambda invocation using REST API",action:e})}#r(e){let n=process.env.ALLOW_API?.split(",").map(t=>t.trim())||null,r=process.env.DENY_API?.split(",").map(t=>t.trim())||[];if(r[0]?.toLowerCase()==="all")return{};for(let t of Object.keys(e))e[t].api&&e[t].toplevel&&(n&&n.indexOf(t)<0||r.indexOf(t)>=0)&&delete e[t];return e}async resolveMethod(e){Array.isArray(e)||(e=[e]),e=[...e];let n=this.#e,r="get";for(let t=0;t<e.length;t++){let i=n[e[t]];if(!i)return r;if(i.method&&(r=i.method),t<e.length-1&&i.action)try{let s=await i.action({},null,{});if(s?.isAPIInterface)n=s.schema;else return r}catch{return r}}return r}confirmAPIKey(e,n){if(n){let r=e["x-api-key"];if(!r||r!==n)throw new u("Invalid or missing API key")}}};export{g as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as c}from"./chunk-6W4C3JBY.js";var l=class a extends c{constructor(r,t,n,e){super("console"),this._path=r,this._params=t,this._method=n,this._payload=e,this._headers={_handler_type:"console"}}static parse(r){let t=a.#t(r.trim()),n=[],e={},i=null,s=0;for(;s<t.length&&!t[s].startsWith("--");)n.push(t[s]),s++;for(;s<t.length;)if(t[s].startsWith("--")){let o=t[s].slice(2);s+1<t.length&&!t[s+1].startsWith("--")?(e[o]=t[s+1],s+=2):(e[o]=!0,s++)}else{let o=t.slice(s).join(" ");try{i=JSON.parse(o)}catch{i=o}break}return{path:n,params:e,body:i}}static#t(r){let t=[],n="",e=!1,i=!1;for(let s of r)s==="'"&&!i?e=!e:s==='"'&&!e?i=!i:s===" "&&!e&&!i?n&&(t.push(n),n=""):n+=s;return n&&t.push(n),t}processResponse(r){let t=r.content;r.contentType?.startsWith("application/json")?process.stdout.write(JSON.stringify(t,null,2)+`
|
|
2
|
+
`):process.stdout.write(String(t)+`
|
|
3
|
+
`)}};export{l as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as u}from"./chunk-S5BWAMGC.js";import{a as d}from"./chunk-S3PQMJO4.js";import R from"cors";import v from"dotenv";import l from"express";import y from"path";var O=c=>{let o=l();o.use(l.json()),o.use(R()),o.use("/docs",l.static(y.join(process.cwd(),"node_modules/redleaf-ishell/swagger")));let a=async(e,s)=>{let r=e.path;r.startsWith("/")&&(r=r.slice(1)),r.endsWith("/")&&(r=r.slice(0,-1));let i=r.lastIndexOf(".");i>0&&(r=r.slice(0,i));let n=await f(r.split("/"),e.query,e.method,e.headers,e.body);s.type(n.contentType).status(n.returnCode).send(n.content)},f=async(e,s,r,i,n=null)=>{let p={...i,_handler_type:"express"};try{if(n!==null){let t;try{t=JSON.parse(n)}catch{t=n}return await c.execute(e,s,r,t,p)}else return await c.execute(e,s,r,void 0,p)}catch(t){let h=t.stack?.split(`
|
|
2
|
+
`).slice(1).map(g=>g.trim());return t instanceof u?new d({status:"error",type:t.name,message:t.message}).errorCode(t.statusCode):new d({status:"error",error:t.message,stack:h}).errorCode(500)}};o.get("/{*path}",(e,s)=>{a(e,s)}),o.post("/{*path}",(e,s)=>{a(e,s)}),o.put("/{*path}",(e,s)=>{a(e,s)}),o.patch("/{*path}",(e,s)=>{a(e,s)}),o.delete("/{*path}",(e,s)=>{a(e,s)}),v.config();let m=parseInt(process.env.PORT||"3001",10);return new Promise((e,s)=>{let r=o.listen(m,()=>{let i=`http://localhost:${m}/`;console.log(`Express server running on ${i}`);for(let[n,p]of Object.entries(c.schema))p.api&&console.log(`For ${p.tag} API go to ${i}docs/?root=${n}`);e(r)});r.on("error",s)})};export{O as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n=class{#t;#r;#n=200;get content(){return this.#t}get contentType(){return this.#r}get returnCode(){return this.#n}constructor(t,s){this.#t=t,this.#r=s}errorCode(t){return this.#n=t,this}},c=class extends n{constructor(t){super(t,"application/json")}},i=class extends n{constructor(t){super(t,"text/csv")}},u=class e extends n{static json2CSV(t){if(!Array.isArray(t)||t.length===0)return"";let s=t,o=[Object.keys(s[0]).join(",")];for(let g of s)o.push(Object.values(g).map(r=>typeof r=="string"?r.includes(",")||r.includes('"')?`"${r.replace(/"/g,'""')}"`:r:(typeof r=="number"||!isNaN(Number(r)),r)).join(","));return o.join(`
|
|
2
|
+
`)}constructor(t){super(e.json2CSV(t),"text/csv")}},p=class extends n{constructor(t){super(t,"text/plain")}},x=class extends n{constructor(t){super(t,"text/html")}},d=class extends n{constructor(t){super(t,"text/xml")}};export{c as a,i as b,u as c,p as d,x as e,d as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{#s;#t;get statusCode(){return this.#s}get name(){return this.#t}constructor(s,t,x){super(t),this.#t=s,this.#s=x}},o=class extends e{constructor(s="Not Found",t=404){super("NotFoundError",s,t)}},n=class extends e{constructor(s="Value is missing",t=501){super("MissingValueError",s,t)}},u=class extends e{constructor(s="Unauthorized",t=401){super("AuthError",s,t)}},c=class extends e{constructor(s="System Error",t=500){super("SystemError",s,t)}},a=class extends e{constructor(s="Not Allowed",t=403){super("NotAllowedError",s,t)}},d=class extends e{constructor(s="Bad format",t=400){super("BadFormatError",s,t)}},p=class extends e{constructor(s="Not Implemented",t=501){super("NotImplementedError",s,t)}};export{e as a,o as b,n as c,u as d,c as e,a as f,d as g,p as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-6W4C3JBY.js";var r=class s extends i{static isS3(e){return e?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(e){super("s3"),this._path=s.identifier,this._method="post",this._params={},this._payload=s.distill(e),this._format="json"}static distill(e){return(e?.Records??[]).map(t=>({eventName:t.eventName,bucket:t.s3?.bucket?.name,key:t.s3?.object?.key,size:t.s3?.object?.size}))}shortInputLog(e){let n=e?.Records?.[0],o=n?.s3?.bucket?.name??"?",a=n?.s3?.object?.key??"?";return`S3 ${n?.eventName??"event"}: s3://${o}/${a}`}};export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-6W4C3JBY.js";var r=class o extends t{static isSNS(n){return n.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(n){super("sns"),this._path=o.identifier,this._method="post",this._params={},this._payload=this.#n(n),this._format="json"}shortInputLog(n){return JSON.stringify(n)}#n(n){return n.Records.map(s=>{try{return JSON.parse(s.Sns.Message)}catch{return s.Sns.Message}})}};export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-6W4C3JBY.js";var o=class extends r{static isExpressURL(t){let n=t;if(!n?.method||!n?.requestContext)return!1;let s=n.requestContext;return!(!s?.http||!s.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let s=t.requestContext.http.path||"";s[0]==="/"&&(s=s.substring(1));let e=s.lastIndexOf(".");e>0?(this._format=s.substring(e+1),s=s.substring(0,e)):this._format="json",this._path=s.split("/"),this._headers=t.headers||{}}processResponse(t,n={}){n["Content-Type"]=t.contentType;let s=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:n,body:s}}};export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-6W4C3JBY.js";var i=class s extends t{static isKinesis(n){return n.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(n){super(s.identifier),this._path=s.identifier,this._method="post",this._params={},this._payload=n,this._format="json"}shortInputLog(n){return JSON.stringify(n)}};export{i as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-6W4C3JBY.js";var o=class extends e{static isLambdaURL(n){let s=n;if(!s?.requestContext)return!1;let t=s.requestContext;if(!t?.http)return!1;let r=t.http;return!(!r?.method||!r?.path)}constructor(n){super("lambda_url");let s=n.requestContext;this._method=s.http.method,this._params=n.queryStringParameters||{},this._payload=n.body;try{this._payload=JSON.parse(this._payload)}catch{}let t=s.http.path;t[0]==="/"&&(t=t.substring(1));let r=t.lastIndexOf(".");r>0?(this._format=t.substring(r+1),t=t.substring(0,r)):this._format="json",this._path=t.split("/"),this._headers=n.headers||{}}shortInputLog(n){let s=n,t=s.requestContext;return JSON.stringify({path:t?.http?.path,method:t?.http?.method,params:s.queryStringParameters,sourceIp:t?.http?.sourceIp})}processResponse(n,s={}){let t={...s,"Content-Type":n.contentType,"Access-Control-Allow-Origin":"*"},r=n.contentType==="application/json"?JSON.stringify(n.content):String(n.content);return{statusCode:n.returnCode,headers:t,body:r}}};export{o as a};
|
package/errors.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var b=(e,s)=>{for(var t in s)u(e,t,{get:s[t],enumerable:!0})},y=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of g(s))!h.call(e,o)&&o!==t&&u(e,o,{get:()=>s[o],enumerable:!(n=m(s,o))||n.enumerable});return e};var N=e=>y(u({},"__esModule",{value:!0}),e);var C={};b(C,{AuthError:()=>d,BadFormatError:()=>l,BaseError:()=>r,MissingValueError:()=>a,NotAllowedError:()=>x,NotFoundError:()=>c,NotImplementedError:()=>i,SystemError:()=>p});module.exports=N(C);var r=class extends Error{#s;#t;get statusCode(){return this.#s}get name(){return this.#t}constructor(s,t,n){super(t),this.#t=s,this.#s=n}},c=class extends r{constructor(s="Not Found",t=404){super("NotFoundError",s,t)}},a=class extends r{constructor(s="Value is missing",t=501){super("MissingValueError",s,t)}},d=class extends r{constructor(s="Unauthorized",t=401){super("AuthError",s,t)}},p=class extends r{constructor(s="System Error",t=500){super("SystemError",s,t)}},x=class extends r{constructor(s="Not Allowed",t=403){super("NotAllowedError",s,t)}},l=class extends r{constructor(s="Bad format",t=400){super("BadFormatError",s,t)}},i=class extends r{constructor(s="Not Implemented",t=501){super("NotImplementedError",s,t)}};0&&(module.exports={AuthError,BadFormatError,BaseError,MissingValueError,NotAllowedError,NotFoundError,NotImplementedError,SystemError});
|
package/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-S5BWAMGC.js";export{d as AuthError,g as BadFormatError,a as BaseError,c as MissingValueError,f as NotAllowedError,b as NotFoundError,h as NotImplementedError,e as SystemError};
|
package/exports.cjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";var ot=Object.create;var v=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,dt=Object.prototype.hasOwnProperty;var pt=(o,t)=>{for(var e in t)v(o,e,{get:t[e],enumerable:!0})},K=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of at(t))!dt.call(o,s)&&s!==e&&v(o,s,{get:()=>t[s],enumerable:!(n=it(t,s))||n.enumerable});return o};var k=(o,t,e)=>(e=o!=null?ot(ct(o)):{},K(t||!o||!o.__esModule?v(e,"default",{value:o,enumerable:!0}):e,o)),ut=o=>K(v({},"__esModule",{value:!0}),o);var lt={};pt(lt,{APIInterface:()=>M,AuthError:()=>x,BadFormatError:()=>D,BaseError:()=>l,MissingValueError:()=>J,NotAllowedError:()=>$,NotFoundError:()=>R,NotImplementedError:()=>W,ResponseCSV:()=>C,ResponseHTML:()=>q,ResponseJSON:()=>h,ResponseJSON2CSV:()=>E,ResponseText:()=>L,ResponseXML:()=>T,SystemError:()=>H,handleLambdaTrigger:()=>Z,localCLI:()=>st,localServer:()=>et});module.exports=ut(lt);var w=class{#t;#e;#n=200;get content(){return this.#t}get contentType(){return this.#e}get returnCode(){return this.#n}constructor(t,e){this.#t=t,this.#e=e}errorCode(t){return this.#n=t,this}},h=class extends w{constructor(t){super(t,"application/json")}},C=class extends w{constructor(t){super(t,"text/csv")}},E=class o extends w{static json2CSV(t){if(!Array.isArray(t)||t.length===0)return"";let e=t,n=[Object.keys(e[0]).join(",")];for(let s of e)n.push(Object.values(s).map(i=>typeof i=="string"?i.includes(",")||i.includes('"')?`"${i.replace(/"/g,'""')}"`:i:(typeof i=="number"||!isNaN(Number(i)),i)).join(","));return n.join(`
|
|
2
|
+
`)}constructor(t){super(o.json2CSV(t),"text/csv")}},L=class extends w{constructor(t){super(t,"text/plain")}},q=class extends w{constructor(t){super(t,"text/html")}},T=class extends w{constructor(t){super(t,"text/xml")}};var _=class{#t;#e;#n;#s;#r;constructor(t,e,n,s="/",i={}){this.#t=t,this.#e=s.startsWith("/")?s:"/"+s,this.#n=i,this.#s=e||"API Documentation",this.#r=n||"1.0.0"}async json(){let t={openapi:"3.0.0",info:{title:this.#s,version:this.#r},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return t.paths=await this.#o(this.#t,this.#e,this.#n),t.tags=await this.#i(this.#t,this.#e),t}async#o(t,e,n,s=null){let i={},r={...n};for(let[a,c]of Object.entries(t.schema)){let p=`${e.endsWith("/")?e.slice(0,-1):e}/${a}`,m=c.method||"get",U=[...Object.entries(r).map(([f,g])=>({name:f,in:g.in||"path",required:g.required||!1,schema:{type:g.type||"string"},description:g.description||""})),...Object.entries(c.params||{}).map(([f,g])=>({name:f,in:g.in||"query",required:g.required||!1,default:g.default,schema:{type:g.type||"string"},description:g.description||""}))],I=c.responses||{200:{description:"Successful response"}},F={summary:c.summary||"",description:c.description||"",operationId:this.#a(p),tags:s?[s]:[],parameters:U,responses:I};(I[401]||I[401])&&(F.security=[{ApiKeyAuth:[]}]),c.body&&(F.requestBody={content:{"application/json":{schema:c.body}}});let rt={[m.toLowerCase()]:F};if(c.api===!0&&typeof c.action=="function"){let f=null;if(c.params){f=[];for(let[y,B]of Object.entries(c.params))B.in==="path"&&(p+=`/{${y}}`),f.push(y),r[y]=B}let g=await this.#o(await c.action(f?Object.fromEntries(f.map(y=>[y,y])):{},null,{}),p,r,c.tag??null);if(c.params)for(let y of Object.keys(c.params))delete r[y];Object.assign(i,g)}else i[p]=rt}return i}async#i(t,e){let n=[];for(let[s,i]of Object.entries(t.schema)){let a=`${e.endsWith("/")?e.slice(0,-1):e}/${s}`;if(i.api===!0&&typeof i.action=="function"){n.push({name:i.tag||a,description:i.description||""});let c={};if(i.params)for(let[p,m]of Object.entries(i.params))m.in==="path"&&(a+=`/{${p}}`),c[p]=p;let d=await this.#i(await i.action(c,null,{}),a);n=[...n,...d]}}return n}#a(t){return t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,-1)),t.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};var l=class extends Error{#t;#e;get statusCode(){return this.#t}get name(){return this.#e}constructor(t,e,n){super(e),this.#e=t,this.#t=n}},R=class extends l{constructor(t="Not Found",e=404){super("NotFoundError",t,e)}},J=class extends l{constructor(t="Value is missing",e=501){super("MissingValueError",t,e)}},x=class extends l{constructor(t="Unauthorized",e=401){super("AuthError",t,e)}},H=class extends l{constructor(t="System Error",e=500){super("SystemError",t,e)}},$=class extends l{constructor(t="Not Allowed",e=403){super("NotAllowedError",t,e)}},D=class extends l{constructor(t="Bad format",e=400){super("BadFormatError",t,e)}},W=class extends l{constructor(t="Not Implemented",e=501){super("NotImplementedError",t,e)}};var M=class o{#t;get schema(){return this.#t}#e;#n;constructor(t={},e="API Documentation",n="Unknown"){this.#t=this.#s(t),this.#e=`${e} (${process.env.AWS_LAMBDA_FUNCTION_NAME||"Local"})`,this.#n=n}get isAPIInterface(){return!0}async execute(t,e,n,s,i={}){Array.isArray(t)||(t=[t]);let r=t.join("/"),a=await this.exrec([...t],e,n,s,i);return a?.isAPIInterface===!0?a.usage(r,this.#t[r]?.params):a}async exrec(t,e,n,s,i={}){let r=this;for(;t.length>0;){let a=t.splice(0,1)[0],c=r.#t[a];if(!c)throw new R(a+" not found");if(c.params&&Object.keys(c.params).length>0)for(let p of Object.keys(c.params))c.params[p]?.in==="path"&&(e[p]=t.splice(0,1)[0]);let d=await c.action(e,s,i);if(t.length===0)return d;if(!(d instanceof o))throw new R(a+" not found");r=d}return r}async usage(t,e={}){let n=await new _(this,this.#e,this.#n,t,e).json();return new h(n)}addHandler(t,e){this.#t[t]={method:"post",action:e}}addLambdaSimulator(t){let e=process.env.ALLOW_API?.split(",").map(s=>s.trim())||["all"];(process.env.DENY_API?.split(",").map(s=>s.trim())||[]).indexOf("lambda")>=0||e.indexOf("all")<0&&e.indexOf("lambda")<0||(this.#t.lambda={api:!0,toplevel:!0,tag:"Lambda Simulator",description:"Simulate Lambda invocation using REST API",action:t})}#s(t){let e=process.env.ALLOW_API?.split(",").map(s=>s.trim())||null,n=process.env.DENY_API?.split(",").map(s=>s.trim())||[];if(n[0]?.toLowerCase()==="all")return{};for(let s of Object.keys(t))t[s].api&&t[s].toplevel&&(e&&e.indexOf(s)<0||n.indexOf(s)>=0)&&delete t[s];return t}async resolveMethod(t){Array.isArray(t)||(t=[t]),t=[...t];let e=this.#t,n="get";for(let s=0;s<t.length;s++){let i=e[t[s]];if(!i)return n;if(i.method&&(n=i.method),s<t.length-1&&i.action)try{let r=await i.action({},null,{});if(r?.isAPIInterface)e=r.schema;else return n}catch{return n}}return n}confirmAPIKey(t,e){if(e){let n=t["x-api-key"];if(!n||n!==e)throw new x("Invalid or missing API key")}}};var u=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,e={}){return t}shortInputLog(t){let e=JSON.stringify(t);return e.length>100&&(e=e.substring(0,100)+"..."),e}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var b=class extends u{static isExpressURL(t){let e=t;if(!e?.method||!e?.requestContext)return!1;let n=e.requestContext;return!(!n?.http||!n.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=t.requestContext.http.path||"";n[0]==="/"&&(n=n.substring(1));let s=n.lastIndexOf(".");s>0?(this._format=n.substring(s+1),n=n.substring(0,s)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}processResponse(t,e={}){e["Content-Type"]=t.contentType;let n=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:e,body:n}}};var A=class extends u{static isLambdaURL(t){let e=t;if(!e?.requestContext)return!1;let n=e.requestContext;if(!n?.http)return!1;let s=n.http;return!(!s?.method||!s?.path)}constructor(t){super("lambda_url");let e=t.requestContext;this._method=e.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=e.http.path;n[0]==="/"&&(n=n.substring(1));let s=n.lastIndexOf(".");s>0?(this._format=n.substring(s+1),n=n.substring(0,s)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}shortInputLog(t){let e=t,n=e.requestContext;return JSON.stringify({path:n?.http?.path,method:n?.http?.method,params:e.queryStringParameters,sourceIp:n?.http?.sourceIp})}processResponse(t,e={}){let n={...e,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},s=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:n,body:s}}};var S=class extends u{static isAmazonConnect(t){let e=t;return!(e?.Name!=="ContactFlowEvent"||!e.Details||!e.Details.ContactData)}#t;get initMethod(){return this.#t}#e;get contactid(){return this.#e}#n;get systemEndpoint(){return this.#n}#s;get customerEndpoint(){return this.#s}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let e=t.Details;this._params=e.Parameters||null;let n=e.ContactData;this._params||(this._params=n.Attributes||{});let s=this._params.path||"";this._path=s.split("/");let i=n.Attributes;this._method=i?.method||"get",this.#e=n.ContactId,this.#e&&(this._params.contactid=this.#e),this.#n=n.SystemEndpoint?.Address,this.#s=n.CustomerEndpoint?.Address,this._payload=i,this.#t=n.InitiationMethod,this.#r=n.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,e={}){let n=t.content;return n.lambdaResult="Success",n}};var P=class o extends u{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(o.identifier),this._path=o.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};var N=class o extends u{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=o.identifier,this._method="post",this._params={},this._payload=o.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(e=>({eventName:e.eventName,bucket:e.s3?.bucket?.name,key:e.s3?.object?.key,size:e.s3?.object?.size}))}shortInputLog(t){let n=t?.Records?.[0],s=n?.s3?.bucket?.name??"?",i=n?.s3?.object?.key??"?";return`S3 ${n?.eventName??"event"}: s3://${s}/${i}`}};var O=class o extends u{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=o.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(n=>{try{return JSON.parse(n.Sns.Message)}catch{return n.Sns.Message}})}};var V={matchHandler(o){return A.isLambdaURL(o)?new A(o):b.isExpressURL(o)?new b(o):S.isAmazonConnect(o)?new S(o):P.isKinesis(o)?new P(o):N.isS3(o)?new N(o):O.isSNS(o)?new O(o):null}};var Y=k(require("fs"),1),G=k(require("mime-types"),1),Z=async(o,t)=>{let e=V.matchHandler(o);if(!e)return console.error("No handler found for input"),console.log("INPUT",JSON.stringify(o)),{statusCode:400,body:"Input not recognized"};let n={"Access-Control-Allow-Origin":"*"};if(e.method.toLowerCase()==="options"){let r=e.headers;return n={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":r["access-control-request-method"],"Access-Control-Allow-Headers":r["access-control-request-headers"]},console.log("CORS request service"),{statusCode:200,headers:n}}let s=e.path;if(s[0]==="docs"){let r,a;if(s.length>1){r=s.slice(1).join("/");let d=e.format;d?(r+="."+d,a=G.default.lookup(r)||"application/octet-stream"):a="application/octet-stream"}else r="index.html",a="text/html";r=process.cwd()+"/node_modules/redleaf-ishell/swagger/"+r;let c=Y.default.readFileSync(r);return console.log("Docs file",r,c.length),{statusCode:200,headers:{...n,"Content-Type":a,"Access-Control-Allow-Origin":"*","Content-Source":"static"},body:c.toString()}}let i={...e.headers,_handler_type:e.type};try{process.env.AWS_LOG_IO==="true"?console.log("INPUT",JSON.stringify(o)):console.log(e.shortInputLog(o));let r=await t.execute(s,e.params,e.method,e.payload,i);return e.processResponse(r,n)}catch(r){if(console.log("INPUT",JSON.stringify(o)),r instanceof l)return{statusCode:r.statusCode,headers:n,body:JSON.stringify({error:r.message,type:r.name})};let a=r.message,d=e.params.stacktrace!=="false"?r.stack?.split(`
|
|
3
|
+
`).slice(1).map(p=>p.trim()):void 0;return{statusCode:500,headers:n,body:JSON.stringify({error:a,stack:d})||"Internal Application Error"}}};var Q=k(require("cors"),1),X=k(require("dotenv"),1),z=k(require("express"),1),tt=k(require("path"),1);var et=o=>{let t=(0,z.default)();t.use(z.default.json()),t.use((0,Q.default)()),t.use("/docs",z.default.static(tt.default.join(process.cwd(),"node_modules/redleaf-ishell/swagger")));let e=async(i,r)=>{let a=i.path;a.startsWith("/")&&(a=a.slice(1)),a.endsWith("/")&&(a=a.slice(0,-1));let c=a.lastIndexOf(".");c>0&&(a=a.slice(0,c));let d=await n(a.split("/"),i.query,i.method,i.headers,i.body);r.type(d.contentType).status(d.returnCode).send(d.content)},n=async(i,r,a,c,d=null)=>{let p={...c,_handler_type:"express"};try{if(d!==null){let m;try{m=JSON.parse(d)}catch{m=d}return await o.execute(i,r,a,m,p)}else return await o.execute(i,r,a,void 0,p)}catch(m){let U=m.stack?.split(`
|
|
4
|
+
`).slice(1).map(I=>I.trim());return m instanceof l?new h({status:"error",type:m.name,message:m.message}).errorCode(m.statusCode):new h({status:"error",error:m.message,stack:U}).errorCode(500)}};t.get("/{*path}",(i,r)=>{e(i,r)}),t.post("/{*path}",(i,r)=>{e(i,r)}),t.put("/{*path}",(i,r)=>{e(i,r)}),t.patch("/{*path}",(i,r)=>{e(i,r)}),t.delete("/{*path}",(i,r)=>{e(i,r)}),X.default.config();let s=parseInt(process.env.PORT||"3001",10);return new Promise((i,r)=>{let a=t.listen(s,()=>{let c=`http://localhost:${s}/`;console.log(`Express server running on ${c}`);for(let[d,p]of Object.entries(o.schema))p.api&&console.log(`For ${p.tag} API go to ${c}docs/?root=${d}`);i(a)});a.on("error",r)})};var nt=k(require("readline"),1);var j=class o extends u{constructor(t,e,n,s){super("console"),this._path=t,this._params=e,this._method=n,this._payload=s,this._headers={_handler_type:"console"}}static parse(t){let e=o.#t(t.trim()),n=[],s={},i=null,r=0;for(;r<e.length&&!e[r].startsWith("--");)n.push(e[r]),r++;for(;r<e.length;)if(e[r].startsWith("--")){let a=e[r].slice(2);r+1<e.length&&!e[r+1].startsWith("--")?(s[a]=e[r+1],r+=2):(s[a]=!0,r++)}else{let a=e.slice(r).join(" ");try{i=JSON.parse(a)}catch{i=a}break}return{path:n,params:s,body:i}}static#t(t){let e=[],n="",s=!1,i=!1;for(let r of t)r==="'"&&!i?s=!s:r==='"'&&!s?i=!i:r===" "&&!s&&!i?n&&(e.push(n),n=""):n+=r;return n&&e.push(n),e}processResponse(t){let e=t.content;t.contentType?.startsWith("application/json")?process.stdout.write(JSON.stringify(e,null,2)+`
|
|
5
|
+
`):process.stdout.write(String(e)+`
|
|
6
|
+
`)}};var st=o=>new Promise(t=>{let e=nt.default.createInterface({input:process.stdin,output:process.stdout,prompt:"> "});e.prompt(),e.on("line",async n=>{if(n=n.trim(),!n){e.prompt();return}if(n==="exit"||n==="quit"){e.close();return}try{let{path:s,params:i,body:r}=j.parse(n),a=await o.resolveMethod(s),c=new j(s,i,a,r),d=await o.execute([...s],i,a,r,c.headers);c.processResponse(d)}catch(s){process.stderr.write(`Error: ${s.message}
|
|
7
|
+
`)}e.prompt()}),e.on("close",t)});0&&(module.exports={APIInterface,AuthError,BadFormatError,BaseError,MissingValueError,NotAllowedError,NotFoundError,NotImplementedError,ResponseCSV,ResponseHTML,ResponseJSON,ResponseJSON2CSV,ResponseText,ResponseXML,SystemError,handleLambdaTrigger,localCLI,localServer});
|
package/exports.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{a as t}from"./chunk-LXIIMVCF.js";import{a as N}from"./chunk-INB47U4Q.js";import"./chunk-6QP54GKU.js";import{a as C}from"./chunk-AVMTVHWW.js";import"./chunk-7LZN2JAA.js";import"./chunk-ZR7NQQXZ.js";import"./chunk-YEDXPIF7.js";import"./chunk-TRA2JUZE.js";import"./chunk-UYING5L4.js";import"./chunk-4ZIBH32D.js";import"./chunk-YCH4ABT5.js";import"./chunk-6W4C3JBY.js";import{a as L}from"./chunk-RO2W6WB2.js";import{a as h,b as E,c as A,d as P,e as R,f as S,g as w,h as y}from"./chunk-S5BWAMGC.js";import{a as d,b as f,c as l,d as u,e as I,f as x}from"./chunk-S3PQMJO4.js";import g from"readline";var M=s=>new Promise(c=>{let r=g.createInterface({input:process.stdin,output:process.stdout,prompt:"> "});r.prompt(),r.on("line",async e=>{if(e=e.trim(),!e){r.prompt();return}if(e==="exit"||e==="quit"){r.close();return}try{let{path:o,params:p,body:n}=t.parse(e),a=await s.resolveMethod(o),m=new t(o,p,a,n),i=await s.execute([...o],p,a,n,m.headers);m.processResponse(i)}catch(o){process.stderr.write(`Error: ${o.message}
|
|
2
|
+
`)}r.prompt()}),r.on("close",c)});export{N as APIInterface,P as AuthError,w as BadFormatError,h as BaseError,A as MissingValueError,S as NotAllowedError,E as NotFoundError,y as NotImplementedError,f as ResponseCSV,I as ResponseHTML,d as ResponseJSON,l as ResponseJSON2CSV,u as ResponseText,x as ResponseXML,R as SystemError,C as handleLambdaTrigger,M as localCLI,L as localServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},u=(r,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!h.call(r,s)&&s!==n&&o(r,s,{get:()=>t[s],enumerable:!(a=p(t,s))||a.enumerable});return r};var c=r=>u(o({},"__esModule",{value:!0}),r);var _={};d(_,{KinesistHandler:()=>i});module.exports=c(_);var e=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,n={}){return t}shortInputLog(t){let n=JSON.stringify(t);return n.length>100&&(n=n.substring(0,100)+"..."),n}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var i=class r extends e{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(r.identifier),this._path=r.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};0&&(module.exports={KinesistHandler});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-YEDXPIF7.js";import"../chunk-6W4C3JBY.js";export{a as KinesistHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var h=(s,t)=>{for(var e in t)i(s,e,{get:t[e],enumerable:!0})},m=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of u(t))!g.call(s,n)&&n!==e&&i(s,n,{get:()=>t[n],enumerable:!(r=p(t,n))||r.enumerable});return s};var d=s=>m(i({},"__esModule",{value:!0}),s);var _={};h(_,{S3Handler:()=>a});module.exports=d(_);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,e={}){return t}shortInputLog(t){let e=JSON.stringify(t);return e.length>100&&(e=e.substring(0,100)+"..."),e}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var a=class s extends o{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=s.identifier,this._method="post",this._params={},this._payload=s.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(e=>({eventName:e.eventName,bucket:e.s3?.bucket?.name,key:e.s3?.object?.key,size:e.s3?.object?.size}))}shortInputLog(t){let r=t?.Records?.[0],n=r?.s3?.bucket?.name??"?",c=r?.s3?.object?.key??"?";return`S3 ${r?.eventName??"event"}: s3://${n}/${c}`}};0&&(module.exports={S3Handler});
|
package/handlers/S3Handler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-TRA2JUZE.js";import"../chunk-6W4C3JBY.js";export{a as S3Handler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var u=(s,t)=>{for(var n in t)i(s,n,{get:t[n],enumerable:!0})},d=(s,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of g(t))!h.call(s,e)&&e!==n&&i(s,e,{get:()=>t[e],enumerable:!(r=p(t,e))||r.enumerable});return s};var c=s=>d(i({},"__esModule",{value:!0}),s);var _={};u(_,{SNSHandler:()=>a});module.exports=c(_);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,n={}){return t}shortInputLog(t){let n=JSON.stringify(t);return n.length>100&&(n=n.substring(0,100)+"..."),n}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var a=class s extends o{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=s.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(r=>{try{return JSON.parse(r.Sns.Message)}catch{return r.Sns.Message}})}};0&&(module.exports={SNSHandler});
|
package/handlers/SNSHandler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-UYING5L4.js";import"../chunk-6W4C3JBY.js";export{a as SNSHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of g(t))!c.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(s=u(t,r))||s.enumerable});return e};var m=e=>p(o({},"__esModule",{value:!0}),e);var l={};h(l,{AmazonConnectHandler:()=>a});module.exports=m(l);var i=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,n={}){return t}shortInputLog(t){let n=JSON.stringify(t);return n.length>100&&(n=n.substring(0,100)+"..."),n}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var a=class extends i{static isAmazonConnect(t){let n=t;return!(n?.Name!=="ContactFlowEvent"||!n.Details||!n.Details.ContactData)}#t;get initMethod(){return this.#t}#n;get contactid(){return this.#n}#s;get systemEndpoint(){return this.#s}#e;get customerEndpoint(){return this.#e}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let n=t.Details;this._params=n.Parameters||null;let s=n.ContactData;this._params||(this._params=s.Attributes||{});let r=this._params.path||"";this._path=r.split("/");let d=s.Attributes;this._method=d?.method||"get",this.#n=s.ContactId,this.#n&&(this._params.contactid=this.#n),this.#s=s.SystemEndpoint?.Address,this.#e=s.CustomerEndpoint?.Address,this._payload=d,this.#t=s.InitiationMethod,this.#r=s.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,n={}){let s=t.content;return s.lambdaResult="Success",s}};0&&(module.exports={AmazonConnectHandler});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-4ZIBH32D.js";import"../chunk-6W4C3JBY.js";export{a as AmazonConnectHandler};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var d=(o,s)=>{for(var t in s)h(o,t,{get:s[t],enumerable:!0})},m=(o,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of u(s))!l.call(o,e)&&e!==t&&h(o,e,{get:()=>s[e],enumerable:!(r=c(s,e))||r.enumerable});return o};var _=o=>m(h({},"__esModule",{value:!0}),o);var f={};d(f,{ConsoleHandler:()=>g});module.exports=_(f);var p=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(s){this.#t=s}getParam(s){return this._params[s]}processResponse(s,t={}){return s}shortInputLog(s){let t=JSON.stringify(s);return t.length>100&&(t=t.substring(0,100)+"..."),t}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var g=class o extends p{constructor(s,t,r,e){super("console"),this._path=s,this._params=t,this._method=r,this._payload=e,this._headers={_handler_type:"console"}}static parse(s){let t=o.#t(s.trim()),r=[],e={},i=null,n=0;for(;n<t.length&&!t[n].startsWith("--");)r.push(t[n]),n++;for(;n<t.length;)if(t[n].startsWith("--")){let a=t[n].slice(2);n+1<t.length&&!t[n+1].startsWith("--")?(e[a]=t[n+1],n+=2):(e[a]=!0,n++)}else{let a=t.slice(n).join(" ");try{i=JSON.parse(a)}catch{i=a}break}return{path:r,params:e,body:i}}static#t(s){let t=[],r="",e=!1,i=!1;for(let n of s)n==="'"&&!i?e=!e:n==='"'&&!e?i=!i:n===" "&&!e&&!i?r&&(t.push(r),r=""):r+=n;return r&&t.push(r),t}processResponse(s){let t=s.content;s.contentType?.startsWith("application/json")?process.stdout.write(JSON.stringify(t,null,2)+`
|
|
2
|
+
`):process.stdout.write(String(t)+`
|
|
3
|
+
`)}};0&&(module.exports={ConsoleHandler});
|
package/handlers/console.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-LXIIMVCF.js";import"../chunk-6W4C3JBY.js";export{a as ConsoleHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var s in t)a(e,s,{get:t[s],enumerable:!0})},c=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of h(t))!g.call(e,n)&&n!==s&&a(e,n,{get:()=>t[n],enumerable:!(r=p(t,n))||r.enumerable});return e};var u=e=>c(a({},"__esModule",{value:!0}),e);var m={};d(m,{ExpressURLHandler:()=>i});module.exports=u(m);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,s={}){return t}shortInputLog(t){let s=JSON.stringify(t);return s.length>100&&(s=s.substring(0,100)+"..."),s}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var i=class extends o{static isExpressURL(t){let s=t;if(!s?.method||!s?.requestContext)return!1;let r=s.requestContext;return!(!r?.http||!r.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let r=t.requestContext.http.path||"";r[0]==="/"&&(r=r.substring(1));let n=r.lastIndexOf(".");n>0?(this._format=r.substring(n+1),r=r.substring(0,n)):this._format="json",this._path=r.split("/"),this._headers=t.headers||{}}processResponse(t,s={}){s["Content-Type"]=t.contentType;let r=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:s,body:r}}};0&&(module.exports={ExpressURLHandler});
|
package/handlers/express.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-YCH4ABT5.js";import"../chunk-6W4C3JBY.js";export{a as ExpressURLHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var s in t)h(e,s,{get:t[s],enumerable:!0})},k=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of l(t))!f.call(e,r)&&r!==s&&h(e,r,{get:()=>t[r],enumerable:!(n=m(t,r))||n.enumerable});return e};var w=e=>k(h({},"__esModule",{value:!0}),e);var y={};R(y,{handlers:()=>_});module.exports=w(y);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,s={}){return t}shortInputLog(t){let s=JSON.stringify(t);return s.length>100&&(s=s.substring(0,100)+"..."),s}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var i=class extends o{static isExpressURL(t){let s=t;if(!s?.method||!s?.requestContext)return!1;let n=s.requestContext;return!(!n?.http||!n.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=t.requestContext.http.path||"";n[0]==="/"&&(n=n.substring(1));let r=n.lastIndexOf(".");r>0?(this._format=n.substring(r+1),n=n.substring(0,r)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}processResponse(t,s={}){s["Content-Type"]=t.contentType;let n=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:s,body:n}}};var a=class extends o{static isLambdaURL(t){let s=t;if(!s?.requestContext)return!1;let n=s.requestContext;if(!n?.http)return!1;let r=n.http;return!(!r?.method||!r?.path)}constructor(t){super("lambda_url");let s=t.requestContext;this._method=s.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=s.http.path;n[0]==="/"&&(n=n.substring(1));let r=n.lastIndexOf(".");r>0?(this._format=n.substring(r+1),n=n.substring(0,r)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}shortInputLog(t){let s=t,n=s.requestContext;return JSON.stringify({path:n?.http?.path,method:n?.http?.method,params:s.queryStringParameters,sourceIp:n?.http?.sourceIp})}processResponse(t,s={}){let n={...s,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},r=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:n,body:r}}};var d=class extends o{static isAmazonConnect(t){let s=t;return!(s?.Name!=="ContactFlowEvent"||!s.Details||!s.Details.ContactData)}#t;get initMethod(){return this.#t}#n;get contactid(){return this.#n}#s;get systemEndpoint(){return this.#s}#e;get customerEndpoint(){return this.#e}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let s=t.Details;this._params=s.Parameters||null;let n=s.ContactData;this._params||(this._params=n.Attributes||{});let r=this._params.path||"";this._path=r.split("/");let g=n.Attributes;this._method=g?.method||"get",this.#n=n.ContactId,this.#n&&(this._params.contactid=this.#n),this.#s=n.SystemEndpoint?.Address,this.#e=n.CustomerEndpoint?.Address,this._payload=g,this.#t=n.InitiationMethod,this.#r=n.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,s={}){let n=t.content;return n.lambdaResult="Success",n}};var c=class e extends o{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(e.identifier),this._path=e.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};var u=class e extends o{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=e.identifier,this._method="post",this._params={},this._payload=e.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(s=>({eventName:s.eventName,bucket:s.s3?.bucket?.name,key:s.s3?.object?.key,size:s.s3?.object?.size}))}shortInputLog(t){let n=t?.Records?.[0],r=n?.s3?.bucket?.name??"?",g=n?.s3?.object?.key??"?";return`S3 ${n?.eventName??"event"}: s3://${r}/${g}`}};var p=class e extends o{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=e.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(n=>{try{return JSON.parse(n.Sns.Message)}catch{return n.Sns.Message}})}};var _={matchHandler(e){return a.isLambdaURL(e)?new a(e):i.isExpressURL(e)?new i(e):d.isAmazonConnect(e)?new d(e):c.isKinesis(e)?new c(e):u.isS3(e)?new u(e):p.isSNS(e)?new p(e):null}};0&&(module.exports={handlers});
|
package/handlers/handlers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-7LZN2JAA.js";import"../chunk-ZR7NQQXZ.js";import"../chunk-YEDXPIF7.js";import"../chunk-TRA2JUZE.js";import"../chunk-UYING5L4.js";import"../chunk-4ZIBH32D.js";import"../chunk-YCH4ABT5.js";import"../chunk-6W4C3JBY.js";export{a as handlers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},d=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!p.call(e,s)&&s!==r&&n(e,s,{get:()=>t[s],enumerable:!(a=i(t,s))||a.enumerable});return e};var u=e=>d(n({},"__esModule",{value:!0}),e);var m={};h(m,{InputHandler:()=>o});module.exports=u(m);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,r={}){return t}shortInputLog(t){let r=JSON.stringify(t);return r.length>100&&(r=r.substring(0,100)+"..."),r}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};0&&(module.exports={InputHandler});
|
package/handlers/inputHandler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-6W4C3JBY.js";export{a as InputHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!g.call(e,s)&&s!==r&&i(e,s,{get:()=>t[s],enumerable:!(n=p(t,s))||n.enumerable});return e};var u=e=>c(i({},"__esModule",{value:!0}),e);var m={};d(m,{LambdaURLHandler:()=>a});module.exports=u(m);var o=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,r={}){return t}shortInputLog(t){let r=JSON.stringify(t);return r.length>100&&(r=r.substring(0,100)+"..."),r}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var a=class extends o{static isLambdaURL(t){let r=t;if(!r?.requestContext)return!1;let n=r.requestContext;if(!n?.http)return!1;let s=n.http;return!(!s?.method||!s?.path)}constructor(t){super("lambda_url");let r=t.requestContext;this._method=r.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=r.http.path;n[0]==="/"&&(n=n.substring(1));let s=n.lastIndexOf(".");s>0?(this._format=n.substring(s+1),n=n.substring(0,s)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}shortInputLog(t){let r=t,n=r.requestContext;return JSON.stringify({path:n?.http?.path,method:n?.http?.method,params:r.queryStringParameters,sourceIp:n?.http?.sourceIp})}processResponse(t,r={}){let n={...r,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},s=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:n,body:s}}};0&&(module.exports={LambdaURLHandler});
|
package/handlers/lambdaURL.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"../chunk-ZR7NQQXZ.js";import"../chunk-6W4C3JBY.js";export{a as LambdaURLHandler};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var C=Object.create;var f=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!O.call(e,r)&&r!==n&&f(e,r,{get:()=>t[r],enumerable:!(s=N(t,r))||s.enumerable});return e};var R=(e,t,n)=>(n=e!=null?C(A(e)):{},k(t||!e||!e.__esModule?f(n,"default",{value:e,enumerable:!0}):n,e)),v=e=>k(f({},"__esModule",{value:!0}),e);var L={};E(L,{handleLambdaTrigger:()=>j});module.exports=v(L);var i=class{#t;get type(){return this.#t}_path=[];_method="";_params={};_payload=null;_format="json";_headers={};get path(){return this._path}get method(){return this._method}get params(){return this._params}get payload(){return this._payload}get format(){return this._format}get headers(){return this._headers}constructor(t){this.#t=t}getParam(t){return this._params[t]}processResponse(t,n={}){return t}shortInputLog(t){let n=JSON.stringify(t);return n.length>100&&(n=n.substring(0,100)+"..."),n}get json(){return{type:this.#t,method:this._method,path:this._path,params:this._params,payload:this._payload,format:this._format}}};var d=class extends i{static isExpressURL(t){let n=t;if(!n?.method||!n?.requestContext)return!1;let s=n.requestContext;return!(!s?.http||!s.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let s=t.requestContext.http.path||"";s[0]==="/"&&(s=s.substring(1));let r=s.lastIndexOf(".");r>0?(this._format=s.substring(r+1),s=s.substring(0,r)):this._format="json",this._path=s.split("/"),this._headers=t.headers||{}}processResponse(t,n={}){n["Content-Type"]=t.contentType;let s=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:n,body:s}}};var u=class extends i{static isLambdaURL(t){let n=t;if(!n?.requestContext)return!1;let s=n.requestContext;if(!s?.http)return!1;let r=s.http;return!(!r?.method||!r?.path)}constructor(t){super("lambda_url");let n=t.requestContext;this._method=n.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let s=n.http.path;s[0]==="/"&&(s=s.substring(1));let r=s.lastIndexOf(".");r>0?(this._format=s.substring(r+1),s=s.substring(0,r)):this._format="json",this._path=s.split("/"),this._headers=t.headers||{}}shortInputLog(t){let n=t,s=n.requestContext;return JSON.stringify({path:s?.http?.path,method:s?.http?.method,params:n.queryStringParameters,sourceIp:s?.http?.sourceIp})}processResponse(t,n={}){let s={...n,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},r=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:s,body:r}}};var p=class extends i{static isAmazonConnect(t){let n=t;return!(n?.Name!=="ContactFlowEvent"||!n.Details||!n.Details.ContactData)}#t;get initMethod(){return this.#t}#n;get contactid(){return this.#n}#s;get systemEndpoint(){return this.#s}#e;get customerEndpoint(){return this.#e}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let n=t.Details;this._params=n.Parameters||null;let s=n.ContactData;this._params||(this._params=s.Attributes||{});let r=this._params.path||"";this._path=r.split("/");let a=s.Attributes;this._method=a?.method||"get",this.#n=s.ContactId,this.#n&&(this._params.contactid=this.#n),this.#s=s.SystemEndpoint?.Address,this.#e=s.CustomerEndpoint?.Address,this._payload=a,this.#t=s.InitiationMethod,this.#r=s.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,n={}){let s=t.content;return s.lambdaResult="Success",s}};var g=class e extends i{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(e.identifier),this._path=e.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};var l=class e extends i{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=e.identifier,this._method="post",this._params={},this._payload=e.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(n=>({eventName:n.eventName,bucket:n.s3?.bucket?.name,key:n.s3?.object?.key,size:n.s3?.object?.size}))}shortInputLog(t){let s=t?.Records?.[0],r=s?.s3?.bucket?.name??"?",a=s?.s3?.object?.key??"?";return`S3 ${s?.eventName??"event"}: s3://${r}/${a}`}};var h=class e extends i{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=e.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(s=>{try{return JSON.parse(s.Sns.Message)}catch{return s.Sns.Message}})}};var _={matchHandler(e){return u.isLambdaURL(e)?new u(e):d.isExpressURL(e)?new d(e):p.isAmazonConnect(e)?new p(e):g.isKinesis(e)?new g(e):l.isS3(e)?new l(e):h.isSNS(e)?new h(e):null}};var y=class extends Error{#t;#n;get statusCode(){return this.#t}get name(){return this.#n}constructor(t,n,s){super(n),this.#n=t,this.#t=s}};var x=R(require("fs"),1),S=R(require("mime-types"),1),j=async(e,t)=>{let n=_.matchHandler(e);if(!n)return console.error("No handler found for input"),console.log("INPUT",JSON.stringify(e)),{statusCode:400,body:"Input not recognized"};let s={"Access-Control-Allow-Origin":"*"};if(n.method.toLowerCase()==="options"){let o=n.headers;return s={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":o["access-control-request-method"],"Access-Control-Allow-Headers":o["access-control-request-headers"]},console.log("CORS request service"),{statusCode:200,headers:s}}let r=n.path;if(r[0]==="docs"){let o,c;if(r.length>1){o=r.slice(1).join("/");let m=n.format;m?(o+="."+m,c=S.default.lookup(o)||"application/octet-stream"):c="application/octet-stream"}else o="index.html",c="text/html";o=process.cwd()+"/node_modules/redleaf-ishell/swagger/"+o;let w=x.default.readFileSync(o);return console.log("Docs file",o,w.length),{statusCode:200,headers:{...s,"Content-Type":c,"Access-Control-Allow-Origin":"*","Content-Source":"static"},body:w.toString()}}let a={...n.headers,_handler_type:n.type};try{process.env.AWS_LOG_IO==="true"?console.log("INPUT",JSON.stringify(e)):console.log(n.shortInputLog(e));let o=await t.execute(r,n.params,n.method,n.payload,a);return n.processResponse(o,s)}catch(o){if(console.log("INPUT",JSON.stringify(e)),o instanceof y)return{statusCode:o.statusCode,headers:s,body:JSON.stringify({error:o.message,type:o.name})};let c=o.message,m=n.params.stacktrace!=="false"?o.stack?.split(`
|
|
2
|
+
`).slice(1).map(b=>b.trim()):void 0;return{statusCode:500,headers:s,body:JSON.stringify({error:c,stack:m})||"Internal Application Error"}}};0&&(module.exports={handleLambdaTrigger});
|
package/lambdaHandler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"./chunk-AVMTVHWW.js";import"./chunk-7LZN2JAA.js";import"./chunk-ZR7NQQXZ.js";import"./chunk-YEDXPIF7.js";import"./chunk-TRA2JUZE.js";import"./chunk-UYING5L4.js";import"./chunk-4ZIBH32D.js";import"./chunk-YCH4ABT5.js";import"./chunk-6W4C3JBY.js";import"./chunk-S5BWAMGC.js";export{a as handleLambdaTrigger};
|
package/local.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
const a16_0x18eb86=a16_0x1419;(function(_0x20a4b5,_0x3c33b8){const _0x37d4fc=a16_0x1419,_0xc1302c=_0x20a4b5();while(!![]){try{const _0x1377e2=parseInt(_0x37d4fc(0xa7))/0x1+parseInt(_0x37d4fc(0xa1))/0x2+parseInt(_0x37d4fc(0x97))/0x3+-parseInt(_0x37d4fc(0xa4))/0x4+-parseInt(_0x37d4fc(0xa3))/0x5+-parseInt(_0x37d4fc(0x96))/0x6+parseInt(_0x37d4fc(0xa0))/0x7*(-parseInt(_0x37d4fc(0x9c))/0x8);if(_0x1377e2===_0x3c33b8)break;else _0xc1302c['push'](_0xc1302c['shift']());}catch(_0x94abc6){_0xc1302c['push'](_0xc1302c['shift']());}}}(a16_0x3c02,0x1e14f));const a16_0x3f7a72=(function(){let _0x2428d0=!![];return function(_0x12f166,_0x1f72ec){const _0x3019ff=_0x2428d0?function(){const _0x4d532d=a16_0x1419;if(_0x1f72ec){const _0xdb0ba1=_0x1f72ec[_0x4d532d(0xa6)](_0x12f166,arguments);return _0x1f72ec=null,_0xdb0ba1;}}:function(){};return _0x2428d0=![],_0x3019ff;};}()),a16_0x402320=a16_0x3f7a72(this,function(){const _0x565aab=a16_0x1419,_0xf5e6eb={'Sdtah':'(((.+)+)+)+$'};return a16_0x402320[_0x565aab(0x99)]()[_0x565aab(0x9f)](_0x565aab(0x9a))[_0x565aab(0x99)]()[_0x565aab(0x9e)](a16_0x402320)[_0x565aab(0x9f)](_0xf5e6eb[_0x565aab(0x98)]);});function a16_0x3c02(){const _0x35c5a9=['u2r0ywG','Dg9tDhjPBMC','kcGOlISPkYKRksSK','ywrKtgfTyMrHu2LTDwXHDg9Y','ognfALP4EG','sgvSBg8Gv29YBgqH','y29UC3rYDwn0B3i','C2vHCMnO','mZm0mJG1rLrODKDI','mZa0otm4rNLqtxbc','uKjwt2u','mta0mJiWmfzdsu9IDW','ntK5ndaWrgXhy09Z','qvbjihrVignVBNrYB2WGzgf0ysbZB3vYy2vZicHLlMCUieDVB2DSzsbtAgvLDhmSifmZksbHBMqGCMv0CMLLDMuGzgf0ysbMCM9TihrOzw0','yxbWBhK','mtGZntm5s2jKDfn1','C3rHCNrPBMCGBg9JywWGC2vYDMvYlI4U','mJyZndKWtwHwqwjI','nZeXntaXtu5JDKro'];a16_0x3c02=function(){return _0x35c5a9;};return a16_0x3c02();}a16_0x402320();import{APIInterface}from'./API.js';function a16_0x1419(_0x30763c,_0xaf294a){_0x30763c=_0x30763c-0x95;const _0x39b9ab=a16_0x3c02();let _0x402320=_0x39b9ab[_0x30763c];if(a16_0x1419['jcaRms']===undefined){var _0x3f7a72=function(_0x2fd359){const _0x1df495='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3425f0='',_0x58658b='',_0x3f569d=_0x3425f0+_0x3f7a72;for(let _0x200b76=0x0,_0xb8e522,_0x407417,_0x23c938=0x0;_0x407417=_0x2fd359['charAt'](_0x23c938++);~_0x407417&&(_0xb8e522=_0x200b76%0x4?_0xb8e522*0x40+_0x407417:_0x407417,_0x200b76++%0x4)?_0x3425f0+=_0x3f569d['charCodeAt'](_0x23c938+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xb8e522>>(-0x2*_0x200b76&0x6)):_0x200b76:0x0){_0x407417=_0x1df495['indexOf'](_0x407417);}for(let _0x1dd525=0x0,_0x180541=_0x3425f0['length'];_0x1dd525<_0x180541;_0x1dd525++){_0x58658b+='%'+('00'+_0x3425f0['charCodeAt'](_0x1dd525)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x58658b);};a16_0x1419['xRWgZs']=_0x3f7a72,a16_0x1419['mXeFMV']={},a16_0x1419['jcaRms']=!![];}const _0x3c0230=_0x39b9ab[0x0],_0x14198b=_0x30763c+_0x3c0230,_0x24c052=a16_0x1419['mXeFMV'][_0x14198b];if(!_0x24c052){const _0x43a496=function(_0x3fc8fe){this['HfYvAY']=_0x3fc8fe,this['BaoXJx']=[0x1,0x0,0x0],this['UNnLhP']=function(){return'newState';},this['YFmNua']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['gyyltz']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x43a496['prototype']['FkZkik']=function(){const _0x4ed711=new RegExp(this['YFmNua']+this['gyyltz']),_0xaff210=_0x4ed711['test'](this['UNnLhP']['toString']())?--this['BaoXJx'][0x1]:--this['BaoXJx'][0x0];return this['YoCipT'](_0xaff210);},_0x43a496['prototype']['YoCipT']=function(_0x579019){if(!Boolean(~_0x579019))return _0x579019;return this['iGuvlf'](this['HfYvAY']);},_0x43a496['prototype']['iGuvlf']=function(_0xbcf9a8){for(let _0x23f677=0x0,_0x26fcb8=this['BaoXJx']['length'];_0x23f677<_0x26fcb8;_0x23f677++){this['BaoXJx']['push'](Math['round'](Math['random']())),_0x26fcb8=this['BaoXJx']['length'];}return _0xbcf9a8(this['BaoXJx'][0x0]);},new _0x43a496(a16_0x1419)['FkZkik'](),_0x402320=a16_0x1419['xRWgZs'](_0x402320),a16_0x1419['mXeFMV'][_0x14198b]=_0x402320;}else _0x402320=_0x24c052;return _0x402320;}import{LambdaSimulatorAPI}from'./LambdaSimulatorAPI.js';import{localServer}from'./localServer.js';import{ResponseJSON}from'./response.js';import{localCLI}from'./localCLI.js';class API extends APIInterface{constructor(){const _0x3e1a77=a16_0x1419;super({'v1':{'api':!![],'toplevel':!![],'tag':'V1','action':()=>new V1()}}),this[_0x3e1a77(0x9b)](async()=>new LambdaSimulatorAPI(this));}}class V1 extends APIInterface{constructor(){const _0x47d28f=a16_0x1419,_0x25ce8c={'whxVP':'get','RBVOe':_0x47d28f(0xa5)};super({'foo':{'method':_0x25ce8c['whxVP'],'description':_0x25ce8c[_0x47d28f(0xa2)],'action':async()=>new ResponseJSON({'message':_0x47d28f(0x9d)})}});}}console['log'](a16_0x18eb86(0x95));const api=new API(),server=await localServer(api);await localCLI(api);
|
|
1
|
+
import{a as m,b as H}from"./chunk-4WZAN36M.js";var j=class{#t;#e;#n=200;get content(){return this.#t}get contentType(){return this.#e}get returnCode(){return this.#n}constructor(t,e){this.#t=t,this.#e=e}errorCode(t){return this.#n=t,this}},g=class extends j{constructor(t){super(t,"application/json")}};var R=class{#t;#e;#n;#s;#r;constructor(t,e,n,s="/",r={}){this.#t=t,this.#e=s.startsWith("/")?s:"/"+s,this.#n=r,this.#s=e||"API Documentation",this.#r=n||"1.0.0"}async json(){let t={openapi:"3.0.0",info:{title:this.#s,version:this.#r},components:{securitySchemes:{ApiKeyAuth:{type:"apiKey",in:"header",name:"x-api-key"}}}};return t.paths=await this.#o(this.#t,this.#e,this.#n),t.tags=await this.#i(this.#t,this.#e),t}async#o(t,e,n,s=null){let r={},o={...n};for(let[a,c]of Object.entries(t.schema)){let u=`${e.endsWith("/")?e.slice(0,-1):e}/${a}`,p=c.method||"get",O=[...Object.entries(o).map(([f,l])=>({name:f,in:l.in||"path",required:l.required||!1,schema:{type:l.type||"string"},description:l.description||""})),...Object.entries(c.params||{}).map(([f,l])=>({name:f,in:l.in||"query",required:l.required||!1,default:l.default,schema:{type:l.type||"string"},description:l.description||""}))],k=c.responses||{200:{description:"Successful response"}},C={summary:c.summary||"",description:c.description||"",operationId:this.#a(u),tags:s?[s]:[],parameters:O,responses:k};(k[401]||k[401])&&(C.security=[{ApiKeyAuth:[]}]),c.body&&(C.requestBody={content:{"application/json":{schema:c.body}}});let z={[p.toLowerCase()]:C};if(c.api===!0&&typeof c.action=="function"){let f=null;if(c.params){f=[];for(let[h,T]of Object.entries(c.params))T.in==="path"&&(u+=`/{${h}}`),f.push(h),o[h]=T}let l=await this.#o(await c.action(f?Object.fromEntries(f.map(h=>[h,h])):{},null,{}),u,o,c.tag??null);if(c.params)for(let h of Object.keys(c.params))delete o[h];Object.assign(r,l)}else r[u]=z}return r}async#i(t,e){let n=[];for(let[s,r]of Object.entries(t.schema)){let a=`${e.endsWith("/")?e.slice(0,-1):e}/${s}`;if(r.api===!0&&typeof r.action=="function"){n.push({name:r.tag||a,description:r.description||""});let c={};if(r.params)for(let[u,p]of Object.entries(r.params))p.in==="path"&&(a+=`/{${u}}`),c[u]=u;let d=await this.#i(await r.action(c,null,{}),a);n=[...n,...d]}}return n}#a(t){return t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,-1)),t.replace(/\//g,"_").replace(/[^a-zA-Z0-9_]/g,"")}};var y=class extends Error{#t;#e;get statusCode(){return this.#t}get name(){return this.#e}constructor(t,e,n){super(e),this.#e=t,this.#t=n}},x=class extends y{constructor(t="Not Found",e=404){super("NotFoundError",t,e)}};var v=class extends y{constructor(t="Unauthorized",e=401){super("AuthError",t,e)}};var w=class i{#t;get schema(){return this.#t}#e;#n;constructor(t={},e="API Documentation",n="Unknown"){this.#t=this.#s(t),this.#e=`${e} (${process.env.AWS_LAMBDA_FUNCTION_NAME||"Local"})`,this.#n=n}get isAPIInterface(){return!0}async execute(t,e,n,s,r={}){Array.isArray(t)||(t=[t]);let o=t.join("/"),a=await this.exrec([...t],e,n,s,r);return a?.isAPIInterface===!0?a.usage(o,this.#t[o]?.params):a}async exrec(t,e,n,s,r={}){let o=this;for(;t.length>0;){let a=t.splice(0,1)[0],c=o.#t[a];if(!c)throw new x(a+" not found");if(c.params&&Object.keys(c.params).length>0)for(let u of Object.keys(c.params))c.params[u]?.in==="path"&&(e[u]=t.splice(0,1)[0]);let d=await c.action(e,s,r);if(t.length===0)return d;if(!(d instanceof i))throw new x(a+" not found");o=d}return o}async usage(t,e={}){let n=await new R(this,this.#e,this.#n,t,e).json();return new g(n)}addHandler(t,e){this.#t[t]={method:"post",action:e}}addLambdaSimulator(t){let e=process.env.ALLOW_API?.split(",").map(s=>s.trim())||["all"];(process.env.DENY_API?.split(",").map(s=>s.trim())||[]).indexOf("lambda")>=0||e.indexOf("all")<0&&e.indexOf("lambda")<0||(this.#t.lambda={api:!0,toplevel:!0,tag:"Lambda Simulator",description:"Simulate Lambda invocation using REST API",action:t})}#s(t){let e=process.env.ALLOW_API?.split(",").map(s=>s.trim())||null,n=process.env.DENY_API?.split(",").map(s=>s.trim())||[];if(n[0]?.toLowerCase()==="all")return{};for(let s of Object.keys(t))t[s].api&&t[s].toplevel&&(e&&e.indexOf(s)<0||n.indexOf(s)>=0)&&delete t[s];return t}async resolveMethod(t){Array.isArray(t)||(t=[t]),t=[...t];let e=this.#t,n="get";for(let s=0;s<t.length;s++){let r=e[t[s]];if(!r)return n;if(r.method&&(n=r.method),s<t.length-1&&r.action)try{let o=await r.action({},null,{});if(o?.isAPIInterface)e=o.schema;else return n}catch{return n}}return n}confirmAPIKey(t,e){if(e){let n=t["x-api-key"];if(!n||n!==e)throw new v("Invalid or missing API key")}}};var I=class extends m{static isExpressURL(t){let e=t;if(!e?.method||!e?.requestContext)return!1;let n=e.requestContext;return!(!n?.http||!n.http?.path)}constructor(t){super("express"),this._method=t.method,this._params=t.query||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=t.requestContext.http.path||"";n[0]==="/"&&(n=n.substring(1));let s=n.lastIndexOf(".");s>0?(this._format=n.substring(s+1),n=n.substring(0,s)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}processResponse(t,e={}){e["Content-Type"]=t.contentType;let n=t.contentType==="application/json"?JSON.stringify(t.content):t.content;return{statusCode:t.returnCode,headers:e,body:n}}};var b=class extends m{static isLambdaURL(t){let e=t;if(!e?.requestContext)return!1;let n=e.requestContext;if(!n?.http)return!1;let s=n.http;return!(!s?.method||!s?.path)}constructor(t){super("lambda_url");let e=t.requestContext;this._method=e.http.method,this._params=t.queryStringParameters||{},this._payload=t.body;try{this._payload=JSON.parse(this._payload)}catch{}let n=e.http.path;n[0]==="/"&&(n=n.substring(1));let s=n.lastIndexOf(".");s>0?(this._format=n.substring(s+1),n=n.substring(0,s)):this._format="json",this._path=n.split("/"),this._headers=t.headers||{}}shortInputLog(t){let e=t,n=e.requestContext;return JSON.stringify({path:n?.http?.path,method:n?.http?.method,params:e.queryStringParameters,sourceIp:n?.http?.sourceIp})}processResponse(t,e={}){let n={...e,"Content-Type":t.contentType,"Access-Control-Allow-Origin":"*"},s=t.contentType==="application/json"?JSON.stringify(t.content):String(t.content);return{statusCode:t.returnCode,headers:n,body:s}}};var A=class extends m{static isAmazonConnect(t){let e=t;return!(e?.Name!=="ContactFlowEvent"||!e.Details||!e.Details.ContactData)}#t;get initMethod(){return this.#t}#e;get contactid(){return this.#e}#n;get systemEndpoint(){return this.#n}#s;get customerEndpoint(){return this.#s}#r;get instanceARN(){return this.#r}constructor(t){super("amazon_connect");let e=t.Details;this._params=e.Parameters||null;let n=e.ContactData;this._params||(this._params=n.Attributes||{});let s=this._params.path||"";this._path=s.split("/");let r=n.Attributes;this._method=r?.method||"get",this.#e=n.ContactId,this.#e&&(this._params.contactid=this.#e),this.#n=n.SystemEndpoint?.Address,this.#s=n.CustomerEndpoint?.Address,this._payload=r,this.#t=n.InitiationMethod,this.#r=n.InstanceARN}get attributes(){return this._payload}shortInputLog(t){return JSON.stringify(t)}processResponse(t,e={}){let n=t.content;return n.lambdaResult="Success",n}};var S=class i extends m{static isKinesis(t){return t.Records?.[0]?.eventSource==="aws:kinesis"}static identifier="__kinesis__";constructor(t){super(i.identifier),this._path=i.identifier,this._method="post",this._params={},this._payload=t,this._format="json"}shortInputLog(t){return JSON.stringify(t)}};var _=class i extends m{static isS3(t){return t?.Records?.[0]?.eventSource==="aws:s3"}static identifier="__s3__";constructor(t){super("s3"),this._path=i.identifier,this._method="post",this._params={},this._payload=i.distill(t),this._format="json"}static distill(t){return(t?.Records??[]).map(e=>({eventName:e.eventName,bucket:e.s3?.bucket?.name,key:e.s3?.object?.key,size:e.s3?.object?.size}))}shortInputLog(t){let n=t?.Records?.[0],s=n?.s3?.bucket?.name??"?",r=n?.s3?.object?.key??"?";return`S3 ${n?.eventName??"event"}: s3://${s}/${r}`}};var P=class i extends m{static isSNS(t){return t.Records?.[0]?.EventSource==="aws:sns"}static identifier="__sns__";constructor(t){super("sns"),this._path=i.identifier,this._method="post",this._params={},this._payload=this.#t(t),this._format="json"}shortInputLog(t){return JSON.stringify(t)}#t(t){return t.Records.map(n=>{try{return JSON.parse(n.Sns.Message)}catch{return n.Sns.Message}})}};var J={matchHandler(i){return b.isLambdaURL(i)?new b(i):I.isExpressURL(i)?new I(i):A.isAmazonConnect(i)?new A(i):S.isKinesis(i)?new S(i):_.isS3(i)?new _(i):P.isSNS(i)?new P(i):null}};import U from"fs";import M from"mime-types";var $=async(i,t)=>{let e=J.matchHandler(i);if(!e)return console.error("No handler found for input"),console.log("INPUT",JSON.stringify(i)),{statusCode:400,body:"Input not recognized"};let n={"Access-Control-Allow-Origin":"*"};if(e.method.toLowerCase()==="options"){let o=e.headers;return n={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":o["access-control-request-method"],"Access-Control-Allow-Headers":o["access-control-request-headers"]},console.log("CORS request service"),{statusCode:200,headers:n}}let s=e.path;if(s[0]==="docs"){let o,a;if(s.length>1){o=s.slice(1).join("/");let d=e.format;d?(o+="."+d,a=M.lookup(o)||"application/octet-stream"):a="application/octet-stream"}else o="index.html",a="text/html";o=process.cwd()+"/node_modules/redleaf-ishell/swagger/"+o;let c=U.readFileSync(o);return console.log("Docs file",o,c.length),{statusCode:200,headers:{...n,"Content-Type":a,"Access-Control-Allow-Origin":"*","Content-Source":"static"},body:c.toString()}}let r={...e.headers,_handler_type:e.type};try{process.env.AWS_LOG_IO==="true"?console.log("INPUT",JSON.stringify(i)):console.log(e.shortInputLog(i));let o=await t.execute(s,e.params,e.method,e.payload,r);return e.processResponse(o,n)}catch(o){if(console.log("INPUT",JSON.stringify(i)),o instanceof y)return{statusCode:o.statusCode,headers:n,body:JSON.stringify({error:o.message,type:o.name})};let a=o.message,d=e.params.stacktrace!=="false"?o.stack?.split(`
|
|
2
|
+
`).slice(1).map(u=>u.trim()):void 0;return{statusCode:500,headers:n,body:JSON.stringify({error:a,stack:d})||"Internal Application Error"}}};var N=class extends w{constructor(t,e="unknown"){super({simulate:{method:"post",summary:"Simulate a raw lambda trigger",description:"Simulate a lambda trigger for testing purposes",body:{properties:{}},action:async(n,s)=>{let r=await $(s,t);return new g(r)},tag:"Debug"}},"Lambda Simulator",e)}};import F from"cors";import K from"dotenv";import E from"express";import B from"path";var D=i=>{let t=E();t.use(E.json()),t.use(F()),t.use("/docs",E.static(B.join(process.cwd(),"node_modules/redleaf-ishell/swagger")));let e=async(r,o)=>{let a=r.path;a.startsWith("/")&&(a=a.slice(1)),a.endsWith("/")&&(a=a.slice(0,-1));let c=a.lastIndexOf(".");c>0&&(a=a.slice(0,c));let d=await n(a.split("/"),r.query,r.method,r.headers,r.body);o.type(d.contentType).status(d.returnCode).send(d.content)},n=async(r,o,a,c,d=null)=>{let u={...c,_handler_type:"express"};try{if(d!==null){let p;try{p=JSON.parse(d)}catch{p=d}return await i.execute(r,o,a,p,u)}else return await i.execute(r,o,a,void 0,u)}catch(p){let O=p.stack?.split(`
|
|
3
|
+
`).slice(1).map(k=>k.trim());return p instanceof y?new g({status:"error",type:p.name,message:p.message}).errorCode(p.statusCode):new g({status:"error",error:p.message,stack:O}).errorCode(500)}};t.get("/{*path}",(r,o)=>{e(r,o)}),t.post("/{*path}",(r,o)=>{e(r,o)}),t.put("/{*path}",(r,o)=>{e(r,o)}),t.patch("/{*path}",(r,o)=>{e(r,o)}),t.delete("/{*path}",(r,o)=>{e(r,o)}),K.config();let s=parseInt(process.env.PORT||"3001",10);return new Promise((r,o)=>{let a=t.listen(s,()=>{let c=`http://localhost:${s}/`;console.log(`Express server running on ${c}`);for(let[d,u]of Object.entries(i.schema))u.api&&console.log(`For ${u.tag} API go to ${c}docs/?root=${d}`);r(a)});a.on("error",o)})};var L=class extends w{constructor(){super({v1:{api:!0,toplevel:!0,tag:"V1",action:()=>Promise.resolve(new q)}}),this.addLambdaSimulator(async()=>new N(this))}},q=class extends w{constructor(){super({foo:{method:"get",description:"API to control data sources (e.g. Google Sheets, S3) and retrieve data from them",action:async()=>new g({message:"Hello World!"})}})}};console.log("starting local server...");var W=new L,Wt=await D(W);await H(W);
|
package/localCLI.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{b as a}from"./chunk-4WZAN36M.js";export{a as localCLI};
|
package/localServer.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var v=Object.create;var m=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var E=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},y=(e,t,s,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of I(t))!A.call(e,p)&&p!==s&&m(e,p,{get:()=>t[p],enumerable:!(u=C(t,p))||u.enumerable});return e};var x=(e,t,s)=>(s=e!=null?v(R(e)):{},y(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),N=e=>y(m({},"__esModule",{value:!0}),e);var $={};E($,{localServer:()=>O});module.exports=N($);var w=x(require("cors"),1),k=x(require("dotenv"),1),h=x(require("express"),1),j=x(require("path"),1);var g=class extends Error{#t;#e;get statusCode(){return this.#t}get name(){return this.#e}constructor(t,s,u){super(s),this.#e=t,this.#t=u}};var f=class{#t;#e;#r=200;get content(){return this.#t}get contentType(){return this.#e}get returnCode(){return this.#r}constructor(t,s){this.#t=t,this.#e=s}errorCode(t){return this.#r=t,this}},l=class extends f{constructor(t){super(t,"application/json")}};var O=e=>{let t=(0,h.default)();t.use(h.default.json()),t.use((0,w.default)()),t.use("/docs",h.default.static(j.default.join(process.cwd(),"node_modules/redleaf-ishell/swagger")));let s=async(r,n)=>{let o=r.path;o.startsWith("/")&&(o=o.slice(1)),o.endsWith("/")&&(o=o.slice(0,-1));let a=o.lastIndexOf(".");a>0&&(o=o.slice(0,a));let i=await u(o.split("/"),r.query,r.method,r.headers,r.body);n.type(i.contentType).status(i.returnCode).send(i.content)},u=async(r,n,o,a,i=null)=>{let d={...a,_handler_type:"express"};try{if(i!==null){let c;try{c=JSON.parse(i)}catch{c=i}return await e.execute(r,n,o,c,d)}else return await e.execute(r,n,o,void 0,d)}catch(c){let P=c.stack?.split(`
|
|
2
|
+
`).slice(1).map(b=>b.trim());return c instanceof g?new l({status:"error",type:c.name,message:c.message}).errorCode(c.statusCode):new l({status:"error",error:c.message,stack:P}).errorCode(500)}};t.get("/{*path}",(r,n)=>{s(r,n)}),t.post("/{*path}",(r,n)=>{s(r,n)}),t.put("/{*path}",(r,n)=>{s(r,n)}),t.patch("/{*path}",(r,n)=>{s(r,n)}),t.delete("/{*path}",(r,n)=>{s(r,n)}),k.default.config();let p=parseInt(process.env.PORT||"3001",10);return new Promise((r,n)=>{let o=t.listen(p,()=>{let a=`http://localhost:${p}/`;console.log(`Express server running on ${a}`);for(let[i,d]of Object.entries(e.schema))d.api&&console.log(`For ${d.tag} API go to ${a}docs/?root=${i}`);r(o)});o.on("error",n)})};0&&(module.exports={localServer});
|
package/localServer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a}from"./chunk-RO2W6WB2.js";import"./chunk-S5BWAMGC.js";import"./chunk-S3PQMJO4.js";export{a as localServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var g=(t,n)=>{for(var s in n)i(t,s,{get:n[s],enumerable:!0})},y=(t,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of u(n))!c.call(t,r)&&r!==s&&i(t,r,{get:()=>n[r],enumerable:!(o=a(n,r))||o.enumerable});return t};var d=t=>y(i({},"__esModule",{value:!0}),t);var h={};g(h,{NotificationChannel:()=>l});module.exports=d(h);var l=class{#n;get url(){return this.#n}constructor(n=null){this.#n=n}async notify(n,s=null){let o;try{o=JSON.stringify(n)}catch{o=String(n)}let r={text:o};s&&(r.thread={threadKey:s});try{return{status:"sent",response:await fetch(this.#n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}}catch(e){return console.error("Failed to send notification",e),{status:"not_sent",reason:e.message}}}};0&&(module.exports={NotificationChannel});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=class{#n;get url(){return this.#n}constructor(n=null){this.#n=n}async notify(n,s=null){let t;try{t=JSON.stringify(n)}catch{t=String(n)}let o={text:t};s&&(o.thread={threadKey:s});try{return{status:"sent",response:await fetch(this.#n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}}catch(r){return console.error("Failed to send notification",r),{status:"not_sent",reason:r.message}}}};export{e as NotificationChannel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var S=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},u=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of p(n))!m.call(t,i)&&i!==e&&o(t,i,{get:()=>n[i],enumerable:!(s=a(n,i))||s.enumerable});return t};var N=t=>u(o({},"__esModule",{value:!0}),t);var g={};S(g,{SNSPublisher:()=>c});module.exports=N(g);var r=require("@aws-sdk/client-sns"),l=require("@aws-sdk/credential-providers"),c=class{#n;get topic(){return this.#n}#t;get client(){return this.#t}constructor(n=null){this.#n=(process.env.SNS_ARN_PREFIX??"")+(n??"");let e=!!process.env.AWS_LAMBDA_FUNCTION_NAME,s={region:process.env.AWS_REGION};e||(s.credentials=(0,l.fromIni)({profile:process.env.AWS_PROFILE})),this.#t=new r.SNSClient(s)}async publish(n){let e=new r.PublishCommand({TopicArn:this.#n,Message:JSON.stringify(n)});return await this.#t.send(e)}};0&&(module.exports={SNSPublisher});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{PublishCommand as i,SNSClient as r}from"@aws-sdk/client-sns";import{fromIni as o}from"@aws-sdk/credential-providers";var s=class{#n;get topic(){return this.#n}#t;get client(){return this.#t}constructor(n=null){this.#n=(process.env.SNS_ARN_PREFIX??"")+(n??"");let t=!!process.env.AWS_LAMBDA_FUNCTION_NAME,e={region:process.env.AWS_REGION};t||(e.credentials=o({profile:process.env.AWS_PROFILE})),this.#t=new r(e)}async publish(n){let t=new i({TopicArn:this.#n,Message:JSON.stringify(n)});return await this.#t.send(t)}};export{s as SNSPublisher};
|
package/package.json
CHANGED
package/response.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var n in t)i(r,n,{get:t[n],enumerable:!0})},j=(r,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of l(t))!y.call(r,o)&&o!==n&&i(r,o,{get:()=>t[o],enumerable:!(c=h(t,o))||c.enumerable});return r};var k=r=>j(i({},"__esModule",{value:!0}),r);var m={};f(m,{ResponseCSV:()=>p,ResponseHTML:()=>g,ResponseJSON:()=>u,ResponseJSON2CSV:()=>x,ResponseText:()=>d,ResponseXML:()=>a});module.exports=k(m);var s=class{#t;#r;#n=200;get content(){return this.#t}get contentType(){return this.#r}get returnCode(){return this.#n}constructor(t,n){this.#t=t,this.#r=n}errorCode(t){return this.#n=t,this}},u=class extends s{constructor(t){super(t,"application/json")}},p=class extends s{constructor(t){super(t,"text/csv")}},x=class r extends s{static json2CSV(t){if(!Array.isArray(t)||t.length===0)return"";let n=t,c=[Object.keys(n[0]).join(",")];for(let o of n)c.push(Object.values(o).map(e=>typeof e=="string"?e.includes(",")||e.includes('"')?`"${e.replace(/"/g,'""')}"`:e:(typeof e=="number"||!isNaN(Number(e)),e)).join(","));return c.join(`
|
|
2
|
+
`)}constructor(t){super(r.json2CSV(t),"text/csv")}},d=class extends s{constructor(t){super(t,"text/plain")}},g=class extends s{constructor(t){super(t,"text/html")}},a=class extends s{constructor(t){super(t,"text/xml")}};0&&(module.exports={ResponseCSV,ResponseHTML,ResponseJSON,ResponseJSON2CSV,ResponseText,ResponseXML});
|
package/response.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a,b,c,d,e,f}from"./chunk-S3PQMJO4.js";export{b as ResponseCSV,e as ResponseHTML,a as ResponseJSON,c as ResponseJSON2CSV,d as ResponseText,f as ResponseXML};
|