@freehour/supabase-core 1.0.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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/data-service.d.ts +3136 -0
- package/dist/data-service.d.ts.map +1 -0
- package/dist/database-service.d.ts +21 -0
- package/dist/database-service.d.ts.map +1 -0
- package/dist/database.d.ts +96 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/errors.d.ts +116 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/filter.d.ts +157 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +695 -0
- package/dist/json.d.ts +4 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/postgrest-extensions.d.ts +180 -0
- package/dist/postgrest-extensions.d.ts.map +1 -0
- package/dist/relation.d.ts +29 -0
- package/dist/relation.d.ts.map +1 -0
- package/dist/select.d.ts +26 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/storage-service.d.ts +73 -0
- package/dist/storage-service.d.ts.map +1 -0
- package/dist/storage.d.ts +20 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/utils.d.ts +66 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +53 -0
- package/scripts/copy-supabase-assets.js +36 -0
- package/supabase/migrations/0000_supabase_core.sql +58 -0
- package/supabase/schemas/supabase-core/1_schemas.sql +11 -0
- package/supabase/schemas/supabase-core/2_extensions.sql +5 -0
- package/supabase/schemas/supabase-core/3_functions.sql +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-service.d.ts","sourceRoot":"","sources":["../lib/data-service.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,E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,EACR,MAAM,EACN,KAAK,GACR,EAAE,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC;CAOrD;AAED,MAAM,WAAW,qBAAqB,CAClC,QAAQ,SAAS,YAAY,CAAC,QAAQ,CAAC,EACvC,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,EACnC,IAAI,SAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CACtE,SAAQ,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;CACd;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe,CACxB,QAAQ,SAAS,YAAY,CAAC,QAAQ,CAAC,EACvC,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,EAC1D,IAAI,SAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CACtE,SAAQ,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;gBAEtC,EACR,QAAQ,EACR,MAAM,EACN,IAAI,GACP,EAAE,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;CAOnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAC/B,QAAQ,EAAE,uBAAuB,CAAC,KAAK,CAAC,GACzC,wBAAwB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAMlE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { DataService, TableDataService, ViewDataService } from './data-service';
|
|
3
|
+
import { BaseDatabase, CoreDatabase } from './database';
|
|
4
|
+
import { RelationName, RelationType, SchemaName, TableName, ViewName } from './relation';
|
|
5
|
+
export interface DatabaseServiceParams<Database> {
|
|
6
|
+
supabase: SupabaseClient<Database>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Service for interacting with a supabase database.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DatabaseService<Database extends BaseDatabase<Database> = CoreDatabase> {
|
|
12
|
+
private readonly supabase;
|
|
13
|
+
constructor({ supabase }: DatabaseServiceParams<Database>);
|
|
14
|
+
get schema(): typeof this.supabase.schema;
|
|
15
|
+
get rpc(): typeof this.supabase.rpc;
|
|
16
|
+
get from(): typeof this.supabase.from;
|
|
17
|
+
relation<Schema extends SchemaName<Database>, Relation extends RelationName<Database, Schema>>(schema: Schema, relation: Relation): DataService<Database, Schema, RelationType, Relation>;
|
|
18
|
+
table<Schema extends SchemaName<Database>, Table extends TableName<Database, Schema>>(schema: Schema, table: Table): TableDataService<Database, Schema, Table>;
|
|
19
|
+
view<Schema extends SchemaName<Database>, View extends ViewName<Database, Schema>>(schema: Schema, view: View): ViewDataService<Database, Schema, View>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=database-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-service.d.ts","sourceRoot":"","sources":["../lib/database-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG9F,MAAM,WAAW,qBAAqB,CAClC,QAAQ;IAER,QAAQ,EAAE,cAAc,CAA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
|
|
5
|
+
columns: string[];
|
|
6
|
+
isOneToOne?: boolean;
|
|
7
|
+
referencedRelation: string;
|
|
8
|
+
referencedColumns: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface GenericTable {
|
|
11
|
+
Row: Record<string, unknown>;
|
|
12
|
+
Insert: Record<string, unknown>;
|
|
13
|
+
Update: Record<string, unknown>;
|
|
14
|
+
Relationships: GenericRelationship[];
|
|
15
|
+
}
|
|
16
|
+
export interface GenericUpdatableView {
|
|
17
|
+
Row: Record<string, unknown>;
|
|
18
|
+
Insert: Record<string, unknown>;
|
|
19
|
+
Update: Record<string, unknown>;
|
|
20
|
+
Relationships: GenericRelationship[];
|
|
21
|
+
}
|
|
22
|
+
export interface GenericNonUpdatableView {
|
|
23
|
+
Row: Record<string, unknown>;
|
|
24
|
+
Relationships: GenericRelationship[];
|
|
25
|
+
}
|
|
26
|
+
export type GenericView = GenericUpdatableView | GenericNonUpdatableView;
|
|
27
|
+
export interface GenericSetofOption {
|
|
28
|
+
isSetofReturn?: boolean | undefined;
|
|
29
|
+
isOneToOne?: boolean | undefined;
|
|
30
|
+
isNotNullable?: boolean | undefined;
|
|
31
|
+
to: string;
|
|
32
|
+
from: string;
|
|
33
|
+
}
|
|
34
|
+
export interface GenericFunction {
|
|
35
|
+
Args: Record<string, unknown>;
|
|
36
|
+
Returns: unknown;
|
|
37
|
+
SetofOptions?: GenericSetofOption;
|
|
38
|
+
}
|
|
39
|
+
export interface GenericSchema {
|
|
40
|
+
Tables: Record<string, GenericTable>;
|
|
41
|
+
Views: Record<string, GenericView>;
|
|
42
|
+
Functions: Record<string, GenericFunction>;
|
|
43
|
+
}
|
|
44
|
+
export type GenericDatabase<K extends string = string> = Record<K, GenericSchema>;
|
|
45
|
+
export interface StorageObjectMetadata {
|
|
46
|
+
eTag: string;
|
|
47
|
+
size: number;
|
|
48
|
+
mimetype: string;
|
|
49
|
+
cacheControl: string;
|
|
50
|
+
lastModified: string;
|
|
51
|
+
contentLength: number;
|
|
52
|
+
httpStatusCode: number;
|
|
53
|
+
}
|
|
54
|
+
export interface StorageObjectsTable extends GenericTable {
|
|
55
|
+
Row: {
|
|
56
|
+
bucket_id: string | null;
|
|
57
|
+
created_at: string | null;
|
|
58
|
+
id: string;
|
|
59
|
+
last_accessed_at: string | null;
|
|
60
|
+
metadata: StorageObjectMetadata | null;
|
|
61
|
+
name: string | null;
|
|
62
|
+
owner: string | null;
|
|
63
|
+
owner_id: string | null;
|
|
64
|
+
path_tokens: string[] | null;
|
|
65
|
+
updated_at: string | null;
|
|
66
|
+
user_metadata: Json | null;
|
|
67
|
+
version: string | null;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface StorageSchema extends GenericSchema {
|
|
71
|
+
Tables: {
|
|
72
|
+
objects: StorageObjectsTable;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface FuzzySearchFunction extends GenericFunction {
|
|
76
|
+
Args: {
|
|
77
|
+
column_name: string;
|
|
78
|
+
limit_results?: number;
|
|
79
|
+
min_similarity?: number;
|
|
80
|
+
schema_name?: string;
|
|
81
|
+
search_term: string;
|
|
82
|
+
relation: string;
|
|
83
|
+
};
|
|
84
|
+
Returns: Json[];
|
|
85
|
+
}
|
|
86
|
+
export interface CoreSchema extends GenericSchema {
|
|
87
|
+
Functions: {
|
|
88
|
+
fuzzy_search: FuzzySearchFunction;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface CoreDatabase {
|
|
92
|
+
storage: StorageSchema;
|
|
93
|
+
core: CoreSchema;
|
|
94
|
+
}
|
|
95
|
+
export type BaseDatabase<Database> = GenericDatabase<KeyOfString<Database>> & CoreDatabase;
|
|
96
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../lib/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,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I,CAAC;KAC1B,CAAC;CACL;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAChD,MAAM,EAAE;QACJ,OAAO,EAAE,mBAAmB,CAAC;KAChC,CAAC;CACL;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IACxD,IAAI,EAAE;QACF,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC7C,SAAS,EAAE;QACP,YAAY,EAAE,mBAAmB,CAAC;KACrC,CAAC;CACL;AAED,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,IAAI,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,CAAC,QAAQ,IAAI,eAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
import { PostgrestError } from '@supabase/supabase-js';
|
|
3
|
+
/**
|
|
4
|
+
* Automatically sets the name and captures the stack trace for the error.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TracedError extends Error {
|
|
7
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
export interface FileNotFoundErrorOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the file that was not found.
|
|
12
|
+
*/
|
|
13
|
+
fileId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The name of the bucket where the file was expected to be found.
|
|
16
|
+
*/
|
|
17
|
+
bucket?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The path relative to the bucket root where the file was expected to be found.
|
|
20
|
+
*/
|
|
21
|
+
path?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error indicating that a file with a specified ID could not be found in storage.
|
|
25
|
+
*/
|
|
26
|
+
export declare class FileNotFoundError extends TracedError {
|
|
27
|
+
/**
|
|
28
|
+
* The ID of the file that was not found.
|
|
29
|
+
*/
|
|
30
|
+
readonly fileId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the bucket where the file was expected to be found.
|
|
33
|
+
*/
|
|
34
|
+
readonly bucket?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The path relative to the bucket root where the file was expected to be found.
|
|
37
|
+
*/
|
|
38
|
+
readonly path?: string;
|
|
39
|
+
constructor(message: string, { fileId, bucket, path, }?: FileNotFoundErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
export interface ParseErrorOptions extends ErrorOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The encountered expression that could not be parsed.
|
|
44
|
+
*/
|
|
45
|
+
expression?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Additional context about the expected format or structure.
|
|
48
|
+
*/
|
|
49
|
+
format?: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An error that indicates that an expression could not be parsed.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ParseError extends TracedError {
|
|
55
|
+
/**
|
|
56
|
+
* The encountered expression that could not be parsed.
|
|
57
|
+
*/
|
|
58
|
+
readonly expression?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Additional context about the expected format or structure.
|
|
61
|
+
*/
|
|
62
|
+
readonly format?: unknown;
|
|
63
|
+
constructor(message?: string, { expression, format, ...options }?: ParseErrorOptions);
|
|
64
|
+
}
|
|
65
|
+
export interface RecordNotFoundErrorOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The schema where the record was expected to be found.
|
|
68
|
+
*/
|
|
69
|
+
schema?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The table or view where the record was expected to be found.
|
|
72
|
+
*/
|
|
73
|
+
relation?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The ID of the record that was not found.
|
|
76
|
+
*/
|
|
77
|
+
id?: string | number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error indicating that a record with a specified ID could not be found in a database table or view.
|
|
81
|
+
* It can provide more context about the missing record, such as the schema and relation it was expected to be in.
|
|
82
|
+
* Note this is a very generic error that is thrown by the `DataService`,
|
|
83
|
+
* you may want to throw a more specific error in the service that uses it.
|
|
84
|
+
*/
|
|
85
|
+
export declare class RecordNotFoundError extends TracedError {
|
|
86
|
+
/**
|
|
87
|
+
* The schema where the record was expected to be found.
|
|
88
|
+
*/
|
|
89
|
+
readonly schema?: string;
|
|
90
|
+
/**
|
|
91
|
+
* The table or view where the record was expected to be found.
|
|
92
|
+
*/
|
|
93
|
+
readonly relation?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The ID of the record that was not found.
|
|
96
|
+
*/
|
|
97
|
+
readonly id?: string | number;
|
|
98
|
+
constructor(message: string, { schema, relation, id, }?: RecordNotFoundErrorOptions);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* PostgREST errors are sometimes returned in this format instead of the declared PostgrestError class.
|
|
102
|
+
*/
|
|
103
|
+
export declare const PostgrestErrorInterface: z.ZodObject<{
|
|
104
|
+
code: z.ZodString;
|
|
105
|
+
details: z.ZodNullable<z.ZodString>;
|
|
106
|
+
hint: z.ZodNullable<z.ZodString>;
|
|
107
|
+
name: z.ZodOptional<z.ZodString>;
|
|
108
|
+
message: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export type PostgrestErrorInterface = z.infer<typeof PostgrestErrorInterface>;
|
|
111
|
+
/**
|
|
112
|
+
* An error indicating that a database request failed.
|
|
113
|
+
*/
|
|
114
|
+
export type DatabaseApiError = PostgrestError | PostgrestErrorInterface;
|
|
115
|
+
export declare function isDatabaseApiError(error: unknown): error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b,GAAE,iBAAsB;CAMhC;AAGD,MAAM,WAAW,0BAA0B;IACvC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAChD;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;gBAG1B,OAAO,EAAE,MAAM,EACf,EACI,MAAM,EACN,QAAQ,EACR,EAAE,GACL,GAAE,0BAA+B;CAOzC;AAGD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;iBAgB9B,CAAC;AAEP,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,uBAAuB,CAAC;AAExE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E"}
|
package/dist/filter.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ZodObject, default as z } from 'zod';
|
|
2
|
+
import { KeyOfString } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Type of filterable items.
|
|
5
|
+
* They must have a string key to form valid filter expressions.
|
|
6
|
+
*/
|
|
7
|
+
export type FilterItem = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Filter operators.
|
|
10
|
+
* @see https://postgrest.org/en/stable/api.html#operators
|
|
11
|
+
*/
|
|
12
|
+
export declare const FilterOp: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "like", "ilike", "match", "imatch", "in", "is", "isdistinct", "fts", "plfts", "phfts", "wfts", "cs", "cd", "ov", "sl", "sr", "nxr", "nxl", "adj"];
|
|
13
|
+
export type FilterOp = `${'' | 'not.'}${typeof FilterOp[number]}`;
|
|
14
|
+
/**
|
|
15
|
+
* Logical operators for combining filters.
|
|
16
|
+
* These operators can be used to create complex filter expressions.
|
|
17
|
+
* @see https://docs.postgrest.org/en/stable/api.html#logical-operators
|
|
18
|
+
*/
|
|
19
|
+
export declare const LogicalOp: readonly ["and", "or"];
|
|
20
|
+
export type LogicalOp = `${'' | 'not.'}${typeof LogicalOp[number]}`;
|
|
21
|
+
/**
|
|
22
|
+
* The separator used to split multiple filter expressions in a logical operator (e.g. `and`, `or`).
|
|
23
|
+
*/
|
|
24
|
+
export declare const LogicalOpSeparator = ",";
|
|
25
|
+
/**
|
|
26
|
+
* The operator for chaining multiple filters.
|
|
27
|
+
* This is a short notation for cascading filters with and().
|
|
28
|
+
*
|
|
29
|
+
* ***NOTE:*** PostgREST uses `&` to separate filters, but we use `~` as `&` is reserved for top-level query parameters.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // The following filter expressions are equivalent:
|
|
33
|
+
* 'name.cs.John~age.gt.30~createdAt.gte.2023-01-01'
|
|
34
|
+
* 'and(name.cs.John,and(age.gt.30,createdAt.gte.2023-01-01))'.
|
|
35
|
+
* @see https://docs.postgrest.org/en/stable/api.html#horizontal-filtering
|
|
36
|
+
*/
|
|
37
|
+
export declare const FilterChainSeparator = "~";
|
|
38
|
+
/**
|
|
39
|
+
* A single filter conddition in an abstract syntax tree (AST) of filter nodes.
|
|
40
|
+
* @param K The type of keys in the filter expression.
|
|
41
|
+
* @return The Zod schema representing the filter condition node.
|
|
42
|
+
*/
|
|
43
|
+
export interface FilterConditionNode<K extends string = string> {
|
|
44
|
+
type: 'condition';
|
|
45
|
+
op: FilterOp;
|
|
46
|
+
value: string | number | boolean | null;
|
|
47
|
+
key: K;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A logical operator in an abstract syntax tree (AST) of filter nodes.
|
|
51
|
+
* This node combines multiple filter expressions using logical operators like `and` or `or`.
|
|
52
|
+
*
|
|
53
|
+
* @template K The type of keys in the filter expressions.
|
|
54
|
+
* @param keys The list of valid keys in the filter expressions.
|
|
55
|
+
* @returns The Zod schema representing the logical filter node.
|
|
56
|
+
*/
|
|
57
|
+
export interface FilterLogicalNode<K extends string = string> {
|
|
58
|
+
type: 'logical';
|
|
59
|
+
op: LogicalOp;
|
|
60
|
+
args: FilterNode<K>[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A node in the abstract syntax tree (AST) representing any filter expression.
|
|
64
|
+
* It can be either a filter condition or a logical operator.
|
|
65
|
+
*
|
|
66
|
+
* @template K The type of keys in the filter expressions.
|
|
67
|
+
* @param keys The list of valid keys in the filter expressions.
|
|
68
|
+
* @returns The Zod schema representing the filter node.
|
|
69
|
+
*/
|
|
70
|
+
export type FilterNode<K extends string = string> = FilterConditionNode<K> | FilterLogicalNode<K>;
|
|
71
|
+
/**
|
|
72
|
+
* A filter key is a string that represents a key in a filter condition.
|
|
73
|
+
* It can be any key from the item being filtered, excluding symbols and numbers.
|
|
74
|
+
* @example
|
|
75
|
+
* For an item like `{ name: string, age: number }`, the filter keys would be `'name'` and `'age'`.
|
|
76
|
+
* @template Item The type of the item being filtered.
|
|
77
|
+
*/
|
|
78
|
+
export type FilterKey<Item extends object> = KeyOfString<Item>;
|
|
79
|
+
/**
|
|
80
|
+
* An array of filter AST nodes, representing a chain of filter expressions joined by a logical `and`.
|
|
81
|
+
* It can be decoded from a string containing one or more filter expressions, chained with the {@link FilterChainSeparator chain separator `~`} .
|
|
82
|
+
*/
|
|
83
|
+
export declare const Filter: <Item extends ZodObject>(item: Item) => <DecodeKey extends string = string>(mapping?: Partial<Record<FilterKey<z.infer<Item>>, DecodeKey>>) => z.ZodPipe<z.ZodString, z.ZodTransform<Filter<DecodeKey>, string>>;
|
|
84
|
+
export type Filter<K extends string = string> = FilterNode<K>[];
|
|
85
|
+
/**
|
|
86
|
+
* Negates a filter or logical operator.
|
|
87
|
+
*
|
|
88
|
+
* If the operator starts with 'not.', it removes the 'not.' prefix.
|
|
89
|
+
* Otherwise, it adds 'not.' as a prefix.
|
|
90
|
+
*
|
|
91
|
+
* @param op The filter or logical operator to negate.
|
|
92
|
+
* @returns The negated operator.
|
|
93
|
+
*/
|
|
94
|
+
export declare function negateOp<Op extends FilterOp | LogicalOp>(op: Op): Op;
|
|
95
|
+
/**
|
|
96
|
+
* Negates a filter AST node, by applying the negation to its operator.
|
|
97
|
+
*
|
|
98
|
+
* @param node The filter AST node to negate.
|
|
99
|
+
* @returns The negated filter.
|
|
100
|
+
*/
|
|
101
|
+
export declare function negateFilterNode<K extends string = string, F extends FilterNode<K> = FilterNode<K>>(node: F): F;
|
|
102
|
+
/**
|
|
103
|
+
* Encodes a filter AST node into a filter expression string.
|
|
104
|
+
* The expression follows the dot notation of [PostgREST](https://docs.postgrest.org/en/v13/references/api/tables_views.html#horizontal-filtering).
|
|
105
|
+
*
|
|
106
|
+
* @template InputKey - The type of keys in the filter AST.
|
|
107
|
+
* @template OutputKey - The type of keys in the expression.
|
|
108
|
+
* @param node The filter AST node to encode to a string.
|
|
109
|
+
* @param transformKey An optional function to transform keys from InputKey to OutputKey.
|
|
110
|
+
* @returns The encoded filter expression as a string.
|
|
111
|
+
* @see https://docs.postgrest.org/en/stable/api.html#horizontal-filtering
|
|
112
|
+
*/
|
|
113
|
+
export declare function encodeFilterNode<K extends string = string>(node: FilterNode<K>, transformKey?: (key: K) => string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Encodes a filter (an array of filter AST nodes) into a filter string
|
|
116
|
+
* containing one or more filter expressions separated by a filter separator.
|
|
117
|
+
*
|
|
118
|
+
* @template InputKey - The type of keys in the filter AST nodes.
|
|
119
|
+
* @template OutputKey - The type of keys in the filter string.
|
|
120
|
+
* @param filter The filter to encode.
|
|
121
|
+
* @param transformKey An optional function to transform keys from InputKey to OutputKey.
|
|
122
|
+
* @param separator The separator used to join multiple filter expressions. Default is the {@link FilterChainSeparator chain separator `~`} .
|
|
123
|
+
* @returns The encoded filter string.
|
|
124
|
+
*/
|
|
125
|
+
export declare function encodeFilter<K extends string = string>(filter: Filter<K>, transformKey?: (key: K) => string, separator?: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Parses a filter expression into a filter AST node.
|
|
128
|
+
* The expression must follow the dot notation of [PostgREST](https://docs.postgrest.org/en/v13/references/api/tables_views.html#horizontal-filtering).
|
|
129
|
+
* See also {@link parseFilterExpressionChain}.
|
|
130
|
+
*
|
|
131
|
+
* @template InputKey - The type of keys in the filter expression.
|
|
132
|
+
* @template OutputKey - The type of keys in the filter AST node.
|
|
133
|
+
* @param expression The filter expression to parse.
|
|
134
|
+
* @param inputKeys An optional list of valid input keys.
|
|
135
|
+
* This is used to validate the keys in the expression. If not provided, any key is valid.
|
|
136
|
+
* @param transformKey An optional function to transform keys from InputKey to OutputKey.
|
|
137
|
+
* @returns The parsed filter AST node.
|
|
138
|
+
* @throws ParseError if any expression in the filter string can not be parsed, e.g. has invalid syntax, unsupported operators or unsupported keys.
|
|
139
|
+
*/
|
|
140
|
+
export declare function parseFilterExpression<InputKey extends string = string, OutputKey extends string = InputKey>(expression: string, inputKeys?: InputKey[], transformKey?: (key: InputKey) => OutputKey): FilterNode<OutputKey>;
|
|
141
|
+
/**
|
|
142
|
+
* Parses a chain of filter expressions into a filter (an array of filter AST nodes).
|
|
143
|
+
* Filter expressions are chained together using a filter separator.
|
|
144
|
+
* Each expression in the chain must follow the dot notation of [PostgREST](https://docs.postgrest.org/en/v13/references/api/tables_views.html#horizontal-filtering).
|
|
145
|
+
*
|
|
146
|
+
* @template InputKey - The type of keys in the filter expressions.
|
|
147
|
+
* @template OutputKey - The type of keys in the filter AST nodes.
|
|
148
|
+
* @param expressions The filter string containing one or more filter expressions, chained together by the {@link separator}.
|
|
149
|
+
* @param inputKeys The list of valid keys in the filter expressions.
|
|
150
|
+
* This is used to validate the keys in the expressions. If not provided, any key is valid.
|
|
151
|
+
* @param transformKey An optional function to transform keys from InputKey to OutputKey.
|
|
152
|
+
* @param separator - The separator used to split multiple filter expressions. Default is the {@link FilterChainSeparator chain separator `~`} .
|
|
153
|
+
* @returns An array of filter AST nodes parsed from the filter string. An empty string will resolve to an empty array.
|
|
154
|
+
* @throws ParseError if any expression in the filter string can not be parsed, e.g. has invalid syntax, unsupported operators or unsupported keys.
|
|
155
|
+
*/
|
|
156
|
+
export declare function parseFilterExpressionChain<InputKey extends string = string, OutputKey extends string = InputKey>(expressions: string, inputKeys?: InputKey[], transformKey?: (key: InputKey) => OutputKey, separator?: string): FilterNode<OutputKey>[];
|
|
157
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,QAAQ,oMAAqM,CAAC;AAC3N,MAAM,MAAM,QAAQ,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,SAAS,wBAAyB,CAAC;AAChD,MAAM,MAAM,SAAS,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;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2
|
+
export * from './database-service';
|
|
3
|
+
export type * from './database';
|
|
4
|
+
export * from './errors';
|
|
5
|
+
export * from './filter';
|
|
6
|
+
export type * from './json';
|
|
7
|
+
export * from './postgrest-extensions';
|
|
8
|
+
export type * from './relation';
|
|
9
|
+
export type * from './select';
|
|
10
|
+
export * from './storage-service';
|
|
11
|
+
export * from './storage';
|
|
12
|
+
export * from './utils';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,mBAAmB,YAAY,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,mBAAmB,QAAQ,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,UAAU,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|