@pol-studios/powersync 1.0.4 → 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.
Files changed (115) hide show
  1. package/dist/CacheSettingsManager-1exbOC6S.d.ts +261 -0
  2. package/dist/attachments/index.d.ts +65 -355
  3. package/dist/attachments/index.js +24 -6
  4. package/dist/{types-Cd7RhNqf.d.ts → background-sync-ChCXW-EV.d.ts} +53 -2
  5. package/dist/chunk-4C3RY5SU.js +204 -0
  6. package/dist/chunk-4C3RY5SU.js.map +1 -0
  7. package/dist/{chunk-3AYXHQ4W.js → chunk-53WH2JJV.js} +111 -47
  8. package/dist/chunk-53WH2JJV.js.map +1 -0
  9. package/dist/chunk-A4IBBWGO.js +377 -0
  10. package/dist/chunk-A4IBBWGO.js.map +1 -0
  11. package/dist/chunk-BREGB4WL.js +1768 -0
  12. package/dist/chunk-BREGB4WL.js.map +1 -0
  13. package/dist/{chunk-EJ23MXPQ.js → chunk-CGL33PL4.js} +3 -1
  14. package/dist/chunk-CGL33PL4.js.map +1 -0
  15. package/dist/chunk-DGUM43GV.js +11 -0
  16. package/dist/chunk-DHYUBVP7.js +131 -0
  17. package/dist/chunk-DHYUBVP7.js.map +1 -0
  18. package/dist/chunk-FV2HXEIY.js +124 -0
  19. package/dist/chunk-FV2HXEIY.js.map +1 -0
  20. package/dist/chunk-GKF7TOMT.js +1 -0
  21. package/dist/{chunk-OTJXIRWX.js → chunk-H772V6XQ.js} +304 -51
  22. package/dist/chunk-H772V6XQ.js.map +1 -0
  23. package/dist/{chunk-C2RSTGDC.js → chunk-HFOFLW5F.js} +525 -87
  24. package/dist/chunk-HFOFLW5F.js.map +1 -0
  25. package/dist/chunk-KGSFAE5B.js +1 -0
  26. package/dist/chunk-LNL64IJZ.js +1 -0
  27. package/dist/chunk-MKD2VCX3.js +32 -0
  28. package/dist/chunk-MKD2VCX3.js.map +1 -0
  29. package/dist/{chunk-7EMDVIZX.js → chunk-N75DEF5J.js} +19 -1
  30. package/dist/chunk-N75DEF5J.js.map +1 -0
  31. package/dist/chunk-P6WOZO7H.js +49 -0
  32. package/dist/chunk-P6WOZO7H.js.map +1 -0
  33. package/dist/chunk-TGBT5XBE.js +1 -0
  34. package/dist/chunk-TGBT5XBE.js.map +1 -0
  35. package/dist/chunk-UEYRTLKE.js +72 -0
  36. package/dist/chunk-UEYRTLKE.js.map +1 -0
  37. package/dist/chunk-WGHNIAF7.js +329 -0
  38. package/dist/chunk-WGHNIAF7.js.map +1 -0
  39. package/dist/chunk-WQ5MPAVC.js +449 -0
  40. package/dist/chunk-WQ5MPAVC.js.map +1 -0
  41. package/dist/{chunk-FPTDATY5.js → chunk-XQAJM2MW.js} +22 -11
  42. package/dist/chunk-XQAJM2MW.js.map +1 -0
  43. package/dist/chunk-YSTEESEG.js +676 -0
  44. package/dist/chunk-YSTEESEG.js.map +1 -0
  45. package/dist/chunk-ZEOKPWUC.js +1165 -0
  46. package/dist/chunk-ZEOKPWUC.js.map +1 -0
  47. package/dist/connector/index.d.ts +182 -2
  48. package/dist/connector/index.js +14 -3
  49. package/dist/core/index.d.ts +5 -3
  50. package/dist/core/index.js +5 -2
  51. package/dist/error/index.d.ts +54 -0
  52. package/dist/error/index.js +8 -0
  53. package/dist/error/index.js.map +1 -0
  54. package/dist/index.d.ts +237 -11
  55. package/dist/index.js +183 -27
  56. package/dist/index.native.d.ts +20 -9
  57. package/dist/index.native.js +183 -28
  58. package/dist/index.web.d.ts +20 -9
  59. package/dist/index.web.js +184 -28
  60. package/dist/maintenance/index.d.ts +118 -0
  61. package/dist/maintenance/index.js +17 -0
  62. package/dist/maintenance/index.js.map +1 -0
  63. package/dist/platform/index.d.ts +16 -1
  64. package/dist/platform/index.js +2 -0
  65. package/dist/platform/index.js.map +1 -1
  66. package/dist/platform/index.native.d.ts +2 -2
  67. package/dist/platform/index.native.js +2 -1
  68. package/dist/platform/index.web.d.ts +1 -1
  69. package/dist/platform/index.web.js +2 -1
  70. package/dist/pol-attachment-queue-C7YNXXhK.d.ts +676 -0
  71. package/dist/provider/index.d.ts +693 -12
  72. package/dist/provider/index.js +57 -12
  73. package/dist/storage/index.d.ts +6 -0
  74. package/dist/storage/index.js +28 -0
  75. package/dist/storage/index.js.map +1 -0
  76. package/dist/storage/index.native.d.ts +6 -0
  77. package/dist/storage/index.native.js +26 -0
  78. package/dist/storage/index.native.js.map +1 -0
  79. package/dist/storage/index.web.d.ts +6 -0
  80. package/dist/storage/index.web.js +26 -0
  81. package/dist/storage/index.web.js.map +1 -0
  82. package/dist/storage/upload/index.d.ts +55 -0
  83. package/dist/storage/upload/index.js +15 -0
  84. package/dist/storage/upload/index.js.map +1 -0
  85. package/dist/storage/upload/index.native.d.ts +57 -0
  86. package/dist/storage/upload/index.native.js +14 -0
  87. package/dist/storage/upload/index.native.js.map +1 -0
  88. package/dist/storage/upload/index.web.d.ts +5 -0
  89. package/dist/storage/upload/index.web.js +14 -0
  90. package/dist/storage/upload/index.web.js.map +1 -0
  91. package/dist/{index-Cb-NI0Ct.d.ts → supabase-connector-qLm-WHkM.d.ts} +146 -10
  92. package/dist/sync/index.d.ts +288 -22
  93. package/dist/sync/index.js +23 -5
  94. package/dist/types-BVacP54t.d.ts +52 -0
  95. package/dist/types-Bgvx7-E8.d.ts +187 -0
  96. package/dist/{types-afHtE1U_.d.ts → types-CDqWh56B.d.ts} +2 -0
  97. package/package.json +72 -2
  98. package/dist/chunk-32OLICZO.js +0 -1
  99. package/dist/chunk-3AYXHQ4W.js.map +0 -1
  100. package/dist/chunk-7EMDVIZX.js.map +0 -1
  101. package/dist/chunk-7JQZBZ5N.js +0 -1
  102. package/dist/chunk-C2RSTGDC.js.map +0 -1
  103. package/dist/chunk-EJ23MXPQ.js.map +0 -1
  104. package/dist/chunk-FPTDATY5.js.map +0 -1
  105. package/dist/chunk-GMFDCVMZ.js +0 -1285
  106. package/dist/chunk-GMFDCVMZ.js.map +0 -1
  107. package/dist/chunk-OLHGI472.js +0 -1
  108. package/dist/chunk-OTJXIRWX.js.map +0 -1
  109. package/dist/chunk-V6LJ6MR2.js +0 -740
  110. package/dist/chunk-V6LJ6MR2.js.map +0 -1
  111. package/dist/chunk-VJCL2SWD.js +0 -1
  112. /package/dist/{chunk-32OLICZO.js.map → chunk-DGUM43GV.js.map} +0 -0
  113. /package/dist/{chunk-7JQZBZ5N.js.map → chunk-GKF7TOMT.js.map} +0 -0
  114. /package/dist/{chunk-OLHGI472.js.map → chunk-KGSFAE5B.js.map} +0 -0
  115. /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 };