@supabase/postgrest-js 1.21.3 → 2.71.2-canary.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/package.json +17 -19
- package/src/PostgrestBuilder.ts +3 -3
- package/src/PostgrestClient.ts +2 -2
- package/src/PostgrestFilterBuilder.ts +25 -25
- package/src/PostgrestQueryBuilder.ts +2 -2
- package/src/PostgrestTransformBuilder.ts +3 -3
- package/src/select-query-parser/parser.ts +233 -226
- package/src/select-query-parser/result.ts +233 -233
- package/src/select-query-parser/types.ts +15 -17
- package/src/select-query-parser/utils.ts +237 -227
- package/src/types.ts +40 -40
- package/src/version.ts +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/PostgrestBuilder.d.ts +0 -71
- package/dist/cjs/PostgrestBuilder.d.ts.map +0 -1
- package/dist/cjs/PostgrestBuilder.js +0 -222
- package/dist/cjs/PostgrestBuilder.js.map +0 -1
- package/dist/cjs/PostgrestClient.d.ts +0 -74
- package/dist/cjs/PostgrestClient.d.ts.map +0 -1
- package/dist/cjs/PostgrestClient.js +0 -121
- package/dist/cjs/PostgrestClient.js.map +0 -1
- package/dist/cjs/PostgrestError.d.ts +0 -17
- package/dist/cjs/PostgrestError.d.ts.map +0 -1
- package/dist/cjs/PostgrestError.js +0 -18
- package/dist/cjs/PostgrestError.js.map +0 -1
- package/dist/cjs/PostgrestFilterBuilder.d.ts +0 -108
- package/dist/cjs/PostgrestFilterBuilder.d.ts.map +0 -1
- package/dist/cjs/PostgrestFilterBuilder.js +0 -381
- package/dist/cjs/PostgrestFilterBuilder.js.map +0 -1
- package/dist/cjs/PostgrestQueryBuilder.d.ts +0 -117
- package/dist/cjs/PostgrestQueryBuilder.d.ts.map +0 -1
- package/dist/cjs/PostgrestQueryBuilder.js +0 -251
- package/dist/cjs/PostgrestQueryBuilder.js.map +0 -1
- package/dist/cjs/PostgrestTransformBuilder.d.ts +0 -157
- package/dist/cjs/PostgrestTransformBuilder.d.ts.map +0 -1
- package/dist/cjs/PostgrestTransformBuilder.js +0 -226
- package/dist/cjs/PostgrestTransformBuilder.js.map +0 -1
- package/dist/cjs/constants.d.ts +0 -4
- package/dist/cjs/constants.d.ts.map +0 -1
- package/dist/cjs/constants.js +0 -6
- package/dist/cjs/constants.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -19
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -28
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/select-query-parser/parser.d.ts +0 -261
- package/dist/cjs/select-query-parser/parser.d.ts.map +0 -1
- package/dist/cjs/select-query-parser/parser.js +0 -5
- package/dist/cjs/select-query-parser/parser.js.map +0 -1
- package/dist/cjs/select-query-parser/result.d.ts +0 -157
- package/dist/cjs/select-query-parser/result.d.ts.map +0 -1
- package/dist/cjs/select-query-parser/result.js +0 -3
- package/dist/cjs/select-query-parser/result.js.map +0 -1
- package/dist/cjs/select-query-parser/types.d.ts +0 -31
- package/dist/cjs/select-query-parser/types.d.ts.map +0 -1
- package/dist/cjs/select-query-parser/types.js +0 -3
- package/dist/cjs/select-query-parser/types.js.map +0 -1
- package/dist/cjs/select-query-parser/utils.d.ts +0 -264
- package/dist/cjs/select-query-parser/utils.d.ts.map +0 -1
- package/dist/cjs/select-query-parser/utils.js +0 -3
- package/dist/cjs/select-query-parser/utils.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -106
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/version.d.ts +0 -2
- package/dist/cjs/version.d.ts.map +0 -1
- package/dist/cjs/version.js +0 -5
- package/dist/cjs/version.js.map +0 -1
- package/dist/esm/wrapper.mjs +0 -28
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/postgrest-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.71.2-canary.0",
|
|
4
4
|
"description": "Isomorphic PostgREST client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postgrest",
|
|
7
7
|
"supabase"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/supabase/postgrest-js",
|
|
10
|
-
"bugs": "https://github.com/supabase/
|
|
9
|
+
"homepage": "https://github.com/supabase/supabase-js-libs/tree/main/packages/core/postgrest-js",
|
|
10
|
+
"bugs": "https://github.com/supabase/supabase-js-libs/issues",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Supabase",
|
|
13
13
|
"files": [
|
|
@@ -27,21 +27,27 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"types": "./dist/cjs/index.d.ts",
|
|
30
|
-
"repository":
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/supabase/supabase-js-libs.git",
|
|
33
|
+
"directory": "packages/core/postgrest-js"
|
|
34
|
+
},
|
|
31
35
|
"scripts": {
|
|
32
36
|
"clean": "rimraf dist docs/v2",
|
|
33
37
|
"format": "prettier --write \"{src,test}/**/*.ts\" wrapper.mjs",
|
|
34
38
|
"format:check": "prettier --check \"{src,test}/**/*.ts\"",
|
|
35
|
-
"build": "run
|
|
39
|
+
"build": "npm run clean && npm run format && npm run build:cjs && npm run build:esm",
|
|
36
40
|
"build:cjs": "tsc -p tsconfig.json",
|
|
37
41
|
"build:esm": "cpy wrapper.mjs dist/esm/",
|
|
38
42
|
"docs": "typedoc src/index.ts --out docs/v2",
|
|
39
43
|
"docs:json": "typedoc --json docs/v2/spec.json --excludeExternals src/index.ts",
|
|
40
|
-
"test": "run
|
|
44
|
+
"test": "npm run format:check && npm run test:types && npm run db:clean && npm run db:run && npm run test:generated-types && npm run test:run && npm run db:clean && node test/smoke.cjs && node test/smoke.mjs",
|
|
45
|
+
"test:ci": "npm run format:check && npm run test:types:ci && npm run db:clean && npm run db:run && npm run test:generated-types && npm run test:run && npm run db:clean && node test/smoke.cjs && node test/smoke.mjs",
|
|
41
46
|
"test:run": "jest --runInBand --coverage",
|
|
42
|
-
"test:generated-types": "run
|
|
43
|
-
"test:update": "run
|
|
44
|
-
"test:types": "run
|
|
47
|
+
"test:generated-types": "npm run db:generate-test-types && git diff --exit-code test/types.generated.ts || (echo '❌ Generated types are not up to date. Run npm run db:generate-test-types.' && exit 1)",
|
|
48
|
+
"test:update": "npm run db:clean && npm run db:run && npm run db:generate-test-types && jest --runInBand --updateSnapshot && npm run db:clean",
|
|
49
|
+
"test:types": "npm run build && tstyche",
|
|
50
|
+
"test:types:ci": "npm run build && tstyche --target '4.7,5.5,latest'",
|
|
45
51
|
"test:types:watch": "chokidar 'src/**/*.ts' 'test/**/*.ts' -c 'npm run test:types'",
|
|
46
52
|
"type-check": "tsc --noEmit --project tsconfig.json",
|
|
47
53
|
"type-check:test": "tsc --noEmit --project tsconfig.test.json",
|
|
@@ -50,24 +56,16 @@
|
|
|
50
56
|
"db:generate-test-types": "cd test/db && docker compose up --detach && wait-for-localhost 8080 && curl --location 'http://0.0.0.0:8080/generators/typescript?included_schemas=public,personal&detect_one_to_one_relationships=true' > ../types.generated.ts && node ../scripts/update-json-type.js && prettier --write ../types.generated.ts"
|
|
51
57
|
},
|
|
52
58
|
"dependencies": {
|
|
53
|
-
"@supabase/node-fetch": "
|
|
59
|
+
"@supabase/node-fetch": "2.6.15"
|
|
54
60
|
},
|
|
55
61
|
"devDependencies": {
|
|
56
|
-
"@types/jest": "^27.5.1",
|
|
57
62
|
"chokidar-cli": "^3.0.0",
|
|
58
63
|
"cpy-cli": "^5.0.0",
|
|
59
64
|
"jest": "^28.1.0",
|
|
60
65
|
"node-abort-controller": "^3.0.1",
|
|
61
|
-
"npm-run-all": "^4.1.5",
|
|
62
|
-
"prettier": "^2.6.2",
|
|
63
|
-
"rimraf": "^3.0.2",
|
|
64
|
-
"semantic-release-plugin-update-version-in-files": "^1.1.0",
|
|
65
|
-
"ts-expect": "^1.3.0",
|
|
66
66
|
"ts-jest": "^28.0.3",
|
|
67
|
-
"
|
|
67
|
+
"tstyche": "^4.3.0",
|
|
68
68
|
"type-fest": "^4.32.0",
|
|
69
|
-
"typedoc": "^0.22.16",
|
|
70
|
-
"typescript": "^4.5.5",
|
|
71
69
|
"wait-for-localhost-cli": "^3.0.0",
|
|
72
70
|
"zod": "^3.25.76"
|
|
73
71
|
}
|
package/src/PostgrestBuilder.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { ContainsNull } from './select-query-parser/types'
|
|
|
16
16
|
export default abstract class PostgrestBuilder<
|
|
17
17
|
ClientOptions extends ClientServerOptions,
|
|
18
18
|
Result,
|
|
19
|
-
ThrowOnError extends boolean = false
|
|
19
|
+
ThrowOnError extends boolean = false,
|
|
20
20
|
> implements
|
|
21
21
|
PromiseLike<
|
|
22
22
|
ThrowOnError extends true ? PostgrestResponseSuccess<Result> : PostgrestSingleResponse<Result>
|
|
@@ -85,7 +85,7 @@ export default abstract class PostgrestBuilder<
|
|
|
85
85
|
TResult1 = ThrowOnError extends true
|
|
86
86
|
? PostgrestResponseSuccess<Result>
|
|
87
87
|
: PostgrestSingleResponse<Result>,
|
|
88
|
-
TResult2 = never
|
|
88
|
+
TResult2 = never,
|
|
89
89
|
>(
|
|
90
90
|
onfulfilled?:
|
|
91
91
|
| ((
|
|
@@ -275,7 +275,7 @@ export default abstract class PostgrestBuilder<
|
|
|
275
275
|
*/
|
|
276
276
|
overrideTypes<
|
|
277
277
|
NewResult,
|
|
278
|
-
Options extends { merge?: boolean } = { merge: true }
|
|
278
|
+
Options extends { merge?: boolean } = { merge: true },
|
|
279
279
|
>(): PostgrestBuilder<
|
|
280
280
|
ClientOptions,
|
|
281
281
|
IsValidResultOverride<Result, NewResult, false, false> extends true
|
package/src/PostgrestClient.ts
CHANGED
|
@@ -31,7 +31,7 @@ export default class PostgrestClient<
|
|
|
31
31
|
'__InternalSupabase'
|
|
32
32
|
>[SchemaName] extends GenericSchema
|
|
33
33
|
? Omit<Database, '__InternalSupabase'>[SchemaName]
|
|
34
|
-
: any
|
|
34
|
+
: any,
|
|
35
35
|
> {
|
|
36
36
|
url: string
|
|
37
37
|
headers: Headers
|
|
@@ -67,7 +67,7 @@ export default class PostgrestClient<
|
|
|
67
67
|
}
|
|
68
68
|
from<
|
|
69
69
|
TableName extends string & keyof Schema['Tables'],
|
|
70
|
-
Table extends Schema['Tables'][TableName]
|
|
70
|
+
Table extends Schema['Tables'][TableName],
|
|
71
71
|
>(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>
|
|
72
72
|
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
|
|
73
73
|
relation: ViewName
|
|
@@ -38,27 +38,27 @@ export type IsStringOperator<Path extends string> = Path extends `${string}->>${
|
|
|
38
38
|
type ResolveFilterValue<
|
|
39
39
|
Schema extends GenericSchema,
|
|
40
40
|
Row extends Record<string, unknown>,
|
|
41
|
-
ColumnName extends string
|
|
41
|
+
ColumnName extends string,
|
|
42
42
|
> = ColumnName extends `${infer RelationshipTable}.${infer Remainder}`
|
|
43
43
|
? Remainder extends `${infer _}.${infer _}`
|
|
44
44
|
? ResolveFilterValue<Schema, Row, Remainder>
|
|
45
45
|
: ResolveFilterRelationshipValue<Schema, RelationshipTable, Remainder>
|
|
46
46
|
: ColumnName extends keyof Row
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
? Row[ColumnName]
|
|
48
|
+
: // If the column selection is a jsonpath like `data->value` or `data->>value` we attempt to match
|
|
49
|
+
// the expected type with the parsed custom json type
|
|
50
|
+
IsStringOperator<ColumnName> extends true
|
|
51
|
+
? string
|
|
52
|
+
: JsonPathToType<Row, JsonPathToAccessor<ColumnName>> extends infer JsonPathValue
|
|
53
|
+
? JsonPathValue extends never
|
|
54
|
+
? never
|
|
55
|
+
: JsonPathValue
|
|
56
|
+
: never
|
|
57
57
|
|
|
58
58
|
type ResolveFilterRelationshipValue<
|
|
59
59
|
Schema extends GenericSchema,
|
|
60
60
|
RelationshipTable extends string,
|
|
61
|
-
RelationshipColumn extends string
|
|
61
|
+
RelationshipColumn extends string,
|
|
62
62
|
> = Schema['Tables'] & Schema['Views'] extends infer TablesAndViews
|
|
63
63
|
? RelationshipTable extends keyof TablesAndViews
|
|
64
64
|
? 'Row' extends keyof TablesAndViews[RelationshipTable]
|
|
@@ -78,7 +78,7 @@ export default class PostgrestFilterBuilder<
|
|
|
78
78
|
Result,
|
|
79
79
|
RelationName = unknown,
|
|
80
80
|
Relationships = unknown,
|
|
81
|
-
Method = unknown
|
|
81
|
+
Method = unknown,
|
|
82
82
|
> extends PostgrestTransformBuilder<
|
|
83
83
|
ClientOptions,
|
|
84
84
|
Schema,
|
|
@@ -101,11 +101,11 @@ export default class PostgrestFilterBuilder<
|
|
|
101
101
|
value: ResolveFilterValue<Schema, Row, ColumnName> extends never
|
|
102
102
|
? NonNullable<unknown>
|
|
103
103
|
: // We want to infer the type before wrapping it into a `NonNullable` to avoid too deep
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
// type resolution error
|
|
105
|
+
ResolveFilterValue<Schema, Row, ColumnName> extends infer ResolvedFilterValue
|
|
106
|
+
? NonNullable<ResolvedFilterValue>
|
|
107
|
+
: // We should never enter this case as all the branches are covered above
|
|
108
|
+
never
|
|
109
109
|
): this {
|
|
110
110
|
this.url.searchParams.append(column, `eq.${value}`)
|
|
111
111
|
return this
|
|
@@ -122,8 +122,8 @@ export default class PostgrestFilterBuilder<
|
|
|
122
122
|
value: ResolveFilterValue<Schema, Row, ColumnName> extends never
|
|
123
123
|
? unknown
|
|
124
124
|
: ResolveFilterValue<Schema, Row, ColumnName> extends infer ResolvedFilterValue
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
? ResolvedFilterValue
|
|
126
|
+
: never
|
|
127
127
|
): this {
|
|
128
128
|
this.url.searchParams.append(column, `neq.${value}`)
|
|
129
129
|
return this
|
|
@@ -305,11 +305,11 @@ export default class PostgrestFilterBuilder<
|
|
|
305
305
|
ResolveFilterValue<Schema, Row, ColumnName> extends never
|
|
306
306
|
? unknown
|
|
307
307
|
: // We want to infer the type before wrapping it into a `NonNullable` to avoid too deep
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
// type resolution error
|
|
309
|
+
ResolveFilterValue<Schema, Row, ColumnName> extends infer ResolvedFilterValue
|
|
310
|
+
? ResolvedFilterValue
|
|
311
|
+
: // We should never enter this case as all the branches are covered above
|
|
312
|
+
never
|
|
313
313
|
>
|
|
314
314
|
): this {
|
|
315
315
|
const cleanedValues = Array.from(new Set(values))
|
|
@@ -7,7 +7,7 @@ export default class PostgrestQueryBuilder<
|
|
|
7
7
|
Schema extends GenericSchema,
|
|
8
8
|
Relation extends GenericTable | GenericView,
|
|
9
9
|
RelationName = unknown,
|
|
10
|
-
Relationships = Relation extends { Relationships: infer R } ? R : unknown
|
|
10
|
+
Relationships = Relation extends { Relationships: infer R } ? R : unknown,
|
|
11
11
|
> {
|
|
12
12
|
url: URL
|
|
13
13
|
headers: Headers
|
|
@@ -63,7 +63,7 @@ export default class PostgrestQueryBuilder<
|
|
|
63
63
|
Relationships,
|
|
64
64
|
Query,
|
|
65
65
|
ClientOptions
|
|
66
|
-
|
|
66
|
+
>,
|
|
67
67
|
>(
|
|
68
68
|
columns?: Query,
|
|
69
69
|
{
|
|
@@ -15,7 +15,7 @@ export default class PostgrestTransformBuilder<
|
|
|
15
15
|
Result,
|
|
16
16
|
RelationName = unknown,
|
|
17
17
|
Relationships = unknown,
|
|
18
|
-
Method = unknown
|
|
18
|
+
Method = unknown,
|
|
19
19
|
> extends PostgrestBuilder<ClientOptions, Result> {
|
|
20
20
|
/**
|
|
21
21
|
* Perform a SELECT on the query result.
|
|
@@ -28,7 +28,7 @@ export default class PostgrestTransformBuilder<
|
|
|
28
28
|
*/
|
|
29
29
|
select<
|
|
30
30
|
Query extends string = '*',
|
|
31
|
-
NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query, ClientOptions
|
|
31
|
+
NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query, ClientOptions>,
|
|
32
32
|
>(
|
|
33
33
|
columns?: Query
|
|
34
34
|
): PostgrestTransformBuilder<
|
|
@@ -218,7 +218,7 @@ export default class PostgrestTransformBuilder<
|
|
|
218
218
|
* this returns an error.
|
|
219
219
|
*/
|
|
220
220
|
maybeSingle<
|
|
221
|
-
ResultOne = Result extends (infer ResultOne)[] ? ResultOne : never
|
|
221
|
+
ResultOne = Result extends (infer ResultOne)[] ? ResultOne : never,
|
|
222
222
|
>(): PostgrestBuilder<ClientOptions, ResultOne | null> {
|
|
223
223
|
// Temporary partial fix for https://github.com/supabase/postgrest-js/issues/361
|
|
224
224
|
// Issue persists e.g. for `.insert([...]).select().maybeSingle()`
|