1import * as AWS from "@/AWS";
2import * as Test from "@/Test/Alchemy";
3import * as sagemaker from "@distilled.cloud/aws/sagemaker-runtime";
4import { expect } from "alchemy-test";
5import * as Effect from "effect/Effect";
6import * as Result from "effect/Result";
7
8const { test } = Test.make({ providers: AWS.providers() });
9
10// Ungated typed-error probe: invoking a nonexistent endpoint must surface as a
11// typed `ValidationError` from distilled's `InvokeEndpointError` union — this
12// proves both the SDK's typed error mapping and that the binding's callable is
13// wired against the real data-plane API, at near-zero cost (no endpoint is
14// provisioned — a real endpoint costs $$ per hour). The full live invocation
15// (with a real deployed endpoint) is gated behind AWS_TEST_SAGEMAKER_ENDPOINT=1
16// in test/AWS/SageMaker/Endpoint.test.ts.
17test.provider(
18 "invoking a nonexistent endpoint returns a typed ValidationError",
19 (_stack) =>
20 Effect.gen(function* () {
21 const result = yield* Effect.result(
22 sagemaker.invokeEndpoint({
23 EndpointName: "alchemy-nonexistent-endpoint-probe",
24 ContentType: "application/json",
25 Body: JSON.stringify({ instances: [[0]] }),
26 }),
27 );
28
29 expect(Result.isFailure(result)).toBe(true);
30 if (Result.isFailure(result)) {
31 expect(result.failure._tag).toBe("ValidationError");
32 }
33 }),
34 {
35 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
36 timeout: 60_000,
37 },
38);
39
40test.provider(
41 "async-invoking a nonexistent endpoint returns a typed ValidationError",
42 (_stack) =>
43 Effect.gen(function* () {
44 const result = yield* Effect.result(
45 sagemaker.invokeEndpointAsync({
46 EndpointName: "alchemy-nonexistent-endpoint-probe",
47 ContentType: "application/json",
48 InputLocation:
49 "s3://alchemy-nonexistent-bucket-probe/input/request.json",
50 }),
51 );
52
53 expect(Result.isFailure(result)).toBe(true);
54 if (Result.isFailure(result)) {
55 expect(result.failure._tag).toBe("ValidationError");
56 }
57 }),
58 {
59 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
60 timeout: 60_000,
61 },
62);
63
64test.provider(
65 "stream-invoking a nonexistent endpoint returns a typed ValidationError",
66 (_stack) =>
67 Effect.gen(function* () {
68 const result = yield* Effect.result(
69 sagemaker.invokeEndpointWithResponseStream({
70 EndpointName: "alchemy-nonexistent-endpoint-probe",
71 ContentType: "application/json",
72 Body: JSON.stringify({ inputs: "hello" }),
73 }),
74 );
75
76 expect(Result.isFailure(result)).toBe(true);
77 if (Result.isFailure(result)) {
78 expect(result.failure._tag).toBe("ValidationError");
79 }
80 }),
81 {
82 tags: ["provider:aws", "provider:aws:sagemakerruntime", "live"],
83 timeout: 60_000,
84 },
85);