@pol-studios/db 1.0.9 → 1.0.11

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 (113) hide show
  1. package/dist/DataLayerContext-CL6alnkb.d.ts +755 -0
  2. package/dist/UserMetadataContext-B8gVWGMl.d.ts +35 -0
  3. package/dist/UserMetadataContext-DntmpK41.d.ts +33 -0
  4. package/dist/auth/context.d.ts +3 -2
  5. package/dist/auth/context.js +22 -12786
  6. package/dist/auth/context.js.map +1 -1
  7. package/dist/auth/guards.js +12 -7640
  8. package/dist/auth/guards.js.map +1 -1
  9. package/dist/auth/hooks.d.ts +3 -3
  10. package/dist/auth/hooks.js +26 -10591
  11. package/dist/auth/hooks.js.map +1 -1
  12. package/dist/auth/index.d.ts +3 -2
  13. package/dist/auth/index.js +45 -13008
  14. package/dist/auth/index.js.map +1 -1
  15. package/dist/{canvas-UVNDA54X.node → canvas-C4TBBDUL.node} +0 -0
  16. package/dist/canvas-ZQNCL7JL.js +1541 -0
  17. package/dist/canvas-ZQNCL7JL.js.map +1 -0
  18. package/dist/chunk-3PJTNH2L.js +2778 -0
  19. package/dist/chunk-3PJTNH2L.js.map +1 -0
  20. package/dist/chunk-5EFDS7SR.js +205 -0
  21. package/dist/chunk-5EFDS7SR.js.map +1 -0
  22. package/dist/chunk-7SCJNYTE.js +1459 -0
  23. package/dist/chunk-7SCJNYTE.js.map +1 -0
  24. package/dist/chunk-DJ6VLEAL.js +247 -0
  25. package/dist/chunk-DJ6VLEAL.js.map +1 -0
  26. package/dist/chunk-GC3TBUWE.js +14 -0
  27. package/dist/chunk-GC3TBUWE.js.map +1 -0
  28. package/dist/chunk-H3LNH2NT.js +611 -0
  29. package/dist/chunk-H3LNH2NT.js.map +1 -0
  30. package/dist/chunk-H6365JPC.js +1858 -0
  31. package/dist/chunk-H6365JPC.js.map +1 -0
  32. package/dist/chunk-HAWJTZCK.js +86 -0
  33. package/dist/chunk-HAWJTZCK.js.map +1 -0
  34. package/dist/chunk-J4ZVCXZ4.js +1 -0
  35. package/dist/chunk-J4ZVCXZ4.js.map +1 -0
  36. package/dist/chunk-JAATANS3.js +429 -0
  37. package/dist/chunk-JAATANS3.js.map +1 -0
  38. package/dist/chunk-LNJ3WF7V.js +470 -0
  39. package/dist/chunk-LNJ3WF7V.js.map +1 -0
  40. package/dist/chunk-N26IEHZT.js +79 -0
  41. package/dist/chunk-N26IEHZT.js.map +1 -0
  42. package/dist/chunk-NSIAAYW3.js +1 -0
  43. package/dist/chunk-NSIAAYW3.js.map +1 -0
  44. package/dist/chunk-NZON56CB.js +3864 -0
  45. package/dist/chunk-NZON56CB.js.map +1 -0
  46. package/dist/chunk-OQ7U6EQ3.js +7550 -0
  47. package/dist/chunk-OQ7U6EQ3.js.map +1 -0
  48. package/dist/chunk-P4UZ7IXC.js +42 -0
  49. package/dist/chunk-P4UZ7IXC.js.map +1 -0
  50. package/dist/chunk-SM73S2DY.js +11 -0
  51. package/dist/chunk-SM73S2DY.js.map +1 -0
  52. package/dist/chunk-TKWR5AAY.js +415 -0
  53. package/dist/chunk-TKWR5AAY.js.map +1 -0
  54. package/dist/chunk-U5UNPBKB.js +501 -0
  55. package/dist/chunk-U5UNPBKB.js.map +1 -0
  56. package/dist/chunk-WGDJ4IXR.js +921 -0
  57. package/dist/chunk-WGDJ4IXR.js.map +1 -0
  58. package/dist/chunk-WVF7RUW5.js +186 -0
  59. package/dist/chunk-WVF7RUW5.js.map +1 -0
  60. package/dist/chunk-X3HZLNBV.js +2129 -0
  61. package/dist/chunk-X3HZLNBV.js.map +1 -0
  62. package/dist/chunk-XU3SBFAG.js +5205 -0
  63. package/dist/chunk-XU3SBFAG.js.map +1 -0
  64. package/dist/chunk-ZVBHWU7O.js +1412 -0
  65. package/dist/chunk-ZVBHWU7O.js.map +1 -0
  66. package/dist/client/index.d.ts +1 -1
  67. package/dist/client/index.js +54 -163
  68. package/dist/client/index.js.map +1 -1
  69. package/dist/core/index.d.ts +19 -0
  70. package/dist/{index-BFu5_dS8.d.ts → database.types-ChFCG-4M.d.ts} +1 -177
  71. package/dist/dist-NDNRSNOG.js +521 -0
  72. package/dist/dist-NDNRSNOG.js.map +1 -0
  73. package/dist/gen/index.js +188 -1280
  74. package/dist/gen/index.js.map +1 -1
  75. package/dist/hooks/index.d.ts +10 -3
  76. package/dist/hooks/index.js +20 -8695
  77. package/dist/hooks/index.js.map +1 -1
  78. package/dist/index-CQLyNG6A.d.ts +433 -0
  79. package/dist/index.d.ts +12 -8
  80. package/dist/index.js +447 -47848
  81. package/dist/index.js.map +1 -1
  82. package/dist/index.native.d.ts +373 -33
  83. package/dist/index.native.js +432 -25048
  84. package/dist/index.native.js.map +1 -1
  85. package/dist/index.web.d.ts +10 -7
  86. package/dist/index.web.js +585 -43773
  87. package/dist/index.web.js.map +1 -1
  88. package/dist/mutation/index.d.ts +2 -2
  89. package/dist/mutation/index.js +331 -4777
  90. package/dist/mutation/index.js.map +1 -1
  91. package/dist/parser/index.js +45 -3697
  92. package/dist/parser/index.js.map +1 -1
  93. package/dist/pdf-PHXP7RHD.js +20336 -0
  94. package/dist/pdf-PHXP7RHD.js.map +1 -0
  95. package/dist/powersync-bridge/index.d.ts +284 -0
  96. package/dist/powersync-bridge/index.js +22 -0
  97. package/dist/powersync-bridge/index.js.map +1 -0
  98. package/dist/query/index.js +31 -13175
  99. package/dist/query/index.js.map +1 -1
  100. package/dist/realtime/index.js +279 -12541
  101. package/dist/realtime/index.js.map +1 -1
  102. package/dist/{UserMetadataContext-BYYqA6LI.d.ts → setupAuthContext-Kv-THH-h.d.ts} +1 -29
  103. package/dist/types/index.d.ts +5 -1
  104. package/dist/types/index.js +14 -0
  105. package/dist/{useBatchUpsert-CSQVX7w8.d.ts → useBatchUpsert-9OYjibLh.d.ts} +1 -1
  106. package/dist/{useDbCount-RGCuHmHp.d.ts → useDbCount-BG356T9i.d.ts} +3 -719
  107. package/dist/{useReceiptAI-Bn0czE7C.d.ts → useReceiptAI-6HkRpRml.d.ts} +1 -1
  108. package/dist/{useResolveFeedback-CpZPP8Pw.d.ts → useResolveFeedback-BWmatBlE.d.ts} +26 -45
  109. package/dist/{useSupabase-pPhUZHcl.d.ts → useSupabase-DvWVuHHE.d.ts} +2 -1
  110. package/dist/with-auth/index.d.ts +704 -0
  111. package/dist/with-auth/index.js +1221 -0
  112. package/dist/with-auth/index.js.map +1 -0
  113. package/package.json +25 -10
