@distilled.cloud/render 1.0.0-rc.12 → 1.0.0-rc.14

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,18 +1,18 @@
1
1
  {
2
2
  "name": "@distilled.cloud/render",
3
- "version": "1.0.0-rc.12",
3
+ "version": "1.0.0-rc.14",
4
+ "license": "Apache-2.0",
4
5
  "repository": {
5
6
  "type": "git",
6
7
  "url": "https://github.com/alchemy-run/distilled",
7
8
  "directory": "packages/render"
8
9
  },
9
- "license": "Apache-2.0",
10
- "type": "module",
11
- "sideEffects": false,
12
10
  "files": [
13
11
  "lib",
14
12
  "src"
15
13
  ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./lib/index.d.ts",
@@ -64,20 +64,22 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "@distilled.cloud/core": "1.0.0-rc.12"
67
+ "@distilled.cloud/core": "1.0.0-rc.14"
68
68
  },
69
69
  "devDependencies": {
70
- "@types/bun": "1.3.14",
71
- "@types/node": "26.2.0",
72
- "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
70
+ "@types/node": "26.2.0"
73
71
  },
74
72
  "peerDependencies": {
75
- "effect": ">=4.0.0-rc.115 || >=4.0.0"
73
+ "effect": "^4.0.0"
74
+ },
75
+ "distilled": {
76
+ "generatedAt": "2026-10-06",
77
+ "specUpdatedAt": "2026-10-06"
76
78
  },
77
79
  "scripts": {
78
80
  "build": "tsc -b",
79
- "convert": "bun scripts/convert.ts",
80
- "generate": "bun scripts/convert.ts && bun scripts/generate.ts",
81
+ "convert": "node --conditions=bun scripts/convert.ts",
82
+ "generate": "node --conditions=bun scripts/convert.ts && node --conditions=bun scripts/generate.ts",
81
83
  "typecheck": "tsc -p tsconfig.json",
82
84
  "specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-render",
83
85
  "specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-render"
@@ -1,3 +1,4 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
1
2
  /**
2
3
  * Render credentials — hand-written.
3
4
  *
@@ -10,7 +11,6 @@ import * as Context from "effect/Context";
10
11
  import * as Effect from "effect/Effect";
11
12
  import * as Layer from "effect/Layer";
12
13
  import * as Redacted from "effect/Redacted";
13
- import { ConfigError } from "@distilled.cloud/core/errors";
14
14
 
15
15
  export const DEFAULT_API_BASE_URL = "https://api.render.com/v1";
16
16
 
@@ -19,20 +19,19 @@ export interface Config {
19
19
  readonly apiBaseUrl: string;
20
20
  }
21
21
 
22
- export class Credentials extends Context.Service<
23
- Credentials,
24
- Effect.Effect<Config>
25
- >()("RenderCredentials") {}
22
+ export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
23
+ "RenderCredentials",
24
+ ) {}
26
25
 
27
- /** Layer from a plain API key + optional base URL. */
26
+ /** Layer from a redacted API key + optional base URL. */
28
27
  export const fromApiKey = (config: {
29
- readonly apiKey: string;
28
+ readonly apiKey: Redacted.Redacted<string>;
30
29
  readonly apiBaseUrl?: string;
31
30
  }): Layer.Layer<Credentials> =>
32
31
  Layer.succeed(
33
32
  Credentials,
34
33
  Effect.succeed({
35
- apiKey: Redacted.make(config.apiKey),
34
+ apiKey: config.apiKey,
36
35
  apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
37
36
  }),
38
37
  );
package/src/errors.ts CHANGED
@@ -27,8 +27,8 @@ export {
27
27
  } from "@distilled.cloud/core/errors";
28
28
  export type { DefaultErrors } from "@distilled.cloud/core/errors";
29
29
 
30
- import * as Schema from "effect/Schema";
31
30
  import * as Category from "@distilled.cloud/core/category";
31
+ import * as Schema from "effect/Schema";
32
32
 
33
33
  /** Unknown Render error — returned when nothing else matches the failure. */
34
34
  export class UnknownRenderError extends Schema.TaggedError<UnknownRenderError>()(
@@ -41,10 +41,7 @@ export class UnknownRenderError extends Schema.TaggedError<UnknownRenderError>()
41
41
  ).pipe(Category.withServerError) {}
42
42
 
43
43
  /** Schema parse error wrapper. */
44
- export class RenderParseError extends Schema.TaggedError<RenderParseError>()(
45
- "RenderParseError",
46
- {
47
- body: Schema.Unknown,
48
- cause: Schema.Unknown,
49
- },
50
- ).pipe(Category.withParseError) {}
44
+ export class RenderParseError extends Schema.TaggedError<RenderParseError>()("RenderParseError", {
45
+ body: Schema.Unknown,
46
+ cause: Schema.Unknown,
47
+ }).pipe(Category.withParseError) {}
package/src/index.ts CHANGED
@@ -15,11 +15,7 @@
15
15
  export * from "./credentials.ts";
16
16
  export * from "./errors.ts";
17
17
  export * as T from "./traits.ts";
18
- export {
19
- RenderProtocol,
20
- type RenderOpError,
21
- type RenderOpContext,
22
- } from "./protocol.ts";
18
+ export { RenderProtocol, type RenderOpError, type RenderOpContext } from "./protocol.ts";
23
19
  export { paginateCursor, paginateRender } from "./pagination.ts";
24
20
  export * as Retry from "./retry.ts";
25
21
  export * as Services from "./services/index.ts";
@@ -28,9 +24,4 @@ export * as Services from "./services/index.ts";
28
24
  // same-named shared ones from ./errors.ts — the ops actually raise the
29
25
  // service-local classes.
30
26
  export * from "./services/render.ts";
31
- export {
32
- BadRequest,
33
- Conflict,
34
- Forbidden,
35
- NotFound,
36
- } from "./services/render.ts";
27
+ export { BadRequest, Conflict, Forbidden, NotFound } from "./services/render.ts";
package/src/pagination.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as Pagination from "@distilled.cloud/core/pagination";
1
2
  /**
2
3
  * Render pagination — hand-written.
3
4
  *
@@ -9,7 +10,6 @@
9
10
  */
10
11
  import * as Effect from "effect/Effect";
11
12
  import * as Stream from "effect/Stream";
12
- import * as Pagination from "@distilled.cloud/core/pagination";
13
13
 
14
14
  export { paginateCursor } from "@distilled.cloud/core/pagination";
15
15
 
@@ -17,24 +17,16 @@ export { paginateCursor } from "@distilled.cloud/core/pagination";
17
17
  * Walk forward with `cursor` set to the last item's `cursor` until a page
18
18
  * comes back empty or the cursor does not advance.
19
19
  */
20
- export const paginateRender: Pagination.PaginationStrategy = (
21
- operation,
22
- input,
23
- pagination,
24
- ) => {
20
+ export const paginateRender: Pagination.PaginationStrategy = (operation, input, pagination) => {
25
21
  const inputToken = pagination.inputToken;
26
22
  if (!inputToken) {
27
- return Stream.die(
28
- new Error("Render cursor pagination requires inputToken"),
29
- );
23
+ return Stream.die(new Error("Render cursor pagination requires inputToken"));
30
24
  }
31
25
  const itemsPath = pagination.items ?? "body";
32
26
 
33
27
  type State = { cursor: string | undefined; done: boolean };
34
28
  const startCursor =
35
- typeof input[inputToken] === "string"
36
- ? (input[inputToken] as string)
37
- : undefined;
29
+ typeof input[inputToken] === "string" ? (input[inputToken] as string) : undefined;
38
30
 
39
31
  return Stream.unfold({ cursor: startCursor, done: false } as State, (state) =>
40
32
  Effect.gen(function* () {
@@ -45,14 +37,10 @@ export const paginateRender: Pagination.PaginationStrategy = (
45
37
  ...(state.cursor ? { [inputToken]: state.cursor } : {}),
46
38
  } as typeof input;
47
39
  const response = yield* operation(requestPayload);
48
- const items = Array.isArray(response)
49
- ? response
50
- : Pagination.getItems(response, itemsPath);
40
+ const items = Array.isArray(response) ? response : Pagination.getItems(response, itemsPath);
51
41
  const last = items.at(-1) as { cursor?: unknown } | undefined;
52
- const nextCursor =
53
- typeof last?.cursor === "string" ? last.cursor : undefined;
54
- const stuckCursor =
55
- state.cursor !== undefined && nextCursor === state.cursor;
42
+ const nextCursor = typeof last?.cursor === "string" ? last.cursor : undefined;
43
+ const stuckCursor = state.cursor !== undefined && nextCursor === state.cursor;
56
44
 
57
45
  return [
58
46
  response,
package/src/protocol.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import type * as API from "@distilled.cloud/core/api";
2
+ import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
3
+ import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
1
4
  /**
2
5
  * RenderProtocol — hand-written.
3
6
  *
@@ -15,15 +18,12 @@
15
18
  * HTTP-status classes, then {@link UnknownRenderError}.
16
19
  */
17
20
  import * as Effect from "effect/Effect";
21
+ import type * as HttpClient from "effect/http/HttpClient";
22
+ import type * as HttpClientError from "effect/http/HttpClientError";
18
23
  import type * as Layer from "effect/Layer";
19
24
  import * as Redacted from "effect/Redacted";
20
- import type * as HttpClient from "effect/unstable/http/HttpClient";
21
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
22
- import type * as API from "@distilled.cloud/core/api";
23
- import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
24
- import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
25
25
  import { Credentials, type Config } from "./credentials.ts";
26
- import { UnknownRenderError } from "./errors.ts";
26
+ import { UnknownRenderError, RenderParseError } from "./errors.ts";
27
27
 
28
28
  /**
29
29
  * Error channel shared by every generated Render operation. Generated
@@ -35,35 +35,31 @@ export type RenderOpError =
35
35
  | InstanceType<(typeof API_ERRORS)[number]>
36
36
  | UnknownRenderError
37
37
  | ConfigError
38
- | HttpClientError.HttpClientError;
38
+ | HttpClientError.HttpClientError
39
+ | RenderParseError;
39
40
 
40
41
  /** Context (requirements) shared by every generated Render operation. */
41
42
  export type RenderOpContext = Credentials | HttpClient.HttpClient;
42
43
 
43
- export const RenderProtocol: Layer.Layer<API.Protocol> =
44
- makeRestProtocol<Config>({
45
- // The Credentials service holds an effect — resolving it here (per
46
- // request, on the calling fiber) picks up context-provided credentials.
47
- credentials: Effect.gen(function* () {
48
- const resolve = yield* Credentials;
49
- return yield* resolve;
50
- }),
51
- baseUrl: (creds) => creds.apiBaseUrl,
52
- headers: (creds) => ({
53
- Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
54
- Accept: "application/json",
44
+ export const RenderProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
45
+ // The Credentials service holds an effect — resolving it here (per
46
+ // request, on the calling fiber) picks up context-provided credentials.
47
+ credentials: Effect.gen(function* () {
48
+ const resolve = yield* Credentials;
49
+ return yield* resolve;
50
+ }),
51
+ baseUrl: (creds) => creds.apiBaseUrl,
52
+ headers: (creds) => ({
53
+ Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
54
+ Accept: "application/json",
55
+ }),
56
+ // Render's error body is `{ message: string }` — the factory's default
57
+ // lenient envelope covers it.
58
+ unknownError: ({ code, message, body }) =>
59
+ new UnknownRenderError({
60
+ code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
61
+ message,
62
+ body,
55
63
  }),
56
- // Render's error body is `{ message: string }` — the factory's default
57
- // lenient envelope covers it.
58
- unknownError: ({ code, message, body }) =>
59
- new UnknownRenderError({
60
- code:
61
- typeof code === "string"
62
- ? code
63
- : code !== undefined
64
- ? String(code)
65
- : undefined,
66
- message,
67
- body,
68
- }),
69
- });
64
+ parseError: ({ body, cause }) => new RenderParseError({ body, cause }),
65
+ });
package/src/retry.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
1
2
  /**
2
3
  * Render retry configuration.
3
4
  *
@@ -16,11 +17,6 @@
16
17
  import * as Context from "effect/Context";
17
18
  import * as Effect from "effect/Effect";
18
19
  import * as Layer from "effect/Layer";
19
- import {
20
- type Policy,
21
- throttlingFactory,
22
- transientFactory,
23
- } from "@distilled.cloud/core/retry";
24
20
 
25
21
  export {
26
22
  type Options,
@@ -43,9 +39,7 @@ export const policy = (optionsOrFactory: Policy) =>
43
39
  Effect.provide(Layer.succeed(Retry, optionsOrFactory));
44
40
 
45
41
  /** Disables all automatic retries. */
46
- export const none = Effect.provide(
47
- Layer.succeed(Retry, { while: () => false }),
48
- );
42
+ export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
49
43
 
50
44
  /** Apply the throttling retry policy (retries throttling errors indefinitely). */
51
45
  export const throttling = policy(throttlingFactory);