@supabase/postgrest-js 0.37.3 → 1.0.0-next.1
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/main/PostgrestBuilder.d.ts +24 -0
- package/dist/main/PostgrestBuilder.d.ts.map +1 -0
- package/dist/main/{lib/types.js → PostgrestBuilder.js} +26 -24
- package/dist/main/PostgrestBuilder.js.map +1 -0
- package/dist/main/PostgrestClient.d.ts +19 -20
- package/dist/main/PostgrestClient.d.ts.map +1 -1
- package/dist/main/PostgrestClient.js +37 -14
- package/dist/main/PostgrestClient.js.map +1 -1
- package/dist/main/{lib/PostgrestFilterBuilder.d.ts → PostgrestFilterBuilder.d.ts} +47 -90
- package/dist/main/PostgrestFilterBuilder.d.ts.map +1 -0
- package/dist/main/PostgrestFilterBuilder.js +162 -0
- package/dist/main/PostgrestFilterBuilder.js.map +1 -0
- package/dist/main/PostgrestQueryBuilder.d.ts +69 -0
- package/dist/main/PostgrestQueryBuilder.d.ts.map +1 -0
- package/dist/main/{lib/PostgrestQueryBuilder.js → PostgrestQueryBuilder.js} +81 -44
- package/dist/main/PostgrestQueryBuilder.js.map +1 -0
- package/dist/{module/lib → main}/PostgrestTransformBuilder.d.ts +14 -7
- package/dist/main/PostgrestTransformBuilder.d.ts.map +1 -0
- package/dist/main/{lib/PostgrestTransformBuilder.js → PostgrestTransformBuilder.js} +13 -14
- package/dist/main/PostgrestTransformBuilder.js.map +1 -0
- package/dist/main/{lib/constants.d.ts → constants.d.ts} +0 -0
- package/dist/main/constants.d.ts.map +1 -0
- package/dist/main/{lib/constants.js → constants.js} +0 -0
- package/dist/main/constants.js.map +1 -0
- package/dist/main/index.d.ts +6 -5
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +11 -9
- package/dist/main/index.js.map +1 -1
- package/dist/main/select-query-parser.d.ts +141 -0
- package/dist/main/select-query-parser.d.ts.map +1 -0
- package/dist/main/select-query-parser.js +4 -0
- package/dist/main/select-query-parser.js.map +1 -0
- package/dist/main/types.d.ts +54 -0
- package/dist/main/types.d.ts.map +1 -0
- package/dist/main/types.js +3 -0
- package/dist/main/types.js.map +1 -0
- package/dist/main/version.d.ts +2 -0
- package/dist/main/version.d.ts.map +1 -0
- package/dist/main/{lib/version.js → version.js} +1 -2
- package/dist/main/version.js.map +1 -0
- package/dist/module/PostgrestBuilder.d.ts +24 -0
- package/dist/module/PostgrestBuilder.d.ts.map +1 -0
- package/dist/module/{lib/types.js → PostgrestBuilder.js} +26 -23
- package/dist/module/PostgrestBuilder.js.map +1 -0
- package/dist/module/PostgrestClient.d.ts +19 -20
- package/dist/module/PostgrestClient.d.ts.map +1 -1
- package/dist/module/PostgrestClient.js +37 -14
- package/dist/module/PostgrestClient.js.map +1 -1
- package/dist/module/{lib/PostgrestFilterBuilder.d.ts → PostgrestFilterBuilder.d.ts} +47 -90
- package/dist/module/PostgrestFilterBuilder.d.ts.map +1 -0
- package/dist/module/PostgrestFilterBuilder.js +156 -0
- package/dist/module/PostgrestFilterBuilder.js.map +1 -0
- package/dist/module/PostgrestQueryBuilder.d.ts +69 -0
- package/dist/module/PostgrestQueryBuilder.d.ts.map +1 -0
- package/dist/module/PostgrestQueryBuilder.js +169 -0
- package/dist/module/PostgrestQueryBuilder.js.map +1 -0
- package/dist/{main/lib → module}/PostgrestTransformBuilder.d.ts +14 -7
- package/dist/module/PostgrestTransformBuilder.d.ts.map +1 -0
- package/dist/module/{lib/PostgrestTransformBuilder.js → PostgrestTransformBuilder.js} +9 -13
- package/dist/module/PostgrestTransformBuilder.js.map +1 -0
- package/dist/module/{lib/constants.d.ts → constants.d.ts} +0 -0
- package/dist/module/constants.d.ts.map +1 -0
- package/dist/module/{lib/constants.js → constants.js} +0 -0
- package/dist/module/constants.js.map +1 -0
- package/dist/module/index.d.ts +6 -5
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +5 -5
- package/dist/module/index.js.map +1 -1
- package/dist/module/select-query-parser.d.ts +141 -0
- package/dist/module/select-query-parser.d.ts.map +1 -0
- package/dist/module/select-query-parser.js +3 -0
- package/dist/module/select-query-parser.js.map +1 -0
- package/dist/module/types.d.ts +54 -0
- package/dist/module/types.d.ts.map +1 -0
- package/dist/module/types.js +2 -0
- package/dist/module/types.js.map +1 -0
- package/dist/module/version.d.ts +2 -0
- package/dist/module/version.d.ts.map +1 -0
- package/dist/module/version.js +2 -0
- package/dist/module/version.js.map +1 -0
- package/package.json +18 -19
- package/dist/main/lib/PostgrestFilterBuilder.d.ts.map +0 -1
- package/dist/main/lib/PostgrestFilterBuilder.js +0 -396
- package/dist/main/lib/PostgrestFilterBuilder.js.map +0 -1
- package/dist/main/lib/PostgrestQueryBuilder.d.ts +0 -80
- package/dist/main/lib/PostgrestQueryBuilder.d.ts.map +0 -1
- package/dist/main/lib/PostgrestQueryBuilder.js.map +0 -1
- package/dist/main/lib/PostgrestRpcBuilder.d.ts +0 -20
- package/dist/main/lib/PostgrestRpcBuilder.d.ts.map +0 -1
- package/dist/main/lib/PostgrestRpcBuilder.js +0 -41
- package/dist/main/lib/PostgrestRpcBuilder.js.map +0 -1
- package/dist/main/lib/PostgrestTransformBuilder.d.ts.map +0 -1
- package/dist/main/lib/PostgrestTransformBuilder.js.map +0 -1
- package/dist/main/lib/constants.d.ts.map +0 -1
- package/dist/main/lib/constants.js.map +0 -1
- package/dist/main/lib/types.d.ts +0 -65
- package/dist/main/lib/types.d.ts.map +0 -1
- package/dist/main/lib/types.js.map +0 -1
- package/dist/main/lib/version.d.ts +0 -2
- package/dist/main/lib/version.d.ts.map +0 -1
- package/dist/main/lib/version.js.map +0 -1
- package/dist/module/lib/PostgrestFilterBuilder.d.ts.map +0 -1
- package/dist/module/lib/PostgrestFilterBuilder.js +0 -390
- package/dist/module/lib/PostgrestFilterBuilder.js.map +0 -1
- package/dist/module/lib/PostgrestQueryBuilder.d.ts +0 -80
- package/dist/module/lib/PostgrestQueryBuilder.d.ts.map +0 -1
- package/dist/module/lib/PostgrestQueryBuilder.js +0 -132
- package/dist/module/lib/PostgrestQueryBuilder.js.map +0 -1
- package/dist/module/lib/PostgrestRpcBuilder.d.ts +0 -20
- package/dist/module/lib/PostgrestRpcBuilder.d.ts.map +0 -1
- package/dist/module/lib/PostgrestRpcBuilder.js +0 -35
- package/dist/module/lib/PostgrestRpcBuilder.js.map +0 -1
- package/dist/module/lib/PostgrestTransformBuilder.d.ts.map +0 -1
- package/dist/module/lib/PostgrestTransformBuilder.js.map +0 -1
- package/dist/module/lib/constants.d.ts.map +0 -1
- package/dist/module/lib/constants.js.map +0 -1
- package/dist/module/lib/types.d.ts +0 -65
- package/dist/module/lib/types.d.ts.map +0 -1
- package/dist/module/lib/types.js.map +0 -1
- package/dist/module/lib/version.d.ts +0 -2
- package/dist/module/lib/version.d.ts.map +0 -1
- package/dist/module/lib/version.js +0 -3
- package/dist/module/lib/version.js.map +0 -1
- package/src/PostgrestClient.ts +0 -94
- package/src/index.ts +0 -21
- package/src/lib/PostgrestFilterBuilder.ts +0 -469
- package/src/lib/PostgrestQueryBuilder.ts +0 -230
- package/src/lib/PostgrestRpcBuilder.ts +0 -58
- package/src/lib/PostgrestTransformBuilder.ts +0 -123
- package/src/lib/constants.ts +0 -2
- package/src/lib/types.ts +0 -193
- package/src/lib/version.ts +0 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Fetch, PostgrestResponse } from './types';
|
|
2
|
+
export default abstract class PostgrestBuilder<Result> implements PromiseLike<PostgrestResponse<Result>> {
|
|
3
|
+
protected method: 'GET' | 'HEAD' | 'POST' | 'PATCH' | 'DELETE';
|
|
4
|
+
protected url: URL;
|
|
5
|
+
protected headers: Record<string, string>;
|
|
6
|
+
protected schema?: string;
|
|
7
|
+
protected body?: unknown;
|
|
8
|
+
protected shouldThrowOnError: boolean;
|
|
9
|
+
protected signal?: AbortSignal;
|
|
10
|
+
protected fetch: Fetch;
|
|
11
|
+
protected allowEmpty: boolean;
|
|
12
|
+
constructor(builder: PostgrestBuilder<Result>);
|
|
13
|
+
/**
|
|
14
|
+
* If there's an error with the query, throwOnError will reject the promise by
|
|
15
|
+
* throwing the error instead of returning it as part of a successful response.
|
|
16
|
+
*
|
|
17
|
+
* {@link https://github.com/supabase/supabase-js/issues/92}
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Use `throwOnError` in the `PostgrestClient` constructor instead.
|
|
20
|
+
*/
|
|
21
|
+
throwOnError(throwOnError?: boolean): this;
|
|
22
|
+
then<TResult1 = PostgrestResponse<Result>, TResult2 = never>(onfulfilled?: ((value: PostgrestResponse<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PostgrestBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgrestBuilder.d.ts","sourceRoot":"","sources":["../../src/PostgrestBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEvD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAgB,CAAC,MAAM,CACnD,YAAW,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjD,SAAS,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC9D,SAAS,CAAC,GAAG,EAAE,GAAG,CAAA;IAClB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACxB,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAA;IACrC,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC9B,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;IACtB,SAAS,CAAC,UAAU,EAAE,OAAO,CAAA;gBAEjB,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAmB7C;;;;;;;OAOG;IACH,YAAY,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI;IAK1C,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,EACzD,WAAW,CAAC,EACR,CAAC,CAAC,KAAK,EAAE,iBAAiB,CAAC,MAAM,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GACxE,SAAS,GACT,IAAI,EACR,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,GAClF,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;CA+FpC"}
|
|
@@ -12,36 +12,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PostgrestBuilder = void 0;
|
|
16
15
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
17
16
|
class PostgrestBuilder {
|
|
18
17
|
constructor(builder) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
this.method = builder.method;
|
|
19
|
+
this.url = builder.url;
|
|
20
|
+
this.headers = builder.headers;
|
|
21
|
+
this.schema = builder.schema;
|
|
22
|
+
this.body = builder.body;
|
|
23
|
+
this.shouldThrowOnError = builder.shouldThrowOnError;
|
|
24
|
+
this.signal = builder.signal;
|
|
25
|
+
this.allowEmpty = builder.allowEmpty;
|
|
21
26
|
if (builder.fetch) {
|
|
22
|
-
|
|
27
|
+
this.fetch = builder.fetch;
|
|
23
28
|
}
|
|
24
29
|
else if (typeof fetch === 'undefined') {
|
|
25
|
-
|
|
30
|
+
this.fetch = cross_fetch_1.default;
|
|
26
31
|
}
|
|
27
32
|
else {
|
|
28
|
-
|
|
33
|
+
this.fetch = fetch;
|
|
29
34
|
}
|
|
30
|
-
this.fetch = (...args) => _fetch(...args);
|
|
31
|
-
this.shouldThrowOnError = builder.shouldThrowOnError || false;
|
|
32
|
-
this.allowEmpty = builder.allowEmpty || false;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* If there's an error with the query, throwOnError will reject the promise by
|
|
36
38
|
* throwing the error instead of returning it as part of a successful response.
|
|
37
39
|
*
|
|
38
40
|
* {@link https://github.com/supabase/supabase-js/issues/92}
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Use `throwOnError` in the `PostgrestClient` constructor instead.
|
|
39
43
|
*/
|
|
40
44
|
throwOnError(throwOnError) {
|
|
41
|
-
|
|
42
|
-
throwOnError = true;
|
|
43
|
-
}
|
|
44
|
-
this.shouldThrowOnError = throwOnError;
|
|
45
|
+
this.shouldThrowOnError = throwOnError !== null && throwOnError !== void 0 ? throwOnError : true;
|
|
45
46
|
return this;
|
|
46
47
|
}
|
|
47
48
|
then(onfulfilled, onrejected) {
|
|
@@ -58,16 +59,19 @@ class PostgrestBuilder {
|
|
|
58
59
|
if (this.method !== 'GET' && this.method !== 'HEAD') {
|
|
59
60
|
this.headers['Content-Type'] = 'application/json';
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
// NOTE: Invoke w/o `this` to avoid illegal invocation error.
|
|
63
|
+
// https://github.com/supabase/postgrest-js/pull/247
|
|
64
|
+
const _fetch = this.fetch;
|
|
65
|
+
let res = _fetch(this.url.toString(), {
|
|
62
66
|
method: this.method,
|
|
63
67
|
headers: this.headers,
|
|
64
68
|
body: JSON.stringify(this.body),
|
|
65
69
|
signal: this.signal,
|
|
66
70
|
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
67
71
|
var _a, _b, _c, _d;
|
|
68
|
-
let error =
|
|
69
|
-
let data =
|
|
70
|
-
let count =
|
|
72
|
+
let error = undefined;
|
|
73
|
+
let data = undefined;
|
|
74
|
+
let count = undefined;
|
|
71
75
|
let status = res.status;
|
|
72
76
|
let statusText = res.statusText;
|
|
73
77
|
if (res.ok) {
|
|
@@ -101,7 +105,7 @@ class PostgrestBuilder {
|
|
|
101
105
|
};
|
|
102
106
|
}
|
|
103
107
|
if (error && this.allowEmpty && ((_d = error === null || error === void 0 ? void 0 : error.details) === null || _d === void 0 ? void 0 : _d.includes('Results contain 0 rows'))) {
|
|
104
|
-
error =
|
|
108
|
+
error = undefined;
|
|
105
109
|
status = 200;
|
|
106
110
|
statusText = 'OK';
|
|
107
111
|
}
|
|
@@ -115,7 +119,6 @@ class PostgrestBuilder {
|
|
|
115
119
|
count,
|
|
116
120
|
status,
|
|
117
121
|
statusText,
|
|
118
|
-
body: data,
|
|
119
122
|
};
|
|
120
123
|
return postgrestResponse;
|
|
121
124
|
}));
|
|
@@ -127,9 +130,8 @@ class PostgrestBuilder {
|
|
|
127
130
|
hint: '',
|
|
128
131
|
code: fetchError.code || '',
|
|
129
132
|
},
|
|
130
|
-
data:
|
|
131
|
-
|
|
132
|
-
count: null,
|
|
133
|
+
data: undefined,
|
|
134
|
+
count: undefined,
|
|
133
135
|
status: 400,
|
|
134
136
|
statusText: 'Bad Request',
|
|
135
137
|
}));
|
|
@@ -137,5 +139,5 @@ class PostgrestBuilder {
|
|
|
137
139
|
return res.then(onfulfilled, onrejected);
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
|
-
exports.
|
|
141
|
-
//# sourceMappingURL=
|
|
142
|
+
exports.default = PostgrestBuilder;
|
|
143
|
+
//# sourceMappingURL=PostgrestBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgrestBuilder.js","sourceRoot":"","sources":["../../src/PostgrestBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAoC;A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EAAE;YAC5B,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC/B,KAAK,EAAE;oBACL,OAAO,EAAE,eAAe,UAAU,CAAC,OAAO,EAAE;oBAC5C,OAAO,EAAE,EAAE;oBACX,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;iBAC5B;gBACD,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,aAAa;aAC1B,CAAC,CAAC,CAAA;SACJ;QAED,OAAO,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;CACF;AAlJD,mCAkJC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import PostgrestQueryBuilder from './
|
|
2
|
-
import PostgrestFilterBuilder from './
|
|
3
|
-
import { Fetch } from './
|
|
4
|
-
export default class PostgrestClient {
|
|
1
|
+
import PostgrestQueryBuilder from './PostgrestQueryBuilder';
|
|
2
|
+
import PostgrestFilterBuilder from './PostgrestFilterBuilder';
|
|
3
|
+
import { Fetch, GenericSchema } from './types';
|
|
4
|
+
export default class PostgrestClient<Database = any, SchemaName extends string & keyof Database = 'public' extends keyof Database ? 'public' : string & keyof Database, Schema extends GenericSchema = Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any> {
|
|
5
5
|
url: string;
|
|
6
|
-
headers:
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
schema?: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
schema?: SchemaName;
|
|
10
8
|
fetch?: Fetch;
|
|
11
|
-
shouldThrowOnError
|
|
9
|
+
shouldThrowOnError: boolean;
|
|
12
10
|
/**
|
|
13
11
|
* Creates a PostgREST client.
|
|
14
12
|
*
|
|
@@ -17,10 +15,8 @@ export default class PostgrestClient {
|
|
|
17
15
|
* @param schema Postgres schema to switch to.
|
|
18
16
|
*/
|
|
19
17
|
constructor(url: string, { headers, schema, fetch, throwOnError, }?: {
|
|
20
|
-
headers?:
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
schema?: string;
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
schema?: SchemaName;
|
|
24
20
|
fetch?: Fetch;
|
|
25
21
|
throwOnError?: boolean;
|
|
26
22
|
});
|
|
@@ -28,6 +24,8 @@ export default class PostgrestClient {
|
|
|
28
24
|
* Authenticates the request with JWT.
|
|
29
25
|
*
|
|
30
26
|
* @param token The JWT token to use.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Use `headers` in constructor instead.
|
|
31
29
|
*/
|
|
32
30
|
auth(token: string): this;
|
|
33
31
|
/**
|
|
@@ -35,18 +33,19 @@ export default class PostgrestClient {
|
|
|
35
33
|
*
|
|
36
34
|
* @param table The table name to operate on.
|
|
37
35
|
*/
|
|
38
|
-
from<
|
|
36
|
+
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(table: TableName): PostgrestQueryBuilder<Table>;
|
|
39
37
|
/**
|
|
40
38
|
* Perform a function call.
|
|
41
39
|
*
|
|
42
40
|
* @param fn The function name to call.
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
41
|
+
* @param args The parameters to pass to the function call.
|
|
42
|
+
* @param options Named parameters.
|
|
43
|
+
* @param options.head When set to true, no data will be returned.
|
|
44
|
+
* @param options.count Count algorithm to use to count rows in a table.
|
|
46
45
|
*/
|
|
47
|
-
rpc<
|
|
46
|
+
rpc<FunctionName extends string & keyof Schema['Functions'], Function_ extends Schema['Functions'][FunctionName]>(fn: FunctionName, args?: Function_['Args'], { head, count, }?: {
|
|
48
47
|
head?: boolean;
|
|
49
|
-
count?:
|
|
50
|
-
}): PostgrestFilterBuilder<
|
|
48
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
49
|
+
}): PostgrestFilterBuilder<Function_['Returns'] extends any[] ? Function_['Returns'][number] extends Record<string, unknown> ? Function_['Returns'][number] : never : never, Function_['Returns']>;
|
|
51
50
|
}
|
|
52
51
|
//# sourceMappingURL=PostgrestClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgrestClient.d.ts","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"PostgrestClient.d.ts","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,sBAAsB,MAAM,0BAA0B,CAAA;AAG7D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE9C,MAAM,CAAC,OAAO,OAAO,eAAe,CAClC,QAAQ,GAAG,GAAG,EACd,UAAU,SAAS,MAAM,GAAG,MAAM,QAAQ,GAAG,QAAQ,SAAS,MAAM,QAAQ,GACxE,QAAQ,GACR,MAAM,GAAG,MAAM,QAAQ,EAC3B,MAAM,SAAS,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,aAAa,GACrE,QAAQ,CAAC,UAAU,CAAC,GACpB,GAAG;IAEP,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,kBAAkB,EAAE,OAAO,CAAA;IAE3B;;;;;;OAMG;gBAED,GAAG,EAAE,MAAM,EACX,EACE,OAAY,EACZ,MAAM,EACN,KAAK,EACL,YAAoB,GACrB,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAChC,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,KAAK,CAAC,EAAE,KAAK,CAAA;QACb,YAAY,CAAC,EAAE,OAAO,CAAA;KAClB;IASR;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKzB;;;;OAIG;IACH,IAAI,CACF,SAAS,SAAS,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,EACjD,KAAK,SAAS,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EACzC,KAAK,EAAE,SAAS,GAAG,qBAAqB,CAAC,KAAK,CAAC;IAUjD;;;;;;;;OAQG;IACH,GAAG,CACD,YAAY,SAAS,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,EACvD,SAAS,SAAS,MAAM,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,EAEnD,EAAE,EAAE,YAAY,EAChB,IAAI,GAAE,SAAS,CAAC,MAAM,CAAM,EAC5B,EACE,IAAY,EACZ,KAAK,GACN,GAAE;QACD,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAA;KACrC,GACL,sBAAsB,CACvB,SAAS,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,GAC9B,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1D,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAC5B,KAAK,GACP,KAAK,EACT,SAAS,CAAC,SAAS,CAAC,CACrB;CA8BF"}
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const PostgrestQueryBuilder_1 = __importDefault(require("./
|
|
7
|
-
const
|
|
8
|
-
const constants_1 = require("./
|
|
6
|
+
const PostgrestQueryBuilder_1 = __importDefault(require("./PostgrestQueryBuilder"));
|
|
7
|
+
const PostgrestFilterBuilder_1 = __importDefault(require("./PostgrestFilterBuilder"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
9
|
class PostgrestClient {
|
|
10
10
|
/**
|
|
11
11
|
* Creates a PostgREST client.
|
|
@@ -14,7 +14,7 @@ class PostgrestClient {
|
|
|
14
14
|
* @param headers Custom headers.
|
|
15
15
|
* @param schema Postgres schema to switch to.
|
|
16
16
|
*/
|
|
17
|
-
constructor(url, { headers = {}, schema, fetch, throwOnError, } = {}) {
|
|
17
|
+
constructor(url, { headers = {}, schema, fetch, throwOnError = false, } = {}) {
|
|
18
18
|
this.url = url;
|
|
19
19
|
this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers);
|
|
20
20
|
this.schema = schema;
|
|
@@ -25,6 +25,8 @@ class PostgrestClient {
|
|
|
25
25
|
* Authenticates the request with JWT.
|
|
26
26
|
*
|
|
27
27
|
* @param token The JWT token to use.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Use `headers` in constructor instead.
|
|
28
30
|
*/
|
|
29
31
|
auth(token) {
|
|
30
32
|
this.headers['Authorization'] = `Bearer ${token}`;
|
|
@@ -36,9 +38,9 @@ class PostgrestClient {
|
|
|
36
38
|
* @param table The table name to operate on.
|
|
37
39
|
*/
|
|
38
40
|
from(table) {
|
|
39
|
-
const url = `${this.url}/${table}
|
|
41
|
+
const url = new URL(`${this.url}/${table}`);
|
|
40
42
|
return new PostgrestQueryBuilder_1.default(url, {
|
|
41
|
-
headers: this.headers,
|
|
43
|
+
headers: Object.assign({}, this.headers),
|
|
42
44
|
schema: this.schema,
|
|
43
45
|
fetch: this.fetch,
|
|
44
46
|
shouldThrowOnError: this.shouldThrowOnError,
|
|
@@ -48,18 +50,39 @@ class PostgrestClient {
|
|
|
48
50
|
* Perform a function call.
|
|
49
51
|
*
|
|
50
52
|
* @param fn The function name to call.
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
53
|
+
* @param args The parameters to pass to the function call.
|
|
54
|
+
* @param options Named parameters.
|
|
55
|
+
* @param options.head When set to true, no data will be returned.
|
|
56
|
+
* @param options.count Count algorithm to use to count rows in a table.
|
|
54
57
|
*/
|
|
55
|
-
rpc(fn,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
rpc(fn, args = {}, { head = false, count, } = {}) {
|
|
59
|
+
let method;
|
|
60
|
+
const url = new URL(`${this.url}/rpc/${fn}`);
|
|
61
|
+
let body;
|
|
62
|
+
if (head) {
|
|
63
|
+
method = 'HEAD';
|
|
64
|
+
Object.entries(args).forEach(([name, value]) => {
|
|
65
|
+
url.searchParams.append(name, `${value}`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
method = 'POST';
|
|
70
|
+
body = args;
|
|
71
|
+
}
|
|
72
|
+
const headers = Object.assign({}, this.headers);
|
|
73
|
+
if (count) {
|
|
74
|
+
headers['Prefer'] = `count=${count}`;
|
|
75
|
+
}
|
|
76
|
+
return new PostgrestFilterBuilder_1.default({
|
|
77
|
+
method,
|
|
78
|
+
url,
|
|
79
|
+
headers,
|
|
59
80
|
schema: this.schema,
|
|
81
|
+
body,
|
|
60
82
|
fetch: this.fetch,
|
|
61
83
|
shouldThrowOnError: this.shouldThrowOnError,
|
|
62
|
-
|
|
84
|
+
allowEmpty: false,
|
|
85
|
+
});
|
|
63
86
|
}
|
|
64
87
|
}
|
|
65
88
|
exports.default = PostgrestClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgrestClient.js","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"PostgrestClient.js","sourceRoot":"","sources":["../../src/PostgrestClient.ts"],"names":[],"mappings":";;;;;AAAA,oFAA2D;AAC3D,sFAA6D;AAE7D,2CAA6C;AAG7C,MAAqB,eAAe;IAelC;;;;;;OAMG;IACH,YACE,GAAW,EAC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CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC7C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;YAC3C,CAAC,CAAC,CAAA;SACH;aAAM;YACL,MAAM,GAAG,MAAM,CAAA;YACf,IAAI,GAAG,IAAI,CAAA;SACZ;QAED,MAAM,OAAO,qBAAQ,IAAI,CAAC,OAAO,CAAE,CAAA;QACnC,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,KAAK,EAAE,CAAA;SACrC;QAED,OAAO,IAAI,gCAAsB,CAAC;YAChC,MAAM;YACN,GAAG;YACH,OAAO;YACP,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,UAAU,EAAE,KAAK;SACmC,CAAC,CAAA;IACzD,CAAC;CACF;AApID,kCAoIC"}
|
|
@@ -2,8 +2,8 @@ import PostgrestTransformBuilder from './PostgrestTransformBuilder';
|
|
|
2
2
|
/**
|
|
3
3
|
* Filters
|
|
4
4
|
*/
|
|
5
|
-
declare type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts'
|
|
6
|
-
export default class PostgrestFilterBuilder<
|
|
5
|
+
declare type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts';
|
|
6
|
+
export default class PostgrestFilterBuilder<Table extends Record<string, unknown>, Result> extends PostgrestTransformBuilder<Table, Result> {
|
|
7
7
|
/**
|
|
8
8
|
* Finds all rows which doesn't satisfy the filter.
|
|
9
9
|
*
|
|
@@ -11,7 +11,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
11
11
|
* @param operator The operator to filter with.
|
|
12
12
|
* @param value The value to filter with.
|
|
13
13
|
*/
|
|
14
|
-
not(column:
|
|
14
|
+
not<ColumnName extends string & keyof Table>(column: ColumnName, operator: FilterOperator, value: Table[ColumnName]): this;
|
|
15
|
+
not(column: string, operator: string, value: unknown): this;
|
|
15
16
|
/**
|
|
16
17
|
* Finds all rows satisfying at least one of the filters.
|
|
17
18
|
*
|
|
@@ -28,7 +29,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
28
29
|
* @param column The column to filter on.
|
|
29
30
|
* @param value The value to filter with.
|
|
30
31
|
*/
|
|
31
|
-
eq(column:
|
|
32
|
+
eq<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
33
|
+
eq(column: string, value: unknown): this;
|
|
32
34
|
/**
|
|
33
35
|
* Finds all rows whose value on the stated `column` doesn't match the
|
|
34
36
|
* specified `value`.
|
|
@@ -36,7 +38,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
36
38
|
* @param column The column to filter on.
|
|
37
39
|
* @param value The value to filter with.
|
|
38
40
|
*/
|
|
39
|
-
neq(column:
|
|
41
|
+
neq<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
42
|
+
neq(column: string, value: unknown): this;
|
|
40
43
|
/**
|
|
41
44
|
* Finds all rows whose value on the stated `column` is greater than the
|
|
42
45
|
* specified `value`.
|
|
@@ -44,7 +47,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
44
47
|
* @param column The column to filter on.
|
|
45
48
|
* @param value The value to filter with.
|
|
46
49
|
*/
|
|
47
|
-
gt(column:
|
|
50
|
+
gt<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
51
|
+
gt(column: string, value: unknown): this;
|
|
48
52
|
/**
|
|
49
53
|
* Finds all rows whose value on the stated `column` is greater than or
|
|
50
54
|
* equal to the specified `value`.
|
|
@@ -52,7 +56,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
52
56
|
* @param column The column to filter on.
|
|
53
57
|
* @param value The value to filter with.
|
|
54
58
|
*/
|
|
55
|
-
gte(column:
|
|
59
|
+
gte<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
60
|
+
gte(column: string, value: unknown): this;
|
|
56
61
|
/**
|
|
57
62
|
* Finds all rows whose value on the stated `column` is less than the
|
|
58
63
|
* specified `value`.
|
|
@@ -60,7 +65,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
60
65
|
* @param column The column to filter on.
|
|
61
66
|
* @param value The value to filter with.
|
|
62
67
|
*/
|
|
63
|
-
lt(column:
|
|
68
|
+
lt<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
69
|
+
lt(column: string, value: unknown): this;
|
|
64
70
|
/**
|
|
65
71
|
* Finds all rows whose value on the stated `column` is less than or equal
|
|
66
72
|
* to the specified `value`.
|
|
@@ -68,7 +74,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
68
74
|
* @param column The column to filter on.
|
|
69
75
|
* @param value The value to filter with.
|
|
70
76
|
*/
|
|
71
|
-
lte(column:
|
|
77
|
+
lte<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName]): this;
|
|
78
|
+
lte(column: string, value: unknown): this;
|
|
72
79
|
/**
|
|
73
80
|
* Finds all rows whose value in the stated `column` matches the supplied
|
|
74
81
|
* `pattern` (case sensitive).
|
|
@@ -76,7 +83,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
76
83
|
* @param column The column to filter on.
|
|
77
84
|
* @param pattern The pattern to filter with.
|
|
78
85
|
*/
|
|
79
|
-
like(column:
|
|
86
|
+
like<ColumnName extends string & keyof Table>(column: ColumnName, pattern: string): this;
|
|
87
|
+
like(column: string, pattern: string): this;
|
|
80
88
|
/**
|
|
81
89
|
* Finds all rows whose value in the stated `column` matches the supplied
|
|
82
90
|
* `pattern` (case insensitive).
|
|
@@ -84,7 +92,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
84
92
|
* @param column The column to filter on.
|
|
85
93
|
* @param pattern The pattern to filter with.
|
|
86
94
|
*/
|
|
87
|
-
ilike(column:
|
|
95
|
+
ilike<ColumnName extends string & keyof Table>(column: ColumnName, pattern: string): this;
|
|
96
|
+
ilike(column: string, pattern: string): this;
|
|
88
97
|
/**
|
|
89
98
|
* A check for exact equality (null, true, false), finds all rows whose
|
|
90
99
|
* value on the stated `column` exactly match the specified `value`.
|
|
@@ -92,7 +101,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
92
101
|
* @param column The column to filter on.
|
|
93
102
|
* @param value The value to filter with.
|
|
94
103
|
*/
|
|
95
|
-
is(column:
|
|
104
|
+
is<ColumnName extends string & keyof Table>(column: ColumnName, value: Table[ColumnName] & (boolean | null)): this;
|
|
105
|
+
is(column: string, value: boolean | null): this;
|
|
96
106
|
/**
|
|
97
107
|
* Finds all rows whose value on the stated `column` is found on the
|
|
98
108
|
* specified `values`.
|
|
@@ -100,7 +110,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
100
110
|
* @param column The column to filter on.
|
|
101
111
|
* @param values The values to filter with.
|
|
102
112
|
*/
|
|
103
|
-
in(column:
|
|
113
|
+
in<ColumnName extends string & keyof Table>(column: ColumnName, values: Table[ColumnName][]): this;
|
|
114
|
+
in(column: string, values: unknown[]): this;
|
|
104
115
|
/**
|
|
105
116
|
* Finds all rows whose json, array, or range value on the stated `column`
|
|
106
117
|
* contains the values specified in `value`.
|
|
@@ -108,9 +119,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
108
119
|
* @param column The column to filter on.
|
|
109
120
|
* @param value The value to filter with.
|
|
110
121
|
*/
|
|
111
|
-
contains(column:
|
|
112
|
-
|
|
113
|
-
cs: (column: keyof T, value: string | T[keyof T][] | object) => this;
|
|
122
|
+
contains<ColumnName extends string & keyof Table>(column: ColumnName, value: string | Table[ColumnName][] | Record<string, unknown>): this;
|
|
123
|
+
contains(column: string, value: string | unknown[] | Record<string, unknown>): this;
|
|
114
124
|
/**
|
|
115
125
|
* Finds all rows whose json, array, or range value on the stated `column` is
|
|
116
126
|
* contained by the specified `value`.
|
|
@@ -118,9 +128,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
118
128
|
* @param column The column to filter on.
|
|
119
129
|
* @param value The value to filter with.
|
|
120
130
|
*/
|
|
121
|
-
containedBy(column:
|
|
122
|
-
|
|
123
|
-
cd: (column: keyof T, value: string | T[keyof T][] | object) => this;
|
|
131
|
+
containedBy<ColumnName extends string & keyof Table>(column: ColumnName, value: string | Table[ColumnName][] | Record<string, unknown>): this;
|
|
132
|
+
containedBy(column: string, value: string | unknown[] | Record<string, unknown>): this;
|
|
124
133
|
/**
|
|
125
134
|
* Finds all rows whose range value on the stated `column` is strictly to the
|
|
126
135
|
* left of the specified `range`.
|
|
@@ -128,9 +137,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
128
137
|
* @param column The column to filter on.
|
|
129
138
|
* @param range The range to filter with.
|
|
130
139
|
*/
|
|
131
|
-
rangeLt(column:
|
|
132
|
-
|
|
133
|
-
sl: (column: keyof T, range: string) => this;
|
|
140
|
+
rangeLt<ColumnName extends string & keyof Table>(column: ColumnName, range: string): this;
|
|
141
|
+
rangeLt(column: string, range: string): this;
|
|
134
142
|
/**
|
|
135
143
|
* Finds all rows whose range value on the stated `column` is strictly to
|
|
136
144
|
* the right of the specified `range`.
|
|
@@ -138,9 +146,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
138
146
|
* @param column The column to filter on.
|
|
139
147
|
* @param range The range to filter with.
|
|
140
148
|
*/
|
|
141
|
-
rangeGt(column:
|
|
142
|
-
|
|
143
|
-
sr: (column: keyof T, range: string) => this;
|
|
149
|
+
rangeGt<ColumnName extends string & keyof Table>(column: ColumnName, range: string): this;
|
|
150
|
+
rangeGt(column: string, range: string): this;
|
|
144
151
|
/**
|
|
145
152
|
* Finds all rows whose range value on the stated `column` does not extend
|
|
146
153
|
* to the left of the specified `range`.
|
|
@@ -148,9 +155,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
148
155
|
* @param column The column to filter on.
|
|
149
156
|
* @param range The range to filter with.
|
|
150
157
|
*/
|
|
151
|
-
rangeGte(column:
|
|
152
|
-
|
|
153
|
-
nxl: (column: keyof T, range: string) => this;
|
|
158
|
+
rangeGte<ColumnName extends string & keyof Table>(column: ColumnName, range: string): this;
|
|
159
|
+
rangeGte(column: string, range: string): this;
|
|
154
160
|
/**
|
|
155
161
|
* Finds all rows whose range value on the stated `column` does not extend
|
|
156
162
|
* to the right of the specified `range`.
|
|
@@ -158,9 +164,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
158
164
|
* @param column The column to filter on.
|
|
159
165
|
* @param range The range to filter with.
|
|
160
166
|
*/
|
|
161
|
-
rangeLte(column:
|
|
162
|
-
|
|
163
|
-
nxr: (column: keyof T, range: string) => this;
|
|
167
|
+
rangeLte<ColumnName extends string & keyof Table>(column: ColumnName, range: string): this;
|
|
168
|
+
rangeLte(column: string, range: string): this;
|
|
164
169
|
/**
|
|
165
170
|
* Finds all rows whose range value on the stated `column` is adjacent to
|
|
166
171
|
* the specified `range`.
|
|
@@ -168,9 +173,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
168
173
|
* @param column The column to filter on.
|
|
169
174
|
* @param range The range to filter with.
|
|
170
175
|
*/
|
|
171
|
-
rangeAdjacent(column:
|
|
172
|
-
|
|
173
|
-
adj: (column: keyof T, range: string) => this;
|
|
176
|
+
rangeAdjacent<ColumnName extends string & keyof Table>(column: ColumnName, range: string): this;
|
|
177
|
+
rangeAdjacent(column: string, range: string): this;
|
|
174
178
|
/**
|
|
175
179
|
* Finds all rows whose array or range value on the stated `column` overlaps
|
|
176
180
|
* (has a value in common) with the specified `value`.
|
|
@@ -178,9 +182,8 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
178
182
|
* @param column The column to filter on.
|
|
179
183
|
* @param value The value to filter with.
|
|
180
184
|
*/
|
|
181
|
-
overlaps(column:
|
|
182
|
-
|
|
183
|
-
ov: (column: keyof T, value: string | T[keyof T][]) => this;
|
|
185
|
+
overlaps<ColumnName extends string & keyof Table>(column: ColumnName, value: string | Table[ColumnName][]): this;
|
|
186
|
+
overlaps(column: string, value: string | unknown[]): this;
|
|
184
187
|
/**
|
|
185
188
|
* Finds all rows whose text or tsvector value on the stated `column` matches
|
|
186
189
|
* the tsquery in `query`.
|
|
@@ -190,61 +193,13 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
190
193
|
* @param config The text search configuration to use.
|
|
191
194
|
* @param type The type of tsquery conversion to use on `query`.
|
|
192
195
|
*/
|
|
193
|
-
textSearch(column:
|
|
196
|
+
textSearch<ColumnName extends string & keyof Table>(column: ColumnName, query: string, options?: {
|
|
194
197
|
config?: string;
|
|
195
|
-
type?: 'plain' | 'phrase' | 'websearch'
|
|
198
|
+
type?: 'plain' | 'phrase' | 'websearch';
|
|
196
199
|
}): this;
|
|
197
|
-
|
|
198
|
-
* Finds all rows whose tsvector value on the stated `column` matches
|
|
199
|
-
* to_tsquery(`query`).
|
|
200
|
-
*
|
|
201
|
-
* @param column The column to filter on.
|
|
202
|
-
* @param query The Postgres tsquery string to filter with.
|
|
203
|
-
* @param config The text search configuration to use.
|
|
204
|
-
*
|
|
205
|
-
* @deprecated Use `textSearch()` instead.
|
|
206
|
-
*/
|
|
207
|
-
fts(column: keyof T, query: string, { config }?: {
|
|
208
|
-
config?: string;
|
|
209
|
-
}): this;
|
|
210
|
-
/**
|
|
211
|
-
* Finds all rows whose tsvector value on the stated `column` matches
|
|
212
|
-
* plainto_tsquery(`query`).
|
|
213
|
-
*
|
|
214
|
-
* @param column The column to filter on.
|
|
215
|
-
* @param query The Postgres tsquery string to filter with.
|
|
216
|
-
* @param config The text search configuration to use.
|
|
217
|
-
*
|
|
218
|
-
* @deprecated Use `textSearch()` with `type: 'plain'` instead.
|
|
219
|
-
*/
|
|
220
|
-
plfts(column: keyof T, query: string, { config }?: {
|
|
221
|
-
config?: string;
|
|
222
|
-
}): this;
|
|
223
|
-
/**
|
|
224
|
-
* Finds all rows whose tsvector value on the stated `column` matches
|
|
225
|
-
* phraseto_tsquery(`query`).
|
|
226
|
-
*
|
|
227
|
-
* @param column The column to filter on.
|
|
228
|
-
* @param query The Postgres tsquery string to filter with.
|
|
229
|
-
* @param config The text search configuration to use.
|
|
230
|
-
*
|
|
231
|
-
* @deprecated Use `textSearch()` with `type: 'phrase'` instead.
|
|
232
|
-
*/
|
|
233
|
-
phfts(column: keyof T, query: string, { config }?: {
|
|
234
|
-
config?: string;
|
|
235
|
-
}): this;
|
|
236
|
-
/**
|
|
237
|
-
* Finds all rows whose tsvector value on the stated `column` matches
|
|
238
|
-
* websearch_to_tsquery(`query`).
|
|
239
|
-
*
|
|
240
|
-
* @param column The column to filter on.
|
|
241
|
-
* @param query The Postgres tsquery string to filter with.
|
|
242
|
-
* @param config The text search configuration to use.
|
|
243
|
-
*
|
|
244
|
-
* @deprecated Use `textSearch()` with `type: 'websearch'` instead.
|
|
245
|
-
*/
|
|
246
|
-
wfts(column: keyof T, query: string, { config }?: {
|
|
200
|
+
textSearch(column: string, query: string, options?: {
|
|
247
201
|
config?: string;
|
|
202
|
+
type?: 'plain' | 'phrase' | 'websearch';
|
|
248
203
|
}): this;
|
|
249
204
|
/**
|
|
250
205
|
* Finds all rows whose `column` satisfies the filter.
|
|
@@ -253,13 +208,15 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder
|
|
|
253
208
|
* @param operator The operator to filter with.
|
|
254
209
|
* @param value The value to filter with.
|
|
255
210
|
*/
|
|
256
|
-
filter(column:
|
|
211
|
+
filter<ColumnName extends string & keyof Table>(column: ColumnName, operator: `${'' | 'not.'}${FilterOperator}`, value: unknown): this;
|
|
212
|
+
filter(column: string, operator: string, value: unknown): this;
|
|
257
213
|
/**
|
|
258
214
|
* Finds all rows whose columns match the specified `query` object.
|
|
259
215
|
*
|
|
260
216
|
* @param query The object to filter with, with column names as keys mapped
|
|
261
217
|
* to their filter values.
|
|
262
218
|
*/
|
|
219
|
+
match<ColumnName extends string & keyof Table>(query: Record<ColumnName, Table[ColumnName]>): this;
|
|
263
220
|
match(query: Record<string, unknown>): this;
|
|
264
221
|
}
|
|
265
222
|
export {};
|