@distilled.cloud/turso 1.0.0-rc.15 → 1.0.0-rc.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/credentials.d.ts +1 -1
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +17 -14
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts +14 -14
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +22 -22
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +12 -12
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +20 -23
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +26 -25
- package/lib/retry.js.map +1 -1
- package/lib/services/turso.d.ts +15 -209
- package/lib/services/turso.d.ts.map +1 -1
- package/lib/services/turso.js +193 -1375
- package/lib/traits.d.ts +2 -2
- package/lib/traits.js +10 -10
- package/package.json +13 -9
- package/src/credentials.ts +10 -11
- package/src/errors.ts +13 -14
- package/src/index.ts +1 -1
- package/src/protocol.ts +6 -9
- package/src/retry.ts +6 -4
- package/src/services/turso.ts +1639 -1663
- package/src/traits.ts +2 -2
- package/lib/services/turso.js.map +0 -1
package/lib/traits.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Turso SDK trait surface
|
|
2
|
+
* Turso SDK trait surface -- hand-written.
|
|
3
3
|
*
|
|
4
4
|
* Re-exports the generic protocol traits from core so generated operations
|
|
5
5
|
* import everything from one place (`import * as T from "../traits.ts"`).
|
|
6
6
|
* The Turso platform API is plain bearer-REST with no response envelope, so
|
|
7
|
-
* there are no Turso-specific traits
|
|
7
|
+
* there are no Turso-specific traits -- the REST-protocol traits
|
|
8
8
|
* (`SensitiveValue` / `RawResponse` / `RawResponseRoot`) come from
|
|
9
9
|
* `core/protocol-rest`.
|
|
10
10
|
*/
|
package/lib/traits.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
11
|
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
12
12
|
export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
|
|
13
13
|
//# sourceMappingURL=traits.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/turso",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.16",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"types": "./lib/index.d.ts",
|
|
20
20
|
"bun": "./src/index.ts",
|
|
21
21
|
"worker": "./src/index.ts",
|
|
22
|
-
"
|
|
22
|
+
"module": "./lib/index.full.js",
|
|
23
|
+
"module-sync": "./lib/index.js",
|
|
24
|
+
"default": "./lib/index.full.js"
|
|
23
25
|
},
|
|
24
26
|
"./Credentials": {
|
|
25
27
|
"types": "./lib/credentials.d.ts",
|
|
@@ -61,27 +63,29 @@
|
|
|
61
63
|
"types": "./lib/services/*.d.ts",
|
|
62
64
|
"bun": "./src/services/*.ts",
|
|
63
65
|
"worker": "./src/services/*.ts",
|
|
64
|
-
"
|
|
66
|
+
"module": "./lib/services.full/*.js",
|
|
67
|
+
"module-sync": "./lib/services/*.js",
|
|
68
|
+
"default": "./lib/services.full/*.js"
|
|
65
69
|
}
|
|
66
70
|
},
|
|
67
71
|
"dependencies": {
|
|
68
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
72
|
+
"@distilled.cloud/core": "1.0.0-rc.16"
|
|
69
73
|
},
|
|
70
74
|
"devDependencies": {
|
|
71
|
-
"@types/node": "26.
|
|
75
|
+
"@types/node": "26.6.5"
|
|
72
76
|
},
|
|
73
77
|
"peerDependencies": {
|
|
74
|
-
"effect": "^4.0.
|
|
78
|
+
"effect": "^4.0.5"
|
|
75
79
|
},
|
|
76
80
|
"distilled": {
|
|
77
|
-
"generatedAt": "2026-10-
|
|
81
|
+
"generatedAt": "2026-10-09",
|
|
78
82
|
"specUpdatedAt": "2026-09-23"
|
|
79
83
|
},
|
|
80
84
|
"scripts": {
|
|
81
|
-
"build": "
|
|
85
|
+
"build": "tsrs -b",
|
|
82
86
|
"convert": "node --conditions=bun scripts/convert.ts",
|
|
83
87
|
"generate": "node --conditions=bun scripts/generate.ts",
|
|
84
|
-
"typecheck": "
|
|
88
|
+
"typecheck": "tsrs -p tsconfig.json",
|
|
85
89
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-turso",
|
|
86
90
|
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-turso"
|
|
87
91
|
}
|
package/src/credentials.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as EffectConfig from "@distilled.cloud/core/config";
|
|
1
2
|
/**
|
|
2
|
-
* Turso credentials
|
|
3
|
+
* Turso credentials -- hand-written.
|
|
3
4
|
*
|
|
4
5
|
* API-compatible port of the distilled repo's turso credentials module: the
|
|
5
6
|
* `Credentials` service holds an *effect* that resolves the current
|
|
@@ -7,7 +8,6 @@
|
|
|
7
8
|
* auth is a plain bearer token (`Authorization: Bearer <apiKey>`).
|
|
8
9
|
*/
|
|
9
10
|
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
10
|
-
import * as EffectConfig from "effect/Config";
|
|
11
11
|
import * as Context from "effect/Context";
|
|
12
12
|
import * as Effect from "effect/Effect";
|
|
13
13
|
import * as Layer from "effect/Layer";
|
|
@@ -20,24 +20,23 @@ export interface Config {
|
|
|
20
20
|
readonly apiBaseUrl: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export class Credentials
|
|
24
|
-
"TursoCredentials"
|
|
25
|
-
) {}
|
|
23
|
+
export class Credentials
|
|
24
|
+
extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config>>()("TursoCredentials") {}
|
|
26
25
|
|
|
27
|
-
const envConfig = EffectConfig.all({
|
|
28
|
-
apiKey: EffectConfig.String("TURSO_API_KEY"),
|
|
26
|
+
const envConfig = /*@__PURE__*/ EffectConfig.all({
|
|
27
|
+
apiKey: /*@__PURE__*/ EffectConfig.String("TURSO_API_KEY"),
|
|
29
28
|
});
|
|
30
29
|
|
|
31
|
-
export const CredentialsFromEnv = Layer.succeed(
|
|
30
|
+
export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(
|
|
32
31
|
Credentials,
|
|
33
|
-
envConfig.pipe(
|
|
34
|
-
Effect.mapError(
|
|
32
|
+
/*@__PURE__*/ envConfig.pipe(
|
|
33
|
+
/*@__PURE__*/ Effect.mapError(
|
|
35
34
|
() =>
|
|
36
35
|
new ConfigError({
|
|
37
36
|
message: "TURSO_API_KEY environment variable is required",
|
|
38
37
|
}),
|
|
39
38
|
),
|
|
40
|
-
Effect.map(({ apiKey }) => ({
|
|
39
|
+
/*@__PURE__*/ Effect.map(({ apiKey }) => ({
|
|
41
40
|
apiKey: Redacted.make(apiKey),
|
|
42
41
|
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
43
42
|
})),
|
package/src/errors.ts
CHANGED
|
@@ -34,30 +34,29 @@ import type {
|
|
|
34
34
|
NotFound as CoreNotFound,
|
|
35
35
|
UnprocessableEntity as CoreUnprocessableEntity,
|
|
36
36
|
} from "@distilled.cloud/core/errors";
|
|
37
|
-
import * as Schema from "
|
|
37
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Unknown Turso error
|
|
40
|
+
* Unknown Turso error -- returned when an error response cannot be mapped to
|
|
41
41
|
* a shared HTTP status class. Carries the raw `code` string Turso sometimes
|
|
42
42
|
* includes in its error body.
|
|
43
43
|
*/
|
|
44
|
-
export class UnknownTursoError
|
|
45
|
-
"UnknownTursoError",
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
message: Schema.optional(Schema.String),
|
|
44
|
+
export class UnknownTursoError
|
|
45
|
+
extends /*@__PURE__*/ Schema.TaggedError<UnknownTursoError>()("UnknownTursoError", {
|
|
46
|
+
code: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
47
|
+
message: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
49
48
|
body: Schema.Unknown,
|
|
50
|
-
}
|
|
51
|
-
).pipe(Category.withServerError) {}
|
|
49
|
+
}).pipe(Category.withServerError) {}
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
|
-
* Schema parse error wrapper
|
|
52
|
+
* Schema parse error wrapper -- kept for parity with the distilled turso SDK's
|
|
55
53
|
* error surface.
|
|
56
54
|
*/
|
|
57
|
-
export class TursoParseError
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
export class TursoParseError
|
|
56
|
+
extends /*@__PURE__*/ Schema.TaggedError<TursoParseError>()("TursoParseError", {
|
|
57
|
+
body: Schema.Unknown,
|
|
58
|
+
cause: Schema.Unknown,
|
|
59
|
+
}).pipe(Category.withParseError) {}
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* Errors any Turso operation may surface beyond the core HTTP defaults.
|
package/src/index.ts
CHANGED
package/src/protocol.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as API from "@distilled.cloud/core/api";
|
|
|
2
2
|
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
3
3
|
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
4
4
|
/**
|
|
5
|
-
* TursoProtocol
|
|
5
|
+
* TursoProtocol -- hand-written.
|
|
6
6
|
*
|
|
7
7
|
* Turso's platform API is plain bearer-REST JSON (`Authorization: Bearer
|
|
8
8
|
* <apiKey>`, no response envelope), so the protocol is a direct
|
|
@@ -11,7 +11,7 @@ import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
|
11
11
|
* request: credentials resolved per request from the Credentials service,
|
|
12
12
|
* bearer auth header, base URL from `creds.apiBaseUrl`
|
|
13
13
|
*
|
|
14
|
-
* response: non-2xx
|
|
14
|
+
* response: non-2xx -> typed error matched like the distilled turso client:
|
|
15
15
|
* per-op matcher classes first, then the shared HTTP status map
|
|
16
16
|
* (`{ error: string, code?: string }` bodies parsed leniently,
|
|
17
17
|
* `retryAfter` hints stamped on retryable statuses), unmapped
|
|
@@ -36,19 +36,16 @@ export type TursoOpError = DefaultErrors | ConfigError | HttpClientError.HttpCli
|
|
|
36
36
|
/** Context (requirements) shared by every generated Turso operation. */
|
|
37
37
|
export type TursoOpContext = Credentials | HttpClient.HttpClient;
|
|
38
38
|
|
|
39
|
-
export const TursoProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
40
|
-
// The Credentials service holds an effect
|
|
39
|
+
export const TursoProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ makeRestProtocol<Config>({
|
|
40
|
+
// The Credentials service holds an effect -- resolving it here (per
|
|
41
41
|
// request) picks up rotations. Its error channel is erased at the protocol
|
|
42
42
|
// boundary; TursoOpError reintroduces it for callers.
|
|
43
|
-
credentials: Effect.
|
|
44
|
-
const resolve = yield* Credentials;
|
|
45
|
-
return yield* resolve;
|
|
46
|
-
}),
|
|
43
|
+
credentials: /*@__PURE__*/ Effect.flatMap(Credentials, (resolve) => resolve),
|
|
47
44
|
baseUrl: (creds) => creds.apiBaseUrl,
|
|
48
45
|
headers: (creds) => ({
|
|
49
46
|
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
50
47
|
}),
|
|
51
|
-
// Turso error bodies are `{ error: string, code?: string }`
|
|
48
|
+
// Turso error bodies are `{ error: string, code?: string }` -- covered by
|
|
52
49
|
// the default lenient envelope (message ?? error, string codes kept).
|
|
53
50
|
unknownError: ({ code, message, body }) =>
|
|
54
51
|
new UnknownTursoError({
|
package/src/retry.ts
CHANGED
|
@@ -33,17 +33,19 @@ export {
|
|
|
33
33
|
} from "@distilled.cloud/core/retry";
|
|
34
34
|
|
|
35
35
|
/** Context tag for configuring retry behavior of Turso API calls. */
|
|
36
|
-
export class Retry extends Context.Service<Retry, Policy>()("TursoRetry") {}
|
|
36
|
+
export class Retry extends /*@__PURE__*/ Context.Service<Retry, Policy>()("TursoRetry") {}
|
|
37
37
|
|
|
38
38
|
/** Provides a custom retry policy to every Turso API call below it. */
|
|
39
39
|
export const policy = (optionsOrFactory: Policy) =>
|
|
40
40
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
41
41
|
|
|
42
42
|
/** Disables all automatic retries. */
|
|
43
|
-
export const none = Effect.provide(
|
|
43
|
+
export const none = /*@__PURE__*/ Effect.provide(
|
|
44
|
+
/*@__PURE__*/ Layer.succeed(Retry, { while: () => false }),
|
|
45
|
+
);
|
|
44
46
|
|
|
45
47
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
46
|
-
export const throttling = policy(throttlingFactory);
|
|
48
|
+
export const throttling = /*@__PURE__*/ policy(throttlingFactory);
|
|
47
49
|
|
|
48
50
|
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
49
|
-
export const transient = policy(transientFactory);
|
|
51
|
+
export const transient = /*@__PURE__*/ policy(transientFactory);
|