@koolbase/core 12.46.0 → 12.48.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.
package/dist/cjs/auth.js CHANGED
@@ -921,6 +921,10 @@ class KoolbaseAuth {
921
921
  createdAt: String(r.created_at),
922
922
  expiresAt: String(r.expires_at),
923
923
  isCurrent: Boolean(r.is_current),
924
+ // An API before these sends none of these: the row's own times.
925
+ device: typeof r.device === 'string' && r.device ? r.device : 'Unknown device',
926
+ lastActiveAt: String(r.last_active_at ?? r.created_at),
927
+ signedInAt: String(r.signed_in_at ?? r.created_at),
924
928
  };
925
929
  });
926
930
  }
@@ -42,3 +42,4 @@ export { RestoreResult } from './types.js';
42
42
  export type { AuthStateListener, FetchLike, KoolbaseAuthStorage, ResendVerificationResult } from './types.js';
43
43
  export { setPlatform, getPlatform, memoryPlatform, type PlatformAdapter, type PlatformBroadcast, type PlatformStorage, type PlatformNetwork, type PlatformLifecycle, type PlatformLocks, type PlatformInfo, } from './platform.js';
44
44
  export * from './query-builder.js';
45
+ export { onCollectionWrite } from './query-refresh.js';
package/dist/cjs/index.js CHANGED
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.memoryPlatform = exports.getPlatform = exports.setPlatform = exports.RestoreResult = exports.koolbaseSdkVersion = exports.getOrCreateDeviceId = exports.KoolbaseMessaging = exports.isPending = exports.isFiscalized = exports.decodeFiscalResponse = exports.KoolbaseFiscalError = exports.KoolbaseFiscal = exports.disabledAnalytics = exports.KoolbaseAnalytics = exports.initialUploadQueueState = exports.KoolbaseUploadQueue = exports.initialFileState = exports.KoolbaseFileController = exports.filesQueryKey = exports.initialFilesState = exports.KoolbaseFilesController = exports.KoolbaseUploadTask = exports.KoolbaseStorage = exports.KoolbaseConnectivity = exports.KoolbaseRealtime = exports.KoolbaseFunctions = exports.KoolbaseFlags = exports.initialRecordState = exports.KoolbaseRecordController = exports.initialCollectionState = exports.collectionQueryKey = exports.KoolbaseCollectionController = exports.KoolbaseDatabase = exports.KoolbaseAppAdmin = exports.KoolbaseAuth = void 0;
22
+ exports.onCollectionWrite = exports.memoryPlatform = exports.getPlatform = exports.setPlatform = exports.RestoreResult = exports.koolbaseSdkVersion = exports.getOrCreateDeviceId = exports.KoolbaseMessaging = exports.isPending = exports.isFiscalized = exports.decodeFiscalResponse = exports.KoolbaseFiscalError = exports.KoolbaseFiscal = exports.disabledAnalytics = exports.KoolbaseAnalytics = exports.initialUploadQueueState = exports.KoolbaseUploadQueue = exports.initialFileState = exports.KoolbaseFileController = exports.filesQueryKey = exports.initialFilesState = exports.KoolbaseFilesController = exports.KoolbaseUploadTask = exports.KoolbaseStorage = exports.KoolbaseConnectivity = exports.KoolbaseRealtime = exports.KoolbaseFunctions = exports.KoolbaseFlags = exports.initialRecordState = exports.KoolbaseRecordController = exports.initialCollectionState = exports.collectionQueryKey = exports.KoolbaseCollectionController = exports.KoolbaseDatabase = exports.KoolbaseAppAdmin = exports.KoolbaseAuth = void 0;
23
23
  __exportStar(require("./types.js"), exports);
24
24
  __exportStar(require("./errors.js"), exports);
25
25
  __exportStar(require("./network.js"), exports);
