exlo 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +11 -0
- package/dist/config.d.ts +35 -0
- package/dist/defineConfig.d.ts +125 -0
- package/dist/defineConfig.mjs +1 -0
- package/dist/lib/esbuild/buildOptimizer.d.ts +9 -0
- package/dist/lib/esbuild/knownCjs.d.ts +1 -0
- package/dist/lib/esbuild/mergeEsbuildConfig.d.ts +2 -0
- package/dist/lib/esbuild/parseCustomEsbuild.d.ts +2 -0
- package/dist/lib/parseEvents/ddbStream.d.ts +17 -0
- package/dist/lib/parseEvents/endpoints.d.ts +29 -0
- package/dist/lib/parseEvents/funcUrl.d.ts +2 -0
- package/dist/lib/parseEvents/index.d.ts +16 -0
- package/dist/lib/parseEvents/sqs.d.ts +11 -0
- package/dist/lib/runtime/bufferedStreamResponse.d.ts +24 -0
- package/dist/lib/runtime/callDestinations.d.ts +12 -0
- package/dist/lib/runtime/eventSourceMapping/base.d.ts +66 -0
- package/dist/lib/runtime/eventSourceMapping/base.mjs +1 -0
- package/dist/lib/runtime/eventSourceMapping/errors/eventSourceMappingError.d.ts +5 -0
- package/dist/lib/runtime/eventSourceMapping/esmBatch.d.ts +15 -0
- package/dist/lib/runtime/eventSourceMapping/filter/compileFilterPolicy.d.ts +12 -0
- package/dist/lib/runtime/eventSourceMapping/filter/compileFilterPolicy.test.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/filter/compileWildcard.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/filter/compileWildcard.test.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/filter/expandDotPathsWithStrictConflicts.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/filter/expandDotPathsWithStrictConflicts.test.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/filter/matchesFilterPolicy.d.ts +2 -0
- package/dist/lib/runtime/eventSourceMapping/filter/matchesFilterPolicy.test.d.ts +1 -0
- package/dist/lib/runtime/eventSourceMapping/sqs.d.ts +19 -0
- package/dist/lib/runtime/eventSourceMapping/utils.d.ts +6 -0
- package/dist/lib/runtime/rapidApi.d.ts +97 -0
- package/dist/lib/runtime/runners/index.d.ts +25 -0
- package/dist/lib/runtime/runners/node/awslambda.d.ts +11 -0
- package/dist/lib/runtime/runners/node/index.d.ts +1 -0
- package/dist/lib/runtime/runners/node/index.js +19 -0
- package/dist/lib/runtime/runners/node/runner.d.ts +34 -0
- package/dist/lib/runtime/runners/node/streamResponse.d.ts +90 -0
- package/dist/lib/runtime/runners/node/utils.d.ts +39 -0
- package/dist/lib/runtime/runners/python/runner.d.ts +48 -0
- package/dist/lib/runtime/runners/ruby/runner.d.ts +43 -0
- package/dist/lib/server/daemon.d.ts +27 -0
- package/dist/lib/server/handlers.d.ts +13 -0
- package/dist/lib/services/index.d.ts +10 -0
- package/dist/lib/utils/amazonifyHeaders.d.ts +3 -0
- package/dist/lib/utils/colorize.d.ts +12 -0
- package/dist/lib/utils/getPackageInstalledDir.d.ts +1 -0
- package/dist/lib/utils/readDefineConfig.d.ts +6 -0
- package/dist/main.d.ts +80 -0
- package/dist/plugins/lambda/events/alb.d.ts +44 -0
- package/dist/plugins/lambda/events/apg.d.ts +111 -0
- package/dist/plugins/lambda/events/common.d.ts +114 -0
- package/dist/plugins/lambda/functionUrlInvoke.d.ts +3 -0
- package/dist/plugins/lambda/htmlStatusMsg.d.ts +4 -0
- package/dist/plugins/lambda/index.d.ts +3 -0
- package/dist/plugins/lambda/invokeRequests.d.ts +3 -0
- package/dist/plugins/lambda/lambdaApi.d.ts +6 -0
- package/dist/plugins/lambda/responseStreamingInvoke.d.ts +3 -0
- package/dist/plugins/lambda/streamEncoder.d.ts +19 -0
- package/dist/plugins/lambda/utils.d.ts +29 -0
- package/dist/plugins/restApi/compileAjvSchema.d.ts +1 -0
- package/dist/plugins/restApi/errors.d.ts +32 -0
- package/dist/plugins/restApi/findRequestResource.d.ts +9 -0
- package/dist/plugins/restApi/findRequestResource.test.d.ts +1 -0
- package/dist/plugins/restApi/index.d.ts +8 -0
- package/dist/plugins/restApi/index.mjs +1 -0
- package/dist/plugins/restApi/resourcesFromOpenApi.d.ts +4 -0
- package/dist/plugins/restApi/restApiServer.d.ts +265 -0
- package/dist/plugins/restApi/restApiServer.test.d.ts +1 -0
- package/dist/plugins/restApi/utils.d.ts +9 -0
- package/dist/plugins/s3/actions/AbortMultipartUploadAction.d.ts +10 -0
- package/dist/plugins/s3/actions/CompleteMultipartUploadAction.d.ts +15 -0
- package/dist/plugins/s3/actions/CopyObjectAction.d.ts +24 -0
- package/dist/plugins/s3/actions/CreateBucketAction.d.ts +8 -0
- package/dist/plugins/s3/actions/CreateMultipartUploadAction.d.ts +13 -0
- package/dist/plugins/s3/actions/DeleteBucketAction.d.ts +8 -0
- package/dist/plugins/s3/actions/DeleteBucketPolicyAction.d.ts +8 -0
- package/dist/plugins/s3/actions/DeleteBucketTaggingAction.d.ts +8 -0
- package/dist/plugins/s3/actions/DeleteObjectAction.d.ts +10 -0
- package/dist/plugins/s3/actions/DeleteObjectTaggingAction.d.ts +9 -0
- package/dist/plugins/s3/actions/DeleteObjectsAction.d.ts +8 -0
- package/dist/plugins/s3/actions/GetBucketAclAction.d.ts +8 -0
- package/dist/plugins/s3/actions/GetBucketPolicy.d.ts +8 -0
- package/dist/plugins/s3/actions/GetBucketTaggingAction.d.ts +8 -0
- package/dist/plugins/s3/actions/GetObjectAclAction.d.ts +8 -0
- package/dist/plugins/s3/actions/GetObjectAction.d.ts +30 -0
- package/dist/plugins/s3/actions/GetObjectTaggingAction.d.ts +10 -0
- package/dist/plugins/s3/actions/HeadBucketAction.d.ts +8 -0
- package/dist/plugins/s3/actions/HeadObjectAction.d.ts +18 -0
- package/dist/plugins/s3/actions/ListBucketsAction.d.ts +15 -0
- package/dist/plugins/s3/actions/ListMultipartUploadsAction.d.ts +19 -0
- package/dist/plugins/s3/actions/ListObjectsAction.d.ts +31 -0
- package/dist/plugins/s3/actions/ListPartsAction.d.ts +14 -0
- package/dist/plugins/s3/actions/PutBucketAclAction.d.ts +11 -0
- package/dist/plugins/s3/actions/PutBucketCorsAction.d.ts +8 -0
- package/dist/plugins/s3/actions/PutBucketPolicyAction.d.ts +9 -0
- package/dist/plugins/s3/actions/PutBucketTaggingAction.d.ts +8 -0
- package/dist/plugins/s3/actions/PutObjectAclAction.d.ts +8 -0
- package/dist/plugins/s3/actions/PutObjectAction.d.ts +22 -0
- package/dist/plugins/s3/actions/PutObjectTaggingAction.d.ts +9 -0
- package/dist/plugins/s3/actions/UnknownAction.d.ts +7 -0
- package/dist/plugins/s3/actions/UploadPartAction.d.ts +12 -0
- package/dist/plugins/s3/actions/localAction.d.ts +92 -0
- package/dist/plugins/s3/calulcateETag.d.ts +1 -0
- package/dist/plugins/s3/commons/constants.d.ts +6 -0
- package/dist/plugins/s3/commons/utils.d.ts +3 -0
- package/dist/plugins/s3/errors/notFound.d.ts +8 -0
- package/dist/plugins/s3/errors/s3Error.d.ts +65 -0
- package/dist/plugins/s3/getLocalStoragePath.d.ts +1 -0
- package/dist/plugins/s3/index.d.ts +32 -0
- package/dist/plugins/s3/index.mjs +97 -0
- package/dist/plugins/s3/lib/createS3Server.d.ts +38 -0
- package/dist/plugins/s3/parsers/parseDeleteRequest.d.ts +10 -0
- package/dist/plugins/s3/parsers/parseGetRequest.d.ts +14 -0
- package/dist/plugins/s3/parsers/parseHeadRequest.d.ts +5 -0
- package/dist/plugins/s3/parsers/parsePostRequest.d.ts +7 -0
- package/dist/plugins/s3/parsers/parsePutRequest.d.ts +14 -0
- package/dist/plugins/s3/triggerEvent.d.ts +12 -0
- package/dist/plugins/sns/errors.d.ts +26 -0
- package/dist/plugins/sns/filter.d.ts +1 -0
- package/dist/plugins/sns/filter.test.d.ts +1 -0
- package/dist/plugins/sns/index.d.ts +23 -0
- package/dist/plugins/sns/index.mjs +106 -0
- package/dist/plugins/sns/parsers/parseCreateTopic.d.ts +2 -0
- package/dist/plugins/sns/parsers/parseMessage.d.ts +18 -0
- package/dist/plugins/sns/parsers/parsePublishMessage.d.ts +6 -0
- package/dist/plugins/sns/parsers/parsePublishMessageBatch.d.ts +9 -0
- package/dist/plugins/sns/parsers/parseSubscribe.d.ts +17 -0
- package/dist/plugins/sns/parsers/parseSubscriptionArn.d.ts +6 -0
- package/dist/plugins/sns/parsers/parseTopicArn.d.ts +4 -0
- package/dist/plugins/sns/server.d.ts +36 -0
- package/dist/plugins/sns/server.test.d.ts +1 -0
- package/dist/plugins/sns/subscriber/index.d.ts +61 -0
- package/dist/plugins/sns/subscriber/validateConfig.d.ts +0 -0
- package/dist/plugins/sns/topic.d.ts +91 -0
- package/dist/plugins/sns/utils.d.ts +20 -0
- package/dist/plugins/sns/validateFilterPolicy.d.ts +19 -0
- package/dist/plugins/sns/validateFilterPolicy.test.d.ts +1 -0
- package/dist/plugins/sqs/index.d.ts +16 -0
- package/dist/plugins/sqs/index.mjs +1 -0
- package/dist/plugins/sqs/types.d.ts +11 -0
- package/dist/plugins/sqs/utils.d.ts +7 -0
- package/dist/plugins/vitest/coverage.d.ts +6 -0
- package/dist/plugins/vitest/index.d.ts +29 -0
- package/dist/plugins/vitest/index.mjs +1 -0
- package/dist/standalone.d.ts +17 -0
- package/dist/standalone.js +13 -0
- package/dist/standalone.mjs +13 -0
- package/dist/standalone_types.d.ts +190 -0
- package/package.json +119 -0
- package/src/lib/runtime/runners/python/index.py +105 -0
- package/src/lib/runtime/runners/ruby/index.rb +67 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StreamableHandler } from "./streamResponse";
|
|
2
|
+
import type { IHttpResponseStream } from "./streamResponse";
|
|
3
|
+
type HandlerMetadata = {
|
|
4
|
+
highWaterMark?: number;
|
|
5
|
+
};
|
|
6
|
+
export interface awslambda {
|
|
7
|
+
streamifyResponse: (handler: StreamableHandler, options?: HandlerMetadata) => Function;
|
|
8
|
+
HttpResponseStream: IHttpResponseStream;
|
|
9
|
+
}
|
|
10
|
+
export declare const awslambda: awslambda;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";var Q=Object.create;var O=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var X=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of K(e))!z.call(t,o)&&o!==r&&O(t,o,{get:()=>e[o],enumerable:!(n=J(e,o))||n.enumerable});return t};var P=(t,e,r)=>(r=t!=null?Q(Y(t)):{},X(e||!t||!t.__esModule?O(r,"default",{value:t,enumerable:!0}):r,t));var L=require("node:util"),i=require("node:worker_threads");var _=require("node:stream"),x=class extends _.Writable{#e=!1;#t;#n=new TypeError('Invalid value "undefined" for header "Content-Type"');_onBeforeFirstWrite;constructor(e){super({highWaterMark:e.highWaterMark,write:e.write}),this.#t=this.write.bind(this),this.write=(n,o,l)=>{n=this.#o(n),!this.#e&&typeof this._onBeforeFirstWrite=="function"&&this._onBeforeFirstWrite(m=>this.#t(m));let a=this.#t(n,o,l);return this.#e||(this.#e=!0),a};let r=this.end.bind(this);this.end=(...n)=>{if(n.length){let[o]=n;o&&typeof o!="function"?(this.write(o),r()):r(...n)}else r(...n)}}#o=e=>(typeof e!="string"&&!Buffer.isBuffer(e)&&e?.constructor!==Uint8Array&&(e=JSON.stringify(e)),e);setContentType=e=>{if(!e)throw this.#n;this.emit("ct",e)}},v=class{static from=(e,r)=>{let n=JSON.stringify(r);return e._onBeforeFirstWrite=o=>{e.setContentType("application/vnd.awslambda.http-integration-response"),o(n),o(new Uint8Array(8))},e}};var $={streamifyResponse:function(e,r){return e.stream=!0,e.streamOpt=r,e},HttpResponseStream:v};var A=P(require("path")),M=require("util"),D=require("async_hooks"),B=process.cwd(),Z=`${B}/`,H="/dist/lambda/router.",F=B.split(A.default.sep).filter(Boolean)[0],C=new RegExp(`\\((/${F}|${F}).*(\\d+):(\\d+)`),ee=clearTimeout.bind(clearTimeout),{AWS_LAMBDA_FUNCTION_NAME:U}=process.env,te=t=>{let e=t.match(/{[\w\W]*}/);if(e)return`${t.slice(0,e.index+1)}
|
|
2
|
+
\x1B[33m try {\x1B[0m
|
|
3
|
+
${t.slice(e.index+1,-1).trim()}
|
|
4
|
+
\x1B[33m } catch (error) {\x1B[0m
|
|
5
|
+
\x1B[35m // handle the error\x1B[0m
|
|
6
|
+
\x1B[33m }\x1B[0m
|
|
7
|
+
}`},R=t=>{let e={errorType:"string",errorMessage:"",trace:[]};if(t instanceof Error)e.errorType=t.name,e.errorMessage=t.message,typeof t.stack=="string"&&(e.trace=t.stack.split(`
|
|
8
|
+
`));else{e.errorType=typeof t;try{e.errorMessage=t.toString()}catch{}}return e},ne=t=>{let e="";try{let r=C.exec(t.stack.split("at")[2])?.[0];typeof r=="string"&&(e=r.slice(1))}catch{}return e},G=()=>{let t={assert:console.assert.bind(console.assert),clear:console.clear.bind(console.clear),count:console.count.bind(console.count),countReset:console.countReset.bind(console.countReset),debug:console.debug.bind(console.debug),dir:console.dir.bind(console.dir),dirxml:console.dirxml.bind(console.dirxml),error:console.error.bind(console.error),group:console.group.bind(console.group),groupCollapsed:console.groupCollapsed.bind(console.groupCollapsed),groupEnd:console.groupEnd.bind(console.groupEnd),info:console.info.bind(console.info),log:console.log.bind(console.log),table:console.table.bind(console.table),time:console.time.bind(console.time),timeEnd:console.timeEnd.bind(console.timeEnd),timeLog:console.timeLog.bind(console.timeLog),timeStamp:console.timeStamp.bind(console.timeStamp),trace:console.trace.bind(console.trace),warn:console.warn.bind(console.warn)};console=new Proxy(console,{get(e,r){return typeof e[r]=="function"?(...n)=>{let o={};Error.captureStackTrace(o);let l=ne(o);process.stdout.write(`\x1B[90m${new Date().toISOString()} ${r.toUpperCase()} ${U} ${l?.replace(Z,"")}\x1B[0m
|
|
9
|
+
`),r=="log"?t.log(...n.map(a=>(0,M.inspect)(a,{colors:!0}))):t[r](...n)}:t[r]}})},V=t=>{let e="",r=0;return t.slice().reverse().filter(n=>n&&!n.includes(__dirname)&&!n.includes(H)).forEach(n=>{let o=C.exec(n)?.[0];o&&(e+=`${o}
|
|
10
|
+
`.slice(1),r++,e+=" ".repeat(r))}),e},g=class t extends Map{static EMPTY_ARGS=[];static IGNORE=["PROMISE","RANDOMBYTESREQUEST","PerformanceObserver","TIMERWRAP"];onEmpty;requestId;callbackWaitsForEmptyEventLoop=!0;async=!1;hook;static context={};static parentPort;static logTimeoutPossibleCause=e=>{let r=this.context[e];if(!r.timeout)return;let n=[...r.promises.values()].reduce((o,l)=>(l.took&&(l.stack=l.stack.reverse().map(a=>{let m=C.exec(a)?.[0];if(m)return m.slice(1)}).filter(a=>a&&!a.includes(__dirname)&&!a.includes(H)),l.stack.length&&(delete l.start,o.push(l))),o),[]);if(n=n.filter((o,l)=>{if(o.took>.01)return!o.stack.every(a=>n.find((m,d)=>l!=d&&(m.took>o.took||o.stack.length<m.stack.length)&&m.stack.includes(a)))}),n.length){let o=(0,M.inspect)(n,{colors:!0});process.stdout.write(`'${U}' Timeout possible cause:
|
|
11
|
+
${o}
|
|
12
|
+
`)}};constructor(e){super(),this.requestId=e,t.context[e]={timers:new Map,promises:new Map}}static restoreContext=()=>{Object.values(this.context).forEach(({timers:e})=>{let r=[...e.entries()];r.length&&process.stdout.write(`\x1B[31mWarning! Restoring context from previous invokation...
|
|
13
|
+
This may lead to data leak.\x1B[0m
|
|
14
|
+
`),r.forEach(([n,o])=>{o.interval?setInterval(o._onTimeout,o.interval):setTimeout(o._onTimeout,o.timerValue),e.delete(n)})})};storeContextTimers=()=>{[...this.entries()].forEach(([e,r])=>{if(r.type!="Timeout")return;let{_idleTimeout:n,_idleStart:o,_onTimeout:l,_repeat:a,_destroyed:m}=r.resource,d=n-o;!m&&(d>-1||a)&&t.context[this.requestId].timers.set(e,{timerValue:d,_onTimeout:l,interval:a}),clearTimeout(r.resource)})};isEmpty=()=>!([...this.values()].filter(r=>!(typeof r.resource.hasRef=="function"&&!r.resource.hasRef())).length>0);add=(e,r,n,o)=>{let l={};Error.captureStackTrace(l);let a=l.stack.split(`
|
|
15
|
+
`).slice(7);if(r=="PROMISE"&&t.context[this.requestId].promises.set(e,{stack:a,start:Date.now()}),t.IGNORE.includes(r))return this;if(r=="Timeout"){let m=o._repeat?"setInterval":"setTimeout",d=o._onTimeout.toString(),p=o._onTimeout.bind(o._onTimeout),S=o._timerArgs??t.EMPTY_ARGS;o._onTimeout=()=>{try{p(...S)}catch(T){let c=R(T),E=te(d);t.parentPort.postMessage({channel:"uncaught",type:m,data:{error:c,solution:E}})}}}return this.set(e,{resource:o,triggerAsyncId:n,type:r,stack:a})};destroy=e=>{this.delete(e)&&this.isEmpty()&&this.onEmpty&&this.onEmpty()};resolve=e=>{let r=t.context[this.requestId];if(r){let n=r.promises.get(e);n?.start&&(n.took=(Date.now()-n.start)/1e3)}};enable=()=>{t.restoreContext();let e=this,r=function(o){ee(o),e.destroy(Number(o))};global.clearTimeout=r,global.clearInterval=r,this.hook=(0,D.createHook)({init:this.add,destroy:this.destroy,promiseResolve:this.resolve}).enable()};disable=()=>{this.hook?.disable(),delete this.hook}};globalThis.awslambda=$;var b={RED:t=>{},BLUE:t=>{},PINK:t=>{}},h,oe=new Error("Unable to stringify response body");i.workerData.debug&&(b.RED=t=>{process.stdout.write(`\x1B[31m${t}\x1B[0m
|
|
16
|
+
`)},b.BLUE=t=>{process.stdout.write(`\x1B[34m${t}\x1B[0m
|
|
17
|
+
`)},b.PINK=t=>{process.stdout.write(`\x1B[95m${t}\x1B[0m
|
|
18
|
+
`)},G());g.parentPort=i.parentPort;var y=(t,e)=>{let r=R(e);i.parentPort.postMessage({channel:"fail",data:r,awsRequestId:t})},re=t=>{let e=R(t);i.parentPort.postMessage({channel:"fatal",data:e})},q=()=>{},W=(t,e,r)=>{try{JSON.stringify(r),i.parentPort.postMessage({channel:t,data:r,awsRequestId:e})}catch{y(e,oe)}finally{q()}};process.exit=t=>{process.stdout.write(`\x1B[31musage of process.exit() will throw Runtime error in AWS Lambda\x1B[0m
|
|
19
|
+
`)};process.on("unhandledRejection",t=>{process.stdout.write((0,L.inspect)(t))});process.on("uncaughtException",t=>{process.stdout.write((0,L.inspect)(t))});var se=async t=>{let{channel:e,data:r,awsRequestId:n}=t;if(e=="import"){let o;try{o=await import(`file://${i.workerData.esOutputPath}?version=${Date.now()}`),process.env.NODE_V8_COVERAGE&&(q=(await import("node:v8")).takeCoverage)}catch(l){re(l);return}if(i.workerData.handlerName=="default"&&typeof o.default=="object"&&typeof o.default.default=="function"?h=o.default.default:h=o[i.workerData.handlerName],typeof h!="function")throw new Error(`${i.workerData.name} > ${i.workerData.handlerName} is not a function`);i.parentPort.postMessage({channel:"import"})}else if(e=="complete"){let o=g.context[n];typeof t.timeout=="boolean"&&(o.timeout=!0)}else if(e=="exec"){let{event:o,clientContext:l}=r,a=!1,m=i.workerData.timeout*1e3,d,p=()=>{a=!0},S=Date.now(),T=()=>Math.max(m-(Date.now()-S),0),c=new g(n),E={functionVersion:"$LATEST",functionName:i.workerData.name,memoryLimitInMB:String(i.workerData.memorySize),logGroupName:`/aws/lambda/${i.workerData.name}`,logStreamName:`${new Date().toLocaleDateString()}[$LATEST]${n.replace(/-/g,"")}`,clientContext:l,identity:void 0,invokedFunctionArn:`arn:aws:lambda:eu-west-1:00000000000:function:${i.workerData.name}`,awsRequestId:n,getRemainingTimeInMillis:T};if(typeof h.stream=="boolean"){let w=(s,u,k)=>{i.parentPort.postMessage({channel:"stream",data:s,awsRequestId:n,type:"write",encoding:u}),k()};d=new x({highWaterMark:h.streamOpt?.highWaterMark,write:w}),d.on("close",()=>{a||(p(),i.parentPort.postMessage({channel:"stream",awsRequestId:n,type:"end"}))}),d.on("error",s=>{a||(p(),b.RED(s),y(n,s))}),d.on("ct",s=>i.parentPort.postMessage({channel:"stream",data:s,awsRequestId:n,type:"ct"}));let f={get callbackWaitsForEmptyEventLoop(){return c.callbackWaitsForEmptyEventLoop},set callbackWaitsForEmptyEventLoop(s){c.callbackWaitsForEmptyEventLoop=s},...E};typeof h(o,d,f)?.catch?.(s=>{d.destroy(),p(),b.RED(s),y(n,s)})?.then!="function"&&(p(),d.destroy(),y(n,new Error("Streaming does not support non-async handlers.")))}else{let w={get callbackWaitsForEmptyEventLoop(){return c.callbackWaitsForEmptyEventLoop},set callbackWaitsForEmptyEventLoop(s){c.callbackWaitsForEmptyEventLoop=s},...E,succeed:s=>{a||(p(),W("succeed",n,s))},fail:s=>{a||(p(),y(n,s))},done:function(s,u){a||(p(),s?y(n,s):W("done",n,u))}},f,I=(s,u)=>{f?b.RED("Invocation has already been reported as done. Cannot call complete more than once per invocation."):f={error:s,res:u}};try{c.enable();let s=h(o,w,I);if(s?.then?.(u=>{c.storeContextTimers(),g.logTimeoutPossibleCause(n),!(f||a)&&(p(),W("return",n,u),c.disable())})?.catch(u=>{p(),y(n,u),c.disable()}),c.async=typeof s?.then=="function",!c.async&&s&&b.RED("Synchronous handler 'return' value is ignored. Consider marking your handler as 'async' or use callback(error, returnValue)"),!a&&(!c.async||f)){let u=()=>{c.storeContextTimers(),c.disable(),f?w.done(f.error,f.res):(p(),W("return",n,null))};if(c.isEmpty())u();else if(!f||c.callbackWaitsForEmptyEventLoop){if(f&&c.callbackWaitsForEmptyEventLoop){b.BLUE("callbackWaitsForEmptyEventLoop...");let k=[...c.values()],j=k[k.length-1],N=V(j.stack);N&&(b.RED("Blocked by:"),b.PINK(N))}c.onEmpty=()=>{u()}}else u()}}catch(s){p(),y(n,s),c.disable()}}}};i.parentPort.on("message",se);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { Worker } from "node:worker_threads";
|
|
3
|
+
import type { Runner } from "../index";
|
|
4
|
+
export declare class NodeRunner extends EventEmitter implements Runner {
|
|
5
|
+
_worker?: Worker;
|
|
6
|
+
isMounted: boolean;
|
|
7
|
+
_isLoading: boolean;
|
|
8
|
+
invoke: (request: any) => Promise<any>;
|
|
9
|
+
mount: () => any;
|
|
10
|
+
unmount: () => any;
|
|
11
|
+
name: string;
|
|
12
|
+
timeout: number;
|
|
13
|
+
memorySize: number;
|
|
14
|
+
environment: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
handlerPath: string;
|
|
18
|
+
handlerName: string;
|
|
19
|
+
esOutputPath: string;
|
|
20
|
+
private hasFatalError;
|
|
21
|
+
constructor({ name, timeout, memorySize, environment, handlerPath, handlerName, esOutputPath, }: {
|
|
22
|
+
name: string;
|
|
23
|
+
handlerPath: string;
|
|
24
|
+
handlerName: string;
|
|
25
|
+
esOutputPath: string;
|
|
26
|
+
timeout: number;
|
|
27
|
+
memorySize: number;
|
|
28
|
+
environment: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
importHandler(): Promise<void>;
|
|
33
|
+
onComplete: (awsRequestId: string, timeout?: boolean) => void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Writable } from "node:stream";
|
|
2
|
+
import type { WritableOptions } from "node:stream";
|
|
3
|
+
interface IResponseStream {
|
|
4
|
+
cork: Writable["cork"];
|
|
5
|
+
/**
|
|
6
|
+
* Do not use. This may lead to unexcepted result in AWS Lambda Runtime.
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
destroy: Writable["destroy"];
|
|
10
|
+
end: Writable["end"];
|
|
11
|
+
uncork: Writable["uncork"];
|
|
12
|
+
write: Writable["write"];
|
|
13
|
+
addListener: Writable["addListener"];
|
|
14
|
+
emit: Writable["emit"];
|
|
15
|
+
eventNames: Writable["eventNames"];
|
|
16
|
+
getMaxListeners: Writable["getMaxListeners"];
|
|
17
|
+
listenerCount: Writable["listenerCount"];
|
|
18
|
+
listeners: Writable["listeners"];
|
|
19
|
+
off: Writable["off"];
|
|
20
|
+
on: Writable["on"];
|
|
21
|
+
once: Writable["once"];
|
|
22
|
+
prependListener: Writable["prependListener"];
|
|
23
|
+
prependOnceListener: Writable["prependOnceListener"];
|
|
24
|
+
rawListeners: Writable["rawListeners"];
|
|
25
|
+
removeAllListeners: Writable["removeAllListeners"];
|
|
26
|
+
removeListener: Writable["removeListener"];
|
|
27
|
+
setMaxListeners: Writable["setMaxListeners"];
|
|
28
|
+
/**
|
|
29
|
+
* @param {any} contentType must be a string or implement toString()
|
|
30
|
+
* @throws Error
|
|
31
|
+
*/
|
|
32
|
+
setContentType: (contentType: any) => void;
|
|
33
|
+
writable: boolean;
|
|
34
|
+
readonly writableEnded: boolean;
|
|
35
|
+
readonly writableFinished: boolean;
|
|
36
|
+
readonly writableHighWaterMark: number;
|
|
37
|
+
readonly writableLength: number;
|
|
38
|
+
readonly writableObjectMode: boolean;
|
|
39
|
+
readonly writableNeedDrain: boolean;
|
|
40
|
+
readonly writableCorked: number;
|
|
41
|
+
destroyed: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface IStreamableHandlerContext {
|
|
44
|
+
callbackwaitsforemptyeventloop: boolean;
|
|
45
|
+
functionVersion: string;
|
|
46
|
+
functionName: string;
|
|
47
|
+
memoryLimitInMB: string;
|
|
48
|
+
logGroupName: string;
|
|
49
|
+
logStreamName: string;
|
|
50
|
+
clientContext: any;
|
|
51
|
+
identity: any;
|
|
52
|
+
invokedFunctionArn: string;
|
|
53
|
+
awsRequestId: string;
|
|
54
|
+
getRemainingTimeInMillis: () => number;
|
|
55
|
+
}
|
|
56
|
+
export type StreamableHandler = (event: any, responseStream: IResponseStream, context?: IStreamableHandlerContext) => Promise<any | void>;
|
|
57
|
+
interface IMetadata {
|
|
58
|
+
statusCode?: number;
|
|
59
|
+
headers?: {
|
|
60
|
+
[key: string]: string;
|
|
61
|
+
};
|
|
62
|
+
cookies?: string[];
|
|
63
|
+
body?: string | Buffer;
|
|
64
|
+
isBase64Encoded?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare class ResponseStream extends Writable {
|
|
67
|
+
#private;
|
|
68
|
+
_onBeforeFirstWrite?: (write: Writable["write"]) => any;
|
|
69
|
+
constructor(opts: Partial<WritableOptions>);
|
|
70
|
+
setContentType: (contentType: any) => void;
|
|
71
|
+
}
|
|
72
|
+
export interface IHttpResponseStream {
|
|
73
|
+
/**
|
|
74
|
+
* @param {any} metadata http proxy integration response object.
|
|
75
|
+
*
|
|
76
|
+
* This could also be 'any' byte to be written before all write.() executions.
|
|
77
|
+
*
|
|
78
|
+
* Metadata will be wrapped into JSON.stringify().
|
|
79
|
+
*
|
|
80
|
+
* `{statusCode: 404, cookies: ["hello=world"]}`
|
|
81
|
+
*
|
|
82
|
+
*
|
|
83
|
+
* @throws Error
|
|
84
|
+
*/
|
|
85
|
+
from: (responseStream: IResponseStream, metadata: IMetadata) => IResponseStream;
|
|
86
|
+
}
|
|
87
|
+
export declare class HttpResponseStream {
|
|
88
|
+
static from: (responseStream: IResponseStream, metadata: IMetadata) => IResponseStream;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AsyncHook } from "async_hooks";
|
|
2
|
+
import type { MessagePort } from "worker_threads";
|
|
3
|
+
interface LambdaErrorResponse {
|
|
4
|
+
errorType?: string;
|
|
5
|
+
errorMessage: string;
|
|
6
|
+
trace?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const genResponsePayload: (err: any) => LambdaErrorResponse;
|
|
9
|
+
export declare const patchConsole: () => void;
|
|
10
|
+
export declare const formatStack: (_stack: string[]) => string;
|
|
11
|
+
interface IEventQueueContext {
|
|
12
|
+
[id: string]: {
|
|
13
|
+
timers: Map<number, any>;
|
|
14
|
+
promises: Map<number, any>;
|
|
15
|
+
timeout?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare class EventQueue extends Map {
|
|
19
|
+
private static readonly EMPTY_ARGS;
|
|
20
|
+
static IGNORE: string[];
|
|
21
|
+
onEmpty?: () => void;
|
|
22
|
+
requestId: string;
|
|
23
|
+
callbackWaitsForEmptyEventLoop: boolean;
|
|
24
|
+
async: boolean;
|
|
25
|
+
hook?: AsyncHook;
|
|
26
|
+
static context: IEventQueueContext;
|
|
27
|
+
static parentPort: MessagePort | null;
|
|
28
|
+
static logTimeoutPossibleCause: (requestId: string) => void;
|
|
29
|
+
constructor(requestId: string);
|
|
30
|
+
static restoreContext: () => void;
|
|
31
|
+
storeContextTimers: () => void;
|
|
32
|
+
isEmpty: () => boolean;
|
|
33
|
+
add: (asyncId: number, type: string, triggerAsyncId: number, resource: any) => this;
|
|
34
|
+
destroy: (asyncId: number) => void;
|
|
35
|
+
resolve: (asyncId: number) => void;
|
|
36
|
+
enable: () => void;
|
|
37
|
+
disable: () => void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
import type { FSWatcher } from "node:fs";
|
|
3
|
+
import type { Runner } from "../index";
|
|
4
|
+
export declare class PythonRunner implements Runner {
|
|
5
|
+
invoke: Runner["invoke"];
|
|
6
|
+
mount: Runner["mount"];
|
|
7
|
+
unmount: Runner["unmount"];
|
|
8
|
+
name: string;
|
|
9
|
+
timeout: number;
|
|
10
|
+
memorySize: number;
|
|
11
|
+
environment: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
handlerPath: string;
|
|
15
|
+
pyModulePath: string;
|
|
16
|
+
handlerDir: string;
|
|
17
|
+
handlerName: string;
|
|
18
|
+
handlerFileAbsolutePath: string;
|
|
19
|
+
runtime: string;
|
|
20
|
+
bin?: string;
|
|
21
|
+
python?: ChildProcessWithoutNullStreams;
|
|
22
|
+
isMounted: boolean;
|
|
23
|
+
watchers: FSWatcher[];
|
|
24
|
+
filesTime: Map<string, number>;
|
|
25
|
+
watcherListener: (event: "rename" | "change", filename: string | Buffer | null) => void;
|
|
26
|
+
emitRebuild: Function;
|
|
27
|
+
static wrapper: string;
|
|
28
|
+
static DELIMITER: string;
|
|
29
|
+
static DELIMITEREND: string;
|
|
30
|
+
static ERR_RESPONSE: string;
|
|
31
|
+
static WATCH: string;
|
|
32
|
+
static WATCHEND: string;
|
|
33
|
+
constructor({ name, timeout, memorySize, environment, handlerPath, handlerName, runtime, }: {
|
|
34
|
+
name: string;
|
|
35
|
+
handlerPath: string;
|
|
36
|
+
handlerName: string;
|
|
37
|
+
runtime: string;
|
|
38
|
+
timeout: number;
|
|
39
|
+
memorySize: number;
|
|
40
|
+
environment: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
}, emitRebuild: Function);
|
|
44
|
+
setWatchFiles: (data: string) => Promise<void>;
|
|
45
|
+
findPython(): string;
|
|
46
|
+
load: () => void;
|
|
47
|
+
onComplete: (awsRequestId: string) => void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
2
|
+
import type { FSWatcher } from "node:fs";
|
|
3
|
+
import type { Runner } from "../index";
|
|
4
|
+
export declare class RubyRunner implements Runner {
|
|
5
|
+
invoke: Runner["invoke"];
|
|
6
|
+
mount: Runner["mount"];
|
|
7
|
+
unmount: Runner["unmount"];
|
|
8
|
+
name: string;
|
|
9
|
+
timeout: number;
|
|
10
|
+
memorySize: number;
|
|
11
|
+
environment: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
handlerPath: string;
|
|
15
|
+
modulePath: string;
|
|
16
|
+
handlerDir: string;
|
|
17
|
+
handlerName: string;
|
|
18
|
+
runtime: string;
|
|
19
|
+
bin?: string;
|
|
20
|
+
ruby?: ChildProcessWithoutNullStreams;
|
|
21
|
+
isMounted: boolean;
|
|
22
|
+
emitRebuild: Function;
|
|
23
|
+
watcherListener: (event: "rename" | "change", filename: string | Buffer | null) => void;
|
|
24
|
+
watchers: FSWatcher[];
|
|
25
|
+
static wrapper: string;
|
|
26
|
+
static DELIMITER: string;
|
|
27
|
+
static ERR_RESPONSE: string;
|
|
28
|
+
static WATCH: string;
|
|
29
|
+
constructor({ name, timeout, memorySize, environment, handlerPath, handlerName, runtime, }: {
|
|
30
|
+
name: string;
|
|
31
|
+
handlerPath: string;
|
|
32
|
+
handlerName: string;
|
|
33
|
+
runtime: string;
|
|
34
|
+
timeout: number;
|
|
35
|
+
memorySize: number;
|
|
36
|
+
environment: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
};
|
|
39
|
+
}, emitRebuild: Function);
|
|
40
|
+
setWatchFiles: (data: string) => Promise<void>;
|
|
41
|
+
load: () => void;
|
|
42
|
+
onComplete: (awsRequestId: string) => void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Socket } from "node:net";
|
|
2
|
+
import { type ILambdaMock } from "../runtime/rapidApi";
|
|
3
|
+
import { Handlers } from "./handlers";
|
|
4
|
+
import type { IAwsProvider, IServiceProvider } from "../../standalone_types";
|
|
5
|
+
interface IDaemonConfig {
|
|
6
|
+
debug: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class Daemon extends Handlers {
|
|
9
|
+
#private;
|
|
10
|
+
runtimeConfig: any;
|
|
11
|
+
sco: Socket[];
|
|
12
|
+
aws: IAwsProvider;
|
|
13
|
+
customOfflineRequests: {
|
|
14
|
+
method?: string | string[];
|
|
15
|
+
filter: RegExp | string;
|
|
16
|
+
callback: (req: any, res: any) => Promise<any> | any | undefined;
|
|
17
|
+
}[];
|
|
18
|
+
customBuildCallback?: Function;
|
|
19
|
+
onReady?: (port: number, ip: string) => any;
|
|
20
|
+
stop(cb?: (err?: any) => void): void;
|
|
21
|
+
constructor(provider: IServiceProvider, config?: IDaemonConfig);
|
|
22
|
+
setPort(p: number): void;
|
|
23
|
+
listen(port?: number, callback?: Function): void;
|
|
24
|
+
fakeRebuildEmitter: () => Promise<void>;
|
|
25
|
+
load(lambdaDefinitions: ILambdaMock[]): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ILambdaMock } from "../runtime/rapidApi";
|
|
2
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ANY";
|
|
3
|
+
export declare class Handlers {
|
|
4
|
+
#private;
|
|
5
|
+
handlers: ILambdaMock[];
|
|
6
|
+
static ip: string;
|
|
7
|
+
debug: boolean;
|
|
8
|
+
port: number;
|
|
9
|
+
constructor(config: any);
|
|
10
|
+
static parseNameFromUrl(lambdaName: string): string;
|
|
11
|
+
getHandlerByName(lambdaName?: string | null): ILambdaMock | undefined;
|
|
12
|
+
addHandler(lambdaController: ILambdaMock): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DynamoDB } from "@aws-sdk/client-dynamodb";
|
|
2
|
+
import type { S3 } from "@aws-sdk/client-s3";
|
|
3
|
+
import type { SNS } from "@aws-sdk/client-sns";
|
|
4
|
+
import type { SQS } from "@aws-sdk/client-sqs";
|
|
5
|
+
export interface AwsServices {
|
|
6
|
+
s3?: S3;
|
|
7
|
+
sns?: SNS;
|
|
8
|
+
sqs?: SQS;
|
|
9
|
+
dynamoDb?: DynamoDB;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const log: {
|
|
2
|
+
GREEN: (s: string) => void;
|
|
3
|
+
YELLOW: (s: string) => void;
|
|
4
|
+
CYAN: (s: string) => void;
|
|
5
|
+
BR_BLUE: (s: string) => void;
|
|
6
|
+
RED: (s: string) => void;
|
|
7
|
+
GREY: (s: string) => void;
|
|
8
|
+
PINK: (s: string) => void;
|
|
9
|
+
setDebug: (_debug: boolean) => void;
|
|
10
|
+
getDebug: () => boolean;
|
|
11
|
+
info: (s: any) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPackageInstalledDir(packageName: string): string;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { DynamoDB } from "@aws-sdk/client-dynamodb";
|
|
2
|
+
import type { S3 } from "@aws-sdk/client-s3";
|
|
3
|
+
import type { SNS } from "@aws-sdk/client-sns";
|
|
4
|
+
import type { SQS } from "@aws-sdk/client-sqs";
|
|
5
|
+
import esbuild from "esbuild";
|
|
6
|
+
import type { BuildContext, BuildResult } from "esbuild";
|
|
7
|
+
import type { Config } from "./config";
|
|
8
|
+
import type { IAwsProviderDefaults, Options } from "./defineConfig";
|
|
9
|
+
import type { ILambdaMock } from "./lib/runtime/rapidApi";
|
|
10
|
+
import { Daemon } from "./lib/server/daemon";
|
|
11
|
+
import type { ILambdaFunction, IServiceProvider } from "./standalone_types";
|
|
12
|
+
export declare class ExloApp extends Daemon {
|
|
13
|
+
#private;
|
|
14
|
+
options: any;
|
|
15
|
+
config?: string | Options;
|
|
16
|
+
esBuildConfig: any;
|
|
17
|
+
buildContext: BuildContext;
|
|
18
|
+
customEsBuildConfig?: Config["build"]["esbuild"];
|
|
19
|
+
optimizeBuild: boolean;
|
|
20
|
+
nodeVersion: number | boolean | string | undefined;
|
|
21
|
+
onKill: (() => Promise<void> | void)[];
|
|
22
|
+
shimRequire: boolean;
|
|
23
|
+
port: number;
|
|
24
|
+
onceServerReady: ((address: {
|
|
25
|
+
port: number;
|
|
26
|
+
url: string;
|
|
27
|
+
}) => void)[];
|
|
28
|
+
isDynamicBuild: boolean;
|
|
29
|
+
endpoints: Record<string, string>;
|
|
30
|
+
constructor(provider: IServiceProvider, options: any);
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
setEsBuildConfig(): void;
|
|
33
|
+
buildAndWatch(): Promise<void>;
|
|
34
|
+
buildCallback: (result: BuildResult, isRebuild: boolean) => Promise<void>;
|
|
35
|
+
setEnv(lambdaName: string, key: string, value: string): void;
|
|
36
|
+
addLambda(lambdaName: string, config: ILambdaFunction): void;
|
|
37
|
+
getLambdaByName(lambdaName: string): ILambdaMock | undefined;
|
|
38
|
+
buildDefineConfigParam(): {
|
|
39
|
+
stop: (cb?: (err?: any) => void) => Promise<void>;
|
|
40
|
+
lambdas: ILambdaMock[];
|
|
41
|
+
addLambda: (lambdaName: string, config: ILambdaFunction) => void;
|
|
42
|
+
esbuild: typeof esbuild;
|
|
43
|
+
getServices(): {
|
|
44
|
+
s3: S3 | undefined;
|
|
45
|
+
sqs: SQS | undefined;
|
|
46
|
+
sns: SNS | undefined;
|
|
47
|
+
dynamoDb: DynamoDB | undefined;
|
|
48
|
+
};
|
|
49
|
+
setService<ServiceName extends "s3" | "sqs" | "sns" | "dynamoDb">(service: ServiceName, client: ServiceName extends "sqs" ? SQS : ServiceName extends "sns" ? SNS : ServiceName extends "dynamoDb" ? DynamoDB : ServiceName extends "s3" ? S3 : never): void;
|
|
50
|
+
setEndpoint: (serviceName: string, url: string, asLambdaEnvVar?: string) => void;
|
|
51
|
+
getEndpoint: (serviceName: string) => string;
|
|
52
|
+
getAwsProviderDefaults: () => {
|
|
53
|
+
accountId: string;
|
|
54
|
+
region: string;
|
|
55
|
+
runtime: `nodejs${number}${string}` | `python${number}${string}` | `ruby${number}${string}`;
|
|
56
|
+
memorySize: number;
|
|
57
|
+
timeout: number;
|
|
58
|
+
environment: {
|
|
59
|
+
[x: string]: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
setAwsProviderDefaults: ({ accountId, environment, memorySize, region, runtime, timeout, }: Partial<IAwsProviderDefaults>) => void;
|
|
63
|
+
log: {
|
|
64
|
+
GREEN: (s: string) => void;
|
|
65
|
+
YELLOW: (s: string) => void;
|
|
66
|
+
CYAN: (s: string) => void;
|
|
67
|
+
BR_BLUE: (s: string) => void;
|
|
68
|
+
RED: (s: string) => void;
|
|
69
|
+
GREY: (s: string) => void;
|
|
70
|
+
PINK: (s: string) => void;
|
|
71
|
+
setDebug: (_debug: boolean) => void;
|
|
72
|
+
getDebug: () => boolean;
|
|
73
|
+
info: (s: any) => void;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
resolveConfig(): Promise<Function | undefined>;
|
|
77
|
+
onBeforeApplyConfigCallbacks: ((configDefiner: Function) => Promise<void> | void)[];
|
|
78
|
+
onBeforeApplyConfig(cb: (configDefiner: Function) => Promise<void> | void): void;
|
|
79
|
+
kill(cb?: (err?: any) => void): Promise<void>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { LambdaEndpoint } from "../../../lib/parseEvents/endpoints";
|
|
3
|
+
import { CommonEventGenerator } from "./common";
|
|
4
|
+
interface AlbPayload {
|
|
5
|
+
requestContext: {
|
|
6
|
+
elb: {
|
|
7
|
+
targetGroupArn: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
multiValueHeaders?: {
|
|
11
|
+
[key: string]: string[];
|
|
12
|
+
};
|
|
13
|
+
multiValueQueryStringParameters?: {
|
|
14
|
+
[key: string]: string[];
|
|
15
|
+
};
|
|
16
|
+
queryStringParameters?: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
headers?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
httpMethod: string;
|
|
23
|
+
path: string;
|
|
24
|
+
isBase64Encoded: boolean;
|
|
25
|
+
body?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class AlbRequestHandler extends CommonEventGenerator {
|
|
28
|
+
#private;
|
|
29
|
+
res: ServerResponse;
|
|
30
|
+
payload: AlbPayload;
|
|
31
|
+
mockEvent: LambdaEndpoint;
|
|
32
|
+
constructor({ res, req, body, mockEvent, multiValueHeaders, isBase64Encoded, lambdaName, }: {
|
|
33
|
+
res: ServerResponse;
|
|
34
|
+
req: IncomingMessage;
|
|
35
|
+
body: any;
|
|
36
|
+
mockEvent: LambdaEndpoint;
|
|
37
|
+
multiValueHeaders: any;
|
|
38
|
+
isBase64Encoded: boolean;
|
|
39
|
+
lambdaName: string;
|
|
40
|
+
});
|
|
41
|
+
returnError: () => true | ServerResponse<IncomingMessage>;
|
|
42
|
+
sendResponse: (output?: any) => void;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { LambdaEndpoint } from "../../../lib/parseEvents/endpoints";
|
|
3
|
+
import { CommonEventGenerator } from "./common";
|
|
4
|
+
interface CommonApgEvent {
|
|
5
|
+
body?: string;
|
|
6
|
+
queryStringParameters: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
isBase64Encoded: boolean;
|
|
10
|
+
headers: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
pathParameters?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type ApgHttpApiEvent = {
|
|
18
|
+
version: string;
|
|
19
|
+
routeKey: string;
|
|
20
|
+
rawPath: string;
|
|
21
|
+
rawQueryString: string;
|
|
22
|
+
cookies?: string[];
|
|
23
|
+
requestContext: {
|
|
24
|
+
accountId: string;
|
|
25
|
+
apiId: string;
|
|
26
|
+
domainName: string;
|
|
27
|
+
domainPrefix: string;
|
|
28
|
+
http: {
|
|
29
|
+
method: string;
|
|
30
|
+
path: string;
|
|
31
|
+
protocol: string;
|
|
32
|
+
sourceIp: string;
|
|
33
|
+
userAgent: string;
|
|
34
|
+
};
|
|
35
|
+
requestId: string;
|
|
36
|
+
routeKey: string;
|
|
37
|
+
stage: string;
|
|
38
|
+
time: string;
|
|
39
|
+
timeEpoch: number;
|
|
40
|
+
};
|
|
41
|
+
} & CommonApgEvent;
|
|
42
|
+
export type ApgHttpEvent = {
|
|
43
|
+
version?: string;
|
|
44
|
+
resource: string;
|
|
45
|
+
path: string;
|
|
46
|
+
httpMethod: string;
|
|
47
|
+
multiValueHeaders: {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
};
|
|
50
|
+
multiValueQueryStringParameters: {
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
};
|
|
53
|
+
requestContext: {
|
|
54
|
+
accountId: string;
|
|
55
|
+
apiId: string;
|
|
56
|
+
domainName: string;
|
|
57
|
+
domainPrefix: string;
|
|
58
|
+
extendedRequestId: string;
|
|
59
|
+
httpMethod: string;
|
|
60
|
+
path: string;
|
|
61
|
+
protocol: string;
|
|
62
|
+
requestId: string;
|
|
63
|
+
requestTime: string;
|
|
64
|
+
requestTimeEpoch: number;
|
|
65
|
+
resourcePath: string;
|
|
66
|
+
stage: string;
|
|
67
|
+
};
|
|
68
|
+
} & CommonApgEvent;
|
|
69
|
+
export declare class ApgRequestHandler extends CommonEventGenerator {
|
|
70
|
+
#private;
|
|
71
|
+
res: ServerResponse;
|
|
72
|
+
mockEvent: LambdaEndpoint;
|
|
73
|
+
payload: ApgHttpApiEvent | ApgHttpEvent;
|
|
74
|
+
constructor({ res, req, body, mockEvent, multiValueHeaders, isBase64Encoded, lambdaName, parsedURL, requestId, }: {
|
|
75
|
+
res: ServerResponse;
|
|
76
|
+
req: IncomingMessage;
|
|
77
|
+
body: any;
|
|
78
|
+
mockEvent: LambdaEndpoint;
|
|
79
|
+
multiValueHeaders: any;
|
|
80
|
+
isBase64Encoded: boolean;
|
|
81
|
+
lambdaName: string;
|
|
82
|
+
parsedURL: URL;
|
|
83
|
+
requestId: string;
|
|
84
|
+
});
|
|
85
|
+
static skipHeaders: string[];
|
|
86
|
+
static createApgV2Event: ({ req, mockEvent, parsedURL, requestId, isBase64Encoded, body, }: {
|
|
87
|
+
req: IncomingMessage;
|
|
88
|
+
mockEvent: LambdaEndpoint;
|
|
89
|
+
isBase64Encoded: boolean;
|
|
90
|
+
parsedURL: URL;
|
|
91
|
+
body: any;
|
|
92
|
+
requestId: string;
|
|
93
|
+
}) => ApgHttpApiEvent;
|
|
94
|
+
static createApgV1Event: ({ req, mockEvent, parsedURL, lambdaName, isBase64Encoded, requestId, body, }: {
|
|
95
|
+
req: IncomingMessage;
|
|
96
|
+
mockEvent: LambdaEndpoint;
|
|
97
|
+
parsedURL: URL;
|
|
98
|
+
lambdaName: string;
|
|
99
|
+
isBase64Encoded: boolean;
|
|
100
|
+
multiValueHeaders: {
|
|
101
|
+
[key: string]: string[];
|
|
102
|
+
};
|
|
103
|
+
requestId: string;
|
|
104
|
+
body: any;
|
|
105
|
+
}) => ApgHttpEvent;
|
|
106
|
+
returnError: (err?: any) => true | ServerResponse<IncomingMessage>;
|
|
107
|
+
sendV1Response: (output?: any) => void;
|
|
108
|
+
sendV2Response: (output?: any) => ServerResponse<IncomingMessage> | undefined;
|
|
109
|
+
sendResponse: (output?: any) => void | ServerResponse<IncomingMessage>;
|
|
110
|
+
}
|
|
111
|
+
export {};
|