@slates-integrations/aws-lambda 0.2.0-rc.6

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.
Files changed (37) hide show
  1. package/README.md +89 -0
  2. package/docs/SPEC.md +91 -0
  3. package/logo.svg +1 -0
  4. package/package.json +21 -0
  5. package/slate.json +23 -0
  6. package/src/auth.ts +51 -0
  7. package/src/config.ts +8 -0
  8. package/src/index.ts +50 -0
  9. package/src/lib/aws-signer.ts +158 -0
  10. package/src/lib/client.ts +919 -0
  11. package/src/lib/errors.ts +101 -0
  12. package/src/lib/helpers.ts +15 -0
  13. package/src/spec.ts +13 -0
  14. package/src/tools/configure-async-invocation.ts +134 -0
  15. package/src/tools/create-function.ts +127 -0
  16. package/src/tools/delete-function.ts +41 -0
  17. package/src/tools/get-account-settings.ts +45 -0
  18. package/src/tools/get-function.ts +104 -0
  19. package/src/tools/index.ts +19 -0
  20. package/src/tools/invoke-function.ts +94 -0
  21. package/src/tools/list-functions.ts +88 -0
  22. package/src/tools/manage-alias.ts +159 -0
  23. package/src/tools/manage-concurrency.ts +141 -0
  24. package/src/tools/manage-durable-execution.ts +209 -0
  25. package/src/tools/manage-event-source-mapping.ts +193 -0
  26. package/src/tools/manage-function-url.ts +132 -0
  27. package/src/tools/manage-layer.ts +186 -0
  28. package/src/tools/manage-permission.ts +94 -0
  29. package/src/tools/manage-recursion-config.ts +63 -0
  30. package/src/tools/manage-runtime-management.ts +85 -0
  31. package/src/tools/manage-tags.ts +72 -0
  32. package/src/tools/publish-version.ts +83 -0
  33. package/src/tools/update-function.ts +156 -0
  34. package/src/triggers/function-changes.ts +113 -0
  35. package/src/triggers/inbound-webhook.ts +67 -0
  36. package/src/triggers/index.ts +2 -0
  37. package/tsconfig.json +23 -0