@@ -91,3 +91,6 @@ Object.defineProperty(exports, "setPlatform", { enumerable: true, get: function
91
91
  Object.defineProperty(exports, "getPlatform", { enumerable: true, get: function () { return platform_js_1.getPlatform; } });
92
92
  Object.defineProperty(exports, "memoryPlatform", { enumerable: true, get: function () { return platform_js_1.memoryPlatform; } });
93
93
  __exportStar(require("./query-builder.js"), exports);
94
+ // Re-read after the app's own writes (12.48.0): counts, totals, charts.
95
+ var query_refresh_js_1 = require("./query-refresh.js");
96
+ Object.defineProperty(exports, "onCollectionWrite", { enumerable: true, get: function () { return query_refresh_js_1.onCollectionWrite; } });
@@ -6,5 +6,13 @@ export declare function registerQueryRefresher(collection: string, refresh: () =
6
6
  * this device). One after another; a failure in one never stops the others.
7
7
  */
8
8
  export declare function refreshCollectionQueries(collection?: string): Promise<void>;
9
+ /**
10
+ * Runs [run] after every write this app makes to [collection] -- an insert,
11
+ * update, upsert or delete, a batch, a synced offline write -- as a list on
12
+ * screen re-reads its records. For anything else drawn from the collection:
13
+ * a count, a total, a chart. Returns the stop. A failure in [run] never
14
+ * stops the others, and never fails the write.
15
+ */
16
+ export declare function onCollectionWrite(collection: string, run: () => void | Promise<void>): () => void;
9
17
  /** Tests only. */
10
18
  export declare function clearQueryRefreshers(): void;
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.registerQueryRefresher = registerQueryRefresher;
8
8
  exports.refreshCollectionQueries = refreshCollectionQueries;
9
+ exports.onCollectionWrite = onCollectionWrite;
9
10
  exports.clearQueryRefreshers = clearQueryRefreshers;
10
11
  const refreshers = new Map();
11
12
  let next = 0;
@@ -35,6 +36,18 @@ async function refreshCollectionQueries(collection) {
35
36
  }
36
37
  }
37
38
  }
39
+ /**
40
+ * Runs [run] after every write this app makes to [collection] -- an insert,
41
+ * update, upsert or delete, a batch, a synced offline write -- as a list on
42
+ * screen re-reads its records. For anything else drawn from the collection:
43
+ * a count, a total, a chart. Returns the stop. A failure in [run] never
44
+ * stops the others, and never fails the write.
45
+ */
46
+ function onCollectionWrite(collection, run) {
47
+ return registerQueryRefresher(collection, async () => {
48
+ await run();
49
+ });
50
+ }
38
51
  /** Tests only. */
