@pol-studios/powersync 1.0.7 → 1.0.10
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 +933 -0
- package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
- package/dist/attachments/index.d.ts +709 -6
- package/dist/attachments/index.js +133 -5
- package/dist/chunk-24RDMMCL.js +44 -0
- package/dist/chunk-24RDMMCL.js.map +1 -0
- package/dist/chunk-4TXTAEF2.js +2060 -0
- package/dist/chunk-4TXTAEF2.js.map +1 -0
- package/dist/chunk-63PXSPIN.js +358 -0
- package/dist/chunk-63PXSPIN.js.map +1 -0
- package/dist/chunk-654ERHA7.js +1 -0
- package/dist/{chunk-BREGB4WL.js → chunk-BRXQNASY.js} +287 -335
- package/dist/chunk-BRXQNASY.js.map +1 -0
- package/dist/{chunk-DHYUBVP7.js → chunk-CAB26E6F.js} +20 -9
- package/dist/chunk-CAB26E6F.js.map +1 -0
- package/dist/{chunk-H772V6XQ.js → chunk-CUCAYK7Z.js} +7 -43
- package/dist/chunk-CUCAYK7Z.js.map +1 -0
- package/dist/{chunk-4C3RY5SU.js → chunk-HWSNV45P.js} +76 -1
- package/dist/chunk-HWSNV45P.js.map +1 -0
- package/dist/{chunk-HFOFLW5F.js → chunk-KN2IZERF.js} +139 -6
- package/dist/chunk-KN2IZERF.js.map +1 -0
- package/dist/{chunk-UEYRTLKE.js → chunk-P4HZA6ZT.js} +20 -9
- package/dist/chunk-P4HZA6ZT.js.map +1 -0
- package/dist/chunk-T4AO7JIG.js +1 -0
- package/dist/{chunk-XQAJM2MW.js → chunk-VACPAAQZ.js} +33 -2
- package/dist/{chunk-XQAJM2MW.js.map → chunk-VACPAAQZ.js.map} +1 -1
- package/dist/{chunk-53WH2JJV.js → chunk-WN5ZJ3E2.js} +5 -8
- package/dist/chunk-WN5ZJ3E2.js.map +1 -0
- package/dist/chunk-XAEII4ZX.js +456 -0
- package/dist/chunk-XAEII4ZX.js.map +1 -0
- package/dist/chunk-XOY2CJ67.js +289 -0
- package/dist/chunk-XOY2CJ67.js.map +1 -0
- package/dist/chunk-YHTZ7VMV.js +1 -0
- package/dist/{chunk-MKD2VCX3.js → chunk-Z6VOBGTU.js} +8 -8
- package/dist/chunk-Z6VOBGTU.js.map +1 -0
- package/dist/chunk-ZM4ENYMF.js +230 -0
- package/dist/chunk-ZM4ENYMF.js.map +1 -0
- package/dist/connector/index.d.ts +56 -3
- package/dist/connector/index.js +8 -5
- package/dist/core/index.d.ts +12 -1
- package/dist/core/index.js +3 -2
- package/dist/error/index.js +0 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.js +191 -29
- package/dist/index.native.d.ts +11 -9
- package/dist/index.native.js +191 -29
- package/dist/index.web.d.ts +11 -9
- package/dist/index.web.js +191 -29
- package/dist/maintenance/index.js +0 -1
- package/dist/platform/index.js +0 -2
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.js +1 -2
- package/dist/platform/index.web.js +0 -1
- package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
- package/dist/provider/index.d.ts +38 -34
- package/dist/provider/index.js +11 -12
- package/dist/react/index.d.ts +372 -0
- package/dist/react/index.js +25 -0
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +22 -8
- package/dist/storage/index.native.d.ts +3 -3
- package/dist/storage/index.native.js +21 -7
- package/dist/storage/index.web.d.ts +3 -3
- package/dist/storage/index.web.js +21 -7
- package/dist/storage/upload/index.d.ts +7 -8
- package/dist/storage/upload/index.js +3 -3
- package/dist/storage/upload/index.native.d.ts +7 -8
- package/dist/storage/upload/index.native.js +4 -3
- package/dist/storage/upload/index.web.d.ts +1 -4
- package/dist/storage/upload/index.web.js +3 -3
- package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
- package/dist/sync/index.js +3 -3
- package/dist/{supabase-connector-qLm-WHkM.d.ts → types-B212hgfA.d.ts} +48 -170
- package/dist/{types-BVacP54t.d.ts → types-CyvBaAl8.d.ts} +12 -4
- package/dist/types-D0WcHrq6.d.ts +234 -0
- package/package.json +18 -4
- package/dist/CacheSettingsManager-1exbOC6S.d.ts +0 -261
- package/dist/chunk-4C3RY5SU.js.map +0 -1
- package/dist/chunk-53WH2JJV.js.map +0 -1
- package/dist/chunk-BREGB4WL.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DHYUBVP7.js.map +0 -1
- package/dist/chunk-GKF7TOMT.js +0 -1
- package/dist/chunk-H772V6XQ.js.map +0 -1
- package/dist/chunk-HFOFLW5F.js.map +0 -1
- package/dist/chunk-KGSFAE5B.js +0 -1
- package/dist/chunk-LNL64IJZ.js +0 -1
- package/dist/chunk-MKD2VCX3.js.map +0 -1
- package/dist/chunk-UEYRTLKE.js.map +0 -1
- package/dist/chunk-WQ5MPAVC.js +0 -449
- package/dist/chunk-WQ5MPAVC.js.map +0 -1
- package/dist/chunk-ZEOKPWUC.js +0 -1165
- package/dist/chunk-ZEOKPWUC.js.map +0 -1
- package/dist/pol-attachment-queue-C7YNXXhK.d.ts +0 -676
- package/dist/types-Bgvx7-E8.d.ts +0 -187
- /package/dist/{chunk-DGUM43GV.js.map → chunk-654ERHA7.js.map} +0 -0
- /package/dist/{chunk-GKF7TOMT.js.map → chunk-T4AO7JIG.js.map} +0 -0
- /package/dist/{chunk-KGSFAE5B.js.map → chunk-YHTZ7VMV.js.map} +0 -0
- /package/dist/{chunk-LNL64IJZ.js.map → react/index.js.map} +0 -0
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SupabaseUploadHandler,
|
|
3
3
|
createSupabaseUploadHandler
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-CAB26E6F.js";
|
|
5
5
|
import {
|
|
6
6
|
CacheSettingsManager,
|
|
7
7
|
DEFAULT_CACHE_SETTINGS,
|
|
8
|
+
createSupabaseStorage,
|
|
9
|
+
isBlobResult,
|
|
10
|
+
isFileResult
|
|
11
|
+
} from "../chunk-XOY2CJ67.js";
|
|
12
|
+
import {
|
|
8
13
|
SupabaseStorageAdapter,
|
|
9
|
-
createSupabaseStorageAdapter
|
|
10
|
-
|
|
14
|
+
createSupabaseStorageAdapter,
|
|
15
|
+
getStorageErrorMessage,
|
|
16
|
+
isStorageAuthError,
|
|
17
|
+
normalizeStoragePath
|
|
18
|
+
} from "../chunk-XAEII4ZX.js";
|
|
11
19
|
import {
|
|
12
20
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
13
|
-
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-
|
|
21
|
+
resolveBucket
|
|
22
|
+
} from "../chunk-Z6VOBGTU.js";
|
|
23
|
+
import "../chunk-FV2HXEIY.js";
|
|
16
24
|
export {
|
|
17
25
|
CacheSettingsManager,
|
|
18
26
|
DEFAULT_CACHE_SETTINGS,
|
|
19
27
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
20
28
|
SupabaseStorageAdapter,
|
|
21
29
|
SupabaseUploadHandler,
|
|
30
|
+
createSupabaseStorage,
|
|
22
31
|
createSupabaseStorageAdapter,
|
|
23
32
|
createSupabaseUploadHandler,
|
|
24
|
-
|
|
33
|
+
getStorageErrorMessage,
|
|
34
|
+
isBlobResult,
|
|
35
|
+
isFileResult,
|
|
36
|
+
isStorageAuthError,
|
|
37
|
+
normalizeStoragePath,
|
|
38
|
+
resolveBucket
|
|
25
39
|
};
|
|
26
40
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-
|
|
1
|
+
export { D as DownloadResult, a as StorageBackend, b as StorageUploadOptions, d as SupabaseClient, S as SupabaseStorage, c as SupabaseStorageOptions, U as UploadProgress, r as resolveBucket } from '../types-D0WcHrq6.js';
|
|
2
|
+
export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManagerOptions, D as DEFAULT_CACHE_SETTINGS, S as SupabaseStorageAdapter, c as createSupabaseStorage, d as createSupabaseStorageAdapter, g as getStorageErrorMessage, a as isBlobResult, i as isFileResult, b as isStorageAuthError, n as normalizeStoragePath } from '../CacheSettingsManager-uz-kbnRH.js';
|
|
3
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../types-CyvBaAl8.js';
|
|
4
4
|
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './upload/index.js';
|
|
5
5
|
import '../platform/index.js';
|
|
6
6
|
import '../types-CDqWh56B.js';
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CacheSettingsManager,
|
|
3
3
|
DEFAULT_CACHE_SETTINGS,
|
|
4
|
+
createSupabaseStorage,
|
|
5
|
+
isBlobResult,
|
|
6
|
+
isFileResult
|
|
7
|
+
} from "../chunk-XOY2CJ67.js";
|
|
8
|
+
import {
|
|
4
9
|
SupabaseStorageAdapter,
|
|
5
|
-
createSupabaseStorageAdapter
|
|
6
|
-
|
|
10
|
+
createSupabaseStorageAdapter,
|
|
11
|
+
getStorageErrorMessage,
|
|
12
|
+
isStorageAuthError,
|
|
13
|
+
normalizeStoragePath
|
|
14
|
+
} from "../chunk-XAEII4ZX.js";
|
|
7
15
|
import {
|
|
8
16
|
SupabaseUploadHandler,
|
|
9
17
|
createSupabaseUploadHandler
|
|
10
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-P4HZA6ZT.js";
|
|
11
19
|
import {
|
|
12
20
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
13
|
-
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-
|
|
21
|
+
resolveBucket
|
|
22
|
+
} from "../chunk-Z6VOBGTU.js";
|
|
23
|
+
import "../chunk-FV2HXEIY.js";
|
|
16
24
|
export {
|
|
17
25
|
CacheSettingsManager,
|
|
18
26
|
DEFAULT_CACHE_SETTINGS,
|
|
19
27
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
20
28
|
SupabaseStorageAdapter,
|
|
21
29
|
SupabaseUploadHandler,
|
|
30
|
+
createSupabaseStorage,
|
|
22
31
|
createSupabaseStorageAdapter,
|
|
23
32
|
createSupabaseUploadHandler,
|
|
24
|
-
|
|
33
|
+
getStorageErrorMessage,
|
|
34
|
+
isBlobResult,
|
|
35
|
+
isFileResult,
|
|
36
|
+
isStorageAuthError,
|
|
37
|
+
normalizeStoragePath,
|
|
38
|
+
resolveBucket
|
|
25
39
|
};
|
|
26
40
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { S as SupabaseUploadHandlerOptions } from '../../types-
|
|
2
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-
|
|
3
|
-
import { S as StorageUploadHandler, a as BucketConfig } from '../../types-Bgvx7-E8.js';
|
|
4
|
-
import '../../platform/index.js';
|
|
5
|
-
import '../../types-CDqWh56B.js';
|
|
1
|
+
import { S as SupabaseUploadHandlerOptions, B as BucketConfig } from '../../types-CyvBaAl8.js';
|
|
2
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-CyvBaAl8.js';
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Supabase Upload Handler for Web
|
|
@@ -33,9 +30,11 @@ import '../../types-CDqWh56B.js';
|
|
|
33
30
|
* );
|
|
34
31
|
* ```
|
|
35
32
|
*/
|
|
36
|
-
declare class SupabaseUploadHandler
|
|
33
|
+
declare class SupabaseUploadHandler {
|
|
37
34
|
private supabase;
|
|
38
|
-
private
|
|
35
|
+
private defaultBucket;
|
|
36
|
+
private bucketMap?;
|
|
37
|
+
private bucketResolver?;
|
|
39
38
|
constructor(options: SupabaseUploadHandlerOptions);
|
|
40
39
|
/**
|
|
41
40
|
* Upload a file to Supabase Storage using fetch.
|
|
@@ -52,4 +51,4 @@ declare class SupabaseUploadHandler implements StorageUploadHandler {
|
|
|
52
51
|
*/
|
|
53
52
|
declare function createSupabaseUploadHandler(supabaseClient: any, bucketConfig: BucketConfig): SupabaseUploadHandler;
|
|
54
53
|
|
|
55
|
-
export { SupabaseUploadHandler, SupabaseUploadHandlerOptions, createSupabaseUploadHandler };
|
|
54
|
+
export { BucketConfig, SupabaseUploadHandler, SupabaseUploadHandlerOptions, createSupabaseUploadHandler };
|
|
@@ -2,11 +2,11 @@ import "../../chunk-TGBT5XBE.js";
|
|
|
2
2
|
import {
|
|
3
3
|
SupabaseUploadHandler,
|
|
4
4
|
createSupabaseUploadHandler
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-P4HZA6ZT.js";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_UPLOAD_NOTIFICATION
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-Z6VOBGTU.js";
|
|
9
|
+
import "../../chunk-FV2HXEIY.js";
|
|
10
10
|
export {
|
|
11
11
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
12
12
|
SupabaseUploadHandler,
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { S as SupabaseUploadHandlerOptions, a as UploadNotificationConfig } from '../../types-
|
|
2
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers } from '../../types-
|
|
3
|
-
import { S as StorageUploadHandler, a as BucketConfig } from '../../types-Bgvx7-E8.js';
|
|
4
|
-
import '../../platform/index.js';
|
|
5
|
-
import '../../types-CDqWh56B.js';
|
|
1
|
+
import { S as SupabaseUploadHandlerOptions, a as UploadNotificationConfig, B as BucketConfig } from '../../types-CyvBaAl8.js';
|
|
2
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, U as UploadEventHandlers } from '../../types-CyvBaAl8.js';
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* Supabase Upload Handler for React Native
|
|
@@ -34,9 +31,11 @@ import '../../types-CDqWh56B.js';
|
|
|
34
31
|
* );
|
|
35
32
|
* ```
|
|
36
33
|
*/
|
|
37
|
-
declare class SupabaseUploadHandler
|
|
34
|
+
declare class SupabaseUploadHandler {
|
|
38
35
|
private supabase;
|
|
39
|
-
private
|
|
36
|
+
private defaultBucket;
|
|
37
|
+
private bucketMap?;
|
|
38
|
+
private bucketResolver?;
|
|
40
39
|
private notificationConfig;
|
|
41
40
|
constructor(options: SupabaseUploadHandlerOptions, notificationConfig?: Partial<UploadNotificationConfig>);
|
|
42
41
|
/**
|
|
@@ -54,4 +53,4 @@ declare class SupabaseUploadHandler implements StorageUploadHandler {
|
|
|
54
53
|
*/
|
|
55
54
|
declare function createSupabaseUploadHandler(supabaseClient: any, bucketConfig: BucketConfig, notificationConfig?: Partial<UploadNotificationConfig>): SupabaseUploadHandler;
|
|
56
55
|
|
|
57
|
-
export { SupabaseUploadHandler, SupabaseUploadHandlerOptions, UploadNotificationConfig, createSupabaseUploadHandler };
|
|
56
|
+
export { BucketConfig, SupabaseUploadHandler, SupabaseUploadHandlerOptions, UploadNotificationConfig, createSupabaseUploadHandler };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import "../../chunk-YHTZ7VMV.js";
|
|
1
2
|
import {
|
|
2
3
|
SupabaseUploadHandler,
|
|
3
4
|
createSupabaseUploadHandler
|
|
4
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-CAB26E6F.js";
|
|
5
6
|
import {
|
|
6
7
|
DEFAULT_UPLOAD_NOTIFICATION
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-Z6VOBGTU.js";
|
|
9
|
+
import "../../chunk-FV2HXEIY.js";
|
|
9
10
|
export {
|
|
10
11
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
11
12
|
SupabaseUploadHandler,
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-
|
|
1
|
+
export { B as BucketConfig, D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from '../../types-CyvBaAl8.js';
|
|
2
2
|
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './index.js';
|
|
3
|
-
import '../../types-Bgvx7-E8.js';
|
|
4
|
-
import '../../platform/index.js';
|
|
5
|
-
import '../../types-CDqWh56B.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SupabaseUploadHandler,
|
|
3
3
|
createSupabaseUploadHandler
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-P4HZA6ZT.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_UPLOAD_NOTIFICATION
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-Z6VOBGTU.js";
|
|
8
|
+
import "../../chunk-FV2HXEIY.js";
|
|
9
9
|
export {
|
|
10
10
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
11
11
|
SupabaseUploadHandler,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { P as PowerSyncBackendConnector, A as AbstractPowerSyncDatabase } from './types-CDqWh56B.js';
|
|
2
|
+
import { S as SupabaseConnectorOptions, P as PowerSyncCredentials } from './types-B212hgfA.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Supabase Connector for PowerSync
|
|
6
|
+
*
|
|
7
|
+
* A generic, configurable connector that handles:
|
|
8
|
+
* - Authentication with Supabase JWT tokens
|
|
9
|
+
* - Uploading local changes back to Supabase
|
|
10
|
+
* - Schema routing for multi-schema databases
|
|
11
|
+
* - Custom CRUD handling for complex operations
|
|
12
|
+
* - Version-based conflict detection (when enabled)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generic Supabase connector for PowerSync.
|
|
17
|
+
*
|
|
18
|
+
* This connector handles authentication and CRUD uploads to Supabase.
|
|
19
|
+
* It supports configurable schema routing and custom CRUD handlers
|
|
20
|
+
* for complex use cases.
|
|
21
|
+
*
|
|
22
|
+
* @example Basic usage
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const connector = new SupabaseConnector({
|
|
25
|
+
* supabaseClient: supabase,
|
|
26
|
+
* powerSyncUrl: 'https://your-powersync-instance.com',
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example With schema routing
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const connector = new SupabaseConnector({
|
|
33
|
+
* supabaseClient: supabase,
|
|
34
|
+
* powerSyncUrl: 'https://your-powersync-instance.com',
|
|
35
|
+
* schemaRouter: (table) => {
|
|
36
|
+
* if (['Profile', 'Comment', 'CommentSection'].includes(table)) {
|
|
37
|
+
* return 'core';
|
|
38
|
+
* }
|
|
39
|
+
* return 'public';
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example With custom CRUD handler
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const connector = new SupabaseConnector({
|
|
47
|
+
* supabaseClient: supabase,
|
|
48
|
+
* powerSyncUrl: 'https://your-powersync-instance.com',
|
|
49
|
+
* crudHandler: {
|
|
50
|
+
* async handlePut(entry, supabase, schema) {
|
|
51
|
+
* // Custom handling for specific tables
|
|
52
|
+
* if (entry.table === 'SpecialTable') {
|
|
53
|
+
* await myCustomUpsert(entry);
|
|
54
|
+
* return true; // Handled
|
|
55
|
+
* }
|
|
56
|
+
* return false; // Use default
|
|
57
|
+
* },
|
|
58
|
+
* },
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare class SupabaseConnector implements PowerSyncBackendConnector {
|
|
63
|
+
private readonly supabase;
|
|
64
|
+
private readonly powerSyncUrl;
|
|
65
|
+
private readonly schemaRouter;
|
|
66
|
+
private readonly crudHandler?;
|
|
67
|
+
private readonly logger?;
|
|
68
|
+
private readonly onTransactionSuccess?;
|
|
69
|
+
private readonly onTransactionFailure?;
|
|
70
|
+
private readonly onTransactionComplete?;
|
|
71
|
+
private readonly shouldUploadFn?;
|
|
72
|
+
private readonly conflictDetection?;
|
|
73
|
+
private readonly conflictHandler?;
|
|
74
|
+
private readonly conflictBus?;
|
|
75
|
+
private versionColumnCache;
|
|
76
|
+
private activeProjectIds;
|
|
77
|
+
private resolvedConflicts;
|
|
78
|
+
private unsubscribeResolution?;
|
|
79
|
+
private versionColumnPromises;
|
|
80
|
+
private isDestroyed;
|
|
81
|
+
private retryConfig;
|
|
82
|
+
private completionFailures;
|
|
83
|
+
private static readonly COMPLETION_MAX_FAILURES;
|
|
84
|
+
private static readonly COMPLETION_EXTENDED_TIMEOUT_MS;
|
|
85
|
+
private autoRetryPaused;
|
|
86
|
+
private entryCooldowns;
|
|
87
|
+
private static readonly COOLDOWN_DURATION_MS;
|
|
88
|
+
constructor(options: SupabaseConnectorOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Clean up resources (unsubscribe from event listeners).
|
|
91
|
+
* Call this when the connector is no longer needed.
|
|
92
|
+
*/
|
|
93
|
+
destroy(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Generate a fingerprint for a set of entries to track completion failures.
|
|
96
|
+
* Uses sorted entry IDs to create a consistent fingerprint regardless of order.
|
|
97
|
+
*/
|
|
98
|
+
private generateTransactionFingerprint;
|
|
99
|
+
/**
|
|
100
|
+
* Pause automatic retry of failed uploads.
|
|
101
|
+
* Use this when the user goes offline intentionally or wants manual control.
|
|
102
|
+
*/
|
|
103
|
+
pauseAutoRetry(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Resume automatic retry of failed uploads.
|
|
106
|
+
*/
|
|
107
|
+
resumeAutoRetry(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Process a single CRUD entry with exponential backoff retry.
|
|
110
|
+
*
|
|
111
|
+
* This method uses a two-phase approach:
|
|
112
|
+
* 1. First attempt - try the operation to classify the error type
|
|
113
|
+
* 2. Retry phase - use the appropriate config (transient vs permanent) based on classification
|
|
114
|
+
*
|
|
115
|
+
* This fixes the issue where reassigning selectedConfig inside withExponentialBackoff's
|
|
116
|
+
* callback had no effect because the config was already destructured at call time.
|
|
117
|
+
*
|
|
118
|
+
* @param entry - The CRUD entry to process
|
|
119
|
+
* @throws Error if all retries exhausted (for critical failures)
|
|
120
|
+
*/
|
|
121
|
+
private processWithRetry;
|
|
122
|
+
/**
|
|
123
|
+
* Set the active project IDs for scoped sync.
|
|
124
|
+
* Call this when user selects/opens projects.
|
|
125
|
+
*/
|
|
126
|
+
setActiveProjectIds(projectIds: string[]): void;
|
|
127
|
+
/**
|
|
128
|
+
* Get the current active project IDs.
|
|
129
|
+
*/
|
|
130
|
+
getActiveProjectIds(): string[];
|
|
131
|
+
/**
|
|
132
|
+
* Get credentials for PowerSync connection.
|
|
133
|
+
* Uses Supabase session token.
|
|
134
|
+
*
|
|
135
|
+
* Note: Token refresh is handled by Supabase's startAutoRefresh() which must be
|
|
136
|
+
* called on app initialization. getSession() returns the auto-refreshed token.
|
|
137
|
+
*/
|
|
138
|
+
fetchCredentials(): Promise<PowerSyncCredentials>;
|
|
139
|
+
/**
|
|
140
|
+
* Upload local changes to Supabase.
|
|
141
|
+
* Called automatically by PowerSync when there are pending uploads.
|
|
142
|
+
*
|
|
143
|
+
* When conflict detection is enabled:
|
|
144
|
+
* 1. Checks if table has _version column (cached)
|
|
145
|
+
* 2. If yes, compares local vs server version
|
|
146
|
+
* 3. On version mismatch, queries AuditLog for field conflicts
|
|
147
|
+
* 4. If conflicts found, calls handler or publishes to conflict bus
|
|
148
|
+
* 5. Applies resolution or skips entry based on handler response
|
|
149
|
+
*/
|
|
150
|
+
uploadData(database: AbstractPowerSyncDatabase): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Finalize a transaction by completing it after all entries processed successfully.
|
|
153
|
+
* Extracted to eliminate duplication between uploadData and processTransaction.
|
|
154
|
+
*
|
|
155
|
+
* Implements circuit breaker logic for completion failures:
|
|
156
|
+
* - On first failure: retry once with extended timeout (60s)
|
|
157
|
+
* - After 3 failures for same entries: log and return without throwing
|
|
158
|
+
* (data is safely in Supabase via idempotent upserts, preventing infinite retry loop)
|
|
159
|
+
*
|
|
160
|
+
* @param context - The finalization context containing results and transaction
|
|
161
|
+
*/
|
|
162
|
+
private finalizeTransaction;
|
|
163
|
+
/**
|
|
164
|
+
* Process a transaction without conflict detection.
|
|
165
|
+
* Uses batched operations for PUT and DELETE, individual processing for PATCH.
|
|
166
|
+
*/
|
|
167
|
+
private processTransaction;
|
|
168
|
+
/**
|
|
169
|
+
* Process batched PUT (upsert) operations for a single table.
|
|
170
|
+
* Falls back to individual processing if batch fails.
|
|
171
|
+
* CRITICAL: Throws on first failure to maintain transaction atomicity.
|
|
172
|
+
* @returns Array of successfully processed entries
|
|
173
|
+
* @throws Error on first failure - keeps entire transaction in ps_crud
|
|
174
|
+
*/
|
|
175
|
+
private processBatchedPuts;
|
|
176
|
+
/**
|
|
177
|
+
* Process batched DELETE operations for a single table.
|
|
178
|
+
* Falls back to individual processing if batch fails.
|
|
179
|
+
* CRITICAL: Throws on first failure to maintain transaction atomicity.
|
|
180
|
+
* @returns Array of successfully processed entries
|
|
181
|
+
* @throws Error on first failure - keeps entire transaction in ps_crud
|
|
182
|
+
*/
|
|
183
|
+
private processBatchedDeletes;
|
|
184
|
+
/**
|
|
185
|
+
* Check if a table has a _version column (cached).
|
|
186
|
+
* P4.1: Uses Promise-based locking to prevent duplicate concurrent queries.
|
|
187
|
+
*/
|
|
188
|
+
private checkVersionColumn;
|
|
189
|
+
/**
|
|
190
|
+
* Filter opData to only include specified fields.
|
|
191
|
+
* Used for partial sync resolution.
|
|
192
|
+
*/
|
|
193
|
+
private filterFields;
|
|
194
|
+
/**
|
|
195
|
+
* Process a single CRUD operation.
|
|
196
|
+
*
|
|
197
|
+
* All synced tables use `id` as their UUID primary key column.
|
|
198
|
+
*/
|
|
199
|
+
private processCrudEntry;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { SupabaseConnector as S };
|
package/dist/sync/index.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
HealthMonitor,
|
|
13
13
|
MetricsCollector,
|
|
14
14
|
SyncStatusTracker
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-CUCAYK7Z.js";
|
|
16
|
+
import "../chunk-24RDMMCL.js";
|
|
16
17
|
import "../chunk-CGL33PL4.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-DGUM43GV.js";
|
|
18
|
+
import "../chunk-VACPAAQZ.js";
|
|
19
19
|
export {
|
|
20
20
|
DeadLetterQueue,
|
|
21
21
|
HealthMonitor,
|