@freehour/supabase-core 1.2.1 → 1.4.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.
@@ -0,0 +1,159 @@
1
+ import { PostgrestSingleResponse } from '@supabase/supabase-js';
2
+ import { Args as BaseArgs, ClientServerOptions, ColumnName, FunctionName as BaseFunctionName, GenericDatabase, GenericSchema, Insert, Relation, RelationName as BaseRelationName, Relationships, RelationType as BaseRelationType, Row, Schema, SchemaName as BaseSchemaName, TableName as BaseTableName, Update, ViewName as BaseViewName } from './database';
3
+ import { FilterNode } from './filter';
4
+ import { ElementOf, KeyOfString, OmitFrom } from './utils';
5
+ import * as Supabase from '@supabase/postgrest-js';
6
+ export type SelectQuery<Database extends GenericDatabase, SchemaName extends BaseSchemaName<Database>, RelationType extends BaseRelationType, RelationName extends BaseRelationName<Database, SchemaName, RelationType>> = (keyof Row<Database, SchemaName, RelationType, RelationName>)[] | '*' | (string & {});
7
+ export type SelectResult<Database extends GenericDatabase, SchemaName extends BaseSchemaName<Database>, RelationType extends BaseRelationType, RelationName extends BaseRelationName<Database, SchemaName, RelationType>, Query extends SelectQuery<Database, SchemaName, RelationType, RelationName>> = Query extends '*' ? Row<Database, SchemaName, RelationType, RelationName> : Query extends string ? Supabase.UnstableGetResult<Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, Query, ClientServerOptions> : Pick<Row<Database, SchemaName, RelationType, RelationName>, Query[number]>;
8
+ /**
9
+ * The method to use to count rows returned by the function.
10
+ * - `exact`: Counts the rows exactly.
11
+ * - `planned`: Uses statistics to get a fairly accurate and fast count.
12
+ * - `estimated`: Uses an estimated count which is the exact count up until a threshold and the planned count when that threshold is surpassed.
13
+ *
14
+ * @see https://docs.postgrest.org/en/v12/references/api/pagination_count.html#counting
15
+ */
16
+ export type CountMethod = 'exact' | 'planned' | 'estimated';
17
+ /**
18
+ * Options for selecting rows from a database table.
19
+ */
20
+ export interface SelectOptions {
21
+ /**
22
+ * When set to `true`, `data` will not be returned, useful if you only need the count.
23
+ */
24
+ head?: boolean;
25
+ /**
26
+ * The method to use to count rows returned by the function.
27
+ * If not set, no count will be performed.
28
+ */
29
+ count?: CountMethod;
30
+ }
31
+ /**
32
+ * Options for inserting rows into a database table.
33
+ */
34
+ export interface InsertOptions {
35
+ /**
36
+ * The method to use to count rows returned by the function.
37
+ * If not set, no count will be performed.
38
+ */
39
+ count?: CountMethod;
40
+ /**
41
+ * Make missing fields default to `null`.
42
+ * Otherwise, use the default value for the column. Only applies for bulk
43
+ * inserts.
44
+ * @default true
45
+ */
46
+ defaultToNull?: boolean;
47
+ }
48
+ /**
49
+ * Options for upserting data into a database.
50
+ * Upserting means inserting a new row or updating an existing row if it already exists.
51
+ */
52
+ export interface UpsertOptions<Database extends GenericDatabase, SchemaName extends BaseSchemaName<Database> = BaseSchemaName<Database>, RelationType extends BaseRelationType = BaseRelationType, RelationName extends BaseRelationName<Database, SchemaName, RelationType> = BaseRelationName<Database, SchemaName, RelationType>> {
53
+ /**
54
+ * Comma-separated UNIQUE column(s) to use for conflict resolution.
55
+ * This column is used to determine if a row already exists in the database.
56
+ * If a row with the same value in this column exists, it will be updated instead of inserted.
57
+ * If not specified, uses the primary key of the relation.
58
+ */
59
+ onConflict?: ColumnName<Database, SchemaName, RelationType, RelationName>[] | string;
60
+ /**
61
+ * If `true`, duplicate rows are ignored. If
62
+ * `false`, duplicate rows are merged with existing rows.
63
+ * @default false
64
+ */
65
+ ignoreDuplicates?: boolean;
66
+ /**
67
+ * Count algorithm to use to count upserted rows.
68
+ */
69
+ count?: CountMethod;
70
+ /**
71
+ * Make missing fields default to `null`.
72
+ * Otherwise, use the default value for the column. This only applies when
73
+ * inserting new rows, not when merging with existing rows under
74
+ * `ignoreDuplicates: false`. This also only applies when doing bulk upserts.
75
+ * @default true
76
+ */
77
+ defaultToNull?: boolean;
78
+ }
79
+ /**
80
+ * Options for updating rows in a database table.
81
+ */
82
+ export interface UpdateOptions {
83
+ /**
84
+ * The method to use to count rows returned by the function.
85
+ * If not set, no count will be performed.
86
+ */
87
+ count?: CountMethod;
88
+ }
89
+ /**
90
+ * Options for calling a PostgREST RPC function.
91
+ */
92
+ export interface RpcOptions extends SelectOptions {
93
+ /**
94
+ * When set to `true`, the function will be called with read-only access mode.
95
+ */
96
+ get?: boolean;
97
+ }
98
+ /**
99
+ * Paginated list of items with pagination info.
100
+ */
101
+ export interface PaginatedList<Item> {
102
+ items: Item[];
103
+ page: number;
104
+ limit: number;
105
+ totalItems: number;
106
+ totalPages: number;
107
+ }
108
+ export declare class PostgrestFilterBuilder<ClientOptions extends ClientServerOptions, Schema extends GenericSchema, Row extends Record<string, unknown>, Result, RelationName = unknown, Relationships = unknown, Method = unknown> extends Supabase.PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method> {
109
+ private pagination?;
110
+ constructor(builder: Supabase.PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method>);
111
+ select<Query extends (keyof Row)[] | '*' | (string & {}) = '*', ResultOne = Query extends '*' ? Row : Query extends string ? Supabase.UnstableGetResult<Schema, Row, RelationName, Relationships, Query, ClientServerOptions> : Pick<Row, Query[number]>>(columns?: Query): PostgrestFilterBuilder<ClientOptions, Schema, Row, Method extends 'RPC' ? Result extends unknown[] ? ResultOne[] : ResultOne : ResultOne[], RelationName, Relationships, Method>;
112
+ /**
113
+ * Applies a filter to the query.
114
+ * A filter is defined as an AST of filter nodes including conditions and logical operators.
115
+ * @param filter The filter to apply.
116
+ */
117
+ where(filter: FilterNode<KeyOfString<Row>>): this;
118
+ /**
119
+ * Limits the range of results to a specific page given a page index and limit.
120
+ * @param page The page index (0-based).
121
+ * @param limit The number of items per page.
122
+ * @param count Optional count of total items, if known.
123
+ * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
124
+ */
125
+ paginate(page: number, limit: number, count?: number): this;
126
+ /**
127
+ * Collects the results of a pagination query.
128
+ * **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
129
+ * @returns The paginated list of queried items.
130
+ */
131
+ collect(): PromiseLike<PostgrestSingleResponse<PaginatedList<ElementOf<Result>>>>;
132
+ }
133
+ export declare class PostgrestQueryBuilder<Database extends GenericDatabase<SchemaName>, ClientOptions extends ClientServerOptions, SchemaName extends BaseSchemaName<Database>, RelationType extends BaseRelationType = BaseRelationType, RelationName extends BaseRelationName<Database, SchemaName, RelationType> = BaseRelationName<Database, SchemaName, RelationType>> extends Supabase.PostgrestQueryBuilder<ClientOptions, Schema<Database, SchemaName>, Relation<Database, SchemaName, RelationType, RelationName>, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>> {
134
+ constructor(builder: Supabase.PostgrestQueryBuilder<ClientOptions, Schema<Database, SchemaName>, Relation<Database, SchemaName, RelationType, RelationName>, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>>);
135
+ select<Query extends SelectQuery<Database, SchemaName, RelationType, RelationName> = '*', ResultOne = SelectResult<Database, SchemaName, RelationType, RelationName, Query>>(columns?: Query, options?: SelectOptions): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, ResultOne[], RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'GET'>;
136
+ /**
137
+ * Counts the number of rows in the relation.
138
+ * Does not select any columns, only counts the rows.
139
+ *
140
+ * @param method The counting method to use, defaults to 'exact'.
141
+ * @returns The PostgREST filter builder with counting applied and filter extension enabled.
142
+ */
143
+ count(method?: CountMethod): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, Row<Database, SchemaName, RelationType, RelationName>[], RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'GET'>;
144
+ insert(value: Insert<Database, SchemaName, RelationType, RelationName>, options?: OmitFrom<InsertOptions, 'defaultToNull'>): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'POST'>;
145
+ insert(values: Insert<Database, SchemaName, RelationType, RelationName>[], options?: InsertOptions): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'POST'>;
146
+ upsert(value: Insert<Database, SchemaName, RelationType, RelationName>, options?: OmitFrom<UpsertOptions<Database, SchemaName, RelationType, RelationName>, 'defaultToNull'>): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'POST'>;
147
+ upsert(values: Insert<Database, SchemaName, RelationType, RelationName>[], options?: UpsertOptions<Database, SchemaName, RelationType, RelationName>): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'POST'>;
148
+ update(value: Update<Database, SchemaName, RelationType, RelationName>, options?: UpdateOptions): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'PATCH'>;
149
+ delete(): PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row<Database, SchemaName, RelationType, RelationName>, null, RelationName, Relationships<Database, SchemaName, RelationType, RelationName>, 'DELETE'>;
150
+ }
151
+ export declare class PostgrestClient<Database extends GenericDatabase<SchemaName>, ClientOptions extends ClientServerOptions, SchemaName extends BaseSchemaName<Database>> {
152
+ private readonly client;
153
+ constructor(client: Supabase.PostgrestClient<Database, ClientOptions, SchemaName, Schema<Database, SchemaName>>);
154
+ from<TableName extends BaseTableName<Database, SchemaName>>(relation: TableName): PostgrestQueryBuilder<Database, ClientOptions, SchemaName, 'Tables', TableName>;
155
+ from<ViewName extends BaseViewName<Database, SchemaName>>(relation: ViewName): PostgrestQueryBuilder<Database, ClientOptions, SchemaName, 'Views', ViewName>;
156
+ from<RelationType extends BaseRelationType, RelationName extends BaseRelationName<Database, SchemaName, RelationType>>(relation: RelationName): PostgrestQueryBuilder<Database, ClientOptions, SchemaName, RelationType, RelationName>;
157
+ rpc<FunctionName extends BaseFunctionName<Database, SchemaName>, Args extends BaseArgs<Database, SchemaName, FunctionName>>(fn: FunctionName, args?: Args, options?: RpcOptions): ReturnType<typeof this.client.rpc<FunctionName, Args>> extends Supabase.PostgrestFilterBuilder<any, any, infer Row, infer Result, infer RelationName, infer Relationships, any> ? PostgrestFilterBuilder<ClientOptions, Schema<Database, SchemaName>, Row, Result, RelationName, Relationships, 'RPC'> : never;
158
+ }
159
+ //# sourceMappingURL=postgrest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgrest.d.ts","sourceRoot":"","sources":["../lib/postgrest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,IAAI,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,IAAI,gBAAgB,EAAE,aAAa,EAAE,YAAY,IAAI,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,IAAI,cAAc,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACpW,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAc,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5E,MAAM,MAAM,WAAW,CACnB,QAAQ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a,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,CAAC;IAuBzF,GAAG,CACC,YAAY,SAAS,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,EAC3D,IAAI,SAAS,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,EAEzD,EAAE,EAAE,YAAY,EAChB,IAAI,CAAC,EAAE,IAAI,EACX,OAAO,CAAC,EAAE,UAAU,GACrB,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,MAAM,MAAM,EAAE,MAAM,YAAY,EAAE,MAAM,aAAa,EAAE,GAAG,CAAC,GAC1K,sBAAsB,CAClB,aAAa,EACb,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,EAC5B,GAAG,EACH,MAAM,EACN,YAAY,EACZ,aAAa,EACb,KAAK,CACR,GACC,KAAK;CAIlB"}
package/dist/storage.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Camelize, FileObjectV2, TransformOptions, StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
2
- import { StorageObjectsTable } from './database';
2
+ import { StorageObjectsTable } from './core-database';
3
3
  import { OmitFrom } from './utils';
