@supabase/supabase-js
Advanced tools
Comparing version 0.1.16 to 0.1.17
@@ -1,1 +0,1 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _slicedToArray=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),convertChangeData=exports.convertChangeData=function(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d={},e='undefined'==typeof c.skipTypes?[]:c.skipTypes;return Object.entries(b).map(function(c){var f=_slicedToArray(c,2),g=f[0],h=f[1];d[g]=convertColumn(g,a,b,e)}),d},convertColumn=exports.convertColumn=function(a,b,c,d){var e=b.find(function(b){return b.name==a});return d.includes(e.type)?noop(c[a]):convertCell(e.type,c[a])},convertCell=exports.convertCell=function(a,b){try{if(null===b)return null;return'abstime'===a?noop(b):'bool'===a?toBoolean(b):'date'===a?noop(b):'daterange'===a?toDateRange(b):'float4'===a?toFloat(b):'float8'===a?toFloat(b):'int2'===a?toInt(b):'int4'===a?toInt(b):'int4range'===a?toIntRange(b):'int8'===a?toInt(b):'int8range'===a?toIntRange(b):'json'===a?toJson(b):'jsonb'===a?toJson(b):'money'===a?toFloat(b):'numeric'===a?toFloat(b):'oid'===a?toInt(b):'reltime'===a?noop(b):'time'===a?noop(b):'timestamp'===a?noop(b):'timestamptz'===a?noop(b):'timetz'===a?noop(b):'tsrange'===a?toDateRange(b):'tstzrange'===a?toDateRange(b):noop(b)}catch(c){return console.log('Could not convert cell of type '+a+' and value '+b),b}},noop=function(a){return a},toBoolean=function(a){return!('t'!==a)||'f'!==a&&null},toDate=function(a){return new Date(a)},toDateRange=function(a){var b=JSON.parse(a);return[new Date(b[0]),new Date(b[1])]},toFloat=function(a){return parseFloat(a)},toInt=function(a){return parseInt(a)},toIntRange=function(a){var b=JSON.parse(a);return[parseInt(b[0]),parseInt(b[1])]},toJson=function(a){return JSON.parse(a)}; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _slicedToArray=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h['return']&&h['return']()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),convertChangeData=exports.convertChangeData=function(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},d={},e='undefined'==typeof c.skipTypes?[]:c.skipTypes;return Object.entries(b).map(function(c){var f=_slicedToArray(c,2),g=f[0],h=f[1];d[g]=convertColumn(g,a,b,e)}),d},convertColumn=exports.convertColumn=function(a,b,c,d){var e=b.find(function(b){return b.name==a});return d.includes(e.type)?noop(c[a]):convertCell(e.type,c[a])},convertCell=exports.convertCell=function(a,b){try{if(null===b)return null;return'abstime'===a?noop(b):'bool'===a?toBoolean(b):'date'===a?noop(b):'daterange'===a?toDateRange(b):'float4'===a?toFloat(b):'float8'===a?toFloat(b):'int2'===a?toInt(b):'int4'===a?toInt(b):'int4range'===a?toIntRange(b):'int8'===a?toInt(b):'int8range'===a?toIntRange(b):'json'===a?toJson(b):'jsonb'===a?toJson(b):'money'===a?toFloat(b):'numeric'===a?toFloat(b):'oid'===a?toInt(b):'reltime'===a?noop(b):'time'===a?noop(b):'timestamp'===a?toTimestampString(b):'timestamptz'===a?noop(b):'timetz'===a?noop(b):'tsrange'===a?toDateRange(b):'tstzrange'===a?toDateRange(b):noop(b)}catch(c){return console.log('Could not convert cell of type '+a+' and value '+b),b}},noop=function(a){return a},toBoolean=function(a){return!('t'!==a)||'f'!==a&&null},toDate=function(a){return new Date(a)},toDateRange=function(a){var b=JSON.parse(a);return[new Date(b[0]),new Date(b[1])]},toFloat=function(a){return parseFloat(a)},toInt=function(a){return parseInt(a)},toIntRange=function(a){var b=JSON.parse(a);return[parseInt(b[0]),parseInt(b[1])]},toJson=function(a){return JSON.parse(a)},toTimestampString=function(a){return a.replace(' ','T')}; |
{ | ||
"name": "@supabase/supabase-js", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "Supabase Realtime API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -109,3 +109,3 @@ // # Lifted from epgsql (src/epgsql_binary.erl), this module licensed under | ||
case 'timestamp': | ||
return noop(stringValue) // To allow users to cast it based on Timezone | ||
return toTimestampString(stringValue) // Format to be consistent with PostgREST | ||
case 'timestamptz': | ||
@@ -164,2 +164,16 @@ return noop(stringValue) // To allow users to cast it based on Timezone | ||
return JSON.parse(stringValue) | ||
} | ||
/** | ||
* Fixes timestamp to be ISO-8601. Swaps the space between the date and time for a 'T' | ||
* See https://github.com/supabase/supabase/issues/18 | ||
* @returns {string} | ||
* | ||
* @example | ||
* toTimestampString('2019-09-10 00:00:00') | ||
* //=> | ||
* '2019-09-10T00:00:00' | ||
*/ | ||
const toTimestampString = stringValue => { | ||
return stringValue.replace(' ', 'T') | ||
} |
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
22852
365