@distilled.cloud/turso 1.0.0-rc.15 → 1.0.0-rc.17

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/.lazy.json ADDED
@@ -0,0 +1 @@
1
+ {"serviceDirs":["services"],"twins":["index.js"]}
@@ -0,0 +1,4 @@
1
+ import*as $0 from"./sdk.js";
2
+ import{api$lazyService as L}from"@distilled.cloud/core/_bundle/base";
3
+ const u=import.meta.url,N=[$0];
4
+ export const $L=(s,k,a,l,x)=>L(u,s,k,a===void 0?void 0:x?N.concat(x):N,a,l);
@@ -0,0 +1,2 @@
1
+ import{api$D as e,api$call as t,api$error as n,api$named as r,api$newError as i,api$op as a,category$withAuthError as o,category$withBadRequestError as ee,category$withConflictError as te,category$withParseError as ne,category$withServerError as re,config$String as ie,config$all as ae,retry$capped as s,retry$jittered as c,retry$makeDefault as l,retry$throttlingFactory as u,retry$throttlingOptions as d,retry$transientFactory as f,retry$transientOptions as p,trait$Body as m,trait$FormDataFile as h,trait$Header as g,trait$Http as _,trait$HttpBody as v,trait$KeyDictionary as y,trait$Label as b,trait$Query as x,trait$ResponseCode as S,trait$UnionCases as C,trait$applyErrorMatchers as w,trait$bodySymbol as T,trait$errorMatchersSymbol as E,trait$formDataFileSymbol as D,trait$getErrorMatchers as O,trait$headerSymbol as k,trait$httpBodySymbol as A,trait$httpSymbol as j,trait$keyDictionarySymbol as M,trait$labelSymbol as N,trait$querySymbol as P,trait$responseCodeSymbol as F,trait$unionCasesSymbol as I}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as L,errors$BadGateway as R,errors$BadRequest as z,errors$ConfigError as B,errors$Conflict as V,errors$DEFAULT_ERRORS as H,errors$Forbidden as U,errors$GatewayTimeout as W,errors$HTTP_STATUS_MAP as G,errors$InternalServerError as K,errors$Locked as oe,errors$NotFound as q,errors$ServiceUnavailable as se,errors$TooManyRequests as ce,errors$Unauthorized as le,errors$UnprocessableEntity as ue,protocol_rest$RawResponse as de,protocol_rest$RawResponseRoot as fe,protocol_rest$SensitiveValue as pe,protocol_rest$makeRestProtocol as me,protocol_rest$rawResponseRootSymbol as he,protocol_rest$rawResponseSymbol as ge,protocol_rest$sensitiveValueSymbol as _e,schema_lite$Array as ve,schema_lite$Boolean as ye,schema_lite$NullOr as be,schema_lite$Number as xe,schema_lite$Record as Se,schema_lite$String as Ce,schema_lite$Struct as we,schema_lite$TaggedError as Te,schema_lite$Unknown as Ee,schema_lite$at as De,schema_lite$optional as Oe,schema_lite$suspend as ke}from"@distilled.cloud/core/_bundle/rest";import*as J from"effect/Context";import*as Y from"effect/Effect";import*as X from"effect/Layer";import*as Z from"effect/Redacted";import*as Q from"@distilled.cloud/core/schema-lite-typed";const $=`https://api.turso.tech`;var Credentials=class extends (/*@__PURE__*/ J.Service()(`TursoCredentials`)){};const Ae=/*@__PURE__*/ ae({apiKey:/*@__PURE__*/ ie(`TURSO_API_KEY`)});const je=/*@__PURE__*/ X.succeed(Credentials,/*@__PURE__*/ Ae.pipe(/*@__PURE__*/ Y.mapError(()=>new B({message:`TURSO_API_KEY environment variable is required`})),/*@__PURE__*/ Y.map(({apiKey:e})=>({apiKey:Z.make(e),apiBaseUrl:$})),Y.orDie));var UnknownTursoError=class extends (/*@__PURE__*/ Q.TaggedError()(`UnknownTursoError`,{code:/*@__PURE__*/ Q.optional(Q.String),message:/*@__PURE__*/ Q.optional(Q.String),body:Q.Unknown}).pipe(re)){};var TursoParseError=class extends (/*@__PURE__*/ Q.TaggedError()(`TursoParseError`,{body:Q.Unknown,cause:Q.Unknown}).pipe(ne)){};const Me=/*@__PURE__*/ me({credentials:/*@__PURE__*/ Y.flatMap(Credentials,e=>e),baseUrl:e=>e.apiBaseUrl,headers:e=>({Authorization:`Bearer ${Z.value(e.apiKey)}`}),unknownError:({code:e,message:t,body:n})=>new UnknownTursoError({code:typeof e===`string`?e:e!==void 0?String(e):void 0,message:t,body:n}),parseError:({body:e,cause:t})=>new TursoParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ J.Service()(`TursoRetry`)){};const policy=e=>Y.provide(X.succeed(Retry,e));const Ne=/*@__PURE__*/ Y.provide(/*@__PURE__*/ X.succeed(Retry,{while:()=>false}));const Pe=/*@__PURE__*/ policy(u);const Fe=/*@__PURE__*/ policy(f);export{i as _,Se as a,ee as b,Te as c,Credentials as credentials$Credentials,je as credentials$CredentialsFromEnv,$ as credentials$DEFAULT_API_BASE_URL,Oe as d,L as errors$API_ERRORS,R as errors$BadGateway,z as errors$BadRequest,B as errors$ConfigError,V as errors$Conflict,H as errors$DEFAULT_ERRORS,U as errors$Forbidden,W as errors$GatewayTimeout,G as errors$HTTP_STATUS_MAP,K as errors$InternalServerError,oe as errors$Locked,q as errors$NotFound,se as errors$ServiceUnavailable,ce as errors$TooManyRequests,TursoParseError as errors$TursoParseError,le as errors$Unauthorized,UnknownTursoError as errors$UnknownTursoError,ue as errors$UnprocessableEntity,ke as f,r as g,n as h,xe as i,Ee as l,t as m,ye as n,Ce as o,e as p,Me as protocol$TursoProtocol,be as r,Retry as retry$Retry,s as retry$capped,c as retry$jittered,l as retry$makeDefault,Ne as retry$none,policy as retry$policy,Pe as retry$throttling,u as retry$throttlingFactory,d as retry$throttlingOptions,Fe as retry$transient,f as retry$transientFactory,p as retry$transientOptions,we as s,ve as t,m as traits$Body,h as traits$FormDataFile,g as traits$Header,_ as traits$Http,v as traits$HttpBody,y as traits$KeyDictionary,b as traits$Label,x as traits$Query,de as traits$RawResponse,fe as traits$RawResponseRoot,S as traits$ResponseCode,pe as traits$SensitiveValue,C as traits$UnionCases,w as traits$applyErrorMatchers,T as traits$bodySymbol,E as traits$errorMatchersSymbol,D as traits$formDataFileSymbol,O as traits$getErrorMatchers,k as traits$headerSymbol,A as traits$httpBodySymbol,j as traits$httpSymbol,M as traits$keyDictionarySymbol,N as traits$labelSymbol,P as traits$querySymbol,he as traits$rawResponseRootSymbol,ge as traits$rawResponseSymbol,F as traits$responseCodeSymbol,_e as traits$sensitiveValueSymbol,I as traits$unionCasesSymbol,De as u,a as v,te as x,o as y};
2
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","names":["Category.withServerError","Category.withParseError","D","call","error","named","newError","op","withAuthError","withBadRequestError","withConflictError","withParseError","withServerError","String$2","all$1","capped","jittered","makeDefault","throttlingFactory","throttlingOptions","transientFactory","transientOptions","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnprocessableEntity","RawResponse","RawResponseRoot","SensitiveValue","makeRestProtocol","rawResponseRootSymbol","rawResponseSymbol","sensitiveValueSymbol","Array","Boolean","NullOr","Number","Record","String$1","Struct","TaggedError","Unknown","at","optional","suspend","Context","Effect","Layer","Redacted","Schema","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","apiKey","TursoProtocol","resolve","creds","code","optionsOrFactory","none","throttling","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"stEAeA,MAAaqF,EAAuB,yBAOpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CAAC,kBAAkB,EAAA,AAAE,CAAC,EAEnG,MAAMC,GAA0B,iBAAiB,CAC/C,OAAsB,iBAAoB,eAAe,CAC3D,CAAC,EAED,MAAaC,GAAmC,gBAAM,QACpD,YACc,iBAAU,KACR,gBAAO,aAEjB,IAAIvC,EAAY,CACd,QAAS,gDACX,CAAC,CACL,EACc,gBAAO,KAAK,CAAE,aAAc,CACxC,OAAQmC,EAAS,KAAKK,CAAM,EAC5B,WAAYH,CACd,EAAE,EACFJ,EAAO,KACT,CACF,ECDA,IAAa,kBAAb,eACwB,gBAAO,YAA+B,CAAC,CAAC,oBAAqB,CACjF,KAAoB,gBAAO,SAASG,EAAO,MAAM,EACjD,QAAuB,gBAAO,SAASA,EAAO,MAAM,EACpD,KAAMA,EAAO,OACf,CAAC,CAAC,CAAC,KAAKpF,EAAwB,EAAA,AAAE,CAAC,EAMrC,IAAa,gBAAb,eACwB,gBAAO,YAA6B,CAAC,CAAC,kBAAmB,CAC7E,KAAMoF,EAAO,QACb,MAAOA,EAAO,OAChB,CAAC,CAAC,CAAC,KAAKnF,EAAuB,EAAA,AAAE,CAAC,ECpBpC,MAAawF,GAAyD,iBAAyB,CAI7F,YAA2B,gBAAO,QAAQ,YAAc,GAAYC,CAAO,EAC3E,QAAU,GAAUC,EAAM,WAC1B,QAAU,IAAW,CACnB,cAAe,UAAUR,EAAS,MAAMQ,EAAM,MAAM,GACtD,GAGA,cAAe,CAAE,OAAM,UAAS,UAC9B,IAAI,kBAAkB,CACpB,KAAM,OAAOC,IAAS,SAAWA,EAAOA,IAAS,IAAA,GAAY,OAAOA,CAAI,EAAI,IAAA,GAC5E,UACA,MACF,CAAC,EACH,YAAa,CAAE,OAAM,WAAY,IAAI,gBAAgB,CAAE,OAAM,OAAM,CAAC,CACtE,CAAC,ECrBD,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,YAAY,EAAA,AAAE,CAAC,EAGzF,MAAa,OAAU,GACrBX,EAAO,QAAQC,EAAM,QAAQ,MAAOW,CAAgB,CAAC,EAGvD,MAAaC,GAAqB,gBAAO,QACzB,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAGA,MAAaC,GAA2B,qBAAO7E,CAAiB,EAGhE,MAAa8E,GAA0B,qBAAO5E,CAAgB"}
@@ -8,7 +8,7 @@ export interface Config {
8
8
  readonly apiBaseUrl: string;
9
9
  }
