11import * as v from "@badrap/valita" ;
22import { type Client , HTTPError } from "./client.ts" ;
33
4- type KvKey = ( number | string | boolean ) [ ] ;
4+ export type KvKey = ( number | string | boolean ) [ ] ;
55
6- type KvEntry < T > = { key : KvKey ; value : T ; versionstamp : string } ;
6+ export type KvEntry < T > = { key : KvKey ; value : T ; versionstamp : string } ;
77
8- type KvEntryMaybe < T > =
8+ export type KvEntryMaybe < T > =
99 | KvEntry < T >
1010 | { key : KvKey ; value : null ; versionstamp : null } ;
1111
12- type AtomicCheck = { key : KvKey ; versionstamp : string | null } ;
12+ export type KvCheck = { key : KvKey ; versionstamp : string | null } ;
1313
14- type KvMutation =
14+ export type KvMutation =
1515 | {
1616 type : "set" ;
1717 key : KvKey ;
@@ -31,19 +31,23 @@ type KvMutation =
3131 backoffSchedule ?: number [ ] ;
3232 } ;
3333
34- type KvCommitResult = { ok : true ; versionstamp : string } ;
34+ export type KvCommitResult = { ok : true ; versionstamp : string } ;
3535
36- type KvCommitError = { ok : false } ;
36+ export type KvCommitError = { ok : false } ;
3737
38- type KvListSelector =
38+ export type KvListSelector =
3939 | { prefix : KvKey ; start ?: undefined ; end ?: undefined }
4040 | { prefix : KvKey ; start : KvKey ; end ?: undefined }
4141 | { prefix : KvKey ; start ?: undefined ; end : KvKey }
4242 | { prefix ?: undefined ; start : KvKey ; end : KvKey } ;
4343
44- type KvListOptions = { limit ?: number ; reverse ?: boolean ; batchSize ?: number } ;
44+ export type KvListOptions = {
45+ limit ?: number ;
46+ reverse ?: boolean ;
47+ batchSize ?: number ;
48+ } ;
4549
46- type KvListIterator < T > = AsyncIterableIterator < KvEntry < T > > ;
50+ export type KvListIterator < T > = AsyncIterableIterator < KvEntry < T > > ;
4751
4852const Key = v . array ( v . union ( v . string ( ) , v . number ( ) , v . boolean ( ) ) ) ;
4953
@@ -155,21 +159,21 @@ export class Kv {
155159 }
156160 }
157161
158- atomic ( ) : AtomicOperation {
159- return new AtomicOperation ( this . #client) ;
162+ atomic ( ) : KvAtomicOperation {
163+ return new KvAtomicOperation ( this . #client) ;
160164 }
161165}
162166
163- class AtomicOperation {
167+ export class KvAtomicOperation {
164168 readonly #client: Client ;
165- readonly #checks: AtomicCheck [ ] = [ ] ;
169+ readonly #checks: KvCheck [ ] = [ ] ;
166170 readonly #mutations: KvMutation [ ] = [ ] ;
167171
168172 constructor ( client : Client ) {
169173 this . #client = client ;
170174 }
171175
172- check ( ...checks : AtomicCheck [ ] ) : this {
176+ check ( ...checks : KvCheck [ ] ) : this {
173177 for ( const { key, versionstamp } of checks ) {
174178 this . #checks. push ( { key, versionstamp } ) ;
175179 }
0 commit comments