@@ -0,0 +1,284 @@
1
+ import { SyncStatus, SyncControl } from '../core/index.js';
2
+ export { P as PowerSyncDatabase } from '../executor-CB4KHyYG.js';
3
+
4
+ /**
5
+ * PowerSync Bridge for @pol-studios/db
6
+ *
7
+ * This module provides integration utilities between @pol-studios/db and
8
+ * @pol-studios/powersync packages. It re-exports key types and provides
9
+ * helper functions for type-safe integration.
10
+ *
11
+ * The @pol-studios/powersync package is an optional peer dependency.
12
+ * This bridge allows the db package to work seamlessly with or without
13
+ * the powersync package installed.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { isPowerSyncAvailable, usePowerSyncDatabase } from '@pol-studios/db/powersync-bridge';
18
+ *
19
+ * if (isPowerSyncAvailable()) {
20
+ * // Use PowerSync features
21
+ * }
22
+ * ```
23
+ */
24
+ /**
25
+ * Re-export core types from @pol-studios/powersync for convenience.
26
+ * These types are defined here to avoid runtime dependency on the package.
27
+ */
28
+ /**
29
+ * Abstract interface for PowerSync database operations.
30
+ * This matches the interface from @pol-studios/powersync/core.
31
+ */
32
+ interface AbstractPowerSyncDatabase {
33
+ /** Execute a query and return all results */
34
+ getAll<T>(sql: string, params?: unknown[]): Promise<T[]>;
35
+ /** Execute a query and return first result or null */
36
+ get<T>(sql: string, params?: unknown[]): Promise<T | null>;
37
+ /** Execute a SQL statement (INSERT, UPDATE, DELETE) */
38
+ execute(sql: string, params?: unknown[]): Promise<{
39
+ rowsAffected: number;
40
+ }>;
41
+ /** Whether the database is currently connected */
42
+ connected: boolean;
43
+ /** Current sync status */
44
+ currentStatus: {
45
+ connected: boolean;
46
+ connecting: boolean;
47
+ hasSynced: boolean;
48
+ lastSyncedAt: Date | null;
49
+ dataFlowStatus?: {
50
+ uploading: boolean;
51
+ downloading: boolean;
52
+ };
53
+ downloadProgress?: {
54
+ downloadedFraction: number;
55
+ downloadedOperations: number;
56
+ totalOperations: number;
57
+ };
58
+ };
59
+ /** Initialize the database */
60
+ init(): Promise<void>;
61
+ /** Close the database connection */
62
+ close(): Promise<void>;
63
+ /** Connect to the PowerSync service */
64
+ connect(connector: unknown): Promise<void>;
65
+ /** Disconnect from the PowerSync service */
66
+ disconnect(): Promise<void>;
67
+ /** Register a listener for status changes */
68
+ registerListener(listener: {
69
+ statusChanged?: (status: unknown) => void;
70
+ }): () => void;
71
+ /** Get the next pending CRUD transaction */
72
+ getNextCrudTransaction(): Promise<unknown>;
73
+ }
74
+ /**
75
+ * Sync status from @pol-studios/powersync.
76
+ */
77
+ interface PowerSyncSyncStatus {
78
+ /** Whether connected to the PowerSync service */
79
+ connected: boolean;
80
+ /** Whether currently attempting to connect */
81
+ connecting: boolean;
82
+ /** Whether initial sync has completed */
83
+ hasSynced: boolean;
84
+ /** Timestamp of last successful sync */
85
+ lastSyncedAt: Date | null;
86
+ /** Whether currently uploading local changes */
87
+ uploading: boolean;
88
+ /** Whether currently downloading remote changes */
89
+ downloading: boolean;
90
+ /** Download progress details */
91
+ downloadProgress: {
92
+ current: number;
93
+ target: number;
94
+ percentage: number;
95
+ } | null;
96
+ }
97
+ /**
98
+ * Connection health status from @pol-studios/powersync.
99
+ */
100
+ interface PowerSyncConnectionHealth {
101
+ /** Current connection status */
102
+ status: "healthy" | "degraded" | "disconnected";
103
+ /** Last measured query latency in milliseconds */
104
+ latency: number | null;
105
+ /** Timestamp of the last health check */
106
+ lastHealthCheck: Date | null;
107
+ /** Number of consecutive health check failures */
108
+ consecutiveFailures: number;
109
+ /** Total reconnection attempts since last successful connection */
110
+ reconnectAttempts: number;
111
+ }
112
+ /**
113
+ * Sync metrics from @pol-studios/powersync.
114
+ */
115
+ interface PowerSyncMetrics {
116
+ /** Total number of sync operations attempted */
117
+ totalSyncs: number;
118
+ /** Number of successful sync operations */
119
+ successfulSyncs: number;
120
+ /** Number of failed sync operations */
121
+ failedSyncs: number;
122
+ /** Duration of the last sync in milliseconds */
123
+ lastSyncDuration: number | null;
124
+ /** Average sync duration in milliseconds */
125
+ averageSyncDuration: number | null;
126
+ /** Total bytes downloaded across all syncs */
127
+ totalDataDownloaded: number;
128
+ /** Total bytes uploaded across all syncs */
129
+ totalDataUploaded: number;
130
+ /** Last sync error details */
131
+ lastError: {
132
+ type: string;
133
+ message: string;
134
+ timestamp: Date;
135
+ } | null;
136
+ }
137
+ /**
138
+ * Sync control actions from @pol-studios/powersync.
139
+ */
140
+ interface PowerSyncControlActions {
141
+ /** Trigger a sync operation */
142
+ triggerSync: () => Promise<void>;
143
+ /** Pause sync operations */
144
+ pause: () => Promise<void>;
145
+ /** Resume sync operations */
146
+ resume: () => Promise<void>;
147
+ /** Disconnect from the PowerSync service */
148
+ disconnect: () => Promise<void>;
149
+ /** Set the sync scope for selective sync */
150
+ setScope: (scope: {
151
+ type: string;
152
+ ids: string[];
153
+ } | null) => void;
154
+ }
155
+ /**
156
+ * Check if @pol-studios/powersync is available.
157
+ *
158
+ * This function performs a lazy check to see if the powersync package
159
+ * is installed and can be imported. The result is cached for subsequent calls.
160
+ *
161
+ * @returns true if @pol-studios/powersync is available, false otherwise
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * import { isPowerSyncAvailable } from '@pol-studios/db/powersync-bridge';
166
+ *
167
+ * if (isPowerSyncAvailable()) {
168
+ * // Safe to use PowerSync features
169
+ * const { usePowerSync } = await import('@pol-studios/powersync');
170
+ * }
171
+ * ```
172
+ */
173
+ declare function isPowerSyncAvailable(): boolean;
174
+ /**
175
+ * Reset the availability check cache.
176
+ * Useful for testing or when package installation state might change.
177
+ */
178
+ declare function resetPowerSyncAvailabilityCache(): void;
179
+ /**
180
+ * Type guard to check if a value is an AbstractPowerSyncDatabase.
181
+ *
182
+ * @param value - The value to check
183
+ * @returns true if value implements AbstractPowerSyncDatabase interface
184
+ */
185
+ declare function isAbstractPowerSyncDatabase(value: unknown): value is AbstractPowerSyncDatabase;
186
+ /**
187
+ * Type guard to check if a value is a PowerSyncSyncStatus.
188
+ *
189
+ * @param value - The value to check
190
+ * @returns true if value matches PowerSyncSyncStatus interface
191
+ */
192
+ declare function isPowerSyncSyncStatus(value: unknown): value is PowerSyncSyncStatus;
193
+ /**
194
+ * Convert PowerSync sync status to the V3 DataLayer SyncStatus format.
195
+ *
196
+ * This utility helps bridge the sync status from @pol-studios/powersync
197
+ * to the format expected by @pol-studios/db's DataLayerProvider.
198
+ *
199
+ * @param powerSyncStatus - The sync status from @pol-studios/powersync
200
+ * @param pendingCount - Number of pending uploads (from pendingMutations)
201
+ * @returns SyncStatus in @pol-studios/db format
202
+ */
203
+ declare function convertToDataLayerSyncStatus(powerSyncStatus: PowerSyncSyncStatus, pendingCount?: number): SyncStatus;
204
+ /**
205
+ * Convert PowerSync sync control to the V3 DataLayer SyncControl format.
206
+ *
207
+ * @param powerSyncControl - The sync control actions from @pol-studios/powersync
208
+ * @returns SyncControl in @pol-studios/db format
209
+ */
210
+ declare function convertToDataLayerSyncControl(powerSyncControl: PowerSyncControlActions): SyncControl;
211
+ /**
212
+ * Create a database instance getter that works with PowerSync context.
213
+ *
214
+ * This is useful for integrating PowerSyncProvider with DataLayerProvider
215
+ * by providing a way to get the database instance from the PowerSync context.
216
+ *
217
+ * @param getPowerSyncDb - Function to get the PowerSync database from context
218
+ * @returns A function that returns the database or null
219
+ */
220
+ declare function createDatabaseGetter(getPowerSyncDb: () => AbstractPowerSyncDatabase | null): () => AbstractPowerSyncDatabase | null;
221
+ /**
222
+ * Options for setting up DataLayerProvider with PowerSync integration.
223
+ */
224
+ interface PowerSyncIntegrationOptions {
225
+ /**
226
+ * The PowerSync database instance from PowerSyncProvider.
227
+ */
228
+ database: AbstractPowerSyncDatabase | null;
229
+ /**
230
+ * Whether the PowerSync database is ready.
231
+ */
232
+ isReady: boolean;
233
+ /**
234
+ * Current sync status from PowerSyncProvider.
235
+ */
236
+ syncStatus?: PowerSyncSyncStatus;
237
+ /**
238
+ * Sync control actions from PowerSyncProvider.
239
+ */
240
+ syncControl?: PowerSyncControlActions;
241
+ /**
242
+ * Number of pending mutations.
243
+ */
244
+ pendingCount?: number;
245
+ }
246
+ /**
247
+ * Get the powerSyncInstance prop for DataLayerProvider from PowerSync context values.
248
+ *
249
+ * This helper extracts the necessary values from @pol-studios/powersync hooks
250
+ * and returns them in a format suitable for DataLayerProvider.
251
+ *
252
+ * @param options - The PowerSync integration options
253
+ * @returns The powerSyncInstance to pass to DataLayerProvider, or null if not ready
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * // Inside a component wrapped with PowerSyncProvider
258
+ * const { db, isReady } = usePowerSync();
259
+ * const { status, pendingCount } = useSyncStatus();
260
+ * const syncControl = useSyncControl();
261
+ *
262
+ * const powerSyncInstance = getPowerSyncInstance({
263
+ * database: db,
264
+ * isReady,
265
+ * syncStatus: status,
266
+ * syncControl,
267
+ * pendingCount,
268
+ * });
269
+ *
270
+ * return (
271
+ * <DataLayerProvider
272
+ * config={config}
273
+ * powerSyncInstance={powerSyncInstance}
274
+ * supabaseClient={supabase}
275
+ * queryClient={queryClient}
276
+ * >
277
+ * {children}
278
+ * </DataLayerProvider>
279
+ * );
280
+ * ```
281
+ */
282
+ declare function getPowerSyncInstance(options: PowerSyncIntegrationOptions): AbstractPowerSyncDatabase | null;
283
+
284
+ export { type AbstractPowerSyncDatabase, type PowerSyncConnectionHealth, type PowerSyncControlActions, type PowerSyncIntegrationOptions, type PowerSyncMetrics, type PowerSyncSyncStatus, convertToDataLayerSyncControl, convertToDataLayerSyncStatus, createDatabaseGetter, getPowerSyncInstance, isAbstractPowerSyncDatabase, isPowerSyncAvailable, isPowerSyncSyncStatus, resetPowerSyncAvailabilityCache };
@@ -0,0 +1,22 @@
1
+ import {
2
+ convertToDataLayerSyncControl,
3
+ convertToDataLayerSyncStatus,
4
+ createDatabaseGetter,
5
+ getPowerSyncInstance,
6
+ isAbstractPowerSyncDatabase,
7
+ isPowerSyncAvailable,
8
+ isPowerSyncSyncStatus,
9
+ resetPowerSyncAvailabilityCache
10
+ } from "../chunk-N26IEHZT.js";
11
+ import "../chunk-P4UZ7IXC.js";
12
+ export {
13
+ convertToDataLayerSyncControl,
14
+ convertToDataLayerSyncStatus,
15
+ createDatabaseGetter,
16
+ getPowerSyncInstance,
17
+ isAbstractPowerSyncDatabase,
18
+ isPowerSyncAvailable,
19
+ isPowerSyncSyncStatus,
20
+ resetPowerSyncAvailabilityCache
21
+ };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}