10
10
  declare const Credentials_base: Context.ServiceClass<Credentials, "TursoCredentials", Effect.Effect<Config, never, never>>;
11
- export declare class Credentials extends Credentials_base {
11
+ export declare class Credentials extends /*@__PURE__*/ Credentials_base {
12
12
  }
13
13
  export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
14
14
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,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;AAMJ,eAAO,MAAM,kBAAkB,wCAe9B,CAAC"}
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,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,WACX,SAAQ,aAAa,CAAC,gBAAyE;CAAG;AAMpG,eAAO,MAAM,kBAAkB,wCAe9B,CAAC"}
@@ -1,27 +1 @@
1
- /**
2
- * Turso credentials — hand-written.
3
- *
4
- * API-compatible port of the distilled repo's turso credentials module: the
5
- * `Credentials` service holds an *effect* that resolves the current
6
- * credentials, so the protocol layer picks up rotations per request. Turso
7
- * auth is a plain bearer token (`Authorization: Bearer <apiKey>`).
8
- */
9
- import { ConfigError } from "@distilled.cloud/core/errors";
10
- import * as EffectConfig from "effect/Config";
11
- import * as Context from "effect/Context";
12
- import * as Effect from "effect/Effect";
13
- import * as Layer from "effect/Layer";
14
- import * as Redacted from "effect/Redacted";
15
- export const DEFAULT_API_BASE_URL = "https://api.turso.tech";
16
- export class Credentials extends Context.Service()("TursoCredentials") {
17
- }
18
- const envConfig = EffectConfig.all({
19
- apiKey: EffectConfig.String("TURSO_API_KEY"),
20
- });
21
- export const CredentialsFromEnv = Layer.succeed(Credentials, envConfig.pipe(Effect.mapError(() => new ConfigError({
22
- message: "TURSO_API_KEY environment variable is required",
23
- })), Effect.map(({ apiKey }) => ({
24
- apiKey: Redacted.make(apiKey),
25
- apiBaseUrl: DEFAULT_API_BASE_URL,
26
- })), Effect.orDie));
27
- //# sourceMappingURL=credentials.js.map
1
+ export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL } from "./_bundle/sdk.js";
package/lib/errors.d.ts CHANGED
@@ -8,36 +8,36 @@
8
8
  */
