exlo 0.0.22 → 0.0.24

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{readFile as I}from"node:fs/promises";import p from"node:path";import{pathToFileURL as O}from"node:url";import{parseArgs as Y}from"node:util";var j="exlo",b="0.0.22";var g=!1,R=e=>{g=e},A=()=>g,l=(e,t)=>{g&&console.log(`\x1B[${e}m${t}\x1B[0m`)},C=e=>console.log(`\x1B[31m${e}\x1B[0m`),$=e=>l("32",e),q=e=>l("33",e),L=e=>l("36",e),S=e=>l("90",e),F=e=>l("94",e),_=e=>l("95",e),D=e=>g?console.log(e):void 0,n={GREEN:$,YELLOW:q,CYAN:L,BR_BLUE:F,RED:C,GREY:S,PINK:_,setDebug:R,getDebug:A,info:D};var y={config:{type:"string",short:"c",default:"exlo.config.ts",description:"Path to exlo 'defineConfig' file."},debug:{type:"boolean",default:!1,description:"Enable debug mode. When enabled exlo will print usefull informations."},create:{type:"boolean",default:!1,description:"Create exlo 'defineConfig' file based on passed options."},runtime:{type:"string",short:"r",description:"Lambda default runtime (ex: nodejs22.x, python3.7, ruby2.7 etc.)."},timeout:{type:"string",short:"t",default:"3",description:"Lambda default timeout."},port:{type:"string",short:"p",default:"0",description:"Lambda server port."},definitions:{type:"string",short:"d",description:"Path to .json, .mjs, .cjs file with Lambda function definitions."},functions:{type:"string",short:"f",multiple:!0,description:"Glob pattern to automatically find and define Lambda handlers."},exclude:{type:"string",short:"X",multiple:!0,default:[".(test|spec)."],description:"RegExp string to exclude found enteries from --functions."},"handler-name":{type:"string",default:"handler",description:"Handler function name. To be used with --functions."},env:{type:"string",short:"e",multiple:!0,default:[],description:"Environment variables to be injected into Lambdas. All existing AWS_* are automatically injected.",example:"-e API_KEY=supersecret -e API_URL=https://website.com"},"optimize-build":{type:"boolean",default:!1,description:"externalize dependencies and other stuff"},"shim-require":{type:"boolean",default:!1,description:"shim 'require()', '__dirname' and '__filename' when bundeling Lambdas with ESM format"},help:{type:"boolean",short:"h",skipFullPrint:!0},version:{type:"boolean",short:"v",skipFullPrint:!0},"esbuild-external":{type:"string",multiple:!0,skip:!0},"esbuild-resolveExtensions":{type:"string",multiple:!0,skip:!0},"esbuild-mainFields":{type:"string",multiple:!0,skip:!0},"esbuild-conditions":{type:"string",multiple:!0,skip:!0},"esbuild-entryPoints":{type:"string",multiple:!0,skip:!0},"esbuild-inject":{type:"string",multiple:!0,skip:!0},"esbuild-nodePaths":{type:"string",multiple:!0,skip:!0}};function M(){n.setDebug(!0),n.GREY("Usage examples:"),console.log("exlo -c exlo.config.ts"),console.log(`exlo -p 3000 --debug --functions "src/lambdas/**/*.ts"
2
+ import{readFile as I}from"node:fs/promises";import p from"node:path";import{pathToFileURL as O}from"node:url";import{parseArgs as Y}from"node:util";var j="exlo",b="0.0.24";var g=!1,R=e=>{g=e},A=()=>g,l=(e,t)=>{g&&console.log(`\x1B[${e}m${t}\x1B[0m`)},$=e=>console.log(`\x1B[31m${e}\x1B[0m`),C=e=>l("32",e),q=e=>l("33",e),L=e=>l("36",e),S=e=>l("90",e),F=e=>l("94",e),_=e=>l("95",e),D=e=>g?console.log(e):void 0,n={GREEN:C,YELLOW:q,CYAN:L,BR_BLUE:F,RED:$,GREY:S,PINK:_,setDebug:R,getDebug:A,info:D};var y={config:{type:"string",short:"c",default:"exlo.config.ts",description:"Path to exlo 'defineConfig' file."},debug:{type:"boolean",default:!1,description:"Enable debug mode. When enabled exlo will print usefull informations."},create:{type:"boolean",default:!1,description:"Create exlo 'defineConfig' file based on passed options."},runtime:{type:"string",short:"r",description:"Lambda default runtime (ex: nodejs22.x, python3.7, ruby2.7 etc.)."},timeout:{type:"string",short:"t",default:"3",description:"Lambda default timeout."},port:{type:"string",short:"p",default:"0",description:"Lambda server port."},definitions:{type:"string",short:"d",description:"Path to .json, .mjs, .cjs file with Lambda function definitions."},functions:{type:"string",short:"f",multiple:!0,description:"Glob pattern to automatically find and define Lambda handlers."},exclude:{type:"string",short:"X",multiple:!0,default:[".(test|spec)."],description:"RegExp string to exclude found enteries from --functions."},"handler-name":{type:"string",default:"handler",description:"Handler function name. To be used with --functions."},env:{type:"string",short:"e",multiple:!0,default:[],description:"Environment variables to be injected into Lambdas. All existing AWS_* are automatically injected.",example:"-e API_KEY=supersecret -e API_URL=https://website.com"},"optimize-build":{type:"boolean",default:!1,description:"externalize dependencies and other stuff"},"shim-require":{type:"boolean",default:!1,description:"shim 'require()', '__dirname' and '__filename' when bundeling Lambdas with ESM format"},help:{type:"boolean",short:"h",skipFullPrint:!0},version:{type:"boolean",short:"v",skipFullPrint:!0},"esbuild-external":{type:"string",multiple:!0,skip:!0},"esbuild-resolveExtensions":{type:"string",multiple:!0,skip:!0},"esbuild-mainFields":{type:"string",multiple:!0,skip:!0},"esbuild-conditions":{type:"string",multiple:!0,skip:!0},"esbuild-entryPoints":{type:"string",multiple:!0,skip:!0},"esbuild-inject":{type:"string",multiple:!0,skip:!0},"esbuild-nodePaths":{type:"string",multiple:!0,skip:!0}};function M(){n.setDebug(!0),n.GREY("Usage examples:"),console.log("exlo -c exlo.config.ts"),console.log(`exlo -p 3000 --debug --functions "src/lambdas/**/*.ts"
3
3
  `),n.BR_BLUE("Options:");for(let[e,t]of Object.entries(y)){let i=e;if(t.skip)continue;if(t.short&&(i+=`, -${t.short}`),t.skipFullPrint){n.CYAN(` --${i}
4
4
  `);continue}let s=` type: ${t.type}`;t.description&&(s+=`
5
5
  description: ${t.description}`),"default"in t&&(s+=`
package/dist/config.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { BuildOptions, BuildResult } from "esbuild";
3
+ import type { LlrtOptions } from "./lib/runtime/runners/llrt/runner";
3
4
  import type { awslambda } from "./lib/runtime/runners/node/awslambda";
4
5
  import type { HttpMethod } from "./lib/server/handlers";
5
6
  export interface OfflineConfig {
@@ -23,6 +24,7 @@ export interface Config {
23
24
  server?: OfflineConfig;
24
25
  buildCallback?: (result: BuildResult, isRebuild: boolean) => Promise<void> | void;
25
26
  onKill?: (() => Promise<void> | void)[];
27
+ llrt?: LlrtOptions;
26
28
  }
27
29
  export interface ServerConfig {
28
30
  stage?: string;
@@ -6,6 +6,7 @@ import type { SQS } from "@aws-sdk/client-sqs";
6
6
  import type { BuildResult, PluginBuild } from "esbuild";
7
7
  import type { Config } from "./config";
8
8
  import type { ILambdaMock } from "./lib/runtime/rapidApi";
9
+ import type { LlrtOptions } from "./lib/runtime/runners/llrt/runner";
9
10
  import type { HttpMethod } from "./lib/server/handlers";
10
11
  import type { log } from "./lib/utils/colorize";
11
12
  import type { IAwsProvider, IFunctionUrlCors, ILambdaFunction } from "./standalone_types";
@@ -129,6 +130,7 @@ export interface Options {
129
130
  [lambdaName: string]: ILambdaFunction;
130
131
  };
131
132
  defaults?: Partial<IAwsProviderDefaults>;
133
+ llrt?: LlrtOptions;
132
134
  }
133
135
  export type ConfigDefiner = (this: ClientConfigParams, internalResources: ClientConfigParams) => Promise<Omit<Config, "config" | "options">>;
134
136
  export declare function defineConfig(options: Options): ConfigDefiner;
@@ -1 +1 @@
1
- var h="0.0.22";function k(e){let c=new Set;e.plugins&&(e.plugins=e.plugins.filter((i,a)=>typeof i!="object"||!i||!("name"in i)?!1:((!i.name||!i.name.length||typeof i.name!="string")&&(i.name=`plugin-${a}`,console.warn(`No Plugin name provided at index ${a}`)),c.has(i.name)?i.name=i.name+a:c.add(i.name),!0)));async function f({stop:i,lambdas:a,region:p,esbuild:v,getServices:y,setService:d,addLambda:g,log:l,setEndpoint:b,getEndpoint:x,getAwsProviderDefaults:C,setAwsProviderDefaults:S}){let r={build:{esbuild:e?.build?.esbuild??{},shimRequire:e?.build?.shimRequire,optimizeBuild:e?.build?.optimizeBuild},server:{port:e.server?.port,setEndpointEnvVar:e.server?.setEndpointEnvVar},onKill:[]};if(e.defaults&&typeof e.defaults=="object"&&!Array.isArray(e.defaults)&&S(e.defaults),e.functions&&typeof e.functions=="object"&&!Array.isArray(e.functions))for(let[m,s]of Object.entries(e.functions))g(m,s);e.services&&(e.services.sqs&&d("sqs",e.services.sqs),e.services.sns&&d("sns",e.services.sns),e.services.dynamodb&&d("dynamodb",e.services.dynamodb));let o={stop:i,lambdas:a,region:p,esbuild:v,options:e,config:r,getServices:y,setService:d,addLambda:g,log:l,setEndpoint:b,getEndpoint:x,getAwsProviderDefaults:C};if(e.plugins){r.server.onReady=async(s,n)=>{for(let t of e.plugins)if(t.server?.onReady)try{await t.server.onReady.call(o,s,n)}catch(u){l.RED(t.name),console.error(u)}},r.buildCallback=async(s,n)=>{for(let t of e.plugins)if(t.buildCallback)try{await t.buildCallback.call(o,s,n)}catch(u){l.RED(t.name),console.error(u),n||process.exit(1)}};let m=e.plugins.reduce((s,n)=>(n.server?.request?.length&&s.push(...n.server.request),s),[]);m?.length&&(r.server.request=m.map(s=>(s.callback=s.callback.bind(o),s)));for(let s of e.plugins)if(s.onKill&&r.onKill.push(s.onKill.bind(o)),s.onInit)try{await s.onInit.call(o)}catch(n){throw l.RED(s.name),n}}return r}return f.plugins=e.plugins??[],f}export{k as defineConfig,h as exloVersion};
1
+ var h="0.0.24";function k(e){let c=new Set;e.plugins&&(e.plugins=e.plugins.filter((i,a)=>typeof i!="object"||!i||!("name"in i)?!1:((!i.name||!i.name.length||typeof i.name!="string")&&(i.name=`plugin-${a}`,console.warn(`No Plugin name provided at index ${a}`)),c.has(i.name)?i.name=i.name+a:c.add(i.name),!0)));async function f({stop:i,lambdas:a,region:p,esbuild:y,getServices:v,setService:d,addLambda:g,log:l,setEndpoint:b,getEndpoint:x,getAwsProviderDefaults:C,setAwsProviderDefaults:S}){let r={build:{esbuild:e?.build?.esbuild??{},shimRequire:e?.build?.shimRequire,optimizeBuild:e?.build?.optimizeBuild},server:{port:e.server?.port,setEndpointEnvVar:e.server?.setEndpointEnvVar},onKill:[],llrt:e.llrt};if(e.defaults&&typeof e.defaults=="object"&&!Array.isArray(e.defaults)&&S(e.defaults),e.functions&&typeof e.functions=="object"&&!Array.isArray(e.functions))for(let[m,s]of Object.entries(e.functions))g(m,s);e.services&&(e.services.sqs&&d("sqs",e.services.sqs),e.services.sns&&d("sns",e.services.sns),e.services.dynamodb&&d("dynamodb",e.services.dynamodb));let o={stop:i,lambdas:a,region:p,esbuild:y,options:e,config:r,getServices:v,setService:d,addLambda:g,log:l,setEndpoint:b,getEndpoint:x,getAwsProviderDefaults:C};if(e.plugins){r.server.onReady=async(s,n)=>{for(let t of e.plugins)if(t.server?.onReady)try{await t.server.onReady.call(o,s,n)}catch(u){l.RED(t.name),console.error(u)}},r.buildCallback=async(s,n)=>{for(let t of e.plugins)if(t.buildCallback)try{await t.buildCallback.call(o,s,n)}catch(u){l.RED(t.name),console.error(u),n||process.exit(1)}};let m=e.plugins.reduce((s,n)=>(n.server?.request?.length&&s.push(...n.server.request),s),[]);m?.length&&(r.server.request=m.map(s=>(s.callback=s.callback.bind(o),s)));for(let s of e.plugins)if(s.onKill&&r.onKill.push(s.onKill.bind(o)),s.onInit)try{await s.onInit.call(o)}catch(n){throw l.RED(s.name),n}}return r}return f.plugins=e.plugins??[],f}export{k as defineConfig,h as exloVersion};
@@ -0,0 +1,58 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ import type { FSWatcher } from "node:fs";
3
+ import { type IncomingMessage, type ServerResponse } from "node:http";
4
+ import type { Runner } from "../index";
5
+ export declare class CustomRunner implements Runner {
6
+ private cwd?;
7
+ private static collectBody;
8
+ invoke: Runner["invoke"];
9
+ mount: Runner["mount"];
10
+ unmount: Runner["unmount"];
11
+ name: string;
12
+ timeout: number;
13
+ memorySize: number;
14
+ environment: {
15
+ [key: string]: any;
16
+ };
17
+ handlerName: string;
18
+ runtime: string;
19
+ bin?: string;
20
+ runner?: ChildProcess;
21
+ isMounted: boolean;
22
+ watchers: FSWatcher[];
23
+ filesTime: Map<string, number>;
24
+ private port?;
25
+ watcher?: FSWatcher;
26
+ emitRebuild: Function;
27
+ invocations: {
28
+ id: string;
29
+ event: any;
30
+ inFlight: boolean;
31
+ resolve: (value: unknown) => void;
32
+ reject: (reason?: any) => void;
33
+ }[];
34
+ queue: ServerResponse<IncomingMessage>[];
35
+ getWaitingInvocation(): {
36
+ id: string;
37
+ event: any;
38
+ inFlight: boolean;
39
+ resolve: (value: unknown) => void;
40
+ reject: (reason?: any) => void;
41
+ } | undefined;
42
+ private server;
43
+ createOwnedServer(): Promise<void>;
44
+ constructor({ name, timeout, memorySize, environment, handlerPath, handlerName, runtime, }: {
45
+ name: string;
46
+ handlerPath: string;
47
+ handlerName: string;
48
+ runtime: string;
49
+ timeout: number;
50
+ memorySize: number;
51
+ environment: {
52
+ [key: string]: any;
53
+ };
54
+ }, emitRebuild: Function, cwd?: string | undefined);
55
+ load: () => Promise<undefined>;
56
+ onComplete: (awsRequestId: string) => void;
57
+ handleInvoke(): void;
58
+ }
@@ -0,0 +1,12 @@
1
+ import { CustomRunner } from "../custom/runner";
2
+ export interface LlrtOptions {
3
+ boostrapPath: string;
4
+ environment?: Record<string, string>;
5
+ }
6
+ type Csp = ConstructorParameters<typeof CustomRunner>;
7
+ export declare class LlrtRunner extends CustomRunner {
8
+ static llrtEnvs: Record<string, string>;
9
+ static llrtBoostrapPath: string;
10
+ constructor(lambda: Csp[0], emitRebuild: Csp[1]);
11
+ }
12
+ export {};
@@ -1,7 +1,8 @@
1
1
  import type { Socket } from "node:net";
2
+ import type { IAwsProvider, IServiceProvider } from "../../standalone_types";
2
3
  import { type ILambdaMock } from "../runtime/rapidApi";
4
+ import { type LlrtOptions } from "../runtime/runners/llrt/runner";
3
5
  import { Handlers } from "./handlers";
4
- import type { IAwsProvider, IServiceProvider } from "../../standalone_types";
5
6
  interface IDaemonConfig {
6
7
  debug: boolean;
7
8
  }
@@ -10,6 +11,7 @@ export declare class Daemon extends Handlers {
10
11
  runtimeConfig: any;
11
12
  sco: Socket[];
12
13
  aws: IAwsProvider;
14
+ llrt?: LlrtOptions;
13
15
  customOfflineRequests: {
14
16
  method?: string | string[];
15
17
  filter: RegExp | string;
package/dist/main.d.ts CHANGED
@@ -53,7 +53,7 @@ export declare class ExloApp extends Daemon {
53
53
  getAwsProviderDefaults: () => {
54
54
  accountId: string;
55
55
  region: string;
56
- runtime: `nodejs${number}${string}` | `python${number}${string}` | `ruby${number}${string}`;
56
+ runtime: "llrt" | "custom" | `nodejs${number}${string}` | `python${number}${string}` | `ruby${number}${string}`;
57
57
  memorySize: number;
58
58
  timeout: number;
59
59
  environment: {
@@ -1,4 +1,5 @@
1
1
  import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http";
2
+ import type { NotificationConfiguration } from "@aws-sdk/client-s3";
2
3
  import { XMLBuilder, XMLParser } from "fast-xml-parser";
3
4
  import type { ILambda } from "../../../defineConfig";
4
5
  export interface BucketConfig {
@@ -9,6 +10,7 @@ export interface BucketConfig {
9
10
  headers?: Record<string, string | string[]>;
10
11
  accessControlPolicy: string;
11
12
  };
13
+ notification?: NotificationConfiguration;
12
14
  }
13
15
  declare const StorageClass: readonly ["STANDARD", "REDUCED_REDUNDANCY", "STANDARD_IA", "ONEZONE_IA", "INTELLIGENT_TIERING", "GLACIER", "DEEP_ARCHIVE", "OUTPOSTS", "GLACIER_IR", "SNOW"];
14
16
  export type LocalS3Object = {
@@ -68,7 +70,7 @@ export declare class S3LocalService {
68
70
  static genLocalKey(bucket: string, key: string, version?: string): string;
69
71
  static getTagsFromRequest(req: IncomingMessage, RequestId: string, type: "Bucket" | "Object"): Promise<Record<string, string> | undefined>;
70
72
  persistence: LocalS3PersistenceV2;
71
- callableLambdas: ILambda[];
73
+ getLambdas: () => ILambda[];
72
74
  accountId: string;
73
75
  ownerId: string;
74
76
  region: string;