@@ -0,0 +1,919 @@
1
+ import { Buffer } from 'node:buffer';
2
+ import {
3
+ AddPermissionCommand,
4
+ CreateAliasCommand,
5
+ CreateEventSourceMappingCommand,
6
+ CreateFunctionCommand,
7
+ CreateFunctionUrlConfigCommand,
8
+ DeleteAliasCommand,
9
+ DeleteEventSourceMappingCommand,
10
+ DeleteFunctionCommand,
11
+ DeleteFunctionConcurrencyCommand,
12
+ DeleteFunctionEventInvokeConfigCommand,
13
+ DeleteFunctionUrlConfigCommand,
14
+ DeleteLayerVersionCommand,
15
+ DeleteProvisionedConcurrencyConfigCommand,
16
+ GetAccountSettingsCommand,
17
+ GetAliasCommand,
18
+ GetDurableExecutionCommand,
19
+ GetDurableExecutionHistoryCommand,
20
+ GetDurableExecutionStateCommand,
21
+ GetEventSourceMappingCommand,
22
+ GetFunctionCommand,
23
+ GetFunctionConcurrencyCommand,
24
+ GetFunctionConfigurationCommand,
25
+ GetFunctionEventInvokeConfigCommand,
26
+ GetFunctionRecursionConfigCommand,
27
+ GetFunctionUrlConfigCommand,
28
+ GetLayerVersionCommand,
29
+ GetPolicyCommand,
30
+ GetProvisionedConcurrencyConfigCommand,
31
+ GetRuntimeManagementConfigCommand,
32
+ InvokeCommand,
33
+ LambdaClient as AwsLambdaClient,
34
+ ListAliasesCommand,
35
+ ListDurableExecutionsByFunctionCommand,
36
+ ListEventSourceMappingsCommand,
37
+ ListFunctionEventInvokeConfigsCommand,
38
+ ListFunctionsCommand,
39
+ ListLayerVersionsCommand,
40
+ ListLayersCommand,
41
+ ListTagsCommand,
42
+ ListVersionsByFunctionCommand,
43
+ PublishLayerVersionCommand,
44
+ PublishVersionCommand,
45
+ PutFunctionConcurrencyCommand,
46
+ PutFunctionEventInvokeConfigCommand,
47
+ PutFunctionRecursionConfigCommand,
48
+ PutProvisionedConcurrencyConfigCommand,
49
+ PutRuntimeManagementConfigCommand,
50
+ RemovePermissionCommand,
51
+ SendDurableExecutionCallbackFailureCommand,
52
+ SendDurableExecutionCallbackHeartbeatCommand,
53
+ SendDurableExecutionCallbackSuccessCommand,
54
+ StopDurableExecutionCommand,
55
+ TagResourceCommand,
56
+ UntagResourceCommand,
57
+ UpdateAliasCommand,
58
+ UpdateEventSourceMappingCommand,
59
+ UpdateFunctionCodeCommand,
60
+ UpdateFunctionConfigurationCommand,
61
+ UpdateFunctionEventInvokeConfigCommand,
62
+ UpdateFunctionUrlConfigCommand
63
+ } from '@aws-sdk/client-lambda';
64
+ import { createSlatesAwsSdkHttpHandler } from '@slates/aws-sdk-http-handler';
65
+ import { lambdaApiError } from './errors';
66
+
67
+ export interface AwsCredentials {
68
+ accessKeyId: string;
69
+ secretAccessKey: string;
70
+ sessionToken?: string;
71
+ }
72
+
73
+ export interface LambdaClientConfig {
74
+ region: string;
75
+ credentials: AwsCredentials;
76
+ }
77
+
78
+ let withoutUndefined = <T extends Record<string, any>>(input: T): T => {
79
+ let out: Record<string, any> = {};
80
+
81
+ for (let [key, value] of Object.entries(input)) {
82
+ if (value !== undefined) {
83
+ out[key] = value;
84
+ }
85
+ }
86
+
87
+ return out as T;
88
+ };
89
+
90
+ let decodeBase64Blob = (value: unknown) =>
91
+ typeof value === 'string' ? Buffer.from(value, 'base64') : value;
92
+
93
+ let normalizeCreateFunctionParams = (params: Record<string, any>) => {
94
+ let out = { ...params };
95
+
96
+ if (out.Code && typeof out.Code === 'object' && !Array.isArray(out.Code)) {
97
+ out.Code = {
98
+ ...out.Code,
99
+ ZipFile: decodeBase64Blob(out.Code.ZipFile)
100
+ };
101
+ }
102
+
103
+ return out;
104
+ };
105
+
106
+ let normalizeZipFileParams = (params: Record<string, any>) => ({
107
+ ...params,
108
+ ZipFile: decodeBase64Blob(params.ZipFile)
109
+ });
110
+
111
+ let normalizeLayerParams = (params: Record<string, any>) => {
112
+ let out = { ...params };
113
+
114
+ if (out.Content && typeof out.Content === 'object' && !Array.isArray(out.Content)) {
115
+ out.Content = {
116
+ ...out.Content,
117
+ ZipFile: decodeBase64Blob(out.Content.ZipFile)
118
+ };
119
+ }
120
+
121
+ return out;
122
+ };
123
+
124
+ let encodeJsonPayload = (value: unknown) =>
125
+ value === undefined ? undefined : Buffer.from(JSON.stringify(value));
126
+
127
+ let decodeInvokePayload = (payload: unknown) => {
128
+ if (payload === undefined || payload === null) {
129
+ return payload;
130
+ }
131
+
132
+ let text =
133
+ typeof payload === 'string'
134
+ ? payload
135
+ : Buffer.from(payload as Uint8Array).toString('utf8');
136
+
137
+ if (!text) {
138
+ return '';
139
+ }
140
+
141
+ try {
142
+ return JSON.parse(text);
143
+ } catch {
144
+ return text;
145
+ }
146
+ };
147
+
148
+ let buildErrorObject = (params?: Record<string, any>) => {
149
+ if (!params) return undefined;
150
+ if (params.Error) return params.Error;
151
+
152
+ let error = withoutUndefined({
153
+ ErrorMessage: params.ErrorMessage,
154
+ ErrorType: params.ErrorType,
155
+ ErrorData: params.ErrorData,
156
+ StackTrace: params.StackTrace
157
+ });
158
+
159
+ return Object.keys(error).length > 0 ? error : undefined;
160
+ };
161
+
162
+ export class LambdaClient {
163
+ private client: AwsLambdaClient;
164
+
165
+ constructor(config: LambdaClientConfig) {
166
+ this.client = new AwsLambdaClient({
167
+ region: config.region,
168
+ credentials: withoutUndefined({
169
+ accessKeyId: config.credentials.accessKeyId,
170
+ secretAccessKey: config.credentials.secretAccessKey,
171
+ sessionToken: config.credentials.sessionToken || undefined
172
+ }),
173
+ requestHandler: createSlatesAwsSdkHttpHandler()
174
+ });
175
+ }
176
+
177
+ private async send<T>(operation: string, command: any): Promise<T> {
178
+ try {
179
+ return (await this.client.send(command)) as T;
180
+ } catch (error) {
181
+ throw lambdaApiError(error, operation);
182
+ }
183
+ }
184
+
185
+ // ---- Function Management ----
186
+
187
+ async createFunction(params: Record<string, any>): Promise<any> {
188
+ return this.send(
189
+ 'CreateFunction',
190
+ new CreateFunctionCommand(normalizeCreateFunctionParams(params) as any)
191
+ );
192
+ }
193
+
194
+ async getFunction(functionName: string, qualifier?: string): Promise<any> {
195
+ return this.send(
196
+ 'GetFunction',
197
+ new GetFunctionCommand(
198
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
199
+ )
200
+ );
201
+ }
202
+
203
+ async getFunctionConfiguration(functionName: string, qualifier?: string): Promise<any> {
204
+ return this.send(
205
+ 'GetFunctionConfiguration',
206
+ new GetFunctionConfigurationCommand(
207
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
208
+ )
209
+ );
210
+ }
211
+
212
+ async updateFunctionCode(functionName: string, params: Record<string, any>): Promise<any> {
213
+ return this.send(
214
+ 'UpdateFunctionCode',
215
+ new UpdateFunctionCodeCommand(
216
+ withoutUndefined({
217
+ FunctionName: functionName,
218
+ ...normalizeZipFileParams(params)
219
+ }) as any
220
+ )
221
+ );
222
+ }
223
+
224
+ async updateFunctionConfiguration(
225
+ functionName: string,
226
+ params: Record<string, any>
227
+ ): Promise<any> {
228
+ return this.send(
229
+ 'UpdateFunctionConfiguration',
230
+ new UpdateFunctionConfigurationCommand({
231
+ FunctionName: functionName,
232
+ ...params
233
+ } as any)
234
+ );
235
+ }
236
+
237
+ async deleteFunction(functionName: string, qualifier?: string): Promise<void> {
238
+ await this.send(
239
+ 'DeleteFunction',
240
+ new DeleteFunctionCommand(
241
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
242
+ )
243
+ );
244
+ }
245
+
246
+ async listFunctions(
247
+ marker?: string,
248
+ maxItems?: number,
249
+ functionVersion?: string
250
+ ): Promise<any> {
251
+ return this.send(
252
+ 'ListFunctions',
253
+ new ListFunctionsCommand(
254
+ withoutUndefined({
255
+ Marker: marker,
256
+ MaxItems: maxItems,
257
+ FunctionVersion: functionVersion
258
+ }) as any
259
+ )
260
+ );
261
+ }
262
+
263
+ // ---- Invocation ----
264
+
265
+ async invokeFunction(
266
+ functionName: string,
267
+ payload?: any,
268
+ options?: {
269
+ invocationType?: string;
270
+ logType?: string;
271
+ qualifier?: string;
272
+ clientContext?: string;
273
+ durableExecutionName?: string;
274
+ tenantId?: string;
275
+ }
276
+ ): Promise<any> {
277
+ let response: any = await this.send(
278
+ 'Invoke',
279
+ new InvokeCommand(
280
+ withoutUndefined({
281
+ FunctionName: functionName,
282
+ InvocationType: options?.invocationType,
283
+ LogType: options?.logType,
284
+ ClientContext: options?.clientContext,
285
+ DurableExecutionName: options?.durableExecutionName,
286
+ Payload: encodeJsonPayload(payload),
287
+ Qualifier: options?.qualifier,
288
+ TenantId: options?.tenantId
289
+ }) as any
290
+ )
291
+ );
292
+
293
+ return {
294
+ ...response,
295
+ Payload: decodeInvokePayload(response.Payload)
296
+ };
297
+ }
298
+
299
+ // ---- Versions ----
300
+
301
+ async publishVersion(functionName: string, params?: Record<string, any>): Promise<any> {
302
+ return this.send(
303
+ 'PublishVersion',
304
+ new PublishVersionCommand({
305
+ FunctionName: functionName,
306
+ ...(params || {})
307
+ } as any)
308
+ );
309
+ }
310
+
311
+ async listVersionsByFunction(
312
+ functionName: string,
313
+ marker?: string,
314
+ maxItems?: number
315
+ ): Promise<any> {
316
+ return this.send(
317
+ 'ListVersionsByFunction',
318
+ new ListVersionsByFunctionCommand(
319
+ withoutUndefined({
320
+ FunctionName: functionName,
321
+ Marker: marker,
322
+ MaxItems: maxItems
323
+ })
324
+ )
325
+ );
326
+ }
327
+
328
+ // ---- Aliases ----
329
+
330
+ async createAlias(functionName: string, params: Record<string, any>): Promise<any> {
331
+ return this.send(
332
+ 'CreateAlias',
333
+ new CreateAliasCommand({
334
+ FunctionName: functionName,
335
+ ...params
336
+ } as any)
337
+ );
338
+ }
339
+
340
+ async getAlias(functionName: string, aliasName: string): Promise<any> {
341
+ return this.send(
342
+ 'GetAlias',
343
+ new GetAliasCommand({ FunctionName: functionName, Name: aliasName })
344
+ );
345
+ }
346
+
347
+ async updateAlias(
348
+ functionName: string,
349
+ aliasName: string,
350
+ params: Record<string, any>
351
+ ): Promise<any> {
352
+ return this.send(
353
+ 'UpdateAlias',
354
+ new UpdateAliasCommand({
355
+ FunctionName: functionName,
356
+ Name: aliasName,
357
+ ...params
358
+ } as any)
359
+ );
360
+ }
361
+
362
+ async deleteAlias(functionName: string, aliasName: string): Promise<void> {
363
+ await this.send(
364
+ 'DeleteAlias',
365
+ new DeleteAliasCommand({ FunctionName: functionName, Name: aliasName })
366
+ );
367
+ }
368
+
369
+ async listAliases(functionName: string, marker?: string, maxItems?: number): Promise<any> {
370
+ return this.send(
371
+ 'ListAliases',
372
+ new ListAliasesCommand(
373
+ withoutUndefined({
374
+ FunctionName: functionName,
375
+ Marker: marker,
376
+ MaxItems: maxItems
377
+ })
378
+ )
379
+ );
380
+ }
381
+
382
+ // ---- Layers ----
383
+
384
+ async publishLayerVersion(layerName: string, params: Record<string, any>): Promise<any> {
385
+ return this.send(
386
+ 'PublishLayerVersion',
387
+ new PublishLayerVersionCommand({
388
+ LayerName: layerName,
389
+ ...normalizeLayerParams(params)
390
+ } as any)
391
+ );
392
+ }
393
+
394
+ async getLayerVersion(layerName: string, versionNumber: number): Promise<any> {
395
+ return this.send(
396
+ 'GetLayerVersion',
397
+ new GetLayerVersionCommand({ LayerName: layerName, VersionNumber: versionNumber })
398
+ );
399
+ }
400
+
401
+ async deleteLayerVersion(layerName: string, versionNumber: number): Promise<void> {
402
+ await this.send(
403
+ 'DeleteLayerVersion',
404
+ new DeleteLayerVersionCommand({ LayerName: layerName, VersionNumber: versionNumber })
405
+ );
406
+ }
407
+
408
+ async listLayers(
409
+ marker?: string,
410
+ maxItems?: number,
411
+ compatibleRuntime?: string
412
+ ): Promise<any> {
413
+ return this.send(
414
+ 'ListLayers',
415
+ new ListLayersCommand(
416
+ withoutUndefined({
417
+ Marker: marker,
418
+ MaxItems: maxItems,
419
+ CompatibleRuntime: compatibleRuntime
420
+ }) as any
421
+ )
422
+ );
423
+ }
424
+
425
+ async listLayerVersions(
426
+ layerName: string,
427
+ marker?: string,
428
+ maxItems?: number
429
+ ): Promise<any> {
430
+ return this.send(
431
+ 'ListLayerVersions',
432
+ new ListLayerVersionsCommand(
433
+ withoutUndefined({
434
+ LayerName: layerName,
435
+ Marker: marker,
436
+ MaxItems: maxItems
437
+ })
438
+ )
439
+ );
440
+ }
441
+
442
+ // ---- Event Source Mappings ----
443
+
444
+ async createEventSourceMapping(params: Record<string, any>): Promise<any> {
445
+ return this.send(
446
+ 'CreateEventSourceMapping',
447
+ new CreateEventSourceMappingCommand(params as any)
448
+ );
449
+ }
450
+
451
+ async getEventSourceMapping(uuid: string): Promise<any> {
452
+ return this.send(
453
+ 'GetEventSourceMapping',
454
+ new GetEventSourceMappingCommand({ UUID: uuid })
455
+ );
456
+ }
457
+
458
+ async updateEventSourceMapping(uuid: string, params: Record<string, any>): Promise<any> {
459
+ return this.send(
460
+ 'UpdateEventSourceMapping',
461
+ new UpdateEventSourceMappingCommand({ UUID: uuid, ...params } as any)
462
+ );
463
+ }
464
+
465
+ async deleteEventSourceMapping(uuid: string): Promise<any> {
466
+ return this.send(
467
+ 'DeleteEventSourceMapping',
468
+ new DeleteEventSourceMappingCommand({ UUID: uuid })
469
+ );
470
+ }
471
+
472
+ async listEventSourceMappings(
473
+ functionName?: string,
474
+ eventSourceArn?: string,
475
+ marker?: string,
476
+ maxItems?: number
477
+ ): Promise<any> {
478
+ return this.send(
479
+ 'ListEventSourceMappings',
480
+ new ListEventSourceMappingsCommand(
481
+ withoutUndefined({
482
+ FunctionName: functionName,
483
+ EventSourceArn: eventSourceArn,
484
+ Marker: marker,
485
+ MaxItems: maxItems
486
+ })
487
+ )
488
+ );
489
+ }
490
+
491
+ // ---- Function URLs ----
492
+
493
+ async createFunctionUrlConfig(
494
+ functionName: string,
495
+ params: Record<string, any>,
496
+ qualifier?: string
497
+ ): Promise<any> {
498
+ return this.send(
499
+ 'CreateFunctionUrlConfig',
500
+ new CreateFunctionUrlConfigCommand(
501
+ withoutUndefined({
502
+ FunctionName: functionName,
503
+ Qualifier: qualifier,
504
+ ...params
505
+ }) as any
506
+ )
507
+ );
508
+ }
509
+
510
+ async getFunctionUrlConfig(functionName: string, qualifier?: string): Promise<any> {
511
+ return this.send(
512
+ 'GetFunctionUrlConfig',
513
+ new GetFunctionUrlConfigCommand(
514
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
515
+ )
516
+ );
517
+ }
518
+
519
+ async updateFunctionUrlConfig(
520
+ functionName: string,
521
+ params: Record<string, any>,
522
+ qualifier?: string
523
+ ): Promise<any> {
524
+ return this.send(
525
+ 'UpdateFunctionUrlConfig',
526
+ new UpdateFunctionUrlConfigCommand(
527
+ withoutUndefined({
528
+ FunctionName: functionName,
529
+ Qualifier: qualifier,
530
+ ...params
531
+ }) as any
532
+ )
533
+ );
534
+ }
535
+
536
+ async deleteFunctionUrlConfig(functionName: string, qualifier?: string): Promise<void> {
537
+ await this.send(
538
+ 'DeleteFunctionUrlConfig',
539
+ new DeleteFunctionUrlConfigCommand(
540
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
541
+ )
542
+ );
543
+ }
544
+
545
+ // ---- Concurrency ----
546
+
547
+ async putFunctionConcurrency(
548
+ functionName: string,
549
+ reservedConcurrentExecutions: number
550
+ ): Promise<any> {
551
+ return this.send(
552
+ 'PutFunctionConcurrency',
553
+ new PutFunctionConcurrencyCommand({
554
+ FunctionName: functionName,
555
+ ReservedConcurrentExecutions: reservedConcurrentExecutions
556
+ })
557
+ );
558
+ }
559
+
560
+ async getFunctionConcurrency(functionName: string): Promise<any> {
561
+ return this.send(
562
+ 'GetFunctionConcurrency',
563
+ new GetFunctionConcurrencyCommand({ FunctionName: functionName })
564
+ );
565
+ }
566
+
567
+ async deleteFunctionConcurrency(functionName: string): Promise<void> {
568
+ await this.send(
569
+ 'DeleteFunctionConcurrency',
570
+ new DeleteFunctionConcurrencyCommand({ FunctionName: functionName })
571
+ );
572
+ }
573
+
574
+ async putProvisionedConcurrencyConfig(
575
+ functionName: string,
576
+ qualifier: string,
577
+ provisionedConcurrentExecutions: number
578
+ ): Promise<any> {
579
+ return this.send(
580
+ 'PutProvisionedConcurrencyConfig',
581
+ new PutProvisionedConcurrencyConfigCommand({
582
+ FunctionName: functionName,
583
+ Qualifier: qualifier,
584
+ ProvisionedConcurrentExecutions: provisionedConcurrentExecutions
585
+ })
586
+ );
587
+ }
588
+
589
+ async getProvisionedConcurrencyConfig(
590
+ functionName: string,
591
+ qualifier: string
592
+ ): Promise<any> {
593
+ return this.send(
594
+ 'GetProvisionedConcurrencyConfig',
595
+ new GetProvisionedConcurrencyConfigCommand({
596
+ FunctionName: functionName,
597
+ Qualifier: qualifier
598
+ })
599
+ );
600
+ }
601
+
602
+ async deleteProvisionedConcurrencyConfig(
603
+ functionName: string,
604
+ qualifier: string
605
+ ): Promise<void> {
606
+ await this.send(
607
+ 'DeleteProvisionedConcurrencyConfig',
608
+ new DeleteProvisionedConcurrencyConfigCommand({
609
+ FunctionName: functionName,
610
+ Qualifier: qualifier
611
+ })
612
+ );
613
+ }
614
+
615
+ // ---- Permissions ----
616
+
617
+ async addPermission(
618
+ functionName: string,
619
+ params: Record<string, any>,
620
+ qualifier?: string
621
+ ): Promise<any> {
622
+ return this.send(
623
+ 'AddPermission',
624
+ new AddPermissionCommand(
625
+ withoutUndefined({
626
+ FunctionName: functionName,
627
+ Qualifier: qualifier,
628
+ ...params
629
+ }) as any
630
+ )
631
+ );
632
+ }
633
+
634
+ async removePermission(
635
+ functionName: string,
636
+ statementId: string,
637
+ qualifier?: string,
638
+ revisionId?: string
639
+ ): Promise<void> {
640
+ await this.send(
641
+ 'RemovePermission',
642
+ new RemovePermissionCommand(
643
+ withoutUndefined({
644
+ FunctionName: functionName,
645
+ StatementId: statementId,
646
+ Qualifier: qualifier,
647
+ RevisionId: revisionId
648
+ })
649
+ )
650
+ );
651
+ }
652
+
653
+ async getPolicy(functionName: string, qualifier?: string): Promise<any> {
654
+ return this.send(
655
+ 'GetPolicy',
656
+ new GetPolicyCommand(
657
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
658
+ )
659
+ );
660
+ }
661
+
662
+ // ---- Tags ----
663
+
664
+ async tagResource(arn: string, tags: Record<string, string>): Promise<void> {
665
+ await this.send('TagResource', new TagResourceCommand({ Resource: arn, Tags: tags }));
666
+ }
667
+
668
+ async untagResource(arn: string, tagKeys: string[]): Promise<void> {
669
+ await this.send(
670
+ 'UntagResource',
671
+ new UntagResourceCommand({ Resource: arn, TagKeys: tagKeys })
672
+ );
673
+ }
674
+
675
+ async listTags(arn: string): Promise<any> {
676
+ return this.send('ListTags', new ListTagsCommand({ Resource: arn }));
677
+ }
678
+
679
+ // ---- Async Invocation Configuration ----
680
+
681
+ async putFunctionEventInvokeConfig(
682
+ functionName: string,
683
+ params: Record<string, any>,
684
+ qualifier?: string
685
+ ): Promise<any> {
686
+ return this.send(
687
+ 'PutFunctionEventInvokeConfig',
688
+ new PutFunctionEventInvokeConfigCommand(
689
+ withoutUndefined({
690
+ FunctionName: functionName,
691
+ Qualifier: qualifier,
692
+ ...params
693
+ }) as any
694
+ )
695
+ );
696
+ }
697
+
698
+ async getFunctionEventInvokeConfig(functionName: string, qualifier?: string): Promise<any> {
699
+ return this.send(
700
+ 'GetFunctionEventInvokeConfig',
701
+ new GetFunctionEventInvokeConfigCommand(
702
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
703
+ )
704
+ );
705
+ }
706
+
707
+ async deleteFunctionEventInvokeConfig(
708
+ functionName: string,
709
+ qualifier?: string
710
+ ): Promise<void> {
711
+ await this.send(
712
+ 'DeleteFunctionEventInvokeConfig',
713
+ new DeleteFunctionEventInvokeConfigCommand(
714
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
715
+ )
716
+ );
717
+ }
718
+
719
+ async updateFunctionEventInvokeConfig(
720
+ functionName: string,
721
+ params: Record<string, any>,
722
+ qualifier?: string
723
+ ): Promise<any> {
724
+ return this.send(
725
+ 'UpdateFunctionEventInvokeConfig',
726
+ new UpdateFunctionEventInvokeConfigCommand(
727
+ withoutUndefined({
728
+ FunctionName: functionName,
729
+ Qualifier: qualifier,
730
+ ...params
731
+ }) as any
732
+ )
733
+ );
734
+ }
735
+
736
+ async listFunctionEventInvokeConfigs(
737
+ functionName: string,
738
+ marker?: string,
739
+ maxItems?: number
740
+ ): Promise<any> {
741
+ return this.send(
742
+ 'ListFunctionEventInvokeConfigs',
743
+ new ListFunctionEventInvokeConfigsCommand(
744
+ withoutUndefined({
745
+ FunctionName: functionName,
746
+ Marker: marker,
747
+ MaxItems: maxItems
748
+ })
749
+ )
750
+ );
751
+ }
752
+
753
+ // ---- Runtime Management ----
754
+
755
+ async getRuntimeManagementConfig(functionName: string, qualifier?: string): Promise<any> {
756
+ return this.send(
757
+ 'GetRuntimeManagementConfig',
758
+ new GetRuntimeManagementConfigCommand(
759
+ withoutUndefined({ FunctionName: functionName, Qualifier: qualifier })
760
+ )
761
+ );
762
+ }
763
+
764
+ async putRuntimeManagementConfig(
765
+ functionName: string,
766
+ params: Record<string, any>,
767
+ qualifier?: string
768
+ ): Promise<any> {
769
+ return this.send(
770
+ 'PutRuntimeManagementConfig',
771
+ new PutRuntimeManagementConfigCommand(
772
+ withoutUndefined({
773
+ FunctionName: functionName,
774
+ Qualifier: qualifier,
775
+ ...params
776
+ }) as any
777
+ )
778
+ );
779
+ }
780
+
781
+ // ---- Recursive Loop Detection ----
782
+
783
+ async getFunctionRecursionConfig(functionName: string): Promise<any> {
784
+ return this.send(
785
+ 'GetFunctionRecursionConfig',
786
+ new GetFunctionRecursionConfigCommand({ FunctionName: functionName })
787
+ );
788
+ }
789
+
790
+ async putFunctionRecursionConfig(
791
+ functionName: string,
792
+ recursiveLoop: 'Allow' | 'Terminate'
793
+ ): Promise<any> {
794
+ return this.send(
795
+ 'PutFunctionRecursionConfig',
796
+ new PutFunctionRecursionConfigCommand({
797
+ FunctionName: functionName,
798
+ RecursiveLoop: recursiveLoop
799
+ })
800
+ );
801
+ }
802
+
803
+ // ---- Durable Executions ----
804
+
805
+ async getDurableExecution(durableExecutionArn: string): Promise<any> {
806
+ return this.send(
807
+ 'GetDurableExecution',
808
+ new GetDurableExecutionCommand({ DurableExecutionArn: durableExecutionArn })
809
+ );
810
+ }
811
+
812
+ async getDurableExecutionHistory(
813
+ durableExecutionArn: string,
814
+ marker?: string,
815
+ maxItems?: number
816
+ ): Promise<any> {
817
+ return this.send(
818
+ 'GetDurableExecutionHistory',
819
+ new GetDurableExecutionHistoryCommand(
820
+ withoutUndefined({
821
+ DurableExecutionArn: durableExecutionArn,
822
+ Marker: marker,
823
+ MaxItems: maxItems
824
+ })
825
+ )
826
+ );
827
+ }
828
+
829
+ async getDurableExecutionState(
830
+ durableExecutionArn: string,
831
+ checkpointToken?: string,
832
+ marker?: string,
833
+ maxItems?: number
834
+ ): Promise<any> {
835
+ return this.send(
836
+ 'GetDurableExecutionState',
837
+ new GetDurableExecutionStateCommand(
838
+ withoutUndefined({
839
+ DurableExecutionArn: durableExecutionArn,
840
+ CheckpointToken: checkpointToken,
841
+ Marker: marker,
842
+ MaxItems: maxItems
843
+ }) as any
844
+ )
845
+ );
846
+ }
847
+
848
+ async listDurableExecutionsByFunction(
849
+ functionName: string,
850
+ statuses?: string,
851
+ marker?: string,
852
+ maxItems?: number
853
+ ): Promise<any> {
854
+ return this.send(
855
+ 'ListDurableExecutionsByFunction',
856
+ new ListDurableExecutionsByFunctionCommand(
857
+ withoutUndefined({
858
+ FunctionName: functionName,
859
+ Statuses: statuses ? [statuses] : undefined,
860
+ Marker: marker,
861
+ MaxItems: maxItems
862
+ }) as any
863
+ )
864
+ );
865
+ }
866
+
867
+ async stopDurableExecution(
868
+ durableExecutionArn: string,
869
+ params?: Record<string, any>
870
+ ): Promise<any> {
871
+ return this.send(
872
+ 'StopDurableExecution',
873
+ new StopDurableExecutionCommand(
874
+ withoutUndefined({
875
+ DurableExecutionArn: durableExecutionArn,
876
+ Error: buildErrorObject(params)
877
+ }) as any
878
+ )
879
+ );
880
+ }
881
+
882
+ async sendDurableExecutionCallbackSuccess(callbackId: string, result?: any): Promise<any> {
883
+ return this.send(
884
+ 'SendDurableExecutionCallbackSuccess',
885
+ new SendDurableExecutionCallbackSuccessCommand({
886
+ CallbackId: callbackId,
887
+ Result: encodeJsonPayload(result || {})
888
+ } as any)
889
+ );
890
+ }
891
+
892
+ async sendDurableExecutionCallbackFailure(
893
+ callbackId: string,
894
+ params?: Record<string, any>
895
+ ): Promise<any> {
896
+ return this.send(
897
+ 'SendDurableExecutionCallbackFailure',
898
+ new SendDurableExecutionCallbackFailureCommand(
899
+ withoutUndefined({
900
+ CallbackId: callbackId,
901
+ Error: buildErrorObject(params)
902
+ }) as any
903
+ )
904
+ );
905
+ }
906
+
907
+ async sendDurableExecutionCallbackHeartbeat(callbackId: string): Promise<any> {
908
+ return this.send(
909
+ 'SendDurableExecutionCallbackHeartbeat',
910
+ new SendDurableExecutionCallbackHeartbeatCommand({ CallbackId: callbackId })
911
+ );
912
+ }
913
+
914
+ // ---- Account Settings ----
915
+
916
+ async getAccountSettings(): Promise<any> {
917
+ return this.send('GetAccountSettings', new GetAccountSettingsCommand({}));
918
+ }
919
+ }