@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
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { c as SupabaseStorageOptions, a as StorageBackend, D as DownloadResult, S as SupabaseStorage, d as SupabaseClient } from './types-D0WcHrq6.js';
|
|
2
|
+
import { LoggerAdapter, FileSystemAdapter, AsyncStorageAdapter } from './platform/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Supabase Storage Backend for @pol-studios/powersync
|
|
6
|
+
*
|
|
7
|
+
* Unified storage implementation using Supabase Storage.
|
|
8
|
+
* Handles both web (Blob) and native (file URI) downloads.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createSupabaseStorage } from '@pol-studios/powersync/storage';
|
|
13
|
+
*
|
|
14
|
+
* const storage = createSupabaseStorage({
|
|
15
|
+
* client: supabaseClient,
|
|
16
|
+
* defaultBucket: 'attachments',
|
|
17
|
+
* fileSystem: platform.fileSystem, // Required for native
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Download
|
|
21
|
+
* const result = await storage.download('photos/image.jpg');
|
|
22
|
+
* if (result.type === 'file') {
|
|
23
|
+
* // Native: zero-copy file path
|
|
24
|
+
* console.log('Downloaded to:', result.uri);
|
|
25
|
+
* } else {
|
|
26
|
+
* // Web: Blob in memory
|
|
27
|
+
* console.log('Downloaded blob:', result.data.size, 'bytes');
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Upload with progress
|
|
31
|
+
* await storage.upload('photos/new.jpg', 'file:///local/path.jpg', 'image/jpeg', {
|
|
32
|
+
* onProgress: ({ loaded, total }) => {
|
|
33
|
+
* console.log(`Progress: ${Math.round(loaded / total * 100)}%`);
|
|
34
|
+
* },
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create a Supabase storage backend.
|
|
41
|
+
*
|
|
42
|
+
* @param options - Configuration options
|
|
43
|
+
* @returns StorageBackend implementation
|
|
44
|
+
*/
|
|
45
|
+
declare function createSupabaseStorage(options: SupabaseStorageOptions): StorageBackend;
|
|
46
|
+
/**
|
|
47
|
+
* Type guard to check if download result is a file URI.
|
|
48
|
+
*/
|
|
49
|
+
declare function isFileResult(result: DownloadResult): result is {
|
|
50
|
+
type: 'file';
|
|
51
|
+
uri: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if download result is a blob.
|
|
55
|
+
*/
|
|
56
|
+
declare function isBlobResult(result: DownloadResult): result is {
|
|
57
|
+
type: 'blob';
|
|
58
|
+
data: Blob;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Utilities for detecting storage authentication errors.
|
|
63
|
+
*
|
|
64
|
+
* These utilities help identify when a storage operation failed due to
|
|
65
|
+
* authentication issues (expired tokens, invalid sessions, etc.) that
|
|
66
|
+
* can often be resolved by refreshing the user's session.
|
|
67
|
+
*
|
|
68
|
+
* NOTE: This is a copy of the utility from @pol-studios/db/storage.
|
|
69
|
+
* We maintain a separate copy here to avoid circular dependencies between
|
|
70
|
+
* @pol-studios/powersync and @pol-studios/db.
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* Check if a storage error is an authentication error.
|
|
74
|
+
*
|
|
75
|
+
* These errors can often be fixed by refreshing the session.
|
|
76
|
+
*
|
|
77
|
+
* @param error - The error to check (typically from Supabase Storage operations)
|
|
78
|
+
* @returns true if the error appears to be authentication-related
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const { data, error } = await storage.createSignedUrl(path, 3600);
|
|
83
|
+
* if (error && isStorageAuthError(error)) {
|
|
84
|
+
* await supabase.auth.refreshSession();
|
|
85
|
+
* // Retry the request...
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function isStorageAuthError(error: unknown): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Extract a meaningful error message from a storage error.
|
|
92
|
+
*
|
|
93
|
+
* Supabase Storage errors may have different structures:
|
|
94
|
+
* - Standard Error with `.message` property
|
|
95
|
+
* - StorageError with `.message` and optional `.error` property
|
|
96
|
+
* - Response-like object with `status`, `statusText`, `url` properties
|
|
97
|
+
* - Plain string
|
|
98
|
+
*
|
|
99
|
+
* This function handles all these cases and returns a human-readable message.
|
|
100
|
+
*
|
|
101
|
+
* @param error - The error to extract a message from
|
|
102
|
+
* @returns A human-readable error message
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const { data, error } = await storage.createSignedUrl(path, 3600);
|
|
107
|
+
* if (error) {
|
|
108
|
+
* console.error(getStorageErrorMessage(error));
|
|
109
|
+
* // "Invalid path format" or "Object not found" etc.
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function getStorageErrorMessage(error: unknown): string;
|
|
114
|
+
/**
|
|
115
|
+
* Normalize a storage path by removing leading slashes.
|
|
116
|
+
*
|
|
117
|
+
* Supabase Storage expects paths without leading slashes.
|
|
118
|
+
* This function ensures the path is properly formatted.
|
|
119
|
+
*
|
|
120
|
+
* @param path - The storage path to normalize
|
|
121
|
+
* @returns The normalized path without leading slashes
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* normalizeStoragePath('/foo/bar.jpg'); // 'foo/bar.jpg'
|
|
126
|
+
* normalizeStoragePath('foo/bar.jpg'); // 'foo/bar.jpg'
|
|
127
|
+
* normalizeStoragePath('//foo/bar.jpg'); // 'foo/bar.jpg'
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function normalizeStoragePath(path: string): string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Supabase Storage Adapter for @pol-studios/powersync
|
|
134
|
+
*
|
|
135
|
+
* Implements the unified SupabaseStorage interface for attachment operations.
|
|
136
|
+
* Uses Supabase Storage with platform-agnostic file system operations.
|
|
137
|
+
*
|
|
138
|
+
* Key features:
|
|
139
|
+
* - Memory-efficient downloads using signed URLs + native file system
|
|
140
|
+
* - Multi-bucket support via BucketConfig/BucketResolver
|
|
141
|
+
* - Platform-agnostic via FileSystemAdapter interface
|
|
142
|
+
* - Implements unified SupabaseStorage interface
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Supabase Storage adapter implementing the unified SupabaseStorage interface.
|
|
147
|
+
*
|
|
148
|
+
* Uses PlatformAdapter's fileSystem for I/O operations to remain platform-agnostic.
|
|
149
|
+
*
|
|
150
|
+
* IMPORTANT: This adapter downloads files using signed URLs + platform file system
|
|
151
|
+
* operations to avoid loading entire files into memory. This prevents OOM crashes
|
|
152
|
+
* on large files that occurred with the previous blob-based approach.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const adapter = new SupabaseStorageAdapter(
|
|
157
|
+
* {
|
|
158
|
+
* client: supabaseClient,
|
|
159
|
+
* defaultBucket: 'attachments',
|
|
160
|
+
* bucketMap: new Map([['avatars/', 'user-avatars']]),
|
|
161
|
+
* },
|
|
162
|
+
* platform.fileSystem
|
|
163
|
+
* );
|
|
164
|
+
*
|
|
165
|
+
* // Download returns file:// URI
|
|
166
|
+
* const localUri = await adapter.download('photos/image.jpg');
|
|
167
|
+
*
|
|
168
|
+
* // Upload from local file
|
|
169
|
+
* await adapter.upload('photos/new.jpg', localUri, 'image/jpeg');
|
|
170
|
+
*
|
|
171
|
+
* // Delete from remote storage
|
|
172
|
+
* await adapter.delete('photos/old.jpg');
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* Image transform options for Supabase Storage.
|
|
177
|
+
* Used to compress/resize images on download via Supabase's transform feature.
|
|
178
|
+
*/
|
|
179
|
+
interface ImageTransformOptions {
|
|
180
|
+
/** Enable image transformation (default: true) */
|
|
181
|
+
enabled?: boolean;
|
|
182
|
+
/** Image width in pixels (default: 2048) */
|
|
183
|
+
width?: number;
|
|
184
|
+
/** Image height in pixels (optional, maintains aspect ratio if omitted) */
|
|
185
|
+
height?: number;
|
|
186
|
+
/** Compression quality 1-100 (default: 70) */
|
|
187
|
+
quality?: number;
|
|
188
|
+
/** Output format (default: 'origin' to keep original format) */
|
|
189
|
+
format?: 'origin' | 'avif' | 'webp';
|
|
190
|
+
/** Resize mode (default: 'contain') */
|
|
191
|
+
resize?: 'cover' | 'contain' | 'fill';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Options for SupabaseStorageAdapter constructor.
|
|
195
|
+
*/
|
|
196
|
+
interface SupabaseStorageAdapterOptions {
|
|
197
|
+
client: SupabaseClient;
|
|
198
|
+
defaultBucket: string;
|
|
199
|
+
bucketMap?: Map<string, string>;
|
|
200
|
+
bucketResolver?: (storagePath: string) => string | undefined;
|
|
201
|
+
signedUrlExpiry?: number;
|
|
202
|
+
logger?: LoggerAdapter;
|
|
203
|
+
/** Image transform options for compression on download */
|
|
204
|
+
imageTransform?: ImageTransformOptions;
|
|
205
|
+
}
|
|
206
|
+
declare class SupabaseStorageAdapter implements SupabaseStorage {
|
|
207
|
+
private client;
|
|
208
|
+
private defaultBucket;
|
|
209
|
+
private bucketMap?;
|
|
210
|
+
private bucketResolver?;
|
|
211
|
+
private signedUrlExpiry;
|
|
212
|
+
private fileSystem?;
|
|
213
|
+
private logger?;
|
|
214
|
+
private imageTransform?;
|
|
215
|
+
constructor(options: SupabaseStorageAdapterOptions, fileSystem?: FileSystemAdapter);
|
|
216
|
+
/**
|
|
217
|
+
* Update image transform options (can be set after construction).
|
|
218
|
+
*/
|
|
219
|
+
setImageTransform(options: ImageTransformOptions): void;
|
|
220
|
+
/**
|
|
221
|
+
* Check if a file path is an image that supports transformation.
|
|
222
|
+
*/
|
|
223
|
+
private isTransformableImage;
|
|
224
|
+
/**
|
|
225
|
+
* Set the file system adapter (can be set after construction).
|
|
226
|
+
*/
|
|
227
|
+
setFileSystem(fileSystem: FileSystemAdapter): void;
|
|
228
|
+
/**
|
|
229
|
+
* Resolve the storage bucket for a given file path.
|
|
230
|
+
*/
|
|
231
|
+
resolveBucket(filePath: string): string;
|
|
232
|
+
/**
|
|
233
|
+
* Download a file from Supabase Storage and return as a file:// URI.
|
|
234
|
+
*
|
|
235
|
+
* Uses streaming download to a temp file to avoid loading the entire file
|
|
236
|
+
* into memory. This prevents OOM crashes and FileReader hangs that occur
|
|
237
|
+
* with blob-based downloads in React Native after ~115 downloads.
|
|
238
|
+
*
|
|
239
|
+
* Implements SupabaseStorage.download
|
|
240
|
+
*
|
|
241
|
+
* @param path - Remote storage path
|
|
242
|
+
* @returns file:// URI pointing to the downloaded temp file
|
|
243
|
+
*/
|
|
244
|
+
download(path: string): Promise<string>;
|
|
245
|
+
/**
|
|
246
|
+
* Download a file from Supabase Storage to a specific local path.
|
|
247
|
+
*
|
|
248
|
+
* Uses the platform's streaming downloadFile method to avoid loading
|
|
249
|
+
* the entire file into memory (prevents OOM on large files).
|
|
250
|
+
*
|
|
251
|
+
* @param remotePath - Remote storage path
|
|
252
|
+
* @param localPath - Local file path to write to
|
|
253
|
+
*/
|
|
254
|
+
downloadToPath(remotePath: string, localPath: string): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Upload a local file to Supabase Storage.
|
|
257
|
+
*
|
|
258
|
+
* Implements SupabaseStorage.upload
|
|
259
|
+
*
|
|
260
|
+
* @param path - Remote storage path
|
|
261
|
+
* @param localUri - Local file:// URI to upload from
|
|
262
|
+
* @param mediaType - MIME type of the file
|
|
263
|
+
* @param signal - Optional AbortSignal for cancellation
|
|
264
|
+
*/
|
|
265
|
+
upload(path: string, localUri: string, mediaType: string, signal?: AbortSignal): Promise<void>;
|
|
266
|
+
/**
|
|
267
|
+
* Delete a file from Supabase Storage.
|
|
268
|
+
*
|
|
269
|
+
* Implements SupabaseStorage.delete
|
|
270
|
+
*
|
|
271
|
+
* @param path - Remote storage path to delete
|
|
272
|
+
*/
|
|
273
|
+
delete(path: string): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Get a signed download URL for a remote file.
|
|
276
|
+
*
|
|
277
|
+
* Includes session refresh logic to handle stale tokens during background downloads.
|
|
278
|
+
* If the initial request fails with an auth error (400/401/403), refreshes the session
|
|
279
|
+
* and retries once.
|
|
280
|
+
*/
|
|
281
|
+
getDownloadUrl(remotePath: string): Promise<string>;
|
|
282
|
+
/**
|
|
283
|
+
* Check if a file exists in remote storage.
|
|
284
|
+
*/
|
|
285
|
+
exists(remotePath: string): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Download a file from remote storage.
|
|
288
|
+
* Alias for download() - for backward compatibility with AttachmentStorageAdapter interface.
|
|
289
|
+
*
|
|
290
|
+
* @param filePath - Remote storage path
|
|
291
|
+
* @returns file:// URI pointing to the downloaded temp file
|
|
292
|
+
*/
|
|
293
|
+
downloadFile(filePath: string): Promise<string>;
|
|
294
|
+
/**
|
|
295
|
+
* Write data to a local file.
|
|
296
|
+
*/
|
|
297
|
+
writeFile(fileURI: string, data: string, options?: {
|
|
298
|
+
encoding?: 'utf8' | 'base64';
|
|
299
|
+
}): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Read data from a local file.
|
|
302
|
+
*/
|
|
303
|
+
readFile(fileURI: string, options?: {
|
|
304
|
+
encoding?: 'utf8' | 'base64';
|
|
305
|
+
mediaType?: string;
|
|
306
|
+
}): Promise<ArrayBuffer>;
|
|
307
|
+
/**
|
|
308
|
+
* Delete a local file.
|
|
309
|
+
*/
|
|
310
|
+
deleteFile(uri: string, _options?: {
|
|
311
|
+
filename?: string;
|
|
312
|
+
}): Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Check if a local file exists.
|
|
315
|
+
*/
|
|
316
|
+
fileExists(fileURI: string): Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Create a directory.
|
|
319
|
+
*/
|
|
320
|
+
makeDir(uri: string): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Copy a file.
|
|
323
|
+
*/
|
|
324
|
+
copyFile(sourceUri: string, targetUri: string): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Get the user storage directory.
|
|
327
|
+
*/
|
|
328
|
+
getUserStorageDirectory(): string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Create a SupabaseStorageAdapter with simplified configuration.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* const adapter = createSupabaseStorageAdapter(
|
|
336
|
+
* supabaseClient,
|
|
337
|
+
* 'attachments',
|
|
338
|
+
* platform.fileSystem
|
|
339
|
+
* );
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
declare function createSupabaseStorageAdapter(client: SupabaseClient, defaultBucket: string, fileSystem?: FileSystemAdapter, options?: {
|
|
343
|
+
bucketMap?: Map<string, string>;
|
|
344
|
+
bucketResolver?: (storagePath: string) => string | undefined;
|
|
345
|
+
signedUrlExpiry?: number;
|
|
346
|
+
logger?: LoggerAdapter;
|
|
347
|
+
}): SupabaseStorageAdapter;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Cache Settings Types for @pol-studios/powersync
|
|
351
|
+
*
|
|
352
|
+
* Defines types for cache configuration storage.
|
|
353
|
+
* Note: UI-specific options (labels, descriptions) should be defined in the app.
|
|
354
|
+
*/
|
|
355
|
+
/**
|
|
356
|
+
* Cache settings stored via AsyncStorageAdapter.
|
|
357
|
+
*/
|
|
358
|
+
interface CacheSettings {
|
|
359
|
+
/**
|
|
360
|
+
* Maximum cache size in megabytes.
|
|
361
|
+
* A value of 0 indicates unlimited cache size.
|
|
362
|
+
*/
|
|
363
|
+
maxCacheSizeMb: number;
|
|
364
|
+
/**
|
|
365
|
+
* Compression quality for cached images (0.0 to 1.0).
|
|
366
|
+
* Higher values mean better quality but larger file sizes.
|
|
367
|
+
*/
|
|
368
|
+
compressionQuality: number;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Options for creating a CacheSettingsManager.
|
|
372
|
+
*/
|
|
373
|
+
interface CacheSettingsManagerOptions {
|
|
374
|
+
/**
|
|
375
|
+
* Prefix for storage keys.
|
|
376
|
+
* Useful for namespacing when multiple apps share storage.
|
|
377
|
+
* @default '@pol-studios/cache'
|
|
378
|
+
*/
|
|
379
|
+
storageKeyPrefix?: string;
|
|
380
|
+
/**
|
|
381
|
+
* Default values for cache settings.
|
|
382
|
+
*/
|
|
383
|
+
defaults?: Partial<CacheSettings>;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Default cache settings values.
|
|
387
|
+
*/
|
|
388
|
+
declare const DEFAULT_CACHE_SETTINGS: CacheSettings;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Cache Settings Manager for @pol-studios/powersync
|
|
392
|
+
*
|
|
393
|
+
* Manages persistence of cache settings via AsyncStorageAdapter.
|
|
394
|
+
* Uses platform-agnostic storage interface for cross-platform support.
|
|
395
|
+
*/
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Manages cache settings persistence using AsyncStorageAdapter.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```typescript
|
|
402
|
+
* const manager = new CacheSettingsManager(platform.storage, {
|
|
403
|
+
* storageKeyPrefix: '@myapp/cache',
|
|
404
|
+
* defaults: { maxCacheSizeMb: 2048 },
|
|
405
|
+
* });
|
|
406
|
+
*
|
|
407
|
+
* const settings = await manager.getSettings();
|
|
408
|
+
* await manager.setMaxCacheSizeMb(1024);
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
declare class CacheSettingsManager {
|
|
412
|
+
private storage;
|
|
413
|
+
private keyPrefix;
|
|
414
|
+
private defaults;
|
|
415
|
+
constructor(storage: AsyncStorageAdapter, options?: CacheSettingsManagerOptions);
|
|
416
|
+
/**
|
|
417
|
+
* Get the full storage key for a setting.
|
|
418
|
+
*/
|
|
419
|
+
private getKey;
|
|
420
|
+
/**
|
|
421
|
+
* Get all cache settings.
|
|
422
|
+
*/
|
|
423
|
+
getSettings(): Promise<CacheSettings>;
|
|
424
|
+
/**
|
|
425
|
+
* Get the maximum cache size in megabytes.
|
|
426
|
+
* Returns 0 for unlimited.
|
|
427
|
+
*/
|
|
428
|
+
getMaxCacheSizeMb(): Promise<number>;
|
|
429
|
+
/**
|
|
430
|
+
* Set the maximum cache size in megabytes.
|
|
431
|
+
* Use 0 for unlimited.
|
|
432
|
+
*
|
|
433
|
+
* @param mb - Maximum cache size in megabytes
|
|
434
|
+
*/
|
|
435
|
+
setMaxCacheSizeMb(mb: number): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Get the maximum cache size in bytes.
|
|
438
|
+
* Returns Number.MAX_SAFE_INTEGER for unlimited.
|
|
439
|
+
*/
|
|
440
|
+
getMaxCacheSizeBytes(): Promise<number>;
|
|
441
|
+
/**
|
|
442
|
+
* Get the compression quality (0.0 to 1.0).
|
|
443
|
+
*/
|
|
444
|
+
getCompressionQuality(): Promise<number>;
|
|
445
|
+
/**
|
|
446
|
+
* Set the compression quality.
|
|
447
|
+
*
|
|
448
|
+
* @param quality - Compression quality (0.0 to 1.0)
|
|
449
|
+
*/
|
|
450
|
+
setCompressionQuality(quality: number): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Reset all settings to defaults.
|
|
453
|
+
*/
|
|
454
|
+
resetToDefaults(): Promise<void>;
|
|
455
|
+
/**
|
|
456
|
+
* Clear all stored settings.
|
|
457
|
+
*/
|
|
458
|
+
clear(): Promise<void>;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export { CacheSettingsManager as C, DEFAULT_CACHE_SETTINGS as D, type ImageTransformOptions as I, SupabaseStorageAdapter as S, isBlobResult as a, isStorageAuthError as b, createSupabaseStorage as c, createSupabaseStorageAdapter as d, type SupabaseStorageAdapterOptions as e, type CacheSettings as f, getStorageErrorMessage as g, type CacheSettingsManagerOptions as h, isFileResult as i, normalizeStoragePath as n };
|