@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.
- package/dist/DataLayerContext-CL6alnkb.d.ts +755 -0
- package/dist/UserMetadataContext-B8gVWGMl.d.ts +35 -0
- package/dist/UserMetadataContext-DntmpK41.d.ts +33 -0
- package/dist/auth/context.d.ts +3 -2
- package/dist/auth/context.js +5 -4
- package/dist/auth/guards.js +2 -2
- package/dist/auth/hooks.d.ts +3 -3
- package/dist/auth/hooks.js +6 -5
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.js +8 -6
- package/dist/{canvas-UVNDA54X.node → canvas-C4TBBDUL.node} +0 -0
- package/dist/{canvas-75Y7XMF3.js → canvas-ZQNCL7JL.js} +2 -2
- package/dist/chunk-5EFDS7SR.js +205 -0
- package/dist/chunk-5EFDS7SR.js.map +1 -0
- package/dist/{chunk-BRTW7CO5.js → chunk-7SCJNYTE.js} +1 -9
- package/dist/chunk-7SCJNYTE.js.map +1 -0
- package/dist/chunk-DJ6VLEAL.js +247 -0
- package/dist/chunk-DJ6VLEAL.js.map +1 -0
- package/dist/{chunk-Y3INY2CS.js → chunk-GC3TBUWE.js} +1 -1
- package/dist/chunk-GC3TBUWE.js.map +1 -0
- package/dist/{chunk-7HG6G25H.js → chunk-H3LNH2NT.js} +169 -268
- package/dist/chunk-H3LNH2NT.js.map +1 -0
- package/dist/{chunk-USJYMRUO.js → chunk-HAWJTZCK.js} +2 -2
- package/dist/chunk-HAWJTZCK.js.map +1 -0
- package/dist/chunk-JAATANS3.js +429 -0
- package/dist/chunk-JAATANS3.js.map +1 -0
- package/dist/chunk-LNJ3WF7V.js +470 -0
- package/dist/chunk-LNJ3WF7V.js.map +1 -0
- package/dist/chunk-N26IEHZT.js +79 -0
- package/dist/chunk-N26IEHZT.js.map +1 -0
- package/dist/chunk-NSIAAYW3.js +1 -0
- package/dist/chunk-NSIAAYW3.js.map +1 -0
- package/dist/chunk-NZON56CB.js +3864 -0
- package/dist/chunk-NZON56CB.js.map +1 -0
- package/dist/{chunk-O3K7R32P.js → chunk-OQ7U6EQ3.js} +118 -123
- package/dist/chunk-OQ7U6EQ3.js.map +1 -0
- package/dist/chunk-SM73S2DY.js +11 -0
- package/dist/chunk-SM73S2DY.js.map +1 -0
- package/dist/{chunk-JUVE3DWY.js → chunk-TKWR5AAY.js} +47 -65
- package/dist/chunk-TKWR5AAY.js.map +1 -0
- package/dist/{chunk-2IFGILT3.js → chunk-U5UNPBKB.js} +76 -107
- package/dist/chunk-U5UNPBKB.js.map +1 -0
- package/dist/chunk-WGDJ4IXR.js +921 -0
- package/dist/chunk-WGDJ4IXR.js.map +1 -0
- package/dist/chunk-WVF7RUW5.js +186 -0
- package/dist/chunk-WVF7RUW5.js.map +1 -0
- package/dist/{chunk-ZTSBF536.js → chunk-X3HZLNBV.js} +637 -435
- package/dist/chunk-X3HZLNBV.js.map +1 -0
- package/dist/{chunk-EL45Z26M.js → chunk-XU3SBFAG.js} +1219 -208
- package/dist/chunk-XU3SBFAG.js.map +1 -0
- package/dist/chunk-ZVBHWU7O.js +1412 -0
- package/dist/chunk-ZVBHWU7O.js.map +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +42 -23
- package/dist/client/index.js.map +1 -1
- package/dist/core/index.d.ts +19 -0
- package/dist/{index-BFu5_dS8.d.ts → database.types-ChFCG-4M.d.ts} +1 -177
- package/dist/gen/index.js +4 -2
- package/dist/hooks/index.d.ts +10 -3
- package/dist/hooks/index.js +8 -10
- package/dist/index-CQLyNG6A.d.ts +433 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +92 -48
- package/dist/index.native.d.ts +373 -33
- package/dist/index.native.js +79 -47
- package/dist/index.web.d.ts +10 -7
- package/dist/index.web.js +83 -78
- package/dist/index.web.js.map +1 -1
- package/dist/mutation/index.d.ts +2 -2
- package/dist/mutation/index.js +307 -122
- package/dist/mutation/index.js.map +1 -1
- package/dist/parser/index.js +2 -2
- package/dist/{pdf-3TIGQRLA.js → pdf-PHXP7RHD.js} +2 -2
- package/dist/powersync-bridge/index.d.ts +284 -0
- package/dist/powersync-bridge/index.js +22 -0
- package/dist/powersync-bridge/index.js.map +1 -0
- package/dist/query/index.js +5 -5
- package/dist/realtime/index.js +252 -128
- package/dist/realtime/index.js.map +1 -1
- package/dist/{UserMetadataContext-BYYqA6LI.d.ts → setupAuthContext-Kv-THH-h.d.ts} +1 -29
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.js +10 -5
- package/dist/{useBatchUpsert-CSQVX7w8.d.ts → useBatchUpsert-9OYjibLh.d.ts} +1 -1
- package/dist/{useDbCount-RGCuHmHp.d.ts → useDbCount-BG356T9i.d.ts} +3 -719
- package/dist/{useReceiptAI-Bn0czE7C.d.ts → useReceiptAI-6HkRpRml.d.ts} +1 -1
- package/dist/{useResolveFeedback-CpZPP8Pw.d.ts → useResolveFeedback-BWmatBlE.d.ts} +26 -45
- package/dist/{useSupabase-pPhUZHcl.d.ts → useSupabase-DvWVuHHE.d.ts} +2 -1
- package/dist/with-auth/index.d.ts +704 -0
- package/dist/with-auth/index.js +1221 -0
- package/dist/with-auth/index.js.map +1 -0
- package/package.json +25 -10
- package/dist/chunk-2IFGILT3.js.map +0 -1
- package/dist/chunk-3M2U6TXH.js +0 -928
- package/dist/chunk-3M2U6TXH.js.map +0 -1
- package/dist/chunk-5ZYAEGCJ.js +0 -416
- package/dist/chunk-5ZYAEGCJ.js.map +0 -1
- package/dist/chunk-7HG6G25H.js.map +0 -1
- package/dist/chunk-7XT7K4QT.js +0 -2687
- package/dist/chunk-7XT7K4QT.js.map +0 -1
- package/dist/chunk-AWFMICFV.js +0 -158
- package/dist/chunk-AWFMICFV.js.map +0 -1
- package/dist/chunk-BRTW7CO5.js.map +0 -1
- package/dist/chunk-EL45Z26M.js.map +0 -1
- package/dist/chunk-ERGF2FCE.js +0 -903
- package/dist/chunk-ERGF2FCE.js.map +0 -1
- package/dist/chunk-GK7B66LY.js +0 -135
- package/dist/chunk-GK7B66LY.js.map +0 -1
- package/dist/chunk-GQI6WJGI.js +0 -172
- package/dist/chunk-GQI6WJGI.js.map +0 -1
- package/dist/chunk-JUVE3DWY.js.map +0 -1
- package/dist/chunk-O3K7R32P.js.map +0 -1
- package/dist/chunk-SEY5UO2T.js +0 -89
- package/dist/chunk-SEY5UO2T.js.map +0 -1
- package/dist/chunk-USJYMRUO.js.map +0 -1
- package/dist/chunk-XX3IWSPM.js +0 -189
- package/dist/chunk-XX3IWSPM.js.map +0 -1
- package/dist/chunk-Y3INY2CS.js.map +0 -1
- package/dist/chunk-ZTSBF536.js.map +0 -1
- /package/dist/{canvas-75Y7XMF3.js.map → canvas-ZQNCL7JL.js.map} +0 -0
- /package/dist/{pdf-3TIGQRLA.js.map → pdf-PHXP7RHD.js.map} +0 -0
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSupabaseUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GC3TBUWE.js";
|
|
4
4
|
import {
|
|
5
5
|
PostgrestParser
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TKWR5AAY.js";
|
|
7
7
|
import {
|
|
8
8
|
isNullOrWhitespace,
|
|
9
9
|
isUsable,
|
|
10
10
|
omit
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-OQ7U6EQ3.js";
|
|
12
12
|
import {
|
|
13
13
|
encode
|
|
14
14
|
} from "./chunk-H6365JPC.js";
|
|
15
15
|
import {
|
|
16
16
|
generateUUID,
|
|
17
17
|
useSupabase
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5EFDS7SR.js";
|
|
19
|
+
|
|
20
|
+
// src/types/powersync-integration.ts
|
|
21
|
+
function createCombinedStatus(dataLayerStatus, powerSyncStatus) {
|
|
22
|
+
return {
|
|
23
|
+
dataLayer: dataLayerStatus,
|
|
24
|
+
powerSync: powerSyncStatus,
|
|
25
|
+
overall: {
|
|
26
|
+
isReady: dataLayerStatus.isInitialized && powerSyncStatus.isReady,
|
|
27
|
+
isInitializing: !dataLayerStatus.isInitialized || powerSyncStatus.isInitializing,
|
|
28
|
+
error: dataLayerStatus.error || powerSyncStatus.error
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
19
32
|
|
|
20
33
|
// src/database.types.ts
|
|
21
34
|
var Constants = {
|
|
22
35
|
core: {
|
|
23
36
|
Enums: {
|
|
24
|
-
AdvanceQueryChangeType: [
|
|
25
|
-
"Removed",
|
|
26
|
-
"Deleted",
|
|
27
|
-
"Created",
|
|
28
|
-
"Updated",
|
|
29
|
-
"Added"
|
|
30
|
-
],
|
|
37
|
+
AdvanceQueryChangeType: ["Removed", "Deleted", "Created", "Updated", "Added"],
|
|
31
38
|
NotificationType: ["App", "Email", "Push"],
|
|
32
39
|
OperationType: ["Insert", "Update", "Delete"],
|
|
33
40
|
PriorityLevel: ["Lowest", "Low", "Medium", "High", "Highest"],
|
|
@@ -37,71 +44,17 @@ var Constants = {
|
|
|
37
44
|
},
|
|
38
45
|
public: {
|
|
39
46
|
Enums: {
|
|
40
|
-
AdvanceQueryChangeType: [
|
|
41
|
-
"Removed",
|
|
42
|
-
"Deleted",
|
|
43
|
-
"Created",
|
|
44
|
-
"Updated",
|
|
45
|
-
"Added"
|
|
46
|
-
],
|
|
47
|
+
AdvanceQueryChangeType: ["Removed", "Deleted", "Created", "Updated", "Added"],
|
|
47
48
|
BillableItemType: ["TimeActivity", "Expense", "Service", "Retainage"],
|
|
48
|
-
BillingStatus: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"Billable",
|
|
52
|
-
"AddedToInvoice",
|
|
53
|
-
"HasBeenBilled",
|
|
54
|
-
"BilledElsewhere",
|
|
55
|
-
"LumpSum"
|
|
56
|
-
],
|
|
57
|
-
ControlType: [
|
|
58
|
-
"Unknown",
|
|
59
|
-
"DMX",
|
|
60
|
-
"ACN",
|
|
61
|
-
"ArtNet",
|
|
62
|
-
"None",
|
|
63
|
-
"DMXPT",
|
|
64
|
-
"PWR",
|
|
65
|
-
"SA",
|
|
66
|
-
"KiNET",
|
|
67
|
-
"ZTTV"
|
|
68
|
-
],
|
|
69
|
-
ExpenseReportStatus: [
|
|
70
|
-
"Pending",
|
|
71
|
-
"Open",
|
|
72
|
-
"Submitted",
|
|
73
|
-
"UnderReview",
|
|
74
|
-
"Approved",
|
|
75
|
-
"Reimbursed",
|
|
76
|
-
"Closed"
|
|
77
|
-
],
|
|
49
|
+
BillingStatus: ["Unknown", "NotBillable", "Billable", "AddedToInvoice", "HasBeenBilled", "BilledElsewhere", "LumpSum"],
|
|
50
|
+
ControlType: ["Unknown", "DMX", "ACN", "ArtNet", "None", "DMXPT", "PWR", "SA", "KiNET", "ZTTV"],
|
|
51
|
+
ExpenseReportStatus: ["Pending", "Open", "Submitted", "UnderReview", "Approved", "Reimbursed", "Closed"],
|
|
78
52
|
HighlightStatus: ["Queued", "Executed", "Failed", "Cleared"],
|
|
79
|
-
InvoiceStatus: [
|
|
80
|
-
|
|
81
|
-
"ReadyToReview",
|
|
82
|
-
"Reviewed",
|
|
83
|
-
"ReadyToSend",
|
|
84
|
-
"Sent",
|
|
85
|
-
"Rejected",
|
|
86
|
-
"Paid"
|
|
87
|
-
],
|
|
88
|
-
MediaContentStatus: [
|
|
89
|
-
"Unknown",
|
|
90
|
-
"Required",
|
|
91
|
-
"Preferred",
|
|
92
|
-
"NotRequired",
|
|
93
|
-
"Retake",
|
|
94
|
-
"Taken"
|
|
95
|
-
],
|
|
53
|
+
InvoiceStatus: ["Created", "ReadyToReview", "Reviewed", "ReadyToSend", "Sent", "Rejected", "Paid"],
|
|
54
|
+
MediaContentStatus: ["Unknown", "Required", "Preferred", "NotRequired", "Retake", "Taken"],
|
|
96
55
|
NotificationType: ["App", "Email", "Push"],
|
|
97
56
|
OperationType: ["Insert", "Update", "Delete"],
|
|
98
|
-
PhaseBillingType: [
|
|
99
|
-
"TBD",
|
|
100
|
-
"NotBillable",
|
|
101
|
-
"LumpSum",
|
|
102
|
-
"TimeAndMaterials",
|
|
103
|
-
"Expenses"
|
|
104
|
-
],
|
|
57
|
+
PhaseBillingType: ["TBD", "NotBillable", "LumpSum", "TimeAndMaterials", "Expenses"],
|
|
105
58
|
Platform: ["Web", "Mobile"],
|
|
106
59
|
pricing_plan_interval: ["day", "week", "month", "year"],
|
|
107
60
|
pricing_type: ["one_time", "recurring"],
|
|
@@ -109,40 +62,11 @@ var Constants = {
|
|
|
109
62
|
ProcessingStatus: ["None", "Processing", "Error"],
|
|
110
63
|
ProjectDocumentType: ["Proposal", "Directive", "Contract"],
|
|
111
64
|
ProjectStatus: ["Active", "Inactive", "Archived"],
|
|
112
|
-
PublicAccessType: [
|
|
113
|
-
"Public",
|
|
114
|
-
"Unlisted",
|
|
115
|
-
"InviteOnly",
|
|
116
|
-
"Private",
|
|
117
|
-
"Internal"
|
|
118
|
-
],
|
|
65
|
+
PublicAccessType: ["Public", "Unlisted", "InviteOnly", "Private", "Internal"],
|
|
119
66
|
PunchListItemStatus: ["NotStarted", "InProgress", "Finished"],
|
|
120
67
|
RevitChangeType: ["Unknown", "Added", "Modified", "Deleted"],
|
|
121
|
-
subscription_status: [
|
|
122
|
-
|
|
123
|
-
"active",
|
|
124
|
-
"canceled",
|
|
125
|
-
"incomplete",
|
|
126
|
-
"incomplete_expired",
|
|
127
|
-
"past_due",
|
|
128
|
-
"unpaid"
|
|
129
|
-
],
|
|
130
|
-
TaskRunStatus: [
|
|
131
|
-
"PENDING",
|
|
132
|
-
"EXECUTING",
|
|
133
|
-
"WAITING_TO_RESUME",
|
|
134
|
-
"RETRYING_AFTER_FAILURE",
|
|
135
|
-
"PAUSED",
|
|
136
|
-
"CANCELED",
|
|
137
|
-
"COMPLETED_SUCCESSFULLY",
|
|
138
|
-
"COMPLETED_WITH_ERRORS",
|
|
139
|
-
"INTERRUPTED",
|
|
140
|
-
"SYSTEM_FAILURE",
|
|
141
|
-
"CRASHED",
|
|
142
|
-
"WAITING_FOR_DEPLOY",
|
|
143
|
-
"DELAYED",
|
|
144
|
-
"EXPIRED"
|
|
145
|
-
],
|
|
68
|
+
subscription_status: ["trialing", "active", "canceled", "incomplete", "incomplete_expired", "past_due", "unpaid"],
|
|
69
|
+
TaskRunStatus: ["PENDING", "EXECUTING", "WAITING_TO_RESUME", "RETRYING_AFTER_FAILURE", "PAUSED", "CANCELED", "COMPLETED_SUCCESSFULLY", "COMPLETED_WITH_ERRORS", "INTERRUPTED", "SYSTEM_FAILURE", "CRASHED", "WAITING_FOR_DEPLOY", "DELAYED", "EXPIRED"],
|
|
146
70
|
TicketCommentParentType: ["Ticket", "TicketComment"],
|
|
147
71
|
TicketStatus: ["Open", "Closed"],
|
|
148
72
|
TicketType: ["Issue", "Feedback"],
|
|
@@ -157,15 +81,8 @@ var Constants = {
|
|
|
157
81
|
};
|
|
158
82
|
|
|
159
83
|
// src/useDbAdvanceQuery.ts
|
|
160
|
-
import {
|
|
161
|
-
|
|
162
|
-
useMemo,
|
|
163
|
-
useRef,
|
|
164
|
-
useState
|
|
165
|
-
} from "react";
|
|
166
|
-
import {
|
|
167
|
-
useQuery
|
|
168
|
-
} from "@tanstack/react-query";
|
|
84
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
85
|
+
import { useQuery } from "@tanstack/react-query";
|
|
169
86
|
import { useSessionStorageState } from "@pol-studios/hooks/storage";
|
|
170
87
|
var normalizeFilter = (filter) => {
|
|
171
88
|
const groupOp = filter.op || filter.operator;
|
|
@@ -175,9 +92,7 @@ var normalizeFilter = (filter) => {
|
|
|
175
92
|
op: groupOp,
|
|
176
93
|
not: filter.not || filter.inverted,
|
|
177
94
|
// Support both 'not' and legacy 'inverted' for groups
|
|
178
|
-
filters: filter.filters.map(normalizeFilter).filter(
|
|
179
|
-
Boolean
|
|
180
|
-
)
|
|
95
|
+
filters: filter.filters.map(normalizeFilter).filter(Boolean)
|
|
181
96
|
};
|
|
182
97
|
}
|
|
183
98
|
let operator = filter.op || filter.condition;
|
|
@@ -192,10 +107,7 @@ var normalizeFilter = (filter) => {
|
|
|
192
107
|
operator = "contains";
|
|
193
108
|
}
|
|
194
109
|
if (!operator) {
|
|
195
|
-
console.error(
|
|
196
|
-
"Filter has undefined operator:",
|
|
197
|
-
JSON.stringify(filter, null, 2)
|
|
198
|
-
);
|
|
110
|
+
console.error("Filter has undefined operator:", JSON.stringify(filter, null, 2));
|
|
199
111
|
return null;
|
|
200
112
|
}
|
|
201
113
|
if (filter.propertyName) {
|
|
@@ -220,12 +132,7 @@ var normalizeFilter = (filter) => {
|
|
|
220
132
|
};
|
|
221
133
|
};
|
|
222
134
|
function useDbAdvanceFilterQuery(query, config) {
|
|
223
|
-
const filterKey = useMemo(
|
|
224
|
-
() => config?.filterKey ?? window.location?.pathname,
|
|
225
|
-
[
|
|
226
|
-
config?.filterKey
|
|
227
|
-
]
|
|
228
|
-
);
|
|
135
|
+
const filterKey = useMemo(() => config?.filterKey ?? window.location?.pathname, [config?.filterKey]);
|
|
229
136
|
const [filterLayer, setFilterLayer] = useSessionStorageState(filterKey, {
|
|
230
137
|
id: "root",
|
|
231
138
|
op: "AND",
|
|
@@ -234,10 +141,7 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
234
141
|
sort: [],
|
|
235
142
|
isReady: isUsable(config?.searchByDefault) ? config.searchByDefault ? false : true : true
|
|
236
143
|
});
|
|
237
|
-
const parser = useMemo(
|
|
238
|
-
() => new PostgrestParser(query),
|
|
239
|
-
[query, config?.key]
|
|
240
|
-
);
|
|
144
|
+
const parser = useMemo(() => new PostgrestParser(query), [query, config?.key]);
|
|
241
145
|
useEffect(() => {
|
|
242
146
|
const searchParam = parser.searchParams.get("order");
|
|
243
147
|
if (searchParam) {
|
|
@@ -266,12 +170,7 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
266
170
|
op: pre.op || "AND",
|
|
267
171
|
filters: pre.filters || [],
|
|
268
172
|
isReady: pre.isReady ?? true,
|
|
269
|
-
sort: [
|
|
270
|
-
...(pre.sort || []).filter(
|
|
271
|
-
(old) => orders.some((o) => o.field === old.field) === false
|
|
272
|
-
),
|
|
273
|
-
...orders
|
|
274
|
-
]
|
|
173
|
+
sort: [...(pre.sort || []).filter((old) => orders.some((o) => o.field === old.field) === false), ...orders]
|
|
275
174
|
};
|
|
276
175
|
});
|
|
277
176
|
}
|
|
@@ -292,18 +191,7 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
292
191
|
filterLayerStringRef.current = currentFilterString;
|
|
293
192
|
}
|
|
294
193
|
const queryKeyRef = useRef([]);
|
|
295
|
-
const newKey = [
|
|
296
|
-
encodedQueryKey[0],
|
|
297
|
-
encodedQueryKey[1],
|
|
298
|
-
encodedQueryKey[2],
|
|
299
|
-
encodedQueryKey[3],
|
|
300
|
-
encodedQueryKey[4],
|
|
301
|
-
encodedQueryKey[5],
|
|
302
|
-
"count=" + (config?.count ?? ""),
|
|
303
|
-
encodedQueryKey[7],
|
|
304
|
-
encodedQueryKey[8],
|
|
305
|
-
filterLayerStringRef.current
|
|
306
|
-
];
|
|
194
|
+
const newKey = [encodedQueryKey[0], encodedQueryKey[1], encodedQueryKey[2], encodedQueryKey[3], encodedQueryKey[4], encodedQueryKey[5], "count=" + (config?.count ?? ""), encodedQueryKey[7], encodedQueryKey[8], filterLayerStringRef.current];
|
|
307
195
|
const newKeyString = JSON.stringify(newKey);
|
|
308
196
|
const oldKeyString = JSON.stringify(queryKeyRef.current);
|
|
309
197
|
if (oldKeyString !== newKeyString) {
|
|
@@ -321,20 +209,17 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
321
209
|
const isEnabled = config?.enabled == null || config?.enabled === void 0 ? true : config.enabled;
|
|
322
210
|
const [extraData, setExtraData] = useState({});
|
|
323
211
|
const queryResponse = useQuery({
|
|
324
|
-
...omit(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
["queryKey", "persister", "initialData"]
|
|
337
|
-
),
|
|
212
|
+
...omit({
|
|
213
|
+
retry: 0,
|
|
214
|
+
// Changed from 1 to 0 to prevent retries
|
|
215
|
+
...config ?? {},
|
|
216
|
+
// Override any config settings to prevent multiple executions
|
|
217
|
+
refetchOnMount: false,
|
|
218
|
+
refetchOnWindowFocus: false,
|
|
219
|
+
refetchOnReconnect: false,
|
|
220
|
+
structuralSharing: false,
|
|
221
|
+
enabled: filterLayer?.isReady && isEnabled
|
|
222
|
+
}, ["queryKey", "persister", "initialData"]),
|
|
338
223
|
queryKey: loadingKey,
|
|
339
224
|
queryFn: async (props) => {
|
|
340
225
|
if (!filterLayer) {
|
|
@@ -345,27 +230,22 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
345
230
|
const body = {
|
|
346
231
|
...filterLayer,
|
|
347
232
|
filters: [...filterLayer.filters],
|
|
348
|
-
pagination: {
|
|
233
|
+
pagination: {
|
|
234
|
+
...filterLayer.pagination
|
|
235
|
+
},
|
|
349
236
|
sort: [...filterLayer.sort || []]
|
|
350
237
|
};
|
|
351
238
|
const currentKey = `${parser.schema}${parser.table}${parser.select}${JSON.stringify(omit(body, "pagination"))}`;
|
|
352
239
|
const requiresEdgeForOrdering = false;
|
|
353
240
|
const hasNaturalLanguageQuery = !!filterLayer.naturalLanguageQuery;
|
|
354
241
|
if (filterLayer.filters.length == 0 && requiresEdgeForOrdering === false && !hasNaturalLanguageQuery) {
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
extraData,
|
|
360
|
-
props.signal,
|
|
361
|
-
config?.count
|
|
362
|
-
);
|
|
363
|
-
setExtraData((pre) => ({
|
|
364
|
-
...omit(result2, "data"),
|
|
365
|
-
count: result2.count ? result2.count : pre.count,
|
|
242
|
+
const result = await executeSupabaseQuery(supabase, body, parser, extraData, props.signal, config?.count);
|
|
243
|
+
setExtraData((pre_0) => ({
|
|
244
|
+
...omit(result, "data"),
|
|
245
|
+
count: result.count ? result.count : pre_0.count,
|
|
366
246
|
key: currentKey
|
|
367
247
|
}));
|
|
368
|
-
return
|
|
248
|
+
return result;
|
|
369
249
|
}
|
|
370
250
|
searchParams.forEach(([k, v]) => {
|
|
371
251
|
if (k.includes("offset")) {
|
|
@@ -383,16 +263,16 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
383
263
|
return;
|
|
384
264
|
}
|
|
385
265
|
if (v.includes(".") === false) return;
|
|
386
|
-
const
|
|
266
|
+
const values_0 = v.split(".");
|
|
387
267
|
const column = k;
|
|
388
|
-
let rawCondition =
|
|
268
|
+
let rawCondition = values_0[0];
|
|
389
269
|
let condition = "";
|
|
390
|
-
let
|
|
391
|
-
const inverted =
|
|
270
|
+
let value_0 = values_0[1];
|
|
271
|
+
const inverted = values_0[0] === "not";
|
|
392
272
|
if (column == "select") return;
|
|
393
273
|
if (rawCondition === "not") {
|
|
394
|
-
rawCondition =
|
|
395
|
-
|
|
274
|
+
rawCondition = values_0[1];
|
|
275
|
+
value_0 = values_0[2];
|
|
396
276
|
}
|
|
397
277
|
switch (rawCondition) {
|
|
398
278
|
case "eq":
|
|
@@ -400,7 +280,7 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
400
280
|
break;
|
|
401
281
|
case "in":
|
|
402
282
|
condition = "in";
|
|
403
|
-
|
|
283
|
+
value_0 = value_0.slice(1, value_0.length - 1).split(",").filter((x_0) => isNullOrWhitespace(x_0) === false);
|
|
404
284
|
break;
|
|
405
285
|
case "lt":
|
|
406
286
|
condition = "<";
|
|
@@ -416,8 +296,8 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
416
296
|
break;
|
|
417
297
|
case "is":
|
|
418
298
|
condition = "is";
|
|
419
|
-
if (
|
|
420
|
-
|
|
299
|
+
if (value_0 == "null") {
|
|
300
|
+
value_0 = null;
|
|
421
301
|
}
|
|
422
302
|
break;
|
|
423
303
|
}
|
|
@@ -425,16 +305,27 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
425
305
|
id: `filter_${column}_${Date.now()}`,
|
|
426
306
|
field: column,
|
|
427
307
|
op: condition,
|
|
428
|
-
value,
|
|
308
|
+
value: value_0,
|
|
429
309
|
not: inverted,
|
|
430
310
|
display: column
|
|
431
|
-
}, {
|
|
311
|
+
}, {
|
|
312
|
+
filters: [...body.filters],
|
|
313
|
+
op: body.op ?? "AND",
|
|
314
|
+
id: "filterstate"
|
|
315
|
+
}];
|
|
432
316
|
body.op = "AND";
|
|
433
317
|
const bodyCopy = JSON.parse(JSON.stringify(body));
|
|
434
|
-
bodyCopy.pagination = {
|
|
318
|
+
bodyCopy.pagination = {
|
|
319
|
+
page: 0,
|
|
320
|
+
pageSize: 50
|
|
321
|
+
};
|
|
435
322
|
bodyCopy.isReady = true;
|
|
436
323
|
});
|
|
437
|
-
const {
|
|
324
|
+
const {
|
|
325
|
+
data: {
|
|
326
|
+
session
|
|
327
|
+
}
|
|
328
|
+
} = await supabase.auth.getSession();
|
|
438
329
|
if (!session?.access_token) {
|
|
439
330
|
throw new Error("No active session");
|
|
440
331
|
}
|
|
@@ -442,29 +333,29 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
442
333
|
props.signal.addEventListener("abort", () => {
|
|
443
334
|
controller.abort();
|
|
444
335
|
});
|
|
445
|
-
const timeout = setTimeout(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
336
|
+
const timeout = setTimeout(() => controller.abort(), config?.timeout ?? 15e3);
|
|
337
|
+
let result_0 = null;
|
|
338
|
+
let response = {
|
|
339
|
+
error: null,
|
|
340
|
+
data: null
|
|
341
|
+
};
|
|
451
342
|
try {
|
|
452
343
|
const UI_ONLY_KEYS = /* @__PURE__ */ new Set(["info", "options", "display"]);
|
|
453
|
-
const filteredBody = JSON.parse(JSON.stringify(body, (
|
|
454
|
-
if (UI_ONLY_KEYS.has(
|
|
344
|
+
const filteredBody = JSON.parse(JSON.stringify(body, (key_0, value_1) => {
|
|
345
|
+
if (UI_ONLY_KEYS.has(key_0)) {
|
|
455
346
|
return void 0;
|
|
456
347
|
}
|
|
457
|
-
return
|
|
348
|
+
return value_1;
|
|
458
349
|
}));
|
|
459
350
|
filteredBody.filters = filteredBody.filters.map(normalizeFilter).filter(Boolean);
|
|
460
351
|
const orParam = parser.searchParams.get("or");
|
|
461
352
|
if (orParam) {
|
|
462
353
|
const cleanedOrParam = orParam.replace(/^\(|\)$/g, "");
|
|
463
354
|
const orConditions = cleanedOrParam.split(",");
|
|
464
|
-
const orFilters = orConditions.map((
|
|
465
|
-
const match =
|
|
355
|
+
const orFilters = orConditions.map((condition_0, idx) => {
|
|
356
|
+
const match = condition_0.match(/^(.+?)\.([^.]+)\.(.+)$/);
|
|
466
357
|
if (match) {
|
|
467
|
-
const [_, field, rawOp,
|
|
358
|
+
const [_, field, rawOp, value_2] = match;
|
|
468
359
|
let op = rawOp.trim();
|
|
469
360
|
switch (op) {
|
|
470
361
|
case "eq":
|
|
@@ -499,58 +390,52 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
499
390
|
id: `or-${idx}`,
|
|
500
391
|
field: field.trim(),
|
|
501
392
|
op,
|
|
502
|
-
value:
|
|
393
|
+
value: value_2.trim()
|
|
503
394
|
};
|
|
504
395
|
}
|
|
505
396
|
return null;
|
|
506
397
|
}).filter(Boolean);
|
|
507
398
|
if (orFilters.length > 0) {
|
|
508
|
-
filteredBody.filters = [
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
isReady: true
|
|
517
|
-
}
|
|
518
|
-
];
|
|
399
|
+
filteredBody.filters = [...filteredBody.filters, {
|
|
400
|
+
id: "base-or-group",
|
|
401
|
+
op: "OR",
|
|
402
|
+
filters: orFilters,
|
|
403
|
+
pagination: void 0,
|
|
404
|
+
sort: void 0,
|
|
405
|
+
isReady: true
|
|
406
|
+
}];
|
|
519
407
|
}
|
|
520
408
|
}
|
|
521
|
-
const res = await fetch(
|
|
522
|
-
|
|
523
|
-
{
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
409
|
+
const res = await fetch(`${getSupabaseUrl()}/functions/v1/query?forceDenoVersion=2`, {
|
|
410
|
+
method: "POST",
|
|
411
|
+
headers: {
|
|
412
|
+
"Content-Type": "application/json",
|
|
413
|
+
"Authorization": `Bearer ${session.access_token}`
|
|
414
|
+
},
|
|
415
|
+
body: JSON.stringify({
|
|
416
|
+
table: parser.table,
|
|
417
|
+
schema: parser.schema,
|
|
418
|
+
select: parser.select,
|
|
419
|
+
filters: {
|
|
420
|
+
id: filteredBody.id || "root",
|
|
421
|
+
op: filteredBody.op || filteredBody.operator || "AND",
|
|
422
|
+
not: filteredBody.not || filteredBody.inverted,
|
|
423
|
+
// Support both 'not' and legacy 'inverted'
|
|
424
|
+
filters: filteredBody.filters || []
|
|
528
425
|
},
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
filters: filteredBody.filters || []
|
|
539
|
-
},
|
|
540
|
-
pagination: filteredBody.pagination,
|
|
541
|
-
sort: filteredBody.sort,
|
|
542
|
-
distinctOn: filteredBody.distinctOn,
|
|
543
|
-
naturalLanguageQuery: filteredBody.naturalLanguageQuery,
|
|
544
|
-
count: currentKey === extraData.key ? "" : config?.count ?? "",
|
|
545
|
-
debug: true
|
|
546
|
-
}),
|
|
547
|
-
signal: controller.signal
|
|
548
|
-
}
|
|
549
|
-
);
|
|
426
|
+
pagination: filteredBody.pagination,
|
|
427
|
+
sort: filteredBody.sort,
|
|
428
|
+
distinctOn: filteredBody.distinctOn,
|
|
429
|
+
naturalLanguageQuery: filteredBody.naturalLanguageQuery,
|
|
430
|
+
count: currentKey === extraData.key ? "" : config?.count ?? "",
|
|
431
|
+
debug: true
|
|
432
|
+
}),
|
|
433
|
+
signal: controller.signal
|
|
434
|
+
});
|
|
550
435
|
if (!res.ok) {
|
|
551
436
|
const errorData = await res.json();
|
|
552
|
-
const
|
|
553
|
-
throw new Error(
|
|
437
|
+
const errorMessage_0 = typeof errorData?.error === "string" ? errorData.error : errorData?.error?.message || errorData?.message || "An error occurred while processing your request";
|
|
438
|
+
throw new Error(errorMessage_0);
|
|
554
439
|
}
|
|
555
440
|
const data = await res.json();
|
|
556
441
|
if (data.clarification) {
|
|
@@ -562,45 +447,57 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
562
447
|
error: void 0
|
|
563
448
|
};
|
|
564
449
|
}
|
|
565
|
-
|
|
566
|
-
|
|
450
|
+
result_0 = data;
|
|
451
|
+
response = {
|
|
452
|
+
error: null,
|
|
453
|
+
data
|
|
454
|
+
};
|
|
567
455
|
} catch (err) {
|
|
568
456
|
if (err.name === "AbortError") {
|
|
569
457
|
console.error("Fetch aborted/time-out");
|
|
570
|
-
|
|
458
|
+
response = {
|
|
459
|
+
error: new Error("This query timed out"),
|
|
460
|
+
data: null
|
|
461
|
+
};
|
|
571
462
|
} else if (err instanceof Error) {
|
|
572
|
-
|
|
463
|
+
response = {
|
|
464
|
+
error: err,
|
|
465
|
+
data: null
|
|
466
|
+
};
|
|
573
467
|
} else {
|
|
574
468
|
const errorMessage = err?.error || err?.message || String(err);
|
|
575
|
-
|
|
469
|
+
response = {
|
|
470
|
+
error: new Error(errorMessage),
|
|
471
|
+
data: null
|
|
472
|
+
};
|
|
576
473
|
}
|
|
577
474
|
} finally {
|
|
578
475
|
clearTimeout(timeout);
|
|
579
476
|
}
|
|
580
|
-
if (
|
|
581
|
-
throw
|
|
582
|
-
} else if (
|
|
583
|
-
throw new Error(
|
|
477
|
+
if (response.error) {
|
|
478
|
+
throw response.error;
|
|
479
|
+
} else if (response.data?.error) {
|
|
480
|
+
throw new Error(response.data.error);
|
|
584
481
|
}
|
|
585
|
-
if (
|
|
482
|
+
if (result_0.clarification) {
|
|
586
483
|
return {
|
|
587
484
|
data: [],
|
|
588
485
|
count: 0,
|
|
589
|
-
clarification:
|
|
486
|
+
clarification: result_0.clarification,
|
|
590
487
|
error: void 0
|
|
591
488
|
};
|
|
592
489
|
}
|
|
593
|
-
setExtraData((
|
|
594
|
-
...omit(
|
|
595
|
-
count:
|
|
490
|
+
setExtraData((pre_1) => ({
|
|
491
|
+
...omit(result_0, "data"),
|
|
492
|
+
count: pre_1.key === currentKey ? pre_1.count : result_0.count,
|
|
596
493
|
key: currentKey
|
|
597
494
|
}));
|
|
598
495
|
return {
|
|
599
|
-
...
|
|
496
|
+
...result_0,
|
|
600
497
|
statusText: "",
|
|
601
|
-
status:
|
|
602
|
-
error:
|
|
603
|
-
hasMore:
|
|
498
|
+
status: result_0.data?.length > result_0.count ? 206 : 200,
|
|
499
|
+
error: response.data?.error ?? null,
|
|
500
|
+
hasMore: result_0.data?.length < result_0.count ? true : false
|
|
604
501
|
};
|
|
605
502
|
} catch (error) {
|
|
606
503
|
if (error instanceof Error && error.name === "AbortError") {
|
|
@@ -615,17 +512,17 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
615
512
|
}
|
|
616
513
|
}
|
|
617
514
|
});
|
|
618
|
-
const
|
|
515
|
+
const response_0 = {
|
|
619
516
|
...queryResponse,
|
|
620
517
|
data: queryResponse.data?.data,
|
|
621
518
|
count: extraData.count,
|
|
622
519
|
clarification: queryResponse.data?.clarification
|
|
623
520
|
};
|
|
624
521
|
useEffect(() => {
|
|
625
|
-
if (queryResponse.isFetched &&
|
|
522
|
+
if (queryResponse.isFetched && response_0.count == null) {
|
|
626
523
|
queryResponse.refetch();
|
|
627
524
|
}
|
|
628
|
-
}, [
|
|
525
|
+
}, [response_0.count]);
|
|
629
526
|
useEffect(() => {
|
|
630
527
|
if (queryResponse.data?.error == null) return;
|
|
631
528
|
if (queryResponse.data?.error?.message?.includes(" does not exist")) {
|
|
@@ -639,7 +536,7 @@ function useDbAdvanceFilterQuery(query, config) {
|
|
|
639
536
|
});
|
|
640
537
|
}
|
|
641
538
|
}, [queryResponse.data?.error]);
|
|
642
|
-
return [
|
|
539
|
+
return [response_0, filterLayer, setFilterLayer];
|
|
643
540
|
}
|
|
644
541
|
function isSearchableColumn(columnName) {
|
|
645
542
|
return true;
|
|
@@ -652,7 +549,9 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
|
|
|
652
549
|
});
|
|
653
550
|
if (body.sort && Array.isArray(body.sort)) {
|
|
654
551
|
body.sort.forEach((s) => {
|
|
655
|
-
query.order(s.field, {
|
|
552
|
+
query.order(s.field, {
|
|
553
|
+
ascending: s.direction === "asc"
|
|
554
|
+
});
|
|
656
555
|
});
|
|
657
556
|
}
|
|
658
557
|
const from = searchParams.find((x) => x[0].includes("offset"))?.[1];
|
|
@@ -667,7 +566,7 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
|
|
|
667
566
|
return;
|
|
668
567
|
}
|
|
669
568
|
if (k === "or") {
|
|
670
|
-
query.or(v.slice(1, v.length -
|
|
569
|
+
query.or(v.slice(1, v.length - 1));
|
|
671
570
|
return;
|
|
672
571
|
}
|
|
673
572
|
const values = v.split(".");
|
|
@@ -675,6 +574,7 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
|
|
|
675
574
|
let rawCondition = values[0];
|
|
676
575
|
let value = values[1];
|
|
677
576
|
if (column == "select") return;
|
|
577
|
+
if (column == "order") return;
|
|
678
578
|
if (v.includes(".") === false) return;
|
|
679
579
|
if (rawCondition === "ilike" && !isSearchableColumn(column)) {
|
|
680
580
|
return;
|
|
@@ -705,6 +605,7 @@ async function executeSupabaseQuery(supabase, body, parser, extraData, signal, c
|
|
|
705
605
|
export {
|
|
706
606
|
Constants,
|
|
707
607
|
normalizeFilter,
|
|
708
|
-
useDbAdvanceFilterQuery
|
|
608
|
+
useDbAdvanceFilterQuery,
|
|
609
|
+
createCombinedStatus
|
|
709
610
|
};
|
|
710
|
-
//# sourceMappingURL=chunk-
|
|
611
|
+
//# sourceMappingURL=chunk-H3LNH2NT.js.map
|