@processfocus/plugin-aws-lambda 0.1.0-next.1 → 0.1.0-next.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/README.md
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
# @processfocus/plugin-aws-lambda
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`
|
|
3
|
+
Invoke AWS Lambda functions from a Process Focus system step using
|
|
4
|
+
`AwsFunctionStep`:
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
7
|
import { AwsFunctionStep } from "@processfocus/plugin-aws-lambda"
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
The
|
|
11
|
-
|
|
10
|
+
The organisation defines the function invocation and its input. The runtime host
|
|
11
|
+
supplies AWS credentials, region and invocation routing.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Run `bun scripts/nx-quiet.ts run @processfocus/plugin-aws-lambda:build` from the
|
|
16
|
-
workspace root.
|
|
17
|
-
|
|
18
|
-
## Test
|
|
19
|
-
|
|
20
|
-
Run `bun scripts/nx-quiet.ts run @processfocus/plugin-aws-lambda:test` from the
|
|
21
|
-
workspace root.
|
|
13
|
+
See [plugin configuration](../CONFIGURATION.md) for how plugins fit into an
|
|
14
|
+
organisation.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { InvokeCommand, LambdaClient } from "@aws-sdk/client-lambda";
|
|
2
2
|
import { Data, Effect, Schema } from "effect";
|
|
3
3
|
import { SystemStep, } from "processfocus";
|
|
4
|
-
// Lazily cached Lambda client at module level
|
|
5
4
|
let lambdaClient;
|
|
6
|
-
const JsonValue = Schema.
|
|
5
|
+
const JsonValue = Schema.fromJsonString(Schema.Unknown);
|
|
7
6
|
function getLambdaClient() {
|
|
8
7
|
if (!lambdaClient) {
|
|
9
8
|
lambdaClient = new LambdaClient({});
|
|
@@ -54,9 +53,9 @@ export class AwsFunctionStep extends SystemStep {
|
|
|
54
53
|
* - Lambda execution errors (FunctionError field) are detected and failed
|
|
55
54
|
*/
|
|
56
55
|
execute(input) {
|
|
57
|
-
return Effect.gen(this, function* () {
|
|
56
|
+
return Effect.gen({ self: this }, function* () {
|
|
58
57
|
const client = getLambdaClient();
|
|
59
|
-
const payloadJson = yield* Schema.
|
|
58
|
+
const payloadJson = yield* Schema.encodeEffect(JsonValue)(input).pipe(Effect.mapError((cause) => new AwsFunctionError({
|
|
60
59
|
message: `Failed to encode Lambda payload for "${this.functionName}"`,
|
|
61
60
|
cause,
|
|
62
61
|
})));
|
|
@@ -84,7 +83,6 @@ export class AwsFunctionStep extends SystemStep {
|
|
|
84
83
|
message: `Lambda function "${this.functionName}" returned an error: ${errorPayload}`,
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
// Parse the response payload as JSON
|
|
88
86
|
if (!response.Payload || response.Payload.length === 0) {
|
|
89
87
|
return yield* new AwsFunctionError({
|
|
90
88
|
message: `Lambda function "${this.functionName}" returned empty response`,
|
|
@@ -94,7 +92,7 @@ export class AwsFunctionStep extends SystemStep {
|
|
|
94
92
|
yield* Effect.log(`Lambda function ${this.functionName} returned response`, {
|
|
95
93
|
responseLength: responseText.length,
|
|
96
94
|
});
|
|
97
|
-
const result = yield* Schema.
|
|
95
|
+
const result = yield* Schema.decodeUnknownEffect(JsonValue)(responseText).pipe(Effect.map((value) => value), Effect.mapError((error) => new AwsFunctionError({
|
|
98
96
|
message: `Failed to parse Lambda response from "${this.functionName}": ${String(error)}. Response: ${responseText.slice(0, 200)}`,
|
|
99
97
|
cause: error,
|
|
100
98
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-function-step.js","sourceRoot":"","sources":["../../src/lib/aws-function-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,C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ocus/plugin-aws-lambda",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"repository": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"!**/*.tsbuildinfo"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aws-sdk/client-lambda": "^3.
|
|
30
|
-
"effect": "
|
|
29
|
+
"@aws-sdk/client-lambda": "^3.1169.0",
|
|
30
|
+
"effect": "4.1.4"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|
|
34
34
|
"tag": "next"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"processfocus": "0.1.0-next.
|
|
37
|
+
"processfocus": "0.1.0-next.3"
|
|
38
38
|
}
|
|
39
39
|
}
|