@superdurable/connector-amazon-lambda 0.1.0 → 0.2.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/README.md +2 -0
- package/dex-connector.json +159 -2
- package/dist/chunk-HI4S6PQZ.js +234 -0
- package/dist/connection-Cqa6vZYT.d.ts +142 -0
- package/dist/index.d.ts +162 -4
- package/dist/index.js +303 -19
- package/dist/mock.d.ts +58 -3
- package/dist/mock.js +139 -3
- package/package.json +1 -1
- package/dist/chunk-G5OORMFR.js +0 -111
- package/dist/connection-B5yl3Wdb.d.ts +0 -73
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
|
|
1
|
+
import { D as DeleteFunctionInput, F as FunctionWriteResult, C as Connection, G as GetFunctionInput, a as FunctionDetails, L as ListFunctionsInput, b as FunctionPage, U as UpdateFunctionDescriptionInput, O as Operations, c as Config, d as Credentials } from './connection-Cqa6vZYT.js';
|
|
2
|
+
export { e as ConfigSchema, f as CredentialMaterialError, g as CredentialSource, h as DeleteFunctionInputSchema, i as FunctionDetailsSchema, j as FunctionPageSchema, k as FunctionWriteResultSchema, l as GetFunctionInputSchema, m as ListFunctionsInputSchema, n as UpdateFunctionDescriptionInputSchema, o as decodeCredentials, p as isCredentialMaterialError, q as newConnection, r as newConnectionWithOperations } from './connection-Cqa6vZYT.js';
|
|
3
|
+
import { MutationDefinition, QueryDefinition, MutationStepConfig, Mutation, MutationResult, QueryStepConfig, Query, QueryResult, MutationStep, QueryStep, CredentialProvider, Call, QueryAttempt, MutationAttempt } from '@superdurable/connectors-sdk';
|
|
4
4
|
import { StepTarget } from '@superdurable/dex';
|
|
5
5
|
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
6
6
|
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
@@ -36,6 +36,75 @@ declare const GetFunctionMetadata: {
|
|
|
36
36
|
readonly idempotency: "none";
|
|
37
37
|
readonly authorization: "required";
|
|
38
38
|
};
|
|
39
|
+
/** Branch IDs for listFunctions. */
|
|
40
|
+
declare const ListFunctionsBranch: {
|
|
41
|
+
readonly Listed: "listed";
|
|
42
|
+
readonly ProviderRejected: "providerRejected";
|
|
43
|
+
readonly InvalidResponse: "invalidResponse";
|
|
44
|
+
readonly Defect: "defect";
|
|
45
|
+
};
|
|
46
|
+
/** AWS returned a page of functions. */
|
|
47
|
+
declare const ListFunctionsBranchListed: "listed";
|
|
48
|
+
/** AWS conclusively rejected the request or credentials. */
|
|
49
|
+
declare const ListFunctionsBranchProviderRejected: "providerRejected";
|
|
50
|
+
/** AWS returned malformed or oversized function metadata. */
|
|
51
|
+
declare const ListFunctionsBranchInvalidResponse: "invalidResponse";
|
|
52
|
+
/** The page input or connection settings are invalid. */
|
|
53
|
+
declare const ListFunctionsBranchDefect: "defect";
|
|
54
|
+
/** Manifest definition for listFunctions. */
|
|
55
|
+
declare const ListFunctionsDefinition: QueryDefinition;
|
|
56
|
+
/** Manifest metadata for listFunctions. */
|
|
57
|
+
declare const ListFunctionsMetadata: {
|
|
58
|
+
readonly kind: "query";
|
|
59
|
+
readonly idempotency: "none";
|
|
60
|
+
readonly authorization: "required";
|
|
61
|
+
};
|
|
62
|
+
/** Branch IDs for updateFunctionDescription. */
|
|
63
|
+
declare const UpdateFunctionDescriptionBranch: {
|
|
64
|
+
readonly Updated: "updated";
|
|
65
|
+
readonly Missing: "missing";
|
|
66
|
+
readonly ProviderRejected: "providerRejected";
|
|
67
|
+
readonly InvalidResponse: "invalidResponse";
|
|
68
|
+
readonly Defect: "defect";
|
|
69
|
+
};
|
|
70
|
+
/** AWS accepted the description update. */
|
|
71
|
+
declare const UpdateFunctionDescriptionBranchUpdated: "updated";
|
|
72
|
+
/** The function does not exist. */
|
|
73
|
+
declare const UpdateFunctionDescriptionBranchMissing: "missing";
|
|
74
|
+
/** AWS conclusively rejected the update. */
|
|
75
|
+
declare const UpdateFunctionDescriptionBranchProviderRejected: "providerRejected";
|
|
76
|
+
/** AWS returned malformed or oversized metadata. */
|
|
77
|
+
declare const UpdateFunctionDescriptionBranchInvalidResponse: "invalidResponse";
|
|
78
|
+
/** The update input or connection settings are invalid. */
|
|
79
|
+
declare const UpdateFunctionDescriptionBranchDefect: "defect";
|
|
80
|
+
/** Manifest definition for updateFunctionDescription. */
|
|
81
|
+
declare const UpdateFunctionDescriptionDefinition: MutationDefinition;
|
|
82
|
+
/** Manifest metadata for updateFunctionDescription. */
|
|
83
|
+
declare const UpdateFunctionDescriptionMetadata: {
|
|
84
|
+
readonly kind: "mutation";
|
|
85
|
+
readonly idempotency: "required";
|
|
86
|
+
readonly authorization: "required";
|
|
87
|
+
};
|
|
88
|
+
/** Branch IDs for deleteFunction. */
|
|
89
|
+
declare const DeleteFunctionBranch: {
|
|
90
|
+
readonly Deleted: "deleted";
|
|
91
|
+
readonly ProviderRejected: "providerRejected";
|
|
92
|
+
readonly Defect: "defect";
|
|
93
|
+
};
|
|
94
|
+
/** The function is absent after deletion. */
|
|
95
|
+
declare const DeleteFunctionBranchDeleted: "deleted";
|
|
96
|
+
/** AWS conclusively rejected the deletion. */
|
|
97
|
+
declare const DeleteFunctionBranchProviderRejected: "providerRejected";
|
|
98
|
+
/** The function name or connection settings are invalid. */
|
|
99
|
+
declare const DeleteFunctionBranchDefect: "defect";
|
|
100
|
+
/** Manifest definition for deleteFunction. */
|
|
101
|
+
declare const DeleteFunctionDefinition: MutationDefinition;
|
|
102
|
+
/** Manifest metadata for deleteFunction. */
|
|
103
|
+
declare const DeleteFunctionMetadata: {
|
|
104
|
+
readonly kind: "mutation";
|
|
105
|
+
readonly idempotency: "required";
|
|
106
|
+
readonly authorization: "required";
|
|
107
|
+
};
|
|
39
108
|
|
|
40
109
|
/** Configuration for the getFunction connector Step. */
|
|
41
110
|
interface GetFunctionStepConfig<StepInput, OperationInput = GetFunctionInput, OperationOutput = FunctionDetails> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
@@ -58,10 +127,68 @@ interface GetFunctionStepConfig<StepInput, OperationInput = GetFunctionInput, Op
|
|
|
58
127
|
}
|
|
59
128
|
/** Build the getFunction Step from a named connection. */
|
|
60
129
|
declare function newGetFunctionStep<StepInput, OperationInput = GetFunctionInput, OperationOutput = FunctionDetails>(configuration: GetFunctionStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
130
|
+
/** Configuration for the listFunctions connector Step. */
|
|
131
|
+
interface ListFunctionsStepConfig<StepInput, OperationInput = ListFunctionsInput, OperationOutput = FunctionPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
132
|
+
/** Named connection supplying this operation. */
|
|
133
|
+
connection: Connection<{
|
|
134
|
+
listFunctions(): Query<OperationInput, OperationOutput>;
|
|
135
|
+
}>;
|
|
136
|
+
/** Name matching the bound connection. */
|
|
137
|
+
connectionName: string;
|
|
138
|
+
/** AWS returned a page of functions. */
|
|
139
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
140
|
+
/** AWS conclusively rejected the request or credentials. */
|
|
141
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
142
|
+
/** AWS returned malformed or oversized function metadata. */
|
|
143
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
144
|
+
/** The page input or connection settings are invalid. */
|
|
145
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
146
|
+
}
|
|
147
|
+
/** Build the listFunctions Step from a named connection. */
|
|
148
|
+
declare function newListFunctionsStep<StepInput, OperationInput = ListFunctionsInput, OperationOutput = FunctionPage>(configuration: ListFunctionsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
149
|
+
/** Configuration for the updateFunctionDescription connector Step. */
|
|
150
|
+
interface UpdateFunctionDescriptionStepConfig<StepInput, OperationInput = UpdateFunctionDescriptionInput, OperationOutput = FunctionDetails> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
151
|
+
/** Named connection supplying this operation. */
|
|
152
|
+
connection: Connection<{
|
|
153
|
+
updateFunctionDescription(): Mutation<OperationInput, OperationOutput>;
|
|
154
|
+
}>;
|
|
155
|
+
/** Name matching the bound connection. */
|
|
156
|
+
connectionName: string;
|
|
157
|
+
/** AWS accepted the description update. */
|
|
158
|
+
updated: StepTarget<MutationResult<OperationOutput>>;
|
|
159
|
+
/** The function does not exist. */
|
|
160
|
+
missing?: StepTarget<MutationResult<OperationOutput>>;
|
|
161
|
+
/** AWS conclusively rejected the update. */
|
|
162
|
+
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
163
|
+
/** AWS returned malformed or oversized metadata. */
|
|
164
|
+
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
165
|
+
/** The update input or connection settings are invalid. */
|
|
166
|
+
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
167
|
+
}
|
|
168
|
+
/** Build the updateFunctionDescription Step from a named connection. */
|
|
169
|
+
declare function newUpdateFunctionDescriptionStep<StepInput, OperationInput = UpdateFunctionDescriptionInput, OperationOutput = FunctionDetails>(configuration: UpdateFunctionDescriptionStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
170
|
+
/** Configuration for the deleteFunction connector Step. */
|
|
171
|
+
interface DeleteFunctionStepConfig<StepInput, OperationInput = DeleteFunctionInput, OperationOutput = FunctionWriteResult> extends Omit<MutationStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
172
|
+
/** Named connection supplying this operation. */
|
|
173
|
+
connection: Connection<{
|
|
174
|
+
deleteFunction(): Mutation<OperationInput, OperationOutput>;
|
|
175
|
+
}>;
|
|
176
|
+
/** Name matching the bound connection. */
|
|
177
|
+
connectionName: string;
|
|
178
|
+
/** The function is absent after deletion. */
|
|
179
|
+
deleted: StepTarget<MutationResult<OperationOutput>>;
|
|
180
|
+
/** AWS conclusively rejected the deletion. */
|
|
181
|
+
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
182
|
+
/** The function name or connection settings are invalid. */
|
|
183
|
+
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
184
|
+
}
|
|
185
|
+
/** Build the deleteFunction Step from a named connection. */
|
|
186
|
+
declare function newDeleteFunctionStep<StepInput, OperationInput = DeleteFunctionInput, OperationOutput = FunctionWriteResult>(configuration: DeleteFunctionStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
61
187
|
|
|
62
188
|
/** Open one named Amazon Lambda connection from Dex project configuration. */
|
|
63
189
|
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
64
190
|
|
|
191
|
+
declare const sendFunctionRequest: unique symbol;
|
|
65
192
|
/** Injectable transport and clock for tests and local applications. */
|
|
66
193
|
interface AmazonLambdaClientOptions {
|
|
67
194
|
/** Provider sender; omitted uses the SDK transport. */ send?: (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
@@ -84,9 +211,14 @@ declare class AmazonLambdaClient {
|
|
|
84
211
|
private readonly now;
|
|
85
212
|
/** Validate the Region, endpoint, and limits without contacting AWS. */
|
|
86
213
|
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: AmazonLambdaClientOptions);
|
|
214
|
+
/** Bind the listFunctions operation. */ listFunctions(): ListFunctionsOperation;
|
|
215
|
+
/** Bind the updateFunctionDescription operation. */ updateFunctionDescription(): UpdateFunctionDescriptionOperation;
|
|
216
|
+
/** Bind the deleteFunction operation. */ deleteFunction(): DeleteFunctionOperation;
|
|
87
217
|
/** Bind the getFunction Query. */ getFunction(): GetFunctionOperation;
|
|
88
218
|
/** Sign and send one bounded GetFunction request. */
|
|
89
219
|
readFunction(call: Call, name: string): Promise<Exchange>;
|
|
220
|
+
/** Sign and send a bounded Lambda API request using the credentials for this attempt. */
|
|
221
|
+
[sendFunctionRequest](call: Call, method: 'GET' | 'PUT' | 'DELETE', path: string, body?: Uint8Array): Promise<Exchange>;
|
|
90
222
|
}
|
|
91
223
|
/** Read the stable name and ARN of one Lambda function. */
|
|
92
224
|
declare class GetFunctionOperation implements Query<GetFunctionInput, FunctionDetails> {
|
|
@@ -96,5 +228,31 @@ declare class GetFunctionOperation implements Query<GetFunctionInput, FunctionDe
|
|
|
96
228
|
/** Classify provider outcomes consistently with the Go implementation. */
|
|
97
229
|
invoke(call: Call, input: GetFunctionInput): Promise<QueryAttempt<FunctionDetails>>;
|
|
98
230
|
}
|
|
231
|
+
/** Read one bounded page of Lambda functions in the configured Region. */
|
|
232
|
+
declare class ListFunctionsOperation implements Query<ListFunctionsInput, FunctionPage> {
|
|
233
|
+
private readonly client;
|
|
234
|
+
/** Bind the signed provider client. */ constructor(client: AmazonLambdaClient);
|
|
235
|
+
/** Return the manifest Query definition. */ definition(): QueryDefinition;
|
|
236
|
+
/** Return function names, ARNs, and the next marker. */
|
|
237
|
+
invoke(call: Call, input: ListFunctionsInput): Promise<QueryAttempt<FunctionPage>>;
|
|
238
|
+
}
|
|
239
|
+
/** Replace the complete unpublished function description. */
|
|
240
|
+
declare class UpdateFunctionDescriptionOperation implements Mutation<UpdateFunctionDescriptionInput, FunctionDetails> {
|
|
241
|
+
private readonly client;
|
|
242
|
+
/** Bind the signed provider client. */ constructor(client: AmazonLambdaClient);
|
|
243
|
+
/** Return the generated Mutation definition. */ definition(): QueryDefinition;
|
|
244
|
+
/** Use the Dex Call ID for the idempotent mutation. */ idempotencyKey(callId: string): string;
|
|
245
|
+
/** Classify one signed provider write. */
|
|
246
|
+
invoke(call: Call, input: UpdateFunctionDescriptionInput): Promise<MutationAttempt<FunctionDetails>>;
|
|
247
|
+
}
|
|
248
|
+
/** Delete a named function and its versions and aliases. */
|
|
249
|
+
declare class DeleteFunctionOperation implements Mutation<DeleteFunctionInput, FunctionWriteResult> {
|
|
250
|
+
private readonly client;
|
|
251
|
+
/** Bind the signed provider client. */ constructor(client: AmazonLambdaClient);
|
|
252
|
+
/** Return the generated Mutation definition. */ definition(): QueryDefinition;
|
|
253
|
+
/** Use the Dex Call ID for the idempotent mutation. */ idempotencyKey(callId: string): string;
|
|
254
|
+
/** Classify one signed provider write. */
|
|
255
|
+
invoke(call: Call, input: DeleteFunctionInput): Promise<MutationAttempt<FunctionWriteResult>>;
|
|
256
|
+
}
|
|
99
257
|
|
|
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 };
|
|
258
|
+
export { AmazonLambdaClient, type AmazonLambdaClientOptions, Config, Connection, ConnectorID, Credentials, DeleteFunctionBranch, DeleteFunctionBranchDefect, DeleteFunctionBranchDeleted, DeleteFunctionBranchProviderRejected, DeleteFunctionDefinition, DeleteFunctionInput, DeleteFunctionMetadata, DeleteFunctionOperation, type DeleteFunctionStepConfig, FunctionDetails, FunctionPage, FunctionWriteResult, GetFunctionBranch, GetFunctionBranchDefect, GetFunctionBranchFound, GetFunctionBranchInvalidResponse, GetFunctionBranchMissing, GetFunctionBranchProviderRejected, GetFunctionDefinition, GetFunctionInput, GetFunctionMetadata, GetFunctionOperation, type GetFunctionStepConfig, ListFunctionsBranch, ListFunctionsBranchDefect, ListFunctionsBranchInvalidResponse, ListFunctionsBranchListed, ListFunctionsBranchProviderRejected, ListFunctionsDefinition, ListFunctionsInput, ListFunctionsMetadata, ListFunctionsOperation, type ListFunctionsStepConfig, ProviderID, UpdateFunctionDescriptionBranch, UpdateFunctionDescriptionBranchDefect, UpdateFunctionDescriptionBranchInvalidResponse, UpdateFunctionDescriptionBranchMissing, UpdateFunctionDescriptionBranchProviderRejected, UpdateFunctionDescriptionBranchUpdated, UpdateFunctionDescriptionDefinition, UpdateFunctionDescriptionInput, UpdateFunctionDescriptionMetadata, UpdateFunctionDescriptionOperation, type UpdateFunctionDescriptionStepConfig, newDeleteFunctionStep, newGetFunctionStep, newListFunctionsStep, newProjectConnection, newUpdateFunctionDescriptionStep };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,17 @@ import {
|
|
|
2
2
|
ConfigSchema,
|
|
3
3
|
Connection,
|
|
4
4
|
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
6
|
+
DeleteFunctionBranch,
|
|
7
|
+
DeleteFunctionBranchDefect,
|
|
8
|
+
DeleteFunctionBranchDeleted,
|
|
9
|
+
DeleteFunctionBranchProviderRejected,
|
|
10
|
+
DeleteFunctionDefinition,
|
|
11
|
+
DeleteFunctionInputSchema,
|
|
12
|
+
DeleteFunctionMetadata,
|
|
5
13
|
FunctionDetailsSchema,
|
|
14
|
+
FunctionPageSchema,
|
|
15
|
+
FunctionWriteResultSchema,
|
|
6
16
|
GetFunctionBranch,
|
|
7
17
|
GetFunctionBranchDefect,
|
|
8
18
|
GetFunctionBranchFound,
|
|
@@ -12,15 +22,33 @@ import {
|
|
|
12
22
|
GetFunctionDefinition,
|
|
13
23
|
GetFunctionInputSchema,
|
|
14
24
|
GetFunctionMetadata,
|
|
25
|
+
ListFunctionsBranch,
|
|
26
|
+
ListFunctionsBranchDefect,
|
|
27
|
+
ListFunctionsBranchInvalidResponse,
|
|
28
|
+
ListFunctionsBranchListed,
|
|
29
|
+
ListFunctionsBranchProviderRejected,
|
|
30
|
+
ListFunctionsDefinition,
|
|
31
|
+
ListFunctionsInputSchema,
|
|
32
|
+
ListFunctionsMetadata,
|
|
15
33
|
ProviderID,
|
|
34
|
+
UpdateFunctionDescriptionBranch,
|
|
35
|
+
UpdateFunctionDescriptionBranchDefect,
|
|
36
|
+
UpdateFunctionDescriptionBranchInvalidResponse,
|
|
37
|
+
UpdateFunctionDescriptionBranchMissing,
|
|
38
|
+
UpdateFunctionDescriptionBranchProviderRejected,
|
|
39
|
+
UpdateFunctionDescriptionBranchUpdated,
|
|
40
|
+
UpdateFunctionDescriptionDefinition,
|
|
41
|
+
UpdateFunctionDescriptionInputSchema,
|
|
42
|
+
UpdateFunctionDescriptionMetadata,
|
|
16
43
|
decodeCredentials,
|
|
44
|
+
isCredentialMaterialError,
|
|
17
45
|
newConnection,
|
|
18
46
|
newConnectionWithOperations,
|
|
19
47
|
newProjectConnection
|
|
20
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-HI4S6PQZ.js";
|
|
21
49
|
|
|
22
50
|
// src/generated/steps.ts
|
|
23
|
-
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
51
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
24
52
|
function newGetFunctionStep(configuration) {
|
|
25
53
|
const { connection, connectionName, found, missing, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
26
54
|
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
@@ -32,6 +60,36 @@ function newGetFunctionStep(configuration) {
|
|
|
32
60
|
...defect ? [goToBranch("defect", defect)] : []
|
|
33
61
|
] });
|
|
34
62
|
}
|
|
63
|
+
function newListFunctionsStep(configuration) {
|
|
64
|
+
const { connection, connectionName, listed, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
65
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
66
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listFunctions(), connection: connection.reference, branches: [
|
|
67
|
+
goToBranch("listed", listed),
|
|
68
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
69
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
70
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
function newUpdateFunctionDescriptionStep(configuration) {
|
|
74
|
+
const { connection, connectionName, updated, missing, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
75
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
76
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateFunctionDescription(), connection: connection.reference, branches: [
|
|
77
|
+
goToBranch("updated", updated),
|
|
78
|
+
...missing ? [goToBranch("missing", missing)] : [],
|
|
79
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
80
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
81
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function newDeleteFunctionStep(configuration) {
|
|
85
|
+
const { connection, connectionName, deleted, providerRejected, defect, ...stepConfiguration } = configuration;
|
|
86
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
87
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteFunction(), connection: connection.reference, branches: [
|
|
88
|
+
goToBranch("deleted", deleted),
|
|
89
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
90
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
35
93
|
|
|
36
94
|
// src/project.ts
|
|
37
95
|
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
@@ -39,8 +97,9 @@ import { z } from "zod";
|
|
|
39
97
|
|
|
40
98
|
// src/client.ts
|
|
41
99
|
import { createHash, createHmac } from "crypto";
|
|
42
|
-
import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
100
|
+
import { SecretString, newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
43
101
|
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
102
|
+
var sendFunctionRequest = /* @__PURE__ */ Symbol("sendFunctionRequest");
|
|
44
103
|
var emptyDetails = () => ({ name: "", arn: "" });
|
|
45
104
|
var functionNamePattern = /^[A-Za-z0-9_-]{1,64}$/;
|
|
46
105
|
var regionPattern = /^[a-z]{2}(?:-gov)?-[a-z]+-[0-9]+$/;
|
|
@@ -66,12 +125,28 @@ var AmazonLambdaClient = class {
|
|
|
66
125
|
maxResponseBytes;
|
|
67
126
|
send;
|
|
68
127
|
now;
|
|
128
|
+
/** Bind the listFunctions operation. */
|
|
129
|
+
listFunctions() {
|
|
130
|
+
return new ListFunctionsOperation(this);
|
|
131
|
+
}
|
|
132
|
+
/** Bind the updateFunctionDescription operation. */
|
|
133
|
+
updateFunctionDescription() {
|
|
134
|
+
return new UpdateFunctionDescriptionOperation(this);
|
|
135
|
+
}
|
|
136
|
+
/** Bind the deleteFunction operation. */
|
|
137
|
+
deleteFunction() {
|
|
138
|
+
return new DeleteFunctionOperation(this);
|
|
139
|
+
}
|
|
69
140
|
/** Bind the getFunction Query. */
|
|
70
141
|
getFunction() {
|
|
71
142
|
return new GetFunctionOperation(this);
|
|
72
143
|
}
|
|
73
144
|
/** Sign and send one bounded GetFunction request. */
|
|
74
145
|
async readFunction(call, name) {
|
|
146
|
+
return this[sendFunctionRequest](call, "GET", "/2015-03-31/functions/" + name);
|
|
147
|
+
}
|
|
148
|
+
/** Sign and send a bounded Lambda API request using the credentials for this attempt. */
|
|
149
|
+
async [sendFunctionRequest](call, method, path, body) {
|
|
75
150
|
let accessKey;
|
|
76
151
|
let secretKey;
|
|
77
152
|
let sessionToken;
|
|
@@ -84,23 +159,23 @@ var AmazonLambdaClient = class {
|
|
|
84
159
|
return emptyExchange("credential");
|
|
85
160
|
}
|
|
86
161
|
if (!accessKey || !secretKey || !isHeaderSafeCredential(accessKey) || !isHeaderSafeCredential(secretKey) || sessionToken && !isHeaderSafeCredential(sessionToken)) return emptyExchange("credential");
|
|
87
|
-
const url =
|
|
162
|
+
const url = this.endpoint + path;
|
|
88
163
|
const now = this.now();
|
|
89
164
|
const timestamp = now.toISOString().replace(/[-:]|\.\d{3}/g, "");
|
|
90
165
|
const day = timestamp.slice(0, 8);
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
166
|
+
const target = new URL(url);
|
|
167
|
+
const fields = { host: target.host, "x-amz-date": timestamp };
|
|
168
|
+
if (body) {
|
|
169
|
+
fields["content-type"] = "application/json";
|
|
170
|
+
fields["content-length"] = String(body.byteLength);
|
|
171
|
+
}
|
|
172
|
+
if (sessionToken) fields["x-amz-security-token"] = sessionToken;
|
|
173
|
+
const names = Object.keys(fields).sort();
|
|
174
|
+
const signedHeaders = names.join(";");
|
|
175
|
+
const canonicalHeaders = names.map((name) => name + ":" + fields[name].trim().replace(/\s+/g, " ") + "\n").join("");
|
|
176
|
+
const payloadHash = createHash("sha256").update(body ?? "").digest("hex");
|
|
177
|
+
const canonicalPath = target.pathname.split("/").map(awsEscape).join("/");
|
|
178
|
+
const canonicalRequest = [method, canonicalPath, target.search.slice(1), canonicalHeaders, signedHeaders, payloadHash].join("\n");
|
|
104
179
|
const scope = `${day}/${this.region}/lambda/aws4_request`;
|
|
105
180
|
const stringToSign = `AWS4-HMAC-SHA256
|
|
106
181
|
${timestamp}
|
|
@@ -113,11 +188,13 @@ ${createHash("sha256").update(canonicalRequest).digest("hex")}`;
|
|
|
113
188
|
"X-Amz-Date": timestamp,
|
|
114
189
|
Authorization: `AWS4-HMAC-SHA256 Credential=${accessKey}/${scope}, SignedHeaders=${signedHeaders}, Signature=${signature}`
|
|
115
190
|
};
|
|
191
|
+
if (body) headers["Content-Type"] = "application/json";
|
|
116
192
|
if (sessionToken) headers["X-Amz-Security-Token"] = sessionToken;
|
|
117
193
|
const request = {
|
|
118
194
|
url,
|
|
119
|
-
method
|
|
195
|
+
method,
|
|
120
196
|
headers,
|
|
197
|
+
...body ? { body } : {},
|
|
121
198
|
maxResponseBytes: this.maxResponseBytes,
|
|
122
199
|
timeoutMs: this.timeoutMs,
|
|
123
200
|
addressPolicy: this.endpoint.startsWith("https://") ? "publicHTTPS" : "privateNetworkHTTP",
|
|
@@ -193,6 +270,179 @@ function header(headers, name) {
|
|
|
193
270
|
const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
194
271
|
return Array.isArray(entry) ? entry[0] ?? "" : entry ?? "";
|
|
195
272
|
}
|
|
273
|
+
function awsEscape(value) {
|
|
274
|
+
return encodeURIComponent(value).replace(
|
|
275
|
+
/[!'()*]/g,
|
|
276
|
+
(character) => "%" + character.charCodeAt(0).toString(16).toUpperCase()
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
function responseFields(body) {
|
|
280
|
+
return lowerCaseFields(JSON.parse(Buffer.from(body).toString("utf8")));
|
|
281
|
+
}
|
|
282
|
+
function lowerCaseFields(value) {
|
|
283
|
+
if (!isObject(value)) throw new TypeError("invalid Lambda response");
|
|
284
|
+
return Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
|
|
285
|
+
}
|
|
286
|
+
function identity(value) {
|
|
287
|
+
const fields = lowerCaseFields(value);
|
|
288
|
+
if (typeof fields.functionname !== "string" || !fields.functionname || typeof fields.functionarn !== "string" || !fields.functionarn)
|
|
289
|
+
throw new TypeError("invalid Lambda identity");
|
|
290
|
+
return { name: fields.functionname, arn: fields.functionarn };
|
|
291
|
+
}
|
|
292
|
+
function operationFailure(operation, kind) {
|
|
293
|
+
return {
|
|
294
|
+
operation,
|
|
295
|
+
kind,
|
|
296
|
+
provider: "amazon-lambda",
|
|
297
|
+
message: "Lambda function operation could not be confirmed"
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
var ListFunctionsOperation = class {
|
|
301
|
+
/** Bind the signed provider client. */
|
|
302
|
+
constructor(client) {
|
|
303
|
+
this.client = client;
|
|
304
|
+
}
|
|
305
|
+
client;
|
|
306
|
+
/** Return the manifest Query definition. */
|
|
307
|
+
definition() {
|
|
308
|
+
return ListFunctionsDefinition;
|
|
309
|
+
}
|
|
310
|
+
/** Return function names, ARNs, and the next marker. */
|
|
311
|
+
async invoke(call, input) {
|
|
312
|
+
const marker = input.marker ?? "", maxItems = input.maxItems ?? 0;
|
|
313
|
+
const failed = (kind) => operationFailure("listFunctions", kind);
|
|
314
|
+
const empty = { functions: [], nextMarker: "" };
|
|
315
|
+
if (typeof marker !== "string" || Buffer.byteLength(marker) > 2048 || /[\r\n]/.test(marker) || !Number.isInteger(maxItems) || maxItems < 0 || maxItems > 50)
|
|
316
|
+
return newQueryBranch("defect", empty, {}, failed("VALIDATION"));
|
|
317
|
+
const parameters = [];
|
|
318
|
+
if (marker) parameters.push("Marker=" + awsEscape(marker));
|
|
319
|
+
if (maxItems) parameters.push("MaxItems=" + maxItems);
|
|
320
|
+
const path = "/2015-03-31/functions" + (parameters.length ? "?" + parameters.join("&") : "");
|
|
321
|
+
const exchange = await this.client[sendFunctionRequest](call, "GET", path);
|
|
322
|
+
if (exchange.error === "credential") return newQueryBranch("defect", empty, {}, failed("AUTHENTICATION"));
|
|
323
|
+
if (exchange.error === "request") return newQueryRetry(failed("TRANSPORT"));
|
|
324
|
+
if (exchange.status === 429) return newQueryRetry(failed("RATE_LIMIT"), exchange.retryAfterMs);
|
|
325
|
+
if (exchange.status === 408 || exchange.status >= 500)
|
|
326
|
+
return newQueryRetry(failed("AVAILABILITY"), exchange.retryAfterMs);
|
|
327
|
+
if (exchange.status !== 200)
|
|
328
|
+
return newQueryBranch("providerRejected", empty, {}, failed("PROVIDER_REJECTION"));
|
|
329
|
+
if (exchange.error === "tooLarge")
|
|
330
|
+
return newQueryBranch("invalidResponse", empty, {}, failed("RESPONSE_TOO_LARGE"));
|
|
331
|
+
try {
|
|
332
|
+
const fields = responseFields(exchange.body), nextMarker = fields.nextmarker ?? "";
|
|
333
|
+
if (!Array.isArray(fields.functions) || fields.functions.length > 50 || typeof nextMarker !== "string" || Buffer.byteLength(nextMarker) > 2048)
|
|
334
|
+
throw new TypeError("invalid Lambda page");
|
|
335
|
+
return newQueryBranch("listed", { functions: fields.functions.map(identity), nextMarker });
|
|
336
|
+
} catch {
|
|
337
|
+
return newQueryBranch("invalidResponse", empty, {}, failed("PROTOCOL"));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
function definiteRefusal(call, exchange) {
|
|
342
|
+
if (call.context.attempt > 1 || ![400, 401, 403, 404, 411, 413, 414, 415, 422].includes(exchange.status))
|
|
343
|
+
return false;
|
|
344
|
+
try {
|
|
345
|
+
const fields = responseFields(exchange.body);
|
|
346
|
+
return typeof fields.message === "string" && fields.message.length > 0 && (fields.functionarn == null || fields.functionarn === "");
|
|
347
|
+
} catch {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function writeFailure(operation, call, exchange, empty) {
|
|
352
|
+
const failed = (kind) => operationFailure(operation, kind);
|
|
353
|
+
if (exchange.error === "credential")
|
|
354
|
+
return call.context.attempt > 1 ? newMutationRetry(failed("AUTHENTICATION")) : newMutationBranch("defect", empty, {}, failed("AUTHENTICATION"));
|
|
355
|
+
if (exchange.error === "request") return newMutationRetry(failed("TRANSPORT"));
|
|
356
|
+
if (exchange.status === 429 || operation === "updateFunctionDescription" && exchange.status === 409)
|
|
357
|
+
return newMutationRetry(failed("RATE_LIMIT"), exchange.retryAfterMs);
|
|
358
|
+
if (exchange.status === 408 || exchange.status >= 500)
|
|
359
|
+
return newMutationRetry(failed("AVAILABILITY"), exchange.retryAfterMs);
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
var UpdateFunctionDescriptionOperation = class {
|
|
363
|
+
/** Bind the signed provider client. */
|
|
364
|
+
constructor(client) {
|
|
365
|
+
this.client = client;
|
|
366
|
+
}
|
|
367
|
+
client;
|
|
368
|
+
/** Return the generated Mutation definition. */
|
|
369
|
+
definition() {
|
|
370
|
+
return UpdateFunctionDescriptionDefinition;
|
|
371
|
+
}
|
|
372
|
+
/** Use the Dex Call ID for the idempotent mutation. */
|
|
373
|
+
idempotencyKey(callId) {
|
|
374
|
+
return callId;
|
|
375
|
+
}
|
|
376
|
+
/** Classify one signed provider write. */
|
|
377
|
+
async invoke(call, input) {
|
|
378
|
+
const operation = "updateFunctionDescription", empty = emptyDetails();
|
|
379
|
+
const failed = (kind) => operationFailure(operation, kind);
|
|
380
|
+
if (typeof input.functionName !== "string" || !functionNamePattern.test(input.functionName) || typeof input.description !== "string" || Buffer.byteLength(input.description) > 256)
|
|
381
|
+
return newMutationBranch("defect", empty, {}, failed("VALIDATION"));
|
|
382
|
+
const payload = JSON.stringify({ Description: input.description }).replace(
|
|
383
|
+
/[<>&\u2028\u2029]/g,
|
|
384
|
+
(ch) => "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0")
|
|
385
|
+
);
|
|
386
|
+
const exchange = await this.client[sendFunctionRequest](
|
|
387
|
+
call,
|
|
388
|
+
"PUT",
|
|
389
|
+
"/2015-03-31/functions/" + input.functionName + "/configuration",
|
|
390
|
+
Buffer.from(payload)
|
|
391
|
+
);
|
|
392
|
+
const failure2 = writeFailure(operation, call, exchange, empty);
|
|
393
|
+
if (failure2) return failure2;
|
|
394
|
+
if (exchange.status === 200) {
|
|
395
|
+
if (exchange.error === "tooLarge") return newMutationRetry(failed("RESPONSE_TOO_LARGE"));
|
|
396
|
+
try {
|
|
397
|
+
const result = identity(responseFields(exchange.body));
|
|
398
|
+
if (result.name !== input.functionName) throw new TypeError("unexpected function");
|
|
399
|
+
return newMutationBranch("updated", result);
|
|
400
|
+
} catch {
|
|
401
|
+
return newMutationRetry(failed("PROTOCOL"));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (definiteRefusal(call, exchange)) {
|
|
405
|
+
if (exchange.status === 404) return newMutationBranch("missing", empty);
|
|
406
|
+
return newMutationBranch("providerRejected", empty, {}, failed("PROVIDER_REJECTION"));
|
|
407
|
+
}
|
|
408
|
+
return newMutationRetry(failed("TRANSPORT"));
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var DeleteFunctionOperation = class {
|
|
412
|
+
/** Bind the signed provider client. */
|
|
413
|
+
constructor(client) {
|
|
414
|
+
this.client = client;
|
|
415
|
+
}
|
|
416
|
+
client;
|
|
417
|
+
/** Return the generated Mutation definition. */
|
|
418
|
+
definition() {
|
|
419
|
+
return DeleteFunctionDefinition;
|
|
420
|
+
}
|
|
421
|
+
/** Use the Dex Call ID for the idempotent mutation. */
|
|
422
|
+
idempotencyKey(callId) {
|
|
423
|
+
return callId;
|
|
424
|
+
}
|
|
425
|
+
/** Classify one signed provider write. */
|
|
426
|
+
async invoke(call, input) {
|
|
427
|
+
const operation = "deleteFunction", empty = { applied: false };
|
|
428
|
+
const failed = (kind) => operationFailure(operation, kind);
|
|
429
|
+
if (typeof input.functionName !== "string" || !functionNamePattern.test(input.functionName))
|
|
430
|
+
return newMutationBranch("defect", empty, {}, failed("VALIDATION"));
|
|
431
|
+
const exchange = await this.client[sendFunctionRequest](
|
|
432
|
+
call,
|
|
433
|
+
"DELETE",
|
|
434
|
+
"/2015-03-31/functions/" + input.functionName
|
|
435
|
+
);
|
|
436
|
+
const failure2 = writeFailure(operation, call, exchange, empty);
|
|
437
|
+
if (failure2) return failure2;
|
|
438
|
+
if (exchange.status === 204) return newMutationBranch("deleted", { applied: true });
|
|
439
|
+
if (definiteRefusal(call, exchange)) {
|
|
440
|
+
if (exchange.status === 404) return newMutationBranch("deleted", { applied: true });
|
|
441
|
+
return newMutationBranch("providerRejected", empty, {}, failed("PROVIDER_REJECTION"));
|
|
442
|
+
}
|
|
443
|
+
return newMutationRetry(failed("TRANSPORT"));
|
|
444
|
+
}
|
|
445
|
+
};
|
|
196
446
|
|
|
197
447
|
// src/project.ts
|
|
198
448
|
function newProjectConnection2(project, connectionName) {
|
|
@@ -235,7 +485,18 @@ export {
|
|
|
235
485
|
ConfigSchema,
|
|
236
486
|
Connection,
|
|
237
487
|
ConnectorID,
|
|
488
|
+
CredentialMaterialError,
|
|
489
|
+
DeleteFunctionBranch,
|
|
490
|
+
DeleteFunctionBranchDefect,
|
|
491
|
+
DeleteFunctionBranchDeleted,
|
|
492
|
+
DeleteFunctionBranchProviderRejected,
|
|
493
|
+
DeleteFunctionDefinition,
|
|
494
|
+
DeleteFunctionInputSchema,
|
|
495
|
+
DeleteFunctionMetadata,
|
|
496
|
+
DeleteFunctionOperation,
|
|
238
497
|
FunctionDetailsSchema,
|
|
498
|
+
FunctionPageSchema,
|
|
499
|
+
FunctionWriteResultSchema,
|
|
239
500
|
GetFunctionBranch,
|
|
240
501
|
GetFunctionBranchDefect,
|
|
241
502
|
GetFunctionBranchFound,
|
|
@@ -246,10 +507,33 @@ export {
|
|
|
246
507
|
GetFunctionInputSchema,
|
|
247
508
|
GetFunctionMetadata,
|
|
248
509
|
GetFunctionOperation,
|
|
510
|
+
ListFunctionsBranch,
|
|
511
|
+
ListFunctionsBranchDefect,
|
|
512
|
+
ListFunctionsBranchInvalidResponse,
|
|
513
|
+
ListFunctionsBranchListed,
|
|
514
|
+
ListFunctionsBranchProviderRejected,
|
|
515
|
+
ListFunctionsDefinition,
|
|
516
|
+
ListFunctionsInputSchema,
|
|
517
|
+
ListFunctionsMetadata,
|
|
518
|
+
ListFunctionsOperation,
|
|
249
519
|
ProviderID,
|
|
520
|
+
UpdateFunctionDescriptionBranch,
|
|
521
|
+
UpdateFunctionDescriptionBranchDefect,
|
|
522
|
+
UpdateFunctionDescriptionBranchInvalidResponse,
|
|
523
|
+
UpdateFunctionDescriptionBranchMissing,
|
|
524
|
+
UpdateFunctionDescriptionBranchProviderRejected,
|
|
525
|
+
UpdateFunctionDescriptionBranchUpdated,
|
|
526
|
+
UpdateFunctionDescriptionDefinition,
|
|
527
|
+
UpdateFunctionDescriptionInputSchema,
|
|
528
|
+
UpdateFunctionDescriptionMetadata,
|
|
529
|
+
UpdateFunctionDescriptionOperation,
|
|
250
530
|
decodeCredentials,
|
|
531
|
+
isCredentialMaterialError,
|
|
251
532
|
newConnection,
|
|
252
533
|
newConnectionWithOperations,
|
|
534
|
+
newDeleteFunctionStep,
|
|
253
535
|
newGetFunctionStep,
|
|
254
|
-
|
|
536
|
+
newListFunctionsStep,
|
|
537
|
+
newProjectConnection2 as newProjectConnection,
|
|
538
|
+
newUpdateFunctionDescriptionStep
|
|
255
539
|
};
|