@distilled.cloud/turso 1.0.0-rc.2 → 1.0.0-rc.20
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/LICENSE +201 -0
- package/README.md +34 -0
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +11 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +1 -27
- package/lib/errors.d.ts +15 -18
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -32
- package/lib/index.d.ts +5 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -14
- package/lib/index.lazy.js +6 -0
- package/lib/{index.js.map → index.lazy.js.map} +1 -1
- package/lib/protocol.d.ts +6 -5
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +1 -46
- package/lib/retry.d.ts +2 -2
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -33
- package/lib/services/index.js +0 -2
- package/lib/services/turso.d.ts +389 -430
- package/lib/services/turso.d.ts.map +1 -1
- package/lib/services/turso.js +82 -1462
- package/lib/services/turso.js.map +1 -1
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/turso.js +4 -0
- package/lib/traits.d.ts +2 -2
- package/lib/traits.js +1 -13
- package/package.json +27 -19
- package/src/credentials.ts +12 -13
- package/src/errors.ts +13 -18
- package/src/index.ts +5 -9
- package/src/protocol.ts +26 -36
- package/src/retry.ts +6 -10
- package/src/services/turso.ts +2273 -2128
- package/src/traits.ts +2 -2
- package/lib/credentials.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/protocol.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/services/index.js.map +0 -1
- package/lib/traits.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @distilled.cloud/turso
|
|
2
|
+
|
|
3
|
+
Effect-native SDK for [turso](https://www.npmjs.com/package/@distilled.cloud/turso).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @distilled.cloud/turso effect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Effect, Layer } from "effect";
|
|
15
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
16
|
+
import * as Turso from "@distilled.cloud/turso";
|
|
17
|
+
|
|
18
|
+
const program = Effect.gen(function* () {
|
|
19
|
+
const result = yield* Turso.listAPITokens({});
|
|
20
|
+
return result;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const Live = Layer.mergeAll(
|
|
24
|
+
FetchHttpClient.layer,
|
|
25
|
+
Turso.CredentialsFromEnv,
|
|
26
|
+
Turso.TursoProtocol,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
program.pipe(Effect.provide(Live), Effect.runPromise);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Auth
|
|
33
|
+
|
|
34
|
+
Required: `TURSO_API_KEY`. Sent as `Authorization: Bearer`.
|
package/lib/.lazy.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"serviceDirs":["services"],"twins":["index.js"]}
|
|
@@ -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 s,category$withConflictError as ee,category$withParseError as te,config$String as ne,config$all as re,retry$capped as ie,retry$jittered as c,retry$makeDefault as l,retry$throttlingFactory as u,retry$throttlingOptions as d,retry$transientFactory as f,retry$transientOptions as p,schema_lite_typed$TaggedError as m,schema_lite_typed$Unknown as h,trait$Body as g,trait$FormDataFile as _,trait$Header as v,trait$Http as y,trait$HttpBody as b,trait$KeyDictionary as x,trait$Label as S,trait$Query as C,trait$ResponseCode as w,trait$UnionCases as T,trait$applyErrorMatchers as E,trait$bodySymbol as D,trait$errorMatchersSymbol as O,trait$formDataFileSymbol as k,trait$getErrorMatchers as A,trait$headerSymbol as j,trait$httpBodySymbol as M,trait$httpSymbol as N,trait$keyDictionarySymbol as P,trait$labelSymbol as F,trait$querySymbol as I,trait$responseCodeSymbol as L,trait$unionCasesSymbol as R}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as z,errors$BadGateway as B,errors$BadRequest as V,errors$ConfigError as H,errors$Conflict as U,errors$DEFAULT_ERRORS as W,errors$Forbidden as G,errors$GatewayTimeout as K,errors$HTTP_STATUS_MAP as q,errors$InternalServerError as ae,errors$Locked as J,errors$NotFound as oe,errors$ServiceUnavailable as se,errors$TooManyRequests as ce,errors$Unauthorized as le,errors$UnknownErrorFields as ue,errors$UnprocessableEntity as de,protocol_rest$RawResponse as fe,protocol_rest$RawResponseRoot as pe,protocol_rest$SensitiveValue as me,protocol_rest$makeRestProtocol as he,protocol_rest$rawResponseRootSymbol as ge,protocol_rest$rawResponseSymbol as _e,protocol_rest$sensitiveValueSymbol as ve,protocol_rest$unknownErrorProps as ye,schema_lite$Array as be,schema_lite$Boolean as xe,schema_lite$NullOr as Se,schema_lite$Number as Ce,schema_lite$Record as we,schema_lite$String as Te,schema_lite$Struct as Ee,schema_lite$TaggedError as De,schema_lite$Unknown as Oe,schema_lite$at as ke,schema_lite$optional as Ae,schema_lite$suspend as je}from"@distilled.cloud/core/_bundle/rest";import*as Y from"effect/Context";import*as X from"effect/Effect";import*as Z from"effect/Layer";import*as Q from"effect/Redacted";const $=`https://api.turso.tech`;var Credentials=class extends (/*@__PURE__*/ Y.Service()(`TursoCredentials`)){};const Me=/*@__PURE__*/ re({apiKey:/*@__PURE__*/ ne(`TURSO_API_KEY`)});const Ne=/*@__PURE__*/ Z.succeed(Credentials,/*@__PURE__*/ Me.pipe(/*@__PURE__*/ X.mapError(()=>new H({message:`TURSO_API_KEY environment variable is required`})),/*@__PURE__*/ X.map(({apiKey:e})=>({apiKey:Q.make(e),apiBaseUrl:$}))));var UnknownTursoError=class extends (/*@__PURE__*/ m()(`UnknownTursoError`,ue)){};var TursoParseError=class extends (/*@__PURE__*/ m()(`TursoParseError`,{body:h,cause:h}).pipe(te)){};const Pe=/*@__PURE__*/ he({credentials:/*@__PURE__*/ X.flatMap(Credentials,e=>e),baseUrl:e=>e.apiBaseUrl,headers:e=>({Authorization:`Bearer ${Q.value(e.apiKey)}`}),unknownError:e=>new UnknownTursoError(ye(e)),parseError:({body:e,cause:t})=>new TursoParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ Y.Service()(`TursoRetry`)){};const policy=e=>X.provide(Z.succeed(Retry,e));const Fe=/*@__PURE__*/ X.provide(/*@__PURE__*/ Z.succeed(Retry,{while:()=>false}));const Ie=/*@__PURE__*/ policy(u);const Le=/*@__PURE__*/ policy(f);export{ee as Ba,be as Wb,xe as Xb,e as a,t as c,Credentials as credentials$Credentials,Ne as credentials$CredentialsFromEnv,$ as credentials$DEFAULT_API_BASE_URL,Se as dc,n as e,Ce as ec,z as errors$API_ERRORS,B as errors$BadGateway,V as errors$BadRequest,H as errors$ConfigError,U as errors$Conflict,W as errors$DEFAULT_ERRORS,G as errors$Forbidden,K as errors$GatewayTimeout,q as errors$HTTP_STATUS_MAP,ae as errors$InternalServerError,J as errors$Locked,oe as errors$NotFound,se as errors$ServiceUnavailable,ce as errors$TooManyRequests,TursoParseError as errors$TursoParseError,le as errors$Unauthorized,UnknownTursoError as errors$UnknownTursoError,de as errors$UnprocessableEntity,we as fc,Te as hc,Ee as ic,r as k,De as kc,i as l,a as m,Oe as nc,ke as pc,Pe as protocol$TursoProtocol,Retry as retry$Retry,ie as retry$capped,c as retry$jittered,l as retry$makeDefault,Fe as retry$none,policy as retry$policy,Ie as retry$throttling,u as retry$throttlingFactory,d as retry$throttlingOptions,Le as retry$transient,f as retry$transientFactory,p as retry$transientOptions,g as traits$Body,_ as traits$FormDataFile,v as traits$Header,y as traits$Http,b as traits$HttpBody,x as traits$KeyDictionary,S as traits$Label,C as traits$Query,fe as traits$RawResponse,pe as traits$RawResponseRoot,w as traits$ResponseCode,me as traits$SensitiveValue,T as traits$UnionCases,E as traits$applyErrorMatchers,D as traits$bodySymbol,O as traits$errorMatchersSymbol,k as traits$formDataFileSymbol,A as traits$getErrorMatchers,j as traits$headerSymbol,M as traits$httpBodySymbol,N as traits$httpSymbol,P as traits$keyDictionarySymbol,F as traits$labelSymbol,I as traits$querySymbol,ge as traits$rawResponseRootSymbol,_e as traits$rawResponseSymbol,L as traits$responseCodeSymbol,ve as traits$sensitiveValueSymbol,R as traits$unionCasesSymbol,Ae as uc,je as vc,o as xa,s as ya};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","D","call","error","named","newError","op","withAuthError","withBadRequestError","withConflictError","withParseError","String$2","all$1","capped","jittered","makeDefault","throttlingFactory","throttlingOptions","transientFactory","transientOptions","TaggedError$1","Unknown$1","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","UnknownErrorFields","UnprocessableEntity","RawResponse","RawResponseRoot","SensitiveValue","makeRestProtocol","rawResponseRootSymbol","rawResponseSymbol","sensitiveValueSymbol","unknownErrorProps","Array","Boolean","NullOr","Number","Record","String","Struct","TaggedError","Unknown","at","optional","suspend","Context","Effect","Layer","Redacted","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","apiKey","TursoProtocol","resolve","creds","info","optionsOrFactory","none","throttling","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"swEAeA,MAAauF,EAAuB,yBAOpC,IAAa,YAAb,eACwB,gBAAQ,QAAyD,CAAC,CACtF,kBACF,EAAA,AAAE,CAAC,EAEL,MAAMC,GAA0B,iBAAiB,CAC/C,OAAsB,iBAAoB,eAAe,CAC3D,CAAC,EAED,MAAaC,GAAmC,gBAAM,QACpD,YACc,iBAAU,KACR,gBAAO,aAEjB,IAAIxC,EAAY,CACd,QAAS,gDACX,CAAC,CACL,EACc,gBAAO,KAAK,CAAE,aAAc,CACxC,OAAQqC,EAAS,KAAKI,CAAM,EAC5B,WAAYH,CACd,EAAE,CACJ,CACF,ECDA,IAAa,kBAAb,eACwB,gBAAsC,CAAC,CAC3D,oBACA1B,EACF,EAAA,AAAE,CAAC,EAML,IAAa,gBAAb,eACwB,gBAAoC,CAAC,CAAC,kBAAmB,CAC7E,KAAM7D,EACN,MAAOA,CACT,CAAC,CAAC,CAAC,KAAKC,EAAuB,EAAA,AAAE,CAAC,ECdpC,MAAa0F,GAAyD,iBAAyB,CAI7F,YAA2B,gBAAO,QAAQ,YAAc,GAAYC,CAAO,EAC3E,QAAU,GAAUC,EAAM,WAC1B,QAAU,IAAW,CACnB,cAAe,UAAUP,EAAS,MAAMO,EAAM,MAAM,GACtD,GAGA,aAAe,GAAS,IAAI,kBAAkBvB,GAAkBwB,CAAI,CAAC,EACrE,YAAa,CAAE,OAAM,WAAY,IAAI,gBAAgB,CAAE,OAAM,OAAM,CAAC,CACtE,CAAC,ECtBD,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,YAAY,EAAA,AAAE,CAAC,EAGzF,MAAa,OAAU,GACrBV,EAAO,QAAQC,EAAM,QAAQ,MAAOU,CAAgB,CAAC,EAGvD,MAAaC,GAAqB,gBAAO,QACzB,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAGA,MAAaC,GAA2B,qBAAOhF,CAAiB,EAGhE,MAAaiF,GAA0B,qBAAO/E,CAAgB"}
|
package/lib/credentials.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
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";
|
|
1
10
|
import * as Context from "effect/Context";
|
|
2
11
|
import * as Effect from "effect/Effect";
|
|
3
12
|
import * as Layer from "effect/Layer";
|
|
@@ -7,8 +16,8 @@ export interface Config {
|
|
|
7
16
|
readonly apiKey: Redacted.Redacted<string>;
|
|
8
17
|
readonly apiBaseUrl: string;
|
|
9
18
|
}
|
|
10
|
-
declare const Credentials_base: Context.ServiceClass<Credentials, "TursoCredentials", Effect.Effect<Config,
|
|
11
|
-
export declare class Credentials extends Credentials_base {
|
|
19
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "TursoCredentials", Effect.Effect<Config, ConfigError, never>>;
|
|
20
|
+
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
12
21
|
}
|
|
13
22
|
export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
|
|
14
23
|
export {};
|
package/lib/credentials.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,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,gBAErB;CAAG;AAMN,eAAO,MAAM,kBAAkB,wCAc9B,CAAC"}
|
package/lib/credentials.js
CHANGED
|
@@ -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,33 @@
|
|
|
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 "
|
|
12
|
-
declare const UnknownTursoError_base: Schema.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ServerError: true;
|
|
19
|
-
};
|
|
20
|
-
});
|
|
11
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
12
|
+
declare const UnknownTursoError_base: Schema.TaggedErrorClass<"UnknownTursoError", {
|
|
13
|
+
status: import("effect/Schema").Number;
|
|
14
|
+
code: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
15
|
+
message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
|
+
body: import("effect/Schema").Unknown;
|
|
17
|
+
}>;
|
|
21
18
|
/**
|
|
22
|
-
* Unknown Turso error
|
|
19
|
+
* Unknown Turso error -- returned when an error response cannot be mapped to
|
|
23
20
|
* a shared HTTP status class. Carries the raw `code` string Turso sometimes
|
|
24
21
|
* includes in its error body.
|
|
25
22
|
*/
|
|
26
|
-
export declare class UnknownTursoError extends UnknownTursoError_base {
|
|
23
|
+
export declare class UnknownTursoError extends /*@__PURE__*/ UnknownTursoError_base {
|
|
27
24
|
}
|
|
28
|
-
declare const TursoParseError_base: Schema.
|
|
29
|
-
readonly body: Schema.Unknown;
|
|
30
|
-
readonly cause: Schema.Unknown;
|
|
31
|
-
}
|
|
25
|
+
declare const TursoParseError_base: Schema.TaggedErrorClass<"TursoParseError", {
|
|
26
|
+
readonly body: import("effect/Schema").Unknown;
|
|
27
|
+
readonly cause: import("effect/Schema").Unknown;
|
|
28
|
+
}> & (new (...args: any[]) => {
|
|
32
29
|
"@distilled.cloud/error/categories": {
|
|
33
30
|
ParseError: true;
|
|
34
31
|
};
|
|
35
32
|
});
|
|
36
33
|
/**
|
|
37
|
-
* Schema parse error wrapper
|
|
34
|
+
* Schema parse error wrapper -- kept for parity with the distilled turso SDK's
|
|
38
35
|
* error surface.
|
|
39
36
|
*/
|
|
40
|
-
export declare class TursoParseError extends TursoParseError_base {
|
|
37
|
+
export declare class TursoParseError extends /*@__PURE__*/ TursoParseError_base {
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
43
40
|
* Errors any Turso operation may surface beyond the core HTTP defaults.
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAEtC,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;;GAIG;AACH,qBAAa,iBACX,SAAQ,aAAa,CAAC,sBAGrB;CAAG;;;;;;;;;AAEN;;;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 Schema from "effect/Schema";
|
|
11
|
-
import * as Category from "@distilled.cloud/core/category";
|
|
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.TaggedErrorClass()("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.TaggedErrorClass()("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,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @distilled.cloud/turso
|
|
2
|
+
* @distilled.cloud/turso -- Turso SDK for Effect.
|
|
3
3
|
*
|
|
4
|
-
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy model that
|
|
5
|
+
* `scripts/convert.ts` converts from the Turso OpenAPI spec. Everything else in
|
|
6
|
+
* this folder is hand-written.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
@@ -14,6 +14,6 @@ export * from "./credentials.ts";
|
|
|
14
14
|
export * from "./errors.ts";
|
|
15
15
|
export * as T from "./traits.ts";
|
|
16
16
|
export * as Retry from "./retry.ts";
|
|
17
|
-
export { TursoProtocol, type TursoOpError, type TursoOpContext
|
|
17
|
+
export { TursoProtocol, type TursoOpError, type TursoOpContext } from "./protocol.ts";
|
|
18
18
|
export * as Services from "./services/index.ts";
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
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
|
-
export { TursoProtocol
|
|
5
|
+
export { TursoProtocol } from "./protocol.js";
|
|
18
6
|
export * as Services from "./services/index.js";
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAA0C,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
package/lib/protocol.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type * as Layer from "effect/Layer";
|
|
2
|
-
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
3
|
-
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
4
1
|
import type * as API from "@distilled.cloud/core/api";
|
|
5
|
-
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
2
|
+
import type { ConfigError, InvalidInput } from "@distilled.cloud/core/errors";
|
|
3
|
+
import type { SdkError } from "@distilled.cloud/core/sdk-error";
|
|
4
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
5
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
6
|
+
import type * as Layer from "effect/Layer";
|
|
6
7
|
import { Credentials } from "./credentials.ts";
|
|
7
8
|
import { type DefaultErrors } from "./errors.ts";
|
|
8
9
|
/**
|
|
@@ -11,7 +12,7 @@ import { type DefaultErrors } from "./errors.ts";
|
|
|
11
12
|
* TursoOpContext>` explicitly so the compiler never infers these back out of
|
|
12
13
|
* the schema generics.
|
|
13
14
|
*/
|
|
14
|
-
export type TursoOpError = DefaultErrors | ConfigError | HttpClientError.HttpClientError;
|
|
15
|
+
export type TursoOpError = DefaultErrors | ConfigError | HttpClientError.HttpClientError | InvalidInput | SdkError;
|
|
15
16
|
/** Context (requirements) shared by every generated Turso operation. */
|
|
16
17
|
export type TursoOpContext = Credentials | HttpClient.HttpClient;
|
|
17
18
|
export declare const TursoProtocol: Layer.Layer<API.Protocol>;
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"
|
|
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,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAkBhE,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,GACpB,aAAa,GACb,WAAW,GACX,eAAe,CAAC,eAAe,GAC/B,YAAY,GACZ,QAAQ,CAAC;AAEb,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAalD,CAAC"}
|
package/lib/protocol.js
CHANGED
|
@@ -1,46 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* TursoProtocol — hand-written.
|
|
3
|
-
*
|
|
4
|
-
* Turso's platform API is plain bearer-REST JSON (`Authorization: Bearer
|
|
5
|
-
* <apiKey>`, no response envelope), so the protocol is a direct
|
|
6
|
-
* `makeRestProtocol` instantiation from `core/protocol-rest`:
|
|
7
|
-
*
|
|
8
|
-
* request: credentials resolved per request from the Credentials service,
|
|
9
|
-
* bearer auth header, base URL from `creds.apiBaseUrl`
|
|
10
|
-
*
|
|
11
|
-
* response: non-2xx → typed error matched like the distilled turso client:
|
|
12
|
-
* per-op matcher classes first, then the shared HTTP status map
|
|
13
|
-
* (`{ error: string, code?: string }` bodies parsed leniently,
|
|
14
|
-
* `retryAfter` hints stamped on retryable statuses), unmapped
|
|
15
|
-
* failures fall back to `UnknownTursoError`.
|
|
16
|
-
*/
|
|
17
|
-
import * as Effect from "effect/Effect";
|
|
18
|
-
import * as Redacted from "effect/Redacted";
|
|
19
|
-
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
20
|
-
import { Credentials } from "./credentials.js";
|
|
21
|
-
import { UnknownTursoError } 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"
|
|
38
|
-
? code
|
|
39
|
-
: code !== undefined
|
|
40
|
-
? String(code)
|
|
41
|
-
: undefined,
|
|
42
|
-
message,
|
|
43
|
-
body,
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=protocol.js.map
|
|
1
|
+
export { protocol$TursoProtocol as TursoProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Policy } from "@distilled.cloud/core/retry";
|
|
1
2
|
/**
|
|
2
3
|
* Turso retry configuration.
|
|
3
4
|
*
|
|
@@ -16,11 +17,10 @@
|
|
|
16
17
|
*/
|
|
17
18
|
import * as Context from "effect/Context";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
19
|
-
import { type Policy } from "@distilled.cloud/core/retry";
|
|
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>>;
|
package/lib/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA
|
|
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
|
-
|
|
2
|
-
* Turso retry configuration.
|
|
3
|
-
*
|
|
4
|
-
* Defines the per-SDK `Retry` Context.Service tag that generated operations
|
|
5
|
-
* wire into `API.make({ retry: Retry.Retry })`. Callers can install a
|
|
6
|
-
* blanket retry policy at the layer level and have every Turso API call
|
|
7
|
-
* below it pick it up:
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import * as Turso from "@distilled.cloud/turso";
|
|
12
|
-
*
|
|
13
|
-
* myEffect.pipe(Turso.Retry.transient);
|
|
14
|
-
* Effect.provide(myEffect, Layer.succeed(Turso.Retry.Retry, customPolicy));
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
import * as Context from "effect/Context";
|
|
18
|
-
import * as Effect from "effect/Effect";
|
|
19
|
-
import * as Layer from "effect/Layer";
|
|
20
|
-
import { throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
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";
|
package/lib/services/index.js
CHANGED