@distilled.cloud/aws 1.0.0-rc.11 → 1.0.0-rc.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/aws",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -343,7 +343,7 @@
343
343
  "@smithy/types": "^4.17.2",
344
344
  "@smithy/util-base64": "^4.6.0",
345
345
  "fast-xml-parser": "^5.10.1",
346
- "@distilled.cloud/core": "1.0.0-rc.11"
346
+ "@distilled.cloud/core": "1.0.0-rc.12"
347
347
  },
348
348
  "devDependencies": {
349
349
  "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0",
@@ -0,0 +1,67 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import * as Effect from "effect/Effect";
3
+ import { isTransientError } from "../category.ts";
4
+ import {
5
+ CreateFunctionRequest,
6
+ FunctionConfiguration,
7
+ InvalidParameterValueException,
8
+ LambdaInternalKmsError,
9
+ UpdateFunctionCodeRequest,
10
+ } from "../services/lambda.ts";
11
+ import { makeResponseParser } from "./response-parser.ts";
12
+
13
+ const parseCreateFunction = makeResponseParser({
14
+ input: CreateFunctionRequest,
15
+ output: FunctionConfiguration,
16
+ errors: [InvalidParameterValueException, LambdaInternalKmsError],
17
+ });
18
+
19
+ const invalidParameterResponse = (message: string) => ({
20
+ status: 400,
21
+ statusText: "Bad Request",
22
+ headers: {
23
+ "content-type": "application/json",
24
+ "x-amzn-errortype": "InvalidParameterValueException",
25
+ },
26
+ body: JSON.stringify({ Type: "User", message }),
27
+ });
28
+
29
+ const internalKmsMessage = "Internal KMS service error. Try again.";
30
+
31
+ describe("Lambda synthetic error parsing", () => {
32
+ test("classifies the observed internal KMS response as retryable", async () => {
33
+ const error = await Effect.runPromise(
34
+ parseCreateFunction(invalidParameterResponse(internalKmsMessage)).pipe(
35
+ Effect.flip,
36
+ ),
37
+ );
38
+ expect(error).toBeInstanceOf(LambdaInternalKmsError);
39
+ expect(error).toMatchObject({ message: internalKmsMessage });
40
+ expect(isTransientError(error)).toBe(true);
41
+ });
42
+
43
+ test("keeps other invalid parameters non-retryable", async () => {
44
+ const error = await Effect.runPromise(
45
+ parseCreateFunction(
46
+ invalidParameterResponse("The provided execution role is invalid."),
47
+ ).pipe(Effect.flip),
48
+ );
49
+ expect(error).toBeInstanceOf(InvalidParameterValueException);
50
+ expect(isTransientError(error)).toBe(false);
51
+ });
52
+
53
+ test("only specializes operations declaring the synthetic error", async () => {
54
+ const parseUpdateFunctionCode = makeResponseParser({
55
+ input: UpdateFunctionCodeRequest,
56
+ output: FunctionConfiguration,
57
+ errors: [InvalidParameterValueException],
58
+ });
59
+ const error = await Effect.runPromise(
60
+ parseUpdateFunctionCode(
61
+ invalidParameterResponse(internalKmsMessage),
62
+ ).pipe(Effect.flip),
63
+ );
64
+ expect(error).toBeInstanceOf(InvalidParameterValueException);
65
+ expect(isTransientError(error)).toBe(false);
66
+ });
67
+ });
@@ -366,6 +366,18 @@ export class KMSNotFoundException
366
366
  },
367
367
  T.HttpError(502),
368
368
  ).pipe(C.withServerError) {}
369
+ export class LambdaInternalKmsError
370
+ extends /*@__PURE__*/ S.TaggedError<LambdaInternalKmsError>()(
371
+ "LambdaInternalKmsError",
372
+ {
373
+ Type: S.optional(S.String),
374
+ message: S.optional(S.String).pipe(T.ErrorMessage()),
375
+ },
376
+ T.SyntheticError({
377
+ from: "InvalidParameterValueException",
378
+ message: "Internal KMS service error. Try again.",
379
+ }),
380
+ ).pipe(C.withRetryableError) {}
369
381
  export class ModeNotSupportedException
370
382
  extends /*@__PURE__*/ S.TaggedError<ModeNotSupportedException>()(
371
383
  "ModeNotSupportedException",
@@ -6518,6 +6530,7 @@ export type CreateFunctionError =
6518
6530
  | ResourceNotFoundException
6519
6531
  | ServiceException
6520
6532
  | TooManyRequestsException
6533
+ | LambdaInternalKmsError
6521
6534
  | CommonErrors;
6522
6535
  /**
6523
6536
  * Creates a Lambda function. To create a function, you need a deployment package and an execution role. The deployment package is a .zip file archive or container image that contains your function code. The execution role grants the function permission to use Amazon Web Services services, such as Amazon CloudWatch Logs for log streaming and X-Ray for request tracing.
@@ -6557,6 +6570,7 @@ export const createFunction: API.OperationMethod<
6557
6570
  ResourceNotFoundException,
6558
6571
  ServiceException,
6559
6572
  TooManyRequestsException,
6573
+ LambdaInternalKmsError,
6560
6574
  ],
6561
6575
  protocol: AwsProtocol,
6562
6576
  retry: Retry,