cdk-local-lambda 0.0.2
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/LICENSE +202 -0
- package/README.md +94 -0
- package/lib/aspect/docker-function-hook.d.ts +18 -0
- package/lib/aspect/docker-function-hook.js +31 -0
- package/lib/aspect/live-lambda-aspect.d.ts +85 -0
- package/lib/aspect/live-lambda-aspect.js +277 -0
- package/lib/aspect/live-lambda-bootstrap.d.ts +17 -0
- package/lib/aspect/live-lambda-bootstrap.js +260 -0
- package/lib/aspect/nodejs-function-hook.d.ts +20 -0
- package/lib/aspect/nodejs-function-hook.js +27 -0
- package/lib/bootstrap-stack/bootstrap-stack.d.ts +60 -0
- package/lib/bootstrap-stack/bootstrap-stack.js +338 -0
- package/lib/cli/appsync/client.d.ts +30 -0
- package/lib/cli/appsync/client.js +227 -0
- package/lib/cli/cdk-app.d.ts +7 -0
- package/lib/cli/cdk-app.js +25 -0
- package/lib/cli/commands/bootstrap.d.ts +9 -0
- package/lib/cli/commands/bootstrap.js +50 -0
- package/lib/cli/commands/local.d.ts +40 -0
- package/lib/cli/commands/local.js +1172 -0
- package/lib/cli/daemon.d.ts +22 -0
- package/lib/cli/daemon.js +18 -0
- package/lib/cli/docker/container.d.ts +116 -0
- package/lib/cli/docker/container.js +414 -0
- package/lib/cli/docker/types.d.ts +71 -0
- package/lib/cli/docker/types.js +5 -0
- package/lib/cli/docker/watcher.d.ts +44 -0
- package/lib/cli/docker/watcher.js +115 -0
- package/lib/cli/index.d.ts +9 -0
- package/lib/cli/index.js +26 -0
- package/lib/cli/runtime-api/server.d.ts +102 -0
- package/lib/cli/runtime-api/server.js +396 -0
- package/lib/cli/runtime-api/types.d.ts +149 -0
- package/lib/cli/runtime-api/types.js +10 -0
- package/lib/cli/runtime-wrapper/nodejs-runtime.d.ts +16 -0
- package/lib/cli/runtime-wrapper/nodejs-runtime.js +248 -0
- package/lib/cli/watcher/file-watcher.d.ts +32 -0
- package/lib/cli/watcher/file-watcher.js +57 -0
- package/lib/functions/bridge/appsync-client.d.ts +73 -0
- package/lib/functions/bridge/appsync-client.js +345 -0
- package/lib/functions/bridge/handler.d.ts +17 -0
- package/lib/functions/bridge/handler.js +79 -0
- package/lib/functions/bridge/ssm-config.d.ts +19 -0
- package/lib/functions/bridge/ssm-config.js +45 -0
- package/lib/functions/bridge-builder/handler.d.ts +12 -0
- package/lib/functions/bridge-builder/handler.js +181 -0
- package/lib/functions/bridge-docker/runtime.d.ts +9 -0
- package/lib/functions/bridge-docker/runtime.js +127 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +28 -0
- package/lib/shared/types.d.ts +102 -0
- package/lib/shared/types.js +125 -0
- package/package.json +111 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub for daemon logic.
|
|
3
|
+
*
|
|
4
|
+
* The daemon will:
|
|
5
|
+
* 1. Connect to AppSync Events
|
|
6
|
+
* 2. Subscribe to invocation channels for discovered Lambda functions
|
|
7
|
+
* 3. Execute local handlers when invocations arrive
|
|
8
|
+
* 4. Publish responses back to the bridge
|
|
9
|
+
*/
|
|
10
|
+
import { Effect } from "effect";
|
|
11
|
+
export interface DaemonConfig {
|
|
12
|
+
profile?: string;
|
|
13
|
+
region?: string;
|
|
14
|
+
stackName?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Start the local daemon.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Configuration for the daemon
|
|
20
|
+
* @returns Effect that fails with "not implemented" error
|
|
21
|
+
*/
|
|
22
|
+
export declare const startDaemon: (_config: DaemonConfig) => Effect.Effect<void, Error>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub for daemon logic.
|
|
3
|
+
*
|
|
4
|
+
* The daemon will:
|
|
5
|
+
* 1. Connect to AppSync Events
|
|
6
|
+
* 2. Subscribe to invocation channels for discovered Lambda functions
|
|
7
|
+
* 3. Execute local handlers when invocations arrive
|
|
8
|
+
* 4. Publish responses back to the bridge
|
|
9
|
+
*/
|
|
10
|
+
import { Effect } from "effect";
|
|
11
|
+
/**
|
|
12
|
+
* Start the local daemon.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Configuration for the daemon
|
|
15
|
+
* @returns Effect that fails with "not implemented" error
|
|
16
|
+
*/
|
|
17
|
+
export const startDaemon = (_config) => Effect.fail(new Error("Daemon not yet implemented"));
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGFlbW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS9kYWVtb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7O0dBUUc7QUFFSCxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sUUFBUSxDQUFBO0FBUS9COzs7OztHQUtHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sV0FBVyxHQUFHLENBQ3pCLE9BQXFCLEVBQ08sRUFBRSxDQUM5QixNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksS0FBSyxDQUFDLDRCQUE0QixDQUFDLENBQUMsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogU3R1YiBmb3IgZGFlbW9uIGxvZ2ljLlxuICpcbiAqIFRoZSBkYWVtb24gd2lsbDpcbiAqIDEuIENvbm5lY3QgdG8gQXBwU3luYyBFdmVudHNcbiAqIDIuIFN1YnNjcmliZSB0byBpbnZvY2F0aW9uIGNoYW5uZWxzIGZvciBkaXNjb3ZlcmVkIExhbWJkYSBmdW5jdGlvbnNcbiAqIDMuIEV4ZWN1dGUgbG9jYWwgaGFuZGxlcnMgd2hlbiBpbnZvY2F0aW9ucyBhcnJpdmVcbiAqIDQuIFB1Ymxpc2ggcmVzcG9uc2VzIGJhY2sgdG8gdGhlIGJyaWRnZVxuICovXG5cbmltcG9ydCB7IEVmZmVjdCB9IGZyb20gXCJlZmZlY3RcIlxuXG5leHBvcnQgaW50ZXJmYWNlIERhZW1vbkNvbmZpZyB7XG4gIHByb2ZpbGU/OiBzdHJpbmdcbiAgcmVnaW9uPzogc3RyaW5nXG4gIHN0YWNrTmFtZT86IHN0cmluZ1xufVxuXG4vKipcbiAqIFN0YXJ0IHRoZSBsb2NhbCBkYWVtb24uXG4gKlxuICogQHBhcmFtIGNvbmZpZyAtIENvbmZpZ3VyYXRpb24gZm9yIHRoZSBkYWVtb25cbiAqIEByZXR1cm5zIEVmZmVjdCB0aGF0IGZhaWxzIHdpdGggXCJub3QgaW1wbGVtZW50ZWRcIiBlcnJvclxuICovXG5leHBvcnQgY29uc3Qgc3RhcnREYWVtb24gPSAoXG4gIF9jb25maWc6IERhZW1vbkNvbmZpZyxcbik6IEVmZmVjdC5FZmZlY3Q8dm9pZCwgRXJyb3I+ID0+XG4gIEVmZmVjdC5mYWlsKG5ldyBFcnJvcihcIkRhZW1vbiBub3QgeWV0IGltcGxlbWVudGVkXCIpKVxuIl19
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker container management utilities.
|
|
3
|
+
*
|
|
4
|
+
* Handles running Docker containers with the Lambda Runtime API
|
|
5
|
+
* environment configured. Uses @effect/platform Command for
|
|
6
|
+
* proper Effect-based process management.
|
|
7
|
+
*/
|
|
8
|
+
import { CommandExecutor } from "@effect/platform";
|
|
9
|
+
import type { Process as EffectProcess } from "@effect/platform/CommandExecutor";
|
|
10
|
+
import { Context, Effect, Layer, type Scope } from "effect";
|
|
11
|
+
import type { DockerImageConfig, DockerRunConfig, DockerRunResult, DockerRuntimeInfo } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Detect the Docker runtime environment.
|
|
14
|
+
*/
|
|
15
|
+
export declare const detectDockerRuntime: () => Effect.Effect<DockerRuntimeInfo, Error>;
|
|
16
|
+
/**
|
|
17
|
+
* Docker Service interface for Effect-based Docker operations.
|
|
18
|
+
* All scoped operations require both Scope and CommandExecutor.
|
|
19
|
+
*/
|
|
20
|
+
export interface DockerService {
|
|
21
|
+
/**
|
|
22
|
+
* Run a Docker container and wait for it to complete.
|
|
23
|
+
* Output is streamed to stdout/stderr.
|
|
24
|
+
*/
|
|
25
|
+
readonly run: (config: DockerRunConfig) => Effect.Effect<DockerRunResult, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
26
|
+
/**
|
|
27
|
+
* Run a Docker container with scoped lifecycle management.
|
|
28
|
+
* Returns the running process which can be interrupted via scope.
|
|
29
|
+
*/
|
|
30
|
+
readonly runScoped: (config: DockerRunConfig) => Effect.Effect<EffectProcess, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
31
|
+
/**
|
|
32
|
+
* Build a Docker image from a local context directory.
|
|
33
|
+
*/
|
|
34
|
+
readonly build: (options: {
|
|
35
|
+
contextPath: string;
|
|
36
|
+
imageName: string;
|
|
37
|
+
platform?: string;
|
|
38
|
+
}) => Effect.Effect<void, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
39
|
+
/**
|
|
40
|
+
* Pull a Docker image if not already present.
|
|
41
|
+
*/
|
|
42
|
+
readonly pull: (imageUri: string) => Effect.Effect<void, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
43
|
+
/**
|
|
44
|
+
* Stop Docker containers matching a name filter.
|
|
45
|
+
* Returns the number of containers stopped.
|
|
46
|
+
* @param containerNameFilter - Filter to match container names
|
|
47
|
+
* @param timeoutSeconds - Seconds to wait before SIGKILL (default: 10)
|
|
48
|
+
*/
|
|
49
|
+
readonly stop: (containerNameFilter: string, timeoutSeconds?: number) => Effect.Effect<number, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
50
|
+
/**
|
|
51
|
+
* List Docker container IDs matching a name filter.
|
|
52
|
+
*/
|
|
53
|
+
readonly list: (containerNameFilter: string) => Effect.Effect<string[], Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the detected Docker runtime info.
|
|
56
|
+
*/
|
|
57
|
+
readonly getRuntimeInfo: () => Effect.Effect<DockerRuntimeInfo, Error>;
|
|
58
|
+
/**
|
|
59
|
+
* Inspect a Docker image to get its configuration.
|
|
60
|
+
* Returns the ENTRYPOINT and CMD from the image.
|
|
61
|
+
*/
|
|
62
|
+
readonly inspect: (imageUri: string) => Effect.Effect<DockerImageConfig, Error, Scope.Scope | CommandExecutor.CommandExecutor>;
|
|
63
|
+
}
|
|
64
|
+
declare const Docker_base: Context.TagClass<Docker, "Docker", DockerService>;
|
|
65
|
+
/**
|
|
66
|
+
* Docker Service tag for dependency injection.
|
|
67
|
+
*/
|
|
68
|
+
export declare class Docker extends Docker_base {
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Live Docker service layer.
|
|
72
|
+
* Note: Does not require CommandExecutor in the layer - it's required
|
|
73
|
+
* when the service methods are called.
|
|
74
|
+
*/
|
|
75
|
+
export declare const DockerLive: Layer.Layer<Docker, Error>;
|
|
76
|
+
/**
|
|
77
|
+
* Create a container config for running a Lambda container.
|
|
78
|
+
*/
|
|
79
|
+
export declare const makeLambdaContainerConfig: (options: {
|
|
80
|
+
imageUri: string;
|
|
81
|
+
runtimeApiHost: string;
|
|
82
|
+
runtimeApiPort: number;
|
|
83
|
+
functionName: string;
|
|
84
|
+
functionVersion: string;
|
|
85
|
+
memoryMB: number;
|
|
86
|
+
timeoutSeconds: number;
|
|
87
|
+
handler?: string;
|
|
88
|
+
awsRegion?: string;
|
|
89
|
+
platform?: string;
|
|
90
|
+
additionalEnv?: Record<string, string>;
|
|
91
|
+
invocationContexts?: Map<string, {
|
|
92
|
+
num: number;
|
|
93
|
+
}>;
|
|
94
|
+
}) => DockerRunConfig;
|
|
95
|
+
/**
|
|
96
|
+
* Stream output from a Docker container.
|
|
97
|
+
*/
|
|
98
|
+
export interface ContainerOutput {
|
|
99
|
+
type: "stdout" | "stderr";
|
|
100
|
+
data: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build a wrapper command that starts Lambda extensions before the main app.
|
|
104
|
+
*
|
|
105
|
+
* This mimics AWS Lambda's behavior of automatically starting all executables
|
|
106
|
+
* in /opt/extensions/ as background processes before running the main command.
|
|
107
|
+
*
|
|
108
|
+
* @param originalEntrypoint - The image's original ENTRYPOINT
|
|
109
|
+
* @param originalCmd - The image's original CMD
|
|
110
|
+
* @returns Entrypoint and command arrays to pass to Docker
|
|
111
|
+
*/
|
|
112
|
+
export declare const buildExtensionWrapperCommand: (originalEntrypoint: string[] | null, originalCmd: string[] | null) => {
|
|
113
|
+
entrypoint: string[];
|
|
114
|
+
command: string[];
|
|
115
|
+
};
|
|
116
|
+
export {};
|