@distilled.cloud/turso 0.0.0-john
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 +35 -0
- package/lib/category.d.ts +5 -0
- package/lib/category.d.ts.map +1 -0
- package/lib/category.js +5 -0
- package/lib/category.js.map +1 -0
- package/lib/client.d.ts +10 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +52 -0
- package/lib/client.js.map +1 -0
- package/lib/credentials.d.ts +15 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +18 -0
- package/lib/credentials.js.map +1 -0
- package/lib/errors.d.ts +31 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +23 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -0
- package/lib/index.js.map +1 -0
- package/lib/operations/index.d.ts +2 -0
- package/lib/operations/index.d.ts.map +1 -0
- package/lib/operations/index.js +3 -0
- package/lib/operations/index.js.map +1 -0
- package/lib/retry.d.ts +22 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +21 -0
- package/lib/retry.js.map +1 -0
- package/lib/sensitive.d.ts +5 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +5 -0
- package/lib/sensitive.js.map +1 -0
- package/lib/traits.d.ts +5 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +5 -0
- package/lib/traits.js.map +1 -0
- package/package.json +88 -0
- package/src/category.ts +4 -0
- package/src/client.ts +63 -0
- package/src/credentials.ts +31 -0
- package/src/errors.ts +47 -0
- package/src/index.ts +15 -0
- package/src/operations/index.ts +2 -0
- package/src/retry.ts +35 -0
- package/src/sensitive.ts +4 -0
- package/src/traits.ts +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @distilled.cloud/turso
|
|
2
|
+
|
|
3
|
+
Effect-native Turso SDK generated from the [Turso API documentation](https://docs.turso.tech/api-reference). Manage databases, organizations, and groups with exhaustive error typing.
|
|
4
|
+
|
|
5
|
+
> **Note:** This SDK is a stub -- operations have not yet been generated. Run `bun run generate` after fetching specs to populate the operations.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @distilled.cloud/turso effect
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Effect, Layer } from "effect";
|
|
17
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
18
|
+
import { CredentialsFromEnv } from "@distilled.cloud/turso";
|
|
19
|
+
|
|
20
|
+
const TursoLive = Layer.mergeAll(FetchHttpClient.layer, CredentialsFromEnv);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
Set the following environment variable:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
TURSO_API_KEY=your-api-token
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Create an API token with `turso auth api-tokens mint` or in the [Turso dashboard](https://app.turso.tech/) under **Settings > API Tokens**.
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../src/category.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gCAAgC,CAAC"}
|
package/lib/category.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../src/category.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gCAAgC,CAAC"}
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
export { UnknownTursoError } from "./errors.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Turso API client.
|
|
5
|
+
*/
|
|
6
|
+
export declare const API: {
|
|
7
|
+
make: <I extends Schema.Top, O extends Schema.Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").OperationConfig<I, O, E>) => any;
|
|
8
|
+
makePaginated: <I extends Schema.Top, O extends Schema.Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").PaginatedOperationConfig<I, O, E>, paginateFn?: import("@distilled.cloud/core/pagination").PaginationStrategy | undefined) => any;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAkChD;;GAEG;AACH,eAAO,MAAM,GAAG;;;CAQd,CAAC"}
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso API Client.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the shared REST client from sdk-core with Turso-specific
|
|
5
|
+
* error matching and credential handling.
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Redacted from "effect/Redacted";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import { makeAPI } from "@distilled.cloud/core/client";
|
|
11
|
+
import { HTTP_STATUS_MAP, UnknownTursoError, TursoParseError, } from "./errors.js";
|
|
12
|
+
// Re-export for backwards compatibility
|
|
13
|
+
export { UnknownTursoError } from "./errors.js";
|
|
14
|
+
import { Credentials } from "./credentials.js";
|
|
15
|
+
// API Error Response Schema
|
|
16
|
+
const ApiErrorResponse = Schema.Struct({
|
|
17
|
+
code: Schema.optional(Schema.String),
|
|
18
|
+
message: Schema.String,
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Match a Turso API error response to the appropriate error class based on HTTP status.
|
|
22
|
+
*/
|
|
23
|
+
const matchError = (status, errorBody) => {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
26
|
+
const ErrorClass = HTTP_STATUS_MAP[status];
|
|
27
|
+
if (ErrorClass) {
|
|
28
|
+
return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
|
|
29
|
+
}
|
|
30
|
+
return Effect.fail(new UnknownTursoError({
|
|
31
|
+
code: parsed.code,
|
|
32
|
+
message: parsed.message,
|
|
33
|
+
body: errorBody,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return Effect.fail(new UnknownTursoError({ body: errorBody }));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Turso API client.
|
|
42
|
+
*/
|
|
43
|
+
export const API = makeAPI({
|
|
44
|
+
credentials: Credentials,
|
|
45
|
+
getBaseUrl: (creds) => creds.apiBaseUrl,
|
|
46
|
+
getAuthHeaders: (creds) => ({
|
|
47
|
+
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
48
|
+
}),
|
|
49
|
+
matchError,
|
|
50
|
+
ParseError: TursoParseError,
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,wCAAwC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,SAAkB,EACa,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,UAAU,GAAI,eAAuB,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,iBAAiB,CAAC;YACpB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,SAAS;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC;IACzB,WAAW,EAAE,WAAkB;IAC/B,UAAU,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU;IAC5C,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,UAAU,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;KACxD,CAAC;IACF,UAAU;IACV,UAAU,EAAE,eAAsB;CACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import * as Redacted from "effect/Redacted";
|
|
3
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
4
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
5
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.turso.com";
|
|
6
|
+
export interface Config {
|
|
7
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
8
|
+
readonly apiBaseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
declare const Credentials_base: ServiceMap.ServiceClass<Credentials, "TursoCredentials", Config>;
|
|
11
|
+
export declare class Credentials extends Credentials_base {
|
|
12
|
+
}
|
|
13
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError, never>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAa9B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Redacted from "effect/Redacted";
|
|
4
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
5
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
6
|
+
export const DEFAULT_API_BASE_URL = "https://api.turso.com";
|
|
7
|
+
export class Credentials extends ServiceMap.Service()("TursoCredentials") {
|
|
8
|
+
}
|
|
9
|
+
export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function* () {
|
|
10
|
+
const apiKey = process.env.TURSO_API_KEY;
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
return yield* new ConfigError({
|
|
13
|
+
message: "TURSO_API_KEY environment variable is required",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return { apiKey: Redacted.make(apiKey), apiBaseUrl: DEFAULT_API_BASE_URL };
|
|
17
|
+
}));
|
|
18
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAO5D,MAAM,OAAO,WAAY,SAAQ,UAAU,CAAC,OAAO,EAAuB,CACxE,kBAAkB,CACnB;CAAG;AAEJ,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAC5C,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAEzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,gDAAgD;SAC1D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AAC7E,CAAC,CAAC,CACH,CAAC"}
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports common HTTP errors from sdk-core and adds Turso-specific
|
|
5
|
+
* error matching and API error types.
|
|
6
|
+
*/
|
|
7
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
8
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
declare const UnknownTursoError_base: Schema.ErrorClass<UnknownTursoError, Schema.TaggedStruct<"UnknownTursoError", {
|
|
11
|
+
readonly code: Schema.optional<Schema.String>;
|
|
12
|
+
readonly message: Schema.optional<Schema.String>;
|
|
13
|
+
readonly body: Schema.Unknown;
|
|
14
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
15
|
+
"@distilled.cloud/error/categories": {
|
|
16
|
+
ServerError: true;
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
export declare class UnknownTursoError extends UnknownTursoError_base {
|
|
20
|
+
}
|
|
21
|
+
declare const TursoParseError_base: Schema.ErrorClass<TursoParseError, Schema.TaggedStruct<"TursoParseError", {
|
|
22
|
+
readonly body: Schema.Unknown;
|
|
23
|
+
readonly cause: Schema.Unknown;
|
|
24
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
25
|
+
"@distilled.cloud/error/categories": {
|
|
26
|
+
ParseError: true;
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
export declare class TursoParseError extends TursoParseError_base {
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAIxC,qBAAa,iBAAkB,SAAQ,sBAOP;CAAG;;;;;;;;;AAGnC,qBAAa,eAAgB,SAAQ,oBAMN;CAAG"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports common HTTP errors from sdk-core and adds Turso-specific
|
|
5
|
+
* error matching and API error types.
|
|
6
|
+
*/
|
|
7
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
8
|
+
import * as Schema from "effect/Schema";
|
|
9
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
10
|
+
// Unknown Turso error - returned when an error code is not recognized
|
|
11
|
+
export class UnknownTursoError extends Schema.TaggedErrorClass()("UnknownTursoError", {
|
|
12
|
+
code: Schema.optional(Schema.String),
|
|
13
|
+
message: Schema.optional(Schema.String),
|
|
14
|
+
body: Schema.Unknown,
|
|
15
|
+
}).pipe(Category.withServerError) {
|
|
16
|
+
}
|
|
17
|
+
// Schema parse error wrapper
|
|
18
|
+
export class TursoParseError extends Schema.TaggedErrorClass()("TursoParseError", {
|
|
19
|
+
body: Schema.Unknown,
|
|
20
|
+
cause: Schema.Unknown,
|
|
21
|
+
}).pipe(Category.withParseError) {
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,sEAAsE;AACtE,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,gBAAgB,EAAqB,CACjF,mBAAmB,EACnB;IACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,6BAA6B;AAC7B,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,gBAAgB,EAAmB,CAC7E,iBAAiB,EACjB;IACE,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso SDK for Effect
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as Turso from "@distilled.cloud/turso";
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export * from "./credentials.ts";
|
|
10
|
+
export * as Category from "./category.ts";
|
|
11
|
+
export * as T from "./traits.ts";
|
|
12
|
+
export * as Retry from "./retry.ts";
|
|
13
|
+
export { API } from "./client.ts";
|
|
14
|
+
export * from "./errors.ts";
|
|
15
|
+
export { SensitiveString, SensitiveNullableString } from "./sensitive.ts";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso SDK for Effect
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as Turso from "@distilled.cloud/turso";
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export * from "./credentials.js";
|
|
10
|
+
export * as Category from "./category.js";
|
|
11
|
+
export * as T from "./traits.js";
|
|
12
|
+
export * as Retry from "./retry.js";
|
|
13
|
+
export { API } from "./client.js";
|
|
14
|
+
export * from "./errors.js";
|
|
15
|
+
export { SensitiveString, SensitiveNullableString } from "./sensitive.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,qDAAqD"}
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso retry configuration.
|
|
3
|
+
*/
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
6
|
+
export { type Options, type Factory, type Policy, makeDefault, jittered, capped, throttlingOptions, transientOptions, } from "@distilled.cloud/core/retry";
|
|
7
|
+
import type { Policy } from "@distilled.cloud/core/retry";
|
|
8
|
+
declare const Retry_base: ServiceMap.ServiceClass<Retry, "TursoRetry", Policy>;
|
|
9
|
+
/**
|
|
10
|
+
* Context tag for configuring retry behavior of Turso API calls.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Retry extends Retry_base {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provides a custom retry policy to all Turso API calls.
|
|
16
|
+
*/
|
|
17
|
+
export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
18
|
+
/**
|
|
19
|
+
* Disables all automatic retries.
|
|
20
|
+
*/
|
|
21
|
+
export declare const none: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
22
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;;AAE1D;;GAEG;AACH,qBAAa,KAAM,SAAQ,UAAiD;CAAG;AAE/E;;GAEG;AACH,eAAO,MAAM,MAAM,iHACqC,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,IAAI,mFAEhB,CAAC"}
|
package/lib/retry.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso retry configuration.
|
|
3
|
+
*/
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
7
|
+
export { makeDefault, jittered, capped, throttlingOptions, transientOptions, } from "@distilled.cloud/core/retry";
|
|
8
|
+
/**
|
|
9
|
+
* Context tag for configuring retry behavior of Turso API calls.
|
|
10
|
+
*/
|
|
11
|
+
export class Retry extends ServiceMap.Service()("TursoRetry") {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provides a custom retry policy to all Turso API calls.
|
|
15
|
+
*/
|
|
16
|
+
export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
17
|
+
/**
|
|
18
|
+
* Disables all automatic retries.
|
|
19
|
+
*/
|
|
20
|
+
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
21
|
+
//# sourceMappingURL=retry.js.map
|
package/lib/retry.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAIL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,UAAU,CAAC,OAAO,EAAiB,CAAC,YAAY,CAAC;CAAG;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,gBAAwB,EAAE,EAAE,CACjD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAChC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.d.ts","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
|
package/lib/sensitive.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
|
package/lib/traits.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,8BAA8B,CAAC"}
|
package/lib/traits.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,8BAA8B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@distilled.cloud/turso",
|
|
3
|
+
"version": "0.0.0-john",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/alchemy-run/distilled",
|
|
7
|
+
"directory": "packages/turso"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"module": "src/index.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"lib",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"bun": "./src/index.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./Category": {
|
|
23
|
+
"types": "./lib/category.d.ts",
|
|
24
|
+
"bun": "./src/category.ts",
|
|
25
|
+
"default": "./lib/category.js"
|
|
26
|
+
},
|
|
27
|
+
"./Client": {
|
|
28
|
+
"types": "./lib/client.d.ts",
|
|
29
|
+
"bun": "./src/client.ts",
|
|
30
|
+
"default": "./lib/client.js"
|
|
31
|
+
},
|
|
32
|
+
"./Credentials": {
|
|
33
|
+
"types": "./lib/credentials.d.ts",
|
|
34
|
+
"bun": "./src/credentials.ts",
|
|
35
|
+
"default": "./lib/credentials.js"
|
|
36
|
+
},
|
|
37
|
+
"./Errors": {
|
|
38
|
+
"types": "./lib/errors.d.ts",
|
|
39
|
+
"bun": "./src/errors.ts",
|
|
40
|
+
"default": "./lib/errors.js"
|
|
41
|
+
},
|
|
42
|
+
"./Operations": {
|
|
43
|
+
"types": "./lib/operations/index.d.ts",
|
|
44
|
+
"bun": "./src/operations/index.ts",
|
|
45
|
+
"default": "./lib/operations/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./Retry": {
|
|
48
|
+
"types": "./lib/retry.d.ts",
|
|
49
|
+
"bun": "./src/retry.ts",
|
|
50
|
+
"default": "./lib/retry.js"
|
|
51
|
+
},
|
|
52
|
+
"./Sensitive": {
|
|
53
|
+
"types": "./lib/sensitive.d.ts",
|
|
54
|
+
"bun": "./src/sensitive.ts",
|
|
55
|
+
"default": "./lib/sensitive.js"
|
|
56
|
+
},
|
|
57
|
+
"./Traits": {
|
|
58
|
+
"types": "./lib/traits.d.ts",
|
|
59
|
+
"bun": "./src/traits.ts",
|
|
60
|
+
"default": "./lib/traits.js"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"typecheck": "tsgo",
|
|
65
|
+
"build": "tsgo -b",
|
|
66
|
+
"fmt": "oxfmt --write src",
|
|
67
|
+
"lint": "oxlint --fix src",
|
|
68
|
+
"check": "tsgo && oxlint src && oxfmt --check src",
|
|
69
|
+
"test": "bunx vitest run test",
|
|
70
|
+
"publish:npm": "bun run build && bun publish --access public",
|
|
71
|
+
"generate": "bun run scripts/generate.ts && oxfmt --write src && oxlint --fix src",
|
|
72
|
+
"specs:fetch": "git submodule update --force --init --recursive specs/turso-docs && git -C specs/turso-docs checkout -- .",
|
|
73
|
+
"specs:update": "git -C specs/turso-docs fetch && git -C specs/turso-docs checkout main && git -C specs/turso-docs pull"
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"@distilled.cloud/core": "0.0.0-john",
|
|
77
|
+
"effect": "4.0.0-beta.30"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/bun": "^1.3.0",
|
|
81
|
+
"@types/node": "^25.3.5",
|
|
82
|
+
"dotenv": "^16.5.0",
|
|
83
|
+
"vitest": "^3.2.3"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"effect": "4.0.0-beta.30"
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/category.ts
ADDED
package/src/client.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso API Client.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the shared REST client from sdk-core with Turso-specific
|
|
5
|
+
* error matching and credential handling.
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Redacted from "effect/Redacted";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import { makeAPI } from "@distilled.cloud/core/client";
|
|
11
|
+
import {
|
|
12
|
+
HTTP_STATUS_MAP,
|
|
13
|
+
UnknownTursoError,
|
|
14
|
+
TursoParseError,
|
|
15
|
+
} from "./errors.ts";
|
|
16
|
+
|
|
17
|
+
// Re-export for backwards compatibility
|
|
18
|
+
export { UnknownTursoError } from "./errors.ts";
|
|
19
|
+
import { Credentials } from "./credentials.ts";
|
|
20
|
+
|
|
21
|
+
// API Error Response Schema
|
|
22
|
+
const ApiErrorResponse = Schema.Struct({
|
|
23
|
+
code: Schema.optional(Schema.String),
|
|
24
|
+
message: Schema.String,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Match a Turso API error response to the appropriate error class based on HTTP status.
|
|
29
|
+
*/
|
|
30
|
+
const matchError = (
|
|
31
|
+
status: number,
|
|
32
|
+
errorBody: unknown,
|
|
33
|
+
): Effect.Effect<never, unknown> => {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
36
|
+
const ErrorClass = (HTTP_STATUS_MAP as any)[status];
|
|
37
|
+
if (ErrorClass) {
|
|
38
|
+
return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
|
|
39
|
+
}
|
|
40
|
+
return Effect.fail(
|
|
41
|
+
new UnknownTursoError({
|
|
42
|
+
code: parsed.code,
|
|
43
|
+
message: parsed.message,
|
|
44
|
+
body: errorBody,
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
47
|
+
} catch {
|
|
48
|
+
return Effect.fail(new UnknownTursoError({ body: errorBody }));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Turso API client.
|
|
54
|
+
*/
|
|
55
|
+
export const API = makeAPI({
|
|
56
|
+
credentials: Credentials as any,
|
|
57
|
+
getBaseUrl: (creds: any) => creds.apiBaseUrl,
|
|
58
|
+
getAuthHeaders: (creds: any) => ({
|
|
59
|
+
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
60
|
+
}),
|
|
61
|
+
matchError,
|
|
62
|
+
ParseError: TursoParseError as any,
|
|
63
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Redacted from "effect/Redacted";
|
|
4
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
5
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_API_BASE_URL = "https://api.turso.com";
|
|
8
|
+
|
|
9
|
+
export interface Config {
|
|
10
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
11
|
+
readonly apiBaseUrl: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Credentials extends ServiceMap.Service<Credentials, Config>()(
|
|
15
|
+
"TursoCredentials",
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
export const CredentialsFromEnv = Layer.effect(
|
|
19
|
+
Credentials,
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
const apiKey = process.env.TURSO_API_KEY;
|
|
22
|
+
|
|
23
|
+
if (!apiKey) {
|
|
24
|
+
return yield* new ConfigError({
|
|
25
|
+
message: "TURSO_API_KEY environment variable is required",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return { apiKey: Redacted.make(apiKey), apiBaseUrl: DEFAULT_API_BASE_URL };
|
|
30
|
+
}),
|
|
31
|
+
);
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports common HTTP errors from sdk-core and adds Turso-specific
|
|
5
|
+
* error matching and API error types.
|
|
6
|
+
*/
|
|
7
|
+
export {
|
|
8
|
+
BadGateway,
|
|
9
|
+
BadRequest,
|
|
10
|
+
Conflict,
|
|
11
|
+
ConfigError,
|
|
12
|
+
Forbidden,
|
|
13
|
+
GatewayTimeout,
|
|
14
|
+
InternalServerError,
|
|
15
|
+
Locked,
|
|
16
|
+
NotFound,
|
|
17
|
+
ServiceUnavailable,
|
|
18
|
+
TooManyRequests,
|
|
19
|
+
Unauthorized,
|
|
20
|
+
UnprocessableEntity,
|
|
21
|
+
HTTP_STATUS_MAP,
|
|
22
|
+
DEFAULT_ERRORS,
|
|
23
|
+
API_ERRORS,
|
|
24
|
+
} from "@distilled.cloud/core/errors";
|
|
25
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
26
|
+
|
|
27
|
+
import * as Schema from "effect/Schema";
|
|
28
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
29
|
+
|
|
30
|
+
// Unknown Turso error - returned when an error code is not recognized
|
|
31
|
+
export class UnknownTursoError extends Schema.TaggedErrorClass<UnknownTursoError>()(
|
|
32
|
+
"UnknownTursoError",
|
|
33
|
+
{
|
|
34
|
+
code: Schema.optional(Schema.String),
|
|
35
|
+
message: Schema.optional(Schema.String),
|
|
36
|
+
body: Schema.Unknown,
|
|
37
|
+
},
|
|
38
|
+
).pipe(Category.withServerError) {}
|
|
39
|
+
|
|
40
|
+
// Schema parse error wrapper
|
|
41
|
+
export class TursoParseError extends Schema.TaggedErrorClass<TursoParseError>()(
|
|
42
|
+
"TursoParseError",
|
|
43
|
+
{
|
|
44
|
+
body: Schema.Unknown,
|
|
45
|
+
cause: Schema.Unknown,
|
|
46
|
+
},
|
|
47
|
+
).pipe(Category.withParseError) {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso SDK for Effect
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import * as Turso from "@distilled.cloud/turso";
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export * from "./credentials.ts";
|
|
10
|
+
export * as Category from "./category.ts";
|
|
11
|
+
export * as T from "./traits.ts";
|
|
12
|
+
export * as Retry from "./retry.ts";
|
|
13
|
+
export { API } from "./client.ts";
|
|
14
|
+
export * from "./errors.ts";
|
|
15
|
+
export { SensitiveString, SensitiveNullableString } from "./sensitive.ts";
|
package/src/retry.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turso retry configuration.
|
|
3
|
+
*/
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
7
|
+
export {
|
|
8
|
+
type Options,
|
|
9
|
+
type Factory,
|
|
10
|
+
type Policy,
|
|
11
|
+
makeDefault,
|
|
12
|
+
jittered,
|
|
13
|
+
capped,
|
|
14
|
+
throttlingOptions,
|
|
15
|
+
transientOptions,
|
|
16
|
+
} from "@distilled.cloud/core/retry";
|
|
17
|
+
import type { Policy } from "@distilled.cloud/core/retry";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Context tag for configuring retry behavior of Turso API calls.
|
|
21
|
+
*/
|
|
22
|
+
export class Retry extends ServiceMap.Service<Retry, Policy>()("TursoRetry") {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provides a custom retry policy to all Turso API calls.
|
|
26
|
+
*/
|
|
27
|
+
export const policy = (optionsOrFactory: Policy) =>
|
|
28
|
+
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Disables all automatic retries.
|
|
32
|
+
*/
|
|
33
|
+
export const none = Effect.provide(
|
|
34
|
+
Layer.succeed(Retry, { while: () => false }),
|
|
35
|
+
);
|
package/src/sensitive.ts
ADDED
package/src/traits.ts
ADDED