@koolbase/core 12.13.1 → 12.15.0

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.
Files changed (49) hide show
  1. package/dist/cjs/auth.d.ts +31 -1
  2. package/dist/cjs/auth.js +167 -20
  3. package/dist/cjs/cache-store.d.ts +5 -0
  4. package/dist/cjs/cache-store.js +31 -0
  5. package/dist/cjs/connectivity.d.ts +25 -0
  6. package/dist/cjs/connectivity.js +59 -0
  7. package/dist/cjs/database.d.ts +32 -0
  8. package/dist/cjs/database.js +111 -16
  9. package/dist/cjs/fiscal.js +2 -2
  10. package/dist/cjs/functions.js +2 -2
  11. package/dist/cjs/index.d.ts +3 -1
  12. package/dist/cjs/index.js +3 -1
  13. package/dist/cjs/network.d.ts +14 -0
  14. package/dist/cjs/network.js +60 -0
  15. package/dist/cjs/offline-state.d.ts +4 -0
  16. package/dist/cjs/offline-state.js +36 -0
  17. package/dist/cjs/platform.d.ts +16 -0
  18. package/dist/cjs/react/use-record.d.ts +1 -1
  19. package/dist/cjs/record-controller.d.ts +8 -1
  20. package/dist/cjs/record-controller.js +29 -7
  21. package/dist/cjs/shared.d.ts +1 -0
  22. package/dist/cjs/storage.js +11 -11
  23. package/dist/cjs/sync-engine.js +3 -3
  24. package/dist/cjs/types.d.ts +7 -0
  25. package/dist/esm/auth.d.ts +31 -1
  26. package/dist/esm/auth.js +168 -21
  27. package/dist/esm/cache-store.d.ts +5 -0
  28. package/dist/esm/cache-store.js +30 -0
  29. package/dist/esm/connectivity.d.ts +25 -0
  30. package/dist/esm/connectivity.js +55 -0
  31. package/dist/esm/database.d.ts +32 -0
  32. package/dist/esm/database.js +101 -6
  33. package/dist/esm/fiscal.js +3 -3
  34. package/dist/esm/functions.js +3 -3
  35. package/dist/esm/index.d.ts +3 -1
  36. package/dist/esm/index.js +1 -0
  37. package/dist/esm/network.d.ts +14 -0
  38. package/dist/esm/network.js +58 -0
  39. package/dist/esm/offline-state.d.ts +4 -0
  40. package/dist/esm/offline-state.js +35 -0
  41. package/dist/esm/platform.d.ts +16 -0
  42. package/dist/esm/react/use-record.d.ts +1 -1
  43. package/dist/esm/record-controller.d.ts +8 -1
  44. package/dist/esm/record-controller.js +29 -7
  45. package/dist/esm/shared.d.ts +1 -0
  46. package/dist/esm/storage.js +12 -12
  47. package/dist/esm/sync-engine.js +4 -4
  48. package/dist/esm/types.d.ts +7 -0
  49. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { koolbaseFetch } from './network.js';
1
+ import { sessionFetch } from './network.js';
2
2
  import { readOfflineState, mutateOfflineState, migrateLegacyQueue, flushLockName, } from './offline-state.js';
3
3
  import { KoolbaseUnauthenticatedError } from './errors.js';
4
4
  import { getPlatform } from './platform.js';
@@ -256,7 +256,7 @@ export class SyncEngine {
256
256
  : `${this.config.baseUrl}/v1/sdk/db/records/${write.recordId}`;
257
257
  let res;
258
258
  if (write.operation === 'insert') {
259
- res = await koolbaseFetch(url, {
259
+ res = await sessionFetch(url, {
260
260
  method: 'POST',
261
261
  headers,
262
262
  // The write's own id: generated at enqueue, identical on every retry.
@@ -270,7 +270,7 @@ export class SyncEngine {
270
270
  });
271
271
  }
272
272
  else if (write.operation === 'update') {
273
- res = await koolbaseFetch(url, {
273
+ res = await sessionFetch(url, {
274
274
  method: 'PATCH',
275
275
  headers,
276
276
  // The revision the change was composed against. The server applies it
@@ -289,7 +289,7 @@ export class SyncEngine {
289
289
  const q = write.baseRevision !== undefined
290
290
  ? `?expected_revision=${write.baseRevision}`
291
291
  : '';
292
- res = await koolbaseFetch(`${url}${q}`, { method: 'DELETE', headers });
292
+ res = await sessionFetch(`${url}${q}`, { method: 'DELETE', headers });
293
293
  }
294
294
  if (res.status === 401)
295
295
  throw new KoolbaseUnauthenticatedError('unauthorized');
@@ -180,6 +180,13 @@ export declare enum RestoreResult {
180
180
  * broken listener cannot break propagation to others.
181
181
  */
182
182
  export type AuthStateListener = (user: KoolbaseUser | null) => void;
183
+ /**
184
+ * Why the last session ended (#104): the person signed out, or the session
185
+ * ended on its own -- revoked, expired past renewal, signed out elsewhere.
186
+ * An app tells them apart to say "You were signed out" only when they did
187
+ * not ask to be.
188
+ */
189
+ export type SignOutReason = 'signed_out' | 'session_ended';
183
190
  /**
184
191
  * Drop-in replacement for the global `fetch` function. Inject via
185
192
  * KoolbaseConfig.fetch for testing (mock fetch), proxying, or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/core",
3
- "version": "12.13.1",
3
+ "version": "12.15.0",
4
4
  "description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/esm/index.d.ts",