39
52
  function clearQueryRefreshers() {
40
53
  refreshers.clear();
@@ -135,6 +135,15 @@ export interface KoolbaseSessionInfo {
135
135
  * exclude.
136
136
  */
137
137
  isCurrent: boolean;
138
+ /**
139
+ * The device, named for a person: "Chrome on macOS", "iOS 18.1".
140
+ * "Unknown device" from an API that does not name it.
141
+ */
142
+ device: string;
143
+ /** When the device last used this session (its last renewal). */
144
+ lastActiveAt: string;
145
+ /** When its owner last signed in on it. */
146
+ signedInAt: string;
138
147
  }
139
148
  /**
140
149
  * One thing that happened to this account.
package/dist/esm/auth.js CHANGED
@@ -918,6 +918,10 @@ export class KoolbaseAuth {
918
918
  createdAt: String(r.created_at),
919
919
  expiresAt: String(r.expires_at),
920
920
  isCurrent: Boolean(r.is_current),
921
+ // An API before these sends none of these: the row's own times.
922
+ device: typeof r.device === 'string' && r.device ? r.device : 'Unknown device',
923
+ lastActiveAt: String(r.last_active_at ?? r.created_at),
924
+ signedInAt: String(r.signed_in_at ?? r.created_at),
921
925
  };
922
926
  });
923
927
  }
@@ -42,3 +42,4 @@ export { RestoreResult } from './types.js';
42
42
  export type { AuthStateListener, FetchLike, KoolbaseAuthStorage, ResendVerificationResult } from './types.js';
43
43
  export { setPlatform, getPlatform, memoryPlatform, type PlatformAdapter, type PlatformBroadcast, type PlatformStorage, type PlatformNetwork, type PlatformLifecycle, type PlatformLocks, type PlatformInfo, } from './platform.js';
44
44
  export * from './query-builder.js';
45
+ export { onCollectionWrite } from './query-refresh.js';
package/dist/esm/index.js CHANGED
@@ -39,3 +39,5 @@ export { koolbaseSdkVersion } from './device-metadata.js';
39
39
  export { RestoreResult } from './types.js';
40
40
  export { setPlatform, getPlatform, memoryPlatform, } from './platform.js';
41
41
  export * from './query-builder.js';
42
+ // Re-read after the app's own writes (12.48.0): counts, totals, charts.
43
+ export { onCollectionWrite } from './query-refresh.js';
@@ -6,5 +6,13 @@ export declare function registerQueryRefresher(collection: string, refresh: () =
6
6
  * this device). One after another; a failure in one never stops the others.
7
7
  */
8
8
  export declare function refreshCollectionQueries(collection?: string): Promise<void>;
9
+ /**
10
+ * Runs [run] after every write this app makes to [collection] -- an insert,
11
+ * update, upsert or delete, a batch, a synced offline write -- as a list on
12
+ * screen re-reads its records. For anything else drawn from the collection:
13
+ * a count, a total, a chart. Returns the stop. A failure in [run] never
14
+ * stops the others, and never fails the write.
15
+ */
16
+ export declare function onCollectionWrite(collection: string, run: () => void | Promise<void>): () => void;
9
17
  /** Tests only. */
10
18
  export declare function clearQueryRefreshers(): void;
@@ -30,6 +30,18 @@ export async function refreshCollectionQueries(collection) {
30
30
  }
31
31
  }
32
32
  }
33
+ /**
34
+ * Runs [run] after every write this app makes to [collection] -- an insert,
35
+ * update, upsert or delete, a batch, a synced offline write -- as a list on
36
+ * screen re-reads its records. For anything else drawn from the collection:
37
+ * a count, a total, a chart. Returns the stop. A failure in [run] never
38
+ * stops the others, and never fails the write.
39
+ */
40
+ export function onCollectionWrite(collection, run) {
41
+ return registerQueryRefresher(collection, async () => {
42
+ await run();
43
+ });
44
+ }
33
45
  /** Tests only. */
34
46
  export function clearQueryRefreshers() {
35
47
  refreshers.clear();
@@ -135,6 +135,15 @@ export interface KoolbaseSessionInfo {
135
135
  * exclude.
136
136
  */
137
137
  isCurrent: boolean;
138
+ /**
139
+ * The device, named for a person: "Chrome on macOS", "iOS 18.1".
140
+ * "Unknown device" from an API that does not name it.
141
+ */
142
+ device: string;
143
+ /** When the device last used this session (its last renewal). */
144
+ lastActiveAt: string;
145
+ /** When its owner last signed in on it. */
146
+ signedInAt: string;
138
147
  }
139
148
  /**
140
149
  * One thing that happened to this account.
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@koolbase/core",
3
- "version": "12.46.0",
4
- "description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
3
+ "version": "12.48.0",
4
+ "description": "Koolbase SDK core — shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
5
5
  "main": "./dist/cjs/index.js",
6
+ "react-native": "./dist/esm/index.js",
6
7
  "types": "./dist/esm/index.d.ts",
7
8
  "files": [
8
9
  "dist",
@@ -2,6 +2,7 @@
2
2
  "//": "For resolvers that ignore \"exports\" (TypeScript node10, older bundlers): the ./react entry.",
3
3
  "main": "../dist/cjs/react/index.js",
4
4
  "module": "../dist/esm/react/index.js",
5
+ "react-native": "../dist/esm/react/index.js",
5
6
  "types": "../dist/cjs/react/index.d.ts",
6
7
  "sideEffects": false
7
8
  }