@distilled.cloud/render 1.0.0-rc.13 → 1.0.0-rc.15
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/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +3 -3
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +3 -7
- package/lib/pagination.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -6
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/render.d.ts +622 -128
- package/lib/services/render.d.ts.map +1 -1
- package/lib/services/render.js +921 -1177
- package/lib/services/render.js.map +1 -1
- package/package.json +12 -10
- package/src/credentials.ts +7 -8
- package/src/errors.ts +5 -8
- package/src/index.ts +2 -11
- package/src/pagination.ts +7 -19
- package/src/protocol.ts +26 -32
- package/src/retry.ts +2 -8
- package/src/services/render.ts +2493 -2815
- package/lib/response-validation.test.d.ts +0 -4
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -33
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -47
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/render",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.15",
|
|
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.
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.15"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/node": "26.2.0",
|
|
72
|
-
"@effect/platform-bun": "^4.0.0"
|
|
70
|
+
"@types/node": "26.2.0"
|
|
73
71
|
},
|
|
74
72
|
"peerDependencies": {
|
|
75
73
|
"effect": "^4.0.0"
|
|
76
74
|
},
|
|
75
|
+
"distilled": {
|
|
76
|
+
"generatedAt": "2026-10-06",
|
|
77
|
+
"specUpdatedAt": "2026-10-06"
|
|
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"
|
package/src/credentials.ts
CHANGED
|
@@ -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
|
-
|
|
24
|
-
|
|
25
|
-
>()("RenderCredentials") {}
|
|
22
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
23
|
+
"RenderCredentials",
|
|
24
|
+
) {}
|
|
26
25
|
|
|
27
|
-
/** Layer from a
|
|
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:
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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,13 +18,10 @@
|
|
|
15
18
|
* HTTP-status classes, then {@link UnknownRenderError}.
|
|
16
19
|
*/
|
|
17
20
|
import * as Effect from "effect/Effect";
|
|
18
|
-
import type * as Layer from "effect/Layer";
|
|
19
|
-
import * as Redacted from "effect/Redacted";
|
|
20
21
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
21
22
|
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
22
|
-
import type * as
|
|
23
|
-
import
|
|
24
|
-
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
23
|
+
import type * as Layer from "effect/Layer";
|
|
24
|
+
import * as Redacted from "effect/Redacted";
|
|
25
25
|
import { Credentials, type Config } from "./credentials.ts";
|
|
26
26
|
import { UnknownRenderError, RenderParseError } from "./errors.ts";
|
|
27
27
|
|
|
@@ -41,31 +41,25 @@ export type RenderOpError =
|
|
|
41
41
|
/** Context (requirements) shared by every generated Render operation. */
|
|
42
42
|
export type RenderOpContext = Credentials | HttpClient.HttpClient;
|
|
43
43
|
|
|
44
|
-
export const RenderProtocol: Layer.Layer<API.Protocol> =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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,
|
|
56
63
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
unknownError: ({ code, message, body }) =>
|
|
60
|
-
new UnknownRenderError({
|
|
61
|
-
code:
|
|
62
|
-
typeof code === "string"
|
|
63
|
-
? code
|
|
64
|
-
: code !== undefined
|
|
65
|
-
? String(code)
|
|
66
|
-
: undefined,
|
|
67
|
-
message,
|
|
68
|
-
body,
|
|
69
|
-
}),
|
|
70
|
-
parseError: ({ body, cause }) => new RenderParseError({ body, cause }),
|
|
71
|
-
});
|
|
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);
|