@pol-studios/powersync 1.0.6 → 1.0.7
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/CacheSettingsManager-1exbOC6S.d.ts +261 -0
- package/dist/attachments/index.d.ts +65 -355
- package/dist/attachments/index.js +24 -6
- package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
- package/dist/chunk-4C3RY5SU.js +204 -0
- package/dist/chunk-4C3RY5SU.js.map +1 -0
- package/dist/{chunk-3AYXHQ4W.js → chunk-53WH2JJV.js} +111 -47
- package/dist/chunk-53WH2JJV.js.map +1 -0
- package/dist/chunk-A4IBBWGO.js +377 -0
- package/dist/chunk-A4IBBWGO.js.map +1 -0
- package/dist/chunk-BREGB4WL.js +1768 -0
- package/dist/chunk-BREGB4WL.js.map +1 -0
- package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
- package/dist/chunk-CGL33PL4.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DHYUBVP7.js +131 -0
- package/dist/chunk-DHYUBVP7.js.map +1 -0
- package/dist/chunk-FV2HXEIY.js +124 -0
- package/dist/chunk-FV2HXEIY.js.map +1 -0
- package/dist/chunk-GKF7TOMT.js +1 -0
- package/dist/{chunk-R4YFWQ3Q.js → chunk-H772V6XQ.js} +304 -51
- package/dist/chunk-H772V6XQ.js.map +1 -0
- package/dist/{chunk-62J2DPKX.js → chunk-HFOFLW5F.js} +396 -412
- package/dist/chunk-HFOFLW5F.js.map +1 -0
- package/dist/chunk-KGSFAE5B.js +1 -0
- package/dist/chunk-LNL64IJZ.js +1 -0
- package/dist/chunk-MKD2VCX3.js +32 -0
- package/dist/chunk-MKD2VCX3.js.map +1 -0
- package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
- package/dist/chunk-N75DEF5J.js.map +1 -0
- package/dist/chunk-P6WOZO7H.js +49 -0
- package/dist/chunk-P6WOZO7H.js.map +1 -0
- package/dist/chunk-TGBT5XBE.js +1 -0
- package/dist/chunk-TGBT5XBE.js.map +1 -0
- package/dist/chunk-UEYRTLKE.js +72 -0
- package/dist/chunk-UEYRTLKE.js.map +1 -0
- package/dist/chunk-WGHNIAF7.js +329 -0
- package/dist/chunk-WGHNIAF7.js.map +1 -0
- package/dist/chunk-WQ5MPAVC.js +449 -0
- package/dist/chunk-WQ5MPAVC.js.map +1 -0
- package/dist/{chunk-FPTDATY5.js → chunk-XQAJM2MW.js} +22 -11
- package/dist/chunk-XQAJM2MW.js.map +1 -0
- package/dist/chunk-YSTEESEG.js +676 -0
- package/dist/chunk-YSTEESEG.js.map +1 -0
- package/dist/chunk-ZEOKPWUC.js +1165 -0
- package/dist/chunk-ZEOKPWUC.js.map +1 -0
- package/dist/connector/index.d.ts +182 -3
- package/dist/connector/index.js +12 -4
- package/dist/core/index.d.ts +5 -3
- package/dist/core/index.js +5 -2
- package/dist/error/index.d.ts +54 -0
- package/dist/error/index.js +8 -0
- package/dist/error/index.js.map +1 -0
- package/dist/index.d.ts +100 -12
- package/dist/index.js +148 -38
- package/dist/index.native.d.ts +20 -10
- package/dist/index.native.js +148 -39
- package/dist/index.web.d.ts +20 -10
- package/dist/index.web.js +149 -39
- package/dist/maintenance/index.d.ts +118 -0
- package/dist/maintenance/index.js +17 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/platform/index.d.ts +16 -1
- package/dist/platform/index.js +2 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.d.ts +2 -2
- package/dist/platform/index.native.js +2 -1
- package/dist/platform/index.web.d.ts +1 -1
- package/dist/platform/index.web.js +2 -1
- package/dist/pol-attachment-queue-C7YNXXhK.d.ts +676 -0
- package/dist/provider/index.d.ts +447 -21
- package/dist/provider/index.js +33 -13
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.js +28 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.native.d.ts +6 -0
- package/dist/storage/index.native.js +26 -0
- package/dist/storage/index.native.js.map +1 -0
- package/dist/storage/index.web.d.ts +6 -0
- package/dist/storage/index.web.js +26 -0
- package/dist/storage/index.web.js.map +1 -0
- package/dist/storage/upload/index.d.ts +55 -0
- package/dist/storage/upload/index.js +15 -0
- package/dist/storage/upload/index.js.map +1 -0
- package/dist/storage/upload/index.native.d.ts +57 -0
- package/dist/storage/upload/index.native.js +14 -0
- package/dist/storage/upload/index.native.js.map +1 -0
- package/dist/storage/upload/index.web.d.ts +5 -0
- package/dist/storage/upload/index.web.js +14 -0
- package/dist/storage/upload/index.web.js.map +1 -0
- package/dist/{index-l3iL9Jte.d.ts → supabase-connector-qLm-WHkM.d.ts} +90 -25
- package/dist/sync/index.d.ts +288 -23
- package/dist/sync/index.js +22 -10
- package/dist/types-BVacP54t.d.ts +52 -0
- package/dist/types-Bgvx7-E8.d.ts +187 -0
- package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
- package/package.json +72 -2
- package/dist/chunk-32OLICZO.js +0 -1
- package/dist/chunk-3AYXHQ4W.js.map +0 -1
- package/dist/chunk-5FIMA26D.js +0 -1
- package/dist/chunk-62J2DPKX.js.map +0 -1
- package/dist/chunk-7EMDVIZX.js.map +0 -1
- package/dist/chunk-EJ23MXPQ.js.map +0 -1
- package/dist/chunk-FPTDATY5.js.map +0 -1
- package/dist/chunk-KCDG2MNP.js +0 -1431
- package/dist/chunk-KCDG2MNP.js.map +0 -1
- package/dist/chunk-OLHGI472.js +0 -1
- package/dist/chunk-PAFBKNL3.js +0 -99
- package/dist/chunk-PAFBKNL3.js.map +0 -1
- package/dist/chunk-R4YFWQ3Q.js.map +0 -1
- package/dist/chunk-V6LJ6MR2.js +0 -740
- package/dist/chunk-V6LJ6MR2.js.map +0 -1
- package/dist/chunk-VJCL2SWD.js +0 -1
- package/dist/failed-upload-store-C0cLxxPz.d.ts +0 -33
- /package/dist/{chunk-32OLICZO.js.map → chunk-DGUM43GV.js.map} +0 -0
- /package/dist/{chunk-5FIMA26D.js.map → chunk-GKF7TOMT.js.map} +0 -0
- /package/dist/{chunk-OLHGI472.js.map → chunk-KGSFAE5B.js.map} +0 -0
- /package/dist/{chunk-VJCL2SWD.js.map → chunk-LNL64IJZ.js.map} +0 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { FileSystemAdapter, LoggerAdapter, AsyncStorageAdapter } from './platform/index.js';
|
|
2
|
+
import { R as RemoteStorageAdapter, P as PowerSyncStorageAdapter, b as SupabaseStorageAdapterOptions } from './types-Bgvx7-E8.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Supabase Storage Adapter for @pol-studios/powersync
|
|
6
|
+
*
|
|
7
|
+
* Provides attachment storage operations using Supabase Storage with
|
|
8
|
+
* platform-agnostic file system operations via PlatformAdapter.
|
|
9
|
+
*
|
|
10
|
+
* Key features:
|
|
11
|
+
* - Memory-efficient downloads using signed URLs + native file system
|
|
12
|
+
* - Multi-bucket support via BucketConfig/BucketResolver
|
|
13
|
+
* - Platform-agnostic via FileSystemAdapter interface
|
|
14
|
+
* - Compatible with PowerSync attachments interface
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Supabase Storage adapter for attachment downloads and local file operations.
|
|
19
|
+
*
|
|
20
|
+
* Uses PlatformAdapter's fileSystem for I/O operations to remain platform-agnostic.
|
|
21
|
+
*
|
|
22
|
+
* IMPORTANT: This adapter downloads files using signed URLs + platform file system
|
|
23
|
+
* operations to avoid loading entire files into memory. This prevents OOM crashes
|
|
24
|
+
* on large files that occurred with the previous blob-based approach.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const adapter = new SupabaseStorageAdapter(
|
|
29
|
+
* {
|
|
30
|
+
* client: supabaseClient,
|
|
31
|
+
* bucketConfig: {
|
|
32
|
+
* defaultBucket: 'attachments',
|
|
33
|
+
* bucketMap: new Map([['avatars/', 'user-avatars']]),
|
|
34
|
+
* },
|
|
35
|
+
* },
|
|
36
|
+
* platform.fileSystem
|
|
37
|
+
* );
|
|
38
|
+
*
|
|
39
|
+
* // Download to local path
|
|
40
|
+
* await adapter.download('photos/image.jpg', '/local/path/image.jpg');
|
|
41
|
+
*
|
|
42
|
+
* // Get signed URL for direct access
|
|
43
|
+
* const url = await adapter.getDownloadUrl('photos/image.jpg');
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare class SupabaseStorageAdapter implements RemoteStorageAdapter, PowerSyncStorageAdapter {
|
|
47
|
+
private client;
|
|
48
|
+
private bucketConfig;
|
|
49
|
+
private signedUrlExpiry;
|
|
50
|
+
private fileSystem?;
|
|
51
|
+
private logger?;
|
|
52
|
+
constructor(options: SupabaseStorageAdapterOptions, fileSystem?: FileSystemAdapter);
|
|
53
|
+
/**
|
|
54
|
+
* Set the file system adapter (can be set after construction).
|
|
55
|
+
*/
|
|
56
|
+
setFileSystem(fileSystem: FileSystemAdapter): void;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the storage bucket for a given file path.
|
|
59
|
+
*/
|
|
60
|
+
resolveBucket(filePath: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Download a file from Supabase Storage to a local path.
|
|
63
|
+
*
|
|
64
|
+
* Uses the platform's streaming downloadFile method to avoid loading
|
|
65
|
+
* the entire file into memory (prevents OOM on large files).
|
|
66
|
+
*/
|
|
67
|
+
download(remotePath: string, localPath: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get a signed download URL for a remote file.
|
|
70
|
+
*/
|
|
71
|
+
getDownloadUrl(remotePath: string): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Check if a file exists in remote storage.
|
|
74
|
+
*/
|
|
75
|
+
exists(remotePath: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* No-op for uploads. Use SupabaseUploadHandler for upload operations.
|
|
78
|
+
*
|
|
79
|
+
* Uploads are handled separately by the upload manager pipeline to support
|
|
80
|
+
* background uploads and proper queue management.
|
|
81
|
+
*/
|
|
82
|
+
uploadFile(filename: string, _data: ArrayBuffer, _options?: {
|
|
83
|
+
mediaType?: string;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Download a file from Supabase Storage and return as a Blob.
|
|
87
|
+
*
|
|
88
|
+
* Uses signed URL + fetch to download the file efficiently.
|
|
89
|
+
* This method is required by the PowerSync attachments interface.
|
|
90
|
+
*
|
|
91
|
+
* Note: This loads the file into memory as a Blob. For very large files,
|
|
92
|
+
* consider using download() to save directly to disk instead.
|
|
93
|
+
*/
|
|
94
|
+
downloadFile(filePath: string): Promise<Blob>;
|
|
95
|
+
/**
|
|
96
|
+
* Write data to a local file.
|
|
97
|
+
*/
|
|
98
|
+
writeFile(fileURI: string, data: string, options?: {
|
|
99
|
+
encoding?: 'utf8' | 'base64';
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Read data from a local file.
|
|
103
|
+
*/
|
|
104
|
+
readFile(fileURI: string, options?: {
|
|
105
|
+
encoding?: 'utf8' | 'base64';
|
|
106
|
+
mediaType?: string;
|
|
107
|
+
}): Promise<ArrayBuffer>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete a local file.
|
|
110
|
+
*/
|
|
111
|
+
deleteFile(uri: string, _options?: {
|
|
112
|
+
filename?: string;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Check if a local file exists.
|
|
116
|
+
*/
|
|
117
|
+
fileExists(fileURI: string): Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Create a directory.
|
|
120
|
+
*/
|
|
121
|
+
makeDir(uri: string): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Copy a file.
|
|
124
|
+
*/
|
|
125
|
+
copyFile(sourceUri: string, targetUri: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Get the user storage directory.
|
|
128
|
+
*/
|
|
129
|
+
getUserStorageDirectory(): string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create a SupabaseStorageAdapter with simplified configuration.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const adapter = createSupabaseStorageAdapter(
|
|
137
|
+
* supabaseClient,
|
|
138
|
+
* 'attachments',
|
|
139
|
+
* platform.fileSystem
|
|
140
|
+
* );
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function createSupabaseStorageAdapter(client: any, defaultBucket: string, fileSystem?: FileSystemAdapter, options?: {
|
|
144
|
+
bucketMap?: Map<string, string>;
|
|
145
|
+
signedUrlExpiry?: number;
|
|
146
|
+
logger?: LoggerAdapter;
|
|
147
|
+
}): SupabaseStorageAdapter;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Cache Settings Types for @pol-studios/powersync
|
|
151
|
+
*
|
|
152
|
+
* Defines types for cache configuration storage.
|
|
153
|
+
* Note: UI-specific options (labels, descriptions) should be defined in the app.
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* Cache settings stored via AsyncStorageAdapter.
|
|
157
|
+
*/
|
|
158
|
+
interface CacheSettings {
|
|
159
|
+
/**
|
|
160
|
+
* Maximum cache size in megabytes.
|
|
161
|
+
* A value of 0 indicates unlimited cache size.
|
|
162
|
+
*/
|
|
163
|
+
maxCacheSizeMb: number;
|
|
164
|
+
/**
|
|
165
|
+
* Compression quality for cached images (0.0 to 1.0).
|
|
166
|
+
* Higher values mean better quality but larger file sizes.
|
|
167
|
+
*/
|
|
168
|
+
compressionQuality: number;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for creating a CacheSettingsManager.
|
|
172
|
+
*/
|
|
173
|
+
interface CacheSettingsManagerOptions {
|
|
174
|
+
/**
|
|
175
|
+
* Prefix for storage keys.
|
|
176
|
+
* Useful for namespacing when multiple apps share storage.
|
|
177
|
+
* @default '@pol-studios/cache'
|
|
178
|
+
*/
|
|
179
|
+
storageKeyPrefix?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Default values for cache settings.
|
|
182
|
+
*/
|
|
183
|
+
defaults?: Partial<CacheSettings>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Default cache settings values.
|
|
187
|
+
*/
|
|
188
|
+
declare const DEFAULT_CACHE_SETTINGS: CacheSettings;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Cache Settings Manager for @pol-studios/powersync
|
|
192
|
+
*
|
|
193
|
+
* Manages persistence of cache settings via AsyncStorageAdapter.
|
|
194
|
+
* Uses platform-agnostic storage interface for cross-platform support.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Manages cache settings persistence using AsyncStorageAdapter.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* const manager = new CacheSettingsManager(platform.storage, {
|
|
203
|
+
* storageKeyPrefix: '@myapp/cache',
|
|
204
|
+
* defaults: { maxCacheSizeMb: 2048 },
|
|
205
|
+
* });
|
|
206
|
+
*
|
|
207
|
+
* const settings = await manager.getSettings();
|
|
208
|
+
* await manager.setMaxCacheSizeMb(1024);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
declare class CacheSettingsManager {
|
|
212
|
+
private storage;
|
|
213
|
+
private keyPrefix;
|
|
214
|
+
private defaults;
|
|
215
|
+
constructor(storage: AsyncStorageAdapter, options?: CacheSettingsManagerOptions);
|
|
216
|
+
/**
|
|
217
|
+
* Get the full storage key for a setting.
|
|
218
|
+
*/
|
|
219
|
+
private getKey;
|
|
220
|
+
/**
|
|
221
|
+
* Get all cache settings.
|
|
222
|
+
*/
|
|
223
|
+
getSettings(): Promise<CacheSettings>;
|
|
224
|
+
/**
|
|
225
|
+
* Get the maximum cache size in megabytes.
|
|
226
|
+
* Returns 0 for unlimited.
|
|
227
|
+
*/
|
|
228
|
+
getMaxCacheSizeMb(): Promise<number>;
|
|
229
|
+
/**
|
|
230
|
+
* Set the maximum cache size in megabytes.
|
|
231
|
+
* Use 0 for unlimited.
|
|
232
|
+
*
|
|
233
|
+
* @param mb - Maximum cache size in megabytes
|
|
234
|
+
*/
|
|
235
|
+
setMaxCacheSizeMb(mb: number): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Get the maximum cache size in bytes.
|
|
238
|
+
* Returns Number.MAX_SAFE_INTEGER for unlimited.
|
|
239
|
+
*/
|
|
240
|
+
getMaxCacheSizeBytes(): Promise<number>;
|
|
241
|
+
/**
|
|
242
|
+
* Get the compression quality (0.0 to 1.0).
|
|
243
|
+
*/
|
|
244
|
+
getCompressionQuality(): Promise<number>;
|
|
245
|
+
/**
|
|
246
|
+
* Set the compression quality.
|
|
247
|
+
*
|
|
248
|
+
* @param quality - Compression quality (0.0 to 1.0)
|
|
249
|
+
*/
|
|
250
|
+
setCompressionQuality(quality: number): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Reset all settings to defaults.
|
|
253
|
+
*/
|
|
254
|
+
resetToDefaults(): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Clear all stored settings.
|
|
257
|
+
*/
|
|
258
|
+
clear(): Promise<void>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { CacheSettingsManager as C, DEFAULT_CACHE_SETTINGS as D, SupabaseStorageAdapter as S, type CacheSettings as a, type CacheSettingsManagerOptions as b, createSupabaseStorageAdapter as c };
|