supastash 0.1.61 → 0.2.0
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 +17 -5
- package/dist/core/config/index.d.ts.map +1 -1
- package/dist/core/config/index.js +5 -1
- package/dist/db/adapters/expo_sqlite.d.ts.map +1 -1
- package/dist/db/adapters/expo_sqlite.js +11 -0
- package/dist/db/adapters/rn_nitro.d.ts.map +1 -1
- package/dist/db/adapters/rn_nitro.js +20 -0
- package/dist/db/adapters/rn_sqlite_storage.d.ts.map +1 -1
- package/dist/db/adapters/rn_sqlite_storage.js +27 -0
- package/dist/hooks/supastashData/fetchCalls.d.ts.map +1 -1
- package/dist/hooks/supastashData/index.d.ts.map +1 -1
- package/dist/hooks/supastashData/index.js +12 -4
- package/dist/hooks/supastashData/realtimeSubscription.js +4 -4
- package/dist/hooks/supastashData/registerSub.d.ts +3 -3
- package/dist/hooks/supastashData/registerSub.d.ts.map +1 -1
- package/dist/hooks/supastashData/registerSub.js +3 -3
- package/dist/hooks/supastashFilters/index.d.ts +2 -2
- package/dist/hooks/supastashFilters/index.d.ts.map +1 -1
- package/dist/hooks/supastashFilters/index.js +6 -4
- package/dist/hooks/supastashLiteQuery/index.d.ts.map +1 -1
- package/dist/hooks/supastashLiteQuery/index.js +12 -2
- package/dist/hooks/syncEngine/pushLocal/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/store/tableFilters.d.ts +3 -3
- package/dist/store/tableFilters.d.ts.map +1 -1
- package/dist/store/tx.d.ts +3 -0
- package/dist/store/tx.d.ts.map +1 -0
- package/dist/store/tx.js +1 -0
- package/dist/types/expoSqlite.types.d.ts +3 -13
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/liteQuery.types.d.ts +2 -2
- package/dist/types/query.types.d.ts +24 -1
- package/dist/types/realtimeData.types.d.ts +8 -4
- package/dist/types/supastashConfig.types.d.ts +83 -6
- package/dist/types/syncEngine.types.d.ts +49 -7
- package/dist/utils/errorHandler.d.ts +6 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/errorHandler.js +8 -0
- package/dist/utils/fetchData/buildFilter.d.ts +8 -4
- package/dist/utils/fetchData/buildFilter.d.ts.map +1 -1
- package/dist/utils/fetchData/createTable.d.ts.map +1 -1
- package/dist/utils/fetchData/createTable.js +3 -46
- package/dist/utils/fetchData/deleteData.d.ts.map +1 -1
- package/dist/utils/fetchData/deleteData.js +6 -3
- package/dist/utils/fetchData/fetchLocalData.d.ts +2 -2
- package/dist/utils/fetchData/fetchLocalData.d.ts.map +1 -1
- package/dist/utils/fetchData/initialFetch.d.ts +2 -2
- package/dist/utils/fetchData/initialFetch.d.ts.map +1 -1
- package/dist/utils/fetchData/liteHelpers.d.ts +2 -2
- package/dist/utils/fetchData/liteHelpers.d.ts.map +1 -1
- package/dist/utils/fetchData/liteHelpers.js +14 -119
- package/dist/utils/fetchData/realTimeCall.js +2 -2
- package/dist/utils/fetchData/receiveData.js +1 -1
- package/dist/utils/query/builder/crud.d.ts +5 -5
- package/dist/utils/query/builder/crud.d.ts.map +1 -1
- package/dist/utils/query/builder/filters.d.ts +36 -12
- package/dist/utils/query/builder/filters.d.ts.map +1 -1
- package/dist/utils/query/builder/filters.js +32 -0
- package/dist/utils/query/builder/index.d.ts +29 -1
- package/dist/utils/query/builder/index.d.ts.map +1 -1
- package/dist/utils/query/builder/index.js +77 -1
- package/dist/utils/query/builder/mainQuery.d.ts.map +1 -1
- package/dist/utils/query/builder/mainQuery.js +17 -2
- package/dist/utils/query/helpers/localDb/getLocalMethod.d.ts +2 -2
- package/dist/utils/query/helpers/localDb/getLocalMethod.d.ts.map +1 -1
- package/dist/utils/query/helpers/localDb/getLocalMethod.js +7 -6
- package/dist/utils/query/helpers/localDb/insertMany.d.ts +3 -0
- package/dist/utils/query/helpers/localDb/insertMany.d.ts.map +1 -1
- package/dist/utils/query/helpers/localDb/insertMany.js +10 -3
- package/dist/utils/query/helpers/localDb/localQueryBuilder.d.ts +6 -6
- package/dist/utils/query/helpers/localDb/localQueryBuilder.d.ts.map +1 -1
- package/dist/utils/query/helpers/localDb/localQueryBuilder.js +17 -10
- package/dist/utils/query/helpers/localDb/upsertMany.d.ts +3 -0
- package/dist/utils/query/helpers/localDb/upsertMany.d.ts.map +1 -1
- package/dist/utils/query/helpers/localDb/upsertMany.js +9 -2
- package/dist/utils/query/helpers/mainQueryHelpers.d.ts.map +1 -1
- package/dist/utils/query/helpers/mainQueryHelpers.js +38 -8
- package/dist/utils/query/helpers/queueRemote.d.ts.map +1 -1
- package/dist/utils/query/helpers/queueRemote.js +33 -24
- package/dist/utils/query/localDbQuery/delete.d.ts +9 -3
- package/dist/utils/query/localDbQuery/delete.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/delete.js +16 -5
- package/dist/utils/query/localDbQuery/index.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/index.js +3 -3
- package/dist/utils/query/localDbQuery/insert.d.ts +2 -2
- package/dist/utils/query/localDbQuery/insert.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/insert.js +8 -5
- package/dist/utils/query/localDbQuery/select.d.ts +2 -2
- package/dist/utils/query/localDbQuery/select.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/select.js +5 -2
- package/dist/utils/query/localDbQuery/update.d.ts +2 -2
- package/dist/utils/query/localDbQuery/update.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/update.js +5 -2
- package/dist/utils/query/localDbQuery/upsert.d.ts +2 -2
- package/dist/utils/query/localDbQuery/upsert.d.ts.map +1 -1
- package/dist/utils/query/localDbQuery/upsert.js +8 -3
- package/dist/utils/query/remoteQuery/supabaseQuery.d.ts.map +1 -1
- package/dist/utils/query/remoteQuery/supabaseQuery.js +4 -1
- package/dist/utils/reusedHelpers.d.ts +8 -0
- package/dist/utils/reusedHelpers.d.ts.map +1 -0
- package/dist/utils/reusedHelpers.js +162 -0
- package/dist/utils/schema/createSyncStatus.d.ts +3 -1
- package/dist/utils/schema/createSyncStatus.d.ts.map +1 -1
- package/dist/utils/schema/createSyncStatus.js +30 -3
- package/dist/utils/sync/pullFromRemote/fetchOlder.d.ts +44 -0
- package/dist/utils/sync/pullFromRemote/fetchOlder.d.ts.map +1 -0
- package/dist/utils/sync/pullFromRemote/fetchOlder.js +55 -0
- package/dist/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts +33 -0
- package/dist/utils/sync/pullFromRemote/fetchOlderHelpers.d.ts.map +1 -0
- package/dist/utils/sync/pullFromRemote/fetchOlderHelpers.js +110 -0
- package/dist/utils/sync/pullFromRemote/helpers.d.ts +10 -7
- package/dist/utils/sync/pullFromRemote/helpers.d.ts.map +1 -1
- package/dist/utils/sync/pullFromRemote/helpers.js +20 -14
- package/dist/utils/sync/pullFromRemote/pullData.d.ts +2 -3
- package/dist/utils/sync/pullFromRemote/pullData.d.ts.map +1 -1
- package/dist/utils/sync/pullFromRemote/pullData.js +4 -9
- package/dist/utils/sync/pullFromRemote/pullDeletedData.d.ts +8 -5
- package/dist/utils/sync/pullFromRemote/updateFilter.d.ts +1 -1
- package/dist/utils/sync/pullFromRemote/updateFilter.d.ts.map +1 -1
- package/dist/utils/sync/pullFromRemote/updateFilter.js +5 -3
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts +4 -3
- package/dist/utils/sync/pullFromRemote/updateLocalDb.d.ts.map +1 -1
- package/dist/utils/sync/pullFromRemote/updateLocalDb.js +51 -46
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts +2 -4
- package/dist/utils/sync/pullFromRemote/validateFilters.d.ts.map +1 -1
- package/dist/utils/sync/pullFromRemote/validateFilters.js +9 -63
- package/dist/utils/sync/pushLocal/deleteChunks.d.ts.map +1 -1
- package/dist/utils/sync/pushLocal/deleteChunks.js +7 -5
- package/dist/utils/sync/pushLocal/getAllUnsyncedData.d.ts.map +1 -1
- package/dist/utils/sync/pushLocal/getAllUnsyncedData.js +12 -44
- package/dist/utils/sync/pushLocal/uploadHelpers.js +1 -1
- package/dist/utils/sync/status/filterKey.d.ts +3 -3
- package/dist/utils/sync/status/filterKey.d.ts.map +1 -1
- package/dist/utils/sync/status/filterKey.js +5 -2
- package/dist/utils/sync/status/remoteSchema.d.ts +4 -0
- package/dist/utils/sync/status/remoteSchema.d.ts.map +1 -0
- package/dist/utils/sync/status/remoteSchema.js +140 -0
- package/dist/utils/sync/status/repo.d.ts +5 -5
- package/dist/utils/sync/status/repo.d.ts.map +1 -1
- package/dist/utils/sync/status/repo.js +40 -22
- package/dist/utils/sync/status/services.d.ts +5 -6
- package/dist/utils/sync/status/services.d.ts.map +1 -1
- package/dist/utils/sync/status/services.js +1 -6
- package/dist/utils/sync/status/syncStatus.d.ts +5 -7
- package/dist/utils/sync/status/syncStatus.d.ts.map +1 -1
- package/dist/utils/sync/status/syncStatus.js +11 -3
- package/package.json +2 -2
- package/dist/types/supastashFilters.types.d.ts +0 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { SQLiteOpenOptions } from "expo-sqlite";
|
|
3
|
+
import { NitroSQLiteConnection } from "react-native-nitro-sqlite";
|
|
4
|
+
import { SQLiteDatabase as RNStorageSQLiteDatabase } from "react-native-sqlite-storage";
|
|
3
5
|
import { ExpoSQLiteDatabase } from "./expoSqlite.types";
|
|
4
|
-
import { RNNitroSQLiteDatabase } from "./rnNitroSqlite.types";
|
|
5
|
-
import { RNStorageSQLiteDatabase } from "./rnSqliteStorage.types";
|
|
6
6
|
|
|
7
7
|
export type SupastashSQLiteClientTypes =
|
|
8
8
|
| "expo"
|
|
@@ -50,7 +50,7 @@ export type SupastashConfig<T extends SupastashSQLiteClientTypes> = {
|
|
|
50
50
|
/**
|
|
51
51
|
* Maximum number of rows sent per Supabase write request.
|
|
52
52
|
* Large payloads are automatically split into sequential batches.
|
|
53
|
-
* Default:
|
|
53
|
+
* Default: 800.
|
|
54
54
|
*/
|
|
55
55
|
supabaseBatchSize?: number;
|
|
56
56
|
|
|
@@ -78,6 +78,72 @@ export type SupastashConfig<T extends SupastashSQLiteClientTypes> = {
|
|
|
78
78
|
push?: number;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Controls how Supastash determines incremental synchronization order.
|
|
83
|
+
*
|
|
84
|
+
* - "client-side":
|
|
85
|
+
* Uses the `updated_at` column as the replication cursor.
|
|
86
|
+
* Timestamps are generated by the client and compared during sync.
|
|
87
|
+
* This mode is backward-compatible but may allow ordering inconsistencies
|
|
88
|
+
* if devices that have been offline for a while push stale data.
|
|
89
|
+
*
|
|
90
|
+
* - "server-side":
|
|
91
|
+
* Uses a server-controlled `arrived_at` column as the replication cursor.
|
|
92
|
+
* The column must exist on the remote table and be enforced via trigger.
|
|
93
|
+
* This provides deterministic, server-ordered replication and prevents
|
|
94
|
+
* stale offline updates from breaking incremental sync.
|
|
95
|
+
*
|
|
96
|
+
* IMPORTANT:
|
|
97
|
+
* When "server-side" is enabled, Supastash requires the `arrived_at`
|
|
98
|
+
* column to exist on all synced tables. Sync will fail if missing.
|
|
99
|
+
*
|
|
100
|
+
* Recommended for production and distributed offline-first systems.
|
|
101
|
+
*
|
|
102
|
+
* @default "client-side"
|
|
103
|
+
*
|
|
104
|
+
* Docs: https://0xzekea.github.io/supastash/docs/replication-mode
|
|
105
|
+
*/
|
|
106
|
+
replicationMode?: "client-side" | "server-side";
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The maximum number of days Supastash will pull data from when syncing.
|
|
110
|
+
*
|
|
111
|
+
* Supastash will not request records older than (now - maxSyncLookbackDays),
|
|
112
|
+
* unless the table is listed in fullSyncTables or has a specific override
|
|
113
|
+
* in perTableSyncLookbackDays.
|
|
114
|
+
*
|
|
115
|
+
* Set to undefined to remove the cap globally.
|
|
116
|
+
*
|
|
117
|
+
* Default: 365 days.
|
|
118
|
+
*/
|
|
119
|
+
maxSyncLookbackDays?: number;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Optional per-table override for maxSyncLookbackDays.
|
|
123
|
+
*
|
|
124
|
+
* Allows you to define a different lookback window (in days) for specific tables.
|
|
125
|
+
*
|
|
126
|
+
* If a table is listed here, its value takes precedence over maxSyncLookbackDays.
|
|
127
|
+
|
|
128
|
+
*
|
|
129
|
+
* Example:
|
|
130
|
+
* {
|
|
131
|
+
* messages: 30, // only sync last 30 days
|
|
132
|
+
* orders: 180, // sync last 6 months
|
|
133
|
+
* }
|
|
134
|
+
*/
|
|
135
|
+
perTableSyncLookbackDays?: Record<string, number | undefined>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* List of tables that should always sync their full history,
|
|
139
|
+
* ignoring maxSyncLookbackDays and perTableSyncLookbackDays.
|
|
140
|
+
*
|
|
141
|
+
* If a table is included here, no lookback cap will be applied.
|
|
142
|
+
*
|
|
143
|
+
* Useful for critical tables where complete cross-checking is required.
|
|
144
|
+
*/
|
|
145
|
+
fullSyncTables?: string[];
|
|
146
|
+
|
|
81
147
|
// --------------------------------------------------
|
|
82
148
|
// Sync Engine Toggles & Behavior
|
|
83
149
|
// --------------------------------------------------
|
|
@@ -203,7 +269,7 @@ export type SupastashConfig<T extends SupastashSQLiteClientTypes> = {
|
|
|
203
269
|
supastashMode?: SupastashMode;
|
|
204
270
|
};
|
|
205
271
|
|
|
206
|
-
interface
|
|
272
|
+
export interface SupastashSQLiteExecutor {
|
|
207
273
|
/**
|
|
208
274
|
* Executes a SQL statement without returning any result.
|
|
209
275
|
* Useful for `INSERT`, `UPDATE`, `DELETE`, or `CREATE TABLE` commands.
|
|
@@ -212,7 +278,7 @@ interface SupastashSQLiteDatabase {
|
|
|
212
278
|
* @param params - Optional parameters for the statement
|
|
213
279
|
* @returns A Promise that resolves when the execution is complete
|
|
214
280
|
*/
|
|
215
|
-
runAsync(sql: string, params?: any[]): Promise<
|
|
281
|
+
runAsync(sql: string, params?: any[]): Promise<any>;
|
|
216
282
|
|
|
217
283
|
/**
|
|
218
284
|
* Executes a query and returns **all rows** as an array.
|
|
@@ -240,7 +306,9 @@ interface SupastashSQLiteDatabase {
|
|
|
240
306
|
* @returns A Promise that resolves when all statements are executed
|
|
241
307
|
*/
|
|
242
308
|
execAsync(statements: string): Promise<void>;
|
|
309
|
+
}
|
|
243
310
|
|
|
311
|
+
export interface SupastashSQLiteDatabase extends SupastashSQLiteExecutor {
|
|
244
312
|
/**
|
|
245
313
|
* Closes the underlying SQLite connection.
|
|
246
314
|
*
|
|
@@ -251,6 +319,15 @@ interface SupastashSQLiteDatabase {
|
|
|
251
319
|
* Do NOT call this in production app code.
|
|
252
320
|
*/
|
|
253
321
|
closeAsync(): Promise<void>;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Executes a function within a transaction.
|
|
325
|
+
* @param fn - The function to execute within the transaction
|
|
326
|
+
* @returns A Promise that resolves when the transaction is complete
|
|
327
|
+
*/
|
|
328
|
+
withTransaction(
|
|
329
|
+
fn: (tx: SupastashSQLiteExecutor) => Promise<void> | void
|
|
330
|
+
): Promise<void>;
|
|
254
331
|
}
|
|
255
332
|
|
|
256
333
|
export interface SupastashSQLiteAdapter {
|
|
@@ -277,7 +354,7 @@ export interface RNStorageSQLiteClient {
|
|
|
277
354
|
}
|
|
278
355
|
|
|
279
356
|
export interface RNSqliteNitroClient {
|
|
280
|
-
open: (options: { name: string; location?: string }) =>
|
|
357
|
+
open: (options: { name: string; location?: string }) => NitroSQLiteConnection;
|
|
281
358
|
}
|
|
282
359
|
|
|
283
360
|
export interface SupastashHookReturn {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { PayloadData } from "./query.types";
|
|
1
2
|
import { SupastashFilter } from "./realtimeData.types";
|
|
3
|
+
import { SupastashSQLiteExecutor } from "./supastashConfig.types";
|
|
2
4
|
|
|
3
5
|
export type SyncResult = {
|
|
4
6
|
success: string[]; // IDs that were successfully upserted
|
|
@@ -32,16 +34,12 @@ export type SupastashSyncStatus = {
|
|
|
32
34
|
table_name: string;
|
|
33
35
|
filter_key: string;
|
|
34
36
|
filter_json: string;
|
|
35
|
-
last_created_at: string;
|
|
36
37
|
last_synced_at: string;
|
|
37
|
-
|
|
38
|
+
last_synced_at_pk: string | null;
|
|
39
|
+
last_deleted_at: string | null;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
export type PublicScope =
|
|
41
|
-
| "all"
|
|
42
|
-
| "last_synced_at"
|
|
43
|
-
| "last_created_at"
|
|
44
|
-
| "last_deleted_at";
|
|
42
|
+
export type PublicScope = "all" | "last_synced_at" | "last_deleted_at";
|
|
45
43
|
|
|
46
44
|
export type CurrentTableInfo = {
|
|
47
45
|
/** Table currently being synced */
|
|
@@ -119,3 +117,47 @@ export type SyncInfo = {
|
|
|
119
117
|
/** Sync information for push operations (local → server) */
|
|
120
118
|
push: SyncInfoItem;
|
|
121
119
|
};
|
|
120
|
+
|
|
121
|
+
export type ReceivedDataCompleted = {
|
|
122
|
+
completed: boolean;
|
|
123
|
+
lastTimestamp: string | undefined;
|
|
124
|
+
lastId: string | undefined;
|
|
125
|
+
};
|
|
126
|
+
export type ReceivedDataCompletedMap = {
|
|
127
|
+
[key: string]: {
|
|
128
|
+
arrived_at: ReceivedDataCompleted;
|
|
129
|
+
updated_at: ReceivedDataCompleted;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type UpsertDataParams = {
|
|
134
|
+
/**
|
|
135
|
+
* Optional transaction executor.
|
|
136
|
+
*
|
|
137
|
+
* If provided, the upsert will execute within this existing transaction.
|
|
138
|
+
* This is typically supplied when called inside
|
|
139
|
+
* `db.withTransaction(...)` or `supastash.withTransaction(...)`.
|
|
140
|
+
*
|
|
141
|
+
* If omitted, the upsert will run using the root database executor.
|
|
142
|
+
*/
|
|
143
|
+
tx?: SupastashSQLiteExecutor;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The table to perform the upsert on.
|
|
147
|
+
*/
|
|
148
|
+
table: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The record to insert or update.
|
|
152
|
+
*/
|
|
153
|
+
record: PayloadData | PayloadData[];
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Optional optimization hint.
|
|
157
|
+
*
|
|
158
|
+
* If true, forces UPDATE.
|
|
159
|
+
* If false, forces INSERT.
|
|
160
|
+
* If undefined, existence will be determined automatically.
|
|
161
|
+
*/
|
|
162
|
+
doesExist?: boolean;
|
|
163
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBACf,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAMvE"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function buildFilterString<R = any>(
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { SupastashFilter } from "../../types/realtimeData.types";
|
|
2
|
+
export declare function buildFilterString<R = any>(
|
|
3
|
+
filters: SupastashFilter<R> | undefined
|
|
4
|
+
): string | undefined;
|
|
5
|
+
export declare function buildFilterForSql<R = any>(
|
|
6
|
+
filter: SupastashFilter<R> | SupastashFilter<R> | undefined | undefined
|
|
7
|
+
): string | undefined;
|
|
8
|
+
//# sourceMappingURL=buildFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFilter.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/buildFilter.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"buildFilter.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/buildFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAExC,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EACvC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,GACrC,MAAM,GAAG,SAAS,CAepB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EACvC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,SAAS,GACrE,MAAM,GAAG,SAAS,CAiCpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTable.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/createTable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTable.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/createTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOtD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,iBAsCrE"}
|
|
@@ -1,52 +1,9 @@
|
|
|
1
|
-
import { getSupastashConfig } from "../../core/config";
|
|
2
1
|
import { getSupastashDb } from "../../db/dbInitializer";
|
|
3
|
-
import { tableSchemaData } from "../../store/tableSchemaData";
|
|
4
|
-
import { isNetworkError, isOnline } from "../connection";
|
|
5
2
|
import log from "../logs";
|
|
6
|
-
import {
|
|
3
|
+
import { getRemoteTableSchema } from "../sync/status/remoteSchema";
|
|
7
4
|
import { checkIfTableExist } from "../tableValidator";
|
|
8
5
|
import { mapPgTypeToSQLite } from "./getKeyType";
|
|
9
|
-
import { validatePayload
|
|
10
|
-
let errorCount = new Map();
|
|
11
|
-
async function getTableSchema(table) {
|
|
12
|
-
const config = getSupastashConfig();
|
|
13
|
-
const supabase = config?.supabaseClient;
|
|
14
|
-
if (!supabase) {
|
|
15
|
-
throw new Error(`Supabase client not found, ${supabaseClientErr}`);
|
|
16
|
-
}
|
|
17
|
-
if (tableSchemaData.has(table)) {
|
|
18
|
-
return tableSchemaData.get(table);
|
|
19
|
-
}
|
|
20
|
-
if (errorCount.get(table) && (errorCount.get(table) || 0) > 3) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const isConnected = await isOnline();
|
|
24
|
-
if (!isConnected) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const { data, error } = await supabase.rpc("get_table_schema", {
|
|
28
|
-
table_name: table,
|
|
29
|
-
});
|
|
30
|
-
if (error) {
|
|
31
|
-
if (!isNetworkError(error)) {
|
|
32
|
-
log(`[Supastash] Error getting table schema for table ${table}: ${error.message}`);
|
|
33
|
-
}
|
|
34
|
-
errorCount.set(table, (errorCount.get(table) || 0) + 1);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
if (!data || !Array.isArray(data))
|
|
38
|
-
return null;
|
|
39
|
-
validatePayloadForTable(data);
|
|
40
|
-
tableSchemaData.set(table, data);
|
|
41
|
-
return [
|
|
42
|
-
...data,
|
|
43
|
-
{
|
|
44
|
-
column_name: "synced_at",
|
|
45
|
-
data_type: "text",
|
|
46
|
-
is_nullable: "YES",
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
}
|
|
6
|
+
import { validatePayload } from "./validatePayload";
|
|
50
7
|
/**
|
|
51
8
|
* Creates a table in the database
|
|
52
9
|
* @param table - The name of the table to create
|
|
@@ -58,7 +15,7 @@ export async function createTable(table, payload) {
|
|
|
58
15
|
const isTableExist = await checkIfTableExist(table);
|
|
59
16
|
if (isTableExist)
|
|
60
17
|
return;
|
|
61
|
-
const tableSchema = await
|
|
18
|
+
const tableSchema = await getRemoteTableSchema(table);
|
|
62
19
|
if (!tableSchema) {
|
|
63
20
|
throw new Error(`[Supastash] Can't create table ${table} because no data was found
|
|
64
21
|
Try creating the table manually using the 'defineLocalSchema()' function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteData.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/deleteData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOtD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,OAAc,
|
|
1
|
+
{"version":3,"file":"deleteData.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/deleteData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOtD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,OAAc,iBAwB5B"}
|
|
@@ -14,9 +14,12 @@ export async function deleteData(payload, table, shouldFetch = true) {
|
|
|
14
14
|
if (!payload?.id)
|
|
15
15
|
return;
|
|
16
16
|
// Delete the data
|
|
17
|
-
await permanentlyDeleteData(
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
await permanentlyDeleteData({
|
|
18
|
+
table,
|
|
19
|
+
filters: [{ column: "id", operator: "=", value: payload.id }],
|
|
20
|
+
tx: null,
|
|
21
|
+
throwOnError: true,
|
|
22
|
+
});
|
|
20
23
|
refreshScreen(table);
|
|
21
24
|
}
|
|
22
25
|
catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadData } from "../../types/query.types";
|
|
2
|
-
import {
|
|
2
|
+
import { SupastashFilter } from "../../types/realtimeData.types";
|
|
3
3
|
/**
|
|
4
4
|
* Fetches the local data from the database
|
|
5
5
|
* @param table - The table name to fetch from
|
|
@@ -7,7 +7,7 @@ import { RealtimeFilter } from "../../types/realtimeData.types";
|
|
|
7
7
|
* @param limit - Optional limit for rows
|
|
8
8
|
* @param extraMapKeys - Optional fields to group data by
|
|
9
9
|
*/
|
|
10
|
-
export declare function fetchLocalData<R = any>(table: string, shouldFetch?: boolean, limit?: number, extraMapKeys?: (keyof R)[], daylength?: number, filter?:
|
|
10
|
+
export declare function fetchLocalData<R = any>(table: string, shouldFetch?: boolean, limit?: number, extraMapKeys?: (keyof R)[], daylength?: number, filter?: SupastashFilter[], orderBy?: keyof R | string, orderDesc?: boolean): Promise<{
|
|
11
11
|
data: PayloadData[];
|
|
12
12
|
dataMap: Map<string, PayloadData>;
|
|
13
13
|
groupedBy: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchLocalData.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/fetchLocalData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fetchLocalData.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/fetchLocalData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AA8DjE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1C,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,OAAc,EAC3B,KAAK,GAAE,MAAY,EACnB,YAAY,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EAC1B,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,eAAe,EAAE,EAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,EAC1B,SAAS,GAAE,OAAc,GACxB,OAAO,CAAC;IACT,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClC,SAAS,EAAE;SACR,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;KAC9C,CAAC;CACH,GAAG,IAAI,CAAC,CAiGR"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function initialFetch(table: string, filter?:
|
|
1
|
+
import { SupastashFilter } from "../../types/realtimeData.types";
|
|
2
|
+
export declare function initialFetch(table: string, filter?: SupastashFilter[], onReceiveData?: (payload: any) => Promise<void>, onPushToRemote?: (payload: any[]) => Promise<boolean>): Promise<void>;
|
|
3
3
|
//# sourceMappingURL=initialFetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialFetch.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/initialFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"initialFetch.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/initialFetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAQjE,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,eAAe,EAAE,EAC1B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,EAC/C,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,iBAatD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SupastashFilter } from "../../types/realtimeData.types";
|
|
2
2
|
export declare function parseJSONColumns<R extends Record<string, any>>(row: R): R;
|
|
3
3
|
export declare function sanitizeTableName(table: string): string;
|
|
4
4
|
export declare function sanitizeOrderBy(orderBy: string): string;
|
|
5
|
-
export declare function buildFilters<R = any>(filters:
|
|
5
|
+
export declare function buildFilters<R = any>(filters: SupastashFilter<R>[], table: string, noChecks?: boolean): Promise<string>;
|
|
6
6
|
//# sourceMappingURL=liteHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liteHelpers.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/liteHelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"liteHelpers.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchData/liteHelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAKjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAuBzE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKvD;AAWD,wBAAsB,YAAY,CAAC,CAAC,GAAG,GAAG,EACxC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,MAAM,CAAC,CAoEjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTableSchema } from "../getTableSchema";
|
|
2
2
|
import { logError, logWarn } from "../logs";
|
|
3
|
-
import {
|
|
3
|
+
import { ReusedHelpers } from "../reusedHelpers";
|
|
4
4
|
export function parseJSONColumns(row) {
|
|
5
5
|
const parsedRow = { ...row };
|
|
6
6
|
const errors = [];
|
|
@@ -50,6 +50,18 @@ export async function buildFilters(filters, table, noChecks = false) {
|
|
|
50
50
|
}
|
|
51
51
|
const filterStringArray = [];
|
|
52
52
|
for (const filter of filters) {
|
|
53
|
+
if ("or" in filter) {
|
|
54
|
+
try {
|
|
55
|
+
const filterSql = ReusedHelpers.buildFilterForSql(filter);
|
|
56
|
+
if (filterSql) {
|
|
57
|
+
filterStringArray.push(filterSql);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
logError(`[Supastash] Failed to build OR filter for table ${table}:`, error);
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
53
65
|
if (!filter?.column) {
|
|
54
66
|
logWarn(`[Supastash] Skipping filter with missing column`);
|
|
55
67
|
continue;
|
|
@@ -60,7 +72,7 @@ export async function buildFilters(filters, table, noChecks = false) {
|
|
|
60
72
|
continue;
|
|
61
73
|
}
|
|
62
74
|
try {
|
|
63
|
-
const filterSql = buildFilterForSql(filter);
|
|
75
|
+
const filterSql = ReusedHelpers.buildFilterForSql(filter);
|
|
64
76
|
if (filterSql) {
|
|
65
77
|
filterStringArray.push(filterSql);
|
|
66
78
|
}
|
|
@@ -78,120 +90,3 @@ export async function buildFilters(filters, table, noChecks = false) {
|
|
|
78
90
|
return "";
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
|
-
// export async function fetchData<R = any>({
|
|
82
|
-
// table,
|
|
83
|
-
// options,
|
|
84
|
-
// state,
|
|
85
|
-
// isLoadMore,
|
|
86
|
-
// isRefresh,
|
|
87
|
-
// }: FetchOptions<R>): Promise<FetchResult<R> | null> {
|
|
88
|
-
// const db = await getSupastashDb();
|
|
89
|
-
// const sanitizedTable = sanitizeTableName(table);
|
|
90
|
-
// const sanitizedOrderBy = sanitizeOrderBy(options.orderBy ?? "created_at");
|
|
91
|
-
// const limit = options.pageSize ?? 50;
|
|
92
|
-
// const orderDirection = options.orderDesc === false ? "ASC" : "DESC";
|
|
93
|
-
// const enableCursor = options.enableCursor !== false;
|
|
94
|
-
// try {
|
|
95
|
-
// const filters = await buildFilters(options.sqlFilter ?? [], sanitizedTable);
|
|
96
|
-
// const staleTime = options.staleTime ?? 30000;
|
|
97
|
-
// const isCacheStale = Date.now() - state.lastFetch > staleTime;
|
|
98
|
-
// if (!isRefresh && !isLoadMore && state.data.length > 0 && !isCacheStale) {
|
|
99
|
-
// logWarn(`[Supastash] Using cached data for ${table}`);
|
|
100
|
-
// return null;
|
|
101
|
-
// }
|
|
102
|
-
// let query: string;
|
|
103
|
-
// let params: any[] = [];
|
|
104
|
-
// if (enableCursor && isLoadMore && state.cursor) {
|
|
105
|
-
// const operator = orderDirection === "DESC" ? "<" : ">";
|
|
106
|
-
// const snapshotClause = state.snapshotTime
|
|
107
|
-
// ? ` AND created_at <= '${state.snapshotTime}'`
|
|
108
|
-
// : "";
|
|
109
|
-
// query = `
|
|
110
|
-
// SELECT * FROM ${sanitizedTable}
|
|
111
|
-
// WHERE deleted_at IS NULL${filters}${snapshotClause}
|
|
112
|
-
// AND ${sanitizedOrderBy} ${operator} ?
|
|
113
|
-
// ORDER BY ${sanitizedOrderBy} ${orderDirection}, id ${orderDirection}
|
|
114
|
-
// LIMIT ${limit};
|
|
115
|
-
// `;
|
|
116
|
-
// params = [state.cursor];
|
|
117
|
-
// } else {
|
|
118
|
-
// const snapshotClause =
|
|
119
|
-
// !isRefresh && state.snapshotTime
|
|
120
|
-
// ? ` AND created_at <= '${state.snapshotTime}'`
|
|
121
|
-
// : "";
|
|
122
|
-
// query = `
|
|
123
|
-
// SELECT * FROM ${sanitizedTable}
|
|
124
|
-
// WHERE deleted_at IS NULL${filters}${snapshotClause}
|
|
125
|
-
// ORDER BY ${sanitizedOrderBy} ${orderDirection}, id ${orderDirection}
|
|
126
|
-
// LIMIT ${limit};
|
|
127
|
-
// `;
|
|
128
|
-
// }
|
|
129
|
-
// const rows = await db.getAllAsync(query, params);
|
|
130
|
-
// if (!rows || rows.length === 0) {
|
|
131
|
-
// return {
|
|
132
|
-
// data: [],
|
|
133
|
-
// dataMap: new Map(),
|
|
134
|
-
// groupedBy: undefined,
|
|
135
|
-
// hasMore: false,
|
|
136
|
-
// cursor: null,
|
|
137
|
-
// };
|
|
138
|
-
// }
|
|
139
|
-
// const processed = await processRows<R>(
|
|
140
|
-
// rows,
|
|
141
|
-
// options.extraMapKeys,
|
|
142
|
-
// sanitizedOrderBy
|
|
143
|
-
// );
|
|
144
|
-
// const newCursor =
|
|
145
|
-
// enableCursor && rows.length > 0
|
|
146
|
-
// ? rows[rows.length - 1][sanitizedOrderBy]
|
|
147
|
-
// : null;
|
|
148
|
-
// return {
|
|
149
|
-
// data: processed.parsed,
|
|
150
|
-
// dataMap: processed.dataMap,
|
|
151
|
-
// groupedBy: processed.groupedBy,
|
|
152
|
-
// hasMore: rows.length === limit,
|
|
153
|
-
// cursor: newCursor,
|
|
154
|
-
// };
|
|
155
|
-
// } catch (error) {
|
|
156
|
-
// logError(`[Supastash] Failed to fetch data from ${table}:`, error);
|
|
157
|
-
// throw error;
|
|
158
|
-
// }
|
|
159
|
-
// }
|
|
160
|
-
async function processRows(rows, extraMapKeys, orderByColumn) {
|
|
161
|
-
const parsed = [];
|
|
162
|
-
const dataMap = new Map();
|
|
163
|
-
const groupedBy = {};
|
|
164
|
-
for (const row of rows) {
|
|
165
|
-
try {
|
|
166
|
-
const parsedRow = parseJSONColumns(row);
|
|
167
|
-
parsed.push(parsedRow);
|
|
168
|
-
dataMap.set(row.id, parsedRow);
|
|
169
|
-
if (extraMapKeys?.length) {
|
|
170
|
-
for (const key of extraMapKeys) {
|
|
171
|
-
if (key === "id") {
|
|
172
|
-
logWarn(`[Supastash] Key 'id' is redundant - use dataMap.get(id)`);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (parsedRow[key] == null) {
|
|
176
|
-
logWarn(`[Supastash] Item ${parsedRow.id} missing ${String(key)}`);
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
const groupVal = parsedRow[key];
|
|
180
|
-
if (!groupedBy[key])
|
|
181
|
-
groupedBy[key] = new Map();
|
|
182
|
-
if (!groupedBy[key].has(groupVal))
|
|
183
|
-
groupedBy[key].set(groupVal, []);
|
|
184
|
-
groupedBy[key].get(groupVal).push(parsedRow);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
logError(`[Supastash] Failed to process row:`, error, row);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
parsed,
|
|
194
|
-
dataMap,
|
|
195
|
-
groupedBy: Object.keys(groupedBy).length > 0 ? groupedBy : undefined,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
@@ -2,12 +2,12 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import { getSupastashConfig } from "../../core/config";
|
|
3
3
|
import { supastashEventBus } from "../events/eventBus";
|
|
4
4
|
import { logError } from "../logs";
|
|
5
|
+
import { ReusedHelpers } from "../reusedHelpers";
|
|
5
6
|
import { supabaseClientErr } from "../supabaseClientErr";
|
|
6
|
-
import { buildFilterString } from "./buildFilter";
|
|
7
7
|
const hasRegistered = new Map();
|
|
8
8
|
const useRealtimeData = (table, queueHandler, options, initialized, realtime) => {
|
|
9
9
|
const { lazy, shouldFetch } = options;
|
|
10
|
-
const filterString = useMemo(() => buildFilterString(options.filter), [options.filter]);
|
|
10
|
+
const filterString = useMemo(() => ReusedHelpers.buildFilterString(options.filter), [options.filter]);
|
|
11
11
|
const subKey = useMemo(() => `${table}:${filterString ?? ""}`, [table, filterString]);
|
|
12
12
|
const [version, setVersion] = useState(0);
|
|
13
13
|
useEffect(() => {
|
|
@@ -18,27 +18,27 @@ export default class SupastashCrudBuilder<T extends CrudMethods, U extends boole
|
|
|
18
18
|
* @param data - The data to insert. Could be a single object or an array of objects.
|
|
19
19
|
* @returns filter options.
|
|
20
20
|
*/
|
|
21
|
-
insert<Z = any>(data: R): SupastashFilterBuilder<"insert", false, R, Z>;
|
|
21
|
+
insert<Z = any>(data: R): Omit<SupastashFilterBuilder<"insert", false, R, Z>, "cacheFirst">;
|
|
22
22
|
/**
|
|
23
23
|
* Sets the method to update.
|
|
24
24
|
*
|
|
25
25
|
* @param data - The data to update.
|
|
26
26
|
* @returns filter options.
|
|
27
27
|
*/
|
|
28
|
-
update<Z = any>(data: R): SupastashFilterBuilder<"update", false, R, Z>;
|
|
28
|
+
update<Z = any>(data: R): Omit<SupastashFilterBuilder<"update", false, R, Z>, "cacheFirst" | "run" | "go" | "execute">;
|
|
29
29
|
/**
|
|
30
30
|
* Sets the method to delete.
|
|
31
31
|
*
|
|
32
32
|
* @returns filter options.
|
|
33
33
|
*/
|
|
34
|
-
delete<Z = any>(): SupastashFilterBuilder<"delete", false, R, Z>;
|
|
34
|
+
delete<Z = any>(): Omit<SupastashFilterBuilder<"delete", false, R, Z>, "cacheFirst">;
|
|
35
35
|
/**
|
|
36
36
|
* Sets the method to select.
|
|
37
37
|
*
|
|
38
38
|
* @param column - The column to select.
|
|
39
39
|
* @returns filter options.
|
|
40
40
|
*/
|
|
41
|
-
select<Z = any>(column?: string): SupastashFilterBuilder<"select", false, R, Z>;
|
|
41
|
+
select<Z = any>(column?: string): Omit<SupastashFilterBuilder<"select", false, R, Z>, "withTx">;
|
|
42
42
|
/**
|
|
43
43
|
* Sets the method to upsert.
|
|
44
44
|
*
|
|
@@ -59,6 +59,6 @@ export default class SupastashCrudBuilder<T extends CrudMethods, U extends boole
|
|
|
59
59
|
*/
|
|
60
60
|
upsert<Z = any>(data: R | R[], options?: {
|
|
61
61
|
onConflictKeys?: string[];
|
|
62
|
-
}): SupastashFilterBuilder<"upsert", false, R, Z>;
|
|
62
|
+
}): Omit<SupastashFilterBuilder<"upsert", false, R, Z>, "cacheFirst">;
|
|
63
63
|
}
|
|
64
64
|
//# sourceMappingURL=crud.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../../src/utils/query/builder/crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,sBAAsB,MAAM,WAAW,CAAC;AAE/C;;;;GAIG;AAEH,MAAM,CAAC,OAAO,OAAO,oBAAoB,CACvC,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,OAAO,EACjB,CAAC;IAMW,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJlC;;;OAGG;gBAC0B,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../../src/utils/query/builder/crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,sBAAsB,MAAM,WAAW,CAAC;AAE/C;;;;GAIG;AAEH,MAAM,CAAC,OAAO,OAAO,oBAAoB,CACvC,CAAC,SAAS,WAAW,EACrB,CAAC,SAAS,OAAO,EACjB,CAAC;IAMW,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJlC;;;OAGG;gBAC0B,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAQhB,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC;IAGxE;;;;;OAKG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAQhB,IAAI,CACP,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7C,YAAY,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CACxC;IAGH;;;;OAIG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,KAOP,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC;IAGxE;;;;;OAKG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,GAQxB,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC;IAGpE;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAS/D,IAAI,CAAC,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC;CAEzE"}
|