@supabase/postgrest-js
Advanced tools
Comparing version 0.37.2 to 0.37.3
@@ -93,18 +93,4 @@ "use strict"; | ||
this.headers['Accept'] = 'application/vnd.pgrst.object+json'; | ||
const _this = new PostgrestTransformBuilder(this); | ||
_this.then = ((onfulfilled, onrejected) => this.then((res) => { | ||
var _a, _b; | ||
if ((_b = (_a = res.error) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.includes('Results contain 0 rows')) { | ||
return onfulfilled({ | ||
error: null, | ||
data: null, | ||
count: res.count, | ||
status: 200, | ||
statusText: 'OK', | ||
body: null, | ||
}); | ||
} | ||
return onfulfilled(res); | ||
}, onrejected)); | ||
return _this; | ||
this.allowEmpty = true; | ||
return this; | ||
} | ||
@@ -111,0 +97,0 @@ /** |
@@ -53,2 +53,3 @@ export declare type Fetch = typeof fetch; | ||
protected fetch: Fetch; | ||
protected allowEmpty: boolean; | ||
constructor(builder: PostgrestBuilder<T>); | ||
@@ -55,0 +56,0 @@ /** |
@@ -32,2 +32,3 @@ "use strict"; | ||
this.shouldThrowOnError = builder.shouldThrowOnError || false; | ||
this.allowEmpty = builder.allowEmpty || false; | ||
} | ||
@@ -67,6 +68,8 @@ /** | ||
}).then((res) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
let error = null; | ||
let data = null; | ||
let count = null; | ||
let status = res.status; | ||
let statusText = res.statusText; | ||
if (res.ok) { | ||
@@ -97,3 +100,3 @@ const isReturnMinimal = (_a = this.headers['Prefer']) === null || _a === void 0 ? void 0 : _a.split(',').includes('return=minimal'); | ||
} | ||
catch (_d) { | ||
catch (_e) { | ||
error = { | ||
@@ -103,2 +106,7 @@ message: body, | ||
} | ||
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'))) { | ||
error = null; | ||
status = 200; | ||
statusText = 'OK'; | ||
} | ||
if (error && this.shouldThrowOnError) { | ||
@@ -112,4 +120,4 @@ throw error; | ||
count, | ||
status: res.status, | ||
statusText: res.statusText, | ||
status, | ||
statusText, | ||
body: data, | ||
@@ -116,0 +124,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.37.2"; | ||
export declare const version = "0.37.3"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// generated by genversion | ||
exports.version = '0.37.2'; | ||
exports.version = '0.37.3'; | ||
//# sourceMappingURL=version.js.map |
@@ -91,18 +91,4 @@ import { PostgrestBuilder } from './types'; | ||
this.headers['Accept'] = 'application/vnd.pgrst.object+json'; | ||
const _this = new PostgrestTransformBuilder(this); | ||
_this.then = ((onfulfilled, onrejected) => this.then((res) => { | ||
var _a, _b; | ||
if ((_b = (_a = res.error) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.includes('Results contain 0 rows')) { | ||
return onfulfilled({ | ||
error: null, | ||
data: null, | ||
count: res.count, | ||
status: 200, | ||
statusText: 'OK', | ||
body: null, | ||
}); | ||
} | ||
return onfulfilled(res); | ||
}, onrejected)); | ||
return _this; | ||
this.allowEmpty = true; | ||
return this; | ||
} | ||
@@ -109,0 +95,0 @@ /** |
@@ -53,2 +53,3 @@ export declare type Fetch = typeof fetch; | ||
protected fetch: Fetch; | ||
protected allowEmpty: boolean; | ||
constructor(builder: PostgrestBuilder<T>); | ||
@@ -55,0 +56,0 @@ /** |
@@ -26,2 +26,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.shouldThrowOnError = builder.shouldThrowOnError || false; | ||
this.allowEmpty = builder.allowEmpty || false; | ||
} | ||
@@ -61,6 +62,8 @@ /** | ||
}).then((res) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
let error = null; | ||
let data = null; | ||
let count = null; | ||
let status = res.status; | ||
let statusText = res.statusText; | ||
if (res.ok) { | ||
@@ -91,3 +94,3 @@ const isReturnMinimal = (_a = this.headers['Prefer']) === null || _a === void 0 ? void 0 : _a.split(',').includes('return=minimal'); | ||
} | ||
catch (_d) { | ||
catch (_e) { | ||
error = { | ||
@@ -97,2 +100,7 @@ message: body, | ||
} | ||
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'))) { | ||
error = null; | ||
status = 200; | ||
statusText = 'OK'; | ||
} | ||
if (error && this.shouldThrowOnError) { | ||
@@ -106,4 +114,4 @@ throw error; | ||
count, | ||
status: res.status, | ||
statusText: res.statusText, | ||
status, | ||
statusText, | ||
body: data, | ||
@@ -110,0 +118,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "0.37.2"; | ||
export declare const version = "0.37.3"; | ||
//# sourceMappingURL=version.d.ts.map |
// generated by genversion | ||
export const version = '0.37.2'; | ||
export const version = '0.37.3'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@supabase/postgrest-js", | ||
"version": "0.37.2", | ||
"version": "0.37.3", | ||
"description": "Isomorphic PostgREST client", | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
"dependencies": { | ||
"cross-fetch": "^3.0.6" | ||
"cross-fetch": "^3.1.5" | ||
}, | ||
@@ -48,3 +48,3 @@ "devDependencies": { | ||
"ts-jest": "^26.3.0", | ||
"typedoc": "^0.19.1", | ||
"typedoc": "^0.22.15", | ||
"typescript": "^4.0.2", | ||
@@ -51,0 +51,0 @@ "wait-for-localhost-cli": "^2.0.0" |
@@ -28,6 +28,6 @@ # `postgrest-js` | ||
- select(): https://supabase.io/docs/reference/javascript/select | ||
- insert(): https://supabase.io/docs/reference/javascript/insert | ||
- update(): https://supabase.io/docs/reference/javascript/update | ||
- delete(): https://supabase.io/docs/reference/javascript/delete | ||
- select(): https://supabase.com/docs/reference/javascript/select | ||
- insert(): https://supabase.com/docs/reference/javascript/insert | ||
- update(): https://supabase.com/docs/reference/javascript/update | ||
- delete(): https://supabase.com/docs/reference/javascript/delete | ||
@@ -34,0 +34,0 @@ #### Custom `fetch` implementation |
@@ -112,19 +112,4 @@ import { PostgrestBuilder, PostgrestMaybeSingleResponse, PostgrestSingleResponse } from './types' | ||
this.headers['Accept'] = 'application/vnd.pgrst.object+json' | ||
const _this = new PostgrestTransformBuilder(this) | ||
_this.then = ((onfulfilled: any, onrejected: any) => | ||
this.then((res: any): any => { | ||
if (res.error?.details?.includes('Results contain 0 rows')) { | ||
return onfulfilled({ | ||
error: null, | ||
data: null, | ||
count: res.count, | ||
status: 200, | ||
statusText: 'OK', | ||
body: null, | ||
}) | ||
} | ||
return onfulfilled(res) | ||
}, onrejected)) as any | ||
return _this as PromiseLike<PostgrestMaybeSingleResponse<T>> | ||
this.allowEmpty = true | ||
return this as PromiseLike<PostgrestMaybeSingleResponse<T>> | ||
} | ||
@@ -131,0 +116,0 @@ |
@@ -62,2 +62,3 @@ import crossFetch from 'cross-fetch' | ||
protected fetch: Fetch | ||
protected allowEmpty: boolean | ||
@@ -76,2 +77,3 @@ constructor(builder: PostgrestBuilder<T>) { | ||
this.shouldThrowOnError = builder.shouldThrowOnError || false | ||
this.allowEmpty = builder.allowEmpty || false | ||
} | ||
@@ -121,2 +123,4 @@ | ||
let count = null | ||
let status = res.status | ||
let statusText = res.statusText | ||
@@ -152,2 +156,8 @@ if (res.ok) { | ||
if (error && this.allowEmpty && error?.details?.includes('Results contain 0 rows')) { | ||
error = null | ||
status = 200 | ||
statusText = 'OK' | ||
} | ||
if (error && this.shouldThrowOnError) { | ||
@@ -162,4 +172,4 @@ throw error | ||
count, | ||
status: res.status, | ||
statusText: res.statusText, | ||
status, | ||
statusText, | ||
body: data, | ||
@@ -166,0 +176,0 @@ } |
// generated by genversion | ||
export const version = '0.37.2' | ||
export const version = '0.37.3' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
214930
3966
Updatedcross-fetch@^3.1.5