9
9
  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";
10
10
  import type { BadRequest as CoreBadRequest, Conflict as CoreConflict, DefaultErrors as CoreDefaultErrors, Forbidden as CoreForbidden, Locked as CoreLocked, NotFound as CoreNotFound, UnprocessableEntity as CoreUnprocessableEntity } from "@distilled.cloud/core/errors";
11
- import * as Schema from "effect/Schema";
12
- declare const UnknownTursoError_base: Schema.Class<UnknownTursoError, Schema.TaggedStruct<"UnknownTursoError", {
13
- readonly code: Schema.optional<Schema.String>;
14
- readonly message: Schema.optional<Schema.String>;
15
- readonly body: Schema.Unknown;
16
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
11
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
12
+ declare const UnknownTursoError_base: Schema.TaggedErrorClass<"UnknownTursoError", {
13
+ readonly code: import("effect/Schema").optional<import("effect/Schema").String>;
14
+ readonly message: import("effect/Schema").optional<import("effect/Schema").String>;
15
+ readonly body: import("effect/Schema").Unknown;
16
+ }> & (new (...args: any[]) => {
17
17
  "@distilled.cloud/error/categories": {
18
18
  ServerError: true;
19
19
  };
20
20
  });
21
21
  /**
22
- * Unknown Turso error — returned when an error response cannot be mapped to
22
+ * Unknown Turso error -- returned when an error response cannot be mapped to
23
23
  * a shared HTTP status class. Carries the raw `code` string Turso sometimes
24
24
  * includes in its error body.
25
25
  */
26
- export declare class UnknownTursoError extends UnknownTursoError_base {
26
+ export declare class UnknownTursoError extends /*@__PURE__*/ UnknownTursoError_base {
27
27
  }
28
- declare const TursoParseError_base: Schema.Class<TursoParseError, Schema.TaggedStruct<"TursoParseError", {
29
- readonly body: Schema.Unknown;
30
- readonly cause: Schema.Unknown;
31
- }>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
28
+ declare const TursoParseError_base: Schema.TaggedErrorClass<"TursoParseError", {
29
+ readonly body: import("effect/Schema").Unknown;
30
+ readonly cause: import("effect/Schema").Unknown;
31
+ }> & (new (...args: any[]) => {
32
32
  "@distilled.cloud/error/categories": {
33
33
  ParseError: true;
34
34
  };
35
35
  });
36
36
  /**
37
- * Schema parse error wrapper — kept for parity with the distilled turso SDK's
37
+ * Schema parse error wrapper -- kept for parity with the distilled turso SDK's
38
38
  * error surface.
39
39
  */
40
- export declare class TursoParseError extends TursoParseError_base {
40
+ export declare class TursoParseError extends /*@__PURE__*/ TursoParseError_base {
41
41
  }
42
42
  /**
43
43
  * Errors any Turso operation may surface beyond the core HTTP defaults.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,MAAM,IAAI,UAAU,EACpB,QAAQ,IAAI,YAAY,EACxB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAExC;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,sBAOP;CAAG;;;;;;;;;AAEnC;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAGL;CAAG;AAEnC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,UAAU,GACV,YAAY,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;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;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,MAAM,IAAI,UAAU,EACpB,QAAQ,IAAI,YAAY,EACxB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;;;;AAElE;;;;GAIG;AACH,qBAAa,iBACX,SAAQ,aAAa,CAAC,sBAIW;CAAG;;;;;;;;;AAEtC;;;GAGG;AACH,qBAAa,eACX,SAAQ,aAAa,CAAC,oBAGU;CAAG;AAErC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,UAAU,GACV,YAAY,CAAC"}
package/lib/errors.js CHANGED
@@ -1,32 +1 @@
1
- /**
2
- * Turso-specific error types.
3
- *
4
- * Re-exports common HTTP errors from sdk-core and adds the Turso-specific
5
- * fallback/parse error types (ported from the distilled repo's turso SDK).
6
- *
7
- * Turso error bodies have the shape `{ error: string, code?: string }`.
8
- */
9
- 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";
10
- import * as Category from "@distilled.cloud/core/category";
11
- import * as Schema from "effect/Schema";
12
- /**
13
- * Unknown Turso error — returned when an error response cannot be mapped to
14
- * a shared HTTP status class. Carries the raw `code` string Turso sometimes
15
- * includes in its error body.
16
- */
17
- export class UnknownTursoError extends Schema.TaggedError()("UnknownTursoError", {
18
- code: Schema.optional(Schema.String),
19
- message: Schema.optional(Schema.String),
20
- body: Schema.Unknown,
21
- }).pipe(Category.withServerError) {
22
- }
23
- /**
24
- * Schema parse error wrapper — kept for parity with the distilled turso SDK's
25
- * error surface.
26
- */
27
- export class TursoParseError extends Schema.TaggedError()("TursoParseError", {
28
- body: Schema.Unknown,
29
- cause: Schema.Unknown,
30
- }).pipe(Category.withParseError) {
31
- }
32
- //# sourceMappingURL=errors.js.map
1
+ export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$TursoParseError as TursoParseError, errors$Unauthorized as Unauthorized, errors$UnknownTursoError as UnknownTursoError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @distilled.cloud/turso — Turso SDK for Effect.
2
+ * @distilled.cloud/turso -- Turso SDK for Effect.
3
3
  *
4
4
  * `./services` is generated by `scripts/generate.ts` from the Smithy model in
5
5
  * `.generated-specs` (converted from the Turso OpenAPI spec by
package/lib/index.js CHANGED
@@ -1,19 +1,6 @@
1
- /**
2
- * @distilled.cloud/turso — Turso SDK for Effect.
3
- *
4
- * `./services` is generated by `scripts/generate.ts` from the Smithy model in
5
- * `.generated-specs` (converted from the Turso OpenAPI spec by
6
- * `scripts/convert.ts`). Everything else in this folder is hand-written.
7
- *
8
- * @example
9
- * ```ts
10
- * import * as Turso from "@distilled.cloud/turso";
11
- * ```
12
- */
13
1
  export * from "./credentials.js";
14
2
  export * from "./errors.js";
15
3
  export * as T from "./traits.js";
16
4
  export * as Retry from "./retry.js";
17
5
  export { TursoProtocol } from "./protocol.js";
18
6
  export * as Services from "./services/index.js";
19
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export * as Retry from "./retry.js";
5
+ export { TursoProtocol } from "./protocol.js";
6
+ export * as Services from "./services.lazy/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAmBhE,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAqB,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAErF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC;AAEzF,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAqBlD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAmBhE,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAqB,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAErF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC;AAEzF,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAkBlD,CAAC"}
package/lib/protocol.js CHANGED
@@ -1,43 +1 @@
1
- import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
2
- /**
3
- * TursoProtocol — hand-written.
4
- *
5
- * Turso's platform API is plain bearer-REST JSON (`Authorization: Bearer
6
- * <apiKey>`, no response envelope), so the protocol is a direct
7
- * `makeRestProtocol` instantiation from `core/protocol-rest`:
8
- *
9
- * request: credentials resolved per request from the Credentials service,
10
- * bearer auth header, base URL from `creds.apiBaseUrl`
11
- *
12
- * response: non-2xx → typed error matched like the distilled turso client:
13
- * per-op matcher classes first, then the shared HTTP status map
14
- * (`{ error: string, code?: string }` bodies parsed leniently,
15
- * `retryAfter` hints stamped on retryable statuses), unmapped
16
- * failures fall back to `UnknownTursoError`.
17
- */
18
- import * as Effect from "effect/Effect";
19
- import * as Redacted from "effect/Redacted";
20
- import { Credentials } from "./credentials.js";
21
- import { UnknownTursoError, TursoParseError } from "./errors.js";
22
- export const TursoProtocol = makeRestProtocol({
23
- // The Credentials service holds an effect — resolving it here (per
24
- // request) picks up rotations. Its error channel is erased at the protocol
25
- // boundary; TursoOpError reintroduces it for callers.
26
- credentials: Effect.gen(function* () {
27
- const resolve = yield* Credentials;
28
- return yield* resolve;
29
- }),
30
- baseUrl: (creds) => creds.apiBaseUrl,
31
- headers: (creds) => ({
32
- Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
33
- }),
34
- // Turso error bodies are `{ error: string, code?: string }` — covered by
35
- // the default lenient envelope (message ?? error, string codes kept).
36
- unknownError: ({ code, message, body }) => new UnknownTursoError({
37
- code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
38
- message,
39
- body,
40
- }),
41
- parseError: ({ body, cause }) => new TursoParseError({ body, cause }),
42
- });
43
- //# sourceMappingURL=protocol.js.map
1
+ export { protocol$TursoProtocol as TursoProtocol } from "./_bundle/sdk.js";
package/lib/retry.d.ts CHANGED
@@ -20,7 +20,7 @@ import * as Effect from "effect/Effect";
20
20
  export { type Options, type Factory, type Policy, makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
21
21
  declare const Retry_base: Context.ServiceClass<Retry, "TursoRetry", Policy>;
22
22
  /** Context tag for configuring retry behavior of Turso API calls. */
23
- export declare class Retry extends Retry_base {
23
+ export declare class Retry extends /*@__PURE__*/ Retry_base {
24
24
  }
25
25
  /** Provides a custom retry policy to every Turso API call below it. */
26
26
  export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAuC,MAAM,6BAA6B,CAAC;AAC/F;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,qEAAqE;AACrE,qBAAa,KAAM,SAAQ,UAA8C;CAAG;AAE5E,uEAAuE;AACvE,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAA+D,CAAC;AAEjF,kFAAkF;AAClF,eAAO,MAAM,UAAU,mFAA4B,CAAC;AAEpD,oFAAoF;AACpF,eAAO,MAAM,SAAS,mFAA2B,CAAC"}
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAuC,MAAM,6BAA6B,CAAC;AAC/F;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,qEAAqE;AACrE,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAA8C;CAAG;AAE1F,uEAAuE;AACvE,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAEhB,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,UAAU,mFAA0C,CAAC;AAElE,oFAAoF;AACpF,eAAO,MAAM,SAAS,mFAAyC,CAAC"}
package/lib/retry.js CHANGED
@@ -1,33 +1 @@
1
- import { throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
2
- /**
3
- * Turso retry configuration.
4
- *
5
- * Defines the per-SDK `Retry` Context.Service tag that generated operations
6
- * wire into `API.make({ retry: Retry.Retry })`. Callers can install a
7
- * blanket retry policy at the layer level and have every Turso API call
8
- * below it pick it up:
9
- *
10
- * @example
11
- * ```ts
12
- * import * as Turso from "@distilled.cloud/turso";
13
- *
14
- * myEffect.pipe(Turso.Retry.transient);
15
- * Effect.provide(myEffect, Layer.succeed(Turso.Retry.Retry, customPolicy));
16
- * ```
17
- */
18
- import * as Context from "effect/Context";
19
- import * as Effect from "effect/Effect";
20
- import * as Layer from "effect/Layer";
21
- export { makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
22
- /** Context tag for configuring retry behavior of Turso API calls. */
23
- export class Retry extends Context.Service()("TursoRetry") {
24
- }
25
- /** Provides a custom retry policy to every Turso API call below it. */
26
- export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
27
- /** Disables all automatic retries. */
28
- export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
29
- /** Apply the throttling retry policy (retries throttling errors indefinitely). */
30
- export const throttling = policy(throttlingFactory);
31
- /** Apply the transient retry policy (retries all transient errors indefinitely). */
32
- export const transient = policy(transientFactory);
33
- //# sourceMappingURL=retry.js.map
1
+ export { retry$Retry as Retry, retry$capped as capped, retry$jittered as jittered, retry$makeDefault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingFactory as throttlingFactory, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientFactory as transientFactory, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
@@ -1,3 +1 @@
1
- // AUTO-GENERATED by scripts/generate.ts. Do not edit.
2
1
  export * as turso from "./turso.js";
3
- //# sourceMappingURL=index.js.map