@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,44 @@
|
|
|
1
|
+
import { RealtimePostgresChangesPayload, PostgrestSingleResponse } from '@supabase/supabase-js';
|
|
2
|
+
import { ItemType } from '@pol-studios/utils';
|
|
3
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
4
|
+
import { U as UseDbQuerySingleReturn } from '../useDbQuery-C-TL8jY1.js';
|
|
5
|
+
import '@supabase-cache-helpers/postgrest-react-query';
|
|
6
|
+
|
|
7
|
+
declare function useRealtime(key: string, query: string, table: string | {
|
|
8
|
+
table: string;
|
|
9
|
+
schema: string;
|
|
10
|
+
}, primaryKeys: string[], options?: {
|
|
11
|
+
filter?: string;
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
onChange?: (payload: RealtimePostgresChangesPayload<{
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>) => any;
|
|
16
|
+
}): "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR";
|
|
17
|
+
|
|
18
|
+
type ConfigurationOptions<T> = {
|
|
19
|
+
crossOrganization?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type FilterOperator = "or" | "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "like" | "ilike" | "is" | "in" | "cs" | "cd" | "fts" | "plfts";
|
|
22
|
+
type ValueType = number | string | boolean | null | Date | object;
|
|
23
|
+
type FilterDefinition = {
|
|
24
|
+
path: string;
|
|
25
|
+
alias?: string;
|
|
26
|
+
operator: FilterOperator;
|
|
27
|
+
negate: boolean;
|
|
28
|
+
value: ValueType;
|
|
29
|
+
};
|
|
30
|
+
type FilterDefinitions = (FilterComposite | FilterDefinition)[];
|
|
31
|
+
type FilterComposite = {
|
|
32
|
+
or?: FilterDefinitions;
|
|
33
|
+
and?: FilterDefinitions;
|
|
34
|
+
};
|
|
35
|
+
type UseRealtimeQueryResult<T> = UseDbQuerySingleReturn<T> & {
|
|
36
|
+
realtimeStatus: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR" | "Loading...";
|
|
37
|
+
isRealtimeConnected: boolean;
|
|
38
|
+
isRealtimeLoading: boolean;
|
|
39
|
+
};
|
|
40
|
+
type DataType = Record<string, any>;
|
|
41
|
+
declare function convertFilterToRealtimeQuery(filters: FilterDefinitions): string;
|
|
42
|
+
declare function useRealtimeQuery<Result extends DataType>(query: PromiseLike<PostgrestSingleResponse<Result>>, config?: Omit<UseQueryOptions<PostgrestSingleResponse<Result>>, "queryKey" | "queryFn"> & ConfigurationOptions<Result>, primaryKeys?: (keyof ItemType<Result> & string)[]): UseRealtimeQueryResult<Result>;
|
|
43
|
+
|
|
44
|
+
export { type UseRealtimeQueryResult, convertFilterToRealtimeQuery, useRealtimeQuery as useDbRealtimeQuery, useRealtime, useRealtimeQuery };
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { j as GenericSchema, k as Prettify } from './types-CYr9JiUE.js';
|
|
2
|
+
|
|
3
|
+
type Whitespace = ' ' | '\n' | '\t';
|
|
4
|
+
type LowerAlphabet = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
5
|
+
type Alphabet = LowerAlphabet | Uppercase<LowerAlphabet>;
|
|
6
|
+
type Digit = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '0';
|
|
7
|
+
type Letter = Alphabet | Digit | '_';
|
|
8
|
+
type Json = string | number | boolean | null | {
|
|
9
|
+
[key: string]: Json;
|
|
10
|
+
} | Json[];
|
|
11
|
+
type SingleValuePostgreSQLTypes = 'bool' | 'int2' | 'int4' | 'int8' | 'float4' | 'float8' | 'numeric' | 'bytea' | 'bpchar' | 'varchar' | 'date' | 'text' | 'citext' | 'time' | 'timetz' | 'timestamp' | 'timestamptz' | 'uuid' | 'vector' | 'json' | 'jsonb' | 'void' | 'record' | string;
|
|
12
|
+
type ArrayPostgreSQLTypes = `_${SingleValuePostgreSQLTypes}`;
|
|
13
|
+
type PostgreSQLTypes = SingleValuePostgreSQLTypes | ArrayPostgreSQLTypes;
|
|
14
|
+
type TypeScriptSingleValueTypes<T extends SingleValuePostgreSQLTypes> = T extends 'bool' ? boolean : T extends 'int2' | 'int4' | 'int8' | 'float4' | 'float8' | 'numeric' ? number : T extends 'bytea' | 'bpchar' | 'varchar' | 'date' | 'text' | 'citext' | 'time' | 'timetz' | 'timestamp' | 'timestamptz' | 'uuid' | 'vector' ? string : T extends 'json' | 'jsonb' ? Json : T extends 'void' ? undefined : T extends 'record' ? Record<string, unknown> : unknown;
|
|
15
|
+
type AggregateFunctions = 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
16
|
+
type StripUnderscore<T extends string> = T extends `_${infer U}` ? U : T;
|
|
17
|
+
type TypeScriptTypes<T extends PostgreSQLTypes> = T extends ArrayPostgreSQLTypes ? TypeScriptSingleValueTypes<StripUnderscore<Extract<T, SingleValuePostgreSQLTypes>>>[] : TypeScriptSingleValueTypes<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Parser errors.
|
|
20
|
+
*/
|
|
21
|
+
type ParserError<Message extends string> = {
|
|
22
|
+
error: true;
|
|
23
|
+
} & Message;
|
|
24
|
+
type GenericStringError = ParserError<'Received a generic string'>;
|
|
25
|
+
type SelectQueryError<Message extends string> = {
|
|
26
|
+
error: true;
|
|
27
|
+
} & Message;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new {@link ParserError} if the given input is not already a parser error.
|
|
30
|
+
*/
|
|
31
|
+
type CreateParserErrorIfRequired<Input, Message extends string> = Input extends ParserError<string> ? Input : ParserError<Message>;
|
|
32
|
+
/**
|
|
33
|
+
* Trims whitespace from the left of the input.
|
|
34
|
+
*/
|
|
35
|
+
type EatWhitespace<Input extends string> = string extends Input ? GenericStringError : Input extends `${Whitespace}${infer Remainder}` ? EatWhitespace<Remainder> : Input;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a boolean representing whether there is a foreign key with the given name.
|
|
38
|
+
*/
|
|
39
|
+
type HasFKey<FKeyName, Relationships> = Relationships extends [infer R] ? R extends {
|
|
40
|
+
foreignKeyName: FKeyName;
|
|
41
|
+
} ? true : false : Relationships extends [infer R, ...infer Rest] ? HasFKey<FKeyName, [R]> extends true ? true : HasFKey<FKeyName, Rest> : false;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a boolean representing whether there the foreign key has a unique constraint.
|
|
44
|
+
*/
|
|
45
|
+
type HasUniqueFKey<FKeyName, Relationships> = Relationships extends [infer R] ? R extends {
|
|
46
|
+
foreignKeyName: FKeyName;
|
|
47
|
+
isOneToOne: true;
|
|
48
|
+
} ? true : false : Relationships extends [infer R, ...infer Rest] ? HasUniqueFKey<FKeyName, [R]> extends true ? true : HasUniqueFKey<FKeyName, Rest> : false;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a boolean representing whether there is a foreign key referencing
|
|
51
|
+
* a given relation.
|
|
52
|
+
*/
|
|
53
|
+
type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R] ? R extends {
|
|
54
|
+
referencedRelation: FRelName;
|
|
55
|
+
} ? true : false : Relationships extends [infer R, ...infer Rest] ? HasFKeyToFRel<FRelName, [R]> extends true ? true : HasFKeyToFRel<FRelName, Rest> : false;
|
|
56
|
+
type HasUniqueFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R] ? R extends {
|
|
57
|
+
referencedRelation: FRelName;
|
|
58
|
+
isOneToOne: true;
|
|
59
|
+
} ? true : false : Relationships extends [infer R, ...infer Rest] ? HasUniqueFKeyToFRel<FRelName, [R]> extends true ? true : HasUniqueFKeyToFRel<FRelName, Rest> : false;
|
|
60
|
+
/**
|
|
61
|
+
* Constructs a type definition for a single field of an object.
|
|
62
|
+
*
|
|
63
|
+
* @param Schema Database schema.
|
|
64
|
+
* @param Row Type of a row in the given table.
|
|
65
|
+
* @param Relationships Relationships between different tables in the database.
|
|
66
|
+
* @param Field Single field parsed by `ParseQuery`.
|
|
67
|
+
*/
|
|
68
|
+
type ConstructFieldDefinition<Schema extends GenericSchema, Row extends Record<string, unknown>, RelationName, Relationships, Field> = Field extends {
|
|
69
|
+
star: true;
|
|
70
|
+
} ? Row : Field extends {
|
|
71
|
+
spread: true;
|
|
72
|
+
original: string;
|
|
73
|
+
children: unknown[];
|
|
74
|
+
} ? GetResultHelper<Schema, (Schema['Tables'] & Schema['Views'])[Field['original']]['Row'], Field['original'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
75
|
+
Relationships: infer R;
|
|
76
|
+
} ? R : unknown, Field['children'], unknown> : Field extends {
|
|
77
|
+
children: [];
|
|
78
|
+
} ? {} : Field extends {
|
|
79
|
+
name: string;
|
|
80
|
+
original: string;
|
|
81
|
+
hint: string;
|
|
82
|
+
children: unknown[];
|
|
83
|
+
} ? {
|
|
84
|
+
[_ in Field['name']]: GetResultHelper<Schema, (Schema['Tables'] & Schema['Views'])[Field['original']]['Row'], Field['original'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
85
|
+
Relationships: infer R;
|
|
86
|
+
} ? R : unknown, Field['children'], unknown> extends infer Child ? HasUniqueFKey<Field['hint'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
87
|
+
Relationships: infer R;
|
|
88
|
+
} ? R : unknown> extends true ? Field extends {
|
|
89
|
+
inner: true;
|
|
90
|
+
} ? Child : Child | null : Relationships extends unknown[] ? HasFKey<Field['hint'], Relationships> extends true ? Field extends {
|
|
91
|
+
inner: true;
|
|
92
|
+
} ? Child : Child | null : Child[] : Child[] : never;
|
|
93
|
+
} : Field extends {
|
|
94
|
+
name: string;
|
|
95
|
+
original: string;
|
|
96
|
+
children: unknown[];
|
|
97
|
+
} ? {
|
|
98
|
+
[_ in Field['name']]: GetResultHelper<Schema, (Schema['Tables'] & Schema['Views'])[Field['original']]['Row'], Field['original'], (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
99
|
+
Relationships: infer R;
|
|
100
|
+
} ? R : unknown, Field['children'], unknown> extends infer Child ? HasUniqueFKeyToFRel<RelationName, (Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
101
|
+
Relationships: infer R;
|
|
102
|
+
} ? R : unknown> extends true ? Field extends {
|
|
103
|
+
inner: true;
|
|
104
|
+
} ? Child : Child | null : Relationships extends unknown[] ? HasFKeyToFRel<Field['original'], Relationships> extends true ? Field extends {
|
|
105
|
+
inner: true;
|
|
106
|
+
} ? Child : Child | null : Child[] : Child[] : never;
|
|
107
|
+
} : Field extends {
|
|
108
|
+
name: string;
|
|
109
|
+
type: infer T;
|
|
110
|
+
} ? {
|
|
111
|
+
[K in Field['name']]: T;
|
|
112
|
+
} : Field extends {
|
|
113
|
+
name: string;
|
|
114
|
+
original: string;
|
|
115
|
+
} ? Field['original'] extends keyof Row ? {
|
|
116
|
+
[K in Field['name']]: Row[Field['original']];
|
|
117
|
+
} : Field['original'] extends 'count' ? {
|
|
118
|
+
count: number;
|
|
119
|
+
} : SelectQueryError<`Referencing missing column \`${Field['original']}\``> : Record<string, unknown>;
|
|
120
|
+
/**
|
|
121
|
+
* Notes: all `Parse*` types assume that their input strings have their whitespace
|
|
122
|
+
* removed. They return tuples of ["Return Value", "Remainder of text"] or
|
|
123
|
+
* a `ParserError`.
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Reads a consecutive sequence of 1 or more letter, where letters are `[0-9a-zA-Z_]`.
|
|
127
|
+
*/
|
|
128
|
+
type ReadLetters<Input extends string> = string extends Input ? GenericStringError : ReadLettersHelper<Input, ''> extends [`${infer Letters}`, `${infer Remainder}`] ? Letters extends '' ? ParserError<`Expected letter at \`${Input}\``> : [Letters, Remainder] : ReadLettersHelper<Input, ''>;
|
|
129
|
+
type ReadLettersHelper<Input extends string, Acc extends string> = string extends Input ? GenericStringError : Input extends `${infer L}${infer Remainder}` ? L extends Letter ? ReadLettersHelper<Remainder, `${Acc}${L}`> : [Acc, Input] : [Acc, ''];
|
|
130
|
+
/**
|
|
131
|
+
* Reads a consecutive sequence of 1 or more double-quoted letters,
|
|
132
|
+
* where letters are `[^"]`.
|
|
133
|
+
*/
|
|
134
|
+
type ReadQuotedLetters<Input extends string> = string extends Input ? GenericStringError : Input extends `"${infer Remainder}` ? ReadQuotedLettersHelper<Remainder, ''> extends [`${infer Letters}`, `${infer Remainder}`] ? Letters extends '' ? ParserError<`Expected string at \`${Remainder}\``> : [Letters, Remainder] : ReadQuotedLettersHelper<Remainder, ''> : ParserError<`Not a double-quoted string at \`${Input}\``>;
|
|
135
|
+
type ReadQuotedLettersHelper<Input extends string, Acc extends string> = string extends Input ? GenericStringError : Input extends `${infer L}${infer Remainder}` ? L extends '"' ? [Acc, Remainder] : ReadQuotedLettersHelper<Remainder, `${Acc}${L}`> : ParserError<`Missing closing double-quote in \`"${Acc}${Input}\``>;
|
|
136
|
+
/**
|
|
137
|
+
* Parses a (possibly double-quoted) identifier.
|
|
138
|
+
* Identifiers are sequences of 1 or more letters.
|
|
139
|
+
*/
|
|
140
|
+
type ParseIdentifier<Input extends string> = ReadLetters<Input> extends [
|
|
141
|
+
infer Name,
|
|
142
|
+
`${infer Remainder}`
|
|
143
|
+
] ? [Name, `${Remainder}`] : ReadQuotedLetters<Input> extends [infer Name, `${infer Remainder}`] ? [Name, `${Remainder}`] : ParserError<`No (possibly double-quoted) identifier at \`${Input}\``>;
|
|
144
|
+
/**
|
|
145
|
+
* Parses a field without preceding field renaming.
|
|
146
|
+
* A field is one of the following:
|
|
147
|
+
* - a field with an embedded resource
|
|
148
|
+
* - `field(nodes)`
|
|
149
|
+
* - `field!hint(nodes)`
|
|
150
|
+
* - `field!inner(nodes)`
|
|
151
|
+
* - `field!hint!inner(nodes)`
|
|
152
|
+
* - a field without an embedded resource (see {@link ParseFieldWithoutEmbeddedResource})
|
|
153
|
+
*/
|
|
154
|
+
type ParseField<Input extends string> = Input extends '' ? ParserError<'Empty string'> : ParseIdentifier<Input> extends [infer Name, `${infer Remainder}`] ? EatWhitespace<Remainder> extends `!inner${infer Remainder}` ? ParseEmbeddedResource<EatWhitespace<Remainder>> extends [infer Fields, `${infer Remainder}`] ? [
|
|
155
|
+
{
|
|
156
|
+
name: Name;
|
|
157
|
+
original: Name;
|
|
158
|
+
children: Fields;
|
|
159
|
+
inner: true;
|
|
160
|
+
},
|
|
161
|
+
EatWhitespace<Remainder>
|
|
162
|
+
] : CreateParserErrorIfRequired<ParseEmbeddedResource<EatWhitespace<Remainder>>, 'Expected embedded resource after `!inner`'> : EatWhitespace<Remainder> extends `!${infer Remainder}` ? ParseIdentifier<EatWhitespace<Remainder>> extends [infer Hint, `${infer Remainder}`] ? EatWhitespace<Remainder> extends `!inner${infer Remainder}` ? ParseEmbeddedResource<EatWhitespace<Remainder>> extends [
|
|
163
|
+
infer Fields,
|
|
164
|
+
`${infer Remainder}`
|
|
165
|
+
] ? [
|
|
166
|
+
{
|
|
167
|
+
name: Name;
|
|
168
|
+
original: Name;
|
|
169
|
+
hint: Hint;
|
|
170
|
+
children: Fields;
|
|
171
|
+
inner: true;
|
|
172
|
+
},
|
|
173
|
+
EatWhitespace<Remainder>
|
|
174
|
+
] : CreateParserErrorIfRequired<ParseEmbeddedResource<EatWhitespace<Remainder>>, 'Expected embedded resource after `!inner`'> : ParseEmbeddedResource<EatWhitespace<Remainder>> extends [
|
|
175
|
+
infer Fields,
|
|
176
|
+
`${infer Remainder}`
|
|
177
|
+
] ? [
|
|
178
|
+
{
|
|
179
|
+
name: Name;
|
|
180
|
+
original: Name;
|
|
181
|
+
hint: Hint;
|
|
182
|
+
children: Fields;
|
|
183
|
+
},
|
|
184
|
+
EatWhitespace<Remainder>
|
|
185
|
+
] : CreateParserErrorIfRequired<ParseEmbeddedResource<EatWhitespace<Remainder>>, 'Expected embedded resource after `!hint`'> : ParserError<'Expected identifier after `!`'> : ParseEmbeddedResource<EatWhitespace<Remainder>> extends [infer Fields, `${infer Remainder}`] ? [
|
|
186
|
+
{
|
|
187
|
+
name: Name;
|
|
188
|
+
original: Name;
|
|
189
|
+
children: Fields;
|
|
190
|
+
},
|
|
191
|
+
EatWhitespace<Remainder>
|
|
192
|
+
] : ParseEmbeddedResource<EatWhitespace<Remainder>> extends ParserError<string> ? ParseEmbeddedResource<EatWhitespace<Remainder>> : ParseFieldWithoutEmbeddedResource<Input> : ParserError<`Expected identifier at \`${Input}\``>;
|
|
193
|
+
/**
|
|
194
|
+
* Parses a field excluding embedded resources, without preceding field renaming.
|
|
195
|
+
* This is one of the following:
|
|
196
|
+
* - `field`
|
|
197
|
+
* - `field.aggregate()`
|
|
198
|
+
* - `field.aggregate()::type`
|
|
199
|
+
* - `field::type`
|
|
200
|
+
* - `field::type.aggregate()`
|
|
201
|
+
* - `field::type.aggregate()::type`
|
|
202
|
+
* - `field->json...`
|
|
203
|
+
* - `field->json.aggregate()`
|
|
204
|
+
* - `field->json.aggregate()::type`
|
|
205
|
+
* - `field->json::type`
|
|
206
|
+
* - `field->json::type.aggregate()`
|
|
207
|
+
* - `field->json::type.aggregate()::type`
|
|
208
|
+
*/
|
|
209
|
+
type ParseFieldWithoutEmbeddedResource<Input extends string> = ParseFieldWithoutEmbeddedResourceAndAggregation<Input> extends [infer Field, `${infer Remainder}`] ? ParseFieldAggregation<EatWhitespace<Remainder>> extends [
|
|
210
|
+
`${infer AggregateFunction}`,
|
|
211
|
+
`${infer Remainder}`
|
|
212
|
+
] ? ParseFieldTypeCast<EatWhitespace<Remainder>> extends [infer Type, `${infer Remainder}`] ? [
|
|
213
|
+
Omit<Field, 'name' | 'original' | 'type'> & {
|
|
214
|
+
name: AggregateFunction;
|
|
215
|
+
original: AggregateFunction;
|
|
216
|
+
type: Type;
|
|
217
|
+
},
|
|
218
|
+
EatWhitespace<Remainder>
|
|
219
|
+
] : ParseFieldTypeCast<EatWhitespace<Remainder>> extends ParserError<string> ? ParseFieldTypeCast<EatWhitespace<Remainder>> : [
|
|
220
|
+
Omit<Field, 'name' | 'original'> & {
|
|
221
|
+
name: AggregateFunction;
|
|
222
|
+
original: AggregateFunction;
|
|
223
|
+
},
|
|
224
|
+
EatWhitespace<Remainder>
|
|
225
|
+
] : ParseFieldAggregation<EatWhitespace<Remainder>> extends ParserError<string> ? ParseFieldAggregation<EatWhitespace<Remainder>> : [
|
|
226
|
+
Field,
|
|
227
|
+
EatWhitespace<Remainder>
|
|
228
|
+
] : CreateParserErrorIfRequired<ParseFieldWithoutEmbeddedResourceAndAggregation<Input>, `Expected field at \`${Input}\``>;
|
|
229
|
+
/**
|
|
230
|
+
* Parses a field excluding embedded resources or aggregation, without preceding field renaming.
|
|
231
|
+
* This is one of the following:
|
|
232
|
+
* - `field`
|
|
233
|
+
* - `field::type`
|
|
234
|
+
* - `field->json...`
|
|
235
|
+
* - `field->json...::type`
|
|
236
|
+
*/
|
|
237
|
+
type ParseFieldWithoutEmbeddedResourceAndAggregation<Input extends string> = ParseFieldWithoutEmbeddedResourceAndTypeCast<Input> extends [infer Field, `${infer Remainder}`] ? ParseFieldTypeCast<EatWhitespace<Remainder>> extends [infer Type, `${infer Remainder}`] ? [
|
|
238
|
+
Omit<Field, 'type'> & {
|
|
239
|
+
type: Type;
|
|
240
|
+
},
|
|
241
|
+
EatWhitespace<Remainder>
|
|
242
|
+
] : ParseFieldTypeCast<EatWhitespace<Remainder>> extends ParserError<string> ? ParseFieldTypeCast<EatWhitespace<Remainder>> : [
|
|
243
|
+
Field,
|
|
244
|
+
EatWhitespace<Remainder>
|
|
245
|
+
] : CreateParserErrorIfRequired<ParseFieldWithoutEmbeddedResourceAndTypeCast<Input>, `Expected field at \`${Input}\``>;
|
|
246
|
+
/**
|
|
247
|
+
* Parses a field excluding embedded resources or typecasting, without preceding field renaming.
|
|
248
|
+
* This is one of the following:
|
|
249
|
+
* - `field`
|
|
250
|
+
* - `field->json...`
|
|
251
|
+
*/
|
|
252
|
+
type ParseFieldWithoutEmbeddedResourceAndTypeCast<Input extends string> = ParseIdentifier<Input> extends [infer Name, `${infer Remainder}`] ? ParseJsonAccessor<EatWhitespace<Remainder>> extends [
|
|
253
|
+
infer PropertyName,
|
|
254
|
+
infer PropertyType,
|
|
255
|
+
`${infer Remainder}`
|
|
256
|
+
] ? [
|
|
257
|
+
{
|
|
258
|
+
name: PropertyName;
|
|
259
|
+
original: PropertyName;
|
|
260
|
+
type: PropertyType;
|
|
261
|
+
},
|
|
262
|
+
EatWhitespace<Remainder>
|
|
263
|
+
] : [
|
|
264
|
+
{
|
|
265
|
+
name: Name;
|
|
266
|
+
original: Name;
|
|
267
|
+
},
|
|
268
|
+
EatWhitespace<Remainder>
|
|
269
|
+
] : ParserError<`Expected field at \`${Input}\``>;
|
|
270
|
+
/**
|
|
271
|
+
* Parses a field typecast (`::type`), returning a tuple of ["Type", "Remainder of text"]
|
|
272
|
+
* or the original string input indicating that no typecast was found.
|
|
273
|
+
*/
|
|
274
|
+
type ParseFieldTypeCast<Input extends string> = EatWhitespace<Input> extends `::${infer Remainder}` ? ParseIdentifier<EatWhitespace<Remainder>> extends [`${infer CastType}`, `${infer Remainder}`] ? CastType extends PostgreSQLTypes ? [TypeScriptTypes<CastType>, EatWhitespace<Remainder>] : ParserError<`Invalid type for \`::\` operator \`${CastType}\``> : ParserError<`Invalid type for \`::\` operator at \`${Remainder}\``> : Input;
|
|
275
|
+
/**
|
|
276
|
+
* Parses a field aggregation (`.max()`), returning a tuple of ["Aggregate function", "Remainder of text"]
|
|
277
|
+
* or the original string input indicating that no aggregation was found.
|
|
278
|
+
*/
|
|
279
|
+
type ParseFieldAggregation<Input extends string> = EatWhitespace<Input> extends `.${infer Remainder}` ? ParseIdentifier<EatWhitespace<Remainder>> extends [
|
|
280
|
+
`${infer FunctionName}`,
|
|
281
|
+
`${infer Remainder}`
|
|
282
|
+
] ? FunctionName extends AggregateFunctions ? EatWhitespace<Remainder> extends `()${infer Remainder}` ? [FunctionName, EatWhitespace<Remainder>] : ParserError<`Expected \`()\` after \`.\` operator \`${FunctionName}\``> : ParserError<`Invalid type for \`.\` operator \`${FunctionName}\``> : ParserError<`Invalid type for \`.\` operator at \`${Remainder}\``> : Input;
|
|
283
|
+
/**
|
|
284
|
+
* Parses a node.
|
|
285
|
+
* A node is one of the following:
|
|
286
|
+
* - `*`
|
|
287
|
+
* - a field, as defined above
|
|
288
|
+
* - a renamed field, `renamed_field:field`
|
|
289
|
+
* - a spread field, `...field`
|
|
290
|
+
*/
|
|
291
|
+
type ParseNode<Input extends string> = Input extends '' ? ParserError<'Empty string'> : Input extends `*${infer Remainder}` ? [{
|
|
292
|
+
star: true;
|
|
293
|
+
}, EatWhitespace<Remainder>] : Input extends `...${infer Remainder}` ? ParseField<EatWhitespace<Remainder>> extends [infer Field, `${infer Remainder}`] ? Field extends {
|
|
294
|
+
children: unknown[];
|
|
295
|
+
} ? [Prettify<{
|
|
296
|
+
spread: true;
|
|
297
|
+
} & Field>, EatWhitespace<Remainder>] : ParserError<'Unable to parse spread resource'> : ParserError<'Unable to parse spread resource'> : ParseIdentifier<Input> extends [infer Name, `${infer Remainder}`] ? EatWhitespace<Remainder> extends `::${infer _Remainder}` ? ParseField<Input> : EatWhitespace<Remainder> extends `:${infer Remainder}` ? ParseField<EatWhitespace<Remainder>> extends [infer Field, `${infer Remainder}`] ? Field extends {
|
|
298
|
+
name: string;
|
|
299
|
+
} ? [Prettify<Omit<Field, 'name'> & {
|
|
300
|
+
name: Name;
|
|
301
|
+
}>, EatWhitespace<Remainder>] : ParserError<`Unable to parse renamed field`> : ParserError<`Unable to parse renamed field`> : ParseField<Input> : ParserError<`Expected identifier at \`${Input}\``>;
|
|
302
|
+
/**
|
|
303
|
+
* Parses a JSON property accessor of the shape `->a->b->c`. The last accessor in
|
|
304
|
+
* the series may convert to text by using the ->> operator instead of ->.
|
|
305
|
+
*
|
|
306
|
+
* Returns a tuple of ["Last property name", "Last property type", "Remainder of text"]
|
|
307
|
+
* or the original string input indicating that no opening `->` was found.
|
|
308
|
+
*/
|
|
309
|
+
type ParseJsonAccessor<Input extends string> = Input extends `->${infer Remainder}` ? Remainder extends `>${infer Remainder}` ? ParseIdentifier<Remainder> extends [infer Name, `${infer Remainder}`] ? [Name, string, EatWhitespace<Remainder>] : ParserError<'Expected property name after `->>`'> : ParseIdentifier<Remainder> extends [infer Name, `${infer Remainder}`] ? ParseJsonAccessor<Remainder> extends [
|
|
310
|
+
infer PropertyName,
|
|
311
|
+
infer PropertyType,
|
|
312
|
+
`${infer Remainder}`
|
|
313
|
+
] ? [PropertyName, PropertyType, EatWhitespace<Remainder>] : [Name, Json, EatWhitespace<Remainder>] : ParserError<'Expected property name after `->`'> : Input;
|
|
314
|
+
/**
|
|
315
|
+
* Parses an embedded resource, which is an opening `(`, followed by a sequence of
|
|
316
|
+
* 0 or more nodes separated by `,`, then a closing `)`.
|
|
317
|
+
*
|
|
318
|
+
* Returns a tuple of ["Parsed fields", "Remainder of text"], an error,
|
|
319
|
+
* or the original string input indicating that no opening `(` was found.
|
|
320
|
+
*/
|
|
321
|
+
type ParseEmbeddedResource<Input extends string> = Input extends `(${infer Remainder}` ? ParseNodes<EatWhitespace<Remainder>> extends [infer Fields, `${infer Remainder}`] ? EatWhitespace<Remainder> extends `)${infer Remainder}` ? [Fields, EatWhitespace<Remainder>] : ParserError<`Expected ")"`> : ParseNodes<EatWhitespace<Remainder>> extends ParserError<string> ? EatWhitespace<Remainder> extends `)${infer Remainder}` ? [[], EatWhitespace<Remainder>] : ParseNodes<EatWhitespace<Remainder>> : ParserError<'Expected embedded resource fields or `)`'> : Input;
|
|
322
|
+
/**
|
|
323
|
+
* Parses a sequence of nodes, separated by `,`.
|
|
324
|
+
*
|
|
325
|
+
* Returns a tuple of ["Parsed fields", "Remainder of text"] or an error.
|
|
326
|
+
*/
|
|
327
|
+
type ParseNodes<Input extends string> = string extends Input ? GenericStringError : ParseNodesHelper<Input, []>;
|
|
328
|
+
type ParseNodesHelper<Input extends string, Fields extends unknown[]> = ParseNode<Input> extends [
|
|
329
|
+
infer Field,
|
|
330
|
+
`${infer Remainder}`
|
|
331
|
+
] ? EatWhitespace<Remainder> extends `,${infer Remainder}` ? ParseNodesHelper<EatWhitespace<Remainder>, [Field, ...Fields]> : [[Field, ...Fields], EatWhitespace<Remainder>] : ParseNode<Input>;
|
|
332
|
+
/**
|
|
333
|
+
* Parses a query.
|
|
334
|
+
* A query is a sequence of nodes, separated by `,`, ensuring that there is
|
|
335
|
+
* no remaining input after all nodes have been parsed.
|
|
336
|
+
*
|
|
337
|
+
* Returns an array of parsed nodes, or an error.
|
|
338
|
+
*/
|
|
339
|
+
type ParseQuery<Query extends string> = string extends Query ? GenericStringError : ParseNodes<EatWhitespace<Query>> extends [infer Fields, `${infer Remainder}`] ? EatWhitespace<Remainder> extends '' ? Fields : ParserError<`Unexpected input: ${Remainder}`> : ParseNodes<EatWhitespace<Query>>;
|
|
340
|
+
type GetResultHelper<Schema extends GenericSchema, Row extends Record<string, unknown>, RelationName, Relationships, Fields extends unknown[], Acc> = Fields extends [infer R] ? ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> extends SelectQueryError<infer E> ? SelectQueryError<E> : GetResultHelper<Schema, Row, RelationName, Relationships, [
|
|
341
|
+
], ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> & Acc> : Fields extends [infer R, ...infer Rest] ? ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> extends SelectQueryError<infer E> ? SelectQueryError<E> : GetResultHelper<Schema, Row, RelationName, Relationships, Rest, ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> & Acc> : Prettify<Acc>;
|
|
342
|
+
/**
|
|
343
|
+
* Constructs a type definition for an object based on a given PostgREST query.
|
|
344
|
+
*
|
|
345
|
+
* @param Schema Database schema.
|
|
346
|
+
* @param Row Type of a row in the given table.
|
|
347
|
+
* @param Relationships Relationships between different tables in the database.
|
|
348
|
+
* @param Query Select query string literal to parse.
|
|
349
|
+
*/
|
|
350
|
+
type GetResult<Schema extends GenericSchema, Row extends Record<string, unknown>, RelationName, Relationships, Query extends string> = ParseQuery<Query> extends unknown[] ? GetResultHelper<Schema, Row, RelationName, Relationships, ParseQuery<Query>, unknown> : ParseQuery<Query>;
|
|
351
|
+
|
|
352
|
+
export type { GetResult as G, SelectQueryError as S };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { User, SignUpWithPasswordCredentials, AuthTokenResponsePassword } from '@supabase/supabase-js';
|
|
5
|
+
|
|
6
|
+
type ProfileStatus = "active" | "archived" | "suspended";
|
|
7
|
+
interface SetupAuthContext {
|
|
8
|
+
user?: User | null | undefined;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
profile: Profile | null | undefined;
|
|
11
|
+
access: string[];
|
|
12
|
+
/** Whether the profile is archived */
|
|
13
|
+
isArchived: boolean;
|
|
14
|
+
/** Whether the profile is suspended */
|
|
15
|
+
isSuspended: boolean;
|
|
16
|
+
/** The profile status (active, archived, suspended) */
|
|
17
|
+
profileStatus: ProfileStatus | undefined;
|
|
18
|
+
registerAsync: (register: SignUpWithPasswordCredentials) => Promise<any>;
|
|
19
|
+
signInAsync: (username: string, password: string) => Promise<AuthTokenResponsePassword>;
|
|
20
|
+
signOutAsync: () => Promise<any>;
|
|
21
|
+
refreshAsync: () => Promise<void>;
|
|
22
|
+
onSignOut: (action: () => any) => string;
|
|
23
|
+
removeOnSignOut: (id: string) => any;
|
|
24
|
+
hasAccess?: (key: string) => boolean;
|
|
25
|
+
}
|
|
26
|
+
interface Profile {
|
|
27
|
+
id: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
fullName?: string;
|
|
30
|
+
status?: ProfileStatus;
|
|
31
|
+
UserAccess?: Array<{
|
|
32
|
+
accessKey: string;
|
|
33
|
+
}>;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
declare const setupAuthContext: react.Context<SetupAuthContext>;
|
|
37
|
+
/**
|
|
38
|
+
* Props for SetupAuthContextProvider
|
|
39
|
+
* A simpler provider that takes pre-computed auth state
|
|
40
|
+
*/
|
|
41
|
+
interface SetupAuthContextProviderProps {
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
auth: SetupAuthContext;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Simple provider that takes auth state and provides it via context.
|
|
47
|
+
* Use this when you already have the auth state and just need to provide it to children.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const auth = useSetupAuth();
|
|
52
|
+
* return (
|
|
53
|
+
* <SetupAuthContextProvider auth={auth}>
|
|
54
|
+
* <MyComponent />
|
|
55
|
+
* </SetupAuthContextProvider>
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function SetupAuthContextProvider({ children, auth, }: SetupAuthContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
|
|
61
|
+
export { type ProfileStatus as P, SetupAuthContextProvider as S, type SetupAuthContext as a, type SetupAuthContextProviderProps as b, type Profile as c, setupAuthContext as s };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { a as FilterConfig, F as FilterConfigOption, G as Group, P as PropertyType, S as SortConfig, T as TableInfo, V as ValueForPropertyType, b as WhereClause, W as WhereFilter } from '../FilterConfig-Bt2Ek74z.js';
|
|
2
|
+
export { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, a as EnhancedSyncControl, E as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus } from '../index-BNKhgDdC.js';
|
|
3
|
+
export { D as Database } from '../database.types-ChFCG-4M.js';
|
|
4
|
+
import 'moment';
|
|
5
|
+
import '@supabase/supabase-js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '@tanstack/react-query';
|
|
8
|
+
import '../core/index.js';
|
|
9
|
+
import '../DataLayerContext-ZmLPYR_s.js';
|
|
10
|
+
import '../executor-CB4KHyYG.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
type Fetch = typeof fetch;
|
|
2
|
+
/**
|
|
3
|
+
* Error format
|
|
4
|
+
*
|
|
5
|
+
* {@link https://postgrest.org/en/stable/api.html?highlight=options#errors-and-http-status-codes}
|
|
6
|
+
*/
|
|
7
|
+
type PostgrestError = {
|
|
8
|
+
message: string;
|
|
9
|
+
details: string;
|
|
10
|
+
hint: string;
|
|
11
|
+
code: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Response format
|
|
15
|
+
*
|
|
16
|
+
* {@link https://github.com/supabase/supabase-js/issues/32}
|
|
17
|
+
*/
|
|
18
|
+
interface PostgrestResponseBase {
|
|
19
|
+
status: number;
|
|
20
|
+
statusText: string;
|
|
21
|
+
}
|
|
22
|
+
interface PostgrestResponseSuccess<T> extends PostgrestResponseBase {
|
|
23
|
+
error: null;
|
|
24
|
+
data: T;
|
|
25
|
+
count: number | null;
|
|
26
|
+
}
|
|
27
|
+
interface PostgrestResponseFailure extends PostgrestResponseBase {
|
|
28
|
+
error: PostgrestError;
|
|
29
|
+
data: null;
|
|
30
|
+
count: null;
|
|
31
|
+
}
|
|
32
|
+
type PostgrestSingleResponse<T> = PostgrestResponseSuccess<T> | PostgrestResponseFailure;
|
|
33
|
+
type PostgrestMaybeSingleResponse<T> = PostgrestSingleResponse<T | null>;
|
|
34
|
+
type PostgrestResponse<T> = PostgrestSingleResponse<T[]>;
|
|
35
|
+
type GenericTable = {
|
|
36
|
+
Row: Record<string, unknown>;
|
|
37
|
+
Insert: Record<string, unknown>;
|
|
38
|
+
Update: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
type GenericUpdatableView = {
|
|
41
|
+
Row: Record<string, unknown>;
|
|
42
|
+
Insert: Record<string, unknown>;
|
|
43
|
+
Update: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
type GenericNonUpdatableView = {
|
|
46
|
+
Row: Record<string, unknown>;
|
|
47
|
+
};
|
|
48
|
+
type GenericView = GenericUpdatableView | GenericNonUpdatableView;
|
|
49
|
+
type GenericFunction = {
|
|
50
|
+
Args: Record<string, unknown>;
|
|
51
|
+
Returns: unknown;
|
|
52
|
+
};
|
|
53
|
+
type GenericSchema = {
|
|
54
|
+
Tables: Record<string, GenericTable>;
|
|
55
|
+
Views: Record<string, GenericView>;
|
|
56
|
+
Functions: Record<string, GenericFunction>;
|
|
57
|
+
};
|
|
58
|
+
type Prettify<T> = {
|
|
59
|
+
[K in keyof T]: T[K];
|
|
60
|
+
} & {};
|
|
61
|
+
|
|
62
|
+
export type { Fetch as F, GenericTable as G, PostgrestError as P, PostgrestResponseSuccess as a, PostgrestResponseFailure as b, PostgrestSingleResponse as c, PostgrestMaybeSingleResponse as d, PostgrestResponse as e, GenericUpdatableView as f, GenericNonUpdatableView as g, GenericView as h, GenericFunction as i, GenericSchema as j, Prettify as k };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { D as Database } from './useSupabase-DvWVuHHE.js';
|
|
3
|
+
import { G as GetResult } from './select-query-parser-BwyHum1L.js';
|
|
4
|
+
import { j as GenericSchema } from './types-CYr9JiUE.js';
|
|
5
|
+
|
|
6
|
+
type ItemType$1<T> = T extends Array<infer U> ? U : T;
|
|
7
|
+
declare function useBatchDelete<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
|
|
8
|
+
Relationships: infer R;
|
|
9
|
+
} ? R : unknown, RowResult extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, Query>, "id">>(relation: TableName | {
|
|
10
|
+
table: TableName;
|
|
11
|
+
schema: Schema;
|
|
12
|
+
}, primaryKeys?: (keyof ItemType$1<RowResult> & string)[]): _tanstack_react_query.UseMutationResult<RowResult, Error, RowResult | RowResult[], unknown>;
|
|
13
|
+
|
|
14
|
+
type ItemType<T> = T extends Array<infer U> ? U : T;
|
|
15
|
+
declare function useBatchUpsert<TableName extends string & keyof PublicSchema["Tables"], Table extends PublicSchema["Tables"][TableName], Schema extends keyof Database = "public", PublicSchema extends GenericSchema = Database[Extract<keyof Database, Schema>], Query extends string = "*", RelationName = unknown, Relationships = Table extends {
|
|
16
|
+
Relationships: infer R;
|
|
17
|
+
} ? R : unknown, RowResult extends object = GetResult<PublicSchema, Table["Row"], RelationName, Relationships, Query>, ResultInsert extends object = GetResult<PublicSchema, Table["Insert"], RelationName, Relationships, Query>, ResultUpdate extends object = Omit<GetResult<PublicSchema, Table["Update"], RelationName, Relationships, Query>, "id"> & {
|
|
18
|
+
id: any;
|
|
19
|
+
}>(relation: TableName | {
|
|
20
|
+
table: TableName;
|
|
21
|
+
schema: Schema;
|
|
22
|
+
}, primaryKeys?: (keyof (ItemType<RowResult> | any) & string)[], query?: string): _tanstack_react_query.UseMutationResult<RowResult[], Error, (ResultInsert | ResultUpdate)[], unknown>;
|
|
23
|
+
|
|
24
|
+
export { useBatchUpsert as a, useBatchDelete as u };
|