@pol-studios/db 1.0.21 → 1.0.23
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/dist/auth/context.js +2 -2
- package/dist/auth/hooks.js +3 -3
- package/dist/auth/index.js +3 -3
- package/dist/{chunk-R5B2XMN5.js → chunk-3L4HOEXV.js} +1614 -2141
- package/dist/chunk-3L4HOEXV.js.map +1 -0
- package/dist/{chunk-72WV3ALS.js → chunk-3UYBZHEV.js} +2 -2
- package/dist/{chunk-X3HZLNBV.js → chunk-BXSOHOQ2.js} +54 -985
- package/dist/chunk-BXSOHOQ2.js.map +1 -0
- package/dist/{chunk-N26IEHZT.js → chunk-FZF26ZRB.js} +18 -2
- package/dist/{chunk-N26IEHZT.js.map → chunk-FZF26ZRB.js.map} +1 -1
- package/dist/chunk-HTJ2FQW5.js +963 -0
- package/dist/chunk-HTJ2FQW5.js.map +1 -0
- package/dist/{chunk-2T6WTCP4.js → chunk-KDORWXGS.js} +69 -154
- package/dist/chunk-KDORWXGS.js.map +1 -0
- package/dist/{chunk-36DVUMQD.js → chunk-MBU4KE3V.js} +2 -2
- package/dist/{chunk-YERWPV6B.js → chunk-Q7WJEOQ5.js} +150 -19
- package/dist/chunk-Q7WJEOQ5.js.map +1 -0
- package/dist/{chunk-RMRYGICS.js → chunk-TSXQTYUG.js} +4 -4
- package/dist/core/index.d.ts +30 -1
- package/dist/hooks/index.d.ts +20 -1
- package/dist/hooks/index.js +1 -1
- package/dist/{index-BNKhgDdC.d.ts → index-2YySlz7X.d.ts} +3 -3
- package/dist/index.d.ts +11 -12
- package/dist/index.js +14 -95
- package/dist/index.native.d.ts +12 -30
- package/dist/index.native.js +17 -96
- package/dist/index.web.d.ts +132 -15
- package/dist/index.web.js +585 -46
- package/dist/index.web.js.map +1 -1
- package/dist/powersync-bridge/index.d.ts +1 -1
- package/dist/powersync-bridge/index.js +1 -1
- package/dist/query/index.js +10 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/{useDbCount-Id14x_1P.d.ts → useDbCount-s-aR9YeV.d.ts} +1 -1
- package/dist/{useResolveFeedback-Ca2rh_Bs.d.ts → useResolveFeedback-DTGcHpCs.d.ts} +275 -390
- package/dist/with-auth/index.js +4 -4
- package/package.json +13 -12
- package/dist/chunk-2T6WTCP4.js.map +0 -1
- package/dist/chunk-R5B2XMN5.js.map +0 -1
- package/dist/chunk-X3HZLNBV.js.map +0 -1
- package/dist/chunk-YERWPV6B.js.map +0 -1
- /package/dist/{chunk-72WV3ALS.js.map → chunk-3UYBZHEV.js.map} +0 -0
- /package/dist/{chunk-36DVUMQD.js.map → chunk-MBU4KE3V.js.map} +0 -0
- /package/dist/{chunk-RMRYGICS.js.map → chunk-TSXQTYUG.js.map} +0 -0
package/dist/index.web.js
CHANGED
|
@@ -25,16 +25,11 @@ import {
|
|
|
25
25
|
useChangelogEntries,
|
|
26
26
|
useChangelogMedia,
|
|
27
27
|
useChangelogs,
|
|
28
|
-
useDbDelete,
|
|
29
|
-
useDbInfiniteQuery,
|
|
30
|
-
useDbInsert,
|
|
28
|
+
useDbDelete as useDbDelete2,
|
|
31
29
|
useDbMultiDelete,
|
|
32
30
|
useDbMultiUpsert,
|
|
33
|
-
useDbPartialAdvanceQuery,
|
|
34
|
-
useDbPartialQuery,
|
|
35
31
|
useDbRealtime,
|
|
36
32
|
useDbRealtimeQuery,
|
|
37
|
-
useDbUpdate,
|
|
38
33
|
useDeleteChangelog,
|
|
39
34
|
useDeleteChangelogEntry,
|
|
40
35
|
useDeleteChangelogMedia,
|
|
@@ -57,7 +52,7 @@ import {
|
|
|
57
52
|
useUpsertChangelog,
|
|
58
53
|
useUpsertChangelogEntry,
|
|
59
54
|
useUpsertChangelogMedia
|
|
60
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-3L4HOEXV.js";
|
|
61
56
|
import {
|
|
62
57
|
LiveChangeContext,
|
|
63
58
|
LiveChangeContextProvider,
|
|
@@ -68,7 +63,7 @@ import {
|
|
|
68
63
|
useUserMetadataState,
|
|
69
64
|
useUserMetadataValue,
|
|
70
65
|
userMetadataContext
|
|
71
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-TSXQTYUG.js";
|
|
72
67
|
import {
|
|
73
68
|
PostgrestFilter,
|
|
74
69
|
binarySearch,
|
|
@@ -291,28 +286,36 @@ import {
|
|
|
291
286
|
UserMetadata
|
|
292
287
|
} from "./chunk-SM73S2DY.js";
|
|
293
288
|
import "./chunk-NSIAAYW3.js";
|
|
294
|
-
import "./chunk-
|
|
289
|
+
import "./chunk-MBU4KE3V.js";
|
|
295
290
|
import {
|
|
296
291
|
DEFAULT_QUERY_TIMEOUT,
|
|
297
292
|
TIMEOUT_ERROR_MESSAGE,
|
|
298
293
|
isTimeoutError,
|
|
299
|
-
useDbQuery
|
|
300
|
-
} from "./chunk-
|
|
294
|
+
useDbQuery as useDbQuery2
|
|
295
|
+
} from "./chunk-3UYBZHEV.js";
|
|
301
296
|
import {
|
|
302
297
|
DataLayerContext,
|
|
303
298
|
useAdvanceQuery,
|
|
304
299
|
useDataLayer,
|
|
305
300
|
useDataLayerOptional,
|
|
306
301
|
useDbCount,
|
|
307
|
-
useDbDelete
|
|
308
|
-
useDbInfiniteQuery
|
|
309
|
-
useDbInsert
|
|
310
|
-
useDbQuery
|
|
302
|
+
useDbDelete,
|
|
303
|
+
useDbInfiniteQuery,
|
|
304
|
+
useDbInsert,
|
|
305
|
+
useDbQuery,
|
|
311
306
|
useDbQueryById,
|
|
312
|
-
useDbUpdate
|
|
307
|
+
useDbUpdate,
|
|
313
308
|
useDbUpsert
|
|
314
|
-
} from "./chunk-
|
|
309
|
+
} from "./chunk-Q7WJEOQ5.js";
|
|
315
310
|
import "./chunk-HAWJTZCK.js";
|
|
311
|
+
import {
|
|
312
|
+
useAdvancedFilterQuery,
|
|
313
|
+
useAdvancedQuery,
|
|
314
|
+
useInfiniteQuery,
|
|
315
|
+
usePartialAdvancedQuery,
|
|
316
|
+
usePartialQuery,
|
|
317
|
+
useQuery
|
|
318
|
+
} from "./chunk-HTJ2FQW5.js";
|
|
316
319
|
import {
|
|
317
320
|
QueryExecutor,
|
|
318
321
|
RelationshipResolver,
|
|
@@ -328,14 +331,8 @@ import {
|
|
|
328
331
|
hasRelation,
|
|
329
332
|
parseSelect,
|
|
330
333
|
stringifySelect,
|
|
331
|
-
tokenizeTopLevel
|
|
332
|
-
|
|
333
|
-
useAdvancedQuery,
|
|
334
|
-
useInfiniteQuery,
|
|
335
|
-
usePartialAdvancedQuery,
|
|
336
|
-
usePartialQuery,
|
|
337
|
-
useQuery
|
|
338
|
-
} from "./chunk-X3HZLNBV.js";
|
|
334
|
+
tokenizeTopLevel
|
|
335
|
+
} from "./chunk-BXSOHOQ2.js";
|
|
339
336
|
import {
|
|
340
337
|
getSupabaseUrl,
|
|
341
338
|
setSupabaseUrl
|
|
@@ -359,8 +356,15 @@ import {
|
|
|
359
356
|
sortSearchParams
|
|
360
357
|
} from "./chunk-TKWR5AAY.js";
|
|
361
358
|
import "./chunk-J4ZVCXZ4.js";
|
|
362
|
-
import
|
|
363
|
-
|
|
359
|
+
import {
|
|
360
|
+
isUsable,
|
|
361
|
+
omit
|
|
362
|
+
} from "./chunk-OQ7U6EQ3.js";
|
|
363
|
+
import {
|
|
364
|
+
encode,
|
|
365
|
+
useInsertMutation,
|
|
366
|
+
useUpsertItem
|
|
367
|
+
} from "./chunk-H6365JPC.js";
|
|
364
368
|
import "./chunk-3PJTNH2L.js";
|
|
365
369
|
import {
|
|
366
370
|
ClientInstanceId,
|
|
@@ -373,8 +377,528 @@ import {
|
|
|
373
377
|
} from "./chunk-5EFDS7SR.js";
|
|
374
378
|
import "./chunk-P4UZ7IXC.js";
|
|
375
379
|
|
|
380
|
+
// src/useDbInfiniteQuery.ts
|
|
381
|
+
import { useInfiniteQuery as useInfiniteQuery2 } from "@tanstack/react-query";
|
|
382
|
+
import { useMemo, useRef } from "react";
|
|
383
|
+
function useDbInfiniteQuery2(query, countPerLoad, config) {
|
|
384
|
+
const initialQueryKey = encode(query, false).join("-");
|
|
385
|
+
const lastKnownQuery = useRef(initialQueryKey);
|
|
386
|
+
const currentPageNumber = useRef(1);
|
|
387
|
+
if (lastKnownQuery.current != initialQueryKey) {
|
|
388
|
+
lastKnownQuery.current = initialQueryKey;
|
|
389
|
+
currentPageNumber.current = 1;
|
|
390
|
+
}
|
|
391
|
+
const isFetching = useRef(false);
|
|
392
|
+
const queryKey = useMemo(() => encode(query, false), [initialQueryKey, config?.crossOrganization]);
|
|
393
|
+
const getQuery = useInfiniteQuery2({
|
|
394
|
+
...config,
|
|
395
|
+
queryKey,
|
|
396
|
+
queryFn: async ({
|
|
397
|
+
pageParam,
|
|
398
|
+
signal
|
|
399
|
+
}) => {
|
|
400
|
+
let adjustableQuery = query;
|
|
401
|
+
const pageNumber = pageParam;
|
|
402
|
+
if (config?.onQuery && config?.enableOnQuery) {
|
|
403
|
+
config?.onQuery({
|
|
404
|
+
query: adjustableQuery,
|
|
405
|
+
pageParam: pageNumber
|
|
406
|
+
});
|
|
407
|
+
} else {
|
|
408
|
+
adjustableQuery = adjustableQuery.range((pageNumber - 1) * countPerLoad, pageNumber * countPerLoad - 1);
|
|
409
|
+
}
|
|
410
|
+
adjustableQuery = adjustableQuery.abortSignal(signal);
|
|
411
|
+
updatedCache.current = false;
|
|
412
|
+
const response = await adjustableQuery;
|
|
413
|
+
currentPageNumber.current = pageNumber;
|
|
414
|
+
if (response.error) {
|
|
415
|
+
throw response.error;
|
|
416
|
+
} else {
|
|
417
|
+
return response;
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
initialPageParam: 1,
|
|
421
|
+
getNextPageParam: (response_0, allResponses, lastParam) => {
|
|
422
|
+
const pageParam_0 = lastParam;
|
|
423
|
+
const resp = response_0;
|
|
424
|
+
if (allResponses.length * countPerLoad >= (resp?.count ?? 0)) {
|
|
425
|
+
return void 0;
|
|
426
|
+
}
|
|
427
|
+
return pageParam_0 + 1;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
const updatedCache = useRef(true);
|
|
431
|
+
return useMemo(() => {
|
|
432
|
+
const pages = getQuery.data?.pages;
|
|
433
|
+
return {
|
|
434
|
+
...getQuery,
|
|
435
|
+
count: pages?.[pages.length - 1]?.count,
|
|
436
|
+
data: pages?.flatMap((x) => x.data ?? [])
|
|
437
|
+
};
|
|
438
|
+
}, [getQuery.data, currentPageNumber.current]);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/useDbInsert.ts
|
|
442
|
+
import { c as _c } from "react/compiler-runtime";
|
|
443
|
+
import { useMutation } from "@tanstack/react-query";
|
|
444
|
+
function useDbInsert2(relation, t0, query, mutationOption) {
|
|
445
|
+
const $ = _c(11);
|
|
446
|
+
let t1;
|
|
447
|
+
if ($[0] !== t0) {
|
|
448
|
+
t1 = t0 === void 0 ? ["id"] : t0;
|
|
449
|
+
$[0] = t0;
|
|
450
|
+
$[1] = t1;
|
|
451
|
+
} else {
|
|
452
|
+
t1 = $[1];
|
|
453
|
+
}
|
|
454
|
+
const primaryKeys = t1;
|
|
455
|
+
const supabase = useSupabase();
|
|
456
|
+
const tableName = typeof relation === "object" ? relation.table : relation;
|
|
457
|
+
const schemaName = typeof relation === "object" ? String(relation.schema) : "public";
|
|
458
|
+
let t2;
|
|
459
|
+
if ($[2] !== primaryKeys) {
|
|
460
|
+
t2 = primaryKeys.map(_temp);
|
|
461
|
+
$[2] = primaryKeys;
|
|
462
|
+
$[3] = t2;
|
|
463
|
+
} else {
|
|
464
|
+
t2 = $[3];
|
|
465
|
+
}
|
|
466
|
+
const primaryKeysAsStrings = t2;
|
|
467
|
+
const t3 = supabase;
|
|
468
|
+
let t4;
|
|
469
|
+
if ($[4] !== schemaName || $[5] !== t3 || $[6] !== tableName) {
|
|
470
|
+
t4 = t3.schema(schemaName).from(tableName);
|
|
471
|
+
$[4] = schemaName;
|
|
472
|
+
$[5] = t3;
|
|
473
|
+
$[6] = tableName;
|
|
474
|
+
$[7] = t4;
|
|
475
|
+
} else {
|
|
476
|
+
t4 = $[7];
|
|
477
|
+
}
|
|
478
|
+
const mutation = useInsertMutation(t4, primaryKeysAsStrings, query, mutationOption);
|
|
479
|
+
let t5;
|
|
480
|
+
if ($[8] !== mutation || $[9] !== primaryKeys) {
|
|
481
|
+
t5 = {
|
|
482
|
+
mutationFn: async (item) => {
|
|
483
|
+
const primaryKeysNull = primaryKeys.filter((x) => x in item === false || isUsable(item[x]) === false).map(_temp2);
|
|
484
|
+
const response = await mutation.mutateAsync([omit(item, primaryKeysNull)]);
|
|
485
|
+
mutation.reset();
|
|
486
|
+
return response?.[0];
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
$[8] = mutation;
|
|
490
|
+
$[9] = primaryKeys;
|
|
491
|
+
$[10] = t5;
|
|
492
|
+
} else {
|
|
493
|
+
t5 = $[10];
|
|
494
|
+
}
|
|
495
|
+
const updateMutation = useMutation(t5);
|
|
496
|
+
return updateMutation;
|
|
497
|
+
}
|
|
498
|
+
function _temp2(k_0) {
|
|
499
|
+
return String(k_0);
|
|
500
|
+
}
|
|
501
|
+
function _temp(k) {
|
|
502
|
+
return String(k);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/useDbPartialAdvanceQuery.ts
|
|
506
|
+
import { c as _c2 } from "react/compiler-runtime";
|
|
507
|
+
import { useLayoutEffect, useState } from "react";
|
|
508
|
+
import { useSessionStorageState } from "@pol-studios/hooks/storage";
|
|
509
|
+
function useDbPartialAdvanceQuery(query, itemCountPerPage, config) {
|
|
510
|
+
const $ = _c2(54);
|
|
511
|
+
const initialQuery = encode(query, false);
|
|
512
|
+
const [id, setId] = useState(window.location.pathname);
|
|
513
|
+
const [currentPage, setCurrentPage] = useSessionStorageState(`${id}-currentPage`, 1);
|
|
514
|
+
const page = currentPage ?? 1;
|
|
515
|
+
const t0 = query;
|
|
516
|
+
let t1;
|
|
517
|
+
if ($[0] !== itemCountPerPage || $[1] !== page || $[2] !== t0) {
|
|
518
|
+
t1 = t0.range((page - 1) * itemCountPerPage, page * itemCountPerPage - 1);
|
|
519
|
+
$[0] = itemCountPerPage;
|
|
520
|
+
$[1] = page;
|
|
521
|
+
$[2] = t0;
|
|
522
|
+
$[3] = t1;
|
|
523
|
+
} else {
|
|
524
|
+
t1 = $[3];
|
|
525
|
+
}
|
|
526
|
+
const rangedQuery = t1;
|
|
527
|
+
const t2 = config?.filterKey;
|
|
528
|
+
const t3 = currentPage ?? 1;
|
|
529
|
+
let t4;
|
|
530
|
+
if ($[4] !== t3) {
|
|
531
|
+
t4 = t3.toString();
|
|
532
|
+
$[4] = t3;
|
|
533
|
+
$[5] = t4;
|
|
534
|
+
} else {
|
|
535
|
+
t4 = $[5];
|
|
536
|
+
}
|
|
537
|
+
let t5;
|
|
538
|
+
if ($[6] !== config || $[7] !== t2 || $[8] !== t4) {
|
|
539
|
+
t5 = {
|
|
540
|
+
...config,
|
|
541
|
+
filterKey: t2,
|
|
542
|
+
count: "exact",
|
|
543
|
+
key: t4
|
|
544
|
+
};
|
|
545
|
+
$[6] = config;
|
|
546
|
+
$[7] = t2;
|
|
547
|
+
$[8] = t4;
|
|
548
|
+
$[9] = t5;
|
|
549
|
+
} else {
|
|
550
|
+
t5 = $[9];
|
|
551
|
+
}
|
|
552
|
+
const [baseQuery, filter, setFilters] = useDbAdvanceFilterQuery(rangedQuery, t5);
|
|
553
|
+
let t6;
|
|
554
|
+
if ($[10] !== filter) {
|
|
555
|
+
t6 = JSON.stringify(omit(filter, ["pagination"]));
|
|
556
|
+
$[10] = filter;
|
|
557
|
+
$[11] = t6;
|
|
558
|
+
} else {
|
|
559
|
+
t6 = $[11];
|
|
560
|
+
}
|
|
561
|
+
const filterKey = t6;
|
|
562
|
+
const select = initialQuery[4].split("&").find(_temp4);
|
|
563
|
+
let t7;
|
|
564
|
+
if ($[12] !== filterKey || $[13] !== id || $[14] !== initialQuery[3] || $[15] !== initialQuery[5] || $[16] !== initialQuery[6] || $[17] !== initialQuery[7] || $[18] !== initialQuery[8] || $[19] !== select || $[20] !== setId) {
|
|
565
|
+
t7 = () => {
|
|
566
|
+
const newId = [initialQuery[3], select, initialQuery[5], initialQuery[6], initialQuery[7], initialQuery[8], filterKey].join("-");
|
|
567
|
+
console.log({
|
|
568
|
+
newId,
|
|
569
|
+
id
|
|
570
|
+
});
|
|
571
|
+
setId(newId);
|
|
572
|
+
};
|
|
573
|
+
$[12] = filterKey;
|
|
574
|
+
$[13] = id;
|
|
575
|
+
$[14] = initialQuery[3];
|
|
576
|
+
$[15] = initialQuery[5];
|
|
577
|
+
$[16] = initialQuery[6];
|
|
578
|
+
$[17] = initialQuery[7];
|
|
579
|
+
$[18] = initialQuery[8];
|
|
580
|
+
$[19] = select;
|
|
581
|
+
$[20] = setId;
|
|
582
|
+
$[21] = t7;
|
|
583
|
+
} else {
|
|
584
|
+
t7 = $[21];
|
|
585
|
+
}
|
|
586
|
+
let t8;
|
|
587
|
+
if ($[22] !== filterKey || $[23] !== initialQuery[3] || $[24] !== initialQuery[5] || $[25] !== initialQuery[6] || $[26] !== initialQuery[7] || $[27] !== initialQuery[8] || $[28] !== select) {
|
|
588
|
+
t8 = [initialQuery[3], select, initialQuery[5], initialQuery[6], initialQuery[7], initialQuery[8], filterKey];
|
|
589
|
+
$[22] = filterKey;
|
|
590
|
+
$[23] = initialQuery[3];
|
|
591
|
+
$[24] = initialQuery[5];
|
|
592
|
+
$[25] = initialQuery[6];
|
|
593
|
+
$[26] = initialQuery[7];
|
|
594
|
+
$[27] = initialQuery[8];
|
|
595
|
+
$[28] = select;
|
|
596
|
+
$[29] = t8;
|
|
597
|
+
} else {
|
|
598
|
+
t8 = $[29];
|
|
599
|
+
}
|
|
600
|
+
useLayoutEffect(t7, t8);
|
|
601
|
+
let t9;
|
|
602
|
+
if ($[30] !== setCurrentPage) {
|
|
603
|
+
t9 = () => {
|
|
604
|
+
setCurrentPage(_temp22);
|
|
605
|
+
};
|
|
606
|
+
$[30] = setCurrentPage;
|
|
607
|
+
$[31] = t9;
|
|
608
|
+
} else {
|
|
609
|
+
t9 = $[31];
|
|
610
|
+
}
|
|
611
|
+
const safeFetchNextPage = t9;
|
|
612
|
+
let t10;
|
|
613
|
+
if ($[32] !== setCurrentPage) {
|
|
614
|
+
t10 = () => {
|
|
615
|
+
setCurrentPage(_temp3);
|
|
616
|
+
};
|
|
617
|
+
$[32] = setCurrentPage;
|
|
618
|
+
$[33] = t10;
|
|
619
|
+
} else {
|
|
620
|
+
t10 = $[33];
|
|
621
|
+
}
|
|
622
|
+
const fetchPreviousPage = t10;
|
|
623
|
+
const pageCount = Math.max(Math.ceil((baseQuery.count ?? 0) / itemCountPerPage), 1);
|
|
624
|
+
const t11 = currentPage ?? 1;
|
|
625
|
+
let t12;
|
|
626
|
+
if ($[34] !== baseQuery.count || $[35] !== baseQuery.data || $[36] !== currentPage || $[37] !== itemCountPerPage) {
|
|
627
|
+
t12 = baseQuery.data ? toPagedResponse(baseQuery.data, currentPage ?? 1, baseQuery.count ?? baseQuery.data.length, itemCountPerPage) : null;
|
|
628
|
+
$[34] = baseQuery.count;
|
|
629
|
+
$[35] = baseQuery.data;
|
|
630
|
+
$[36] = currentPage;
|
|
631
|
+
$[37] = itemCountPerPage;
|
|
632
|
+
$[38] = t12;
|
|
633
|
+
} else {
|
|
634
|
+
t12 = $[38];
|
|
635
|
+
}
|
|
636
|
+
const t13 = (currentPage ?? 1) < pageCount;
|
|
637
|
+
const t14 = (currentPage ?? 1) > 1;
|
|
638
|
+
const t15 = baseQuery.count ?? baseQuery.data?.length;
|
|
639
|
+
let t16;
|
|
640
|
+
if ($[39] !== baseQuery || $[40] !== fetchPreviousPage || $[41] !== pageCount || $[42] !== safeFetchNextPage || $[43] !== setCurrentPage || $[44] !== t11 || $[45] !== t12 || $[46] !== t13 || $[47] !== t14 || $[48] !== t15) {
|
|
641
|
+
t16 = {
|
|
642
|
+
...baseQuery,
|
|
643
|
+
clarification: baseQuery.clarification,
|
|
644
|
+
fetchPreviousPage,
|
|
645
|
+
fetchNextPage: safeFetchNextPage,
|
|
646
|
+
currentPage: t11,
|
|
647
|
+
setCurrentPage,
|
|
648
|
+
data: t12,
|
|
649
|
+
pageCount,
|
|
650
|
+
hasNextPage: t13,
|
|
651
|
+
hasPreviousPage: t14,
|
|
652
|
+
count: t15
|
|
653
|
+
};
|
|
654
|
+
$[39] = baseQuery;
|
|
655
|
+
$[40] = fetchPreviousPage;
|
|
656
|
+
$[41] = pageCount;
|
|
657
|
+
$[42] = safeFetchNextPage;
|
|
658
|
+
$[43] = setCurrentPage;
|
|
659
|
+
$[44] = t11;
|
|
660
|
+
$[45] = t12;
|
|
661
|
+
$[46] = t13;
|
|
662
|
+
$[47] = t14;
|
|
663
|
+
$[48] = t15;
|
|
664
|
+
$[49] = t16;
|
|
665
|
+
} else {
|
|
666
|
+
t16 = $[49];
|
|
667
|
+
}
|
|
668
|
+
const request = t16;
|
|
669
|
+
let t17;
|
|
670
|
+
if ($[50] !== filter || $[51] !== request || $[52] !== setFilters) {
|
|
671
|
+
t17 = [request, filter, setFilters];
|
|
672
|
+
$[50] = filter;
|
|
673
|
+
$[51] = request;
|
|
674
|
+
$[52] = setFilters;
|
|
675
|
+
$[53] = t17;
|
|
676
|
+
} else {
|
|
677
|
+
t17 = $[53];
|
|
678
|
+
}
|
|
679
|
+
return t17;
|
|
680
|
+
}
|
|
681
|
+
function _temp3(currentPage_1) {
|
|
682
|
+
return (currentPage_1 ?? 1) - 1;
|
|
683
|
+
}
|
|
684
|
+
function _temp22(currentPage_0) {
|
|
685
|
+
return (currentPage_0 ?? 1) + 1;
|
|
686
|
+
}
|
|
687
|
+
function _temp4(x) {
|
|
688
|
+
return x.startsWith("select=");
|
|
689
|
+
}
|
|
690
|
+
function toPagedResponse(results, currentPage, totalCount, itemPerPage) {
|
|
691
|
+
const newPage = {
|
|
692
|
+
Items: results,
|
|
693
|
+
CurrentPage: currentPage,
|
|
694
|
+
ItemCount: totalCount,
|
|
695
|
+
MaxCountPerPage: itemPerPage,
|
|
696
|
+
PageCount: Math.max(Math.ceil(totalCount / itemPerPage), 1)
|
|
697
|
+
};
|
|
698
|
+
return newPage;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/useDbPartialQuery.ts
|
|
702
|
+
import { c as _c3 } from "react/compiler-runtime";
|
|
703
|
+
import { useSessionStorageState as useSessionStorageState2 } from "@pol-studios/hooks/storage";
|
|
704
|
+
function useDbPartialQuery(query, itemCountPerPage, config) {
|
|
705
|
+
const $ = _c3(28);
|
|
706
|
+
let t0;
|
|
707
|
+
if ($[0] !== query) {
|
|
708
|
+
t0 = encode(query, false);
|
|
709
|
+
$[0] = query;
|
|
710
|
+
$[1] = t0;
|
|
711
|
+
} else {
|
|
712
|
+
t0 = $[1];
|
|
713
|
+
}
|
|
714
|
+
const initialQuery = t0;
|
|
715
|
+
let t1;
|
|
716
|
+
if ($[2] !== initialQuery[7] || $[3] !== initialQuery[8]) {
|
|
717
|
+
t1 = [initialQuery[7], initialQuery[8]];
|
|
718
|
+
$[2] = initialQuery[7];
|
|
719
|
+
$[3] = initialQuery[8];
|
|
720
|
+
$[4] = t1;
|
|
721
|
+
} else {
|
|
722
|
+
t1 = $[4];
|
|
723
|
+
}
|
|
724
|
+
const id = t1.join("-");
|
|
725
|
+
const [currentPage, setCurrentPage] = useSessionStorageState2(id, 1);
|
|
726
|
+
const page = currentPage ?? 1;
|
|
727
|
+
const t2 = query;
|
|
728
|
+
let t3;
|
|
729
|
+
if ($[5] !== itemCountPerPage || $[6] !== page || $[7] !== t2) {
|
|
730
|
+
t3 = t2.range((page - 1) * itemCountPerPage, page * itemCountPerPage - 1);
|
|
731
|
+
$[5] = itemCountPerPage;
|
|
732
|
+
$[6] = page;
|
|
733
|
+
$[7] = t2;
|
|
734
|
+
$[8] = t3;
|
|
735
|
+
} else {
|
|
736
|
+
t3 = $[8];
|
|
737
|
+
}
|
|
738
|
+
const rangedQuery = t3;
|
|
739
|
+
const baseQuery = useDbQuery2(rangedQuery, config);
|
|
740
|
+
let t4;
|
|
741
|
+
if ($[9] !== setCurrentPage) {
|
|
742
|
+
t4 = () => {
|
|
743
|
+
setCurrentPage(_temp5);
|
|
744
|
+
};
|
|
745
|
+
$[9] = setCurrentPage;
|
|
746
|
+
$[10] = t4;
|
|
747
|
+
} else {
|
|
748
|
+
t4 = $[10];
|
|
749
|
+
}
|
|
750
|
+
const safeFetchNextPage = t4;
|
|
751
|
+
let t5;
|
|
752
|
+
if ($[11] !== setCurrentPage) {
|
|
753
|
+
t5 = () => {
|
|
754
|
+
setCurrentPage(_temp23);
|
|
755
|
+
};
|
|
756
|
+
$[11] = setCurrentPage;
|
|
757
|
+
$[12] = t5;
|
|
758
|
+
} else {
|
|
759
|
+
t5 = $[12];
|
|
760
|
+
}
|
|
761
|
+
const fetchPreviousPage = t5;
|
|
762
|
+
const pageCount = Math.max(Math.ceil((baseQuery.count ?? 0) / itemCountPerPage), 1);
|
|
763
|
+
const t6 = currentPage ?? 1;
|
|
764
|
+
let t7;
|
|
765
|
+
if ($[13] !== baseQuery.count || $[14] !== baseQuery.data || $[15] !== currentPage || $[16] !== itemCountPerPage) {
|
|
766
|
+
t7 = baseQuery.data ? toPagedResponse2(baseQuery.data, currentPage ?? 1, baseQuery.count ?? baseQuery.data.length, itemCountPerPage) : null;
|
|
767
|
+
$[13] = baseQuery.count;
|
|
768
|
+
$[14] = baseQuery.data;
|
|
769
|
+
$[15] = currentPage;
|
|
770
|
+
$[16] = itemCountPerPage;
|
|
771
|
+
$[17] = t7;
|
|
772
|
+
} else {
|
|
773
|
+
t7 = $[17];
|
|
774
|
+
}
|
|
775
|
+
const t8 = (currentPage ?? 1) < pageCount;
|
|
776
|
+
const t9 = (currentPage ?? 1) > 1;
|
|
777
|
+
let t10;
|
|
778
|
+
if ($[18] !== baseQuery || $[19] !== fetchPreviousPage || $[20] !== pageCount || $[21] !== safeFetchNextPage || $[22] !== setCurrentPage || $[23] !== t6 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9) {
|
|
779
|
+
t10 = {
|
|
780
|
+
...baseQuery,
|
|
781
|
+
fetchPreviousPage,
|
|
782
|
+
fetchNextPage: safeFetchNextPage,
|
|
783
|
+
currentPage: t6,
|
|
784
|
+
setCurrentPage,
|
|
785
|
+
data: t7,
|
|
786
|
+
pageCount,
|
|
787
|
+
hasNextPage: t8,
|
|
788
|
+
hasPreviousPage: t9
|
|
789
|
+
};
|
|
790
|
+
$[18] = baseQuery;
|
|
791
|
+
$[19] = fetchPreviousPage;
|
|
792
|
+
$[20] = pageCount;
|
|
793
|
+
$[21] = safeFetchNextPage;
|
|
794
|
+
$[22] = setCurrentPage;
|
|
795
|
+
$[23] = t6;
|
|
796
|
+
$[24] = t7;
|
|
797
|
+
$[25] = t8;
|
|
798
|
+
$[26] = t9;
|
|
799
|
+
$[27] = t10;
|
|
800
|
+
} else {
|
|
801
|
+
t10 = $[27];
|
|
802
|
+
}
|
|
803
|
+
return t10;
|
|
804
|
+
}
|
|
805
|
+
function _temp23(currentPage_1) {
|
|
806
|
+
return currentPage_1 - 1;
|
|
807
|
+
}
|
|
808
|
+
function _temp5(currentPage_0) {
|
|
809
|
+
return currentPage_0 + 1;
|
|
810
|
+
}
|
|
811
|
+
function toPagedResponse2(results, currentPage, totalCount, itemPerPage) {
|
|
812
|
+
const newPage = {
|
|
813
|
+
Items: results,
|
|
814
|
+
CurrentPage: currentPage,
|
|
815
|
+
ItemCount: totalCount,
|
|
816
|
+
MaxCountPerPage: itemPerPage,
|
|
817
|
+
PageCount: Math.max(Math.ceil(totalCount / itemPerPage), 1)
|
|
818
|
+
};
|
|
819
|
+
return newPage;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// src/useDbUpdate.ts
|
|
823
|
+
import { c as _c4 } from "react/compiler-runtime";
|
|
824
|
+
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
825
|
+
function useDbUpdate2(relation, t0, query, mutationOption) {
|
|
826
|
+
const $ = _c4(14);
|
|
827
|
+
let t1;
|
|
828
|
+
if ($[0] !== t0) {
|
|
829
|
+
t1 = t0 === void 0 ? ["id"] : t0;
|
|
830
|
+
$[0] = t0;
|
|
831
|
+
$[1] = t1;
|
|
832
|
+
} else {
|
|
833
|
+
t1 = $[1];
|
|
834
|
+
}
|
|
835
|
+
const primaryKeys = t1;
|
|
836
|
+
const supabase = useSupabase();
|
|
837
|
+
const tableName = typeof relation === "object" ? relation.table : relation;
|
|
838
|
+
const schemaName = typeof relation === "object" ? String(relation.schema) : "public";
|
|
839
|
+
let t2;
|
|
840
|
+
if ($[2] !== primaryKeys) {
|
|
841
|
+
t2 = primaryKeys.map(_temp6);
|
|
842
|
+
$[2] = primaryKeys;
|
|
843
|
+
$[3] = t2;
|
|
844
|
+
} else {
|
|
845
|
+
t2 = $[3];
|
|
846
|
+
}
|
|
847
|
+
const primaryKeysAsStrings = t2;
|
|
848
|
+
const t3 = primaryKeysAsStrings;
|
|
849
|
+
const t4 = relation;
|
|
850
|
+
let t5;
|
|
851
|
+
if ($[4] !== t3 || $[5] !== t4) {
|
|
852
|
+
t5 = {
|
|
853
|
+
primaryKeys: t3,
|
|
854
|
+
table: t4,
|
|
855
|
+
schema: "public"
|
|
856
|
+
};
|
|
857
|
+
$[4] = t3;
|
|
858
|
+
$[5] = t4;
|
|
859
|
+
$[6] = t5;
|
|
860
|
+
} else {
|
|
861
|
+
t5 = $[6];
|
|
862
|
+
}
|
|
863
|
+
const upsertItem = useUpsertItem(t5);
|
|
864
|
+
let t6;
|
|
865
|
+
if ($[7] !== primaryKeys || $[8] !== primaryKeysAsStrings || $[9] !== schemaName || $[10] !== supabase || $[11] !== tableName || $[12] !== upsertItem) {
|
|
866
|
+
t6 = {
|
|
867
|
+
mutationFn: async (item) => {
|
|
868
|
+
let response = null;
|
|
869
|
+
if (primaryKeys.every((x_0) => x_0 in item && isUsable(item[x_0]))) {
|
|
870
|
+
const query_0 = supabase.schema(schemaName).from(tableName).update(omit(item, primaryKeysAsStrings));
|
|
871
|
+
primaryKeys.forEach((x) => {
|
|
872
|
+
query_0.eq(String(x), item[x]);
|
|
873
|
+
});
|
|
874
|
+
const queryResponse = await query_0.select().single().throwOnError();
|
|
875
|
+
if (queryResponse.data) {
|
|
876
|
+
response = queryResponse.data;
|
|
877
|
+
upsertItem(response);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return response;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
$[7] = primaryKeys;
|
|
884
|
+
$[8] = primaryKeysAsStrings;
|
|
885
|
+
$[9] = schemaName;
|
|
886
|
+
$[10] = supabase;
|
|
887
|
+
$[11] = tableName;
|
|
888
|
+
$[12] = upsertItem;
|
|
889
|
+
$[13] = t6;
|
|
890
|
+
} else {
|
|
891
|
+
t6 = $[13];
|
|
892
|
+
}
|
|
893
|
+
const updateMutation = useMutation2(t6);
|
|
894
|
+
return updateMutation;
|
|
895
|
+
}
|
|
896
|
+
function _temp6(k) {
|
|
897
|
+
return String(k);
|
|
898
|
+
}
|
|
899
|
+
|
|
376
900
|
// src/providers/DataLayerProvider.web.tsx
|
|
377
|
-
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
901
|
+
import { useState as useState2, useEffect, useMemo as useMemo3, useCallback } from "react";
|
|
378
902
|
import { jsx } from "react/jsx-runtime";
|
|
379
903
|
var defaultSyncStatus = {
|
|
380
904
|
isConnected: false,
|
|
@@ -395,7 +919,22 @@ var defaultSyncControl = {
|
|
|
395
919
|
},
|
|
396
920
|
setScope: async () => {
|
|
397
921
|
console.warn("Scope control not available: PowerSync not initialized");
|
|
398
|
-
}
|
|
922
|
+
},
|
|
923
|
+
// Failed upload controls
|
|
924
|
+
retryFailedUploads: async () => {
|
|
925
|
+
console.warn("Retry not available: PowerSync not initialized");
|
|
926
|
+
},
|
|
927
|
+
clearFailedUploads: () => {
|
|
928
|
+
console.warn("Clear failed uploads not available: PowerSync not initialized");
|
|
929
|
+
},
|
|
930
|
+
failedUploads: [],
|
|
931
|
+
pauseAutoRetry: () => {
|
|
932
|
+
console.warn("Pause auto-retry not available: PowerSync not initialized");
|
|
933
|
+
},
|
|
934
|
+
resumeAutoRetry: () => {
|
|
935
|
+
console.warn("Resume auto-retry not available: PowerSync not initialized");
|
|
936
|
+
},
|
|
937
|
+
isAutoRetryPaused: false
|
|
399
938
|
};
|
|
400
939
|
function DataLayerProvider({
|
|
401
940
|
config,
|
|
@@ -405,9 +944,9 @@ function DataLayerProvider({
|
|
|
405
944
|
onInitialized,
|
|
406
945
|
onError
|
|
407
946
|
}) {
|
|
408
|
-
const [registry] =
|
|
409
|
-
const [autoDetector, setAutoDetector] =
|
|
410
|
-
const [status, setStatus] =
|
|
947
|
+
const [registry] = useState2(() => createAdapterRegistry(config));
|
|
948
|
+
const [autoDetector, setAutoDetector] = useState2(null);
|
|
949
|
+
const [status, setStatus] = useState2({
|
|
411
950
|
isInitialized: false,
|
|
412
951
|
currentBackend: null,
|
|
413
952
|
powerSyncStatus: "unavailable" /* UNAVAILABLE */,
|
|
@@ -536,7 +1075,7 @@ function DataLayerProvider({
|
|
|
536
1075
|
syncControl: defaultSyncControl
|
|
537
1076
|
};
|
|
538
1077
|
}, [registry, getAdapter, supabaseClient, queryClient, config.schema, status]);
|
|
539
|
-
const contextValue =
|
|
1078
|
+
const contextValue = useMemo3(() => buildContextValue(), [buildContextValue]);
|
|
540
1079
|
useEffect(() => {
|
|
541
1080
|
return () => {
|
|
542
1081
|
registry.dispose();
|
|
@@ -838,32 +1377,32 @@ export {
|
|
|
838
1377
|
useDbAdvanceFilterQuery as useDbAdvanceQuery,
|
|
839
1378
|
useDbCount,
|
|
840
1379
|
useDbCount as useDbCountV3,
|
|
841
|
-
useDbDelete,
|
|
842
|
-
|
|
843
|
-
useDbInfiniteQuery,
|
|
844
|
-
|
|
845
|
-
useDbInsert,
|
|
846
|
-
|
|
1380
|
+
useDbDelete2 as useDbDelete,
|
|
1381
|
+
useDbDelete as useDbDeleteV3,
|
|
1382
|
+
useDbInfiniteQuery2 as useDbInfiniteQuery,
|
|
1383
|
+
useDbInfiniteQuery as useDbInfiniteQueryV3,
|
|
1384
|
+
useDbInsert2 as useDbInsert,
|
|
1385
|
+
useDbInsert as useDbInsertV3,
|
|
847
1386
|
useDbMultiDelete,
|
|
848
1387
|
useDbMultiUpsert,
|
|
849
1388
|
useDbPartialAdvanceQuery,
|
|
850
1389
|
useDbPartialQuery,
|
|
851
|
-
useDbQuery,
|
|
1390
|
+
useDbQuery2 as useDbQuery,
|
|
852
1391
|
useDbQueryById,
|
|
853
|
-
|
|
1392
|
+
useDbQuery as useDbQueryV3,
|
|
854
1393
|
useDbRealtime,
|
|
855
1394
|
useDbRealtimeQuery,
|
|
856
|
-
useDbUpdate,
|
|
857
|
-
|
|
1395
|
+
useDbUpdate2 as useDbUpdate,
|
|
1396
|
+
useDbUpdate as useDbUpdateV3,
|
|
858
1397
|
useDbUpsert,
|
|
859
1398
|
useDbUpsert as useDbUpsertV3,
|
|
860
|
-
|
|
1399
|
+
useDbDelete2 as useDelete,
|
|
861
1400
|
useDeleteChangelog,
|
|
862
1401
|
useDeleteChangelogEntry,
|
|
863
1402
|
useDeleteChangelogMedia,
|
|
864
1403
|
useFeedbackList,
|
|
865
1404
|
useInfiniteQuery,
|
|
866
|
-
|
|
1405
|
+
useDbInsert2 as useInsert,
|
|
867
1406
|
useLatestOperationLog,
|
|
868
1407
|
useLiveChangeTracking,
|
|
869
1408
|
useLiveChangesIndicator,
|
|
@@ -888,7 +1427,7 @@ export {
|
|
|
888
1427
|
useSupabase,
|
|
889
1428
|
useSupabaseFunction,
|
|
890
1429
|
useToastError,
|
|
891
|
-
|
|
1430
|
+
useDbUpdate2 as useUpdate,
|
|
892
1431
|
useUploadChangelogMedia,
|
|
893
1432
|
useDbUpsert as useUpsert,
|
|
894
1433
|
useUpsertChangelog,
|