@pol-studios/db 1.0.10 → 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 (120) 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 +5 -4
  6. package/dist/auth/guards.js +2 -2
  7. package/dist/auth/hooks.d.ts +3 -3
  8. package/dist/auth/hooks.js +6 -5
  9. package/dist/auth/index.d.ts +3 -2
  10. package/dist/auth/index.js +8 -6
  11. package/dist/{canvas-UVNDA54X.node → canvas-C4TBBDUL.node} +0 -0
  12. package/dist/{canvas-75Y7XMF3.js → canvas-ZQNCL7JL.js} +2 -2
  13. package/dist/chunk-5EFDS7SR.js +205 -0
  14. package/dist/chunk-5EFDS7SR.js.map +1 -0
  15. package/dist/{chunk-BRTW7CO5.js → chunk-7SCJNYTE.js} +1 -9
  16. package/dist/chunk-7SCJNYTE.js.map +1 -0
  17. package/dist/chunk-DJ6VLEAL.js +247 -0
  18. package/dist/chunk-DJ6VLEAL.js.map +1 -0
  19. package/dist/{chunk-Y3INY2CS.js → chunk-GC3TBUWE.js} +1 -1
  20. package/dist/chunk-GC3TBUWE.js.map +1 -0
  21. package/dist/{chunk-7HG6G25H.js → chunk-H3LNH2NT.js} +169 -268
  22. package/dist/chunk-H3LNH2NT.js.map +1 -0
  23. package/dist/{chunk-USJYMRUO.js → chunk-HAWJTZCK.js} +2 -2
  24. package/dist/chunk-HAWJTZCK.js.map +1 -0
  25. package/dist/chunk-JAATANS3.js +429 -0
  26. package/dist/chunk-JAATANS3.js.map +1 -0
  27. package/dist/chunk-LNJ3WF7V.js +470 -0
  28. package/dist/chunk-LNJ3WF7V.js.map +1 -0
  29. package/dist/chunk-N26IEHZT.js +79 -0
  30. package/dist/chunk-N26IEHZT.js.map +1 -0
  31. package/dist/chunk-NSIAAYW3.js +1 -0
  32. package/dist/chunk-NSIAAYW3.js.map +1 -0
  33. package/dist/chunk-NZON56CB.js +3864 -0
  34. package/dist/chunk-NZON56CB.js.map +1 -0
  35. package/dist/{chunk-O3K7R32P.js → chunk-OQ7U6EQ3.js} +118 -123
  36. package/dist/chunk-OQ7U6EQ3.js.map +1 -0
  37. package/dist/chunk-SM73S2DY.js +11 -0
  38. package/dist/chunk-SM73S2DY.js.map +1 -0
  39. package/dist/{chunk-JUVE3DWY.js → chunk-TKWR5AAY.js} +47 -65
  40. package/dist/chunk-TKWR5AAY.js.map +1 -0
  41. package/dist/{chunk-2IFGILT3.js → chunk-U5UNPBKB.js} +76 -107
  42. package/dist/chunk-U5UNPBKB.js.map +1 -0
  43. package/dist/chunk-WGDJ4IXR.js +921 -0
  44. package/dist/chunk-WGDJ4IXR.js.map +1 -0
  45. package/dist/chunk-WVF7RUW5.js +186 -0
  46. package/dist/chunk-WVF7RUW5.js.map +1 -0
  47. package/dist/{chunk-ZTSBF536.js → chunk-X3HZLNBV.js} +637 -435
  48. package/dist/chunk-X3HZLNBV.js.map +1 -0
  49. package/dist/{chunk-EL45Z26M.js → chunk-XU3SBFAG.js} +1219 -208
  50. package/dist/chunk-XU3SBFAG.js.map +1 -0
  51. package/dist/chunk-ZVBHWU7O.js +1412 -0
  52. package/dist/chunk-ZVBHWU7O.js.map +1 -0
  53. package/dist/client/index.d.ts +1 -1
  54. package/dist/client/index.js +42 -23
  55. package/dist/client/index.js.map +1 -1
  56. package/dist/core/index.d.ts +19 -0
  57. package/dist/{index-BFu5_dS8.d.ts → database.types-ChFCG-4M.d.ts} +1 -177
  58. package/dist/gen/index.js +4 -2
  59. package/dist/hooks/index.d.ts +10 -3
  60. package/dist/hooks/index.js +8 -10
  61. package/dist/index-CQLyNG6A.d.ts +433 -0
  62. package/dist/index.d.ts +12 -8
  63. package/dist/index.js +92 -48
  64. package/dist/index.native.d.ts +373 -33
  65. package/dist/index.native.js +79 -47
  66. package/dist/index.web.d.ts +10 -7
  67. package/dist/index.web.js +83 -78
  68. package/dist/index.web.js.map +1 -1
  69. package/dist/mutation/index.d.ts +2 -2
  70. package/dist/mutation/index.js +307 -122
  71. package/dist/mutation/index.js.map +1 -1
  72. package/dist/parser/index.js +2 -2
  73. package/dist/{pdf-3TIGQRLA.js → pdf-PHXP7RHD.js} +2 -2
  74. package/dist/powersync-bridge/index.d.ts +284 -0
  75. package/dist/powersync-bridge/index.js +22 -0
  76. package/dist/powersync-bridge/index.js.map +1 -0
  77. package/dist/query/index.js +5 -5
  78. package/dist/realtime/index.js +252 -128
  79. package/dist/realtime/index.js.map +1 -1
  80. package/dist/{UserMetadataContext-BYYqA6LI.d.ts → setupAuthContext-Kv-THH-h.d.ts} +1 -29
  81. package/dist/types/index.d.ts +5 -1
  82. package/dist/types/index.js +10 -5
  83. package/dist/{useBatchUpsert-CSQVX7w8.d.ts → useBatchUpsert-9OYjibLh.d.ts} +1 -1
  84. package/dist/{useDbCount-RGCuHmHp.d.ts → useDbCount-BG356T9i.d.ts} +3 -719
  85. package/dist/{useReceiptAI-Bn0czE7C.d.ts → useReceiptAI-6HkRpRml.d.ts} +1 -1
  86. package/dist/{useResolveFeedback-CpZPP8Pw.d.ts → useResolveFeedback-BWmatBlE.d.ts} +26 -45
  87. package/dist/{useSupabase-pPhUZHcl.d.ts → useSupabase-DvWVuHHE.d.ts} +2 -1
  88. package/dist/with-auth/index.d.ts +704 -0
  89. package/dist/with-auth/index.js +1221 -0
  90. package/dist/with-auth/index.js.map +1 -0
  91. package/package.json +25 -10
  92. package/dist/chunk-2IFGILT3.js.map +0 -1
  93. package/dist/chunk-3M2U6TXH.js +0 -928
  94. package/dist/chunk-3M2U6TXH.js.map +0 -1
  95. package/dist/chunk-5ZYAEGCJ.js +0 -416
  96. package/dist/chunk-5ZYAEGCJ.js.map +0 -1
  97. package/dist/chunk-7HG6G25H.js.map +0 -1
  98. package/dist/chunk-7XT7K4QT.js +0 -2687
  99. package/dist/chunk-7XT7K4QT.js.map +0 -1
  100. package/dist/chunk-AWFMICFV.js +0 -158
  101. package/dist/chunk-AWFMICFV.js.map +0 -1
  102. package/dist/chunk-BRTW7CO5.js.map +0 -1
  103. package/dist/chunk-EL45Z26M.js.map +0 -1
  104. package/dist/chunk-ERGF2FCE.js +0 -903
  105. package/dist/chunk-ERGF2FCE.js.map +0 -1
  106. package/dist/chunk-GK7B66LY.js +0 -135
  107. package/dist/chunk-GK7B66LY.js.map +0 -1
  108. package/dist/chunk-GQI6WJGI.js +0 -172
  109. package/dist/chunk-GQI6WJGI.js.map +0 -1
  110. package/dist/chunk-JUVE3DWY.js.map +0 -1
  111. package/dist/chunk-O3K7R32P.js.map +0 -1
  112. package/dist/chunk-SEY5UO2T.js +0 -89
  113. package/dist/chunk-SEY5UO2T.js.map +0 -1
  114. package/dist/chunk-USJYMRUO.js.map +0 -1
  115. package/dist/chunk-XX3IWSPM.js +0 -189
  116. package/dist/chunk-XX3IWSPM.js.map +0 -1
  117. package/dist/chunk-Y3INY2CS.js.map +0 -1
  118. package/dist/chunk-ZTSBF536.js.map +0 -1
  119. /package/dist/{canvas-75Y7XMF3.js.map → canvas-ZQNCL7JL.js.map} +0 -0
  120. /package/dist/{pdf-3TIGQRLA.js.map → pdf-PHXP7RHD.js.map} +0 -0
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getSupabaseUrl
3
- } from "./chunk-Y3INY2CS.js";
3
+ } from "./chunk-GC3TBUWE.js";
4
4
  import {
5
5
  PostgrestParser
6
- } from "./chunk-JUVE3DWY.js";
6
+ } from "./chunk-TKWR5AAY.js";
7
7
  import {
8
8
  isNullOrWhitespace,
9
9
  isUsable,
10
10
  omit
11
- } from "./chunk-O3K7R32P.js";
11
+ } from "./chunk-OQ7U6EQ3.js";
12
12
  import {
13
13
  encode,
14
14
  useQuery
@@ -16,7 +16,7 @@ import {
16
16
  import {
17
17
  generateUUID,
18
18
  useSupabase
19
- } from "./chunk-AWFMICFV.js";
19
+ } from "./chunk-5EFDS7SR.js";
20
20
 
21
21
  // src/query/select-parser.ts
22
22
  function tokenizeTopLevel(input) {
@@ -54,15 +54,23 @@ function parseColumnToken(token) {
54
54
  alias: aliasMatch[1]
55
55
  };
56
56
  }
57
- return { name: token };
57
+ return {
58
+ name: token
59
+ };
58
60
  }
