@pol-studios/powersync 1.0.0 → 1.0.2

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 (51) hide show
  1. package/dist/attachments/index.js +1 -1
  2. package/dist/{chunk-4FJVBR3X.js → chunk-3AYXHQ4W.js} +24 -13
  3. package/dist/chunk-3AYXHQ4W.js.map +1 -0
  4. package/dist/{chunk-BJ36QDFN.js → chunk-7EMDVIZX.js} +1 -1
  5. package/dist/chunk-7EMDVIZX.js.map +1 -0
  6. package/dist/chunk-C2RSTGDC.js +726 -0
  7. package/dist/chunk-C2RSTGDC.js.map +1 -0
  8. package/dist/{chunk-NPNBGCRC.js → chunk-EJ23MXPQ.js} +1 -1
  9. package/dist/{chunk-NPNBGCRC.js.map → chunk-EJ23MXPQ.js.map} +1 -1
  10. package/dist/{chunk-CHRTN5PF.js → chunk-FPTDATY5.js} +1 -1
  11. package/dist/chunk-FPTDATY5.js.map +1 -0
  12. package/dist/chunk-GMFDCVMZ.js +1285 -0
  13. package/dist/chunk-GMFDCVMZ.js.map +1 -0
  14. package/dist/chunk-OLHGI472.js +1 -0
  15. package/dist/{chunk-CFCK2LHI.js → chunk-OTJXIRWX.js} +45 -40
  16. package/dist/chunk-OTJXIRWX.js.map +1 -0
  17. package/dist/{chunk-GBGATW2S.js → chunk-V6LJ6MR2.js} +86 -95
  18. package/dist/chunk-V6LJ6MR2.js.map +1 -0
  19. package/dist/chunk-VJCL2SWD.js +1 -0
  20. package/dist/chunk-VJCL2SWD.js.map +1 -0
  21. package/dist/connector/index.d.ts +1 -2
  22. package/dist/connector/index.js +3 -6
  23. package/dist/core/index.js +2 -2
  24. package/dist/{supabase-connector-D14-kl5v.d.ts → index-Cb-NI0Ct.d.ts} +159 -2
  25. package/dist/index.d.ts +2 -3
  26. package/dist/index.js +12 -13
  27. package/dist/index.native.d.ts +1 -2
  28. package/dist/index.native.js +13 -14
  29. package/dist/index.web.d.ts +1 -2
  30. package/dist/index.web.js +13 -14
  31. package/dist/platform/index.js.map +1 -1
  32. package/dist/platform/index.native.js +1 -1
  33. package/dist/platform/index.web.js +1 -1
  34. package/dist/provider/index.d.ts +6 -1
  35. package/dist/provider/index.js +6 -6
  36. package/dist/sync/index.js +3 -3
  37. package/package.json +35 -10
  38. package/dist/chunk-4FJVBR3X.js.map +0 -1
  39. package/dist/chunk-7BPTGEVG.js +0 -1
  40. package/dist/chunk-BJ36QDFN.js.map +0 -1
  41. package/dist/chunk-CFCK2LHI.js.map +0 -1
  42. package/dist/chunk-CHRTN5PF.js.map +0 -1
  43. package/dist/chunk-FLHDT4TS.js +0 -327
  44. package/dist/chunk-FLHDT4TS.js.map +0 -1
  45. package/dist/chunk-GBGATW2S.js.map +0 -1
  46. package/dist/chunk-Q3LFFMRR.js +0 -925
  47. package/dist/chunk-Q3LFFMRR.js.map +0 -1
  48. package/dist/chunk-T225XEML.js +0 -298
  49. package/dist/chunk-T225XEML.js.map +0 -1
  50. package/dist/index-nae7nzib.d.ts +0 -147
  51. /package/dist/{chunk-7BPTGEVG.js.map → chunk-OLHGI472.js.map} +0 -0
