@distilled.cloud/vercel 1.0.0-rc.12 → 1.0.0-rc.13

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 ADDED
@@ -0,0 +1,34 @@
1
+ # @distilled.cloud/vercel
2
+
3
+ Effect-native SDK for [vercel](https://www.npmjs.com/package/@distilled.cloud/vercel).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @distilled.cloud/vercel effect
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { Effect, Layer } from "effect";
15
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
16
+ import * as Vercel from "@distilled.cloud/vercel";
17
+
18
+ const program = Effect.gen(function* () {
19
+ const result = yield* Vercel.dns.getDomainsRecord({});
20
+ return result;
21
+ });
22
+
23
+ const Live = Layer.mergeAll(
24
+ FetchHttpClient.layer,
25
+ Vercel.CredentialsFromEnv,
26
+ Vercel.VercelProtocol,
27
+ );
28
+
29
+ program.pipe(Effect.provide(Live), Effect.runPromise);
30
+ ```
31
+
32
+ ## Auth
33
+
34
+ Required: `VERCEL_TOKEN`. Optional: `VERCEL_API_URL`. Sent as `Authorization: Bearer`.
package/lib/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export * from "./errors.ts";
11
11
  export * as T from "./traits.ts";
12
12
  export { VercelProtocol, type VercelOpError, type VercelOpContext, } from "./protocol.ts";
13
13
  export * as Retry from "./retry.ts";
14
- export * as Services from "./services/index.ts";
14
+ export * from "./services/index.ts";
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -11,5 +11,5 @@ export * from "./errors.js";
11
11
  export * as T from "./traits.js";
12
12
  export { VercelProtocol, } from "./protocol.js";
13
13
  export * as Retry from "./retry.js";
14
- export * as Services from "./services/index.js";
14
+ export * from "./services/index.js";
15
15
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/protocol.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type * as Layer from "effect/Layer";
2
- import type * as HttpClient from "effect/unstable/http/HttpClient";
3
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
2
+ import type * as HttpClient from "effect/http/HttpClient";
3
+ import type * as HttpClientError from "effect/http/HttpClientError";
4
4
  import type * as API from "@distilled.cloud/core/api";
5
5
  import type { ConfigError } from "@distilled.cloud/core/errors";
6
6
  import { Credentials } from "./credentials.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAkBlE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAkCjD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAkBlE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAmCjD,CAAC"}
package/lib/protocol.js CHANGED
@@ -16,7 +16,7 @@ import * as Redacted from "effect/Redacted";
16
16
  import { HTTP_STATUS_MAP } from "@distilled.cloud/core/errors";
17
17
  import { makeRestProtocol, } from "@distilled.cloud/core/protocol-rest";
18
18
  import { Credentials } from "./credentials.js";
19
- import { Gone, PaymentRequired, UnknownVercelError, } from "./errors.js";
19
+ import { Gone, PaymentRequired, UnknownVercelError, VercelParseError, } from "./errors.js";
20
20
  /**
21
21
  * Vercel error bodies nest under `error`: `{ error: { code, message } }`.
22
22
  * A handful of edge paths (proxy 502s, HTML error pages) answer without that
@@ -65,5 +65,6 @@ export const VercelProtocol = makeRestProtocol({
65
65
  message,
66
66
  body,
67
67
  }),
68
+ parseError: ({ body, cause }) => new VercelParseError({ body, cause }),
68
69
  });
69
70
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,QAAQ,MAAM,iBAAiB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BACd,CAAC,CAAC,SAAS;QACjB,OAAO;QACP,IAAI;KACL,CAAC;IACJ,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;CACvE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { VercelParseError } from "./errors.ts";
2
+ import type { VercelOpError } from "./protocol.ts";
3
+ export declare const parseErrorIsDeclared: [VercelParseError] extends [VercelOpError] ? true : false;
4
+ //# sourceMappingURL=response-validation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAmCnD,eAAO,MAAM,oBAAoB,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,aAAa,CAAC,GACzE,IAAI,GACJ,KAAY,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { runValidationModes } from "@distilled.cloud/core/testing";
3
+ import * as Effect from "effect/Effect";
4
+ import { credentials } from "./credentials.js";
5
+ import { VercelParseError } from "./errors.js";
6
+ import * as Retry from "./retry.js";
7
+ import { listAiGatewayRules } from "./services/ai_gateway.js";
8
+ // listAiGatewayRules declares `{ rules: AiGatewayRule[] }`.
9
+ const run = (body) => runValidationModes(listAiGatewayRules({}).pipe(Retry.none, Effect.provide(credentials({ token: "test" }))), { body });
10
+ describe("Vercel response validation", () => {
11
+ test("a matching body succeeds unchanged in both modes", async () => {
12
+ const body = { rules: [] };
13
+ const { lenient, strict } = await run(JSON.stringify(body));
14
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
15
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
16
+ });
17
+ test("a body missing required members: lenient returns it, strict fails", async () => {
18
+ const { lenient, strict } = await run("{}");
19
+ expect(lenient).toMatchObject({ _tag: "Success", success: {} });
20
+ expect(strict._tag).toBe("Failure");
21
+ expect(strict.failure).toBeInstanceOf(VercelParseError);
22
+ });
23
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
24
+ const { lenient, strict } = await run("not json");
25
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
26
+ expect(strict.failure).toBeInstanceOf(VercelParseError);
27
+ });
28
+ });
29
+ // VercelParseError is part of every operation's declared error type.
30
+ export const parseErrorIsDeclared = true;
31
+ //# sourceMappingURL=response-validation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-validation.test.js","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,4DAA4D;AAC5D,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,kBAAkB,CAAC,EAAE,CAAC,CAAC,IAAI,CACzB,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAC/C,EACD,EAAE,IAAI,EAAE,CACT,CAAC;AAEJ,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MA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AEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/vercel",
3
- "version": "1.0.0-rc.12",
3
+ "version": "1.0.0-rc.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -51,12 +51,6 @@
51
51
  "worker": "./src/traits.ts",
52
52
  "default": "./lib/traits.js"
53
53
  },
54
- "./Services": {
55
- "types": "./lib/services/index.d.ts",
56
- "bun": "./src/services/index.ts",
57
- "worker": "./src/services/index.ts",
58
- "default": "./lib/services/index.js"
59
- },
60
54
  "./*": {
61
55
  "types": "./lib/services/*.d.ts",
62
56
  "bun": "./src/services/*.ts",
@@ -65,15 +59,15 @@
65
59
  }
66
60
  },
67
61
  "dependencies": {
68
- "@distilled.cloud/core": "1.0.0-rc.12"
62
+ "@distilled.cloud/core": "1.0.0-rc.13"
69
63
  },
70
64
  "devDependencies": {
71
65
  "@types/bun": "1.3.14",
72
66
  "@types/node": "26.2.0",
73
- "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
67
+ "@effect/platform-bun": "^4.0.0"
74
68
  },
75
69
  "peerDependencies": {
76
- "effect": ">=4.0.0-rc.115 || >=4.0.0"
70
+ "effect": "^4.0.0"
77
71
  },
78
72
  "scripts": {
79
73
  "build": "tsc -b",
package/src/index.ts CHANGED
@@ -15,4 +15,4 @@ export {
15
15
  type VercelOpContext,
16
16
  } from "./protocol.ts";
17
17
  export * as Retry from "./retry.ts";
18
- export * as Services from "./services/index.ts";
18
+ export * from "./services/index.ts";
package/src/protocol.ts CHANGED
@@ -14,8 +14,8 @@
14
14
  import * as Effect from "effect/Effect";
15
15
  import type * as Layer from "effect/Layer";
16
16
  import * as Redacted from "effect/Redacted";
17
- import type * as HttpClient from "effect/unstable/http/HttpClient";
18
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
17
+ import type * as HttpClient from "effect/http/HttpClient";
18
+ import type * as HttpClientError from "effect/http/HttpClientError";
19
19
  import type * as API from "@distilled.cloud/core/api";
20
20
  import type { ConfigError } from "@distilled.cloud/core/errors";
21
21
  import { HTTP_STATUS_MAP } from "@distilled.cloud/core/errors";
@@ -29,6 +29,7 @@ import {
29
29
  PaymentRequired,
30
30
  UnknownVercelError,
31
31
  type DefaultErrors,
32
+ VercelParseError,
32
33
  } from "./errors.ts";
33
34
 
34
35
  /**
@@ -95,4 +96,5 @@ export const VercelProtocol: Layer.Layer<API.Protocol> =
95
96
  message,
96
97
  body,
97
98
  }),
99
+ parseError: ({ body, cause }) => new VercelParseError({ body, cause }),
98
100
  });
@@ -0,0 +1,45 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { runValidationModes } from "@distilled.cloud/core/testing";
3
+ import * as Effect from "effect/Effect";
4
+ import { credentials } from "./credentials.ts";
5
+ import { VercelParseError } from "./errors.ts";
6
+ import * as Retry from "./retry.ts";
7
+ import { listAiGatewayRules } from "./services/ai_gateway.ts";
8
+ import type { VercelOpError } from "./protocol.ts";
9
+
10
+ // listAiGatewayRules declares `{ rules: AiGatewayRule[] }`.
11
+ const run = (body: string) =>
12
+ runValidationModes(
13
+ listAiGatewayRules({}).pipe(
14
+ Retry.none,
15
+ Effect.provide(credentials({ token: "test" })),
16
+ ),
17
+ { body },
18
+ );
19
+
20
+ describe("Vercel response validation", () => {
21
+ test("a matching body succeeds unchanged in both modes", async () => {
22
+ const body = { rules: [] };
23
+ const { lenient, strict } = await run(JSON.stringify(body));
24
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
25
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
26
+ });
27
+
28
+ test("a body missing required members: lenient returns it, strict fails", async () => {
29
+ const { lenient, strict } = await run("{}");
30
+ expect(lenient).toMatchObject({ _tag: "Success", success: {} });
31
+ expect(strict._tag).toBe("Failure");
32
+ expect((strict as any).failure).toBeInstanceOf(VercelParseError);
33
+ });
34
+
35
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
36
+ const { lenient, strict } = await run("not json");
37
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
38
+ expect((strict as any).failure).toBeInstanceOf(VercelParseError);
39
+ });
40
+ });
41
+
42
+ // VercelParseError is part of every operation's declared error type.
43
+ export const parseErrorIsDeclared: [VercelParseError] extends [VercelOpError]
44
+ ? true
45
+ : false = true;