@pol-studios/db 1.0.19 → 1.0.21
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-ZmLPYR_s.d.ts +825 -0
- package/dist/EntityPermissions-DwFt4tUd.d.ts +35 -0
- package/dist/FilterConfig-Bt2Ek74z.d.ts +99 -0
- package/dist/UserMetadataContext-B8gVWGMl.d.ts +35 -0
- package/dist/UserMetadataContext-DntmpK41.d.ts +33 -0
- package/dist/auth/context.d.ts +48 -0
- package/dist/auth/guards.d.ts +180 -0
- package/dist/auth/hooks.d.ts +312 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/client/index.d.ts +16 -0
- package/dist/core/index.d.ts +539 -0
- package/dist/database.types-ChFCG-4M.d.ts +8604 -0
- package/dist/executor-CB4KHyYG.d.ts +507 -0
- package/dist/gen/index.d.ts +1099 -0
- package/dist/hooks/index.d.ts +100 -0
- package/dist/index-BNKhgDdC.d.ts +433 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.native.d.ts +793 -0
- package/dist/index.web.d.ts +321 -0
- package/dist/mutation/index.d.ts +58 -0
- package/dist/parser/index.d.ts +366 -0
- package/dist/powersync-bridge/index.d.ts +284 -0
- package/dist/query/index.d.ts +723 -0
- package/dist/realtime/index.d.ts +44 -0
- package/dist/select-query-parser-BwyHum1L.d.ts +352 -0
- package/dist/setupAuthContext-Kv-THH-h.d.ts +61 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types-CYr9JiUE.d.ts +62 -0
- package/dist/useBatchUpsert-9OYjibLh.d.ts +24 -0
- package/dist/useDbCount-Id14x_1P.d.ts +1082 -0
- package/dist/useDbQuery-C-TL8jY1.d.ts +19 -0
- package/dist/useReceiptAI-6HkRpRml.d.ts +58 -0
- package/dist/useResolveFeedback-Ca2rh_Bs.d.ts +997 -0
- package/dist/useSupabase-DvWVuHHE.d.ts +28 -0
- package/dist/with-auth/index.d.ts +704 -0
- package/package.json +61 -13
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { User } from '@supabase/supabase-js';
|
|
2
|
+
import { a as SetupAuthContext } from '../setupAuthContext-Kv-THH-h.js';
|
|
3
|
+
import { d as EntityType, a as EntityAction, b as EntityPermissionCheck } from '../EntityPermissions-DwFt4tUd.js';
|
|
4
|
+
export { u as useSetUserMetadata, a as useUserMetadata, b as useUserMetadataState, c as useUserMetadataValue } from '../UserMetadataContext-DntmpK41.js';
|
|
5
|
+
import 'react/jsx-runtime';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../useSupabase-DvWVuHHE.js';
|
|
8
|
+
import '@supabase/supabase-js/dist/module/lib/types.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook for authenticated users only.
|
|
12
|
+
* Throws an error if the user is not authenticated.
|
|
13
|
+
* Use useSetupAuth() if you need to handle unauthenticated users.
|
|
14
|
+
*
|
|
15
|
+
* @returns Auth context with guaranteed non-null user and hasAccess helper
|
|
16
|
+
* @throws Error if user is not authenticated
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* function AuthenticatedComponent() {
|
|
21
|
+
* const { user, hasAccess, profile } = useAuth();
|
|
22
|
+
*
|
|
23
|
+
* // user is guaranteed to be non-null
|
|
24
|
+
* console.log(user.id);
|
|
25
|
+
*
|
|
26
|
+
* if (hasAccess('admin')) {
|
|
27
|
+
* return <AdminDashboard />;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* return <UserDashboard />;
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function useAuth(): Omit<SetupAuthContext, "user"> & {
|
|
35
|
+
hasAccess: (access: string) => boolean;
|
|
36
|
+
user: User;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Hook for handling both authenticated and unauthenticated states.
|
|
40
|
+
* Does not throw if user is not authenticated.
|
|
41
|
+
*
|
|
42
|
+
* @returns Auth context with possibly null user, hasAccess, and hasEntityAccess helpers
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* function FlexibleComponent() {
|
|
47
|
+
* const { user, hasAccess, hasEntityAccess, isLoading } = useSetupAuth();
|
|
48
|
+
*
|
|
49
|
+
* if (isLoading) {
|
|
50
|
+
* return <Spinner />;
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* if (!user) {
|
|
54
|
+
* return <LoginPrompt />;
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Check global access
|
|
58
|
+
* const isAdmin = hasAccess('admin');
|
|
59
|
+
*
|
|
60
|
+
* // Check entity-level access
|
|
61
|
+
* const canEditProject = hasEntityAccess('Project', 123, 'edit');
|
|
62
|
+
*
|
|
63
|
+
* return <Dashboard />;
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function useSetupAuth(): SetupAuthContext & {
|
|
68
|
+
hasAccess: (access: string) => boolean;
|
|
69
|
+
hasEntityAccess: (entityType: EntityType, entityId: number, action: EntityAction) => boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Hook to get full permission info for a single entity
|
|
74
|
+
* @param entityType - 'Project' | 'Client' | 'ProjectDatabase'
|
|
75
|
+
* @param entityId - The ID of the entity (can be undefined for loading states)
|
|
76
|
+
* @returns EntityPermissionCheck with canView, canEdit, etc. and isLoading
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* function ProjectHeader({ projectId }: { projectId: number }) {
|
|
81
|
+
* const permission = usePermission('Project', projectId);
|
|
82
|
+
*
|
|
83
|
+
* if (permission.isLoading) {
|
|
84
|
+
* return <Spinner />;
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* return (
|
|
88
|
+
* <div>
|
|
89
|
+
* {permission.canEdit && <EditButton />}
|
|
90
|
+
* {permission.canDelete && <DeleteButton />}
|
|
91
|
+
* </div>
|
|
92
|
+
* );
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function usePermission(entityType: EntityType, entityId: number | undefined): EntityPermissionCheck;
|
|
97
|
+
/**
|
|
98
|
+
* Hook to check a single action permission
|
|
99
|
+
* @param entityType - Entity type
|
|
100
|
+
* @param entityId - Entity ID
|
|
101
|
+
* @param action - 'view' | 'adminView' | 'edit' | 'create' | 'delete' | 'share'
|
|
102
|
+
* @returns boolean - true if user has permission for action
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* function ProjectActions({ projectId }: { projectId: number }) {
|
|
107
|
+
* const canEdit = usePermissionCheck('Project', projectId, 'edit');
|
|
108
|
+
* const canDelete = usePermissionCheck('Project', projectId, 'delete');
|
|
109
|
+
*
|
|
110
|
+
* return (
|
|
111
|
+
* <div>
|
|
112
|
+
* <Button disabled={!canEdit}>Edit</Button>
|
|
113
|
+
* <Button disabled={!canDelete}>Delete</Button>
|
|
114
|
+
* </div>
|
|
115
|
+
* );
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function usePermissionCheck(entityType: EntityType, entityId: number | undefined, action: EntityAction): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Result type for usePermissions batch hook
|
|
122
|
+
*/
|
|
123
|
+
interface EntityWithPermission {
|
|
124
|
+
type: EntityType;
|
|
125
|
+
id: number;
|
|
126
|
+
permission: EntityPermissionCheck;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Hook for batch permission lookup - useful for lists
|
|
130
|
+
* @param entities - Array of { type, id } objects
|
|
131
|
+
* @returns Array of entities with their permissions attached
|
|
132
|
+
*
|
|
133
|
+
* This hook:
|
|
134
|
+
* - Calls prefetchPermissions on mount and when entities change
|
|
135
|
+
* - Returns memoized results
|
|
136
|
+
* - Handles empty arrays gracefully
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* function ProjectList({ projects }: { projects: Array<{ id: number; name: string }> }) {
|
|
141
|
+
* const entities = projects.map(p => ({ type: 'Project' as const, id: p.id }));
|
|
142
|
+
* const entitiesWithPermissions = usePermissionsBatch(entities);
|
|
143
|
+
*
|
|
144
|
+
* return (
|
|
145
|
+
* <ul>
|
|
146
|
+
* {entitiesWithPermissions.map(({ id, permission }) => {
|
|
147
|
+
* const project = projects.find(p => p.id === id);
|
|
148
|
+
* return (
|
|
149
|
+
* <li key={id}>
|
|
150
|
+
* {project?.name}
|
|
151
|
+
* {permission.canEdit && <EditIcon />}
|
|
152
|
+
* </li>
|
|
153
|
+
* );
|
|
154
|
+
* })}
|
|
155
|
+
* </ul>
|
|
156
|
+
* );
|
|
157
|
+
* }
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare function usePermissionsBatch(entities: Array<{
|
|
161
|
+
type: EntityType;
|
|
162
|
+
id: number;
|
|
163
|
+
}>): EntityWithPermission[];
|
|
164
|
+
/**
|
|
165
|
+
* Simple boolean hook to check if user can view an entity
|
|
166
|
+
* @param entityType - Entity type
|
|
167
|
+
* @param entityId - Entity ID (can be undefined for loading states)
|
|
168
|
+
* @returns boolean - true if user can view the entity
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```tsx
|
|
172
|
+
* function ProjectPage({ projectId }: { projectId: number }) {
|
|
173
|
+
* const canView = useCanView('Project', projectId);
|
|
174
|
+
*
|
|
175
|
+
* if (!canView) {
|
|
176
|
+
* return <AccessDenied />;
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* return <ProjectContent projectId={projectId} />;
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
declare function useCanView(entityType: EntityType, entityId: number | undefined): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Simple boolean hook to check if user can edit an entity
|
|
186
|
+
* @param entityType - Entity type
|
|
187
|
+
* @param entityId - Entity ID (can be undefined for loading states)
|
|
188
|
+
* @returns boolean - true if user can edit the entity
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```tsx
|
|
192
|
+
* function ProjectEditor({ projectId }: { projectId: number }) {
|
|
193
|
+
* const canEdit = useCanEdit('Project', projectId);
|
|
194
|
+
*
|
|
195
|
+
* return (
|
|
196
|
+
* <form>
|
|
197
|
+
* <input disabled={!canEdit} />
|
|
198
|
+
* <button disabled={!canEdit}>Save</button>
|
|
199
|
+
* </form>
|
|
200
|
+
* );
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function useCanEdit(entityType: EntityType, entityId: number | undefined): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Simple boolean hook to check if user can delete an entity
|
|
207
|
+
* @param entityType - Entity type
|
|
208
|
+
* @param entityId - Entity ID (can be undefined for loading states)
|
|
209
|
+
* @returns boolean - true if user can delete the entity
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* function ProjectActions({ projectId }: { projectId: number }) {
|
|
214
|
+
* const canDelete = useCanDelete('Project', projectId);
|
|
215
|
+
*
|
|
216
|
+
* return (
|
|
217
|
+
* <Button
|
|
218
|
+
* variant="destructive"
|
|
219
|
+
* disabled={!canDelete}
|
|
220
|
+
* onClick={handleDelete}
|
|
221
|
+
* >
|
|
222
|
+
* Delete Project
|
|
223
|
+
* </Button>
|
|
224
|
+
* );
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
declare function useCanDelete(entityType: EntityType, entityId: number | undefined): boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Simple boolean hook to check if user can share an entity
|
|
231
|
+
* @param entityType - Entity type
|
|
232
|
+
* @param entityId - Entity ID (can be undefined for loading states)
|
|
233
|
+
* @returns boolean - true if user can share the entity
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```tsx
|
|
237
|
+
* function ShareButton({ projectId }: { projectId: number }) {
|
|
238
|
+
* const canShare = useCanShare('Project', projectId);
|
|
239
|
+
*
|
|
240
|
+
* if (!canShare) {
|
|
241
|
+
* return null;
|
|
242
|
+
* }
|
|
243
|
+
*
|
|
244
|
+
* return <Button onClick={openShareModal}>Share</Button>;
|
|
245
|
+
* }
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
declare function useCanShare(entityType: EntityType, entityId: number | undefined): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Simple boolean hook to check if user can create entities of a type
|
|
251
|
+
* Note: For create permission, the entityId should be the parent entity ID
|
|
252
|
+
* (e.g., for creating a ProjectDatabase, pass the Project ID)
|
|
253
|
+
*
|
|
254
|
+
* @param entityType - Entity type
|
|
255
|
+
* @param entityId - Parent entity ID (can be undefined for loading states)
|
|
256
|
+
* @returns boolean - true if user can create entities
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```tsx
|
|
260
|
+
* function AddDatabaseButton({ projectId }: { projectId: number }) {
|
|
261
|
+
* const canCreate = useCanCreate('ProjectDatabase', projectId);
|
|
262
|
+
*
|
|
263
|
+
* return (
|
|
264
|
+
* <Button disabled={!canCreate} onClick={handleCreate}>
|
|
265
|
+
* Add Database
|
|
266
|
+
* </Button>
|
|
267
|
+
* );
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function useCanCreate(entityType: EntityType, entityId: number | undefined): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Hook to invalidate permission cache for a specific entity
|
|
274
|
+
* Useful after permission changes (e.g., after sharing an entity)
|
|
275
|
+
*
|
|
276
|
+
* @returns Function to invalidate permission for an entity
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* function ShareModal({ projectId }: { projectId: number }) {
|
|
281
|
+
* const invalidatePermission = useInvalidatePermission();
|
|
282
|
+
*
|
|
283
|
+
* const handleShare = async (userId: string) => {
|
|
284
|
+
* await shareProject(projectId, userId);
|
|
285
|
+
* invalidatePermission('Project', projectId);
|
|
286
|
+
* };
|
|
287
|
+
*
|
|
288
|
+
* return <ShareForm onShare={handleShare} />;
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function useInvalidatePermission(): (entityType: EntityType, entityId: number) => void;
|
|
293
|
+
/**
|
|
294
|
+
* Hook to get the loading state of the permission context
|
|
295
|
+
* @returns boolean - true if permissions are being fetched
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```tsx
|
|
299
|
+
* function PermissionAwareComponent() {
|
|
300
|
+
* const isLoadingPermissions = usePermissionLoading();
|
|
301
|
+
*
|
|
302
|
+
* if (isLoadingPermissions) {
|
|
303
|
+
* return <LoadingSpinner />;
|
|
304
|
+
* }
|
|
305
|
+
*
|
|
306
|
+
* return <Content />;
|
|
307
|
+
* }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function usePermissionLoading(): boolean;
|
|
311
|
+
|
|
312
|
+
export { EntityAction, EntityPermissionCheck, EntityType, type EntityWithPermission, useAuth, useCanCreate, useCanDelete, useCanEdit, useCanShare, useCanView, useInvalidatePermission, usePermission, usePermissionCheck, usePermissionLoading, usePermissionsBatch, useSetupAuth };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { EntityWithPermission, useAuth, useCanCreate, useCanDelete, useCanEdit, useCanShare, useCanView, useInvalidatePermission, usePermission, usePermissionCheck, usePermissionLoading, usePermissionsBatch, useSetupAuth } from './hooks.js';
|
|
2
|
+
export { c as Profile, P as ProfileStatus, a as SetupAuthContext, S as SetupAuthContextProvider, b as SetupAuthContextProviderProps, s as setupAuthContext } from '../setupAuthContext-Kv-THH-h.js';
|
|
3
|
+
export { AuthProvider, AuthProviderProps, EntityPermissionContextValue, PermissionContextValue, PermissionProvider, entityPermissionContext, permissionContext, usePermissions } from './context.js';
|
|
4
|
+
export { U as UserMetadataContextType, e as UserMetadataInsert, f as UserMetadataProvider, g as UserMetadataRow, h as UserMetadataUpdate, u as useSetUserMetadata, a as useUserMetadata, b as useUserMetadataState, c as useUserMetadataValue, d as userMetadataContext } from '../UserMetadataContext-DntmpK41.js';
|
|
5
|
+
export { hasAccess, hasAllAccess, hasAllEntityAccess, hasAnyAccess, hasAnyEntityAccess, hasEntityAccess, isEntityAccessDenied, isPermissionLoaded } from './guards.js';
|
|
6
|
+
export { E as EntityAccessRecord, a as EntityAction, b as EntityPermissionCheck, c as EntityPermissionLevel, d as EntityType, P as PermissionEffect } from '../EntityPermissions-DwFt4tUd.js';
|
|
7
|
+
import '@supabase/supabase-js';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '../useSupabase-DvWVuHHE.js';
|
|
11
|
+
import '@supabase/supabase-js/dist/module/lib/types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { C as ClientInstanceId, D as Database, S as SupabaseDatabaseTypes, a as SupabaseProvider, T as TypedSupabaseClient, U as UserSessionId, c as createNewSupabaseClient, o as onSupabaseInitialized, s as setDefaultOptions, t as typedSupabase, u as useSupabase } from '../useSupabase-DvWVuHHE.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '@supabase/supabase-js/dist/module/lib/types.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@supabase/supabase-js';
|
|
6
|
+
|
|
7
|
+
declare function setSupabaseUrl(url: string): void;
|
|
8
|
+
declare function getSupabaseUrl(): string;
|
|
9
|
+
declare function setSupabaseKey(key: string): void;
|
|
10
|
+
declare function getSupabaseKey(): string;
|
|
11
|
+
|
|
12
|
+
declare function useFunction(): {
|
|
13
|
+
downloadFunctionResponse: (functionName: string, body?: any, name?: string) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { getSupabaseKey, getSupabaseUrl, setSupabaseKey, setSupabaseUrl, useFunction };
|