@@ -1,147 +0,0 @@
1
- import { S as SupabaseConnector, a as SupabaseConnectorOptions } from './supabase-connector-D14-kl5v.js';
2
- import { A as AbstractPowerSyncDatabase } from './types-afHtE1U_.js';
3
-
4
- /**
5
- * Conflict Types for @pol-studios/powersync
6
- *
7
- * Provides types for version-based conflict detection using AuditLog attribution.
8
- */
9
- /**
10
- * Represents a field-level conflict where both local and server changed the same field.
11
- */
12
- interface FieldConflict {
13
- /** The field name that has conflicting changes */
14
- field: string;
15
- /** The local (pending) value */
16
- localValue: unknown;
17
- /** The current server value */
18
- serverValue: unknown;
19
- /** User who made the server change (from AuditLog.changeBy) */
20
- changedBy: string | null;
21
- /** When the server change occurred (from AuditLog.changeAt) */
22
- changedAt: Date;
23
- }
24
- /**
25
- * Result of checking for conflicts between local changes and server state.
26
- */
27
- interface ConflictCheckResult {
28
- /** Whether any field conflicts were detected */
29
- hasConflict: boolean;
30
- /** List of field-level conflicts */
31
- conflicts: FieldConflict[];
32
- /** Fields that can safely sync (no server changes) */
33
- nonConflictingChanges: string[];
34
- /** The table name */
35
- table: string;
36
- /** The record ID */
37
- recordId: string;
38
- }
39
- /**
40
- * User's resolution choice for a conflict.
41
- */
42
- type ConflictResolution = {
43
- action: 'overwrite';
44
- } | {
45
- action: 'keep-server';
46
- } | {
47
- action: 'partial';
48
- fields: string[];
49
- };
50
- /**
51
- * Handler for conflict events in the connector.
52
- */
53
- interface ConflictHandler {
54
- /**
55
- * Called when a conflict is detected during upload.
56
- *
57
- * @param result - The conflict check result
58
- * @returns Resolution to apply, or null to queue for UI resolution
59
- */
60
- onConflict: (result: ConflictCheckResult) => Promise<ConflictResolution | null>;
61
- }
62
- /**
63
- * Configuration for conflict detection behavior.
64
- */
65
- interface ConflictDetectionConfig {
66
- /** Tables to skip conflict detection (opt-out). Default: [] */
67
- skipTables?: string[];
68
- /** Fields to ignore in conflict detection. Default: ['updatedAt', 'createdAt'] */
69
- ignoredFields?: string[];
70
- /** Whether to enable conflict detection. Default: true */
71
- enabled?: boolean;
72
- }
73
-
74
- /**
75
- * Conflict-Aware Connector for @pol-studios/powersync
76
- *
77
- * Extends SupabaseConnector with version-based conflict detection.
78
- * Tables with a _version column automatically get conflict checking.
79
- */
80
-
81
- /**
82
- * Options for ConflictAwareConnector.
83
- */
84
- interface ConflictAwareConnectorOptions extends SupabaseConnectorOptions {
85
- /** Handler for conflict resolution. If not provided, conflicts are logged. */
86
- conflictHandler?: ConflictHandler;
87
- /** Configuration for conflict detection behavior */
88
- conflictDetection?: ConflictDetectionConfig;
89
- }
90
- /**
91
- * A PowerSync connector with built-in conflict detection.
92
- *
93
- * This connector extends SupabaseConnector to add version-based conflict
94
- * detection for tables with a `_version` column. When a conflict is detected,
95
- * it calls the provided conflict handler to determine how to proceed.
96
- *
97
- * @example
98
- * ```typescript
99
- * const connector = new ConflictAwareConnector({
100
- * supabaseClient: supabase,
101
- * powerSyncUrl: POWERSYNC_URL,
102
- * conflictHandler: {
103
- * onConflict: async (result) => {
104
- * // Queue for UI resolution
105
- * conflictContext.addConflict(result);
106
- * return null; // Don't proceed with upload
107
- * },
108
- * },
109
- * });
110
- * ```
111
- */
112
- declare class ConflictAwareConnector extends SupabaseConnector {
113
- private readonly conflictHandler?;
114
- private readonly conflictConfig?;
115
- private readonly supabaseClient;
116
- private readonly schemaRouterFn;
117
- private versionColumnCache;
118
- constructor(options: ConflictAwareConnectorOptions);
119
- /**
120
- * Override uploadData to check for conflicts before uploading.
121
- *
122
- * For each CRUD entry in the transaction:
123
- * 1. Check if table has _version column (cached)
124
- * 2. If yes, compare local vs server version
125
- * 3. On version mismatch, query AuditLog for field conflicts
126
- * 4. If conflicts found, call handler to determine resolution
127
- * 5. Apply resolution or skip entry based on handler response
128
- */
129
- uploadData(database: AbstractPowerSyncDatabase): Promise<void>;
130
- /**
131
- * Check if a table has a _version column (cached).
132
- */
133
- private checkVersionColumn;
134
- /**
135
- * Filter opData to only include specified fields.
136
- */
137
- private filterFields;
138
- /**
139
- * Process a single CRUD entry - delegates to parent's private method.
140
- *
141
- * Note: This is a workaround since processCrudEntry is private in parent.
142
- * We replicate the logic here for now.
143
- */
144
- private processEntry;
145
- }
146
-
147
- export { ConflictAwareConnector as C, type FieldConflict as F, type ConflictAwareConnectorOptions as a, type ConflictCheckResult as b, type ConflictResolution as c, type ConflictHandler as d, type ConflictDetectionConfig as e };