@freehour/supabase-core 1.2.1 → 1.3.0
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/data-service.d.ts +21 -21
- package/dist/embedding-service.d.ts +1 -1
- package/dist/embedding-service.d.ts.map +1 -1
- package/dist/filter.d.ts +2 -2
- package/dist/filter.d.ts.map +1 -1
- package/dist/index.js +106 -100
- package/dist/postgrest-extensions.d.ts +26 -26
- package/dist/postgrest-extensions.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/data-service.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DatabaseService } from './database-service';
|
|
|
6
6
|
import { ColumnName, ID, Insert, RelationName, RelationType, Row, SchemaName, TableName, Update, ViewName } from './relation';
|
|
7
7
|
import { Select, SelectColumns, SelectOptions, CountMethod } from './select';
|
|
8
8
|
import { OmitFrom } from './utils';
|
|
9
|
-
import {
|
|
9
|
+
import { FilterNode } from './filter';
|
|
10
10
|
import { PaginatedList } from './postgrest-extensions';
|
|
11
11
|
export interface DataServiceParams<Database extends CoreDatabase, Schema extends SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
|
|
12
12
|
/**
|
|
@@ -52,7 +52,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
52
52
|
* @example
|
|
53
53
|
* const { data, error } = await dataService.query.select('*');
|
|
54
54
|
*/
|
|
55
|
-
get query(): PostgrestQueryBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T ? T extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
55
|
+
get query(): OmitFrom< PostgrestQueryBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T ? T extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
56
56
|
__InternalSupabase: {
|
|
57
57
|
PostgrestVersion: string;
|
|
58
58
|
};
|
|
@@ -242,7 +242,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
242
242
|
}>;
|
|
243
243
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_1 extends {
|
|
244
244
|
Relationships: infer R;
|
|
245
|
-
} ? R : unknown : never : never> & {
|
|
245
|
+
} ? R : unknown : never : never>, "select" | "delete"> & {
|
|
246
246
|
select: <Columns extends SelectColumns<(Database[Schema] extends {
|
|
247
247
|
Tables: Record<string, {
|
|
248
248
|
Row: Record<string, unknown>;
|
|
@@ -288,7 +288,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
288
288
|
from: string;
|
|
289
289
|
};
|
|
290
290
|
}>;
|
|
291
|
-
} ? Database[Schema] : any)["Tables"][Relation]["Row"]>>(columns: Columns, options?: SelectOptions) => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
291
|
+
} ? Database[Schema] : any)["Tables"][Relation]["Row"]>>(columns: Columns, options?: SelectOptions) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
292
292
|
__InternalSupabase: {
|
|
293
293
|
PostgrestVersion: string;
|
|
294
294
|
};
|
|
@@ -523,8 +523,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
523
523
|
}>;
|
|
524
524
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_3 extends {
|
|
525
525
|
Relationships: infer R;
|
|
526
|
-
} ? R : unknown : never : never, "GET"> & {
|
|
527
|
-
|
|
526
|
+
} ? R : unknown : never : never, "GET">, "filter"> & {
|
|
527
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
528
528
|
__InternalSupabase: {
|
|
529
529
|
PostgrestVersion: string;
|
|
530
530
|
};
|
|
@@ -759,8 +759,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
759
759
|
}>;
|
|
760
760
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_5 extends {
|
|
761
761
|
Relationships: infer R;
|
|
762
|
-
} ? R : unknown : never : never, "GET"> & /*elided*/ any;
|
|
763
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
762
|
+
} ? R : unknown : never : never, "GET">, "filter"> & /*elided*/ any;
|
|
763
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
764
764
|
__InternalSupabase: {
|
|
765
765
|
PostgrestVersion: string;
|
|
766
766
|
};
|
|
@@ -995,7 +995,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
995
995
|
}>;
|
|
996
996
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_5 extends {
|
|
997
997
|
Relationships: infer R;
|
|
998
|
-
} ? R : unknown : never : never, "GET"> & /*elided*/ any;
|
|
998
|
+
} ? R : unknown : never : never, "GET">, "filter"> & /*elided*/ any;
|
|
999
999
|
collect: () => PromiseLike< PaginatedList<Select<(Database[Schema] extends {
|
|
1000
1000
|
Tables: Record<string, {
|
|
1001
1001
|
Row: Record<string, unknown>;
|
|
@@ -1043,7 +1043,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
1043
1043
|
}>;
|
|
1044
1044
|
} ? Database[Schema] : any)["Tables"][Relation]["Row"], Columns>>>;
|
|
1045
1045
|
};
|
|
1046
|
-
count: (method?: CountMethod) => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
1046
|
+
count: (method?: CountMethod) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
1047
1047
|
__InternalSupabase: {
|
|
1048
1048
|
PostgrestVersion: string;
|
|
1049
1049
|
};
|
|
@@ -1423,8 +1423,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
1423
1423
|
}>;
|
|
1424
1424
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_5 extends {
|
|
1425
1425
|
Relationships: infer R;
|
|
1426
|
-
} ? R : unknown : never : never, "GET"> & {
|
|
1427
|
-
|
|
1426
|
+
} ? R : unknown : never : never, "GET">, "filter"> & {
|
|
1427
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_6 ? T_6 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_6 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
1428
1428
|
__InternalSupabase: {
|
|
1429
1429
|
PostgrestVersion: string;
|
|
1430
1430
|
};
|
|
@@ -1804,8 +1804,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
1804
1804
|
}>;
|
|
1805
1805
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_9 extends {
|
|
1806
1806
|
Relationships: infer R;
|
|
1807
|
-
} ? R : unknown : never : never, "GET"> & /*elided*/ any;
|
|
1808
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_6 ? T_6 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_6 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
1807
|
+
} ? R : unknown : never : never, "GET">, "filter"> & /*elided*/ any;
|
|
1808
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_6 ? T_6 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_6 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
1809
1809
|
__InternalSupabase: {
|
|
1810
1810
|
PostgrestVersion: string;
|
|
1811
1811
|
};
|
|
@@ -2185,7 +2185,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
2185
2185
|
}>;
|
|
2186
2186
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_9 extends {
|
|
2187
2187
|
Relationships: infer R;
|
|
2188
|
-
} ? R : unknown : never : never, "GET"> & /*elided*/ any;
|
|
2188
|
+
} ? R : unknown : never : never, "GET">, "filter"> & /*elided*/ any;
|
|
2189
2189
|
collect: () => PromiseLike< PaginatedList<UnstableGetResult<Database[Schema] extends {
|
|
2190
2190
|
Tables: Record<string, {
|
|
2191
2191
|
Row: Record<string, unknown>;
|
|
@@ -2378,7 +2378,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
2378
2378
|
PostgrestVersion: string;
|
|
2379
2379
|
} ? T_7 : never : never : never>>>;
|
|
2380
2380
|
};
|
|
2381
|
-
delete: () => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
2381
|
+
delete: () => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_2 ? T_2 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_2 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
2382
2382
|
__InternalSupabase: {
|
|
2383
2383
|
PostgrestVersion: string;
|
|
2384
2384
|
};
|
|
@@ -2568,8 +2568,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
2568
2568
|
}>;
|
|
2569
2569
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_3 extends {
|
|
2570
2570
|
Relationships: infer R;
|
|
2571
|
-
} ? R : unknown : never : never, "DELETE"> & {
|
|
2572
|
-
|
|
2571
|
+
} ? R : unknown : never : never, "DELETE">, "filter"> & {
|
|
2572
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
2573
2573
|
__InternalSupabase: {
|
|
2574
2574
|
PostgrestVersion: string;
|
|
2575
2575
|
};
|
|
@@ -2759,8 +2759,8 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
2759
2759
|
}>;
|
|
2760
2760
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_5 extends {
|
|
2761
2761
|
Relationships: infer R;
|
|
2762
|
-
} ? R : unknown : never : never, "DELETE"> & /*elided*/ any;
|
|
2763
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
2762
|
+
} ? R : unknown : never : never, "DELETE">, "filter"> & /*elided*/ any;
|
|
2763
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom< PostgrestFilterBuilder<("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) extends infer T_4 ? T_4 extends ("public" extends Exclude<keyof Database, "__InternalSupabase"> ? Exclude<keyof Database, "__InternalSupabase"> & "public" : string & Exclude<keyof Database, "__InternalSupabase">) ? T_4 extends string & Exclude<keyof Database, "__InternalSupabase"> ? Database extends {
|
|
2764
2764
|
__InternalSupabase: {
|
|
2765
2765
|
PostgrestVersion: string;
|
|
2766
2766
|
};
|
|
@@ -2950,7 +2950,7 @@ export declare class DataService<Database extends CoreDatabase, Schema extends S
|
|
|
2950
2950
|
}>;
|
|
2951
2951
|
} ? Database[Schema] : any)["Tables"][Relation] ? T_5 extends {
|
|
2952
2952
|
Relationships: infer R;
|
|
2953
|
-
} ? R : unknown : never : never, "DELETE"> & /*elided*/ any;
|
|
2953
|
+
} ? R : unknown : never : never, "DELETE">, "filter"> & /*elided*/ any;
|
|
2954
2954
|
collect: () => PromiseLike< PaginatedList<null>>;
|
|
2955
2955
|
};
|
|
2956
2956
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Embedding, EmbeddingPreprocessingStep, EmbeddingSynchronizationResult, FileMetadata, Metadata, MetadataGeneratorFn } from './embedding';
|
|
2
2
|
import { FileRef, StorageLocation } from './storage';
|
|
3
3
|
import { StorageService } from './storage-service';
|
|
4
|
-
export interface EmbeddingServiceParams<BucketName extends string> {
|
|
4
|
+
export interface EmbeddingServiceParams<BucketName extends string = string> {
|
|
5
5
|
storage: StorageService<BucketName>;
|
|
6
6
|
}
|
|
7
7
|
export declare abstract class EmbeddingService<BucketName extends string = string> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B,EAAmC,8BAA8B,EAAmC,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAExN,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,M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UAAU;IAOlB,oBAAoB,CAAC,UAAU,EAAE,0BAA0B,GAAG,IAAI;IAKlE,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKrC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKvD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAyBrG,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;CA2B9H"}
|
package/dist/filter.d.ts
CHANGED
|
@@ -36,12 +36,12 @@ export declare const LogicalOpSeparator = ",";
|
|
|
36
36
|
*/
|
|
37
37
|
export declare const FilterChainSeparator = "~";
|
|
38
38
|
/**
|
|
39
|
-
* A single filter
|
|
39
|
+
* A single filter condition in an abstract syntax tree (AST) of filter nodes.
|
|
40
40
|
* @param K The type of keys in the filter expression.
|
|
41
41
|
* @return The Zod schema representing the filter condition node.
|
|
42
42
|
*/
|
|
43
43
|
export interface FilterConditionNode<K extends string = string> {
|
|
44
|
-
type
|
|
44
|
+
type?: 'condition';
|
|
45
45
|
op: FilterOp;
|
|
46
46
|
value: string | number | boolean | null;
|
|
47
47
|
key: K;
|
package/dist/filter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../lib/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,CAAC,MAAM,KAAK,CAAC;AAKpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,M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C,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAK/G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACtD,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,GAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAmB,GAC9C,MAAM,CAQR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAClD,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,YAAY,GAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAmB,EAC7C,SAAS,SAAuB,GACjC,MAAM,CAER;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,SAAS,MAAM,GAAG,QAAQ,EACvG,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,QAAQ,EAAO,EAC1B,YAAY,GAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,SAA8C,GAChF,UAAU,CAAC,SAAS,CAAC,CAoFvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,SAAS,MAAM,GAAG,QAAQ,EAC5G,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,QAAQ,EAAO,EAC1B,YAAY,GAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,SAA8C,EAC/E,SAAS,SAAuB,GACjC,UAAU,CAAC,SAAS,CAAC,EAAE,CAOzB"}
|
package/dist/index.js
CHANGED
|
@@ -214,44 +214,47 @@ const w = {
|
|
|
214
214
|
* @example
|
|
215
215
|
* const table = supabase.schema('public').from('my_table');
|
|
216
216
|
* const {data, error} = await postgrestExtensions.query.enable(table)
|
|
217
|
-
* .
|
|
217
|
+
* .select(['id', 'name'])
|
|
218
218
|
* .then(({data}) => console.log(data)); // [{ id: 1, name: 'John' }, ...]
|
|
219
219
|
*/
|
|
220
220
|
query: {
|
|
221
|
-
enable: (s) => Object.assign(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
221
|
+
enable: (s) => Object.assign(
|
|
222
|
+
s,
|
|
223
|
+
{
|
|
224
|
+
/**
|
|
225
|
+
* Selects columns from the relation.
|
|
226
|
+
*
|
|
227
|
+
* @param columns The array of column names to select, or '*' to select all columns.
|
|
228
|
+
* @param options The options for the selection, such as count.
|
|
229
|
+
* @returns The PostgREST filter builder with selection applied and filter extension enabled.
|
|
230
|
+
*/
|
|
231
|
+
select: (t, e) => w.filter.enable(
|
|
232
|
+
s.select(
|
|
233
|
+
A(t).join(","),
|
|
234
|
+
e
|
|
235
|
+
)
|
|
236
|
+
),
|
|
237
|
+
/**
|
|
238
|
+
* Counts the number of rows in the relation.
|
|
239
|
+
* Does not select any columns, only counts the rows.
|
|
240
|
+
*
|
|
241
|
+
* @param method The counting method to use, defaults to 'exact'.
|
|
242
|
+
* @returns The PostgREST filter builder with counting applied and filter extension enabled.
|
|
243
|
+
*/
|
|
244
|
+
count: (t = "exact") => w.filter.enable(
|
|
245
|
+
s.select("*", { count: t, head: !0 })
|
|
246
|
+
),
|
|
247
|
+
/**
|
|
248
|
+
* Deletes rows from the relation.
|
|
249
|
+
* Returns a filter builder for further filtering before deletion.
|
|
250
|
+
*
|
|
251
|
+
* @returns The PostgREST filter builder with delete applied and filter extension enabled.
|
|
252
|
+
*/
|
|
253
|
+
delete: () => w.filter.enable(
|
|
254
|
+
s.delete()
|
|
233
255
|
)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
* Counts the number of rows in the relation.
|
|
237
|
-
* Does not select any columns, only counts the rows.
|
|
238
|
-
*
|
|
239
|
-
* @param method The counting method to use, defaults to 'exact'.
|
|
240
|
-
* @returns The PostgREST filter builder with counting applied and filter extension enabled.
|
|
241
|
-
*/
|
|
242
|
-
count: (t = "exact") => w.filter.enable(
|
|
243
|
-
s.select("*", { count: t, head: !0 })
|
|
244
|
-
),
|
|
245
|
-
/**
|
|
246
|
-
* Deletes rows from the relation.
|
|
247
|
-
* Returns a filter builder for further filtering before deletion.
|
|
248
|
-
*
|
|
249
|
-
* @returns The PostgREST filter builder with delete applied and filter extension enabled.
|
|
250
|
-
*/
|
|
251
|
-
delete: () => w.filter.enable(
|
|
252
|
-
s.delete()
|
|
253
|
-
)
|
|
254
|
-
})
|
|
256
|
+
}
|
|
257
|
+
)
|
|
255
258
|
},
|
|
256
259
|
/**
|
|
257
260
|
* Filter extension for PostgREST queries.
|
|
@@ -261,78 +264,81 @@ const w = {
|
|
|
261
264
|
* @example
|
|
262
265
|
* const selection = supabase.schema('public').from('my_table').select('*', { count: 'exact' });
|
|
263
266
|
* const {data, error} = await postgrestExtensions.filter.enable(selection)
|
|
264
|
-
* .
|
|
267
|
+
* .filter({ key: 'name', op: 'eq', value: 'John' })
|
|
265
268
|
* .paginate(1, 10)
|
|
266
269
|
* .collect();
|
|
267
270
|
*/
|
|
268
271
|
filter: {
|
|
269
|
-
enable: (s, t = {}) => Object.assign(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
272
|
+
enable: (s, t = {}) => Object.assign(
|
|
273
|
+
s,
|
|
274
|
+
{
|
|
275
|
+
/**
|
|
276
|
+
* Applies a filter to the query.
|
|
277
|
+
* A filter is defined as an AST of filter nodes including conditions and logical operators.
|
|
278
|
+
* @param node The filter to apply.
|
|
279
|
+
*/
|
|
280
|
+
filter: (e) => w.filter.enable(
|
|
281
|
+
(() => {
|
|
282
|
+
function r(a, n) {
|
|
283
|
+
if (n.type === "logical") {
|
|
284
|
+
const i = D(n.args, (c) => c, ",");
|
|
285
|
+
return n.op === "or" ? a.or(i) : n.op === "not.or" ? a.or(i, { referencedTable: "not" }) : r(a, {
|
|
286
|
+
type: "logical",
|
|
287
|
+
op: n.op === "and" ? "not.or" : "or",
|
|
288
|
+
args: n.args.map(N)
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return a.filter(n.key, n.op, n.value);
|
|
292
|
+
}
|
|
293
|
+
return r(s, e);
|
|
294
|
+
})(),
|
|
295
|
+
t
|
|
296
|
+
),
|
|
297
|
+
/**
|
|
298
|
+
* Limits the range of results to a specific page given a page index and limit.
|
|
299
|
+
* @param page The page index (0-based).
|
|
300
|
+
* @param limit The number of items per page.
|
|
301
|
+
* @param count Optional count of total items, if known.
|
|
302
|
+
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
303
|
+
*/
|
|
304
|
+
paginate: (e, r, a) => w.filter.enable(
|
|
305
|
+
(() => {
|
|
306
|
+
l(e >= 0, "Page index must be ≥ 0"), l(r >= 0, "Page limit must be ≥ 0");
|
|
307
|
+
const n = e * r, i = n + r - 1;
|
|
308
|
+
if (a !== void 0) {
|
|
309
|
+
if (n >= a)
|
|
310
|
+
return s.limit(0);
|
|
311
|
+
if (i >= a)
|
|
312
|
+
return s.range(n, a - 1);
|
|
313
|
+
}
|
|
314
|
+
return s.range(n, i);
|
|
315
|
+
})(),
|
|
316
|
+
{
|
|
317
|
+
...t,
|
|
318
|
+
pagination: {
|
|
319
|
+
page: e,
|
|
320
|
+
limit: r,
|
|
321
|
+
count: a
|
|
285
322
|
}
|
|
286
|
-
return a.filter(n.key, n.op, n.value);
|
|
287
|
-
}
|
|
288
|
-
return e.reduce(r, s);
|
|
289
|
-
})(),
|
|
290
|
-
t
|
|
291
|
-
),
|
|
292
|
-
/**
|
|
293
|
-
* Limits the range of results to a specific page given a page index and limit.
|
|
294
|
-
* @param page The page index (0-based).
|
|
295
|
-
* @param limit The number of items per page.
|
|
296
|
-
* @param count Optional count of total items, if known.
|
|
297
|
-
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
298
|
-
*/
|
|
299
|
-
paginate: (e, r, a) => w.filter.enable(
|
|
300
|
-
(() => {
|
|
301
|
-
l(e >= 0, "Page index must be ≥ 0"), l(r >= 0, "Page limit must be ≥ 0");
|
|
302
|
-
const n = e * r, i = n + r - 1;
|
|
303
|
-
if (a !== void 0) {
|
|
304
|
-
if (n >= a)
|
|
305
|
-
return s.limit(0);
|
|
306
|
-
if (i >= a)
|
|
307
|
-
return s.range(n, a - 1);
|
|
308
|
-
}
|
|
309
|
-
return s.range(n, i);
|
|
310
|
-
})(),
|
|
311
|
-
{
|
|
312
|
-
...t,
|
|
313
|
-
pagination: {
|
|
314
|
-
page: e,
|
|
315
|
-
limit: r,
|
|
316
|
-
count: a
|
|
317
323
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
324
|
+
),
|
|
325
|
+
/**
|
|
326
|
+
* Collects the results of a pagination query.
|
|
327
|
+
* **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
|
|
328
|
+
* @returns The paginated list of queried items.
|
|
329
|
+
*/
|
|
330
|
+
collect: () => s.throwOnError().then((e) => {
|
|
331
|
+
const { data: r, count: a } = e, { page: n, limit: i, ...c } = l.defined(t.pagination, "Pagination context is required for collect(). Make sure to call paginate() before collect()"), o = a ?? c.count;
|
|
332
|
+
return l(i > 0, "Page limit must be > 0"), l(Array.isArray(r), "Data must be an array for pagination, make sure to select multiple rows in query"), l(o !== void 0, "Row count is required for pagination, make sure to count in query or pass `count` in paginate()"), {
|
|
333
|
+
items: r,
|
|
334
|
+
totalItems: o,
|
|
335
|
+
page: n,
|
|
336
|
+
totalPages: Math.ceil(o / i),
|
|
337
|
+
limit: i
|
|
338
|
+
};
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
)
|
|
336
342
|
}
|
|
337
343
|
};
|
|
338
344
|
class F {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PostgrestClientOptions, PostgrestFilterBuilder, PostgrestQueryBuilder, UnstableGetResult } from '@supabase/postgrest-js';
|
|
2
2
|
import { GenericSchema, GenericTable, GenericView } from './database';
|
|
3
|
-
import {
|
|
3
|
+
import { FilterNode } from './filter';
|
|
4
4
|
import { CountMethod, Select, SelectColumns, SelectOptions } from './select';
|
|
5
|
-
import { ElementOf } from './utils';
|
|
5
|
+
import { ElementOf, OmitFrom } from './utils';
|
|
6
6
|
/**
|
|
7
7
|
* Paginated list of items with pagination info.
|
|
8
8
|
*/
|
|
@@ -31,7 +31,7 @@ interface PostgrestFilterExtensionContext {
|
|
|
31
31
|
* @example
|
|
32
32
|
* const selection = supabase.schema('public').from('my_table').select('*', { count: 'exact' });
|
|
33
33
|
* const {data, error} = await postgrestExtensions.filter.enable(selection)
|
|
34
|
-
* .
|
|
34
|
+
* .filter({ key: 'name', op: 'eq', value: 'John' })
|
|
35
35
|
* .paginate(1, 10)
|
|
36
36
|
* .collect();
|
|
37
37
|
*/
|
|
@@ -44,13 +44,13 @@ export declare const postgrestExtensions: {
|
|
|
44
44
|
* @example
|
|
45
45
|
* const table = supabase.schema('public').from('my_table');
|
|
46
46
|
* const {data, error} = await postgrestExtensions.query.enable(table)
|
|
47
|
-
* .
|
|
47
|
+
* .select(['id', 'name'])
|
|
48
48
|
* .then(({data}) => console.log(data)); // [{ id: 1, name: 'John' }, ...]
|
|
49
49
|
*/
|
|
50
50
|
readonly query: {
|
|
51
51
|
readonly enable: <ClientOptions extends PostgrestClientOptions, Schema extends GenericSchema, Relation extends GenericTable | GenericView, RelationName = unknown, Relationships = Relation extends {
|
|
52
52
|
Relationships: infer R;
|
|
53
|
-
} ? R : unknown>(builder: PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships>) => PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships> & {
|
|
53
|
+
} ? R : unknown>(builder: PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships>) => OmitFrom<PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships>, "select" | "delete"> & {
|
|
54
54
|
/**
|
|
55
55
|
* Selects columns from the relation.
|
|
56
56
|
*
|
|
@@ -58,13 +58,13 @@ export declare const postgrestExtensions: {
|
|
|
58
58
|
* @param options The options for the selection, such as count.
|
|
59
59
|
* @returns The PostgREST filter builder with selection applied and filter extension enabled.
|
|
60
60
|
*/
|
|
61
|
-
select: <Columns extends SelectColumns<Relation["Row"]>>(columns: Columns, options?: SelectOptions) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET"> & {
|
|
61
|
+
select: <Columns extends SelectColumns<Relation["Row"]>>(columns: Columns, options?: SelectOptions) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET">, "filter"> & {
|
|
62
62
|
/**
|
|
63
63
|
* Applies a filter to the query.
|
|
64
|
-
* A filter is defined as an
|
|
65
|
-
* @param
|
|
64
|
+
* A filter is defined as an AST of filter nodes including conditions and logical operators.
|
|
65
|
+
* @param node The filter to apply.
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET">, "filter"> & /*elided*/ any;
|
|
68
68
|
/**
|
|
69
69
|
* Limits the range of results to a specific page given a page index and limit.
|
|
70
70
|
* @param page The page index (0-based).
|
|
@@ -72,7 +72,7 @@ export declare const postgrestExtensions: {
|
|
|
72
72
|
* @param count Optional count of total items, if known.
|
|
73
73
|
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
74
74
|
*/
|
|
75
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET"> & /*elided*/ any;
|
|
75
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET">, "filter"> & /*elided*/ any;
|
|
76
76
|
/**
|
|
77
77
|
* Collects the results of a pagination query.
|
|
78
78
|
* **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
|
|
@@ -87,13 +87,13 @@ export declare const postgrestExtensions: {
|
|
|
87
87
|
* @param method The counting method to use, defaults to 'exact'.
|
|
88
88
|
* @returns The PostgREST filter builder with counting applied and filter extension enabled.
|
|
89
89
|
*/
|
|
90
|
-
count: (method?: CountMethod) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET"> & {
|
|
90
|
+
count: (method?: CountMethod) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET">, "filter"> & {
|
|
91
91
|
/**
|
|
92
92
|
* Applies a filter to the query.
|
|
93
|
-
* A filter is defined as an
|
|
94
|
-
* @param
|
|
93
|
+
* A filter is defined as an AST of filter nodes including conditions and logical operators.
|
|
94
|
+
* @param node The filter to apply.
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET">, "filter"> & /*elided*/ any;
|
|
97
97
|
/**
|
|
98
98
|
* Limits the range of results to a specific page given a page index and limit.
|
|
99
99
|
* @param page The page index (0-based).
|
|
@@ -101,7 +101,7 @@ export declare const postgrestExtensions: {
|
|
|
101
101
|
* @param count Optional count of total items, if known.
|
|
102
102
|
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
103
103
|
*/
|
|
104
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET"> & /*elided*/ any;
|
|
104
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET">, "filter"> & /*elided*/ any;
|
|
105
105
|
/**
|
|
106
106
|
* Collects the results of a pagination query.
|
|
107
107
|
* **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
|
|
@@ -115,13 +115,13 @@ export declare const postgrestExtensions: {
|
|
|
115
115
|
*
|
|
116
116
|
* @returns The PostgREST filter builder with delete applied and filter extension enabled.
|
|
117
117
|
*/
|
|
118
|
-
delete: () => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE"> & {
|
|
118
|
+
delete: () => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE">, "filter"> & {
|
|
119
119
|
/**
|
|
120
120
|
* Applies a filter to the query.
|
|
121
|
-
* A filter is defined as an
|
|
122
|
-
* @param
|
|
121
|
+
* A filter is defined as an AST of filter nodes including conditions and logical operators.
|
|
122
|
+
* @param node The filter to apply.
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE">, "filter"> & /*elided*/ any;
|
|
125
125
|
/**
|
|
126
126
|
* Limits the range of results to a specific page given a page index and limit.
|
|
127
127
|
* @param page The page index (0-based).
|
|
@@ -129,7 +129,7 @@ export declare const postgrestExtensions: {
|
|
|
129
129
|
* @param count Optional count of total items, if known.
|
|
130
130
|
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
131
131
|
*/
|
|
132
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE"> & /*elided*/ any;
|
|
132
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE">, "filter"> & /*elided*/ any;
|
|
133
133
|
/**
|
|
134
134
|
* Collects the results of a pagination query.
|
|
135
135
|
* **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
|
|
@@ -147,18 +147,18 @@ export declare const postgrestExtensions: {
|
|
|
147
147
|
* @example
|
|
148
148
|
* const selection = supabase.schema('public').from('my_table').select('*', { count: 'exact' });
|
|
149
149
|
* const {data, error} = await postgrestExtensions.filter.enable(selection)
|
|
150
|
-
* .
|
|
150
|
+
* .filter({ key: 'name', op: 'eq', value: 'John' })
|
|
151
151
|
* .paginate(1, 10)
|
|
152
152
|
* .collect();
|
|
153
153
|
*/
|
|
154
154
|
readonly filter: {
|
|
155
|
-
readonly enable: <ClientOptions extends PostgrestClientOptions, Schema extends GenericSchema, Row extends Record<string, unknown>, Result, RelationName = unknown, Relationships = unknown, Method = unknown>(builder: PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>, context?: PostgrestFilterExtensionContext) => PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method> & {
|
|
155
|
+
readonly enable: <ClientOptions extends PostgrestClientOptions, Schema extends GenericSchema, Row extends Record<string, unknown>, Result, RelationName = unknown, Relationships = unknown, Method = unknown>(builder: PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>, context?: PostgrestFilterExtensionContext) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>, "filter"> & {
|
|
156
156
|
/**
|
|
157
157
|
* Applies a filter to the query.
|
|
158
|
-
* A filter is defined as an
|
|
159
|
-
* @param
|
|
158
|
+
* A filter is defined as an AST of filter nodes including conditions and logical operators.
|
|
159
|
+
* @param node The filter to apply.
|
|
160
160
|
*/
|
|
161
|
-
|
|
161
|
+
filter: <K extends string = string>(node: FilterNode<K>) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>, "filter"> & /*elided*/ any;
|
|
162
162
|
/**
|
|
163
163
|
* Limits the range of results to a specific page given a page index and limit.
|
|
164
164
|
* @param page The page index (0-based).
|
|
@@ -166,7 +166,7 @@ export declare const postgrestExtensions: {
|
|
|
166
166
|
* @param count Optional count of total items, if known.
|
|
167
167
|
* If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
|
|
168
168
|
*/
|
|
169
|
-
paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method> & /*elided*/ any;
|
|
169
|
+
paginate: (page: number, limit: number, count?: number) => OmitFrom<PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>, "filter"> & /*elided*/ any;
|
|
170
170
|
/**
|
|
171
171
|
* Collects the results of a pagination query.
|
|
172
172
|
* **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgrest-extensions.d.ts","sourceRoot":"","sources":["../lib/postgrest-extensions.ts"],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ightweight services for supabase to make it easier to work with databases, tables and storage buckets",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.3.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|