@distilled.cloud/turso 1.0.0-rc.20 → 1.0.0-rc.21
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 +0 -1
- package/lib/_bundle/sdk.js +1 -1
- package/lib/_bundle/sdk.js.map +1 -1
- package/lib/credentials.d.ts +7 -3
- package/lib/credentials.d.ts.map +1 -1
- package/lib/errors.d.ts +7 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.lazy.js.map +1 -1
- package/lib/protocol.d.ts +9 -12
- package/lib/protocol.d.ts.map +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/turso.d.ts +38 -5
- package/lib/services/turso.d.ts.map +1 -1
- package/lib/services/turso.js +81 -80
- package/lib/services/turso.js.map +1 -1
- package/lib/services.lazy/turso.js +1 -1
- package/lib/traits.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/credentials.ts +20 -15
- package/src/errors.ts +9 -1
- package/src/protocol.ts +13 -21
- package/src/services/turso.ts +413 -263
package/src/protocol.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
import { makeRestProtocol, unknownErrorProps } from "@distilled.cloud/core/protocol-rest";
|
|
4
|
-
import type { SdkError } from "@distilled.cloud/core/sdk-error";
|
|
1
|
+
import type { ErrorOf } from "@distilled.cloud/core/protocol";
|
|
2
|
+
import { restProtocol, unknownErrorProps } from "@distilled.cloud/core/protocol-rest";
|
|
5
3
|
/**
|
|
6
4
|
* TursoProtocol -- hand-written.
|
|
7
5
|
*
|
|
8
6
|
* Turso's platform API is plain bearer-REST JSON (`Authorization: Bearer
|
|
9
7
|
* <apiKey>`, no response envelope), so the protocol is a direct
|
|
10
|
-
* `
|
|
8
|
+
* `restProtocol` instantiation from `core/protocol-rest`:
|
|
11
9
|
*
|
|
12
10
|
* request: credentials resolved per request from the Credentials service,
|
|
13
11
|
* bearer auth header, base URL from `creds.apiBaseUrl`
|
|
@@ -20,33 +18,27 @@ import type { SdkError } from "@distilled.cloud/core/sdk-error";
|
|
|
20
18
|
*/
|
|
21
19
|
import * as Effect from "effect/Effect";
|
|
22
20
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
23
|
-
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
24
|
-
import type * as Layer from "effect/Layer";
|
|
25
21
|
import * as Redacted from "effect/Redacted";
|
|
26
|
-
import { Credentials
|
|
27
|
-
import { UnknownTursoError, type
|
|
22
|
+
import { Credentials } from "./credentials.ts";
|
|
23
|
+
import { UnknownTursoError, TursoParseError, type TursoServiceError } from "./errors.ts";
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
26
|
+
* What every generated Turso operation fails with besides its own errors: the
|
|
27
|
+
* service's errors, the protocol's, and what resolving the credentials fails
|
|
28
|
+
* with. Generated service files annotate operations with
|
|
29
|
+
* `API.OperationMethod<I, O, TursoOpError, TursoOpContext>` explicitly so the
|
|
30
|
+
* compiler never infers these back out of the schema generics.
|
|
34
31
|
*/
|
|
35
|
-
export type TursoOpError =
|
|
36
|
-
| DefaultErrors
|
|
37
|
-
| ConfigError
|
|
38
|
-
| HttpClientError.HttpClientError
|
|
39
|
-
| InvalidInput
|
|
40
|
-
| SdkError;
|
|
32
|
+
export type TursoOpError = TursoServiceError | ErrorOf<typeof TursoProtocol>;
|
|
41
33
|
|
|
42
34
|
/** Context (requirements) shared by every generated Turso operation. */
|
|
43
35
|
export type TursoOpContext = Credentials | HttpClient.HttpClient;
|
|
44
36
|
|
|
45
|
-
export const TursoProtocol
|
|
37
|
+
export const TursoProtocol = /*@__PURE__*/ restProtocol({
|
|
46
38
|
// The Credentials service holds an effect -- resolving it here (per
|
|
47
39
|
// request) picks up rotations. Its error channel is erased at the protocol
|
|
48
40
|
// boundary; TursoOpError reintroduces it for callers.
|
|
49
|
-
credentials: /*@__PURE__*/ Effect.
|
|
41
|
+
credentials: /*@__PURE__*/ Effect.flatten(Credentials),
|
|
50
42
|
baseUrl: (creds) => creds.apiBaseUrl,
|
|
51
43
|
headers: (creds) => ({
|
|
52
44
|
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|