vaultbase 0.4.0
vaultbase: ^0.4.0 copied to clipboard
Dart client for Vaultbase, the single-binary backend. Records, auth, files and realtime.
0.4.0 #
dart run vaultbase:typesgenerates a class per group field, named after the collection and field (OrdersItemsItem, orOrdersAddressfor a single object), with a member per subfield, the item'sid,fromJsonandtoJson. Records getList<OrdersItemsItem>(orOrdersAddress?) getters; create classes take them. Group fields need server 0.32.0.
0.3.0 #
excludeonlist,iterate,get,Singleton.getandBatch.list: fields to leave out of the response, applied afterfields.Batch.gettakesexpand,fieldsandexclude.- Both need server 0.31.0.
0.2.0 #
- Native Apple and Google sign-in:
auth.collection(name).signInWithIdTokenwith the ID token from the platform's sign-in sheet, andidTokenNoncefor the single-use nonce (required for Apple). Needs server 0.28.
0.1.0 #
- The client:
Vaultbase(baseUrl)with anAuthStore(memory by default), an optionalhttp.Client, a per-request timeout and default headers. - Records:
collection(name)/collectionOf(name, fromJson)withlist,iterate,get,create,update,deleteandaggregate; ETags are kept from reads and sent asIf-Matchon update and delete. - Singletons (
singleton(name)), batches of up to 100 operations (batch()), custom routes (custom), andsend()for any endpoint. filter()/buildFilter():{:name}placeholders, escaped by type.- Sessions: refreshed 60 s before the token expires and once on a 401,
shared by concurrent requests;
auth.refresh(),auth.logout(),auth.me(). A refresh that fails for lack of a connection keeps the session; only one the server refuses clears it. CancelToken, request keys andautoCancelto cancel requests.- Typed errors: a sealed
VaultbaseExceptionwith one subclass per kind; the server's errorcodeis kept. - Sign-in:
auth.collection(name)with register, login, two-factor (loginMfa, TOTP setup / confirm / disable, recovery codes), one-time codes, anonymous sign-in and promote, email verification, password reset, email change, invitations, and OAuth (oauth2Authorize,oauth2Exchange,oauth2ExchangeRedirect, merge confirm, unlink). Results are a sealedAuthResult:SignedIn,MfaRequired,MergeRequired.auth.adminfor admin setup, sign-in, invites and impersonation. - Files:
files.uploadwithUploadFile.fromBytes/fromStreamand upload progress,files.urlwith thumbnails and formats, access tokens for protected files (token,urlWithToken),files.delete. - Realtime over one WebSocket:
collection(name).subscribe/events(), per-record subscriptions,readyonce the server confirms, reconnect with backoff, the new token sent after each refresh,pause/resume, and astatesstream. AsyncAuthStorefor sessions kept in async storage: loads the saved session once, writes changes in order. Requests and the realtime connection wait forauthStore.ready, so the first request after start carries the saved token.- Feature flags:
vb.flags.connect(context: ...)loads every flag the server evaluates for the context;isEnabled,getString,getNumber,getJsonread them synchronously;changesnames the keys that changed. Changes are pushed over the realtime connection record subscriptions use, with a periodic refetch as a fallback, and the flags are fetched again after sign-in, sign-out and a reconnect. realtime.subscribeTopicfor server topics that aren't collections.- Typed records:
dart run vaultbase:types --schema=vaultbase-schema.json(or--urlwith--admin-token) writeslib/vaultbase_schema.g.dart: anXRecord extends RecordModelper collection with a getter per field, anXCreatewithtoJson(), andvb.collections.<name>returningCollection<XRecord>/Singleton<XRecord>. - Realtime: closing the client while a connection is opening leaves no pending timer (widget tests failed on it), and a connection attempt that times out is closed.