4
4
  export declare class StorageClient<BucketName extends string = string> extends SupabaseStorageClient {
5
5
  from(bucket: BucketName | (string & {})): ReturnType<SupabaseStorageClient['from']>;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../lib/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACt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
4
  "displayName": "Supabase-Core",
5
5
  "description": "Lightweight services for supabase to make it easier to work with databases, tables and storage buckets",
6
- "version": "1.2.1",
6
+ "version": "1.4.0",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@freehour/assert": "1.0.0",
31
31
  "@freehour/mime": "^1.0.5",
32
+ "@supabase/postgrest-js": "^2.100.0",
32
33
  "@supabase/storage-js": "^2.99.3",
33
34
  "@supabase/supabase-js": "2.99.3",
34
35
  "zod": "4.3.6"
package/dist/data.d.ts DELETED
@@ -1,53 +0,0 @@
1
- import { CoreDatabase } from './database';
2
- import { ColumnName, RelationName, RelationType, SchemaName } from './relation';
3
- import { CountMethod } from './select';
4
- /**
5
- * Options for fuzzy searching within a database table or view.
6
- */
7
- export interface FuzzySearchParams<Database extends CoreDatabase, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
8
- /**
9
- * The name of the column to search in.
10
- */
11
- column: ColumnName<Database, Schema, Type, Relation>;
12
- /**
13
- * The search term to use for the fuzzy search.
14
- * This is the term that will be matched against the specified column.
15
- * If empty or undefined, the function will return all rows sorted by the search column.
16
- * @default ''
17
- */
18
- searchTerm?: string;
19
- /**
20
- * The minimum similarity score for results to be included.
21
- * This is a number between 0 and 1, where 1 means an exact match.
22
- * @default 0
23
- */
24
- minSimilarity?: number;
25
- /**
26
- * The maximum number of results to return.
27
- * @default 64
28
- */
29
- limit?: number;
30
- }
31
- /**
32
- * Options for upserting data into a database.
33
- * Upserting means inserting a new row or updating an existing row if it already exists.
34
- */
35
- export interface UpsertOptions<Database extends CoreDatabase, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
36
- /**
37
- * The name of the columns to use for conflict resolution.
38
- * This column is used to determine if a row already exists in the database.
39
- * If a row with the same value in this column exists, it will be updated instead of inserted.
40
- * If not specified, uses the primary key of the relation.
41
- */
42
- onConflict?: ColumnName<Database, Schema, Type, Relation>[];
43
- /**
44
- * If `true`, duplicate rows are ignored. If
45
- * `false`, duplicate rows are merged with existing rows.
46
- */
47
- ignoreDuplicates?: boolean;
48
- /**
49
- * Count algorithm to use to count upserted rows.
50
- */
51
- countMethod?: CountMethod;
52
- }
53
- //# sourceMappingURL=data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../lib/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAC9B,QAAQ,SAAS,YAAY,EAC7B,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,EAC1D,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,QAAQ,SAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;IAE5F;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAErD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAC1B,QAAQ,SAAS,YAAY,EAC7B,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,EAC1D,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,QAAQ,SAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;IAE5F;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;IAE5D;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B"}
@@ -1,180 +0,0 @@
1
- import { PostgrestClientOptions, PostgrestFilterBuilder, PostgrestQueryBuilder, UnstableGetResult } from '@supabase/postgrest-js';
2
- import { GenericSchema, GenericTable, GenericView } from './database';
3
- import { Filter } from './filter';
4
- import { CountMethod, Select, SelectColumns, SelectOptions } from './select';
5
- import { ElementOf } from './utils';
6
- /**
7
- * Paginated list of items with pagination info.
8
- */
9
- export interface PaginatedList<Item> {
10
- items: Item[];
11
- page: number;
12
- limit: number;
13
- totalItems: number;
14
- totalPages: number;
15
- }
16
- /**
17
- * Internal context for PostgREST filter extension. Keeps track of current filter state
18
- * modified by functions in the postgrestExtensions.filter chain.
19
- */
20
- interface PostgrestFilterExtensionContext {
21
- pagination?: {
22
- page: number;
23
- limit: number;
24
- count?: number;
25
- };
26
- }
27
- /**
28
- * Database extensions for PostgREST queries.
29
- * Provides methods for column selection, filtering and pagination.
30
- *
31
- * @example
32
- * const selection = supabase.schema('public').from('my_table').select('*', { count: 'exact' });
33
- * const {data, error} = await postgrestExtensions.filter.enable(selection)
34
- * .apply({ key: 'name', op: 'eq', value: 'John' })
35
- * .paginate(1, 10)
36
- * .collect();
37
- */
38
- export declare const postgrestExtensions: {
39
- /**
40
- * Query extension for PostgREST queries.
41
- * Supports typesafe column selection and counting.
42
- * This extension can be used with any PostgREST query builder.
43
- *
44
- * @example
45
- * const table = supabase.schema('public').from('my_table');
46
- * const {data, error} = await postgrestExtensions.query.enable(table)
47
- * .selectColumns(['id', 'name'])
48
- * .then(({data}) => console.log(data)); // [{ id: 1, name: 'John' }, ...]
49
- */
50
- readonly query: {
51
- readonly enable: <ClientOptions extends PostgrestClientOptions, Schema extends GenericSchema, Relation extends GenericTable | GenericView, RelationName = unknown, Relationships = Relation extends {
52
- Relationships: infer R;
53
- } ? R : unknown>(builder: PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships>) => PostgrestQueryBuilder<ClientOptions, Schema, Relation, RelationName, Relationships> & {
54
- /**
55
- * Selects columns from the relation.
56
- *
57
- * @param columns The array of column names to select, or '*' to select all columns.
58
- * @param options The options for the selection, such as count.
59
- * @returns The PostgREST filter builder with selection applied and filter extension enabled.
60
- */
61
- select: <Columns extends SelectColumns<Relation["Row"]>>(columns: Columns, options?: SelectOptions) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET"> & {
62
- /**
63
- * Applies a filter to the query.
64
- * A filter is defined as an array of AST filter nodes including conditions and logical operators.
65
- * @param filter The filter to apply.
66
- */
67
- apply: <K extends string = string>(filter: Filter<K>) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET"> & /*elided*/ any;
68
- /**
69
- * Limits the range of results to a specific page given a page index and limit.
70
- * @param page The page index (0-based).
71
- * @param limit The number of items per page.
72
- * @param count Optional count of total items, if known.
73
- * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
74
- */
75
- paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], Select<Relation["Row"], Columns>[], RelationName, Relationships, "GET"> & /*elided*/ any;
76
- /**
77
- * Collects the results of a pagination query.
78
- * **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
79
- * @returns The paginated list of queried items.
80
- */
81
- collect: () => PromiseLike<PaginatedList<Select<Relation["Row"], Columns>>>;
82
- };
83
- /**
84
- * Counts the number of rows in the relation.
85
- * Does not select any columns, only counts the rows.
86
- *
87
- * @param method The counting method to use, defaults to 'exact'.
88
- * @returns The PostgREST filter builder with counting applied and filter extension enabled.
89
- */
90
- count: (method?: CountMethod) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET"> & {
91
- /**
92
- * Applies a filter to the query.
93
- * A filter is defined as an array of AST filter nodes including conditions and logical operators.
94
- * @param filter The filter to apply.
95
- */
96
- apply: <K extends string = string>(filter: Filter<K>) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>[], RelationName, Relationships, "GET"> & /*elided*/ any;
97
- /**
98
- * Limits the range of results to a specific page given a page index and limit.
99
- * @param page The page index (0-based).
100
- * @param limit The number of items per page.
101
- * @param count Optional count of total items, if known.
102
- * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
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;
105
- /**
106
- * Collects the results of a pagination query.
107
- * **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
108
- * @returns The paginated list of queried items.
109
- */
110
- collect: () => PromiseLike<PaginatedList< UnstableGetResult<Schema, Relation["Row"], RelationName, Relationships, "*", ClientOptions>>>;
111
- };
112
- /**
113
- * Deletes rows from the relation.
114
- * Returns a filter builder for further filtering before deletion.
115
- *
116
- * @returns The PostgREST filter builder with delete applied and filter extension enabled.
117
- */
118
- delete: () => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE"> & {
119
- /**
120
- * Applies a filter to the query.
121
- * A filter is defined as an array of AST filter nodes including conditions and logical operators.
122
- * @param filter The filter to apply.
123
- */
124
- apply: <K extends string = string>(filter: Filter<K>) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE"> & /*elided*/ any;
125
- /**
126
- * Limits the range of results to a specific page given a page index and limit.
127
- * @param page The page index (0-based).
128
- * @param limit The number of items per page.
129
- * @param count Optional count of total items, if known.
130
- * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
131
- */
132
- paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Relation["Row"], null, RelationName, Relationships, "DELETE"> & /*elided*/ any;
133
- /**
134
- * Collects the results of a pagination query.
135
- * **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
136
- * @returns The paginated list of queried items.
137
- */
138
- collect: () => PromiseLike<PaginatedList<null>>;
139
- };
140
- };
141
- };
142
- /**
143
- * Filter extension for PostgREST queries.
144
- * Supports applying filters, pagination and collecting results.
145
- * This extension can be used with any PostgREST filter builder.
146
- *
147
- * @example
148
- * const selection = supabase.schema('public').from('my_table').select('*', { count: 'exact' });
149
- * const {data, error} = await postgrestExtensions.filter.enable(selection)
150
- * .apply({ key: 'name', op: 'eq', value: 'John' })
151
- * .paginate(1, 10)
152
- * .collect();
153
- */
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> & {
156
- /**
157
- * Applies a filter to the query.
158
- * A filter is defined as an array of AST filter nodes including conditions and logical operators.
159
- * @param filter The filter to apply.
160
- */
161
- apply: <K extends string = string>(filter: Filter<K>) => PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method> & /*elided*/ any;
162
- /**
163
- * Limits the range of results to a specific page given a page index and limit.
164
- * @param page The page index (0-based).
165
- * @param limit The number of items per page.
166
- * @param count Optional count of total items, if known.
167
- * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
168
- */
169
- paginate: (page: number, limit: number, count?: number) => PostgrestFilterBuilder<ClientOptions, Schema, Row, Result, RelationName, Relationships, Method> & /*elided*/ any;
170
- /**
171
- * Collects the results of a pagination query.
172
- * **Note:** For collect to work, paginate() must be called before collect() and the selection must include a `count`.
173
- * @returns The paginated list of queried items.
174
- */
175
- collect: () => PromiseLike<PaginatedList<ElementOf<Result>>>;
176
- };
177
- };
178
- };
179
- export {};
180
- //# sourceMappingURL=postgrest-extensions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgrest-extensions.d.ts","sourceRoot":"","sources":["../lib/postgrest-extensions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,qBAAqB,EAA4B,MAAM,wBAAwB,CAAC;AAE9I,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,UAAU,+BAA+B;IACrC,UAAU,CAAC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YAC/F,+BAA+B;YAGxC;;;;eAIG;oBACK,CAAC,SAAS,MAAM,mBAAmB,MAAM,CAAC,CAAC,CAAC;YAgCpD;;;;;;eAMG;6BACc,MAAM,SAAS,MAAM,UAAU,MAAM;YA8BtD;;;;eAIG;;;;CAoBL,CAAC"}
@@ -1,29 +0,0 @@
1
- import { GenericDatabase } from './database';
2
- import { KeyOfString } from './utils';
3
- export type SchemaName<D extends GenericDatabase> = Exclude<KeyOfString<D>, '__InternalSupabase'>;
4
- export type RelationType = 'Tables' | 'Views';
5
- export type RelationName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>, R extends RelationType = RelationType> = KeyOfString<D[S][R]>;
6
- export type TableName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>> = RelationName<D, S, 'Tables'>;
7
- export type ViewName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>> = RelationName<D, S, 'Views'>;
8
- export type ColumnName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>, R extends RelationType = RelationType, T extends RelationName<D, S, R> = RelationName<D, S, R>> = KeyOfString<D[S][R][T]['Row']>;
9
- export type TableColumnName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>, T extends TableName<D, S> = TableName<D, S>> = ColumnName<D, S, 'Tables', T>;
10
- export type ViewColumnName<D extends GenericDatabase<S>, S extends SchemaName<D> = SchemaName<D>, V extends ViewName<D, S> = ViewName<D, S>> = ColumnName<D, S, 'Views', V>;
11
- export type Relation<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = D[S][R][T] extends {
12
- Row: infer R;
13
- Insert?: infer I;
14
- Update?: infer U;
15
- Relationships: infer Rel;
16
- } ? {
17
- Row: R;
18
- Insert: I;
19
- Update: U;
20
- Relationships: Rel;
21
- } : never;
22
- export type Row<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = Relation<D, S, R, T>['Row'];
23
- export type Insert<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = Relation<D, S, R, T>['Insert'];
24
- export type Update<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = Relation<D, S, R, T>['Update'];
25
- export type Relationships<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = Relation<D, S, R, T>['Relationships'];
26
- export type ID<D extends GenericDatabase<KeyOfString<D>>, S extends SchemaName<D>, R extends RelationType, T extends RelationName<D, S, R>> = Row<D, S, R, T> extends {
27
- id: infer ID;
28
- } ? ID : never;
29
- //# sourceMappingURL=relation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relation.d.ts","sourceRoot":"","sources":["../lib/relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAElG,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC9C,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9J,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CA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AAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEnC,MAAM,MAAM,MAAM,CACd,CAAC,SAAS,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACzC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EACvB,CAAC,SAAS,YAAY,EACtB,CAAC,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAC/B,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEnC,MAAM,MAAM,aAAa,CACrB,CAAC,SAAS,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACzC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EACvB,CAAC,SAAS,YAAY,EACtB,CAAC,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAC/B,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;AAE1C,MAAM,MAAM,EAAE,CACV,CAAC,SAAS,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EACzC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EACvB,CAAC,SAAS,YAAY,EACtB,CAAC,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAC/B,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,EAAE,GAAG,KAAK,CAAC"}
package/dist/select.d.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * The method to use to count rows returned by the function.
3
- * - `exact`: Counts the rows exactly.
4
- * - `planned`: Uses statistics to get a fairly accurate and fast count.
5
- * - `estimated`: Uses an estimated count which is the exact count up until a threshold and the planned count when that threshold is surpassed.
6
- *
7
- * @see https://docs.postgrest.org/en/v12/references/api/pagination_count.html#counting
8
- */
9
- export type CountMethod = 'exact' | 'planned' | 'estimated';
10
- /**
11
- * Options for selecting rows from a database table.
12
- */
13
- export interface SelectOptions {
14
- /**
15
- * When set to `true`, `data` will not be returned, useful if you only need the count.
16
- */
17
- head?: boolean;
18
- /**
19
- * The method to use to count rows returned by the function.
20
- * If not set, no count will be performed.
21
- */
22
- count?: CountMethod;
23
- }
24
- export type SelectColumns<Row> = (keyof Row)[] | '*';
25
- export type Select<Row, Columns extends SelectColumns<Row> = SelectColumns<Row>> = Pick<Row, Columns extends '*' ? keyof Row : Columns[number]>;
26
- //# sourceMappingURL=select.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../lib/select.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;AACrD,MAAM,MAAM,MAAM,CACd,GAAG,EACH,OAAO,SAAS,aAAa,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,IACvD,IAAI,CAAC,GAAG,EAAE,OAAO,SAAS,GAAG,GAAG,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC"}