Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@supabase/postgrest-js

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/postgrest-js - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

2

lib/Builder.js

@@ -24,3 +24,3 @@ "use strict";var _Request=_interopRequireDefault(require("./Request"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}/**

* Start a "DELETE" request
*/},{key:"delete",value:function _delete(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=this.request("DELETE");return this.addFilters(b,a),b}}]),a}(),advancedFilters=["eq","gt","lt","gte","lte","like","ilike","is","in","not"];// pre-empts if any of the filters are used before select
*/},{key:"delete",value:function _delete(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=this.request("DELETE");return this.addFilters(b,a),b}}]),a}(),advancedFilters=["eq","gt","lt","gte","lte","like","ilike","is","in","not","cs","cd","ov","sl","sr","nxr","nxl","adj"];// pre-empts if any of the filters are used before select
advancedFilters.forEach(function(a){return Builder.prototype[a]=function(b,c){return this.filter(b,a,c),this}});var _default=Builder;exports["default"]=_default;

@@ -19,3 +19,4 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _superagent=require("superagent"),Filters=_interopRequireWildcard(require("./utils/Filters"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!==_typeof(a)&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c["default"]=a,b&&b.set(a,c),c}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _get(a,b,c){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(a,b,c){var d=_superPropBase(a,b);if(d){var e=Object.getOwnPropertyDescriptor(d,b);return e.get?e.get.call(c):e.value}},_get(a,b,c||a)}function _superPropBase(a,b){for(;!Object.prototype.hasOwnProperty.call(a,b)&&(a=_getPrototypeOf(a),null!==a););return a}function _createSuper(a){return function(){var b,c=_getPrototypeOf(a);if(_isNativeReflectConstruct()){var d=_getPrototypeOf(this).constructor;b=Reflect.construct(c,arguments,d)}else b=c.apply(this,arguments);return _possibleConstructorReturn(this,b)}}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}var contentRangeStructure=/^(\d+)-(\d+)\/(\d+)$/,Request=/*#__PURE__*/function(a){function b(a,d){var e,f=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(_classCallCheck(this,b),e=c.call(this,a,d),e.set("Accept","application/json"),{}!=f)for(var g in f)e.set(g,f[g]);// Fix for superagent disconnect on client & server.

* @returns {string}
*/},{key:"filter",value:function filter(a,b,c){var d=Filters["_".concat(b.toLowerCase())](a,c);return this.query(d)}/**
*/},{key:"filter",value:function filter(a,b,c){if(["in","cs","cd","ova","ovr","sl","sr","nxr","nxl","adj"].includes(b)&&!Array.isArray(c))return{body:null,status:400,statusCode:400,statusText:".".concat(b,"() cannot be invoked with criteria that is not an Array.")};// for ranges, length of array should always be equal to 2
if(["ovr","sl","sr","nxr","nxl","adj"].includes(b)&&2!=c.length)return{body:null,status:400,statusCode:400,statusText:".".concat(b,"() can only be invoked with a criteria that is an Array of length 2.")};var d=Filters["_".concat(b.toLowerCase())](a,c);return this.query(d)}/**
* Takes a query object and translates it to a PostgREST filter query string.

@@ -70,2 +71,2 @@ * All values are prefixed with `eq.`.

* @returns {Promise} Resolves when there is an error.
*/},{key:"catch",value:function _catch(a){return this.end()["catch"](a)}}]),b}(_superagent.Request),filters=["eq","gt","lt","gte","lte","like","ilike","is","in","not"];filters.forEach(function(a){return Request.prototype[a]=function(b,c){return this.filter(b,a,c)}});var _default=Request;exports["default"]=_default;
*/},{key:"catch",value:function _catch(a){return this.end()["catch"](a)}}]),b}(_superagent.Request),filters=["eq","gt","lt","gte","lte","like","ilike","is","in","not","cs","cd","ov","sl","sr","nxr","nxl","adj"];filters.forEach(function(a){return Request.prototype[a]=function(b,c){return this.filter(b,a,c)}});var _default=Request;exports["default"]=_default;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._eq=_eq,exports._gt=_gt,exports._lt=_lt,exports._gte=_gte,exports._lte=_lte,exports._like=_like,exports._ilike=_ilike,exports._is=_is,exports._in=_in,exports._not=_not;/** @module Filters **/ /**
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._eq=_eq,exports._gt=_gt,exports._lt=_lt,exports._gte=_gte,exports._lte=_lte,exports._like=_like,exports._ilike=_ilike,exports._is=_is,exports._in=_in,exports._not=_not,exports._cs=_cs,exports._cd=_cd,exports._ova=_ova,exports._ovr=_ovr,exports._sl=_sl,exports._sr=_sr,exports._nxl=_nxl,exports._nxr=_nxr,exports._adj=_adj;/** @module Filters **/ /**
* All exports are prefixed with an underscore to avoid collisions with reserved keywords (eg: "in")

@@ -133,2 +133,120 @@ */ /**

* 'name=neq.China'
*/function _not(a,b){return"".concat(a,"=neq.").concat(b)}
*/function _not(a,b){return"".concat(a,"=neq.").concat(b)}/**
* Finds all rows whose json || array || range value on the stated columnName contains the values specified in the filterObject.
* @param {string} columnName Name of the database column
* @param { array | object } filterObject Value to compare to
* @name cs
* @function
* @returns {string}
*
* @example
* _cs('countries', ['China', 'France'])
* //=>
* 'countries=cs.{China,France}'
*
* @example
* _cd('food_supplies', {fruits:1000, meat:800})
* //=>
* 'food_supplies=cd.{"fruits":1000,"meat":800}'
*/function _cs(a,b){return Array.isArray(b)?"".concat(a,"=cs.{").concat(b.join(","),"}"):"".concat(a,"=cs.").concat(JSON.stringify(b))}/**
* Finds all rows whose json || array || range value on the stated columnName is contained by the specified filterObject.
* @param {string} columnName Name of the database column
* @param { array | object } filterObject Value to compare to
* @name cd
* @function
* @returns {string}
*
* @example
* _cd('countries', ['China', 'France'])
* //=>
* 'countries=cd.{China,France}'
*
* @example
* _cd('food_supplies', {fruits:1000, meat:800})
* //=>
* 'food_supplies=cd.{"fruits":1000,"meat":800}'
*/function _cd(a,b){return Array.isArray(b)?"".concat(a,"=cd.{").concat(b.join(","),"}"):"".concat(a,"=cd.").concat(JSON.stringify(b))}/**
* Finds all rows whose array value on the stated columnName overlaps on the specified filterArray.
* @param {string} columnName Name of the database column
* @param {array} filterValue Value to compare to
* @name ova
* @function
* @returns {string}
*
* @example
* _ova('allies', ['China', 'France'])
* //=>
* 'allies=ov.{China,France}'
*/function _ova(a,b){return"".concat(a,"=ov.{").concat(b.join(","),"}")}/**
* Finds all rows whose range value on the stated columnName overlaps on the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to to compare to
* @name ovr
* @function
* @returns {string}
*
* @example
* _ovr('population_range', [100, 500])
* //=>
* 'population_range=ov.(100,500)'
*/function _ovr(a,b){return"".concat(a,"=ov.(").concat(b.join(","),")")}/**
* Finds all rows whose range value on the stated columnName is strictly on the left of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name sl
* @function
* @returns {string}
*
* @example
* _sl('population_range', [100, 500])
* //=>
* 'population_range=sl.(100,500)'
*/function _sl(a,b){return"".concat(a,"=sl.(").concat(b.join(","),")")}/**
* Finds all rows whose range value on the stated columnName is strictly on the right of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name sr
* @function
* @returns {string}
*
* @example
* _sr('population_range', [100,500])
* //=>
* 'population_range=sr.(100,500)'
*/function _sr(a,b){return"".concat(a,"=sr.(").concat(b.join(","),")")}/**
* Finds all rows whose range value on the stated columnName does not extend to the left of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name nxl
* @function
* @returns {string}
*
* @example
* _nxl('population_range', [100, 500])
* //=>
* 'population_range=nxl.(100,500)'
*/function _nxl(a,b){return"".concat(a,"=nxl.(").concat(b.join(","),")")}/**
* Finds all rows whose range value on the stated columnName does not extend to the right of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name nxr
* @function
* @returns {string}
*
* @example
* _nxr('population_range', [100, 500])
* //=>
* 'population_range=nxr.(100,500)'
*/function _nxr(a,b){return"".concat(a,"=nxr.(").concat(b.join(","),")")}/**
* Finds all rows whose range value on the stated columnName is adjacent to the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name adj
* @function
* @returns {string}
*
* @example
* _adj('population_range', [100, 500])
* //=>
* 'population_range=adj.(100,500)'
*/function _adj(a,b){return"".concat(a,"=adj.(").concat(b.join(","),")")}
{
"name": "@supabase/postgrest-js",
"version": "0.11.0",
"version": "0.12.0",
"description": "PostgREST JS client",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -33,3 +33,3 @@ import Request from './Request'

if (Object.keys(options).length != 0) {
Object.keys(options).forEach(option => {
Object.keys(options).forEach((option) => {
let setting = options[option]

@@ -41,3 +41,3 @@ request.set(option, setting)

// loop through this.queryFilters
this.queryFilters.forEach(queryFilter => {
this.queryFilters.forEach((queryFilter) => {
switch (queryFilter.filter) {

@@ -186,6 +186,25 @@ case 'filter':

// pre-empts if any of the filters are used before select
const advancedFilters = ['eq', 'gt', 'lt', 'gte', 'lte', 'like', 'ilike', 'is', 'in', 'not']
const advancedFilters = [
'eq',
'gt',
'lt',
'gte',
'lte',
'like',
'ilike',
'is',
'in',
'not',
'cs',
'cd',
'ov',
'sl',
'sr',
'nxr',
'nxl',
'adj',
]
advancedFilters.forEach(
operator =>
(operator) =>
(Builder.prototype[operator] = function filterValue(columnName, criteria) {

@@ -192,0 +211,0 @@ this.filter(columnName, operator, criteria)

@@ -70,2 +70,25 @@ /**

filter(columnName, operator, criteria) {
if (
['in', 'cs', 'cd', 'ova', 'ovr', 'sl', 'sr', 'nxr', 'nxl', 'adj'].includes(operator) &&
!Array.isArray(criteria)
) {
return {
body: null,
status: 400,
statusCode: 400,
statusText: `.${operator}() cannot be invoked with criteria that is not an Array.`,
}
}
// for ranges, length of array should always be equal to 2
if (['ovr', 'sl', 'sr', 'nxr', 'nxl', 'adj'].includes(operator) && criteria.length != 2) {
return {
body: null,
status: 400,
statusCode: 400,
statusText: `.${operator}() can only be invoked with a criteria that is an Array of length 2.`,
}
}
let newQuery = Filters[`_${operator.toLowerCase()}`](columnName, criteria)

@@ -84,3 +107,3 @@ return this.query(newQuery)

match(query) {
Object.keys(query).forEach(key => {
Object.keys(query).forEach((key) => {
this.query(`${key}=eq.${query[key]}`)

@@ -221,5 +244,24 @@ })

// Attached all the filters
const filters = ['eq', 'gt', 'lt', 'gte', 'lte', 'like', 'ilike', 'is', 'in', 'not']
const filters = [
'eq',
'gt',
'lt',
'gte',
'lte',
'like',
'ilike',
'is',
'in',
'not',
'cs',
'cd',
'ov',
'sl',
'sr',
'nxr',
'nxl',
'adj',
]
filters.forEach(
filter =>
(filter) =>
(Request.prototype[filter] = function filterValue(columnName, criteria) {

@@ -226,0 +268,0 @@ return this.filter(columnName, filter, criteria)

@@ -190,1 +190,166 @@ /** @module Filters **/

}
/**
* Finds all rows whose json || array || range value on the stated columnName contains the values specified in the filterObject.
* @param {string} columnName Name of the database column
* @param { array | object } filterObject Value to compare to
* @name cs
* @function
* @returns {string}
*
* @example
* _cs('countries', ['China', 'France'])
* //=>
* 'countries=cs.{China,France}'
*
* @example
* _cd('food_supplies', {fruits:1000, meat:800})
* //=>
* 'food_supplies=cd.{"fruits":1000,"meat":800}'
*/
export function _cs(columnName, filterObject) {
if(Array.isArray(filterObject)) return `${columnName}=cs.{${filterObject.join(',')}}`
return `${columnName}=cs.${JSON.stringify(filterObject)}`
}
/**
* Finds all rows whose json || array || range value on the stated columnName is contained by the specified filterObject.
* @param {string} columnName Name of the database column
* @param { array | object } filterObject Value to compare to
* @name cd
* @function
* @returns {string}
*
* @example
* _cd('countries', ['China', 'France'])
* //=>
* 'countries=cd.{China,France}'
*
* @example
* _cd('food_supplies', {fruits:1000, meat:800})
* //=>
* 'food_supplies=cd.{"fruits":1000,"meat":800}'
*/
export function _cd(columnName, filterObject) {
if(Array.isArray(filterObject)) return `${columnName}=cd.{${filterObject.join(',')}}`
return `${columnName}=cd.${JSON.stringify(filterObject)}`
}
/**
* Finds all rows whose array value on the stated columnName overlaps on the specified filterArray.
* @param {string} columnName Name of the database column
* @param {array} filterValue Value to compare to
* @name ova
* @function
* @returns {string}
*
* @example
* _ova('allies', ['China', 'France'])
* //=>
* 'allies=ov.{China,France}'
*/
export function _ova(columnName, filterArray) {
return `${columnName}=ov.{${filterArray.join(',')}}`
}
/**
* Finds all rows whose range value on the stated columnName overlaps on the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to to compare to
* @name ovr
* @function
* @returns {string}
*
* @example
* _ovr('population_range', [100, 500])
* //=>
* 'population_range=ov.(100,500)'
*/
export function _ovr(columnName, filterRange) {
return `${columnName}=ov.(${filterRange.join(',')})`
}
/**
* Finds all rows whose range value on the stated columnName is strictly on the left of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name sl
* @function
* @returns {string}
*
* @example
* _sl('population_range', [100, 500])
* //=>
* 'population_range=sl.(100,500)'
*/
export function _sl(columnName, filterRange) {
return `${columnName}=sl.(${filterRange.join(',')})`
}
/**
* Finds all rows whose range value on the stated columnName is strictly on the right of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name sr
* @function
* @returns {string}
*
* @example
* _sr('population_range', [100,500])
* //=>
* 'population_range=sr.(100,500)'
*/
export function _sr(columnName, filterRange) {
return `${columnName}=sr.(${filterRange.join(',')})`
}
/**
* Finds all rows whose range value on the stated columnName does not extend to the left of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name nxl
* @function
* @returns {string}
*
* @example
* _nxl('population_range', [100, 500])
* //=>
* 'population_range=nxl.(100,500)'
*/
export function _nxl(columnName, filterRange) {
return `${columnName}=nxl.(${filterRange.join(',')})`
}
/**
* Finds all rows whose range value on the stated columnName does not extend to the right of the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name nxr
* @function
* @returns {string}
*
* @example
* _nxr('population_range', [100, 500])
* //=>
* 'population_range=nxr.(100,500)'
*/
export function _nxr(columnName, filterRange) {
return `${columnName}=nxr.(${filterRange.join(',')})`
}
/**
* Finds all rows whose range value on the stated columnName is adjacent to the specified filterRange.
* @param {string} columnName Name of the database column
* @param {array} filterRange Value to compare to
* @name adj
* @function
* @returns {string}
*
* @example
* _adj('population_range', [100, 500])
* //=>
* 'population_range=adj.(100,500)'
*/
export function _adj(columnName, filterRange) {
return `${columnName}=adj.(${filterRange.join(',')})`
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc