@distilled.cloud/turso 0.0.0 → 0.2.5-alpha2

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.
Files changed (47) hide show
  1. package/lib/category.d.ts +5 -0
  2. package/lib/category.d.ts.map +1 -0
  3. package/lib/category.js +5 -0
  4. package/lib/category.js.map +1 -0
  5. package/lib/client.d.ts +17 -0
  6. package/lib/client.d.ts.map +1 -0
  7. package/lib/client.js +51 -0
  8. package/lib/client.js.map +1 -0
  9. package/lib/credentials.d.ts +14 -0
  10. package/lib/credentials.d.ts.map +1 -0
  11. package/lib/credentials.js +17 -0
  12. package/lib/credentials.js.map +1 -0
  13. package/lib/errors.d.ts +31 -0
  14. package/lib/errors.d.ts.map +1 -0
  15. package/lib/errors.js +23 -0
  16. package/lib/errors.js.map +1 -0
  17. package/lib/index.d.ts +16 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +16 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/operations/index.d.ts +2 -0
  22. package/lib/operations/index.d.ts.map +1 -0
  23. package/lib/operations/index.js +3 -0
  24. package/lib/operations/index.js.map +1 -0
  25. package/lib/retry.d.ts +22 -0
  26. package/lib/retry.d.ts.map +1 -0
  27. package/lib/retry.js +21 -0
  28. package/lib/retry.js.map +1 -0
  29. package/lib/sensitive.d.ts +5 -0
  30. package/lib/sensitive.d.ts.map +1 -0
  31. package/lib/sensitive.js +5 -0
  32. package/lib/sensitive.js.map +1 -0
  33. package/lib/traits.d.ts +5 -0
  34. package/lib/traits.d.ts.map +1 -0
  35. package/lib/traits.js +5 -0
  36. package/lib/traits.js.map +1 -0
  37. package/package.json +81 -9
  38. package/src/category.ts +4 -0
  39. package/src/client.ts +62 -0
  40. package/src/credentials.ts +30 -0
  41. package/src/errors.ts +47 -0
  42. package/src/index.ts +15 -0
  43. package/src/operations/index.ts +2 -0
  44. package/src/retry.ts +35 -0
  45. package/src/sensitive.ts +4 -0
  46. package/src/traits.ts +4 -0
  47. package/index.js +0 -2
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export the shared category system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/category";
5
+ //# sourceMappingURL=category.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../src/category.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export the shared category system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/category";
5
+ //# sourceMappingURL=category.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category.js","sourceRoot":"","sources":["../src/category.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,17 @@
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 Schema from "effect/Schema";
9
+ export { UnknownTursoError } from "./errors.ts";
10
+ /**
11
+ * Turso API client.
12
+ */
13
+ export declare const API: {
14
+ 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;
15
+ 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?: ((baseFn: (input: any) => Effect.Effect<any, any, any>, input: any, pagination: import("@distilled.cloud/core/pagination").PaginatedTrait) => import("effect/Stream").Stream<any, any, any>) | undefined) => any;
16
+ };
17
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,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,51 @@
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 Schema from "effect/Schema";
9
+ import { makeAPI } from "@distilled.cloud/core/client";
10
+ import { HTTP_STATUS_MAP, UnknownTursoError, TursoParseError, } from "./errors.js";
11
+ // Re-export for backwards compatibility
12
+ export { UnknownTursoError } from "./errors.js";
13
+ import { Credentials } from "./credentials.js";
14
+ // API Error Response Schema
15
+ const ApiErrorResponse = Schema.Struct({
16
+ code: Schema.optional(Schema.String),
17
+ message: Schema.String,
18
+ });
19
+ /**
20
+ * Match a Turso API error response to the appropriate error class based on HTTP status.
21
+ */
22
+ const matchError = (status, errorBody) => {
23
+ try {
24
+ const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
25
+ const ErrorClass = HTTP_STATUS_MAP[status];
26
+ if (ErrorClass) {
27
+ return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
28
+ }
29
+ return Effect.fail(new UnknownTursoError({
30
+ code: parsed.code,
31
+ message: parsed.message,
32
+ body: errorBody,
33
+ }));
34
+ }
35
+ catch {
36
+ return Effect.fail(new UnknownTursoError({ body: errorBody }));
37
+ }
38
+ };
39
+ /**
40
+ * Turso API client.
41
+ */
42
+ export const API = makeAPI({
43
+ credentials: Credentials,
44
+ getBaseUrl: (creds) => creds.apiBaseUrl,
45
+ getAuthHeaders: (creds) => ({
46
+ Authorization: `Bearer ${creds.apiKey}`,
47
+ }),
48
+ matchError,
49
+ ParseError: TursoParseError,
50
+ });
51
+ //# 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,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,KAAK,CAAC,MAAM,EAAE;KACxC,CAAC;IACF,UAAU;IACV,UAAU,EAAE,eAAsB;CACnC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as ServiceMap from "effect/ServiceMap";
3
+ import { ConfigError } from "@distilled.cloud/core/errors";
4
+ export declare const DEFAULT_API_BASE_URL = "https://api.turso.com";
5
+ export interface Config {
6
+ readonly apiKey: string;
7
+ readonly apiBaseUrl: string;
8
+ }
9
+ declare const Credentials_base: ServiceMap.ServiceClass<Credentials, "TursoCredentials", Config>;
10
+ export declare class Credentials extends Credentials_base {
11
+ }
12
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError, never>;
13
+ export {};
14
+ //# 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,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,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAa9B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import * as ServiceMap from "effect/ServiceMap";
4
+ import { ConfigError } from "@distilled.cloud/core/errors";
5
+ export const DEFAULT_API_BASE_URL = "https://api.turso.com";
6
+ export class Credentials extends ServiceMap.Service()("TursoCredentials") {
7
+ }
8
+ export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function* () {
9
+ const apiKey = process.env.TURSO_API_KEY;
10
+ if (!apiKey) {
11
+ return yield* new ConfigError({
12
+ message: "TURSO_API_KEY environment variable is required",
13
+ });
14
+ }
15
+ return { apiKey, apiBaseUrl: DEFAULT_API_BASE_URL };
16
+ }));
17
+ //# 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,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,UAAU,EAAE,oBAAoB,EAAE,CAAC;AACtD,CAAC,CAAC,CACH,CAAC"}
@@ -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
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ // Generated operations will be placed here by the code generator.
2
+ // Run `bun run generate` to populate this directory.
3
+ //# sourceMappingURL=index.js.map
@@ -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
@@ -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,5 @@
1
+ /**
2
+ * Re-export sensitive data schemas from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/sensitive";
5
+ //# sourceMappingURL=sensitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensitive.d.ts","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export sensitive data schemas from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/sensitive";
5
+ //# sourceMappingURL=sensitive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export the shared traits system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/traits";
5
+ //# sourceMappingURL=traits.d.ts.map
@@ -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,5 @@
1
+ /**
2
+ * Re-export the shared traits system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/traits";
5
+ //# sourceMappingURL=traits.js.map
@@ -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 CHANGED
@@ -1,16 +1,88 @@
1
1
  {
2
2
  "name": "@distilled.cloud/turso",
3
- "version": "0.0.0",
4
- "description": "Turso SDK for Effect (placeholder)",
5
- "type": "module",
6
- "main": "index.js",
7
- "files": [
8
- "index.js"
9
- ],
3
+ "version": "0.2.5-alpha2",
10
4
  "repository": {
11
5
  "type": "git",
12
6
  "url": "https://github.com/alchemy-run/distilled",
13
7
  "directory": "packages/turso"
14
8
  },
15
- "license": "MIT"
16
- }
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.2.5-alpha2",
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
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Re-export the shared category system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/category";
package/src/client.ts ADDED
@@ -0,0 +1,62 @@
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 Schema from "effect/Schema";
9
+ import { makeAPI } from "@distilled.cloud/core/client";
10
+ import {
11
+ HTTP_STATUS_MAP,
12
+ UnknownTursoError,
13
+ TursoParseError,
14
+ } from "./errors.ts";
15
+
16
+ // Re-export for backwards compatibility
17
+ export { UnknownTursoError } from "./errors.ts";
18
+ import { Credentials } from "./credentials.ts";
19
+
20
+ // API Error Response Schema
21
+ const ApiErrorResponse = Schema.Struct({
22
+ code: Schema.optional(Schema.String),
23
+ message: Schema.String,
24
+ });
25
+
26
+ /**
27
+ * Match a Turso API error response to the appropriate error class based on HTTP status.
28
+ */
29
+ const matchError = (
30
+ status: number,
31
+ errorBody: unknown,
32
+ ): Effect.Effect<never, unknown> => {
33
+ try {
34
+ const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
35
+ const ErrorClass = (HTTP_STATUS_MAP as any)[status];
36
+ if (ErrorClass) {
37
+ return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
38
+ }
39
+ return Effect.fail(
40
+ new UnknownTursoError({
41
+ code: parsed.code,
42
+ message: parsed.message,
43
+ body: errorBody,
44
+ }),
45
+ );
46
+ } catch {
47
+ return Effect.fail(new UnknownTursoError({ body: errorBody }));
48
+ }
49
+ };
50
+
51
+ /**
52
+ * Turso API client.
53
+ */
54
+ export const API = makeAPI({
55
+ credentials: Credentials as any,
56
+ getBaseUrl: (creds: any) => creds.apiBaseUrl,
57
+ getAuthHeaders: (creds: any) => ({
58
+ Authorization: `Bearer ${creds.apiKey}`,
59
+ }),
60
+ matchError,
61
+ ParseError: TursoParseError as any,
62
+ });
@@ -0,0 +1,30 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
3
+ import * as ServiceMap from "effect/ServiceMap";
4
+ import { ConfigError } from "@distilled.cloud/core/errors";
5
+
6
+ export const DEFAULT_API_BASE_URL = "https://api.turso.com";
7
+
8
+ export interface Config {
9
+ readonly apiKey: string;
10
+ readonly apiBaseUrl: string;
11
+ }
12
+
13
+ export class Credentials extends ServiceMap.Service<Credentials, Config>()(
14
+ "TursoCredentials",
15
+ ) {}
16
+
17
+ export const CredentialsFromEnv = Layer.effect(
18
+ Credentials,
19
+ Effect.gen(function* () {
20
+ const apiKey = process.env.TURSO_API_KEY;
21
+
22
+ if (!apiKey) {
23
+ return yield* new ConfigError({
24
+ message: "TURSO_API_KEY environment variable is required",
25
+ });
26
+ }
27
+
28
+ return { apiKey, apiBaseUrl: DEFAULT_API_BASE_URL };
29
+ }),
30
+ );
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";
@@ -0,0 +1,2 @@
1
+ // Generated operations will be placed here by the code generator.
2
+ // Run `bun run generate` to populate this directory.
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
+ );
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Re-export sensitive data schemas from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/sensitive";
package/src/traits.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Re-export the shared traits system from sdk-core.
3
+ */
4
+ export * from "@distilled.cloud/core/traits";
package/index.js DELETED
@@ -1,2 +0,0 @@
1
- // Placeholder — this package will be replaced by the generated SDK.
2
- export {};