@techfinityedge/koolbase-react-native 2.3.0 → 2.4.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/README.md CHANGED
@@ -323,6 +323,30 @@ Koolbase.codePush.applyDirectives();
323
323
 
324
324
  ---
325
325
 
326
+ ### Mandatory updates
327
+
328
+ Mark a bundle **mandatory** in the dashboard (or via `PATCH /mandatory`) when every device must apply it before continuing — surfaced as a push callback and a pollable flag:
329
+
330
+ ```typescript
331
+ await Koolbase.initialize({
332
+ publicKey: 'pk_live_xxxx',
333
+ baseUrl: 'https://api.koolbase.com',
334
+ // Fires the moment a mandatory bundle is staged for the next launch
335
+ onMandatoryUpdate: ({ version }) => {
336
+ showRestartRequiredDialog(version);
337
+ },
338
+ });
339
+
340
+ // Or poll it — e.g. on app resume — before letting the user proceed
341
+ if (Koolbase.codePush.hasMandatoryUpdate) {
342
+ showRestartRequiredDialog();
343
+ }
344
+ ```
345
+
346
+ A mandatory bundle still activates on the next cold launch like any other; the callback and flag just let you prompt the user to restart now instead of waiting.
347
+
348
+ ---
349
+
326
350
  ## Logic Engine
327
351
 
328
352
  Define conditional app behavior as data in your Runtime Bundle — no code changes required.
@@ -442,7 +466,7 @@ try {
442
466
 
443
467
  ## What's included
444
468
 
445
- - Authentication: email + password, Apple Sign-In, phone + OTP
469
+ - Authentication: email + password, Apple Sign-In, Google Sign-In, phone + OTP
446
470
  - Database with offline-first cache, realtime subscriptions, and populate
447
471
  - Storage with download URLs
448
472
  - Realtime subscriptions over WebSocket
@@ -23,11 +23,13 @@ export interface BundleManifest {
23
23
  signature: string;
24
24
  size_bytes: number;
25
25
  payload: BundlePayload;
26
+ mandatory?: boolean;
26
27
  }
27
28
  export declare class KoolbaseCodePush {
28
29
  private config;
29
30
  private channel;
30
31
  private activeManifest;
32
+ private mandatoryPending;
31
33
  constructor(config: KoolbaseConfig, channel?: string);
32
34
  init(options: {
33
35
  appVersion: string;
@@ -40,6 +42,12 @@ export declare class KoolbaseCodePush {
40
42
  private download;
41
43
  private handleRollback;
42
44
  get hasActiveBundle(): boolean;
45
+ /**
46
+ * True when a mandatory bundle has been staged this session and is awaiting
47
+ * application (it activates on the next cold launch). Gate your UI on this to
48
+ * prompt the user to restart so the required update takes effect.
49
+ */
50
+ get hasMandatoryUpdate(): boolean;
43
51
  get manifest(): BundleManifest | null;
44
52
  getBundleConfig(key: string): unknown | undefined;
45
53
  getBundleFlag(key: string): boolean | undefined;
package/dist/code-push.js CHANGED
@@ -72,6 +72,7 @@ async function extractManifestFromZip(data) {
72
72
  class KoolbaseCodePush {
73
73
  constructor(config, channel = 'stable') {
74
74
  this.activeManifest = null;
75
+ this.mandatoryPending = false;
75
76
  // ─── Directive handling ──────────────────────────────────────────────────
76
77
  this.directiveHandlers = new Map();
77
78
  this.config = config;
@@ -178,9 +179,21 @@ class KoolbaseCodePush {
178
179
  console.warn('[KoolbaseCodePush] manifest extraction failed');
179
180
  return;
180
181
  }
182
+ // Carry the mandatory flag from the check response onto the staged manifest
183
+ manifest.mandatory = ref.mandatory;
181
184
  // Store as pending — activates on next launch
182
185
  await async_storage_1.default.setItem(STORAGE_KEY_PENDING, JSON.stringify(manifest));
183
186
  console.log(`[KoolbaseCodePush] bundle v${manifest.version} ready for next launch`);
187
+ if (ref.mandatory) {
188
+ this.mandatoryPending = true;
189
+ console.log('[KoolbaseCodePush] staged bundle is mandatory — notifying app');
190
+ try {
191
+ this.config.onMandatoryUpdate?.({ version: manifest.version, bundleId: manifest.bundle_id });
192
+ }
193
+ catch (cbErr) {
194
+ console.warn('[KoolbaseCodePush] onMandatoryUpdate handler threw:', cbErr);
195
+ }
196
+ }
184
197
  }
185
198
  catch (e) {
186
199
  console.warn('[KoolbaseCodePush] download error:', e);
@@ -197,6 +210,14 @@ class KoolbaseCodePush {
197
210
  get hasActiveBundle() {
198
211
  return this.activeManifest !== null;
199
212
  }
213
+ /**
214
+ * True when a mandatory bundle has been staged this session and is awaiting
215
+ * application (it activates on the next cold launch). Gate your UI on this to
216
+ * prompt the user to restart so the required update takes effect.
217
+ */
218
+ get hasMandatoryUpdate() {
219
+ return this.mandatoryPending;
220
+ }
200
221
  get manifest() {
201
222
  return this.activeManifest;
202
223
  }
package/dist/types.d.ts CHANGED
@@ -2,6 +2,10 @@ export interface KoolbaseConfig {
2
2
  publicKey: string;
3
3
  baseUrl: string;
4
4
  codePushChannel?: string;
5
+ onMandatoryUpdate?: (info: {
6
+ version: number;
7
+ bundleId: string;
8
+ }) => void;
5
9
  analyticsEnabled?: boolean;
6
10
  appVersion?: string;
7
11
  messagingEnabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techfinityedge/koolbase-react-native",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "React Native SDK for Koolbase \u2014 auth, database, storage, realtime, feature flags, and functions in one package.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",