@teincfood/core 0.9.2 → 0.9.3
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/sync/sync-guard.d.ts +4 -1
- package/dist/sync/sync-guard.js +15 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export { getSyncJobsPendingCount, debugDumpSyncJobs, drainPending } from "./sync
|
|
|
141
141
|
export { performFullSync } from "./sync/full-sync";
|
|
142
142
|
export { stopHealthProbe } from "./sync/health-probe";
|
|
143
143
|
export { notifyAuthChanged, subscribeAuth } from "./adapters/auth";
|
|
144
|
-
export { isAuthenticated, hasActiveBusiness, canBusinessSync } from "./sync/sync-guard";
|
|
144
|
+
export { isAuthenticated, hasActiveBusiness, canBusinessSync, setOfflineSyncEnabled, isOfflineSyncEnabled } from "./sync/sync-guard";
|
|
145
145
|
export { ACCESS_EXPIRED_CODE, SESSION_DEAD_CODES, SKIP_AUTH_RETRY, extractAuthFailure, isAccessExpired, isSessionDead, hasAuthRetrySkip, refreshSession, withAuthRetry, } from "./auth/session";
|
|
146
146
|
export type { AuthFailure, SessionTokens } from "./auth/session";
|
|
147
147
|
export { getCachedImagePath, ensureImageCacheDir, getCachedImageInfo, cacheRemoteImage, cacheImageBatch, clearImageCache, pruneImageCache, resolveImageSource, stableCacheUrl } from "./image-cache/service";
|
package/dist/index.js
CHANGED
|
@@ -156,7 +156,7 @@ export { getSyncJobsPendingCount, debugDumpSyncJobs, drainPending } from "./sync
|
|
|
156
156
|
export { performFullSync } from "./sync/full-sync";
|
|
157
157
|
export { stopHealthProbe } from "./sync/health-probe";
|
|
158
158
|
export { notifyAuthChanged, subscribeAuth } from "./adapters/auth";
|
|
159
|
-
export { isAuthenticated, hasActiveBusiness, canBusinessSync } from "./sync/sync-guard";
|
|
159
|
+
export { isAuthenticated, hasActiveBusiness, canBusinessSync, setOfflineSyncEnabled, isOfflineSyncEnabled } from "./sync/sync-guard";
|
|
160
160
|
// ── Session lifecycle (access-expired → refresh → refresh-expired → logout)
|
|
161
161
|
export { ACCESS_EXPIRED_CODE, SESSION_DEAD_CODES, SKIP_AUTH_RETRY, extractAuthFailure, isAccessExpired, isSessionDead, hasAuthRetrySkip, refreshSession, withAuthRetry, } from "./auth/session";
|
|
162
162
|
// ── Image cache (durable) ──
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
* the user has logged in and a business is selected. User-scoped queries
|
|
8
8
|
* (invitations, fleet) gate on auth only.
|
|
9
9
|
*/
|
|
10
|
+
export declare function setOfflineSyncEnabled(enabled: boolean): void;
|
|
11
|
+
export declare function isOfflineSyncEnabled(): boolean;
|
|
10
12
|
export declare function isAuthenticated(): boolean;
|
|
11
13
|
export declare function hasActiveBusiness(): boolean;
|
|
12
14
|
/**
|
|
13
|
-
* Business sync may run only when
|
|
15
|
+
* Business sync may run only when offline sync is enabled for the role,
|
|
16
|
+
* authenticated and a business is selected.
|
|
14
17
|
* Pass an explicit `businessId` to test that specific id; otherwise reads
|
|
15
18
|
* the active business store.
|
|
16
19
|
*/
|
package/dist/sync/sync-guard.js
CHANGED
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { getAuthToken } from "../adapters/auth";
|
|
11
11
|
import { getActiveBusiness } from "../adapters/business";
|
|
12
|
+
// Offline machinery (reference sync, drains, pulls, leases) runs for the
|
|
13
|
+
// seller role only. Fleet managers and riders are fully online: the app
|
|
14
|
+
// disables this flag on role change, which funnels through canBusinessSync
|
|
15
|
+
// and stops every business sync path at once.
|
|
16
|
+
let offlineSyncEnabled = true;
|
|
17
|
+
export function setOfflineSyncEnabled(enabled) {
|
|
18
|
+
offlineSyncEnabled = enabled;
|
|
19
|
+
}
|
|
20
|
+
export function isOfflineSyncEnabled() {
|
|
21
|
+
return offlineSyncEnabled;
|
|
22
|
+
}
|
|
12
23
|
export function isAuthenticated() {
|
|
13
24
|
return !!getAuthToken();
|
|
14
25
|
}
|
|
@@ -16,11 +27,14 @@ export function hasActiveBusiness() {
|
|
|
16
27
|
return !!getActiveBusiness()?.id;
|
|
17
28
|
}
|
|
18
29
|
/**
|
|
19
|
-
* Business sync may run only when
|
|
30
|
+
* Business sync may run only when offline sync is enabled for the role,
|
|
31
|
+
* authenticated and a business is selected.
|
|
20
32
|
* Pass an explicit `businessId` to test that specific id; otherwise reads
|
|
21
33
|
* the active business store.
|
|
22
34
|
*/
|
|
23
35
|
export function canBusinessSync(businessId) {
|
|
36
|
+
if (!offlineSyncEnabled)
|
|
37
|
+
return false;
|
|
24
38
|
const bid = businessId ?? getActiveBusiness()?.id;
|
|
25
39
|
return !!bid && !!getAuthToken();
|
|
26
40
|
}
|
package/package.json
CHANGED