@superdurable/connector-amazon-lambda 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +2 -2
- package/dex-connector.json +64 -0
- package/dist/chunk-G5OORMFR.js +111 -0
- package/dist/connection-B5yl3Wdb.d.ts +73 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +255 -0
- package/dist/mock.d.ts +35 -0
- package/dist/mock.js +73 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated keyation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Amazon Lambda TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `getFunction` Query reads a Lambda function name and ARN. Configure AWS Region and signing credentials as described in the [connector README](../README.md). The [runnable Flow](examples/function-lookup/README.md) exercises a real Dex Worker and local provider fixture. Live AWS access has not been verified.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "amazon-lambda",
|
|
3
|
+
"releaseTag": "connectors/amazon/lambda/go/v0.1.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-amazon-lambda",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newGetFunctionStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "getFunction",
|
|
14
|
+
"inputType": "GetFunctionInput",
|
|
15
|
+
"description": "Read the function name and ARN from AWS Lambda GetFunction.",
|
|
16
|
+
"fields": {
|
|
17
|
+
"stepType": "stepType",
|
|
18
|
+
"annotations": "annotations",
|
|
19
|
+
"connectionName": "connectionName",
|
|
20
|
+
"resultAttribute": "resultAttribute"
|
|
21
|
+
},
|
|
22
|
+
"branches": [
|
|
23
|
+
{
|
|
24
|
+
"id": "found",
|
|
25
|
+
"field": "found",
|
|
26
|
+
"optional": false
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "missing",
|
|
30
|
+
"field": "missing",
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "providerRejected",
|
|
35
|
+
"field": "providerRejected",
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "invalidResponse",
|
|
40
|
+
"field": "invalidResponse",
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "defect",
|
|
45
|
+
"field": "defect",
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "GetFunctionInput identifies one Lambda function in the configured Region.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"functionName": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": [
|
|
58
|
+
"functionName"
|
|
59
|
+
],
|
|
60
|
+
"type": "object"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var ConfigSchema = z.object({
|
|
5
|
+
"region": z.string().optional(),
|
|
6
|
+
"endpoint": z.string().optional(),
|
|
7
|
+
"timeoutMs": z.number().int().optional(),
|
|
8
|
+
"maxResponseBytes": z.number().int().optional()
|
|
9
|
+
});
|
|
10
|
+
function decodeCredentials(value) {
|
|
11
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
12
|
+
const fields = value;
|
|
13
|
+
const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
|
|
14
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
15
|
+
if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new TypeError("credential access_key_id has an invalid type");
|
|
16
|
+
if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new TypeError("credential secret_access_key has an invalid type");
|
|
17
|
+
if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new TypeError("credential session_token has an invalid type");
|
|
18
|
+
const credentials = {};
|
|
19
|
+
if (!fields["access_key_id"]) throw new TypeError("credential access_key_id is required");
|
|
20
|
+
credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
|
|
21
|
+
if (!fields["secret_access_key"]) throw new TypeError("credential secret_access_key is required");
|
|
22
|
+
credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
|
|
23
|
+
credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
|
|
24
|
+
return credentials;
|
|
25
|
+
}
|
|
26
|
+
var GetFunctionInputSchema = z.strictObject({
|
|
27
|
+
"functionName": z.string()
|
|
28
|
+
});
|
|
29
|
+
var FunctionDetailsSchema = z.strictObject({
|
|
30
|
+
"name": z.string(),
|
|
31
|
+
"arn": z.string()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// src/generated/definitions.ts
|
|
35
|
+
var ConnectorID = "amazon-lambda";
|
|
36
|
+
var ProviderID = "amazon-lambda";
|
|
37
|
+
var GetFunctionBranch = {
|
|
38
|
+
Found: "found",
|
|
39
|
+
Missing: "missing",
|
|
40
|
+
ProviderRejected: "providerRejected",
|
|
41
|
+
InvalidResponse: "invalidResponse",
|
|
42
|
+
Defect: "defect"
|
|
43
|
+
};
|
|
44
|
+
var GetFunctionBranchFound = GetFunctionBranch.Found;
|
|
45
|
+
var GetFunctionBranchMissing = GetFunctionBranch.Missing;
|
|
46
|
+
var GetFunctionBranchProviderRejected = GetFunctionBranch.ProviderRejected;
|
|
47
|
+
var GetFunctionBranchInvalidResponse = GetFunctionBranch.InvalidResponse;
|
|
48
|
+
var GetFunctionBranchDefect = GetFunctionBranch.Defect;
|
|
49
|
+
var GetFunctionDefinition = {
|
|
50
|
+
operation: { connectorId: ConnectorID, operationId: "getFunction" },
|
|
51
|
+
branches: [
|
|
52
|
+
{ id: "found", description: "AWS returned the function configuration." },
|
|
53
|
+
{ id: "missing", description: "The function does not exist in the selected Region.", optional: true },
|
|
54
|
+
{ id: "providerRejected", description: "AWS conclusively rejected the request or credentials.", optional: true },
|
|
55
|
+
{ id: "invalidResponse", description: "AWS returned malformed or oversized function metadata.", optional: true },
|
|
56
|
+
{ id: "defect", description: "The function name, endpoint, Region, or credentials are invalid.", optional: true }
|
|
57
|
+
],
|
|
58
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
59
|
+
};
|
|
60
|
+
var GetFunctionMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
61
|
+
|
|
62
|
+
// src/generated/connection.ts
|
|
63
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
64
|
+
var Connection = class {
|
|
65
|
+
/** Stable provider and connection name. */
|
|
66
|
+
reference;
|
|
67
|
+
/** Bound provider operations. */
|
|
68
|
+
operations;
|
|
69
|
+
/** Validate a reference and bind operations. */
|
|
70
|
+
constructor(reference, operations) {
|
|
71
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
72
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
73
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
74
|
+
this.operations = operations;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function newConnection(client, reference) {
|
|
78
|
+
if (!client) throw new TypeError("connector client is required");
|
|
79
|
+
return new Connection(reference, client);
|
|
80
|
+
}
|
|
81
|
+
function newConnectionWithOperations(operations, reference) {
|
|
82
|
+
return new Connection(reference, operations);
|
|
83
|
+
}
|
|
84
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
85
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
86
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
87
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
88
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
89
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
ConfigSchema,
|
|
94
|
+
decodeCredentials,
|
|
95
|
+
GetFunctionInputSchema,
|
|
96
|
+
FunctionDetailsSchema,
|
|
97
|
+
ConnectorID,
|
|
98
|
+
ProviderID,
|
|
99
|
+
GetFunctionBranch,
|
|
100
|
+
GetFunctionBranchFound,
|
|
101
|
+
GetFunctionBranchMissing,
|
|
102
|
+
GetFunctionBranchProviderRejected,
|
|
103
|
+
GetFunctionBranchInvalidResponse,
|
|
104
|
+
GetFunctionBranchDefect,
|
|
105
|
+
GetFunctionDefinition,
|
|
106
|
+
GetFunctionMetadata,
|
|
107
|
+
Connection,
|
|
108
|
+
newConnection,
|
|
109
|
+
newConnectionWithOperations,
|
|
110
|
+
newProjectConnection
|
|
111
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** AWS Region of the Lambda function, as a Region code such as eu-west-1. In https://console.aws.amazon.com/lambda > Functions, use the console Region selector and the function ARN. Blank uses the displayed default; change it when your function is elsewhere. */
|
|
7
|
+
region?: string;
|
|
8
|
+
/** Optional Lambda-compatible API root. Blank derives the regional AWS endpoint from region. Override only for a trusted compatible endpoint; local tests may use loopback HTTP. */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Maximum duration of one GetFunction request as a positive Go duration such as 15s. Blank uses the displayed default; increase only for a slow network. Runtime value in milliseconds. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
/** Maximum complete function metadata response in bytes. Blank uses the displayed default; increase only for unusually large responses. */
|
|
13
|
+
maxResponseBytes?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Runtime schema for manifest configuration. */
|
|
16
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
17
|
+
region: z.ZodOptional<z.ZodString>;
|
|
18
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
19
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
/** Private connector credentials resolved by the host. */
|
|
23
|
+
interface Credentials {
|
|
24
|
+
/** Secret-stored AWS access key ID from https://console.aws.amazon.com/iam > Users > selected user > Security credentials > Access keys > Create access key. Long-term IDs start AKIA and temporary IDs start ASIA. Blank prevents signing. Dex stores it as a secret. */
|
|
25
|
+
accessKeyId: SecretString;
|
|
26
|
+
/** Secret access key paired with access_key_id, shown once on the IAM Retrieve access keys page. Copy the Value, never the key ID. Blank prevents signing; rotate by creating another key and deleting the old one after verification. */
|
|
27
|
+
secretAccessKey: SecretString;
|
|
28
|
+
/** Secret session token for temporary ASIA credentials, from AWS STS. Blank means long-term IAM user credentials. Temporary credentials expire; replace all three fields before expiry. */
|
|
29
|
+
sessionToken?: SecretString;
|
|
30
|
+
}
|
|
31
|
+
/** Decode private credential fields for the connector. */
|
|
32
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
33
|
+
/** Host-owned source of private connector credentials. */
|
|
34
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
35
|
+
/** GetFunctionInput identifies one Lambda function in the configured Region. */
|
|
36
|
+
interface GetFunctionInput {
|
|
37
|
+
"functionName": string;
|
|
38
|
+
}
|
|
39
|
+
/** FunctionDetails returns the stable identity of a Lambda function. */
|
|
40
|
+
interface FunctionDetails {
|
|
41
|
+
"name": string;
|
|
42
|
+
"arn": string;
|
|
43
|
+
}
|
|
44
|
+
/** Runtime validator for GetFunctionInput. */
|
|
45
|
+
declare const GetFunctionInputSchema: z.ZodObject<{
|
|
46
|
+
functionName: z.ZodString;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
/** Runtime validator for FunctionDetails. */
|
|
49
|
+
declare const FunctionDetailsSchema: z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
arn: z.ZodString;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
|
|
54
|
+
/** Typed operations supplied by a client or mock. */
|
|
55
|
+
interface Operations {
|
|
56
|
+
/** Invoke getFunction through this connection. */
|
|
57
|
+
getFunction(): Query<GetFunctionInput, FunctionDetails>;
|
|
58
|
+
}
|
|
59
|
+
/** Named connector connection kept outside Flow state. */
|
|
60
|
+
declare class Connection<BoundOperations = Operations> {
|
|
61
|
+
/** Stable provider and connection name. */
|
|
62
|
+
readonly reference: ConnectionRef;
|
|
63
|
+
/** Bound provider operations. */
|
|
64
|
+
readonly operations: BoundOperations;
|
|
65
|
+
/** Validate a reference and bind operations. */
|
|
66
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
67
|
+
}
|
|
68
|
+
/** Bind a client to a named connection. */
|
|
69
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
70
|
+
/** Bind scripted operations to a named connection. */
|
|
71
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
72
|
+
|
|
73
|
+
export { Connection as C, type FunctionDetails as F, type GetFunctionInput as G, type Operations as O, type Config as a, type Credentials as b, ConfigSchema as c, type CredentialSource as d, FunctionDetailsSchema as e, GetFunctionInputSchema as f, decodeCredentials as g, newConnectionWithOperations as h, newConnection as n };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { G as GetFunctionInput, F as FunctionDetails, C as Connection, O as Operations, a as Config, b as Credentials } from './connection-B5yl3Wdb.js';
|
|
2
|
+
export { c as ConfigSchema, d as CredentialSource, e as FunctionDetailsSchema, f as GetFunctionInputSchema, g as decodeCredentials, n as newConnection, h as newConnectionWithOperations } from './connection-B5yl3Wdb.js';
|
|
3
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
|
|
4
|
+
import { StepTarget } from '@superdurable/dex';
|
|
5
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
6
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
/** Stable connector identity. */
|
|
10
|
+
declare const ConnectorID = "amazon-lambda";
|
|
11
|
+
/** Provider identity for named connections. */
|
|
12
|
+
declare const ProviderID = "amazon-lambda";
|
|
13
|
+
/** Branch IDs for getFunction. */
|
|
14
|
+
declare const GetFunctionBranch: {
|
|
15
|
+
readonly Found: "found";
|
|
16
|
+
readonly Missing: "missing";
|
|
17
|
+
readonly ProviderRejected: "providerRejected";
|
|
18
|
+
readonly InvalidResponse: "invalidResponse";
|
|
19
|
+
readonly Defect: "defect";
|
|
20
|
+
};
|
|
21
|
+
/** AWS returned the function configuration. */
|
|
22
|
+
declare const GetFunctionBranchFound: "found";
|
|
23
|
+
/** The function does not exist in the selected Region. */
|
|
24
|
+
declare const GetFunctionBranchMissing: "missing";
|
|
25
|
+
/** AWS conclusively rejected the request or credentials. */
|
|
26
|
+
declare const GetFunctionBranchProviderRejected: "providerRejected";
|
|
27
|
+
/** AWS returned malformed or oversized function metadata. */
|
|
28
|
+
declare const GetFunctionBranchInvalidResponse: "invalidResponse";
|
|
29
|
+
/** The function name, endpoint, Region, or credentials are invalid. */
|
|
30
|
+
declare const GetFunctionBranchDefect: "defect";
|
|
31
|
+
/** Manifest definition for getFunction. */
|
|
32
|
+
declare const GetFunctionDefinition: QueryDefinition;
|
|
33
|
+
/** Manifest metadata for getFunction. */
|
|
34
|
+
declare const GetFunctionMetadata: {
|
|
35
|
+
readonly kind: "query";
|
|
36
|
+
readonly idempotency: "none";
|
|
37
|
+
readonly authorization: "required";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Configuration for the getFunction connector Step. */
|
|
41
|
+
interface GetFunctionStepConfig<StepInput, OperationInput = GetFunctionInput, OperationOutput = FunctionDetails> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
42
|
+
/** Named connection supplying this operation. */
|
|
43
|
+
connection: Connection<{
|
|
44
|
+
getFunction(): Query<OperationInput, OperationOutput>;
|
|
45
|
+
}>;
|
|
46
|
+
/** Name matching the bound connection. */
|
|
47
|
+
connectionName: string;
|
|
48
|
+
/** AWS returned the function configuration. */
|
|
49
|
+
found: StepTarget<QueryResult<OperationOutput>>;
|
|
50
|
+
/** The function does not exist in the selected Region. */
|
|
51
|
+
missing?: StepTarget<QueryResult<OperationOutput>>;
|
|
52
|
+
/** AWS conclusively rejected the request or credentials. */
|
|
53
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
54
|
+
/** AWS returned malformed or oversized function metadata. */
|
|
55
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
56
|
+
/** The function name, endpoint, Region, or credentials are invalid. */
|
|
57
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
58
|
+
}
|
|
59
|
+
/** Build the getFunction Step from a named connection. */
|
|
60
|
+
declare function newGetFunctionStep<StepInput, OperationInput = GetFunctionInput, OperationOutput = FunctionDetails>(configuration: GetFunctionStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
61
|
+
|
|
62
|
+
/** Open one named Amazon Lambda connection from Dex project configuration. */
|
|
63
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
64
|
+
|
|
65
|
+
/** Injectable transport and clock for tests and local applications. */
|
|
66
|
+
interface AmazonLambdaClientOptions {
|
|
67
|
+
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
68
|
+
/** Signing clock; omitted uses the current time. */ now?: () => Date;
|
|
69
|
+
}
|
|
70
|
+
interface Exchange {
|
|
71
|
+
status: number;
|
|
72
|
+
body: Uint8Array;
|
|
73
|
+
retryAfterMs: number;
|
|
74
|
+
error?: 'credential' | 'request' | 'tooLarge';
|
|
75
|
+
}
|
|
76
|
+
/** Authenticated AWS Lambda client for signed GetFunction requests. */
|
|
77
|
+
declare class AmazonLambdaClient {
|
|
78
|
+
private readonly credentials;
|
|
79
|
+
private readonly endpoint;
|
|
80
|
+
private readonly region;
|
|
81
|
+
private readonly timeoutMs;
|
|
82
|
+
private readonly maxResponseBytes;
|
|
83
|
+
private readonly send;
|
|
84
|
+
private readonly now;
|
|
85
|
+
/** Validate the Region, endpoint, and limits without contacting AWS. */
|
|
86
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: AmazonLambdaClientOptions);
|
|
87
|
+
/** Bind the getFunction Query. */ getFunction(): GetFunctionOperation;
|
|
88
|
+
/** Sign and send one bounded GetFunction request. */
|
|
89
|
+
readFunction(call: Call, name: string): Promise<Exchange>;
|
|
90
|
+
}
|
|
91
|
+
/** Read the stable name and ARN of one Lambda function. */
|
|
92
|
+
declare class GetFunctionOperation implements Query<GetFunctionInput, FunctionDetails> {
|
|
93
|
+
private readonly client;
|
|
94
|
+
/** Bind the provider client. */ constructor(client: AmazonLambdaClient);
|
|
95
|
+
/** Return the generated Query contract. */ definition(): QueryDefinition;
|
|
96
|
+
/** Classify provider outcomes consistently with the Go implementation. */
|
|
97
|
+
invoke(call: Call, input: GetFunctionInput): Promise<QueryAttempt<FunctionDetails>>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { AmazonLambdaClient, type AmazonLambdaClientOptions, Config, Connection, ConnectorID, Credentials, FunctionDetails, GetFunctionBranch, GetFunctionBranchDefect, GetFunctionBranchFound, GetFunctionBranchInvalidResponse, GetFunctionBranchMissing, GetFunctionBranchProviderRejected, GetFunctionDefinition, GetFunctionInput, GetFunctionMetadata, GetFunctionOperation, type GetFunctionStepConfig, ProviderID, newGetFunctionStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
FunctionDetailsSchema,
|
|
6
|
+
GetFunctionBranch,
|
|
7
|
+
GetFunctionBranchDefect,
|
|
8
|
+
GetFunctionBranchFound,
|
|
9
|
+
GetFunctionBranchInvalidResponse,
|
|
10
|
+
GetFunctionBranchMissing,
|
|
11
|
+
GetFunctionBranchProviderRejected,
|
|
12
|
+
GetFunctionDefinition,
|
|
13
|
+
GetFunctionInputSchema,
|
|
14
|
+
GetFunctionMetadata,
|
|
15
|
+
ProviderID,
|
|
16
|
+
decodeCredentials,
|
|
17
|
+
newConnection,
|
|
18
|
+
newConnectionWithOperations,
|
|
19
|
+
newProjectConnection
|
|
20
|
+
} from "./chunk-G5OORMFR.js";
|
|
21
|
+
|
|
22
|
+
// src/generated/steps.ts
|
|
23
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
24
|
+
function newGetFunctionStep(configuration) {
|
|
25
|
+
const { connection, connectionName, found, missing, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
26
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
27
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getFunction(), connection: connection.reference, branches: [
|
|
28
|
+
goToBranch("found", found),
|
|
29
|
+
...missing ? [goToBranch("missing", missing)] : [],
|
|
30
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
31
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
32
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/project.ts
|
|
37
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
import { createHash, createHmac } from "crypto";
|
|
42
|
+
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
44
|
+
var emptyDetails = () => ({ name: "", arn: "" });
|
|
45
|
+
var functionNamePattern = /^[A-Za-z0-9_-]{1,64}$/;
|
|
46
|
+
var regionPattern = /^[a-z]{2}(?:-gov)?-[a-z]+-[0-9]+$/;
|
|
47
|
+
var AmazonLambdaClient = class {
|
|
48
|
+
/** Validate the Region, endpoint, and limits without contacting AWS. */
|
|
49
|
+
constructor(config, credentials, options = {}) {
|
|
50
|
+
this.credentials = credentials;
|
|
51
|
+
if (!config || !credentials) throw new TypeError("Lambda configuration and credentials are required");
|
|
52
|
+
this.region = config.region || "us-east-1";
|
|
53
|
+
if (!regionPattern.test(this.region)) throw new TypeError("Lambda Region is invalid");
|
|
54
|
+
this.endpoint = validateBaseURL(config.endpoint || `https://lambda.${this.region}.amazonaws.com`).replace(/\/+$/, "");
|
|
55
|
+
this.timeoutMs = config.timeoutMs || 15e3;
|
|
56
|
+
this.maxResponseBytes = config.maxResponseBytes || 2097152;
|
|
57
|
+
if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0)
|
|
58
|
+
throw new TypeError("Lambda request limits must be positive integers");
|
|
59
|
+
this.send = options.send ?? sendProviderRequest;
|
|
60
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
61
|
+
}
|
|
62
|
+
credentials;
|
|
63
|
+
endpoint;
|
|
64
|
+
region;
|
|
65
|
+
timeoutMs;
|
|
66
|
+
maxResponseBytes;
|
|
67
|
+
send;
|
|
68
|
+
now;
|
|
69
|
+
/** Bind the getFunction Query. */
|
|
70
|
+
getFunction() {
|
|
71
|
+
return new GetFunctionOperation(this);
|
|
72
|
+
}
|
|
73
|
+
/** Sign and send one bounded GetFunction request. */
|
|
74
|
+
async readFunction(call, name) {
|
|
75
|
+
let accessKey;
|
|
76
|
+
let secretKey;
|
|
77
|
+
let sessionToken;
|
|
78
|
+
try {
|
|
79
|
+
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
80
|
+
accessKey = credentials.accessKeyId instanceof SecretString ? credentials.accessKeyId.reveal() : "";
|
|
81
|
+
secretKey = credentials.secretAccessKey instanceof SecretString ? credentials.secretAccessKey.reveal() : "";
|
|
82
|
+
sessionToken = credentials.sessionToken instanceof SecretString ? credentials.sessionToken.reveal() : "";
|
|
83
|
+
} catch {
|
|
84
|
+
return emptyExchange("credential");
|
|
85
|
+
}
|
|
86
|
+
if (!accessKey || !secretKey || !isHeaderSafeCredential(accessKey) || !isHeaderSafeCredential(secretKey) || sessionToken && !isHeaderSafeCredential(sessionToken)) return emptyExchange("credential");
|
|
87
|
+
const url = `${this.endpoint}/2015-03-31/functions/${name}`;
|
|
88
|
+
const now = this.now();
|
|
89
|
+
const timestamp = now.toISOString().replace(/[-:]|\.\d{3}/g, "");
|
|
90
|
+
const day = timestamp.slice(0, 8);
|
|
91
|
+
const host = new URL(url).host;
|
|
92
|
+
const signedHeaders = sessionToken ? "host;x-amz-date;x-amz-security-token" : "host;x-amz-date";
|
|
93
|
+
const canonicalHeaders = `host:${host}
|
|
94
|
+
x-amz-date:${timestamp}
|
|
95
|
+
` + (sessionToken ? `x-amz-security-token:${sessionToken}
|
|
96
|
+
` : "");
|
|
97
|
+
const payloadHash = createHash("sha256").update("").digest("hex");
|
|
98
|
+
const canonicalRequest = `GET
|
|
99
|
+
/2015-03-31/functions/${name}
|
|
100
|
+
|
|
101
|
+
${canonicalHeaders}
|
|
102
|
+
${signedHeaders}
|
|
103
|
+
${payloadHash}`;
|
|
104
|
+
const scope = `${day}/${this.region}/lambda/aws4_request`;
|
|
105
|
+
const stringToSign = `AWS4-HMAC-SHA256
|
|
106
|
+
${timestamp}
|
|
107
|
+
${scope}
|
|
108
|
+
${createHash("sha256").update(canonicalRequest).digest("hex")}`;
|
|
109
|
+
const hmac = (key, value) => createHmac("sha256", key).update(value).digest();
|
|
110
|
+
const signingKey = hmac(hmac(hmac(hmac(`AWS4${secretKey}`, day), this.region), "lambda"), "aws4_request");
|
|
111
|
+
const signature = createHmac("sha256", signingKey).update(stringToSign).digest("hex");
|
|
112
|
+
const headers = {
|
|
113
|
+
"X-Amz-Date": timestamp,
|
|
114
|
+
Authorization: `AWS4-HMAC-SHA256 Credential=${accessKey}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
115
|
+
};
|
|
116
|
+
if (sessionToken) headers["X-Amz-Security-Token"] = sessionToken;
|
|
117
|
+
const request = {
|
|
118
|
+
url,
|
|
119
|
+
method: "GET",
|
|
120
|
+
headers,
|
|
121
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
122
|
+
timeoutMs: this.timeoutMs,
|
|
123
|
+
addressPolicy: this.endpoint.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
124
|
+
signal: call.context.cancellationSignal
|
|
125
|
+
};
|
|
126
|
+
let response;
|
|
127
|
+
let isTooLarge = false;
|
|
128
|
+
try {
|
|
129
|
+
response = await this.send(request);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0) {
|
|
132
|
+
response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
133
|
+
isTooLarge = true;
|
|
134
|
+
} else return emptyExchange("request");
|
|
135
|
+
}
|
|
136
|
+
const retryAfterMs = parseRetryAfter(header(response.headers, "retry-after"));
|
|
137
|
+
if (isTooLarge || response.body.length > this.maxResponseBytes)
|
|
138
|
+
return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
|
|
139
|
+
if ([accessKey, secretKey, sessionToken].some((secret) => secret && Buffer.from(response.body).includes(secret)))
|
|
140
|
+
return { ...emptyExchange("credential"), status: response.status, retryAfterMs };
|
|
141
|
+
return { status: response.status, body: response.body, retryAfterMs };
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var GetFunctionOperation = class {
|
|
145
|
+
/** Bind the provider client. */
|
|
146
|
+
constructor(client) {
|
|
147
|
+
this.client = client;
|
|
148
|
+
}
|
|
149
|
+
client;
|
|
150
|
+
/** Return the generated Query contract. */
|
|
151
|
+
definition() {
|
|
152
|
+
return GetFunctionDefinition;
|
|
153
|
+
}
|
|
154
|
+
/** Classify provider outcomes consistently with the Go implementation. */
|
|
155
|
+
async invoke(call, input) {
|
|
156
|
+
if (!input || typeof input.functionName !== "string" || !functionNamePattern.test(input.functionName))
|
|
157
|
+
return terminal("defect", "VALIDATION", "Lambda function name is invalid");
|
|
158
|
+
const exchange = await this.client.readFunction(call, input.functionName);
|
|
159
|
+
if (exchange.error === "credential") return terminal("defect", "AUTHENTICATION", "Lambda credentials are unavailable or invalid");
|
|
160
|
+
if (exchange.error === "request") return retry("TRANSPORT", "Lambda request failed");
|
|
161
|
+
if (exchange.status === 429) return retry("RATE_LIMIT", "Lambda rate limited the request", exchange.retryAfterMs);
|
|
162
|
+
if (exchange.status === 408 || exchange.status >= 500) return retry("AVAILABILITY", "Lambda is temporarily unavailable", exchange.retryAfterMs);
|
|
163
|
+
if (exchange.status === 404) return newQueryBranch("missing", emptyDetails());
|
|
164
|
+
if (exchange.status !== 200) return terminal("providerRejected", "PROVIDER_REJECTION", `Lambda rejected HTTP ${exchange.status}`);
|
|
165
|
+
if (exchange.error === "tooLarge") return terminal("invalidResponse", "RESPONSE_TOO_LARGE", "Lambda response exceeded the configured limit");
|
|
166
|
+
let document;
|
|
167
|
+
try {
|
|
168
|
+
document = JSON.parse(Buffer.from(exchange.body).toString("utf8"));
|
|
169
|
+
} catch {
|
|
170
|
+
return terminal("invalidResponse", "PROTOCOL", "Lambda returned invalid function JSON");
|
|
171
|
+
}
|
|
172
|
+
if (!isObject(document) || !isObject(document.Configuration) || document.Configuration.FunctionName !== input.functionName || typeof document.Configuration.FunctionArn !== "string" || !document.Configuration.FunctionArn)
|
|
173
|
+
return terminal("invalidResponse", "PROTOCOL", "Lambda returned invalid function JSON");
|
|
174
|
+
return newQueryBranch("found", { name: input.functionName, arn: document.Configuration.FunctionArn });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
function isObject(value) {
|
|
178
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
179
|
+
}
|
|
180
|
+
function emptyExchange(error) {
|
|
181
|
+
return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error };
|
|
182
|
+
}
|
|
183
|
+
function failure(kind, message) {
|
|
184
|
+
return { provider: "amazon-lambda", operation: "getFunction", kind, message };
|
|
185
|
+
}
|
|
186
|
+
function terminal(branch, kind, message) {
|
|
187
|
+
return newQueryBranch(branch, emptyDetails(), {}, failure(kind, message));
|
|
188
|
+
}
|
|
189
|
+
function retry(kind, message, delay = 0) {
|
|
190
|
+
return newQueryRetry(failure(kind, message), delay);
|
|
191
|
+
}
|
|
192
|
+
function header(headers, name) {
|
|
193
|
+
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
194
|
+
return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/project.ts
|
|
198
|
+
function newProjectConnection2(project, connectionName) {
|
|
199
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
200
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "amazon-lambda" && entry.connectionName === name);
|
|
201
|
+
if (!selected) throw new TypeError("Amazon Lambda project connection is not configured");
|
|
202
|
+
const fields = z.strictObject({ region: z.string().optional(), endpoint: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
|
|
203
|
+
const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
|
|
204
|
+
const config = {
|
|
205
|
+
...fields.region ? { region: fields.region } : {},
|
|
206
|
+
...fields.endpoint ? { endpoint: fields.endpoint } : {},
|
|
207
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
208
|
+
...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
|
|
209
|
+
};
|
|
210
|
+
const credentials = {
|
|
211
|
+
async resolve(_call, signal) {
|
|
212
|
+
const privateFields = await loadedProject.resolveCredential("amazon-lambda", name, signal);
|
|
213
|
+
if (typeof privateFields.access_key_id !== "string" || typeof privateFields.secret_access_key !== "string") throw new TypeError("Amazon Lambda credentials are unavailable");
|
|
214
|
+
return { accessKeyId: new SecretString2(privateFields.access_key_id), secretAccessKey: new SecretString2(privateFields.secret_access_key), sessionToken: new SecretString2(typeof privateFields.session_token === "string" ? privateFields.session_token : "") };
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
return new AmazonLambdaClient(config, credentials);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function parseDurationMilliseconds(value) {
|
|
221
|
+
let remaining = value;
|
|
222
|
+
let milliseconds = 0;
|
|
223
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
224
|
+
while (remaining) {
|
|
225
|
+
const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
226
|
+
if (!part) throw new TypeError("Amazon Lambda timeout must be a positive Go duration");
|
|
227
|
+
milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
|
|
228
|
+
remaining = remaining.slice(part[0].length);
|
|
229
|
+
}
|
|
230
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Amazon Lambda timeout must resolve to positive whole milliseconds");
|
|
231
|
+
return milliseconds;
|
|
232
|
+
}
|
|
233
|
+
export {
|
|
234
|
+
AmazonLambdaClient,
|
|
235
|
+
ConfigSchema,
|
|
236
|
+
Connection,
|
|
237
|
+
ConnectorID,
|
|
238
|
+
FunctionDetailsSchema,
|
|
239
|
+
GetFunctionBranch,
|
|
240
|
+
GetFunctionBranchDefect,
|
|
241
|
+
GetFunctionBranchFound,
|
|
242
|
+
GetFunctionBranchInvalidResponse,
|
|
243
|
+
GetFunctionBranchMissing,
|
|
244
|
+
GetFunctionBranchProviderRejected,
|
|
245
|
+
GetFunctionDefinition,
|
|
246
|
+
GetFunctionInputSchema,
|
|
247
|
+
GetFunctionMetadata,
|
|
248
|
+
GetFunctionOperation,
|
|
249
|
+
ProviderID,
|
|
250
|
+
decodeCredentials,
|
|
251
|
+
newConnection,
|
|
252
|
+
newConnectionWithOperations,
|
|
253
|
+
newGetFunctionStep,
|
|
254
|
+
newProjectConnection2 as newProjectConnection
|
|
255
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, G as GetFunctionInput, F as FunctionDetails } from './connection-B5yl3Wdb.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for GetFunctionInput in scripted cases. */
|
|
7
|
+
declare const emptyGetFunctionInput: GetFunctionInput;
|
|
8
|
+
/** Go zero value for FunctionDetails in scripted cases. */
|
|
9
|
+
declare const emptyFunctionDetails: FunctionDetails;
|
|
10
|
+
/** Script the found branch. */
|
|
11
|
+
declare function getFunctionFound(value: FunctionDetails, failure?: Failure): Case<FunctionDetails>;
|
|
12
|
+
/** Script the missing branch. */
|
|
13
|
+
declare function getFunctionMissing(value: FunctionDetails, failure?: Failure): Case<FunctionDetails>;
|
|
14
|
+
/** Script the providerRejected branch. */
|
|
15
|
+
declare function getFunctionProviderRejected(value: FunctionDetails, failure?: Failure): Case<FunctionDetails>;
|
|
16
|
+
/** Script the invalidResponse branch. */
|
|
17
|
+
declare function getFunctionInvalidResponse(value: FunctionDetails, failure?: Failure): Case<FunctionDetails>;
|
|
18
|
+
/** Script the defect branch. */
|
|
19
|
+
declare function getFunctionDefect(value: FunctionDetails, failure?: Failure): Case<FunctionDetails>;
|
|
20
|
+
/** Script a safe retry of getFunction. */
|
|
21
|
+
declare function getFunctionRetry(failure: Failure, retryAfterMs?: number): Case<FunctionDetails>;
|
|
22
|
+
/** Manifest scenario foundDefault for getFunction. */
|
|
23
|
+
declare function getFunctionFoundDefault(): Case<FunctionDetails>;
|
|
24
|
+
/** Default getFunction scenario. */
|
|
25
|
+
declare function getFunctionDefault(): Case<FunctionDetails>;
|
|
26
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
27
|
+
declare class GeneratedMock implements Operations {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(connectionName: string);
|
|
30
|
+
connection(): Connection;
|
|
31
|
+
getFunction(): MockQuery<GetFunctionInput, FunctionDetails>;
|
|
32
|
+
assertNoFailures(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { GeneratedMock, GeneratedMock as Mock, emptyFunctionDetails, emptyGetFunctionInput, getFunctionDefault, getFunctionDefect, getFunctionFound, getFunctionFoundDefault, getFunctionInvalidResponse, getFunctionMissing, getFunctionProviderRejected, getFunctionRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionDetailsSchema,
|
|
3
|
+
GetFunctionDefinition,
|
|
4
|
+
GetFunctionInputSchema,
|
|
5
|
+
ProviderID,
|
|
6
|
+
newConnectionWithOperations
|
|
7
|
+
} from "./chunk-G5OORMFR.js";
|
|
8
|
+
|
|
9
|
+
// src/generated/mock.ts
|
|
10
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
11
|
+
var emptyGetFunctionInput = GetFunctionInputSchema.parse({
|
|
12
|
+
"functionName": ""
|
|
13
|
+
});
|
|
14
|
+
var emptyFunctionDetails = FunctionDetailsSchema.parse({
|
|
15
|
+
"name": "",
|
|
16
|
+
"arn": ""
|
|
17
|
+
});
|
|
18
|
+
function getFunctionFound(value, failure) {
|
|
19
|
+
return branchCase("found", value, failure);
|
|
20
|
+
}
|
|
21
|
+
function getFunctionMissing(value, failure) {
|
|
22
|
+
return branchCase("missing", value, failure);
|
|
23
|
+
}
|
|
24
|
+
function getFunctionProviderRejected(value, failure) {
|
|
25
|
+
return branchCase("providerRejected", value, failure);
|
|
26
|
+
}
|
|
27
|
+
function getFunctionInvalidResponse(value, failure) {
|
|
28
|
+
return branchCase("invalidResponse", value, failure);
|
|
29
|
+
}
|
|
30
|
+
function getFunctionDefect(value, failure) {
|
|
31
|
+
return branchCase("defect", value, failure);
|
|
32
|
+
}
|
|
33
|
+
function getFunctionRetry(failure, retryAfterMs = 0) {
|
|
34
|
+
return retryCase(failure, retryAfterMs);
|
|
35
|
+
}
|
|
36
|
+
function getFunctionFoundDefault() {
|
|
37
|
+
const value = FunctionDetailsSchema.parse({ "arn": "arn:aws:lambda:us-east-1:123456789012:function:example-function", "name": "example-function" });
|
|
38
|
+
return branchCase("found", value);
|
|
39
|
+
}
|
|
40
|
+
function getFunctionDefault() {
|
|
41
|
+
return getFunctionFoundDefault();
|
|
42
|
+
}
|
|
43
|
+
var GeneratedMock = class {
|
|
44
|
+
#getFunction;
|
|
45
|
+
#connection;
|
|
46
|
+
constructor(connectionName) {
|
|
47
|
+
this.#getFunction = newQuery(GetFunctionDefinition).default(getFunctionDefault());
|
|
48
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
49
|
+
}
|
|
50
|
+
connection() {
|
|
51
|
+
return this.#connection;
|
|
52
|
+
}
|
|
53
|
+
getFunction() {
|
|
54
|
+
return this.#getFunction;
|
|
55
|
+
}
|
|
56
|
+
assertNoFailures() {
|
|
57
|
+
this.#getFunction.assertNoFailures();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
GeneratedMock,
|
|
62
|
+
GeneratedMock as Mock,
|
|
63
|
+
emptyFunctionDetails,
|
|
64
|
+
emptyGetFunctionInput,
|
|
65
|
+
getFunctionDefault,
|
|
66
|
+
getFunctionDefect,
|
|
67
|
+
getFunctionFound,
|
|
68
|
+
getFunctionFoundDefault,
|
|
69
|
+
getFunctionInvalidResponse,
|
|
70
|
+
getFunctionMissing,
|
|
71
|
+
getFunctionProviderRejected,
|
|
72
|
+
getFunctionRetry
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-amazon-lambda",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Amazon Lambda connector for Dex TypeScript applications",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/amazon/lambda/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./mock": {
|
|
23
|
+
"types": "./dist/mock.d.ts",
|
|
24
|
+
"import": "./dist/mock.js"
|
|
25
|
+
},
|
|
26
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"dex-connector.json"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "eslint src test examples",
|
|
39
|
+
"test": "vitest run --exclude test/integration/**",
|
|
40
|
+
"test:integration": "vitest run test/integration/*.integration.test.ts",
|
|
41
|
+
"example:worker": "tsx examples/function-lookup/worker.ts",
|
|
42
|
+
"example:start": "tsx examples/function-lookup/start.ts",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm test && npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@superdurable/connectors-sdk": "0.1.1",
|
|
47
|
+
"@superdurable/dex": ">=1.28.0",
|
|
48
|
+
"zod": "^4.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/js": "^9.0.0",
|
|
52
|
+
"@types/node": "^22.0.0",
|
|
53
|
+
"eslint": "^9.0.0",
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"tsx": "^4.23.15",
|
|
56
|
+
"typescript": "^5.9.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"vitest": "^3.0.0",
|
|
59
|
+
"yaml": "^2.9.1"
|
|
60
|
+
}
|
|
61
|
+
}
|