@biltme/backend 0.9.0 → 0.11.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 +22 -4
- package/dist/index.d.ts +15 -5
- package/dist/index.js +290 -271
- package/dist/notifications.d.ts +14 -2
- package/dist/platform.d.ts +1 -0
- package/dist/refresh.d.ts +38 -0
- package/package.json +10 -5
package/dist/notifications.d.ts
CHANGED
|
@@ -11,12 +11,20 @@ export type NotificationMessage = {
|
|
|
11
11
|
data?: Record<string, unknown>;
|
|
12
12
|
/** An in-app path such as `/chat/123`, opened on tap. */
|
|
13
13
|
url?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The kind of notification, such as `'New messages'`, at most 64 bytes. A
|
|
16
|
+
* recipient who turned it off gets nothing. On Android it is also the
|
|
17
|
+
* notification channel, which the user sees by this name in system settings.
|
|
18
|
+
*/
|
|
19
|
+
category?: string;
|
|
14
20
|
};
|
|
15
21
|
/**
|
|
16
22
|
* What happened for the recipient. `accepted` means Google or Apple took the
|
|
17
|
-
* notification, not that it arrived.
|
|
23
|
+
* notification, not that it arrived. `opted_out` means the recipient turned
|
|
24
|
+
* the send's category off, and `suspended` that Bilt has stopped push for
|
|
25
|
+
* this app; neither sends anything.
|
|
18
26
|
*/
|
|
19
|
-
export type NotificationOutcome = 'accepted' | 'no_devices' | 'notifications_off' | 'platform_off';
|
|
27
|
+
export type NotificationOutcome = 'accepted' | 'no_devices' | 'notifications_off' | 'platform_off' | 'opted_out' | 'suspended';
|
|
20
28
|
/** A send bilt-cloud refused or never answered, with its error code, such as `rate_limited`. */
|
|
21
29
|
export declare class NotificationsError extends Error {
|
|
22
30
|
readonly status: number;
|
|
@@ -39,6 +47,10 @@ export type NotificationCounts = {
|
|
|
39
47
|
platform_off: number;
|
|
40
48
|
error: number;
|
|
41
49
|
rate_limited: number;
|
|
50
|
+
/** Devices whose user, or the signed-out device itself, turned the send's category off. */
|
|
51
|
+
opted_out: number;
|
|
52
|
+
/** Every device of an app Bilt has stopped push for; then the only nonzero count. */
|
|
53
|
+
suspended: number;
|
|
42
54
|
};
|
|
43
55
|
export type NotificationSendAllResult = {
|
|
44
56
|
data: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isReactNative(): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
type Auth = SupabaseClient<any, any, any>['auth'];
|
|
3
|
+
/** Auth options Bilt adds to supabase-js's. */
|
|
4
|
+
export type BiltAuthOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* How long after the first attempt a session refresh that failed on the
|
|
7
|
+
* network keeps being retried, in milliseconds. `0` tries once. Defaults to
|
|
8
|
+
* 10 000; supabase-js's own is 30 000.
|
|
9
|
+
*/
|
|
10
|
+
refreshRetryWindowMs?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const DEFAULT_REFRESH_RETRY_WINDOW_MS = 10000;
|
|
13
|
+
export declare function refreshRetryWindow(options: BiltAuthOptions | undefined): number;
|
|
14
|
+
/** Read by auth-js's refresh retry check, through patches/@supabase%2Fauth-js@*.patch. */
|
|
15
|
+
export declare function setRefreshRetryWindow(auth: Auth, windowMs: number): void;
|
|
16
|
+
type NetworkState = {
|
|
17
|
+
isConnected?: boolean;
|
|
18
|
+
isInternetReachable?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** The part of `expo-network` used here. */
|
|
21
|
+
export type Network = {
|
|
22
|
+
getNetworkStateAsync(): Promise<NetworkState>;
|
|
23
|
+
addNetworkStateListener(listener: (state: NetworkState) => void): {
|
|
24
|
+
remove(): void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare function loadNetwork(): Promise<Network | undefined>;
|
|
28
|
+
type PauseOptions = {
|
|
29
|
+
autoRefreshToken?: boolean;
|
|
30
|
+
skipAutoInitialize?: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* On React Native with `expo-network` installed, stops the auto-refresh ticker
|
|
34
|
+
* while the device is offline and starts it again, refreshing at once if due,
|
|
35
|
+
* when it comes back.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pauseRefreshWhileOffline(auth: Auth, options: PauseOptions | undefined, load?: () => Promise<Network | undefined>): Promise<void>;
|
|
38
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biltme/backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Bilt backend SDK — thin shim over @supabase/supabase-js for bilt-cloud projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lint:fix": "oxlint --type-aware --type-check --fix src/",
|
|
29
29
|
"format": "oxfmt --write src/",
|
|
30
30
|
"format:check": "oxfmt --check src/",
|
|
31
|
-
"build": "bun build src/index.ts --outdir dist --target node && tsc -p tsconfig.build.json"
|
|
31
|
+
"build": "bun build src/index.ts --outdir dist --target node --external expo-network && tsc -p tsconfig.build.json"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/bun": "latest",
|
|
@@ -39,12 +39,17 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@opentelemetry/api": "^1.9.0",
|
|
42
|
-
"@supabase/supabase-js": "
|
|
42
|
+
"@supabase/supabase-js": "2.110.7"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@react-native-async-storage/async-storage": "^2.0.0"
|
|
45
|
+
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
46
|
+
"expo-network": "*"
|
|
46
47
|
},
|
|
47
48
|
"peerDependenciesMeta": {
|
|
48
|
-
"@react-native-async-storage/async-storage": { "optional": true }
|
|
49
|
+
"@react-native-async-storage/async-storage": { "optional": true },
|
|
50
|
+
"expo-network": { "optional": true }
|
|
51
|
+
},
|
|
52
|
+
"patchedDependencies": {
|
|
53
|
+
"@supabase/auth-js@2.110.7": "patches/@supabase%2Fauth-js@2.110.7.patch"
|
|
49
54
|
}
|
|
50
55
|
}
|