@distilled.cloud/core 0.0.0 → 0.2.0

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.
@@ -0,0 +1,123 @@
1
+ /**
2
+ * REST API Client
3
+ *
4
+ * Provides the core API.make() factory for building typed Effect-based API operations.
5
+ * This is the shared client for REST/OpenAPI-style SDKs (PlanetScale, Neon, GCP).
6
+ *
7
+ * AWS and Cloudflare have their own more specialized client implementations,
8
+ * but they share the same OperationMethod pattern.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { API } from "@distilled.cloud/sdk-core/client";
13
+ *
14
+ * const listDatabases = API.make(() => ({
15
+ * inputSchema: ListDatabasesInput,
16
+ * outputSchema: ListDatabasesOutput,
17
+ * errors: [NotFound, Forbidden] as const,
18
+ * }));
19
+ *
20
+ * // Direct call
21
+ * const result = yield* listDatabases({ organization: "my-org" });
22
+ *
23
+ * // Yield first for requirement-free function
24
+ * const fn = yield* listDatabases;
25
+ * const result = yield* fn({ organization: "my-org" });
26
+ * ```
27
+ */
28
+ import * as Effect from "effect/Effect";
29
+ import * as Schema from "effect/Schema";
30
+ import * as Stream from "effect/Stream";
31
+ import type { PaginatedTrait } from "./pagination.ts";
32
+ /**
33
+ * An operation that can be used in two ways:
34
+ * 1. Direct call: `yield* operation(input)` - returns Effect with requirements
35
+ * 2. Yield first: `const fn = yield* operation` - captures services, returns requirement-free function
36
+ */
37
+ export type OperationMethod<I, A, E, R> = Effect.Effect<(input: I) => Effect.Effect<A, E, never>, never, R> & ((input: I) => Effect.Effect<A, E, R>);
38
+ /**
39
+ * A paginated operation that additionally has `.pages()` and `.items()` methods.
40
+ */
41
+ export type PaginatedOperationMethod<I, A, E, R> = OperationMethod<I, A, E, R> & {
42
+ pages: (input: I) => Stream.Stream<A, E, R>;
43
+ items: (input: I) => Stream.Stream<unknown, E, R>;
44
+ };
45
+ /**
46
+ * Configuration for the API client factory.
47
+ * SDKs provide this to customize how errors are matched and credentials are applied.
48
+ */
49
+ export interface ClientConfig<Creds> {
50
+ /** The credentials service tag */
51
+ credentials: {
52
+ new (): Creds;
53
+ };
54
+ /** Get the base URL from credentials */
55
+ getBaseUrl: (creds: Creds) => string;
56
+ /** Get authorization header(s) from credentials */
57
+ getAuthHeaders: (creds: Creds) => Record<string, string>;
58
+ /** Match an error response body to a typed error.
59
+ * Should return Effect.fail(error) for known errors,
60
+ * or Effect.fail(fallbackError) for unknown errors.
61
+ * The optional `errors` parameter provides per-operation typed error classes.
62
+ */
63
+ matchError: (status: number, body: unknown, errors?: readonly ApiErrorClass[]) => Effect.Effect<never, unknown>;
64
+ /** Parse error class for schema decode failures */
65
+ ParseError: new (props: {
66
+ body: unknown;
67
+ cause: unknown;
68
+ }) => unknown;
69
+ /**
70
+ * Optional transform applied to the response body before schema decoding.
71
+ * For example, Cloudflare wraps responses in `{ result: <data>, ... }`.
72
+ */
73
+ transformResponse?: (body: unknown) => unknown;
74
+ }
75
+ /**
76
+ * Base API error type - any error class with at least a _tag and message.
77
+ * Uses `new (...args: any[])` to accommodate error classes with extra fields (e.g. `code`).
78
+ */
79
+ export type ApiErrorClass = {
80
+ new (...args: any[]): {
81
+ readonly _tag: string;
82
+ readonly message: string;
83
+ };
84
+ };
85
+ /**
86
+ * Operation configuration with optional operation-specific errors.
87
+ * Supports both `inputSchema`/`outputSchema` and `input`/`output` aliases.
88
+ */
89
+ export interface OperationConfig<I extends Schema.Top, O extends Schema.Top, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
90
+ inputSchema?: I;
91
+ outputSchema?: O;
92
+ /** Alias for inputSchema (used by Cloudflare/GCP generators) */
93
+ input?: I;
94
+ /** Alias for outputSchema (used by Cloudflare/GCP generators) */
95
+ output?: O;
96
+ errors?: E;
97
+ }
98
+ /**
99
+ * Paginated operation configuration.
100
+ */
101
+ export interface PaginatedOperationConfig<I extends Schema.Top, O extends Schema.Top, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, E> {
102
+ pagination?: PaginatedTrait;
103
+ }
104
+ /**
105
+ * Creates an API namespace bound to a specific SDK's client configuration.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * // In planetscale-sdk/src/client.ts
110
+ * export const API = makeAPI({
111
+ * credentials: Credentials,
112
+ * getBaseUrl: (c) => c.apiBaseUrl,
113
+ * getAuthHeaders: (c) => ({ Authorization: c.token }),
114
+ * matchError: matchPlanetScaleError,
115
+ * ParseError: PlanetScaleParseError,
116
+ * });
117
+ * ```
118
+ */
119
+ export declare const makeAPI: <Creds>(config: ClientConfig<Creds>) => {
120
+ make: <I extends Schema.Top, O extends Schema.Top, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, E>) => any;
121
+ makePaginated: <I extends Schema.Top, O extends Schema.Top, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, E>, paginateFn?: ((baseFn: (input: any) => Effect.Effect<any, any, any>, input: any, pagination: PaginatedTrait) => Stream.Stream<any, any, any>) | undefined) => any;
122
+ };
123
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAQxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMtD;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,CACrD,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EACxC,KAAK,EACL,CAAC,CACF,GACC,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AAM,aAAa,GAAG;IAC1B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,eAAe,CAC9B,CAAC,SAAS,MAAM,CAAC,GAAG,EACpB,CAAC,SAAS,MAAM,CAAC,GAAG,EACpB,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,aAAa,EAAE;IAE7D,WAAW,CAAC,EAAE,CAAC,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,iEAAiE;IACjE,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB,CACvC,CAAC,SAAS,MAAM,CAAC,GAAG,EACpB,CAAC,SAAS,MAAM,CAAC,GAAG,EACpB,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,aAAa,EAAE,CAC7D,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAmFD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK;WAKvB,CAAC,qBACD,CAAC,2BACK,CAAC;oBAmLP,CAAC,qBACD,CAAC,2BACK,CAAC;CA+EZ,CAAC"}
package/lib/client.js ADDED
@@ -0,0 +1,268 @@
1
+ /**
2
+ * REST API Client
3
+ *
4
+ * Provides the core API.make() factory for building typed Effect-based API operations.
5
+ * This is the shared client for REST/OpenAPI-style SDKs (PlanetScale, Neon, GCP).
6
+ *
7
+ * AWS and Cloudflare have their own more specialized client implementations,
8
+ * but they share the same OperationMethod pattern.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { API } from "@distilled.cloud/sdk-core/client";
13
+ *
14
+ * const listDatabases = API.make(() => ({
15
+ * inputSchema: ListDatabasesInput,
16
+ * outputSchema: ListDatabasesOutput,
17
+ * errors: [NotFound, Forbidden] as const,
18
+ * }));
19
+ *
20
+ * // Direct call
21
+ * const result = yield* listDatabases({ organization: "my-org" });
22
+ *
23
+ * // Yield first for requirement-free function
24
+ * const fn = yield* listDatabases;
25
+ * const result = yield* fn({ organization: "my-org" });
26
+ * ```
27
+ */
28
+ import * as Effect from "effect/Effect";
29
+ import { pipeArguments } from "effect/Pipeable";
30
+ import * as Schema from "effect/Schema";
31
+ import * as AST from "effect/SchemaAST";
32
+ import * as Stream from "effect/Stream";
33
+ import * as HttpBody from "effect/unstable/http/HttpBody";
34
+ import * as HttpClient from "effect/unstable/http/HttpClient";
35
+ import * as HttpClientError from "effect/unstable/http/HttpClientError";
36
+ import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
37
+ import { SingleShotGen } from "effect/Utils";
38
+ import * as Traits from "./traits.js";
39
+ import { getPath } from "./traits.js";
40
+ // ============================================================================
41
+ // AST Helpers
42
+ // ============================================================================
43
+ /**
44
+ * Check if a schema AST represents an array type.
45
+ * Follows encoding chains and Suspend wrappers.
46
+ */
47
+ function isArrayAST(ast) {
48
+ if (ast._tag === "Arrays")
49
+ return true;
50
+ if (ast._tag === "Suspend")
51
+ return isArrayAST(ast.thunk());
52
+ if (ast.encoding && ast.encoding.length > 0)
53
+ return isArrayAST(ast.encoding[0].to);
54
+ return false;
55
+ }
56
+ // ============================================================================
57
+ // Multipart FormData Builder
58
+ // ============================================================================
59
+ /**
60
+ * Check if a value is a File or Blob.
61
+ */
62
+ function isFileOrBlob(value) {
63
+ return ((typeof File !== "undefined" && value instanceof File) ||
64
+ (typeof Blob !== "undefined" && value instanceof Blob));
65
+ }
66
+ /**
67
+ * Build a FormData from a record of body properties.
68
+ * Handles files/blobs, arrays of files, objects (as JSON blobs), and primitives.
69
+ *
70
+ * This is used for multipart operations (e.g., Cloudflare Workers script uploads)
71
+ * where the body contains a mix of metadata objects and file uploads.
72
+ */
73
+ function buildFormData(body) {
74
+ const formData = new FormData();
75
+ for (const [key, value] of Object.entries(body)) {
76
+ if (value === undefined || value === null)
77
+ continue;
78
+ if (isFileOrBlob(value)) {
79
+ // Single file/blob
80
+ formData.append(key, value, value instanceof File ? value.name : key);
81
+ }
82
+ else if (Array.isArray(value) &&
83
+ value.length > 0 &&
84
+ isFileOrBlob(value[0])) {
85
+ // Array of files/blobs — append each individually
86
+ for (const file of value) {
87
+ if (isFileOrBlob(file)) {
88
+ formData.append(file instanceof File ? file.name : key, file, file instanceof File ? file.name : undefined);
89
+ }
90
+ }
91
+ }
92
+ else if (typeof value === "object" && value !== null) {
93
+ // Object → append as JSON blob
94
+ formData.append(key, new Blob([JSON.stringify(value)], { type: "application/json" }), key);
95
+ }
96
+ else {
97
+ // Primitive → append as string
98
+ formData.append(key, String(value));
99
+ }
100
+ }
101
+ return formData;
102
+ }
103
+ // ============================================================================
104
+ // API Client Factory
105
+ // ============================================================================
106
+ /**
107
+ * Creates an API namespace bound to a specific SDK's client configuration.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * // In planetscale-sdk/src/client.ts
112
+ * export const API = makeAPI({
113
+ * credentials: Credentials,
114
+ * getBaseUrl: (c) => c.apiBaseUrl,
115
+ * getAuthHeaders: (c) => ({ Authorization: c.token }),
116
+ * matchError: matchPlanetScaleError,
117
+ * ParseError: PlanetScaleParseError,
118
+ * });
119
+ * ```
120
+ */
121
+ export const makeAPI = (config) => {
122
+ return {
123
+ make: (configFn) => {
124
+ const opConfig = configFn();
125
+ // Support both input/output and inputSchema/outputSchema aliases
126
+ const inputSchema = (opConfig.inputSchema ?? opConfig.input);
127
+ const outputSchema = (opConfig.outputSchema ?? opConfig.output);
128
+ // Read HTTP trait from input schema annotations
129
+ const httpTrait = Traits.getHttpTrait(inputSchema.ast);
130
+ if (!httpTrait) {
131
+ throw new Error("Input schema must have Http trait");
132
+ }
133
+ const method = httpTrait.method;
134
+ const fn = (input) => Effect.gen(function* () {
135
+ const creds = yield* config.credentials;
136
+ const client = yield* HttpClient.HttpClient;
137
+ const baseUrl = config.getBaseUrl(creds);
138
+ const authHeaders = config.getAuthHeaders(creds);
139
+ // Use schema-aware request builder for proper camelCase → wire_name mapping
140
+ const parts = Traits.buildRequestParts(inputSchema.ast, httpTrait, input, inputSchema);
141
+ let request = HttpClientRequest.make(method)(baseUrl + parts.path).pipe(HttpClientRequest.setHeaders(authHeaders), HttpClientRequest.setHeaders(parts.headers), HttpClientRequest.setHeader("Accept", "application/json"));
142
+ // Set Content-Type based on body type (skip for FormData — browser sets boundary)
143
+ if (!parts.isMultipart) {
144
+ request = HttpClientRequest.setHeader("Content-Type", "application/json")(request);
145
+ }
146
+ if (Object.keys(parts.query).length > 0) {
147
+ request = HttpClientRequest.setUrlParams(request, parts.query);
148
+ }
149
+ if (method !== "GET" && parts.body !== undefined) {
150
+ if (parts.isMultipart) {
151
+ // Build FormData from body properties for multipart operations
152
+ const formData = buildFormData(parts.body);
153
+ request = HttpClientRequest.setBody(HttpBody.formData(formData))(request);
154
+ }
155
+ else {
156
+ request = yield* HttpClientRequest.bodyJson(parts.body)(request);
157
+ }
158
+ }
159
+ else if (method === "GET" && parts.body !== undefined) {
160
+ // For GET requests, remaining non-annotated fields go as query params
161
+ const extraQuery = {};
162
+ for (const [key, value] of Object.entries(parts.body)) {
163
+ if (value !== undefined) {
164
+ extraQuery[key] = String(value);
165
+ }
166
+ }
167
+ if (Object.keys(extraQuery).length > 0) {
168
+ request = HttpClientRequest.setUrlParams(request, extraQuery);
169
+ }
170
+ }
171
+ const response = yield* client.execute(request).pipe(Effect.scoped);
172
+ if (response.status >= 400) {
173
+ // Try to parse error body as JSON; fall back to text if not JSON
174
+ const errorBody = yield* response.json.pipe(Effect.catchIf(() => true, () => response.text.pipe(Effect.map((text) => ({ _nonJsonError: true, body: text })), Effect.catchIf(() => true, () => Effect.succeed({
175
+ _nonJsonError: true,
176
+ body: `HTTP ${response.status}`,
177
+ })))));
178
+ return yield* config.matchError(response.status, errorBody, opConfig.errors);
179
+ }
180
+ // For void-returning operations (e.g. DELETE 204 No Content)
181
+ if (AST.isVoid(outputSchema.ast)) {
182
+ return undefined;
183
+ }
184
+ // For 204 No Content: if schema is not Unknown, return undefined.
185
+ // If schema IS Unknown, return empty string (so callers get a defined value).
186
+ if (response.status === 204) {
187
+ if (outputSchema.ast._tag === "Unknown") {
188
+ return "";
189
+ }
190
+ return undefined;
191
+ }
192
+ // Try to parse response as JSON; fall back to text for non-JSON responses
193
+ // (e.g., multipart/form-data worker scripts, raw KV values)
194
+ const rawBody = yield* response.json.pipe(Effect.catchIf(() => true, () => response.text.pipe(Effect.map((text) => text))));
195
+ let responseBody = config.transformResponse
196
+ ? config.transformResponse(rawBody)
197
+ : rawBody;
198
+ // Handle Cloudflare-style paginated responses where result is
199
+ // { items: [...] } but the schema expects an array
200
+ if (isArrayAST(outputSchema.ast) &&
201
+ !Array.isArray(responseBody) &&
202
+ typeof responseBody === "object" &&
203
+ responseBody !== null &&
204
+ "items" in responseBody &&
205
+ Array.isArray(responseBody.items)) {
206
+ responseBody = responseBody.items;
207
+ }
208
+ return yield* Schema.decodeUnknownEffect(outputSchema)(responseBody).pipe(Effect.catchTag("SchemaError", (cause) => Effect.fail(new config.ParseError({ body: rawBody, cause }))));
209
+ });
210
+ const Proto = {
211
+ [Symbol.iterator]() {
212
+ return new SingleShotGen(this);
213
+ },
214
+ pipe() {
215
+ return pipeArguments(this.asEffect(), arguments);
216
+ },
217
+ asEffect() {
218
+ return Effect.map(Effect.services(), (sm) => (input) => fn(input).pipe(Effect.provide(sm)));
219
+ },
220
+ };
221
+ return Object.assign(fn, Proto);
222
+ },
223
+ makePaginated: (configFn, paginateFn) => {
224
+ const opConfig = configFn();
225
+ const pagination = opConfig.pagination;
226
+ // Create the base operation
227
+ const baseFn = makeAPI(config).make(() => ({
228
+ inputSchema: opConfig.inputSchema ?? opConfig.input,
229
+ outputSchema: opConfig.outputSchema ?? opConfig.output,
230
+ errors: opConfig.errors,
231
+ }));
232
+ // Default pagination: token-based (works for Cloudflare/GCP style)
233
+ const defaultPaginateFn = (op, input, pag) => {
234
+ return Stream.unfold({ token: undefined, done: false }, (state) => Effect.gen(function* () {
235
+ if (state.done)
236
+ return undefined;
237
+ const requestPayload = state.token !== undefined
238
+ ? { ...input, [pag.inputToken]: state.token }
239
+ : input;
240
+ const response = yield* op(requestPayload);
241
+ const nextToken = getPath(response, pag.outputToken);
242
+ return [
243
+ response,
244
+ {
245
+ token: nextToken,
246
+ done: nextToken === undefined || nextToken === null,
247
+ },
248
+ ];
249
+ }));
250
+ };
251
+ const paginate = paginateFn ?? defaultPaginateFn;
252
+ // Stream all pages
253
+ const pagesFn = (input) => paginate(baseFn, input, pagination);
254
+ // Stream individual items
255
+ const itemsFn = (input) => pagesFn(input).pipe(Stream.flatMap((page) => {
256
+ if (!pagination.items)
257
+ return Stream.make(page);
258
+ const items = getPath(page, pagination.items);
259
+ return Stream.fromIterable(items ?? []);
260
+ }));
261
+ const result = baseFn;
262
+ result.pages = pagesFn;
263
+ result.items = itemsFn;
264
+ return result;
265
+ },
266
+ };
267
+ };
268
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,UAAU,MAAM,iCAAi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,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAChD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAE/B,CAAC;gBACd,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC1C,CAAC,CAAC,CACH,CAAC;YAEJ,MAAM,MAAM,GAAG,MAGd,CAAC;YAEF,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;YACvB,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC;YAEvB,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Common error types shared across SDKs.
3
+ *
4
+ * Each SDK defines its own provider-specific errors (e.g., Unauthorized, NotFound)
5
+ * using the category system. This module provides base error types and utilities
6
+ * that are used across all SDKs.
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ import * as Category from "./category.ts";
10
+ declare const Unauthorized_base: Schema.ErrorClass<Unauthorized, Schema.TaggedStruct<"Unauthorized", {
11
+ readonly message: Schema.String;
12
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
13
+ "@distilled.cloud/error/categories": {
14
+ AuthError: true;
15
+ };
16
+ });
17
+ /**
18
+ * Unauthorized - Authentication failure (401).
19
+ */
20
+ export declare class Unauthorized extends Unauthorized_base {
21
+ }
22
+ declare const Forbidden_base: Schema.ErrorClass<Forbidden, Schema.TaggedStruct<"Forbidden", {
23
+ readonly message: Schema.String;
24
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
25
+ "@distilled.cloud/error/categories": {
26
+ AuthError: true;
27
+ };
28
+ });
29
+ /**
30
+ * Forbidden - Access denied (403).
31
+ */
32
+ export declare class Forbidden extends Forbidden_base {
33
+ }
34
+ declare const NotFound_base: Schema.ErrorClass<NotFound, Schema.TaggedStruct<"NotFound", {
35
+ readonly message: Schema.String;
36
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
37
+ "@distilled.cloud/error/categories": {
38
+ NotFoundError: true;
39
+ };
40
+ });
41
+ /**
42
+ * NotFound - Resource not found (404).
43
+ */
44
+ export declare class NotFound extends NotFound_base {
45
+ }
46
+ declare const BadRequest_base: Schema.ErrorClass<BadRequest, Schema.TaggedStruct<"BadRequest", {
47
+ readonly message: Schema.String;
48
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
49
+ "@distilled.cloud/error/categories": {
50
+ BadRequestError: true;
51
+ };
52
+ });
53
+ /**
54
+ * BadRequest - Invalid request (400).
55
+ */
56
+ export declare class BadRequest extends BadRequest_base {
57
+ }
58
+ declare const Conflict_base: Schema.ErrorClass<Conflict, Schema.TaggedStruct<"Conflict", {
59
+ readonly message: Schema.String;
60
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
61
+ "@distilled.cloud/error/categories": {
62
+ ConflictError: true;
63
+ };
64
+ });
65
+ /**
66
+ * Conflict - Resource conflict (409).
67
+ */
68
+ export declare class Conflict extends Conflict_base {
69
+ }
70
+ declare const UnprocessableEntity_base: Schema.ErrorClass<UnprocessableEntity, Schema.TaggedStruct<"UnprocessableEntity", {
71
+ readonly message: Schema.String;
72
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
73
+ "@distilled.cloud/error/categories": {
74
+ BadRequestError: true;
75
+ };
76
+ });
77
+ /**
78
+ * UnprocessableEntity - Validation error (422).
79
+ */
80
+ export declare class UnprocessableEntity extends UnprocessableEntity_base {
81
+ }
82
+ declare const TooManyRequests_base: Schema.ErrorClass<TooManyRequests, Schema.TaggedStruct<"TooManyRequests", {
83
+ readonly message: Schema.String;
84
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
85
+ "@distilled.cloud/error/categories": {
86
+ ThrottlingError: true;
87
+ };
88
+ }) & (new (...args: any[]) => {
89
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
90
+ });
91
+ /**
92
+ * TooManyRequests - Rate limited (429).
93
+ */
94
+ export declare class TooManyRequests extends TooManyRequests_base {
95
+ }
96
+ declare const Locked_base: Schema.ErrorClass<Locked, Schema.TaggedStruct<"Locked", {
97
+ readonly message: Schema.String;
98
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
99
+ "@distilled.cloud/error/categories": {
100
+ LockedError: true;
101
+ };
102
+ }) & (new (...args: any[]) => {
103
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
104
+ });
105
+ /**
106
+ * Locked - Resource locked (423).
107
+ */
108
+ export declare class Locked extends Locked_base {
109
+ }
110
+ declare const InternalServerError_base: Schema.ErrorClass<InternalServerError, Schema.TaggedStruct<"InternalServerError", {
111
+ readonly message: Schema.String;
112
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
113
+ "@distilled.cloud/error/categories": {
114
+ ServerError: true;
115
+ };
116
+ }) & (new (...args: any[]) => {
117
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
118
+ });
119
+ /**
120
+ * InternalServerError - Server error (500).
121
+ */
122
+ export declare class InternalServerError extends InternalServerError_base {
123
+ }
124
+ declare const ServiceUnavailable_base: Schema.ErrorClass<ServiceUnavailable, Schema.TaggedStruct<"ServiceUnavailable", {
125
+ readonly message: Schema.String;
126
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
127
+ "@distilled.cloud/error/categories": {
128
+ ServerError: true;
129
+ };
130
+ }) & (new (...args: any[]) => {
131
+ "@distilled.cloud/error/retryable": Category.RetryableInfo;
132
+ });
133
+ /**
134
+ * ServiceUnavailable - Service unavailable (503).
135
+ */
136
+ export declare class ServiceUnavailable extends ServiceUnavailable_base {
137
+ }
138
+ declare const ConfigError_base: Schema.ErrorClass<ConfigError, Schema.TaggedStruct<"ConfigError", {
139
+ readonly message: Schema.String;
140
+ }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
141
+ "@distilled.cloud/error/categories": {
142
+ ConfigurationError: true;
143
+ };
144
+ });
145
+ /**
146
+ * Configuration error - missing or invalid configuration.
147
+ */
148
+ export declare class ConfigError extends ConfigError_base {
149
+ }
150
+ /**
151
+ * Mapping from HTTP status codes to common error classes.
152
+ */
153
+ export declare const HTTP_STATUS_MAP: {
154
+ readonly 400: typeof BadRequest;
155
+ readonly 401: typeof Unauthorized;
156
+ readonly 403: typeof Forbidden;
157
+ readonly 404: typeof NotFound;
158
+ readonly 409: typeof Conflict;
159
+ readonly 422: typeof UnprocessableEntity;
160
+ readonly 423: typeof Locked;
161
+ readonly 429: typeof TooManyRequests;
162
+ readonly 500: typeof InternalServerError;
163
+ readonly 503: typeof ServiceUnavailable;
164
+ };
165
+ /**
166
+ * HTTP status codes that are considered "default" errors (always present).
167
+ * These are excluded from per-operation error types since they're handled globally.
168
+ */
169
+ export declare const DEFAULT_ERROR_STATUSES: Set<number>;
170
+ /**
171
+ * All common API error classes.
172
+ */
173
+ export declare const API_ERRORS: readonly [typeof Unauthorized, typeof Forbidden, typeof NotFound, typeof BadRequest, typeof Conflict, typeof UnprocessableEntity, typeof TooManyRequests, typeof Locked, typeof InternalServerError, typeof ServiceUnavailable];
174
+ /**
175
+ * Default errors that apply to ALL operations.
176
+ * These are infrastructure-level errors that can occur regardless of the operation.
177
+ */
178
+ export declare const DEFAULT_ERRORS: readonly [typeof Unauthorized, typeof TooManyRequests, typeof InternalServerError, typeof ServiceUnavailable];
179
+ export type DefaultErrors = InstanceType<(typeof DEFAULT_ERRORS)[number]>;
180
+ export {};
181
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;;;;;;;;AAM1C;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAGJ;CAAG;;;;;;;;AAEjC;;GAEG;AACH,qBAAa,SAAU,SA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