@pol-studios/db 1.0.33 → 1.0.34
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/UserMetadataContext-QLIv-mfF.d.ts +171 -0
- package/dist/auth/context.d.ts +52 -4
- package/dist/auth/context.js +26 -1
- package/dist/auth/hooks.d.ts +107 -3
- package/dist/auth/hooks.js +9 -2
- package/dist/auth/index.d.ts +5 -5
- package/dist/auth/index.js +40 -9
- package/dist/chunk-5HJLTYRA.js +355 -0
- package/dist/chunk-5HJLTYRA.js.map +1 -0
- package/dist/{chunk-E6JL3RUF.js → chunk-67HMVGV7.js} +144 -69
- package/dist/chunk-67HMVGV7.js.map +1 -0
- package/dist/chunk-6KN7KLEG.js +1 -0
- package/dist/{chunk-4EJ6LUH7.js → chunk-AML2TLXJ.js} +6 -4
- package/dist/{chunk-4EJ6LUH7.js.map → chunk-AML2TLXJ.js.map} +1 -1
- package/dist/{chunk-OUCPYEKC.js → chunk-FESQS4S5.js} +4 -4
- package/dist/{chunk-PNC6CG5U.js → chunk-MREERKQU.js} +42 -9
- package/dist/chunk-MREERKQU.js.map +1 -0
- package/dist/{chunk-3XCW225W.js → chunk-NP34C3O3.js} +53 -256
- package/dist/chunk-NP34C3O3.js.map +1 -0
- package/dist/{chunk-E64B4PJZ.js → chunk-TN7QINPK.js} +3 -3
- package/dist/chunk-UBHORKBS.js +215 -0
- package/dist/chunk-UBHORKBS.js.map +1 -0
- package/dist/hooks/index.js +9 -7
- package/dist/index.js +18 -15
- package/dist/index.native.js +18 -15
- package/dist/index.web.js +13 -10
- package/dist/index.web.js.map +1 -1
- package/dist/with-auth/index.js +7 -5
- package/dist/with-auth/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/UserMetadataContext-yLZQu24J.d.ts +0 -33
- package/dist/chunk-3XCW225W.js.map +0 -1
- package/dist/chunk-E6JL3RUF.js.map +0 -1
- package/dist/chunk-NSIAAYW3.js +0 -1
- package/dist/chunk-PNC6CG5U.js.map +0 -1
- /package/dist/{chunk-NSIAAYW3.js.map → chunk-6KN7KLEG.js.map} +0 -0
- /package/dist/{chunk-OUCPYEKC.js.map → chunk-FESQS4S5.js.map} +0 -0
- /package/dist/{chunk-E64B4PJZ.js.map → chunk-TN7QINPK.js.map} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useDbQuery
|
|
3
|
+
} from "./chunk-UBHORKBS.js";
|
|
1
4
|
import {
|
|
2
5
|
buildNormalizedQuery,
|
|
3
6
|
encode,
|
|
@@ -22,7 +25,7 @@ import { useMemo, useRef } from "react";
|
|
|
22
25
|
import { omit } from "@pol-studios/utils";
|
|
23
26
|
import { useQuery } from "@tanstack/react-query";
|
|
24
27
|
import { useDelayedValue } from "@pol-studios/hooks/state";
|
|
25
|
-
function
|
|
28
|
+
function useDbQuery2(query, config) {
|
|
26
29
|
const queryKey = encode(query, false);
|
|
27
30
|
const queryKeyString = queryKey.join("-");
|
|
28
31
|
const debouncedKeyString = useDelayedValue(queryKeyString, 50);
|
|
@@ -488,6 +491,9 @@ function getPermissionLevel(action) {
|
|
|
488
491
|
}
|
|
489
492
|
}
|
|
490
493
|
var profileQuery = typedSupabase?.schema("core").from("Profile").select("*, UserAccess(accessKey), status").single();
|
|
494
|
+
function isNotExpired(expiresAt) {
|
|
495
|
+
return !expiresAt || new Date(expiresAt) > /* @__PURE__ */ new Date();
|
|
496
|
+
}
|
|
491
497
|
function AuthProvider({
|
|
492
498
|
children,
|
|
493
499
|
enableEntityPermissions = false
|
|
@@ -574,40 +580,80 @@ function AuthProvider({
|
|
|
574
580
|
setUserNeedsChange(false);
|
|
575
581
|
});
|
|
576
582
|
}, [userNeedsChange]);
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
583
|
+
const {
|
|
584
|
+
data: profileData,
|
|
585
|
+
isLoading: profileLoading,
|
|
586
|
+
refetch: refetchProfile
|
|
587
|
+
} = useDbQuery("core.Profile", {
|
|
588
|
+
where: {
|
|
589
|
+
id: currentUser?.id
|
|
590
|
+
},
|
|
591
|
+
enabled: isUsable(currentUser)
|
|
580
592
|
});
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
593
|
+
const profile = profileData?.[0] ?? null;
|
|
594
|
+
const {
|
|
595
|
+
data: directAccess,
|
|
596
|
+
isLoading: directAccessLoading,
|
|
597
|
+
refetch: refetchDirectAccess
|
|
598
|
+
} = useDbQuery("core.UserAccess", {
|
|
599
|
+
where: {
|
|
600
|
+
userId: currentUser?.id
|
|
601
|
+
},
|
|
602
|
+
enabled: isUsable(currentUser)
|
|
586
603
|
});
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
604
|
+
const {
|
|
605
|
+
data: userGroups,
|
|
606
|
+
isLoading: userGroupsLoading,
|
|
607
|
+
refetch: refetchUserGroups
|
|
608
|
+
} = useDbQuery("core.UserGroup", {
|
|
609
|
+
where: {
|
|
610
|
+
userId: currentUser?.id
|
|
611
|
+
},
|
|
612
|
+
enabled: isUsable(currentUser)
|
|
613
|
+
});
|
|
614
|
+
const {
|
|
615
|
+
data: groups,
|
|
616
|
+
isLoading: groupsLoading,
|
|
617
|
+
refetch: refetchGroups
|
|
618
|
+
} = useDbQuery("core.Group", {
|
|
619
|
+
where: {
|
|
620
|
+
isActive: 1
|
|
621
|
+
},
|
|
622
|
+
// PowerSync stores booleans as 0/1
|
|
623
|
+
enabled: isUsable(currentUser)
|
|
624
|
+
});
|
|
625
|
+
const groupIds = useMemo3(() => userGroups?.map((ug) => ug.groupId) ?? [], [userGroups]);
|
|
626
|
+
const groupsMap = useMemo3(() => new Map(groups?.map((g) => [g.id, g]) ?? []), [groups]);
|
|
627
|
+
const {
|
|
628
|
+
data: groupAccess,
|
|
629
|
+
isLoading: groupAccessLoading,
|
|
630
|
+
refetch: refetchGroupAccess
|
|
631
|
+
} = useDbQuery("core.GroupAccessKey", {
|
|
632
|
+
where: groupIds.length > 0 ? {
|
|
633
|
+
groupId: {
|
|
634
|
+
in: groupIds
|
|
635
|
+
}
|
|
636
|
+
} : void 0,
|
|
637
|
+
enabled: groupIds.length > 0
|
|
592
638
|
});
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}, [
|
|
639
|
+
const refetchAccessData = useCallback2(() => {
|
|
640
|
+
refetchDirectAccess();
|
|
641
|
+
refetchUserGroups();
|
|
642
|
+
refetchGroups();
|
|
643
|
+
refetchGroupAccess();
|
|
644
|
+
}, [refetchDirectAccess, refetchUserGroups, refetchGroups, refetchGroupAccess]);
|
|
599
645
|
const userGroupIdsRef = useRef3(/* @__PURE__ */ new Set());
|
|
600
646
|
useEffect2(() => {
|
|
601
|
-
if (
|
|
602
|
-
const
|
|
603
|
-
for (const
|
|
604
|
-
if (
|
|
605
|
-
|
|
647
|
+
if (userGroups) {
|
|
648
|
+
const groupIdSet = /* @__PURE__ */ new Set();
|
|
649
|
+
for (const ug_0 of userGroups) {
|
|
650
|
+
if (ug_0.groupId) {
|
|
651
|
+
groupIdSet.add(typeof ug_0.groupId === "number" ? ug_0.groupId : parseInt(ug_0.groupId, 10));
|
|
606
652
|
}
|
|
607
653
|
}
|
|
608
|
-
userGroupIdsRef.current =
|
|
654
|
+
userGroupIdsRef.current = groupIdSet;
|
|
609
655
|
}
|
|
610
|
-
}, [
|
|
656
|
+
}, [userGroups]);
|
|
611
657
|
useEffect2(() => {
|
|
612
658
|
if (!currentUser?.id) return;
|
|
613
659
|
const channel = supabase.channel(`user-access-keys-${currentUser.id}`).on("postgres_changes", {
|
|
@@ -616,16 +662,14 @@ function AuthProvider({
|
|
|
616
662
|
table: "UserAccess",
|
|
617
663
|
filter: `userId=eq.${currentUser.id}`
|
|
618
664
|
}, () => {
|
|
619
|
-
|
|
620
|
-
refetchEffectivePermissions();
|
|
665
|
+
refetchAccessData();
|
|
621
666
|
}).on("postgres_changes", {
|
|
622
667
|
event: "*",
|
|
623
668
|
schema: "core",
|
|
624
669
|
table: "UserGroup",
|
|
625
670
|
filter: `userId=eq.${currentUser.id}`
|
|
626
671
|
}, () => {
|
|
627
|
-
|
|
628
|
-
refetchEffectivePermissions();
|
|
672
|
+
refetchAccessData();
|
|
629
673
|
}).on("postgres_changes", {
|
|
630
674
|
event: "*",
|
|
631
675
|
schema: "core",
|
|
@@ -633,8 +677,7 @@ function AuthProvider({
|
|
|
633
677
|
}, (payload) => {
|
|
634
678
|
const groupId = payload.new?.groupId || payload.old?.groupId;
|
|
635
679
|
if (groupId && userGroupIdsRef.current.has(groupId)) {
|
|
636
|
-
|
|
637
|
-
refetchEffectivePermissions();
|
|
680
|
+
refetchAccessData();
|
|
638
681
|
}
|
|
639
682
|
}).on("postgres_changes", {
|
|
640
683
|
event: "UPDATE",
|
|
@@ -645,15 +688,14 @@ function AuthProvider({
|
|
|
645
688
|
const newActive = payload_0.new?.isActive;
|
|
646
689
|
const groupId_0 = payload_0.new?.id;
|
|
647
690
|
if (oldActive !== newActive && groupId_0 && userGroupIdsRef.current.has(groupId_0)) {
|
|
648
|
-
|
|
649
|
-
refetchEffectivePermissions();
|
|
691
|
+
refetchAccessData();
|
|
650
692
|
}
|
|
651
693
|
}).subscribe();
|
|
652
694
|
return () => {
|
|
653
695
|
channel.unsubscribe();
|
|
654
696
|
supabase.removeChannel(channel);
|
|
655
697
|
};
|
|
656
|
-
}, [supabase, currentUser?.id,
|
|
698
|
+
}, [supabase, currentUser?.id, refetchAccessData]);
|
|
657
699
|
useEffect2(() => {
|
|
658
700
|
if (!currentUser?.id) return;
|
|
659
701
|
const profileChannel = supabase.channel(`profile-status-${currentUser.id}`).on("postgres_changes", {
|
|
@@ -667,40 +709,72 @@ function AuthProvider({
|
|
|
667
709
|
if (oldStatus === "active" && (newStatus === "archived" || newStatus === "suspended")) {
|
|
668
710
|
signOutAsync();
|
|
669
711
|
}
|
|
670
|
-
|
|
712
|
+
refetchProfile();
|
|
671
713
|
}).subscribe();
|
|
672
714
|
return () => {
|
|
673
715
|
profileChannel.unsubscribe();
|
|
674
716
|
supabase.removeChannel(profileChannel);
|
|
675
717
|
};
|
|
676
|
-
}, [supabase, currentUser?.id,
|
|
718
|
+
}, [supabase, currentUser?.id, refetchProfile]);
|
|
719
|
+
const allAccessKeys = useMemo3(() => {
|
|
720
|
+
const keys = [];
|
|
721
|
+
directAccess?.forEach((a) => {
|
|
722
|
+
if (isNotExpired(a.expiresAt)) {
|
|
723
|
+
keys.push({
|
|
724
|
+
accessKey: a.accessKey,
|
|
725
|
+
effect: a.effect ?? "allow",
|
|
726
|
+
source: "direct",
|
|
727
|
+
expiresAt: a.expiresAt
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
const activeGroupIds = new Set(userGroups?.filter((ug_1) => {
|
|
732
|
+
const group = groupsMap.get(ug_1.groupId);
|
|
733
|
+
return group?.isActive === 1 && isNotExpired(ug_1.expiresAt);
|
|
734
|
+
}).map((ug_2) => ug_2.groupId) ?? []);
|
|
735
|
+
groupAccess?.forEach((ga) => {
|
|
736
|
+
if (activeGroupIds.has(ga.groupId) && isNotExpired(ga.expiresAt)) {
|
|
737
|
+
keys.push({
|
|
738
|
+
accessKey: ga.accessKey,
|
|
739
|
+
effect: ga.effect ?? "allow",
|
|
740
|
+
source: "group",
|
|
741
|
+
expiresAt: ga.expiresAt
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
return keys;
|
|
746
|
+
}, [directAccess, userGroups, groupsMap, groupAccess]);
|
|
677
747
|
const combinedAccess = useMemo3(() => {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
uniqueKeys.add(item_0.access_key);
|
|
683
|
-
}
|
|
748
|
+
const uniqueKeys = /* @__PURE__ */ new Set();
|
|
749
|
+
for (const item of allAccessKeys) {
|
|
750
|
+
if (item.accessKey && item.effect === "allow") {
|
|
751
|
+
uniqueKeys.add(item.accessKey);
|
|
684
752
|
}
|
|
685
|
-
return Array.from(uniqueKeys);
|
|
686
753
|
}
|
|
687
|
-
return
|
|
688
|
-
}, [
|
|
754
|
+
return Array.from(uniqueKeys);
|
|
755
|
+
}, [allAccessKeys]);
|
|
689
756
|
const effectivePermissions = useMemo3(() => {
|
|
690
|
-
|
|
691
|
-
|
|
757
|
+
const permissions = [];
|
|
758
|
+
for (const item_0 of allAccessKeys) {
|
|
759
|
+
if (item_0.effect !== "allow") continue;
|
|
760
|
+
const parts = item_0.accessKey.split(":");
|
|
761
|
+
if (parts.length === 3) {
|
|
762
|
+
const [resourceType, resourceId, permission] = parts;
|
|
763
|
+
const permissionLevel = getPermissionLevel(permission);
|
|
764
|
+
permissions.push({
|
|
765
|
+
resourceType,
|
|
766
|
+
resourceId,
|
|
767
|
+
permission,
|
|
768
|
+
permissionLevel,
|
|
769
|
+
source: item_0.source,
|
|
770
|
+
inheritedFrom: null,
|
|
771
|
+
expiresAt: item_0.expiresAt ?? null
|
|
772
|
+
});
|
|
773
|
+
}
|
|
692
774
|
}
|
|
693
|
-
return
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
permission: item_1.permission,
|
|
697
|
-
permissionLevel: item_1.permission_level,
|
|
698
|
-
source: item_1.source,
|
|
699
|
-
inheritedFrom: item_1.inherited_from,
|
|
700
|
-
expiresAt: item_1.expires_at
|
|
701
|
-
}));
|
|
702
|
-
}, [effectivePermissionsRequest.data]);
|
|
703
|
-
const profileStatus = profileRequest.data?.status;
|
|
775
|
+
return permissions;
|
|
776
|
+
}, [allAccessKeys]);
|
|
777
|
+
const profileStatus = profile?.status;
|
|
704
778
|
const isArchived = profileStatus === "archived";
|
|
705
779
|
const isSuspended = profileStatus === "suspended";
|
|
706
780
|
const hasAccess = useCallback2((key) => {
|
|
@@ -712,9 +786,9 @@ function AuthProvider({
|
|
|
712
786
|
if (accessGiven.includes("*:*:*")) return true;
|
|
713
787
|
if (accessGiven.includes(key)) return true;
|
|
714
788
|
if (isUsable(key) === false) return true;
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const [type, id_1, action_0] =
|
|
789
|
+
const parts_0 = key.split(":");
|
|
790
|
+
if (parts_0.length === 3) {
|
|
791
|
+
const [type, id_1, action_0] = parts_0;
|
|
718
792
|
const requiredLevel = getPermissionLevel(action_0);
|
|
719
793
|
const hasPermission = effectivePermissions.some((p) => p.resourceType === type && p.resourceId === id_1 && p.permissionLevel >= requiredLevel);
|
|
720
794
|
if (hasPermission) {
|
|
@@ -723,23 +797,24 @@ function AuthProvider({
|
|
|
723
797
|
}
|
|
724
798
|
return false;
|
|
725
799
|
}, [combinedAccess, effectivePermissions, isArchived, isSuspended]);
|
|
800
|
+
const isAccessLoading = directAccessLoading || userGroupsLoading || groupsLoading || groupAccessLoading;
|
|
726
801
|
const authStateWithLoading = useMemo3(() => ({
|
|
727
802
|
hasAccess,
|
|
728
803
|
user: currentUser,
|
|
729
|
-
profile
|
|
804
|
+
profile,
|
|
730
805
|
access: combinedAccess,
|
|
731
806
|
effectivePermissions,
|
|
732
807
|
profileStatus,
|
|
733
808
|
isArchived,
|
|
734
809
|
isSuspended,
|
|
735
|
-
isLoading: currentUser === null ? false :
|
|
810
|
+
isLoading: currentUser === null ? false : profileLoading || isAccessLoading || currentUser === void 0,
|
|
736
811
|
signInAsync,
|
|
737
812
|
signOutAsync,
|
|
738
813
|
onSignOut,
|
|
739
814
|
removeOnSignOut,
|
|
740
815
|
registerAsync,
|
|
741
816
|
refreshAsync
|
|
742
|
-
}), [
|
|
817
|
+
}), [profile, profileLoading, isAccessLoading, currentUser, combinedAccess, effectivePermissions, profileStatus, isArchived, isSuspended, hasAccess]);
|
|
743
818
|
const content = enableEntityPermissions ? /* @__PURE__ */ jsx2(PermissionProvider, { children }) : children;
|
|
744
819
|
return /* @__PURE__ */ jsx2(setupAuthContext.Provider, { value: authStateWithLoading, children: content });
|
|
745
820
|
}
|
|
@@ -881,7 +956,7 @@ function UserMetadataProvider({
|
|
|
881
956
|
const [error, setError] = useState3(null);
|
|
882
957
|
const setupAuth = useContext2(setupAuthContext);
|
|
883
958
|
const userId = setupAuth?.user?.id;
|
|
884
|
-
const metadataQuery =
|
|
959
|
+
const metadataQuery = useDbQuery2(supabase.schema("core").from("UserMetadata").select(UserMetadataQuery.defaultQuery).eq("userId", userId).order("key"), {
|
|
885
960
|
enabled: isUsable3(userId),
|
|
886
961
|
crossOrganization: true
|
|
887
962
|
});
|
|
@@ -1083,7 +1158,7 @@ export {
|
|
|
1083
1158
|
TIMEOUT_ERROR_MESSAGE,
|
|
1084
1159
|
DEFAULT_QUERY_TIMEOUT,
|
|
1085
1160
|
isTimeoutError,
|
|
1086
|
-
useDbQuery,
|
|
1161
|
+
useDbQuery2 as useDbQuery,
|
|
1087
1162
|
setupAuthContext,
|
|
1088
1163
|
permissionContext,
|
|
1089
1164
|
entityPermissionContext,
|
|
@@ -1097,4 +1172,4 @@ export {
|
|
|
1097
1172
|
useSetUserMetadata,
|
|
1098
1173
|
useUserMetadataState
|
|
1099
1174
|
};
|
|
1100
|
-
//# sourceMappingURL=chunk-
|
|
1175
|
+
//# sourceMappingURL=chunk-67HMVGV7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors/TimeoutError.ts","../src/useDbQuery.ts","../src/auth/context/setupAuthContext.tsx","../src/auth/context/PermissionContext.tsx","../src/auth/context/AuthProvider.tsx","../src/auth/context/UserMetadataContext.tsx","../src/useDbUpsert.ts"],"sourcesContent":["export const TIMEOUT_ERROR_MESSAGE = \"Request timed out\";\nexport const DEFAULT_QUERY_TIMEOUT = 15_000; // 15 seconds\n\nexport function isTimeoutError(error: Error | null | undefined): boolean {\n if (!error) return false;\n return error.name === \"AbortError\" || error.message === TIMEOUT_ERROR_MESSAGE || error.message.toLowerCase().includes(\"timed out\");\n}","import { PostgrestError, PostgrestSingleResponse } from \"@supabase/supabase-js\";\nimport { useMemo, useRef } from \"react\";\nimport { ItemType } from \"@pol-studios/utils\";\nimport { encode, UseQuerySingleReturn } from \"@supabase-cache-helpers/postgrest-react-query\";\nimport { omit } from \"@pol-studios/utils\";\nimport { useQuery, UseQueryOptions } from \"@tanstack/react-query\";\nimport { useDelayedValue } from \"@pol-studios/hooks/state\";\nimport { DEFAULT_QUERY_TIMEOUT, TIMEOUT_ERROR_MESSAGE } from \"./errors/TimeoutError\";\ntype ConfigurationOptions<T> = {\n crossOrganization?: boolean;\n filter?: (item: ItemType<T>) => boolean;\n timeout?: number;\n};\nexport type UseDbQuerySingleReturn<T> = UseQuerySingleReturn<T> & {\n data: T | null | undefined;\n count?: number | null;\n};\nexport function useDbQuery<Result>(query: PromiseLike<PostgrestSingleResponse<Result>> & {\n abortSignal?: (signal: AbortSignal) => PromiseLike<PostgrestSingleResponse<Result>>;\n}, config?: Omit<UseQueryOptions<Result, PostgrestError>, \"queryKey\" | \"queryFn\"> & ConfigurationOptions<Result>) {\n // Debounce query key to prevent rapid query churn during fast navigation\n const queryKey = encode(query, false);\n const queryKeyString = queryKey.join(\"-\");\n const debouncedKeyString = useDelayedValue(queryKeyString, 50);\n\n // Only enable query when key has stabilized (debounced matches current)\n const isKeyStable = queryKeyString === debouncedKeyString;\n const effectiveEnabled = config?.enabled !== false && isKeyStable;\n const timeoutMs = config?.timeout ?? DEFAULT_QUERY_TIMEOUT;\n\n // Track count from Supabase response (for queries with count: \"exact\")\n const countRef = useRef<number | null>(null);\n const request = useQuery(useMemo(() => ({\n queryKey,\n queryFn: async ({\n signal\n }) => {\n const controller = new AbortController();\n signal.addEventListener(\"abort\", () => controller.abort());\n const timeoutId = setTimeout(() => controller.abort(), timeoutMs);\n try {\n // Execute query with abort signal\n const queryWithSignal = query.abortSignal?.(controller.signal) ?? query;\n const result = await queryWithSignal;\n if (result.error) throw result.error;\n // Store count if available (from queries with count: \"exact\")\n countRef.current = result.count ?? null;\n return result.data;\n } catch (err: any) {\n if (err.name === \"AbortError\") {\n throw new Error(TIMEOUT_ERROR_MESSAGE);\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n }\n },\n ...omit({\n retry: 1,\n ...config,\n enabled: effectiveEnabled\n }, [\"queryKey\", \"timeout\"])\n }), [queryKey, config, effectiveEnabled, timeoutMs, query]));\n\n // Return request with count property added\n return useMemo(() => ({\n ...request,\n count: countRef.current\n }), [request, countRef.current]) as UseDbQuerySingleReturn<Result>;\n}","/**\n * SetupAuthContext - Shared context for auth state\n *\n * This file is separate to avoid circular dependencies between\n * AuthProvider and PermissionContext.\n */\n\nimport { createContext, ReactNode } from \"react\";\nimport { AuthTokenResponsePassword, SignUpWithPasswordCredentials, User } from \"@supabase/supabase-js\";\nexport type ProfileStatus = \"active\" | \"archived\" | \"suspended\";\n\n/**\n * Represents an effective permission for a user on a specific resource.\n * These are eagerly loaded at login for fast permission checks.\n */\nexport interface EffectivePermission {\n /** The type of resource (e.g., 'project', 'client', 'database') */\n resourceType: string;\n /** The ID of the specific resource */\n resourceId: string;\n /** The permission action (e.g., 'view', 'edit', 'admin') */\n permission: string;\n /** Numeric level for comparison: view=1, edit=2, admin=3 */\n permissionLevel: number;\n /** How the permission was granted */\n source: \"direct\" | \"group\" | \"inherited\";\n /** If inherited, from which resource */\n inheritedFrom: string | null;\n /** When the permission expires, if applicable */\n expiresAt: string | null;\n}\nexport interface SetupAuthContext {\n user?: User | null | undefined;\n isLoading: boolean;\n profile: Profile | null | undefined;\n access: string[];\n /** Eagerly loaded effective permissions for the user */\n effectivePermissions: EffectivePermission[];\n /** Whether the profile is archived */\n isArchived: boolean;\n /** Whether the profile is suspended */\n isSuspended: boolean;\n /** The profile status (active, archived, suspended) */\n profileStatus: ProfileStatus | undefined;\n registerAsync: (register: SignUpWithPasswordCredentials) => Promise<any>;\n signInAsync: (username: string, password: string) => Promise<AuthTokenResponsePassword>;\n signOutAsync: () => Promise<any>;\n refreshAsync: () => Promise<void>;\n onSignOut: (action: () => any) => string;\n removeOnSignOut: (id: string) => any;\n hasAccess?: (key: string) => boolean;\n}\n\n// Profile type - simplified version, the full type is in AuthProvider\nexport interface Profile {\n id: string;\n email?: string;\n fullName?: string;\n status?: ProfileStatus;\n UserAccess?: Array<{\n accessKey: string;\n }>;\n [key: string]: any;\n}\nexport const setupAuthContext = createContext({} as SetupAuthContext);\n\n/**\n * Props for SetupAuthContextProvider\n * A simpler provider that takes pre-computed auth state\n */\nexport interface SetupAuthContextProviderProps {\n children: ReactNode;\n auth: SetupAuthContext;\n}","import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport useSupabase from \"../../useSupabase\";\nimport { setupAuthContext } from \"./setupAuthContext\";\nimport { EntityType, EntityPermissionLevel, EntityAction, EntityPermissionCheck } from \"../types/EntityPermissions\";\n\n// Cache entry with TTL\ninterface CacheEntry {\n permission: EntityPermissionCheck;\n expiresAt: number;\n}\n\n// Entity identifier for batch lookups\ninterface EntityIdentifier {\n entityType: EntityType;\n entityId: number;\n}\n\n// Cache key helper\nfunction getCacheKey(userId: string | undefined, entityType: EntityType, entityId: number): string {\n return `${userId || \"anon\"}:${entityType}:${entityId}`;\n}\n\n// Default loading state\nconst loadingPermission: EntityPermissionCheck = {\n canView: false,\n canAdminView: false,\n canEdit: false,\n canCreate: false,\n canDelete: false,\n canShare: false,\n permissionLevel: null,\n isLoading: true\n};\n\n// No permission state\nconst noPermission: EntityPermissionCheck = {\n canView: false,\n canAdminView: false,\n canEdit: false,\n canCreate: false,\n canDelete: false,\n canShare: false,\n permissionLevel: null,\n isLoading: false,\n isDenied: false\n};\n\n// Denied permission state - explicitly blocked access\nconst deniedPermission: EntityPermissionCheck = {\n canView: false,\n canAdminView: false,\n canEdit: false,\n canCreate: false,\n canDelete: false,\n canShare: false,\n permissionLevel: null,\n isLoading: false,\n isDenied: true\n};\n\n// Map permission level to permission check\n// If permission is 'denied', it means access was explicitly blocked\n// Handles both legacy formats (ReadOnly, AdminReadOnly, ReadWrite, Admin)\n// and new formats (view, edit, admin, denied)\nfunction mapPermissionLevel(level: EntityPermissionLevel | \"denied\" | string | null): EntityPermissionCheck {\n if (!level) {\n return noPermission;\n }\n\n // Normalize to lowercase for comparison to handle both legacy and new formats\n const normalizedLevel = level.toLowerCase();\n switch (normalizedLevel) {\n // Legacy format: ReadOnly, New format: view\n case \"readonly\":\n case \"view\":\n return {\n canView: true,\n canAdminView: false,\n canEdit: false,\n canCreate: false,\n canDelete: false,\n canShare: false,\n permissionLevel: \"ReadOnly\",\n isLoading: false,\n isDenied: false\n };\n // Legacy format: AdminReadOnly (no new equivalent, keep for backwards compatibility)\n case \"adminreadonly\":\n return {\n canView: true,\n canAdminView: true,\n canEdit: false,\n canCreate: false,\n canDelete: false,\n canShare: false,\n permissionLevel: \"AdminReadOnly\",\n isLoading: false,\n isDenied: false\n };\n // Legacy format: ReadWrite, New format: edit\n case \"readwrite\":\n case \"edit\":\n return {\n canView: true,\n canAdminView: false,\n canEdit: true,\n canCreate: true,\n canDelete: false,\n canShare: false,\n permissionLevel: \"ReadWrite\",\n isLoading: false,\n isDenied: false\n };\n // Legacy format: Admin, New format: admin\n case \"admin\":\n return {\n canView: true,\n canAdminView: true,\n canEdit: true,\n canCreate: true,\n canDelete: true,\n canShare: true,\n permissionLevel: \"Admin\",\n isLoading: false,\n isDenied: false\n };\n // New format: denied - explicit access denial\n case \"denied\":\n return deniedPermission;\n default:\n console.warn(`Unknown permission level: ${level}`);\n return noPermission;\n }\n}\n\n// Context interface\nexport interface PermissionContextValue {\n getPermission: (entityType: EntityType, entityId: number) => EntityPermissionCheck;\n checkPermission: (entityType: EntityType, entityId: number, action: EntityAction) => boolean;\n prefetchPermissions: (entities: EntityIdentifier[]) => Promise<void>;\n invalidatePermission: (entityType: EntityType, entityId: number) => void;\n isLoading: boolean;\n}\n\n/**\n * @deprecated Use permissionContext instead\n */\nexport interface EntityPermissionContextValue extends PermissionContextValue {}\nexport const permissionContext = createContext<PermissionContextValue>({} as PermissionContextValue);\n\n/**\n * @deprecated Use permissionContext instead\n */\nexport const entityPermissionContext = permissionContext;\n\n// TTL for cache entries (5 minutes)\nconst CACHE_TTL_MS = 5 * 60 * 1000;\n\n// TTL for error cache entries (30 seconds) - shorter to allow quick retry\nconst ERROR_CACHE_TTL_MS = 30 * 1000;\n\n// Batch collection delay (50ms)\nconst BATCH_DELAY_MS = 50;\nexport function PermissionProvider({\n children\n}: {\n children: ReactNode;\n}) {\n const supabase = useSupabase();\n const setupAuth = useContext(setupAuthContext);\n const user = setupAuth?.user;\n\n // Permission cache\n const cacheRef = useRef<Map<string, CacheEntry>>(new Map());\n\n // Pending lookups for batching\n const pendingLookupsRef = useRef<Set<string>>(new Set());\n\n // In-flight lookups to prevent duplicate requests during async RPC calls\n const inFlightRef = useRef<Set<string>>(new Set());\n\n // Batch timer ref\n const batchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Loading state\n const [isLoading, setIsLoading] = useState(false);\n\n // Force re-render trigger\n const [, forceUpdate] = useState(0);\n\n // Clean up expired cache entries\n const cleanupExpiredEntries = useCallback(() => {\n const now = Date.now();\n const cache = cacheRef.current;\n let hasExpired = false;\n for (const [key, entry] of cache.entries()) {\n if (entry.expiresAt < now) {\n cache.delete(key);\n hasExpired = true;\n }\n }\n if (hasExpired) {\n forceUpdate(prev => prev + 1);\n }\n }, []);\n\n // Periodic cleanup of expired entries\n useEffect(() => {\n const cleanupInterval = setInterval(cleanupExpiredEntries, 60 * 1000);\n return () => clearInterval(cleanupInterval);\n }, [cleanupExpiredEntries]);\n\n // Execute batch lookup\n const executeBatchLookup = useCallback(async () => {\n const pending = Array.from(pendingLookupsRef.current);\n pendingLookupsRef.current.clear();\n if (pending.length === 0 || !user?.id) {\n return;\n }\n\n // Move pending keys to in-flight to prevent duplicate requests\n pending.forEach(k => inFlightRef.current.add(k));\n setIsLoading(true);\n try {\n // Parse pending keys back to entities (format: userId:entityType:entityId)\n const entities = pending.map(key_0 => {\n const parts = key_0.split(\":\");\n // Skip the userId part (index 0), use entityType (index 1) and entityId (index 2)\n const entityType = parts[1];\n const entityIdStr = parts[2];\n return {\n entity_type: entityType as EntityType,\n entity_id: parseInt(entityIdStr, 10)\n };\n });\n\n // Call RPC for batch lookup\n // Using 'as any' because the RPC function type isn't in the generated database types\n const {\n data,\n error\n } = await (supabase.rpc as any)(\"get_user_entity_permissions\", {\n p_user_id: user.id,\n p_entities: entities\n });\n if (error) {\n console.error(\"Failed to fetch entity permissions:\", error);\n // Mark all pending as no permission with shorter TTL to allow quick retry\n const cache_0 = cacheRef.current;\n const now_0 = Date.now();\n for (const key_1 of pending) {\n cache_0.set(key_1, {\n permission: noPermission,\n expiresAt: now_0 + ERROR_CACHE_TTL_MS\n });\n }\n } else if (data) {\n // Update cache with results\n const cache_1 = cacheRef.current;\n const now_1 = Date.now();\n\n // Create a map of results for quick lookup\n // Permission can be a standard level or 'denied' for explicit deny\n const resultsMap = new Map<string, EntityPermissionLevel | \"denied\">();\n // Type the data as an array of permission results\n const results = data as Array<{\n entity_type: EntityType;\n entity_id: number;\n permission: EntityPermissionLevel | \"denied\";\n }>;\n for (const result of results) {\n const key_2 = getCacheKey(user?.id, result.entity_type, result.entity_id);\n resultsMap.set(key_2, result.permission);\n }\n\n // Update cache for all pending keys\n for (const key_3 of pending) {\n const permissionLevel = resultsMap.get(key_3) || null;\n cache_1.set(key_3, {\n permission: mapPermissionLevel(permissionLevel),\n expiresAt: now_1 + CACHE_TTL_MS\n });\n }\n }\n forceUpdate(prev_0 => prev_0 + 1);\n } catch (err) {\n console.error(\"Unexpected error fetching entity permissions:\", err);\n } finally {\n // Remove from in-flight after completion (success or error)\n pending.forEach(k => inFlightRef.current.delete(k));\n setIsLoading(false);\n }\n }, [supabase, user?.id]);\n\n // Schedule batch lookup\n const scheduleBatchLookup = useCallback(() => {\n if (batchTimerRef.current) {\n clearTimeout(batchTimerRef.current);\n }\n batchTimerRef.current = setTimeout(() => {\n batchTimerRef.current = null;\n executeBatchLookup();\n }, BATCH_DELAY_MS);\n }, [executeBatchLookup]);\n\n // Get permission for an entity\n const getPermission = useCallback((entityType_0: EntityType, entityId: number): EntityPermissionCheck => {\n const key_4 = getCacheKey(user?.id, entityType_0, entityId);\n const cache_2 = cacheRef.current;\n const cached = cache_2.get(key_4);\n const now_2 = Date.now();\n\n // Return cached if valid\n if (cached && cached.expiresAt > now_2) {\n return cached.permission;\n }\n\n // Don't add if already pending or in-flight to prevent duplicate requests\n if (!pendingLookupsRef.current.has(key_4) && !inFlightRef.current.has(key_4)) {\n pendingLookupsRef.current.add(key_4);\n scheduleBatchLookup();\n }\n return loadingPermission;\n }, [scheduleBatchLookup, user?.id]);\n\n // Check specific permission action\n const checkPermission = useCallback((entityType_1: EntityType, entityId_0: number, action: EntityAction): boolean => {\n const permission = getPermission(entityType_1, entityId_0);\n if (permission.isLoading) {\n return false;\n }\n switch (action) {\n case \"view\":\n return permission.canView;\n case \"adminView\":\n return permission.canAdminView;\n case \"edit\":\n return permission.canEdit;\n case \"create\":\n return permission.canCreate;\n case \"delete\":\n return permission.canDelete;\n case \"share\":\n return permission.canShare;\n default:\n return false;\n }\n }, [getPermission]);\n\n // Prefetch permissions for multiple entities\n const prefetchPermissions = useCallback(async (entities_0: EntityIdentifier[]): Promise<void> => {\n if (!user?.id || entities_0.length === 0) {\n return;\n }\n const cache_3 = cacheRef.current;\n const now_3 = Date.now();\n\n // Filter out already cached entries, items already pending, and items in-flight\n const toFetch = entities_0.filter(entity => {\n const key_5 = getCacheKey(user?.id, entity.entityType, entity.entityId);\n const cached_0 = cache_3.get(key_5);\n const isPending = pendingLookupsRef.current.has(key_5);\n const isInFlight = inFlightRef.current.has(key_5);\n return !isPending && !isInFlight && (!cached_0 || cached_0.expiresAt <= now_3);\n });\n if (toFetch.length === 0) {\n return;\n }\n setIsLoading(true);\n try {\n const entitiesParam = toFetch.map(e => ({\n entity_type: e.entityType,\n entity_id: e.entityId\n }));\n\n // Using 'as any' because the RPC function type isn't in the generated database types\n const {\n data: data_0,\n error: error_0\n } = await (supabase.rpc as any)(\"get_user_entity_permissions\", {\n p_user_id: user.id,\n p_entities: entitiesParam\n });\n if (error_0) {\n console.error(\"Failed to prefetch entity permissions:\", error_0);\n return;\n }\n if (data_0) {\n // Capture timestamp AFTER the RPC call completes\n const cacheTimestamp = Date.now();\n\n // Permission can be a standard level or 'denied' for explicit deny\n const resultsMap_0 = new Map<string, EntityPermissionLevel | \"denied\">();\n // Type the data as an array of permission results\n const results_0 = data_0 as Array<{\n entity_type: EntityType;\n entity_id: number;\n permission: EntityPermissionLevel | \"denied\";\n }>;\n for (const result_0 of results_0) {\n const key_6 = getCacheKey(user?.id, result_0.entity_type, result_0.entity_id);\n resultsMap_0.set(key_6, result_0.permission);\n }\n for (const entity_0 of toFetch) {\n const key_7 = getCacheKey(user?.id, entity_0.entityType, entity_0.entityId);\n const permissionLevel_0 = resultsMap_0.get(key_7) || null;\n cache_3.set(key_7, {\n permission: mapPermissionLevel(permissionLevel_0),\n expiresAt: cacheTimestamp + CACHE_TTL_MS\n });\n }\n forceUpdate(prev_1 => prev_1 + 1);\n }\n } catch (err_0) {\n console.error(\"Unexpected error prefetching entity permissions:\", err_0);\n } finally {\n setIsLoading(false);\n }\n }, [supabase, user?.id]);\n\n // Invalidate a specific permission\n const invalidatePermission = useCallback((entityType_2: EntityType, entityId_1: number): void => {\n const key_8 = getCacheKey(user?.id, entityType_2, entityId_1);\n cacheRef.current.delete(key_8);\n forceUpdate(prev_2 => prev_2 + 1);\n }, [user?.id]);\n\n // Parse scoped access key format: <entity_type>:<entity_id>:<permission_level>\n // Returns null if the key format is invalid\n const parseScopedAccessKey = useCallback((key_9: string): {\n entityType: EntityType;\n entityId: number;\n } | null => {\n if (!key_9 || typeof key_9 !== \"string\") {\n return null;\n }\n const parts_0 = key_9.split(\":\");\n if (parts_0.length < 2) {\n return null;\n }\n const entityType_3 = parts_0[0];\n const entityId_2 = parseInt(parts_0[1], 10);\n if (isNaN(entityId_2)) {\n return null;\n }\n // Use explicit mapping instead of string manipulation\n // This correctly handles \"database\" -> \"ProjectDatabase\" case\n const entityTypeMap: Record<string, EntityType> = {\n client: \"Client\",\n project: \"Project\",\n database: \"ProjectDatabase\",\n projectdatabase: \"ProjectDatabase\"\n };\n const normalizedEntityType = entityTypeMap[entityType_3.toLowerCase()];\n if (!normalizedEntityType) {\n return null;\n }\n return {\n entityType: normalizedEntityType,\n entityId: entityId_2\n };\n }, []);\n\n // Real-time subscription for permission changes\n useEffect(() => {\n if (!user?.id) {\n return;\n }\n\n // Subscribe to changes on UserAccess table for the current user\n // Use unique channel name per user to avoid collisions\n const channel = supabase.channel(`entity-permissions-${user.id}`).on(\"postgres_changes\", {\n event: \"*\",\n schema: \"core\",\n table: \"UserAccess\",\n filter: `userId=eq.${user.id}`\n }, payload => {\n // Parse the scoped access key from the new record\n if (payload.new && typeof payload.new === \"object\" && \"scopedAccessKey\" in payload.new && typeof payload.new.scopedAccessKey === \"string\") {\n const parsed = parseScopedAccessKey(payload.new.scopedAccessKey);\n if (parsed) {\n invalidatePermission(parsed.entityType, parsed.entityId);\n }\n }\n // Parse the scoped access key from the old record (for deletes/updates)\n if (payload.old && typeof payload.old === \"object\" && \"scopedAccessKey\" in payload.old && typeof payload.old.scopedAccessKey === \"string\") {\n const parsed_0 = parseScopedAccessKey(payload.old.scopedAccessKey);\n if (parsed_0) {\n invalidatePermission(parsed_0.entityType, parsed_0.entityId);\n }\n }\n }).subscribe();\n return () => {\n channel.unsubscribe();\n supabase.removeChannel(channel);\n };\n }, [supabase, user?.id, invalidatePermission, parseScopedAccessKey]);\n\n // Clear cache on user change\n useEffect(() => {\n cacheRef.current.clear();\n pendingLookupsRef.current.clear();\n inFlightRef.current.clear();\n if (batchTimerRef.current) {\n clearTimeout(batchTimerRef.current);\n batchTimerRef.current = null;\n }\n forceUpdate(prev_3 => prev_3 + 1);\n }, [user?.id]);\n\n // Cleanup batch timer on unmount\n useEffect(() => {\n return () => {\n if (batchTimerRef.current) {\n clearTimeout(batchTimerRef.current);\n }\n };\n }, []);\n const value = useMemo(() => ({\n getPermission,\n checkPermission,\n prefetchPermissions,\n invalidatePermission,\n isLoading\n }), [getPermission, checkPermission, prefetchPermissions, invalidatePermission, isLoading]);\n return <permissionContext.Provider value={value}>\n {children}\n </permissionContext.Provider>;\n}\nexport function usePermissions() {\n const context = useContext(permissionContext);\n if (!context || Object.keys(context).length === 0) {\n throw new Error(\"usePermissions must be used within a PermissionProvider\");\n }\n return context;\n}","import { useDbQuery } from \"../../hooks/useDbQuery\";\nimport useSupabase, { typedSupabase } from \"../../useSupabase\";\nimport { isUsable, newUuid } from \"@pol-studios/utils\";\nimport { QueryData, SignUpWithPasswordCredentials, User } from \"@supabase/supabase-js\";\nimport { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { PermissionProvider } from \"./PermissionContext\";\n// Import from shared context to use internally\nimport { setupAuthContext, type ProfileStatus, type EffectivePermission } from \"./setupAuthContext\";\n// Re-export from shared context to maintain API compatibility\nexport { setupAuthContext, type SetupAuthContext, type SetupAuthContextProviderProps, type ProfileStatus, type EffectivePermission } from \"./setupAuthContext\";\n\n/**\n * Maps permission action strings to numeric levels for comparison.\n * Higher numbers grant more access.\n */\nfunction getPermissionLevel(action: string): number {\n switch (action.toLowerCase()) {\n case \"view\":\n case \"read\":\n return 1;\n case \"edit\":\n case \"write\":\n return 2;\n case \"admin\":\n case \"delete\":\n case \"share\":\n return 3;\n default:\n return 0;\n }\n}\nconst profileQuery = typedSupabase?.schema(\"core\").from(\"Profile\").select(\"*, UserAccess(accessKey), status\").single();\nexport type Profile = QueryData<typeof profileQuery>;\nexport interface AuthProviderProps {\n children: ReactNode;\n /**\n * Enable entity-level permissions system (Project, Client, ProjectDatabase access control).\n * When enabled, wraps children with PermissionProvider.\n * @default false\n */\n enableEntityPermissions?: boolean;\n}\n\n// ============================================================================\n// Types for access-related tables (synced via PowerSync)\n// ============================================================================\n\ninterface UserAccessRow {\n id: string;\n accessKey: string;\n effect: string;\n expiresAt: string | null;\n grantedAt: string | null;\n grantedBy: string | null;\n userId: string;\n}\ninterface UserGroupRow {\n id: string;\n userId: string;\n groupId: number;\n expiresAt: string | null;\n grantedAt: string | null;\n grantedBy: string | null;\n}\ninterface GroupAccessKeyRow {\n id: string;\n groupId: number;\n accessKey: string;\n effect: string;\n expiresAt?: string | null;\n}\ninterface GroupRow {\n id: number;\n name: string;\n isActive: number; // PowerSync stores booleans as 0/1\n description?: string | null;\n createdAt?: string | null;\n createdBy?: string | null;\n}\ninterface ProfileRow {\n id: string;\n email?: string | null;\n firstName?: string | null;\n lastName?: string | null;\n fullName?: string | null;\n status?: string | null;\n [key: string]: unknown;\n}\n\n/** Check if a date string is not expired (null = never expires) */\nfunction isNotExpired(expiresAt: string | null | undefined): boolean {\n return !expiresAt || new Date(expiresAt) > new Date();\n}\nexport function AuthProvider({\n children,\n enableEntityPermissions = false\n}: AuthProviderProps) {\n const supabase = useSupabase();\n const [currentUser, setCurrentUser] = useState<User | null | undefined>(undefined);\n const [userNeedsChange, setUserNeedsChange] = useState(true);\n // Prevents premature isLoading=false during async gap between auth event and session fetch\n const [onSignOutCallbacks, setOnSignOutCallbacks] = useState(new Map<string, () => any>());\n async function registerAsync(register: SignUpWithPasswordCredentials) {\n const response = await supabase.auth.signUp(register);\n setCurrentUser(prev => {\n const newUser = response.data.user;\n if (prev?.id === newUser?.id) {\n return prev;\n }\n return newUser;\n });\n return response;\n }\n async function signInAsync(username: string, password: string) {\n const response_0 = await supabase.auth.signInWithPassword({\n email: username,\n password\n });\n if (response_0.data) {\n setCurrentUser(prev_0 => {\n const newUser_0 = response_0.data.user;\n if (prev_0?.id === newUser_0?.id) {\n return prev_0;\n }\n return newUser_0;\n });\n }\n return response_0;\n }\n async function signOutAsync() {\n const response_1 = await supabase.auth.signOut();\n if (isUsable(response_1.error) === false) {\n Array.from(onSignOutCallbacks.values()).forEach(x => {\n x();\n });\n }\n return response_1;\n }\n function onSignOut(action: () => any) {\n const id = newUuid();\n setOnSignOutCallbacks(x_0 => new Map(x_0).set(id, action));\n return id;\n }\n function removeOnSignOut(id_0: string) {\n setOnSignOutCallbacks(x_1 => {\n const map = new Map(x_1);\n map.delete(id_0);\n return map;\n });\n }\n async function refreshAsync() {}\n useEffect(() => {\n const request = supabase.auth.onAuthStateChange(event => {\n if (event === \"SIGNED_IN\" || event === \"SIGNED_OUT\") {\n setUserNeedsChange(true);\n }\n });\n return () => {\n request.data.subscription.unsubscribe();\n };\n }, [supabase.auth]);\n useEffect(() => {\n if (userNeedsChange === false) return;\n supabase.auth.getSession().then(x_2 => {\n setCurrentUser(prev_1 => {\n const newUser_1 = x_2?.data?.session?.user ?? null;\n if (newUser_1 === null) return null;\n // Only update reference if user actually changed\n if (prev_1?.id === newUser_1?.id) {\n return prev_1;\n }\n return newUser_1;\n });\n setUserNeedsChange(false);\n }).catch(error => {\n console.error(\"Failed to get session:\", error);\n setCurrentUser(prev_2 => prev_2 === null ? prev_2 : null);\n setUserNeedsChange(false);\n });\n }, [userNeedsChange]);\n\n // Query user's profile using V3 hook\n const {\n data: profileData,\n isLoading: profileLoading,\n refetch: refetchProfile\n } = useDbQuery<ProfileRow>(\"core.Profile\", {\n where: {\n id: currentUser?.id\n },\n enabled: isUsable(currentUser)\n });\n // Cast to Profile type to match the context interface\n const profile = profileData?.[0] as Profile | null ?? null;\n\n // Query user's direct access using V3 hook\n const {\n data: directAccess,\n isLoading: directAccessLoading,\n refetch: refetchDirectAccess\n } = useDbQuery<UserAccessRow>(\"core.UserAccess\", {\n where: {\n userId: currentUser?.id\n },\n enabled: isUsable(currentUser)\n });\n\n // Query user's group memberships using V3 hook\n const {\n data: userGroups,\n isLoading: userGroupsLoading,\n refetch: refetchUserGroups\n } = useDbQuery<UserGroupRow>(\"core.UserGroup\", {\n where: {\n userId: currentUser?.id\n },\n enabled: isUsable(currentUser)\n });\n\n // Query active groups using V3 hook\n const {\n data: groups,\n isLoading: groupsLoading,\n refetch: refetchGroups\n } = useDbQuery<GroupRow>(\"core.Group\", {\n where: {\n isActive: 1\n },\n // PowerSync stores booleans as 0/1\n enabled: isUsable(currentUser)\n });\n\n // Get group IDs the user belongs to\n const groupIds = useMemo(() => userGroups?.map(ug => ug.groupId) ?? [], [userGroups]);\n\n // Map groups by ID for O(1) lookups\n const groupsMap = useMemo(() => new Map(groups?.map(g => [g.id, g]) ?? []), [groups]);\n\n // Query group access keys for user's groups using V3 hook\n const {\n data: groupAccess,\n isLoading: groupAccessLoading,\n refetch: refetchGroupAccess\n } = useDbQuery<GroupAccessKeyRow>(\"core.GroupAccessKey\", {\n where: groupIds.length > 0 ? {\n groupId: {\n in: groupIds\n }\n } : undefined,\n enabled: groupIds.length > 0\n });\n\n // Stable refetch callback for access data (replaces RPC calls)\n const refetchAccessData = useCallback(() => {\n refetchDirectAccess();\n refetchUserGroups();\n refetchGroups();\n refetchGroupAccess();\n }, [refetchDirectAccess, refetchUserGroups, refetchGroups, refetchGroupAccess]);\n\n // Track user's group IDs for filtering GroupAccessKey changes\n const userGroupIdsRef = useRef<Set<number>>(new Set());\n\n // Update group IDs ref when userGroups changes\n useEffect(() => {\n if (userGroups) {\n const groupIdSet = new Set<number>();\n for (const ug_0 of userGroups) {\n if (ug_0.groupId) {\n groupIdSet.add(typeof ug_0.groupId === \"number\" ? ug_0.groupId : parseInt(ug_0.groupId, 10));\n }\n }\n userGroupIdsRef.current = groupIdSet;\n }\n }, [userGroups]);\n\n // Real-time subscription for access key changes (direct + group-based)\n useEffect(() => {\n if (!currentUser?.id) return;\n const channel = supabase.channel(`user-access-keys-${currentUser.id}`)\n // Direct access changes\n .on(\"postgres_changes\", {\n event: \"*\",\n schema: \"core\",\n table: \"UserAccess\",\n filter: `userId=eq.${currentUser.id}`\n }, () => {\n refetchAccessData();\n })\n // Group membership changes for this user\n .on(\"postgres_changes\", {\n event: \"*\",\n schema: \"core\",\n table: \"UserGroup\",\n filter: `userId=eq.${currentUser.id}`\n }, () => {\n refetchAccessData();\n })\n // Group access key changes (check if user is in affected group)\n .on(\"postgres_changes\", {\n event: \"*\",\n schema: \"core\",\n table: \"GroupAccessKey\"\n }, payload => {\n const groupId = (payload.new as {\n groupId?: number;\n })?.groupId || (payload.old as {\n groupId?: number;\n })?.groupId;\n if (groupId && userGroupIdsRef.current.has(groupId)) {\n refetchAccessData();\n }\n })\n // Group activation/deactivation\n .on(\"postgres_changes\", {\n event: \"UPDATE\",\n schema: \"core\",\n table: \"Group\"\n }, payload_0 => {\n const oldActive = (payload_0.old as {\n isActive?: boolean;\n })?.isActive;\n const newActive = (payload_0.new as {\n isActive?: boolean;\n })?.isActive;\n const groupId_0 = (payload_0.new as {\n id?: number;\n })?.id;\n // Refetch if activation status changed and user is in this group\n if (oldActive !== newActive && groupId_0 && userGroupIdsRef.current.has(groupId_0)) {\n refetchAccessData();\n }\n }).subscribe();\n return () => {\n channel.unsubscribe();\n supabase.removeChannel(channel);\n };\n }, [supabase, currentUser?.id, refetchAccessData]);\n\n // Real-time subscription for profile status changes (force signout if archived/suspended)\n useEffect(() => {\n if (!currentUser?.id) return;\n const profileChannel = supabase.channel(`profile-status-${currentUser.id}`).on(\"postgres_changes\", {\n event: \"UPDATE\",\n schema: \"core\",\n table: \"Profile\",\n filter: `id=eq.${currentUser.id}`\n }, payload_1 => {\n const newStatus = (payload_1.new as {\n status?: string;\n })?.status;\n const oldStatus = (payload_1.old as {\n status?: string;\n })?.status;\n\n // If status changed to archived/suspended, force sign out\n if (oldStatus === \"active\" && (newStatus === \"archived\" || newStatus === \"suspended\")) {\n signOutAsync();\n }\n\n // Refetch profile data to update UI\n refetchProfile();\n }).subscribe();\n return () => {\n profileChannel.unsubscribe();\n supabase.removeChannel(profileChannel);\n };\n }, [supabase, currentUser?.id, refetchProfile]);\n\n // All access keys with metadata (for detailed permission info)\n const allAccessKeys = useMemo(() => {\n const keys: Array<{\n accessKey: string;\n effect: string;\n source: \"direct\" | \"group\";\n expiresAt?: string | null;\n }> = [];\n\n // Add direct access keys (filter out expired)\n directAccess?.forEach(a => {\n if (isNotExpired(a.expiresAt)) {\n keys.push({\n accessKey: a.accessKey,\n effect: a.effect ?? \"allow\",\n source: \"direct\",\n expiresAt: a.expiresAt\n });\n }\n });\n\n // Add group access keys (only from active groups user belongs to)\n const activeGroupIds = new Set(userGroups?.filter(ug_1 => {\n const group = groupsMap.get(ug_1.groupId); // O(1) lookup\n return group?.isActive === 1 && isNotExpired(ug_1.expiresAt);\n }).map(ug_2 => ug_2.groupId) ?? []);\n groupAccess?.forEach(ga => {\n if (activeGroupIds.has(ga.groupId) && isNotExpired(ga.expiresAt)) {\n keys.push({\n accessKey: ga.accessKey,\n effect: ga.effect ?? \"allow\",\n source: \"group\",\n expiresAt: ga.expiresAt\n });\n }\n });\n return keys;\n }, [directAccess, userGroups, groupsMap, groupAccess]);\n\n // Combine access keys into a simple string array for hasAccess checks\n const combinedAccess: string[] = useMemo(() => {\n const uniqueKeys = new Set<string>();\n for (const item of allAccessKeys) {\n // Only include \"allow\" effect keys\n if (item.accessKey && item.effect === \"allow\") {\n uniqueKeys.add(item.accessKey);\n }\n }\n return Array.from(uniqueKeys);\n }, [allAccessKeys]);\n\n // Compute effective permissions client-side from access keys\n const effectivePermissions: EffectivePermission[] = useMemo(() => {\n const permissions: EffectivePermission[] = [];\n for (const item_0 of allAccessKeys) {\n // Only process \"allow\" effect keys\n if (item_0.effect !== \"allow\") continue;\n\n // Parse access key format: type:id:action or type:*:action\n const parts = item_0.accessKey.split(\":\");\n if (parts.length === 3) {\n const [resourceType, resourceId, permission] = parts;\n const permissionLevel = getPermissionLevel(permission);\n permissions.push({\n resourceType,\n resourceId,\n permission,\n permissionLevel,\n source: item_0.source,\n inheritedFrom: null,\n expiresAt: item_0.expiresAt ?? null\n });\n }\n }\n return permissions;\n }, [allAccessKeys]);\n\n // Compute profile status values\n const profileStatus = profile?.status as ProfileStatus | undefined;\n const isArchived = profileStatus === \"archived\";\n const isSuspended = profileStatus === \"suspended\";\n const hasAccess = useCallback((key: string) => {\n // Archived/suspended users have no access\n if (isArchived || isSuspended) {\n return false;\n }\n const accessGiven = combinedAccess;\n if (isUsable(accessGiven) === false) return false;\n // Super-admin key bypasses all permission checks\n if (accessGiven.includes(\"*:*:*\")) return true;\n if (accessGiven.includes(key)) return true;\n if (isUsable(key) === false) return true;\n\n // Check if this is an entity-level permission key (format: type:id:action)\n const parts_0 = key.split(\":\");\n if (parts_0.length === 3) {\n const [type, id_1, action_0] = parts_0;\n const requiredLevel = getPermissionLevel(action_0);\n\n // Check against effective permissions\n const hasPermission = effectivePermissions.some(p => p.resourceType === type && p.resourceId === id_1 && p.permissionLevel >= requiredLevel);\n if (hasPermission) {\n return true;\n }\n }\n return false;\n }, [combinedAccess, effectivePermissions, isArchived, isSuspended]);\n\n // Compute overall loading state for auth data\n const isAccessLoading = directAccessLoading || userGroupsLoading || groupsLoading || groupAccessLoading;\n const authStateWithLoading = useMemo(() => ({\n hasAccess,\n user: currentUser,\n profile,\n access: combinedAccess,\n effectivePermissions,\n profileStatus,\n isArchived,\n isSuspended,\n isLoading: currentUser === null ? false : profileLoading || isAccessLoading || currentUser === undefined,\n signInAsync,\n signOutAsync,\n onSignOut,\n removeOnSignOut,\n registerAsync,\n refreshAsync\n }), [profile, profileLoading, isAccessLoading, currentUser, combinedAccess, effectivePermissions, profileStatus, isArchived, isSuspended, hasAccess]);\n const content = enableEntityPermissions ? <PermissionProvider>{children}</PermissionProvider> : children;\n return <setupAuthContext.Provider value={authStateWithLoading}>\n {content}\n </setupAuthContext.Provider>;\n}","import { c as _c } from \"react/compiler-runtime\";\nimport { ReactNode, createContext, useContext, useEffect, useMemo, useState, useCallback, useRef } from \"react\";\nimport { useDbQuery as useQuery } from \"../../useDbQuery\";\nimport { useDbUpsert as useUpsert } from \"../../useDbUpsert\";\nimport useSupabase, { Database } from \"../../useSupabase\";\nimport { isUsable } from \"@pol-studios/utils\";\nimport { setupAuthContext } from \"./AuthProvider\";\n\n// UserMetadata query constant\nconst UserMetadataQuery = {\n schema: \"core\",\n table: \"UserMetadata\",\n defaultQuery: \"key, userId, value\"\n} as const;\n\n// Type definitions for UserMetadata\nexport type UserMetadataRow = Database[\"core\"][\"Tables\"][\"UserMetadata\"][\"Row\"];\nexport type UserMetadataInsert = Database[\"core\"][\"Tables\"][\"UserMetadata\"][\"Insert\"];\nexport type UserMetadataUpdate = Database[\"core\"][\"Tables\"][\"UserMetadata\"][\"Update\"];\n\n// Context interface\nexport interface UserMetadataContextType {\n metadata: Record<string, string>;\n isLoading: boolean;\n error: Error | null;\n setMetadata: (key: string, value: string) => Promise<void>;\n getMetadata: (key: string) => string | undefined;\n removeMetadata: (key: string) => Promise<void>;\n refreshMetadata: () => Promise<void>;\n}\n\n// Create context\nexport const userMetadataContext = createContext<UserMetadataContextType | null>(null);\n\n// Provider component\nexport function UserMetadataProvider({\n children\n}: {\n children: ReactNode;\n}) {\n const supabase = useSupabase();\n const [metadata, setMetadataState] = useState<Record<string, string>>({});\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n // Get current user ID from auth context\n const setupAuth = useContext(setupAuthContext);\n const userId = setupAuth?.user?.id;\n\n // Query to fetch all user metadata\n const metadataQuery = useQuery(supabase.schema(\"core\").from(\"UserMetadata\").select(UserMetadataQuery.defaultQuery).eq(\"userId\", userId!).order(\"key\"), {\n enabled: isUsable(userId),\n crossOrganization: true\n });\n\n // Upsert mutation for updating metadata\n const upsertMutation = useUpsert({\n table: \"UserMetadata\",\n schema: \"core\"\n }, [\"userId\", \"key\"] // composite primary keys\n );\n\n // Ref to hold mutation to avoid infinite loops in useCallback dependencies\n const upsertMutationRef = useRef(upsertMutation);\n upsertMutationRef.current = upsertMutation;\n\n // Update local state when query data changes\n useEffect(() => {\n if (metadataQuery.data && Array.isArray(metadataQuery.data)) {\n const metadataMap: Record<string, string> = {};\n metadataQuery.data.forEach((item: any) => {\n metadataMap[item.key] = item.value;\n });\n setMetadataState(metadataMap);\n setIsLoading(false);\n setError(null);\n } else if (metadataQuery.error) {\n setError(metadataQuery.error);\n setIsLoading(false);\n } else if (metadataQuery.isLoading) {\n setIsLoading(true);\n } else if (metadataQuery.data && !Array.isArray(metadataQuery.data)) {\n // Handle case where data is not an array (e.g., empty response or count)\n setMetadataState({});\n setIsLoading(false);\n }\n }, [metadataQuery.data, metadataQuery.error, metadataQuery.isLoading]);\n\n // Set metadata function\n const setMetadata = useCallback(async (key: string, value: string) => {\n if (!userId) {\n throw new Error(\"User not authenticated\");\n }\n try {\n await upsertMutationRef.current.mutateAsync({\n userId,\n key,\n value\n });\n\n // Update local state optimistically\n setMetadataState(prev => ({\n ...prev,\n [key]: value\n }));\n } catch (err) {\n setError(err as Error);\n throw err;\n }\n }, [userId]);\n\n // Get metadata function\n const getMetadata = useCallback((key_0: string): string | undefined => {\n return metadata[key_0];\n }, [metadata]);\n\n // Remove metadata function\n const removeMetadata = useCallback(async (key_1: string) => {\n if (!userId) {\n throw new Error(\"User not authenticated\");\n }\n try {\n await supabase.schema(\"core\").from(\"UserMetadata\").delete().eq(\"userId\", userId).eq(\"key\", key_1);\n\n // Update local state\n setMetadataState(prev_0 => {\n const newState = {\n ...prev_0\n };\n delete newState[key_1];\n return newState;\n });\n } catch (err_0) {\n setError(err_0 as Error);\n throw err_0;\n }\n }, [userId, supabase]);\n\n // Refresh metadata function\n const refreshMetadata = useCallback(async () => {\n await metadataQuery.refetch();\n }, [metadataQuery]);\n\n // Context value\n const contextValue = useMemo(() => ({\n metadata,\n isLoading,\n error,\n setMetadata,\n getMetadata,\n removeMetadata,\n refreshMetadata\n }), [metadata, isLoading, error, setMetadata, getMetadata, removeMetadata, refreshMetadata]);\n return <userMetadataContext.Provider value={contextValue}>\n {children}\n </userMetadataContext.Provider>;\n}\n\n// Hook to use the context\nexport function useUserMetadata() {\n const context = useContext(userMetadataContext);\n if (!context) {\n throw new Error(\"useUserMetadata must be used within a UserMetadataProvider\");\n }\n return context;\n}\n\n// Convenience hook for getting a specific metadata value\nexport function useUserMetadataValue(key) {\n const $ = _c(3);\n const {\n getMetadata\n } = useUserMetadata();\n let t0;\n if ($[0] !== getMetadata || $[1] !== key) {\n t0 = getMetadata(key);\n $[0] = getMetadata;\n $[1] = key;\n $[2] = t0;\n } else {\n t0 = $[2];\n }\n return t0;\n}\n\n// Convenience hook for setting a specific metadata value\nexport function useSetUserMetadata() {\n const $ = _c(3);\n const {\n setMetadata,\n removeMetadata\n } = useUserMetadata();\n let t0;\n if ($[0] !== removeMetadata || $[1] !== setMetadata) {\n t0 = {\n setMetadata,\n removeMetadata\n };\n $[0] = removeMetadata;\n $[1] = setMetadata;\n $[2] = t0;\n } else {\n t0 = $[2];\n }\n return t0;\n}\n\n// Advanced state-like hook with JSON serialization support\nexport function useUserMetadataState(key, defaultValue, options) {\n const $ = _c(11);\n const {\n metadata,\n setMetadata,\n isLoading\n } = useUserMetadata();\n const serialize = options?.serialize ?? _temp;\n const deserialize = options?.deserialize ?? _temp2;\n let t0;\n bb0: {\n const rawValue = metadata[key];\n if (!rawValue) {\n t0 = defaultValue;\n break bb0;\n }\n ;\n try {\n let t2;\n if ($[0] !== deserialize || $[1] !== rawValue) {\n t2 = deserialize(rawValue);\n $[0] = deserialize;\n $[1] = rawValue;\n $[2] = t2;\n } else {\n t2 = $[2];\n }\n t0 = t2;\n } catch (t1) {\n const error = t1;\n console.warn(`Failed to deserialize metadata for key \"${key}\":`, error);\n t0 = defaultValue;\n }\n }\n const currentValue = t0;\n let t1;\n if ($[3] !== key || $[4] !== serialize || $[5] !== setMetadata) {\n t1 = async value_1 => {\n const serializedValue = serialize(value_1);\n await setMetadata(key, serializedValue);\n };\n $[3] = key;\n $[4] = serialize;\n $[5] = setMetadata;\n $[6] = t1;\n } else {\n t1 = $[6];\n }\n const setValue = t1;\n let t2;\n if ($[7] !== currentValue || $[8] !== isLoading || $[9] !== setValue) {\n t2 = [currentValue, setValue, isLoading];\n $[7] = currentValue;\n $[8] = isLoading;\n $[9] = setValue;\n $[10] = t2;\n } else {\n t2 = $[10];\n }\n return t2;\n}\nfunction _temp2(value_0) {\n return JSON.parse(value_0);\n}\nfunction _temp(value) {\n return JSON.stringify(value);\n}","import { c as _c } from \"react/compiler-runtime\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport useSupabase, { Database } from \"./useSupabase\";\nimport { useQueriesForTableLoader, useUpdateMutation, useUpsertItem } from \"@supabase-cache-helpers/postgrest-react-query\";\nimport { GetResult } from \"./parser/select-query-parser\";\nimport { GenericSchema } from \"./parser/types\";\nimport { isUsable } from \"@pol-studios/utils\";\nimport { omit } from \"@pol-studios/utils\";\nimport { buildNormalizedQuery } from \"@supabase-cache-helpers/postgrest-core\";\ntype ItemType<T> = T extends Array<infer U> ? U : T;\nexport type MutationOption = Parameters<typeof useUpdateMutation>[3];\nexport type useDbUpsertResponse = ReturnType<typeof useDbUpsert>;\nexport function useDbUpsert(relation, t0, query, mutationOption) {\n const $ = _c(16);\n let t1;\n if ($[0] !== t0) {\n t1 = t0 === undefined ? [\"id\"] : t0;\n $[0] = t0;\n $[1] = t1;\n } else {\n t1 = $[1];\n }\n const primaryKeys = t1;\n const tableName = typeof relation === \"object\" ? relation.table : relation;\n const schemaName = typeof relation === \"object\" ? String(relation.schema) : \"public\";\n const supabase = useSupabase();\n let t2;\n if ($[2] !== primaryKeys) {\n t2 = primaryKeys.map(_temp);\n $[2] = primaryKeys;\n $[3] = t2;\n } else {\n t2 = $[3];\n }\n const primaryKeysAsStrings = t2 as string[];\n const t3 = primaryKeysAsStrings as any;\n const t4 = relation as any;\n let t5;\n if ($[4] !== t3 || $[5] !== t4) {\n t5 = {\n primaryKeys: t3,\n table: t4,\n schema: \"public\"\n };\n $[4] = t3;\n $[5] = t4;\n $[6] = t5;\n } else {\n t5 = $[6];\n }\n const upsertItem = useUpsertItem(t5);\n const queriesForTable = useQueriesForTableLoader(tableName);\n let t6;\n if ($[7] !== primaryKeys || $[8] !== primaryKeysAsStrings || $[9] !== queriesForTable || $[10] !== query || $[11] !== schemaName || $[12] !== supabase || $[13] !== tableName || $[14] !== upsertItem) {\n t6 = {\n mutationFn: async item => {\n let result = null;\n const selectQuery = buildNormalizedQuery({\n queriesForTable,\n query\n });\n const insert = async function insert() {\n const keysToFilter = primaryKeys.filter(x => isUsable((item as any)[x]) === false);\n const keysToFilterAsStrings = keysToFilter.map(_temp2) as string[];\n const response = await (supabase as any).schema(schemaName as \"public\" | \"core\").from(tableName).insert(omit(item as any, keysToFilterAsStrings as any) as any).select(query).single();\n if (response.error) {\n throw response.error;\n }\n result = response.data as any;\n if (result) {\n upsertItem(result as any);\n }\n };\n const isUpsertable = primaryKeys.every(x_0 => x_0 in item && isUsable((item as any)[x_0]));\n if (isUpsertable) {\n const query_0 = (supabase as any).schema(schemaName as \"public\" | \"core\").from(tableName).update(omit(item as any, primaryKeysAsStrings as any) as any);\n primaryKeys.forEach(x_1 => {\n query_0.eq(String(x_1), (item as any)[x_1]);\n });\n const queryResponse = await query_0.select(selectQuery?.selectQuery).single();\n console.log(\"queryResponse\", queryResponse, tableName);\n if (queryResponse.status === 406) {\n await insert();\n } else {\n if (queryResponse.error) {\n throw queryResponse.error;\n }\n if (queryResponse.data) {\n result = queryResponse.data as any;\n if (result) {\n upsertItem(result as any);\n }\n }\n }\n } else {\n await insert();\n }\n return result as any;\n }\n };\n $[7] = primaryKeys;\n $[8] = primaryKeysAsStrings;\n $[9] = queriesForTable;\n $[10] = query;\n $[11] = schemaName;\n $[12] = supabase;\n $[13] = tableName;\n $[14] = upsertItem;\n $[15] = t6;\n } else {\n t6 = $[15];\n }\n const mutation = useMutation(t6);\n return mutation;\n}\nfunction _temp2(k_0) {\n return String(k_0);\n}\nfunction _temp(k) {\n return String(k);\n}"],"mappings":";;;;;;;;;;;;;;;AAAO,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAE9B,SAAS,eAAe,OAA0C;AACvE,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,MAAM,SAAS,gBAAgB,MAAM,YAAY,yBAAyB,MAAM,QAAQ,YAAY,EAAE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;AACP,UAAE,CAAC,IAAIA;AAAA,MACT,OAAO;AACL,QAAAA,MAAK,EAAE,CAAC;AAAA,MACV;AACA,WAAKA;AAAA,IACP,SAASC,KAAI;AACX,YAAM,QAAQA;AACd,cAAQ,KAAK,2CAA2C,GAAG,MAAM,KAAK;AACtE,WAAK;AAAA,IACP;AAAA,EACF;AACA,QAAM,eAAe;AACrB,MAAI;AACJ,MAAI,EAAE,CAAC,MAAM,OAAO,EAAE,CAAC,MAAM,aAAa,EAAE,CAAC,MAAM,aAAa;AAC9D,SAAK,OAAM,YAAW;AACpB,YAAM,kBAAkB,UAAU,OAAO;AACzC,YAAM,YAAY,KAAK,eAAe;AAAA,IACxC;AACA,MAAE,CAAC,IAAI;AACP,MAAE,CAAC,IAAI;AACP,MAAE,CAAC,IAAI;AACP,MAAE,CAAC,IAAI;AAAA,EACT,OAAO;AACL,SAAK,EAAE,CAAC;AAAA,EACV;AACA,QAAM,WAAW;AACjB,MAAI;AACJ,MAAI,EAAE,CAAC,MAAM,gBAAgB,EAAE,CAAC,MAAM,aAAa,EAAE,CAAC,MAAM,UAAU;AACpE,SAAK,CAAC,cAAc,UAAU,SAAS;AACvC,MAAE,CAAC,IAAI;AACP,MAAE,CAAC,IAAI;AACP,MAAE,CAAC,IAAI;AACP,MAAE,EAAE,IAAI;AAAA,EACV,OAAO;AACL,SAAK,EAAE,EAAE;AAAA,EACX;AACA,SAAO;AACT;AACA,SAASF,QAAO,SAAS;AACvB,SAAO,KAAK,MAAM,OAAO;AAC3B;AACA,SAASD,OAAM,OAAO;AACpB,SAAO,KAAK,UAAU,KAAK;AAC7B;","names":["useDbQuery","createContext","useMemo","useRef","createContext","useRef","useMemo","useCallback","useEffect","useMemo","useRef","useState","jsx","useState","useEffect","useMemo","useCallback","useRef","_c","createContext","useContext","useEffect","useMemo","useState","useCallback","useRef","isUsable","omit","insert","isUsable","omit","isUsable","jsx","createContext","useState","useContext","useDbQuery","isUsable","useRef","useEffect","useCallback","useMemo","_c","_temp","_temp2","t2","t1"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-6KN7KLEG.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useDataLayerCoreOptional,
|
|
3
2
|
useDbUpsert
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NP34C3O3.js";
|
|
5
4
|
import {
|
|
6
5
|
normalizeFilter
|
|
7
6
|
} from "./chunk-Z456IHCB.js";
|
|
@@ -10,7 +9,10 @@ import {
|
|
|
10
9
|
} from "./chunk-7SCJNYTE.js";
|
|
11
10
|
import {
|
|
12
11
|
useDbQuery
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-67HMVGV7.js";
|
|
13
|
+
import {
|
|
14
|
+
useDataLayerCoreOptional
|
|
15
|
+
} from "./chunk-UBHORKBS.js";
|
|
14
16
|
import {
|
|
15
17
|
getSupabaseUrl
|
|
16
18
|
} from "./chunk-GC3TBUWE.js";
|
|
@@ -7922,4 +7924,4 @@ moment/moment.js:
|
|
|
7922
7924
|
(*! license : MIT *)
|
|
7923
7925
|
(*! momentjs.com *)
|
|
7924
7926
|
*/
|
|
7925
|
-
//# sourceMappingURL=chunk-
|
|
7927
|
+
//# sourceMappingURL=chunk-AML2TLXJ.js.map
|