59
61
  function parseSelect(select) {
60
62
  const trimmed = select.trim();
61
63
  if (trimmed === "*") {
62
- return { columns: "*", relations: [] };
64
+ return {
65
+ columns: "*",
66
+ relations: []
67
+ };
63
68
  }
64
69
  if (!trimmed) {
65
- return { columns: "*", relations: [] };
70
+ return {
71
+ columns: "*",
72
+ relations: []
73
+ };
66
74
  }
67
75
  const result = {
68
76
  columns: [],
@@ -139,9 +147,7 @@ function hasRelation(parsed, relationName) {
139
147
  return parsed.relations.some((rel) => rel.name === relationName || rel.alias === relationName);
140
148
  }
141
149
  function getRelationSelect(parsed, relationName) {
142
- return parsed.relations.find(
143
- (rel) => rel.name === relationName || rel.alias === relationName
144
- );
150
+ return parsed.relations.find((rel) => rel.name === relationName || rel.alias === relationName);
145
151
  }
146
152
 
147
153
  // src/query/relationship-resolver.ts
@@ -242,9 +248,7 @@ var RelationshipResolver = class {
242
248
  for (const schemaName of Object.keys(this.schema.schemas)) {
243
249
  const schemaDefinition = this.schema.schemas[schemaName];
244
250
  if (!schemaDefinition) continue;
245
- for (const [otherTableName, otherTableSchema] of Object.entries(
246
- schemaDefinition.tables
247
- )) {
251
+ for (const [otherTableName, otherTableSchema] of Object.entries(schemaDefinition.tables)) {
248
252
  if (otherTableName === tableName) continue;
249
253
  for (const rel of otherTableSchema.relationships) {
250
254
  if (rel.referencedTable === tableName) {
@@ -265,10 +269,7 @@ var RelationshipResolver = class {
265
269
  * Get all relationships for a table (both directions).
266
270
  */
267
271
  getAllRelationships(tableName) {
268
- return [
269
- ...this.getForwardRelationships(tableName),
270
- ...this.getReverseRelationships(tableName)
271
- ];
272
+ return [...this.getForwardRelationships(tableName), ...this.getReverseRelationships(tableName)];
272
273
  }
273
274
  /**
274
275
  * Check if a relationship exists between two tables.
@@ -405,9 +406,7 @@ var SQLBuilder = class {
405
406
  }
406
407
  }
407
408
  if (options.orderBy && options.orderBy.length > 0) {
408
- const orderClauses = options.orderBy.map(
409
- (o) => `"${o.field}" ${o.direction.toUpperCase()}`
410
- );
409
+ const orderClauses = options.orderBy.map((o) => `"${o.field}" ${o.direction.toUpperCase()}`);
411
410
  sql += ` ORDER BY ${orderClauses.join(", ")}`;
412
411
  }
413
412
  if (options.limit !== void 0) {
@@ -418,7 +417,10 @@ var SQLBuilder = class {
418
417
  sql += ` OFFSET ?`;
419
418
  params.push(options.offset);
420
419
  }
421
- return { sql, params };
420
+ return {
421
+ sql,
422
+ params
423
+ };
422
424
  }
423
425
  /**
424
426
  * Build WHERE clauses from operator objects.
@@ -511,7 +513,10 @@ var SQLBuilder = class {
511
513
  }
512
514
  const placeholders = parentIds.map(() => "?").join(", ");
513
515
  const sql = `SELECT ${columnList} FROM "${table}" WHERE "${foreignKey}" IN (${placeholders})`;
514
- return { sql, params: [...parentIds] };
516
+ return {
517
+ sql,
518
+ params: [...parentIds]
519
+ };
515
520
  }
516
521
  /**
517
522
  * Build column list ensuring the foreign key is included.
@@ -548,7 +553,10 @@ var SQLBuilder = class {
548
553
  columnList = columns.map((c) => c.alias ? `"${c.name}" AS "${c.alias}"` : `"${c.name}"`).join(", ");
549
554
  }
550
555
  const sql = `SELECT ${columnList} FROM "${table}" WHERE "${idColumn}" = ? LIMIT 1`;
551
- return { sql, params: [id] };
556
+ return {
557
+ sql,
558
+ params: [id]
559
+ };
552
560
  }
553
561
  /**
554
562
  * Build an INSERT query.
@@ -581,9 +589,7 @@ var SQLBuilder = class {
581
589
  * @returns Built query
582
590
  */
583
591
  buildUpdateQuery(table, id, data, idColumn = "id") {
584
- const columns = Object.keys(data).filter(
585
- (k) => k !== idColumn && data[k] !== void 0
586
- );
592
+ const columns = Object.keys(data).filter((k) => k !== idColumn && data[k] !== void 0);
587
593
  if (columns.length === 0) {
588
594
  throw new Error("No fields to update");
589
595
  }
@@ -605,7 +611,10 @@ var SQLBuilder = class {
605
611
  */
606
612
  buildDeleteQuery(table, id, idColumn = "id") {
607
613
  const sql = `DELETE FROM "${table}" WHERE "${idColumn}" = ?`;
608
- return { sql, params: [id] };
614
+ return {
615
+ sql,
616
+ params: [id]
617
+ };
609
618
  }
610
619
  /**
611
620
  * Build a COUNT query.
@@ -634,7 +643,10 @@ var SQLBuilder = class {
634
643
  sql += ` WHERE ${whereClauses.join(" AND ")}`;
635
644
  }
636
645
  }
637
- return { sql, params };
646
+ return {
647
+ sql,
648
+ params
649
+ };
638
650
  }
639
651
  };
640
652
  function createSQLBuilder() {
@@ -680,9 +692,7 @@ var ResultJoiner = class {
680
692
  if (relationship.type === "one-to-many") {
681
693
  return baseRecords.map((base) => {
682
694
  const baseId = base[relationship.referencedColumn];
683
- const related = relatedRecords.filter(
684
- (r) => r[relationship.foreignKey] === baseId
685
- );
695
+ const related = relatedRecords.filter((r) => r[relationship.foreignKey] === baseId);
686
696
  return {
687
697
  ...base,
688
698
  [relationName]: related
@@ -807,7 +817,10 @@ var ResultJoiner = class {
807
817
  */
808
818
  removeRelation(records, relationName) {
809
819
  return records.map((record) => {
810
- const { [relationName]: _removed, ...rest } = record;
820
+ const {
821
+ [relationName]: _removed,
822
+ ...rest
823
+ } = record;
811
824
  return rest;
812
825
  });
813
826
  }
@@ -823,7 +836,10 @@ var ResultJoiner = class {
823
836
  flattenRelation(records, relationName, prefix = "") {
824
837
  return records.map((record) => {
825
838
  const relation = record[relationName];
826
- const { [relationName]: _removed, ...rest } = record;
839
+ const {
840
+ [relationName]: _removed,
841
+ ...rest
842
+ } = record;
827
843
  if (!relation) {
828
844
  return rest;
829
845
  }
@@ -832,7 +848,10 @@ var ResultJoiner = class {
832
848
  const fieldName = prefix ? `${prefix}_${key}` : `${relationName}_${key}`;
833
849
  flattenedRelation[fieldName] = value;
834
850
  }
835
- return { ...rest, ...flattenedRelation };
851
+ return {
852
+ ...rest,
853
+ ...flattenedRelation
854
+ };
836
855
  });
837
856
  }
838
857
  };
@@ -867,18 +886,11 @@ var QueryExecutor = class {
867
886
  limit: options.limit,
868
887
  offset: options.offset
869
888
  });
870
- const baseRecords = await this.db.getAll(
871
- baseQuery.sql,
872
- baseQuery.params
873
- );
889
+ const baseRecords = await this.db.getAll(baseQuery.sql, baseQuery.params);
874
890
  if (baseRecords.length === 0 || parsed.relations.length === 0) {
875
891
  return baseRecords;
876
892
  }
877
- const result = await this.queryAndJoinRelations(
878
- table,
879
- baseRecords,
880
- parsed.relations
881
- );
893
+ const result = await this.queryAndJoinRelations(table, baseRecords, parsed.relations);
882
894
  return result;
883
895
  }
884
896
  /**
@@ -892,27 +904,15 @@ var QueryExecutor = class {
892
904
  async executeById(table, id, options = {}) {
893
905
  const parsed = parseSelect(options.select ?? "*");
894
906
  const idColumn = this.resolver.getPrimaryKey(table);
895
- const baseQuery = this.builder.buildByIdQuery(
896
- table,
897
- id,
898
- parsed.columns,
899
- idColumn
900
- );
901
- const records = await this.db.getAll(
902
- baseQuery.sql,
903
- baseQuery.params
904
- );
907
+ const baseQuery = this.builder.buildByIdQuery(table, id, parsed.columns, idColumn);
908
+ const records = await this.db.getAll(baseQuery.sql, baseQuery.params);
905
909
  if (records.length === 0) {
906
910
  return null;
907
911
  }
908
912
  if (parsed.relations.length === 0) {
909
913
  return records[0];
910
914
  }
911
- const result = await this.queryAndJoinRelations(
912
- table,
913
- records,
914
- parsed.relations
915
- );
915
+ const result = await this.queryAndJoinRelations(table, records, parsed.relations);
916
916
  return result[0];
917
917
  }
918
918
  /**
@@ -924,10 +924,7 @@ var QueryExecutor = class {
924
924
  */
925
925
  async count(table, options = {}) {
926
926
  const query = this.builder.buildCountQuery(table, options.where);
927
- const result = await this.db.getAll(
928
- query.sql,
929
- query.params
930
- );
927
+ const result = await this.db.getAll(query.sql, query.params);
931
928
  return result[0]?.count ?? 0;
932
929
  }
933
930
  /**
@@ -938,16 +935,53 @@ var QueryExecutor = class {
938
935
  * @returns The inserted record (re-fetched to get defaults)
939
936
  */
940
937
  async insert(table, data) {
938
+ if (__DEV__) {
939
+ console.log(`[QueryExecutor] insert called:`, {
940
+ table,
941
+ dataKeys: Object.keys(data),
942
+ hasId: "id" in data
943
+ });
944
+ }
941
945
  const idColumn = this.resolver.getPrimaryKey(table);
942
946
  if (!data[idColumn]) {
943
- const [{ id }] = await this.db.getAll(
944
- "SELECT uuid() as id"
945
- );
946
- data = { ...data, [idColumn]: id };
947
+ const [{
948
+ id
949
+ }] = await this.db.getAll("SELECT uuid() as id");
950
+ data = {
951
+ ...data,
952
+ [idColumn]: id
953
+ };
954
+ if (__DEV__) {
955
+ console.log(`[QueryExecutor] insert generated UUID:`, {
956
+ table,
957
+ id
958
+ });
959
+ }
947
960
  }
948
961
  const query = this.builder.buildInsertQuery(table, data);
962
+ if (__DEV__) {
963
+ console.log(`[QueryExecutor] insert executing SQL:`, {
964
+ table,
965
+ sql: query.sql,
966
+ paramCount: query.params.length
967
+ });
968
+ }
949
969
  await this.db.execute(query.sql, query.params);
970
+ if (__DEV__) {
971
+ console.log(`[QueryExecutor] insert SQL executed successfully:`, {
972
+ table,
973
+ id: data[idColumn]
974
+ });
975
+ }
950
976
  const result = await this.executeById(table, data[idColumn]);
977
+ if (__DEV__) {
978
+ console.log(`[QueryExecutor] insert completed:`, {
979
+ table,
980
+ operation: "insert",
981
+ resultId: result?.[idColumn] ?? data[idColumn],
982
+ refetchSucceeded: result !== null
983
+ });
984
+ }
951
985
  return result ?? data;
952
986
  }
953
987
  /**
@@ -959,14 +993,46 @@ var QueryExecutor = class {
959
993
  * @returns The updated record
960
994
  */
961
995
  async update(table, id, data) {
996
+ if (__DEV__) {
997
+ console.log(`[QueryExecutor] update called:`, {
998
+ table,
999
+ id,
1000
+ dataKeys: Object.keys(data)
1001
+ });
1002
+ }
962
1003
  const idColumn = this.resolver.getPrimaryKey(table);
963
1004
  const query = this.builder.buildUpdateQuery(table, id, data, idColumn);
1005
+ if (__DEV__) {
1006
+ console.log(`[QueryExecutor] update executing SQL:`, {
1007
+ table,
1008
+ id,
1009
+ sql: query.sql,
1010
+ paramCount: query.params.length
1011
+ });
1012
+ }
964
1013
  await this.db.execute(query.sql, query.params);
1014
+ if (__DEV__) {
1015
+ console.log(`[QueryExecutor] update SQL executed successfully:`, {
1016
+ table,
1017
+ id
1018
+ });
1019
+ }
965
1020
  const result = await this.executeById(table, id);
1021
+ if (__DEV__) {
1022
+ console.log(`[QueryExecutor] update completed:`, {
1023
+ table,
1024
+ operation: "update",
1025
+ id,
1026
+ refetchSucceeded: result !== null
1027
+ });
1028
+ }
966
1029
  if (result) {
967
1030
  return result;
968
1031
  }
969
- return { ...data, [idColumn]: id };
1032
+ return {
1033
+ ...data,
1034
+ [idColumn]: id
1035
+ };
970
1036
  }
971
1037
  /**
972
1038
  * Upsert a record (insert or update).
@@ -976,16 +1042,41 @@ var QueryExecutor = class {
976
1042
  * @returns The upserted record
977
1043
  */
978
1044
  async upsert(table, data) {
1045
+ if (__DEV__) {
1046
+ console.log(`[QueryExecutor] upsert called:`, {
1047
+ table,
1048
+ dataKeys: Object.keys(data),
1049
+ hasId: "id" in data,
1050
+ idValue: data.id ?? "none"
1051
+ });
1052
+ }
979
1053
  const idColumn = this.resolver.getPrimaryKey(table);
980
1054
  let id = data[idColumn];
981
1055
  if (!id) {
982
- const [{ id: generatedId }] = await this.db.getAll(
983
- "SELECT uuid() as id"
984
- );
1056
+ const [{
1057
+ id: generatedId
1058
+ }] = await this.db.getAll("SELECT uuid() as id");
985
1059
  id = generatedId;
986
- data = { ...data, [idColumn]: id };
1060
+ data = {
1061
+ ...data,
1062
+ [idColumn]: id
1063
+ };
1064
+ if (__DEV__) {
1065
+ console.log(`[QueryExecutor] upsert generated UUID:`, {
1066
+ table,
1067
+ id
1068
+ });
1069
+ }
987
1070
  }
988
1071
  const existing = await this.executeById(table, id);
1072
+ if (__DEV__) {
1073
+ console.log(`[QueryExecutor] upsert existence check:`, {
1074
+ table,
1075
+ id,
1076
+ exists: existing !== null,
1077
+ willPerform: existing ? "update" : "insert"
1078
+ });
1079
+ }
989
1080
  if (existing) {
990
1081
  return this.update(table, id, data);
991
1082
  }
@@ -1015,9 +1106,7 @@ var QueryExecutor = class {
1015
1106
  for (const relation of relations) {
1016
1107
  const resolved = this.resolver.resolve(parentTable, relation.name);
1017
1108
  if (!resolved) {
1018
- console.warn(
1019
- `Could not resolve relationship: ${parentTable} -> ${relation.name}`
1020
- );
1109
+ console.warn(`Could not resolve relationship: ${parentTable} -> ${relation.name}`);
1021
1110
  continue;
1022
1111
  }
1023
1112
  const parentIds = this.getParentIdsForRelation(parentRecords, resolved);
@@ -1029,23 +1118,11 @@ var QueryExecutor = class {
1029
1118
  continue;
1030
1119
  }
1031
1120
  const relQuery = this.buildRelatedQuery(relation, resolved, parentIds);
1032
- let relatedRecords = await this.db.getAll(
1033
- relQuery.sql,
1034
- relQuery.params
1035
- );
1121
+ let relatedRecords = await this.db.getAll(relQuery.sql, relQuery.params);
1036
1122
  if (relation.relations.length > 0 && relatedRecords.length > 0) {
1037
- relatedRecords = await this.queryAndJoinRelations(
1038
- relation.name,
1039
- relatedRecords,
1040
- relation.relations
1041
- );
1123
+ relatedRecords = await this.queryAndJoinRelations(relation.name, relatedRecords, relation.relations);
1042
1124
  }
1043
- result = this.joiner.join(
1044
- result,
1045
- relatedRecords,
1046
- resolved,
1047
- relation.alias ?? relation.name
1048
- );
1125
+ result = this.joiner.join(result, relatedRecords, resolved, relation.alias ?? relation.name);
1049
1126
  }
1050
1127
  return result;
1051
1128
  }
@@ -1055,15 +1132,9 @@ var QueryExecutor = class {
1055
1132
  getParentIdsForRelation(parentRecords, resolved) {
1056
1133
  let parentIds;
1057
1134
  if (resolved.type === "one-to-many") {
1058
- parentIds = this.joiner.extractUniqueValues(
1059
- parentRecords,
1060
- resolved.referencedColumn
1061
- );
1135
+ parentIds = this.joiner.extractUniqueValues(parentRecords, resolved.referencedColumn);
1062
1136
  } else {
1063
- parentIds = this.joiner.extractUniqueValues(
1064
- parentRecords,
1065
- resolved.foreignKey
1066
- );
1137
+ parentIds = this.joiner.extractUniqueValues(parentRecords, resolved.foreignKey);
1067
1138
  }
1068
1139
  return parentIds;
1069
1140
  }
@@ -1073,12 +1144,7 @@ var QueryExecutor = class {
1073
1144
  buildRelatedQuery(relation, resolved, parentIds) {
1074
1145
  const filterColumn = resolved.type === "one-to-many" ? resolved.foreignKey : resolved.referencedColumn;
1075
1146
  const uniqueIds = Array.from(new Set(parentIds));
1076
- return this.builder.buildRelationQuery(
1077
- relation.name,
1078
- filterColumn,
1079
- uniqueIds,
1080
- relation.columns
1081
- );
1147
+ return this.builder.buildRelationQuery(relation.name, filterColumn, uniqueIds, relation.columns);
1082
1148
  }
1083
1149
  /**
1084
1150
  * Get the relationship resolver (for advanced use).
@@ -1104,76 +1170,148 @@ function createQueryExecutor(db, schema) {
1104
1170
  }
1105
1171
 
1106
1172
  // src/query/useQuery.ts
1107
- import { useMemo } from "react";
1173
+ import { c as _c } from "react/compiler-runtime";
1108
1174
  import { useDelayedValue } from "@pol-studios/hooks/state";
1109
1175
  function useQuery2(query, config) {
1110
- const queryKey = encode(query, false);
1111
- const queryKeyString = queryKey.join("-");
1176
+ const $ = _c(5);
1177
+ let t0;
1178
+ if ($[0] !== query) {
1179
+ const queryKey = encode(query, false);
1180
+ t0 = queryKey.join("-");
1181
+ $[0] = query;
1182
+ $[1] = t0;
1183
+ } else {
1184
+ t0 = $[1];
1185
+ }
1186
+ const queryKeyString = t0;
1112
1187
  const debouncedKeyString = useDelayedValue(queryKeyString, 50);
1113
1188
  const isKeyStable = queryKeyString === debouncedKeyString;
1114
1189
  const effectiveEnabled = config?.enabled !== false && isKeyStable;
1115
- const request = useQuery(
1116
- query,
1117
- useMemo(() => omit({ retry: 1, ...config, enabled: effectiveEnabled }, ["queryKey"]), [config, effectiveEnabled])
1118
- );
1190
+ let t1;
1191
+ if ($[2] !== config || $[3] !== effectiveEnabled) {
1192
+ t1 = omit({
1193
+ retry: 1,
1194
+ ...config,
1195
+ enabled: effectiveEnabled
1196
+ }, ["queryKey"]);
1197
+ $[2] = config;
1198
+ $[3] = effectiveEnabled;
1199
+ $[4] = t1;
1200
+ } else {
1201
+ t1 = $[4];
1202
+ }
1203
+ const request = useQuery(query, t1);
1119
1204
  return request;
1120
1205
  }
1121
1206
 
1122
1207
  // src/query/usePartialQuery.ts
1123
- import { useMemo as useMemo2 } from "react";
1208
+ import { c as _c2 } from "react/compiler-runtime";
1124
1209
  import { useSessionStorageState } from "@pol-studios/hooks/storage";
1125
1210
  function usePartialQuery(query, itemCountPerPage, config) {
1126
- const initialQuery = encode(query, false);
1127
- const id = useMemo2(
1128
- () => [
1129
- initialQuery[7],
1130
- initialQuery[8]
1131
- ].join("-"),
1132
- [
1133
- initialQuery[7],
1134
- initialQuery[8]
1135
- ]
1136
- );
1211
+ const $ = _c2(28);
1212
+ let t0;
1213
+ if ($[0] !== query) {
1214
+ t0 = encode(query, false);
1215
+ $[0] = query;
1216
+ $[1] = t0;
1217
+ } else {
1218
+ t0 = $[1];
1219
+ }
1220
+ const initialQuery = t0;
1221
+ let t1;
1222
+ if ($[2] !== initialQuery[7] || $[3] !== initialQuery[8]) {
1223
+ t1 = [initialQuery[7], initialQuery[8]];
1224
+ $[2] = initialQuery[7];
1225
+ $[3] = initialQuery[8];
1226
+ $[4] = t1;
1227
+ } else {
1228
+ t1 = $[4];
1229
+ }
1230
+ const id = t1.join("-");
1137
1231
  const [currentPage, setCurrentPage] = useSessionStorageState(id, 1);
1138
- const rangedQuery = useMemo2(
1139
- () => {
1140
- const page = currentPage ?? 1;
1141
- return query.range(
1142
- (page - 1) * itemCountPerPage,
1143
- page * itemCountPerPage - 1
1144
- );
1145
- },
1146
- [query, currentPage, itemCountPerPage]
1147
- );
1232
+ const page = currentPage ?? 1;
1233
+ const t2 = query;
1234
+ let t3;
1235
+ if ($[5] !== itemCountPerPage || $[6] !== page || $[7] !== t2) {
1236
+ t3 = t2.range((page - 1) * itemCountPerPage, page * itemCountPerPage - 1);
1237
+ $[5] = itemCountPerPage;
1238
+ $[6] = page;
1239
+ $[7] = t2;
1240
+ $[8] = t3;
1241
+ } else {
1242
+ t3 = $[8];
1243
+ }
1244
+ const rangedQuery = t3;
1148
1245
  const baseQuery = useQuery2(rangedQuery, config);
1149
- const safeFetchNextPage = () => {
1150
- setCurrentPage((currentPage2) => currentPage2 + 1);
1151
- };
1152
- const fetchPreviousPage = () => {
1153
- setCurrentPage((currentPage2) => currentPage2 - 1);
1154
- };
1155
- const pageCount = Math.max(
1156
- Math.ceil(
1157
- (baseQuery.count ?? 0) / itemCountPerPage
1158
- ),
1159
- 1
1160
- );
1161
- return {
1162
- ...baseQuery,
1163
- fetchPreviousPage,
1164
- fetchNextPage: safeFetchNextPage,
1165
- currentPage,
1166
- setCurrentPage,
1167
- data: baseQuery.data ? toPagedResponse(
1168
- baseQuery.data,
1246
+ let t4;
1247
+ if ($[9] !== setCurrentPage) {
1248
+ t4 = () => {
1249
+ setCurrentPage(_temp);
1250
+ };
1251
+ $[9] = setCurrentPage;
1252
+ $[10] = t4;
1253
+ } else {
1254
+ t4 = $[10];
1255
+ }
1256
+ const safeFetchNextPage = t4;
1257
+ let t5;
1258
+ if ($[11] !== setCurrentPage) {
1259
+ t5 = () => {
1260
+ setCurrentPage(_temp2);
1261
+ };
1262
+ $[11] = setCurrentPage;
1263
+ $[12] = t5;
1264
+ } else {
1265
+ t5 = $[12];
1266
+ }
1267
+ const fetchPreviousPage = t5;
1268
+ const pageCount = Math.max(Math.ceil((baseQuery.count ?? 0) / itemCountPerPage), 1);
1269
+ let t6;
1270
+ if ($[13] !== baseQuery.count || $[14] !== baseQuery.data || $[15] !== currentPage || $[16] !== itemCountPerPage) {
1271
+ t6 = baseQuery.data ? toPagedResponse(baseQuery.data, currentPage, baseQuery.count ?? baseQuery.data.length, itemCountPerPage) : null;
1272
+ $[13] = baseQuery.count;
1273
+ $[14] = baseQuery.data;
1274
+ $[15] = currentPage;
1275
+ $[16] = itemCountPerPage;
1276
+ $[17] = t6;
1277
+ } else {
1278
+ t6 = $[17];
1279
+ }
1280
+ const t7 = currentPage < pageCount;
1281
+ const t8 = currentPage > 1;
1282
+ let t9;
1283
+ if ($[18] !== baseQuery || $[19] !== currentPage || $[20] !== fetchPreviousPage || $[21] !== pageCount || $[22] !== safeFetchNextPage || $[23] !== setCurrentPage || $[24] !== t6 || $[25] !== t7 || $[26] !== t8) {
1284
+ t9 = {
1285
+ ...baseQuery,
1286
+ fetchPreviousPage,
1287
+ fetchNextPage: safeFetchNextPage,
1169
1288
  currentPage,
1170
- baseQuery.count ?? baseQuery.data.length,
1171
- itemCountPerPage
1172
- ) : null,
1173
- pageCount,
1174
- hasNextPage: currentPage < pageCount,
1175
- hasPreviousPage: currentPage > 1
1176
- };
1289
+ setCurrentPage,
1290
+ data: t6,
1291
+ pageCount,
1292
+ hasNextPage: t7,
1293
+ hasPreviousPage: t8
1294
+ };
1295
+ $[18] = baseQuery;
1296
+ $[19] = currentPage;
1297
+ $[20] = fetchPreviousPage;
1298
+ $[21] = pageCount;
1299
+ $[22] = safeFetchNextPage;
1300
+ $[23] = setCurrentPage;
1301
+ $[24] = t6;
1302
+ $[25] = t7;
1303
+ $[26] = t8;
1304
+ $[27] = t9;
1305
+ } else {
1306
+ t9 = $[27];
1307
+ }
1308
+ return t9;
1309
+ }
1310
+ function _temp2(currentPage_1) {
1311
+ return currentPage_1 - 1;
1312
+ }
1313
+ function _temp(currentPage_0) {
1314
+ return currentPage_0 + 1;
1177
1315
  }
1178
1316
  function toPagedResponse(results, currentPage, totalCount, itemPerPage) {
1179
1317
  const newPage = {
@@ -1187,15 +1325,8 @@ function toPagedResponse(results, currentPage, totalCount, itemPerPage) {
1187
1325
  }
1188
1326
 
1189
1327
  // src/query/useAdvancedQuery.ts
1190
- import {
1191
- useEffect,
1192
- useMemo as useMemo3,
1193
- useRef,
1194
- useState
1195
- } from "react";
1196
- import {
1197
- useQuery as useQuery3
1198
- } from "@tanstack/react-query";
1328
+ import { useEffect, useMemo, useRef, useState } from "react";
1329
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
1199
1330
  import { useSessionStorageState as useSessionStorageState2 } from "@pol-studios/hooks/storage";
1200
1331
  var normalizeFilter = (filter) => {
1201
1332
  const groupOp = filter.op || filter.operator;
@@ -1205,9 +1336,7 @@ var normalizeFilter = (filter) => {
1205
1336
  op: groupOp,
1206
1337
  not: filter.not || filter.inverted,
1207
1338
  // Support both 'not' and legacy 'inverted' for groups
1208
- filters: filter.filters.map(normalizeFilter).filter(
1209
- Boolean
1210
- )
1339
+ filters: filter.filters.map(normalizeFilter).filter(Boolean)
1211
1340
  };
1212
1341
  }
1213
1342
  let operator = filter.op || filter.condition;
@@ -1222,10 +1351,7 @@ var normalizeFilter = (filter) => {
1222
1351
  operator = "contains";
1223
1352
  }
1224
1353
  if (!operator) {
1225
- console.error(
1226
- "Filter has undefined operator:",
1227
- JSON.stringify(filter, null, 2)
1228
- );
1354
+ console.error("Filter has undefined operator:", JSON.stringify(filter, null, 2));
1229
1355
  return null;
1230
1356
  }
1231
1357
  if (filter.propertyName) {
@@ -1250,12 +1376,7 @@ var normalizeFilter = (filter) => {
1250
1376
  };
1251
1377
  };
1252
1378
  function useAdvancedFilterQuery(query, config) {
1253
- const filterKey = useMemo3(
1254
- () => config?.filterKey ?? window.location?.pathname,
1255
- [
1256
- config?.filterKey
1257
- ]
1258
- );
1379
+ const filterKey = useMemo(() => config?.filterKey ?? window.location?.pathname, [config?.filterKey]);
1259
1380
  const [filterLayer, setFilterLayer] = useSessionStorageState2(filterKey, {
1260
1381
  id: "root",
1261
1382
  op: "AND",
@@ -1264,10 +1385,7 @@ function useAdvancedFilterQuery(query, config) {
1264
1385
  sort: [],
1265
1386
  isReady: isUsable(config?.searchByDefault) ? config.searchByDefault ? false : true : true
1266
1387
  });
1267
- const parser = useMemo3(
1268
- () => new PostgrestParser(query),
1269
- [query, config?.key]
1270
- );
1388
+ const parser = useMemo(() => new PostgrestParser(query), [query, config?.key]);
1271
1389
  useEffect(() => {
1272
1390
  const searchParam = parser.searchParams.get("order");
1273
1391
  if (searchParam) {
@@ -1296,18 +1414,13 @@ function useAdvancedFilterQuery(query, config) {
1296
1414
  op: pre.op || "AND",
1297
1415
  filters: pre.filters || [],
1298
1416
  isReady: pre.isReady ?? true,
1299
- sort: [
1300
- ...(pre.sort || []).filter(
1301
- (old) => orders.some((o) => o.field === old.field) === false
1302
- ),
1303
- ...orders
1304
- ]
1417
+ sort: [...(pre.sort || []).filter((old) => orders.some((o) => o.field === old.field) === false), ...orders]
1305
1418
  };
1306
1419
  });
1307
1420
  }
1308
1421
  }, [JSON.stringify(parser.searchParams), config?.key]);
1309
1422
  const encodedQueryKeyRef = useRef([]);
1310
- const encodedQueryKey = useMemo3(() => {
1423
+ const encodedQueryKey = useMemo(() => {
1311
1424
  const newEncoded = encode(query, false);
1312
1425
  const newEncodedString = JSON.stringify(newEncoded);
1313
1426
  const oldEncodedString = JSON.stringify(encodedQueryKeyRef.current);
@@ -1322,18 +1435,7 @@ function useAdvancedFilterQuery(query, config) {
1322
1435
  filterLayerStringRef.current = currentFilterString;
1323
1436
  }
1324
1437
  const queryKeyRef = useRef([]);
1325
- const newKey = [
1326
- encodedQueryKey[0],
1327
- encodedQueryKey[1],
1328
- encodedQueryKey[2],
1329
- encodedQueryKey[3],
1330
- encodedQueryKey[4],
1331
- encodedQueryKey[5],
1332
- "count=" + (config?.count ?? ""),
1333
- encodedQueryKey[7],
1334
- encodedQueryKey[8],
1335
- filterLayerStringRef.current
1336
- ];
1438
+ const newKey = [encodedQueryKey[0], encodedQueryKey[1], encodedQueryKey[2], encodedQueryKey[3], encodedQueryKey[4], encodedQueryKey[5], "count=" + (config?.count ?? ""), encodedQueryKey[7], encodedQueryKey[8], filterLayerStringRef.current];
1337
1439
  const newKeyString = JSON.stringify(newKey);
1338
1440
  const oldKeyString = JSON.stringify(queryKeyRef.current);
1339
1441
  if (oldKeyString !== newKeyString) {
@@ -1351,20 +1453,17 @@ function useAdvancedFilterQuery(query, config) {
1351
1453
  const isEnabled = config?.enabled == null || config?.enabled === void 0 ? true : config.enabled;
1352
1454
  const [extraData, setExtraData] = useState({});
1353
1455
  const queryResponse = useQuery3({
1354
- ...omit(
1355
- {
1356
- retry: 0,
1357
- // Changed from 1 to 0 to prevent retries
1358
- ...config ?? {},
1359
- // Override any config settings to prevent multiple executions
1360
- refetchOnMount: false,
1361
- refetchOnWindowFocus: false,
1362
- refetchOnReconnect: false,
1363
- structuralSharing: false,
1364
- enabled: filterLayer?.isReady && isEnabled
1365
- },
1366
- ["queryKey", "persister", "initialData"]
1367
- ),
1456
+ ...omit({
1457
+ retry: 0,
1458
+ // Changed from 1 to 0 to prevent retries
1459
+ ...config ?? {},
1460
+ // Override any config settings to prevent multiple executions
1461
+ refetchOnMount: false,
1462
+ refetchOnWindowFocus: false,
1463
+ refetchOnReconnect: false,
1464
+ structuralSharing: false,
1465
+ enabled: filterLayer?.isReady && isEnabled
1466
+ }, ["queryKey", "persister", "initialData"]),
1368
1467
  queryKey: loadingKey,
1369
1468
  queryFn: async (props) => {
1370
1469
  if (!filterLayer) {
@@ -1375,27 +1474,22 @@ function useAdvancedFilterQuery(query, config) {
1375
1474
  const body = {
1376
1475
  ...filterLayer,
1377
1476
  filters: [...filterLayer.filters],
1378
- pagination: { ...filterLayer.pagination },
1477
+ pagination: {
1478
+ ...filterLayer.pagination
1479
+ },
1379
1480
  sort: [...filterLayer.sort || []]
1380
1481
  };
1381
1482
  const currentKey = `${parser.schema}${parser.table}${parser.select}${JSON.stringify(omit(body, "pagination"))}`;
1382
1483
  const requiresEdgeForOrdering = false;
1383
1484
  const hasNaturalLanguageQuery = !!filterLayer.naturalLanguageQuery;
1384
1485
  if (filterLayer.filters.length == 0 && requiresEdgeForOrdering === false && !hasNaturalLanguageQuery) {
1385
- const result2 = await executeSupabaseQuery(
1386
- supabase,
1387
- body,
1388
- parser,
1389
- extraData,
1390
- props.signal,
1391
- config?.count
1392
- );
1393
- setExtraData((pre) => ({
1394
- ...omit(result2, "data"),
1395
- count: result2.count ? result2.count : pre.count,
1486
+ const result = await executeSupabaseQuery(supabase, body, parser, extraData, props.signal, config?.count);
1487
+ setExtraData((pre_0) => ({
1488
+ ...omit(result, "data"),
1489
+ count: result.count ? result.count : pre_0.count,
1396
1490
  key: currentKey
1397
1491
  }));
1398
- return result2;
1492
+ return result;
1399
1493
  }
1400
1494
  searchParams.forEach(([k, v]) => {
1401
1495
  if (k.includes("offset")) {
@@ -1413,16 +1507,16 @@ function useAdvancedFilterQuery(query, config) {
1413
1507
  return;
1414
1508
  }
1415
1509
  if (v.includes(".") === false) return;
1416
- const values = v.split(".");
1510
+ const values_0 = v.split(".");
1417
1511
  const column = k;
1418
- let rawCondition = values[0];
1512
+ let rawCondition = values_0[0];
1419
1513
  let condition = "";
1420
- let value = values[1];
1421
- const inverted = values[0] === "not";
1514
+ let value_0 = values_0[1];
1515
+ const inverted = values_0[0] === "not";
1422
1516
  if (column == "select") return;
1423
1517
  if (rawCondition === "not") {
1424
- rawCondition = values[1];
1425
- value = values[2];
1518
+ rawCondition = values_0[1];
1519
+ value_0 = values_0[2];
1426
1520
  }
1427
1521
  switch (rawCondition) {
1428
1522
  case "eq":
@@ -1430,7 +1524,7 @@ function useAdvancedFilterQuery(query, config) {
1430
1524
  break;
1431
1525
  case "in":
1432
1526
  condition = "in";
1433
- value = value.slice(1, value.length - 1).split(",").filter((x) => isNullOrWhitespace(x) === false);
1527
+ value_0 = value_0.slice(1, value_0.length - 1).split(",").filter((x_0) => isNullOrWhitespace(x_0) === false);
1434
1528
  break;
1435
1529
  case "lt":
1436
1530
  condition = "<";
@@ -1446,8 +1540,8 @@ function useAdvancedFilterQuery(query, config) {
1446
1540
  break;
1447
1541
  case "is":
1448
1542
  condition = "is";
1449
- if (value == "null") {
1450
- value = null;
1543
+ if (value_0 == "null") {
1544
+ value_0 = null;
1451
1545
  }
1452
1546
  break;
1453
1547
  }
@@ -1455,16 +1549,27 @@ function useAdvancedFilterQuery(query, config) {
1455
1549
  id: `filter_${column}_${Date.now()}`,
1456
1550
  field: column,
1457
1551
  op: condition,
1458
- value,
1552
+ value: value_0,
1459
1553
  not: inverted,
1460
1554
  display: column
1461
- }, { filters: [...body.filters], op: body.op ?? "AND", id: "filterstate" }];
1555
+ }, {
1556
+ filters: [...body.filters],
1557
+ op: body.op ?? "AND",
1558
+ id: "filterstate"
1559
+ }];
1462
1560
  body.op = "AND";
1463
1561
  const bodyCopy = JSON.parse(JSON.stringify(body));
1464
- bodyCopy.pagination = { page: 0, pageSize: 50 };
1562
+ bodyCopy.pagination = {
1563
+ page: 0,
1564
+ pageSize: 50
1565
+ };
1465
1566
  bodyCopy.isReady = true;
1466
1567
  });
1467
- const { data: { session } } = await supabase.auth.getSession();
1568
+ const {
1569
+ data: {
1570
+ session
1571
+ }
1572
+ } = await supabase.auth.getSession();
1468
1573
  if (!session?.access_token) {
1469
1574
  throw new Error("No active session");
1470
1575
  }
@@ -1472,29 +1577,29 @@ function useAdvancedFilterQuery(query, config) {
1472
1577
  props.signal.addEventListener("abort", () => {
1473
1578
  controller.abort();
1474
1579
  });
1475
- const timeout = setTimeout(
1476
- () => controller.abort(),
1477
- config?.timeout ?? 15e3
1478
- );
1479
- let result = null;
1480
- let response2 = { error: null, data: null };
1580
+ const timeout = setTimeout(() => controller.abort(), config?.timeout ?? 15e3);
1581
+ let result_0 = null;
1582
+ let response = {
1583
+ error: null,
1584
+ data: null
1585
+ };
1481
1586
  try {
1482
1587
  const UI_ONLY_KEYS = /* @__PURE__ */ new Set(["info", "options", "display"]);
1483
- const filteredBody = JSON.parse(JSON.stringify(body, (key, value) => {
1484
- if (UI_ONLY_KEYS.has(key)) {
1588
+ const filteredBody = JSON.parse(JSON.stringify(body, (key_0, value_1) => {
1589
+ if (UI_ONLY_KEYS.has(key_0)) {
1485
1590
  return void 0;
1486
1591
  }
1487
- return value;
1592
+ return value_1;
1488
1593
  }));
1489
1594
  filteredBody.filters = filteredBody.filters.map(normalizeFilter).filter(Boolean);
1490
1595
  const orParam = parser.searchParams.get("or");
1491
1596
  if (orParam) {
1492
1597
  const cleanedOrParam = orParam.replace(/^\(|\)$/g, "");
1493
1598
  const orConditions = cleanedOrParam.split(",");
1494
- const orFilters = orConditions.map((condition, idx) => {
1495
- const match = condition.match(/^(.+?)\.([^.]+)\.(.+)$/);
1599
+ const orFilters = orConditions.map((condition_0, idx) => {
1600
+ const match = condition_0.match(/^(.+?)\.([^.]+)\.(.+)$/);
1496
1601
  if (match) {
1497
- const [_, field, rawOp, value] = match;
1602
+ const [_, field, rawOp, value_2] = match;
1498
1603
  let op = rawOp.trim();
1499
1604
  switch (op) {
1500
1605
  case "eq":
@@ -1529,58 +1634,52 @@ function useAdvancedFilterQuery(query, config) {
1529
1634
  id: `or-${idx}`,
1530
1635
  field: field.trim(),
1531
1636
  op,
1532
- value: value.trim()
1637
+ value: value_2.trim()
1533
1638
  };
1534
1639
  }
1535
1640
  return null;
1536
1641
  }).filter(Boolean);
1537
1642
  if (orFilters.length > 0) {
1538
- filteredBody.filters = [
1539
- ...filteredBody.filters,
1540
- {
1541
- id: "base-or-group",
1542
- op: "OR",
1543
- filters: orFilters,
1544
- pagination: void 0,
1545
- sort: void 0,
1546
- isReady: true
1547
- }
1548
- ];
1643
+ filteredBody.filters = [...filteredBody.filters, {
1644
+ id: "base-or-group",
1645
+ op: "OR",
1646
+ filters: orFilters,
1647
+ pagination: void 0,
1648
+ sort: void 0,
1649
+ isReady: true
1650
+ }];
1549
1651
  }
1550
1652
  }
1551
- const res = await fetch(
1552
- `${getSupabaseUrl()}/functions/v1/query?forceDenoVersion=2`,
1553
- {
1554
- method: "POST",
1555
- headers: {
1556
- "Content-Type": "application/json",
1557
- "Authorization": `Bearer ${session.access_token}`
1653
+ const res = await fetch(`${getSupabaseUrl()}/functions/v1/query?forceDenoVersion=2`, {
1654
+ method: "POST",
1655
+ headers: {
1656
+ "Content-Type": "application/json",
1657
+ "Authorization": `Bearer ${session.access_token}`
1658
+ },
1659
+ body: JSON.stringify({
1660
+ table: parser.table,
1661
+ schema: parser.schema,
1662
+ select: parser.select,
1663
+ filters: {
1664
+ id: filteredBody.id || "root",
1665
+ op: filteredBody.op || filteredBody.operator || "AND",
1666
+ not: filteredBody.not || filteredBody.inverted,
1667
+ // Support both 'not' and legacy 'inverted'
1668
+ filters: filteredBody.filters || []
1558
1669
  },
1559
- body: JSON.stringify({
1560
- table: parser.table,
1561
- schema: parser.schema,
1562
- select: parser.select,
1563
- filters: {
1564
- id: filteredBody.id || "root",
1565
- op: filteredBody.op || filteredBody.operator || "AND",
1566
- not: filteredBody.not || filteredBody.inverted,
1567
- // Support both 'not' and legacy 'inverted'
1568
- filters: filteredBody.filters || []
1569
- },
1570
- pagination: filteredBody.pagination,
1571
- sort: filteredBody.sort,
1572
- distinctOn: filteredBody.distinctOn,
1573
- naturalLanguageQuery: filteredBody.naturalLanguageQuery,
1574
- count: currentKey === extraData.key ? "" : config?.count ?? "",
1575
- debug: true
1576
- }),
1577
- signal: controller.signal
1578
- }
1579
- );
1670
+ pagination: filteredBody.pagination,
1671
+ sort: filteredBody.sort,
1672
+ distinctOn: filteredBody.distinctOn,
1673
+ naturalLanguageQuery: filteredBody.naturalLanguageQuery,
1674
+ count: currentKey === extraData.key ? "" : config?.count ?? "",
1675
+ debug: true
1676
+ }),
1677
+ signal: controller.signal
1678
+ });
1580
1679
  if (!res.ok) {
1581
1680
  const errorData = await res.json();
1582
- const errorMessage = typeof errorData?.error === "string" ? errorData.error : errorData?.error?.message || errorData?.message || "An error occurred while processing your request";
1583
- throw new Error(errorMessage);
1681
+ const errorMessage_0 = typeof errorData?.error === "string" ? errorData.error : errorData?.error?.message || errorData?.message || "An error occurred while processing your request";
1682
+ throw new Error(errorMessage_0);
1584
1683
  }
1585
1684
  const data = await res.json();
1586
1685
  if (data.clarification) {
@@ -1592,45 +1691,57 @@ function useAdvancedFilterQuery(query, config) {
1592
1691
  error: void 0
1593
1692
  };
1594
1693
  }
1595
- result = data;
1596
- response2 = { error: null, data };
1694
+ result_0 = data;
1695
+ response = {
1696
+ error: null,
1697
+ data
1698
+ };
1597
1699
  } catch (err) {
1598
1700
  if (err.name === "AbortError") {
1599
1701
  console.error("Fetch aborted/time-out");
1600
- response2 = { error: new Error("This query timed out"), data: null };
1702
+ response = {
1703
+ error: new Error("This query timed out"),
1704
+ data: null
1705
+ };
1601
1706
  } else if (err instanceof Error) {
1602
- response2 = { error: err, data: null };
1707
+ response = {
1708
+ error: err,
1709
+ data: null
1710
+ };
1603
1711
  } else {
1604
1712
  const errorMessage = err?.error || err?.message || String(err);
1605
- response2 = { error: new Error(errorMessage), data: null };
1713
+ response = {
1714
+ error: new Error(errorMessage),
1715
+ data: null
1716
+ };
1606
1717
  }
1607
1718
  } finally {
1608
1719
  clearTimeout(timeout);
1609
1720
  }
1610
- if (response2.error) {
1611
- throw response2.error;
1612
- } else if (response2.data?.error) {
1613
- throw new Error(response2.data.error);
1721
+ if (response.error) {
1722
+ throw response.error;
1723
+ } else if (response.data?.error) {
1724
+ throw new Error(response.data.error);
1614
1725
  }
1615
- if (result.clarification) {
1726
+ if (result_0.clarification) {
1616
1727
  return {
1617
1728
  data: [],
1618
1729
  count: 0,
1619
- clarification: result.clarification,
1730
+ clarification: result_0.clarification,
1620
1731
  error: void 0
1621
1732
  };
1622
1733
  }
1623
- setExtraData((pre) => ({
1624
- ...omit(result, "data"),
1625
- count: pre.key === currentKey ? pre.count : result.count,
1734
+ setExtraData((pre_1) => ({
1735
+ ...omit(result_0, "data"),
1736
+ count: pre_1.key === currentKey ? pre_1.count : result_0.count,
1626
1737
  key: currentKey
1627
1738
  }));
1628
1739
  return {
1629
- ...result,
1740
+ ...result_0,
1630
1741
  statusText: "",
1631
- status: result.data?.length > result.count ? 206 : 200,
1632
- error: response2.data?.error ?? null,
1633
- hasMore: result.data?.length < result.count ? true : false
1742
+ status: result_0.data?.length > result_0.count ? 206 : 200,
1743
+ error: response.data?.error ?? null,
1744
+ hasMore: result_0.data?.length < result_0.count ? true : false
1634
1745
  };
1635
1746
  } catch (error) {
1636
1747
  if (error instanceof Error && error.name === "AbortError") {
@@ -1645,17 +1756,17 @@ function useAdvancedFilterQuery(query, config) {
1645
1756
  }
1646
1757
  }
1647
1758
  });
1648
- const response = {
1759
+ const response_0 = {
1649
1760
  ...queryResponse,
1650
1761
  data: queryResponse.data?.data,
1651
1762
  count: extraData.count,
1652
1763
  clarification: queryResponse.data?.clarification
1653
1764
  };
1654
1765
  useEffect(() => {
1655
- if (queryResponse.isFetched && response.count == null) {
1766
+ if (queryResponse.isFetched && response_0.count == null) {
1656
1767
  queryResponse.refetch();
1657
1768
  }
1658
- }, [response.count]);
1769
+ }, [response_0.count]);
1659
1770
  useEffect(() => {
1660
1771
  if (queryResponse.data?.error == null) return;
1661
1772
  if (queryResponse.data?.error?.message?.includes(" does not exist")) {
@@ -1669,7 +1780,7 @@ function useAdvancedFilterQuery(query, config) {
1669
1780
  });
1670
1781
  }
1671
1782
  }, [queryResponse.data?.error]);
1672
- return [response, filterLayer, setFilterLayer];
1783
+ return [response_0, filterLayer, setFilterLayer];
1673
1784
  }
1674
1785
  function isSearchableColumn(columnName) {
1675
1786
  return true;
@@ -1682,7 +1793,9 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
1682
1793
  });
1683
1794
  if (body.sort && Array.isArray(body.sort)) {
1684
1795
  body.sort.forEach((s) => {
1685
- query.order(s.field, { ascending: s.direction === "asc" });
1796
+ query.order(s.field, {
1797
+ ascending: s.direction === "asc"
1798
+ });
1686
1799
  });
1687
1800
  }
1688
1801
  const from = searchParams.find((x) => x[0].includes("offset"))?.[1];
@@ -1697,7 +1810,7 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
1697
1810
  return;
1698
1811
  }
1699
1812
  if (k === "or") {
1700
- query.or(v.slice(1, v.length - 2));
1813
+ query.or(v.slice(1, v.length - 1));
1701
1814
  return;
1702
1815
  }
1703
1816
  const values = v.split(".");
@@ -1705,6 +1818,7 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
1705
1818
  let rawCondition = values[0];
1706
1819
  let value = values[1];
1707
1820
  if (column == "select") return;
1821
+ if (column == "order") return;
1708
1822
  if (v.includes(".") === false) return;
1709
1823
  if (rawCondition === "ilike" && !isSearchableColumn(column)) {
1710
1824
  return;
@@ -1734,10 +1848,8 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
1734
1848
  var useAdvancedQuery = useAdvancedFilterQuery;
1735
1849
 
1736
1850
  // src/query/useInfiniteQuery.ts
1737
- import {
1738
- useInfiniteQuery as useTanstackInfiniteQuery
1739
- } from "@tanstack/react-query";
1740
- import { useMemo as useMemo4, useRef as useRef2 } from "react";
1851
+ import { useInfiniteQuery as useTanstackInfiniteQuery } from "@tanstack/react-query";
1852
+ import { useMemo as useMemo2, useRef as useRef2 } from "react";
1741
1853
  function useInfiniteQuery(query, countPerLoad, config) {
1742
1854
  const initialQueryKey = encode(query, false).join("-");
1743
1855
  const lastKnownQuery = useRef2(initialQueryKey);
@@ -1747,23 +1859,23 @@ function useInfiniteQuery(query, countPerLoad, config) {
1747
1859
  currentPageNumber.current = 1;
1748
1860
  }
1749
1861
  const isFetching = useRef2(false);
1750
- const queryKey = useMemo4(
1751
- () => encode(query, false),
1752
- [initialQueryKey, config?.crossOrganization]
1753
- );
1862
+ const queryKey = useMemo2(() => encode(query, false), [initialQueryKey, config?.crossOrganization]);
1754
1863
  const getQuery = useTanstackInfiniteQuery({
1755
1864
  ...config,
1756
1865
  queryKey,
1757
- queryFn: async ({ pageParam, signal }) => {
1866
+ queryFn: async ({
1867
+ pageParam,
1868
+ signal
1869
+ }) => {
1758
1870
  let adjustableQuery = query;
1759
1871
  const pageNumber = pageParam;
1760
1872
  if (config?.onQuery && config?.enableOnQuery) {
1761
- config?.onQuery({ query: adjustableQuery, pageParam: pageNumber });
1873
+ config?.onQuery({
1874
+ query: adjustableQuery,
1875
+ pageParam: pageNumber
1876
+ });
1762
1877
  } else {
1763
- adjustableQuery = adjustableQuery.range(
1764
- (pageNumber - 1) * countPerLoad,
1765
- pageNumber * countPerLoad - 1
1766
- );
1878
+ adjustableQuery = adjustableQuery.range((pageNumber - 1) * countPerLoad, pageNumber * countPerLoad - 1);
1767
1879
  }
1768
1880
  adjustableQuery = adjustableQuery.abortSignal(signal);
1769
1881
  updatedCache.current = false;
@@ -1776,119 +1888,209 @@ function useInfiniteQuery(query, countPerLoad, config) {
1776
1888
  }
1777
1889
  },
1778
1890
  initialPageParam: 1,
1779
- getNextPageParam: (response, allResponses, lastParam) => {
1780
- const pageParam = lastParam;
1781
- const resp = response;
1891
+ getNextPageParam: (response_0, allResponses, lastParam) => {
1892
+ const pageParam_0 = lastParam;
1893
+ const resp = response_0;
1782
1894
  if (allResponses.length * countPerLoad >= (resp?.count ?? 0)) {
1783
1895
  return void 0;
1784
1896
  }
1785
- return pageParam + 1;
1897
+ return pageParam_0 + 1;
1786
1898
  }
1787
1899
  });
1788
1900
  const updatedCache = useRef2(true);
1789
- return useMemo4(
1790
- () => {
1791
- const pages = getQuery.data?.pages;
1792
- return {
1793
- ...getQuery,
1794
- count: pages?.[pages.length - 1]?.count,
1795
- data: pages?.flatMap((x) => x.data ?? [])
1796
- };
1797
- },
1798
- [getQuery.data, currentPageNumber.current]
1799
- );
1901
+ return useMemo2(() => {
1902
+ const pages = getQuery.data?.pages;
1903
+ return {
1904
+ ...getQuery,
1905
+ count: pages?.[pages.length - 1]?.count,
1906
+ data: pages?.flatMap((x) => x.data ?? [])
1907
+ };
1908
+ }, [getQuery.data, currentPageNumber.current]);
1800
1909
  }
1801
1910
 
1802
1911
  // src/query/usePartialAdvancedQuery.ts
1803
- import { useLayoutEffect, useMemo as useMemo5, useState as useState2 } from "react";
1912
+ import { c as _c3 } from "react/compiler-runtime";
1913
+ import { useLayoutEffect, useState as useState2 } from "react";
1804
1914
  import { useSessionStorageState as useSessionStorageState3 } from "@pol-studios/hooks/storage";
1805
1915
  function usePartialAdvancedQuery(query, itemCountPerPage, config) {
1916
+ const $ = _c3(54);
1806
1917
  const initialQuery = encode(query, false);
1807
1918
  const [id, setId] = useState2(window.location.pathname);
1808
- const [currentPage, setCurrentPage] = useSessionStorageState3(
1809
- `${id}-currentPage`,
1810
- 1
1811
- );
1812
- const rangedQuery = useMemo5(
1813
- () => {
1814
- const page = currentPage ?? 1;
1815
- return query.range(
1816
- (page - 1) * itemCountPerPage,
1817
- page * itemCountPerPage - 1
1818
- );
1819
- },
1820
- [query, currentPage, itemCountPerPage]
1821
- );
1822
- const [baseQuery, filter, setFilters] = useAdvancedFilterQuery(
1823
- rangedQuery,
1824
- {
1919
+ const [currentPage, setCurrentPage] = useSessionStorageState3(`${id}-currentPage`, 1);
1920
+ const page = currentPage ?? 1;
1921
+ const t0 = query;
1922
+ let t1;
1923
+ if ($[0] !== itemCountPerPage || $[1] !== page || $[2] !== t0) {
1924
+ t1 = t0.range((page - 1) * itemCountPerPage, page * itemCountPerPage - 1);
1925
+ $[0] = itemCountPerPage;
1926
+ $[1] = page;
1927
+ $[2] = t0;
1928
+ $[3] = t1;
1929
+ } else {
1930
+ t1 = $[3];
1931
+ }
1932
+ const rangedQuery = t1;
1933
+ const t2 = config?.filterKey;
1934
+ const t3 = currentPage ?? 1;
1935
+ let t4;
1936
+ if ($[4] !== t3) {
1937
+ t4 = t3.toString();
1938
+ $[4] = t3;
1939
+ $[5] = t4;
1940
+ } else {
1941
+ t4 = $[5];
1942
+ }
1943
+ let t5;
1944
+ if ($[6] !== config || $[7] !== t2 || $[8] !== t4) {
1945
+ t5 = {
1825
1946
  ...config,
1826
- filterKey: config?.filterKey,
1947
+ filterKey: t2,
1827
1948
  count: "exact",
1828
- key: (currentPage ?? 1).toString()
1829
- }
1830
- );
1831
- const filterKey = JSON.stringify(omit(filter, ["pagination"]));
1832
- const select = initialQuery[4].split("&").find(
1833
- (x) => x.startsWith("select=")
1834
- );
1835
- useLayoutEffect(() => {
1836
- const newId = [
1837
- initialQuery[3],
1838
- select,
1839
- initialQuery[5],
1840
- initialQuery[6],
1841
- initialQuery[7],
1842
- initialQuery[8],
1843
- filterKey
1844
- ].join("-");
1845
- console.log({ newId, id });
1846
- setId(newId);
1847
- }, [
1848
- initialQuery[3],
1849
- select,
1850
- initialQuery[5],
1851
- initialQuery[6],
1852
- initialQuery[7],
1853
- initialQuery[8],
1854
- filterKey
1855
- ]);
1856
- const safeFetchNextPage = () => {
1857
- setCurrentPage((currentPage2) => (currentPage2 ?? 1) + 1);
1858
- };
1859
- const fetchPreviousPage = () => {
1860
- setCurrentPage((currentPage2) => (currentPage2 ?? 1) - 1);
1861
- };
1862
- const pageCount = Math.max(
1863
- Math.ceil(
1864
- (baseQuery.count ?? 0) / itemCountPerPage
1865
- ),
1866
- 1
1867
- );
1868
- const request = {
1869
- ...baseQuery,
1870
- clarification: baseQuery.clarification,
1871
- // Explicitly pass through clarification
1872
- fetchPreviousPage,
1873
- fetchNextPage: safeFetchNextPage,
1874
- currentPage,
1875
- setCurrentPage,
1876
- data: baseQuery.data ? toPagedResponse2(
1877
- baseQuery.data,
1878
- currentPage ?? 1,
1879
- baseQuery.count ?? baseQuery.data.length,
1880
- itemCountPerPage
1881
- ) : null,
1882
- pageCount,
1883
- hasNextPage: (currentPage ?? 1) < pageCount,
1884
- hasPreviousPage: (currentPage ?? 1) > 1,
1885
- count: baseQuery.count ?? baseQuery.data?.length
1886
- };
1887
- return [
1888
- request,
1889
- filter,
1890
- setFilters
1891
- ];
1949
+ key: t4
1950
+ };
1951
+ $[6] = config;
1952
+ $[7] = t2;
1953
+ $[8] = t4;
1954
+ $[9] = t5;
1955
+ } else {
1956
+ t5 = $[9];
1957
+ }
1958
+ const [baseQuery, filter, setFilters] = useAdvancedFilterQuery(rangedQuery, t5);
1959
+ let t6;
1960
+ if ($[10] !== filter) {
1961
+ t6 = JSON.stringify(omit(filter, ["pagination"]));
1962
+ $[10] = filter;
1963
+ $[11] = t6;
1964
+ } else {
1965
+ t6 = $[11];
1966
+ }
1967
+ const filterKey = t6;
1968
+ const select = initialQuery[4].split("&").find(_temp4);
1969
+ let t7;
1970
+ if ($[12] !== filterKey || $[13] !== id || $[14] !== initialQuery[3] || $[15] !== initialQuery[5] || $[16] !== initialQuery[6] || $[17] !== initialQuery[7] || $[18] !== initialQuery[8] || $[19] !== select || $[20] !== setId) {
1971
+ t7 = () => {
1972
+ const newId = [initialQuery[3], select, initialQuery[5], initialQuery[6], initialQuery[7], initialQuery[8], filterKey].join("-");
1973
+ console.log({
1974
+ newId,
1975
+ id
1976
+ });
1977
+ setId(newId);
1978
+ };
1979
+ $[12] = filterKey;
1980
+ $[13] = id;
1981
+ $[14] = initialQuery[3];
1982
+ $[15] = initialQuery[5];
1983
+ $[16] = initialQuery[6];
1984
+ $[17] = initialQuery[7];
1985
+ $[18] = initialQuery[8];
1986
+ $[19] = select;
1987
+ $[20] = setId;
1988
+ $[21] = t7;
1989
+ } else {
1990
+ t7 = $[21];
1991
+ }
1992
+ let t8;
1993
+ if ($[22] !== filterKey || $[23] !== initialQuery[3] || $[24] !== initialQuery[5] || $[25] !== initialQuery[6] || $[26] !== initialQuery[7] || $[27] !== initialQuery[8] || $[28] !== select) {
1994
+ t8 = [initialQuery[3], select, initialQuery[5], initialQuery[6], initialQuery[7], initialQuery[8], filterKey];
1995
+ $[22] = filterKey;
1996
+ $[23] = initialQuery[3];
1997
+ $[24] = initialQuery[5];
1998
+ $[25] = initialQuery[6];
1999
+ $[26] = initialQuery[7];
2000
+ $[27] = initialQuery[8];
2001
+ $[28] = select;
2002
+ $[29] = t8;
2003
+ } else {
2004
+ t8 = $[29];
2005
+ }
2006
+ useLayoutEffect(t7, t8);
2007
+ let t9;
2008
+ if ($[30] !== setCurrentPage) {
2009
+ t9 = () => {
2010
+ setCurrentPage(_temp22);
2011
+ };
2012
+ $[30] = setCurrentPage;
2013
+ $[31] = t9;
2014
+ } else {
2015
+ t9 = $[31];
2016
+ }
2017
+ const safeFetchNextPage = t9;
2018
+ let t10;
2019
+ if ($[32] !== setCurrentPage) {
2020
+ t10 = () => {
2021
+ setCurrentPage(_temp3);
2022
+ };
2023
+ $[32] = setCurrentPage;
2024
+ $[33] = t10;
2025
+ } else {
2026
+ t10 = $[33];
2027
+ }
2028
+ const fetchPreviousPage = t10;
2029
+ const pageCount = Math.max(Math.ceil((baseQuery.count ?? 0) / itemCountPerPage), 1);
2030
+ let t11;
2031
+ if ($[34] !== baseQuery.count || $[35] !== baseQuery.data || $[36] !== currentPage || $[37] !== itemCountPerPage) {
2032
+ t11 = baseQuery.data ? toPagedResponse2(baseQuery.data, currentPage ?? 1, baseQuery.count ?? baseQuery.data.length, itemCountPerPage) : null;
2033
+ $[34] = baseQuery.count;
2034
+ $[35] = baseQuery.data;
2035
+ $[36] = currentPage;
2036
+ $[37] = itemCountPerPage;
2037
+ $[38] = t11;
2038
+ } else {
2039
+ t11 = $[38];
2040
+ }
2041
+ const t12 = (currentPage ?? 1) < pageCount;
2042
+ const t13 = (currentPage ?? 1) > 1;
2043
+ const t14 = baseQuery.count ?? baseQuery.data?.length;
2044
+ let t15;
2045
+ if ($[39] !== baseQuery || $[40] !== currentPage || $[41] !== fetchPreviousPage || $[42] !== pageCount || $[43] !== safeFetchNextPage || $[44] !== setCurrentPage || $[45] !== t11 || $[46] !== t12 || $[47] !== t13 || $[48] !== t14) {
2046
+ t15 = {
2047
+ ...baseQuery,
2048
+ clarification: baseQuery.clarification,
2049
+ fetchPreviousPage,
2050
+ fetchNextPage: safeFetchNextPage,
2051
+ currentPage,
2052
+ setCurrentPage,
2053
+ data: t11,
2054
+ pageCount,
2055
+ hasNextPage: t12,
2056
+ hasPreviousPage: t13,
2057
+ count: t14
2058
+ };
2059
+ $[39] = baseQuery;
2060
+ $[40] = currentPage;
2061
+ $[41] = fetchPreviousPage;
2062
+ $[42] = pageCount;
2063
+ $[43] = safeFetchNextPage;
2064
+ $[44] = setCurrentPage;
2065
+ $[45] = t11;
2066
+ $[46] = t12;
2067
+ $[47] = t13;
2068
+ $[48] = t14;
2069
+ $[49] = t15;
2070
+ } else {
2071
+ t15 = $[49];
2072
+ }
2073
+ const request = t15;
2074
+ let t16;
2075
+ if ($[50] !== filter || $[51] !== request || $[52] !== setFilters) {
2076
+ t16 = [request, filter, setFilters];
2077
+ $[50] = filter;
2078
+ $[51] = request;
2079
+ $[52] = setFilters;
2080
+ $[53] = t16;
2081
+ } else {
2082
+ t16 = $[53];
2083
+ }
2084
+ return t16;
2085
+ }
2086
+ function _temp3(currentPage_1) {
2087
+ return (currentPage_1 ?? 1) - 1;
2088
+ }
2089
+ function _temp22(currentPage_0) {
2090
+ return (currentPage_0 ?? 1) + 1;
2091
+ }
2092
+ function _temp4(x) {
2093
+ return x.startsWith("select=");
1892
2094
  }
1893
2095
  function toPagedResponse2(results, currentPage, totalCount, itemPerPage) {
1894
2096
  const newPage = {
@@ -1924,4 +2126,4 @@ export {
1924
2126
  useInfiniteQuery,
1925
2127
  usePartialAdvancedQuery
1926
2128
  };
1927
- //# sourceMappingURL=chunk-ZTSBF536.js.map
2129
+ //# sourceMappingURL=chunk-X3HZLNBV.js.map