Releases: pocketbase/js-sdk
v0.18.0 Release
-
Added
pb.backups.upload(data)
action (available with PocketBase v0.18.0). -
Added experimental
autoRefreshThreshold
option to auto refresh (or reauthenticate) the AuthStore when authenticated as admin.
This could be used as an alternative to fixed Admin API keys.await pb.admins.authWithPassword("test@example.com", "1234567890", { // This will trigger auto refresh or auto reauthentication in case // the token has expired or is going to expire in the next 30 minutes. autoRefreshThreshold: 30 * 60 })
v0.17.3 Release
- Loosen the type check when calling
pb.files.getUrl(record, filename)
to allow passing thepb.authStore.model
without type assertion.
v0.17.2 Release
- Fixed mulitple
File
/Blob
array values not transformed properly to theirFormData
equivalent when an object syntax is used.
v0.17.1 Release
- Fixed typo in the deprecation console.warn messages (#235; thanks @heloineto).
v0.17.0 Release
β οΈ Please read carefully the release notes as there are some minor breaking changes!
-
To simplify file uploads, we now allow sending the
multipart/form-data
request body also as plain object if at least one of the object props hasFile
orBlob
value.// the standard way to create multipart/form-data body const data = new FormData(); data.set("title", "lorem ipsum...") data.set("document", new File(...)) // this is the same as above // (it will be converted behind the scenes to FormData) const data = { "title": "lorem ipsum...", "document": new File(...), }; await pb.collection("example").create(data);
-
Added new
pb.authStore.isAdmin
andpb.authStore.isAuthRecord
helpers to check the type of the current auth state. -
The default
LocalAuthStore
now listen to the browser storage event,
so that we can sync automatically thepb.authStore
state between multiple tabs. -
Added new helper
AsyncAuthStore
class that can be used to integrate with any 3rd party async storage implementation (usually this is needed when working with React Native):import AsyncStorage from "@react-native-async-storage/async-storage"; import PocketBase, { AsyncAuthStore } from "pocketbase"; const store = new AsyncAuthStore({ save: async (serialized) => AsyncStorage.setItem("pb_auth", serialized), initial: await AsyncStorage.getItem("pb_auth"), }); const pb = new PocketBase("https://example.com", store)
-
pb.files.getUrl()
now returns empty string in case an empty filename is passed. -
β οΈ All API actions now return plain object (POJO) as response, aka. the custom class wrapping was removed and you no longer need to manually callstructuredClone(response)
when using with SSR frameworks.This could be a breaking change if you use the below classes (and respectively their helper methods like
$isNew
,$load()
, etc.) since they were replaced with plain TS interfaces:class BaseModel -> interface BaseModel class Admin -> interface AdminModel class Record -> interface RecordModel class LogRequest -> interface LogRequestModel class ExternalAuth -> interface ExternalAuthModel class Collection -> interface CollectionModel class SchemaField -> interface SchemaField class ListResult -> interface ListResult
Side-note: If you use somewhere in your code the
Record
andAdmin
classes to determine the type of yourpb.authStore.model
,
you can safely replace it with the newpb.authStore.isAdmin
andpb.authStore.isAuthRecord
getters. -
β οΈ Added support for per-requestfetch
options, including also specifying completely customfetch
implementation.In addition to the default
fetch
options, the following configurable fields are supported:interface SendOptions extends RequestInit { // any other custom key will be merged with the query parameters // for backward compatibility and to minimize the verbosity [key: string]: any; // optional custom fetch function to use for sending the request fetch?: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response>; // custom headers to send with the requests headers?: { [key: string]: string }; // the body of the request (serialized automatically for json requests) body?: any; // query params that will be appended to the request url query?: { [key: string]: any }; // the request identifier that can be used to cancel pending requests requestKey?: string|null; // @deprecated use `requestKey:string` instead $cancelKey?: string; // @deprecated use `requestKey:null` instead $autoCancel?: boolean; }
For most users the above will not be a breaking change since there are available function overloads (when possible) to preserve the old behavior, but you can get a warning message in the console to update to the new format.
For example:// OLD (should still work but with a warning in the console) await pb.collection("example").authRefresh({}, { "expand": "someRelField", }) // NEW await pb.collection("example").authRefresh({ "expand": "someRelField", // send some additional header "headers": { "X-Custom-Header": "123", }, "cache": "no-store" // also usually used by frameworks like Next.js })
-
Eagerly open the default OAuth2 signin popup in case no custom
urlCallback
is provided as a workaround for Safari. -
Internal refactoring (updated dev dependencies, refactored the tests to use Vitest instead of Mocha, etc.).
v0.16.0 Release
-
Added
skipTotal=1
query parameter by default for thegetFirstListItem()
andgetFullList()
requests.
Note that this have performance boost only with PocketBase v0.17+. -
Added optional
download=1
query parameter to force file urls withContent-Disposition: attachment
(supported with PocketBase v0.17+).
v0.15.3 Release
- Automatically resolve pending realtime connect
Promise
s in caseunsubscribe
is called before
subscribe
is being able to complete (pocketbase#2897).
v0.15.2 Release
-
Replaced
new URL(...)
with manual url parsing as it doesn't seem to be fully supported in React Native (pocketbase#2484). -
Fixed nested
ClientResponseError.originalError
wrapping and addedClientResponseError
constructor tests.
v0.15.1 Release
- Cancel any pending subscriptions submit requests on realtime disconnect (#204).
v0.15.0 Release
-
Added
fields
to the optional query parameters for limiting the returned API fields (available with PocketBase v0.16.0). -
Added
pb.backups
service for the new PocketBase backup and restore APIs (available with PocketBase v0.16.0). -
Updated
pb.settings.testS3(filesystem)
to allow specifying a filesystem to test -storage
orbackups
(available with PocketBase v0.16.0).