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

kinto-client

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kinto-client - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

dist/kinto-client.min.js

@@ -41,3 +41,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.KintoClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

},{"./batch":7,"./bucket":8,"./endpoint":10,"./http.js":12,"./requests":14,"./utils.js":15,"events":1,"isomorphic-fetch":5}],14:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function doNotOverwrite(e){return e?{"If-None-Match":"*"}:{}}function concurrencyCheck(e,t){if(!e)return{};if(!t)throw new Error("Safe concurrency check requires a last_modified value.");return{"If-Match":'"'+t+'"'}}function createBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e)throw new Error("A bucket name is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.permissions,n=r.safe;return{method:"PUT",path:(0,_endpoint2["default"])("bucket",e),headers:_extends({},o,doNotOverwrite(n)),body:{permissions:d}}}function updateBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.permissions,n=r.safe,i=r.patch,s=r.last_modified;return{method:i?"PATCH":"PUT",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},o,concurrencyCheck(n,s||e.last_modified)),body:{data:e,permissions:d}}}function deleteBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.safe,n=r.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},o,concurrencyCheck(d,n||e.last_modified)),body:{data:e}}}function createCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.permissions,i=r.data,s=r.safe,a=e?(0,_endpoint2["default"])("collection",o,e):(0,_endpoint2["default"])("collections",o);return{method:e?"PUT":"POST",path:a,headers:_extends({},d,doNotOverwrite(s)),body:{data:i,permissions:n}}}function updateCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.permissions,i=r.schema,s=r.metadata,a=r.safe,c=r.patch,u=r.last_modified,f=_extends({},s,e);return t.schema&&(f.schema=i),{method:c?"PATCH":"PUT",path:(0,_endpoint2["default"])("collection",o,e.id),headers:_extends({},d,concurrencyCheck(a,u||e.last_modified)),body:{data:f,permissions:n}}}function deleteCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.safe,i=r.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("collection",o,e.id),headers:_extends({},d,concurrencyCheck(n,i||e.last_modified)),body:{data:e}}}function createRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.permissions,s=o.safe;return{method:t.id?"PUT":"POST",path:t.id?(0,_endpoint2["default"])("record",d,e,t.id):(0,_endpoint2["default"])("records",d,e),headers:_extends({},n,doNotOverwrite(s)),body:{data:t,permissions:i}}}function updateRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if(!t.id)throw new Error("A record id is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.permissions,s=o.safe,a=o.patch,c=o.last_modified;return{method:a?"PATCH":"PUT",path:(0,_endpoint2["default"])("record",d,e,t.id),headers:_extends({},n,concurrencyCheck(s,c||t.last_modified)),body:{data:t,permissions:i}}}function deleteRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if("object"!==("undefined"==typeof t?"undefined":_typeof(t)))throw new Error("A record object is required.");if(!t.id)throw new Error("A record id is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.safe,s=o.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("record",d,e,t.id),headers:_extends({},n,concurrencyCheck(i,s||t.last_modified)),body:{data:t}}}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};exports.createBucket=createBucket,exports.updateBucket=updateBucket,exports.deleteBucket=deleteBucket,exports.createCollection=createCollection,exports.updateCollection=updateCollection,exports.deleteCollection=deleteCollection,exports.createRecord=createRecord,exports.updateRecord=updateRecord,exports.deleteRecord=deleteRecord;var _endpoint=require("./endpoint"),_endpoint2=_interopRequireDefault(_endpoint),requestDefaults={safe:!1,headers:{},bucket:"default",permissions:{},data:{},patch:!1};
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function safeHeader(e,t){return e?t?{"If-Match":'"'+t+'"'}:{"If-None-Match":"*"}:{}}function createBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e)throw new Error("A bucket name is required.");var r=_extends({},requestDefaults,t),d=r.headers,o=r.permissions,i=r.safe;return{method:"PUT",path:(0,_endpoint2["default"])("bucket",e),headers:_extends({},d,safeHeader(i)),body:{permissions:o}}}function updateBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),d=r.headers,o=r.permissions,i=r.safe,n=r.patch,a=r.last_modified;return{method:n?"PATCH":"PUT",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},d,safeHeader(i,a||e.last_modified)),body:{data:e,permissions:o}}}function deleteBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,{last_modified:e.last_modified},t),d=r.headers,o=r.safe,i=r.last_modified;if(o&&!i)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},d,safeHeader(o,i)),body:{data:e}}}function createCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_extends({},requestDefaults,t),d=r.bucket,o=r.headers,i=r.permissions,n=r.data,a=r.safe,s=e?(0,_endpoint2["default"])("collection",d,e):(0,_endpoint2["default"])("collections",d);return{method:e?"PUT":"POST",path:s,headers:_extends({},o,safeHeader(a)),body:{data:n,permissions:i}}}function updateCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),d=r.bucket,o=r.headers,i=r.permissions,n=r.schema,a=r.metadata,s=r.safe,u=r.patch,c=r.last_modified,f=_extends({},a,e);return t.schema&&(f.schema=n),{method:u?"PATCH":"PUT",path:(0,_endpoint2["default"])("collection",d,e.id),headers:_extends({},o,safeHeader(s,c||e.last_modified)),body:{data:f,permissions:i}}}function deleteCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,{last_modified:e.last_modified},t),d=r.bucket,o=r.headers,i=r.safe,n=r.last_modified;if(i&&!n)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("collection",d,e.id),headers:_extends({},o,safeHeader(i,n)),body:{data:e}}}function createRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");var d=_extends({},requestDefaults,r),o=d.bucket,i=d.headers,n=d.permissions,a=d.safe;return{method:t.id?"PUT":"POST",path:t.id?(0,_endpoint2["default"])("record",o,e,t.id):(0,_endpoint2["default"])("records",o,e),headers:_extends({},i,safeHeader(a)),body:{data:t,permissions:n}}}function updateRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if(!t.id)throw new Error("A record id is required.");var d=_extends({},requestDefaults,r),o=d.bucket,i=d.headers,n=d.permissions,a=d.safe,s=d.patch,u=d.last_modified;return{method:s?"PATCH":"PUT",path:(0,_endpoint2["default"])("record",o,e,t.id),headers:_extends({},i,safeHeader(a,u||t.last_modified)),body:{data:t,permissions:n}}}function deleteRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if("object"!==("undefined"==typeof t?"undefined":_typeof(t)))throw new Error("A record object is required.");if(!t.id)throw new Error("A record id is required.");var d=_extends({},requestDefaults,{last_modified:t.last_modified},r),o=d.bucket,i=d.headers,n=d.safe,a=d.last_modified;if(n&&!a)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("record",o,e,t.id),headers:_extends({},i,safeHeader(n,a)),body:{data:t}}}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var d in r)Object.prototype.hasOwnProperty.call(r,d)&&(e[d]=r[d])}return e};exports.createBucket=createBucket,exports.updateBucket=updateBucket,exports.deleteBucket=deleteBucket,exports.createCollection=createCollection,exports.updateCollection=updateCollection,exports.deleteCollection=deleteCollection,exports.createRecord=createRecord,exports.updateRecord=updateRecord,exports.deleteRecord=deleteRecord;var _endpoint=require("./endpoint"),_endpoint2=_interopRequireDefault(_endpoint),requestDefaults={safe:!1,headers:{},bucket:"default",permissions:{},data:{},patch:!1};

@@ -44,0 +44,0 @@ },{"./endpoint":10}],15:[function(require,module,exports){

@@ -37,3 +37,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.KintoClient = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

},{"./batch":6,"./bucket":7,"./endpoint":9,"./http.js":11,"./requests":13,"./utils.js":14,"events":2,"isomorphic-fetch":1}],13:[function(require,module,exports){
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function doNotOverwrite(e){return e?{"If-None-Match":"*"}:{}}function concurrencyCheck(e,t){if(!e)return{};if(!t)throw new Error("Safe concurrency check requires a last_modified value.");return{"If-Match":'"'+t+'"'}}function createBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e)throw new Error("A bucket name is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.permissions,n=r.safe;return{method:"PUT",path:(0,_endpoint2["default"])("bucket",e),headers:_extends({},o,doNotOverwrite(n)),body:{permissions:d}}}function updateBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.permissions,n=r.safe,i=r.patch,s=r.last_modified;return{method:i?"PATCH":"PUT",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},o,concurrencyCheck(n,s||e.last_modified)),body:{data:e,permissions:d}}}function deleteBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),o=r.headers,d=r.safe,n=r.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},o,concurrencyCheck(d,n||e.last_modified)),body:{data:e}}}function createCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.permissions,i=r.data,s=r.safe,a=e?(0,_endpoint2["default"])("collection",o,e):(0,_endpoint2["default"])("collections",o);return{method:e?"PUT":"POST",path:a,headers:_extends({},d,doNotOverwrite(s)),body:{data:i,permissions:n}}}function updateCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.permissions,i=r.schema,s=r.metadata,a=r.safe,c=r.patch,u=r.last_modified,f=_extends({},s,e);return t.schema&&(f.schema=i),{method:c?"PATCH":"PUT",path:(0,_endpoint2["default"])("collection",o,e.id),headers:_extends({},d,concurrencyCheck(a,u||e.last_modified)),body:{data:f,permissions:n}}}function deleteCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),o=r.bucket,d=r.headers,n=r.safe,i=r.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("collection",o,e.id),headers:_extends({},d,concurrencyCheck(n,i||e.last_modified)),body:{data:e}}}function createRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.permissions,s=o.safe;return{method:t.id?"PUT":"POST",path:t.id?(0,_endpoint2["default"])("record",d,e,t.id):(0,_endpoint2["default"])("records",d,e),headers:_extends({},n,doNotOverwrite(s)),body:{data:t,permissions:i}}}function updateRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if(!t.id)throw new Error("A record id is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.permissions,s=o.safe,a=o.patch,c=o.last_modified;return{method:a?"PATCH":"PUT",path:(0,_endpoint2["default"])("record",d,e,t.id),headers:_extends({},n,concurrencyCheck(s,c||t.last_modified)),body:{data:t,permissions:i}}}function deleteRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if("object"!==("undefined"==typeof t?"undefined":_typeof(t)))throw new Error("A record object is required.");if(!t.id)throw new Error("A record id is required.");var o=_extends({},requestDefaults,r),d=o.bucket,n=o.headers,i=o.safe,s=o.last_modified;return{method:"DELETE",path:(0,_endpoint2["default"])("record",d,e,t.id),headers:_extends({},n,concurrencyCheck(i,s||t.last_modified)),body:{data:t}}}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};exports.createBucket=createBucket,exports.updateBucket=updateBucket,exports.deleteBucket=deleteBucket,exports.createCollection=createCollection,exports.updateCollection=updateCollection,exports.deleteCollection=deleteCollection,exports.createRecord=createRecord,exports.updateRecord=updateRecord,exports.deleteRecord=deleteRecord;var _endpoint=require("./endpoint"),_endpoint2=_interopRequireDefault(_endpoint),requestDefaults={safe:!1,headers:{},bucket:"default",permissions:{},data:{},patch:!1};
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function safeHeader(e,t){return e?t?{"If-Match":'"'+t+'"'}:{"If-None-Match":"*"}:{}}function createBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e)throw new Error("A bucket name is required.");var r=_extends({},requestDefaults,t),d=r.headers,o=r.permissions,i=r.safe;return{method:"PUT",path:(0,_endpoint2["default"])("bucket",e),headers:_extends({},d,safeHeader(i)),body:{permissions:o}}}function updateBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,t),d=r.headers,o=r.permissions,i=r.safe,n=r.patch,a=r.last_modified;return{method:n?"PATCH":"PUT",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},d,safeHeader(i,a||e.last_modified)),body:{data:e,permissions:o}}}function deleteBucket(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A bucket object is required.");if(!e.id)throw new Error("A bucket id is required.");var r=_extends({},requestDefaults,{last_modified:e.last_modified},t),d=r.headers,o=r.safe,i=r.last_modified;if(o&&!i)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("bucket",e.id),headers:_extends({},d,safeHeader(o,i)),body:{data:e}}}function createCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_extends({},requestDefaults,t),d=r.bucket,o=r.headers,i=r.permissions,n=r.data,a=r.safe,s=e?(0,_endpoint2["default"])("collection",d,e):(0,_endpoint2["default"])("collections",d);return{method:e?"PUT":"POST",path:s,headers:_extends({},o,safeHeader(a)),body:{data:n,permissions:i}}}function updateCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,t),d=r.bucket,o=r.headers,i=r.permissions,n=r.schema,a=r.metadata,s=r.safe,u=r.patch,c=r.last_modified,f=_extends({},a,e);return t.schema&&(f.schema=n),{method:u?"PATCH":"PUT",path:(0,_endpoint2["default"])("collection",d,e.id),headers:_extends({},o,safeHeader(s,c||e.last_modified)),body:{data:f,permissions:i}}}function deleteCollection(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("A collection object is required.");if(!e.id)throw new Error("A collection id is required.");var r=_extends({},requestDefaults,{last_modified:e.last_modified},t),d=r.bucket,o=r.headers,i=r.safe,n=r.last_modified;if(i&&!n)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("collection",d,e.id),headers:_extends({},o,safeHeader(i,n)),body:{data:e}}}function createRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");var d=_extends({},requestDefaults,r),o=d.bucket,i=d.headers,n=d.permissions,a=d.safe;return{method:t.id?"PUT":"POST",path:t.id?(0,_endpoint2["default"])("record",o,e,t.id):(0,_endpoint2["default"])("records",o,e),headers:_extends({},i,safeHeader(a)),body:{data:t,permissions:n}}}function updateRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if(!t.id)throw new Error("A record id is required.");var d=_extends({},requestDefaults,r),o=d.bucket,i=d.headers,n=d.permissions,a=d.safe,s=d.patch,u=d.last_modified;return{method:s?"PATCH":"PUT",path:(0,_endpoint2["default"])("record",o,e,t.id),headers:_extends({},i,safeHeader(a,u||t.last_modified)),body:{data:t,permissions:n}}}function deleteRecord(e,t){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if(!e)throw new Error("A collection name is required.");if("object"!==("undefined"==typeof t?"undefined":_typeof(t)))throw new Error("A record object is required.");if(!t.id)throw new Error("A record id is required.");var d=_extends({},requestDefaults,{last_modified:t.last_modified},r),o=d.bucket,i=d.headers,n=d.safe,a=d.last_modified;if(n&&!a)throw new Error("Safe concurrency check requires a last_modified value.");return{method:"DELETE",path:(0,_endpoint2["default"])("record",o,e,t.id),headers:_extends({},i,safeHeader(n,a)),body:{data:t}}}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var d in r)Object.prototype.hasOwnProperty.call(r,d)&&(e[d]=r[d])}return e};exports.createBucket=createBucket,exports.updateBucket=updateBucket,exports.deleteBucket=deleteBucket,exports.createCollection=createCollection,exports.updateCollection=updateCollection,exports.deleteCollection=deleteCollection,exports.createRecord=createRecord,exports.updateRecord=updateRecord,exports.deleteRecord=deleteRecord;var _endpoint=require("./endpoint"),_endpoint2=_interopRequireDefault(_endpoint),requestDefaults={safe:!1,headers:{},bucket:"default",permissions:{},data:{},patch:!1};

@@ -40,0 +40,0 @@ },{"./endpoint":9}],14:[function(require,module,exports){

@@ -32,3 +32,3 @@ "use strict";

function callWithOptions(requestFn, args, options) {
var newArgs = undefined;
var newArgs = void 0;
// Function.length doesn't count default arguments, so we're sure if we have

@@ -35,0 +35,0 @@ // a supplementary object arg, it's our request options object.

@@ -118,7 +118,7 @@ "use strict";

var response = undefined,
status = undefined,
statusText = undefined,
headers = undefined,
hasTimedout = undefined;
var response = void 0,
status = void 0,
statusText = void 0,
headers = void 0,
hasTimedout = void 0;
// Ensure default request headers are always set

@@ -191,3 +191,3 @@ options.headers = Object.assign({}, HTTP.DEFAULT_REQUEST_HEADERS, options.headers);

}
var alert = undefined;
var alert = void 0;
try {

@@ -205,3 +205,3 @@ alert = JSON.parse(alertHeader);

value: function _checkForBackoffHeader(status, headers) {
var backoffMs = undefined;
var backoffMs = void 0;
var backoffSeconds = parseInt(headers.get("Backoff"), 10);

@@ -208,0 +208,0 @@ if (backoffSeconds > 0) {

@@ -386,3 +386,3 @@ "use strict";

set: function set(url) {
var version = undefined;
var version = void 0;
try {

@@ -389,0 +389,0 @@ version = url.match(/\/(v\d+)\/?$/)[1];

@@ -37,14 +37,10 @@ "use strict";

function doNotOverwrite(safe) {
return safe ? { "If-None-Match": "*" } : {};
}
function concurrencyCheck(safe, last_modified) {
function safeHeader(safe, last_modified) {
if (!safe) {
return {};
}
if (!last_modified) {
throw new Error("Safe concurrency check requires a last_modified value.");
if (last_modified) {
return { "If-Match": "\"" + last_modified + "\"" };
}
return { "If-Match": "\"" + last_modified + "\"" };
return { "If-None-Match": "*" };
}

@@ -73,3 +69,3 @@

path: (0, _endpoint2.default)("bucket", bucketName),
headers: _extends({}, headers, doNotOverwrite(safe)),
headers: _extends({}, headers, safeHeader(safe)),
body: {

@@ -106,3 +102,3 @@ // XXX We can't pass the data option just yet, see Kinto/kinto/issues/239

path: (0, _endpoint2.default)("bucket", bucket.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || bucket.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified || bucket.last_modified)),
body: {

@@ -128,12 +124,17 @@ data: bucket,

var _requestDefaults$opti3 = _extends({}, requestDefaults, options);
var _requestDefaults$last = _extends({}, requestDefaults, {
last_modified: bucket.last_modified
}, options);
var headers = _requestDefaults$opti3.headers;
var safe = _requestDefaults$opti3.safe;
var last_modified = _requestDefaults$opti3.last_modified;
var headers = _requestDefaults$last.headers;
var safe = _requestDefaults$last.safe;
var last_modified = _requestDefaults$last.last_modified;
if (safe && !last_modified) {
throw new Error("Safe concurrency check requires a last_modified value.");
}
return {
method: "DELETE",
path: (0, _endpoint2.default)("bucket", bucket.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || bucket.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified)),
body: {

@@ -151,9 +152,9 @@ data: bucket

var _requestDefaults$opti4 = _extends({}, requestDefaults, options);
var _requestDefaults$opti3 = _extends({}, requestDefaults, options);
var bucket = _requestDefaults$opti4.bucket;
var headers = _requestDefaults$opti4.headers;
var permissions = _requestDefaults$opti4.permissions;
var data = _requestDefaults$opti4.data;
var safe = _requestDefaults$opti4.safe;
var bucket = _requestDefaults$opti3.bucket;
var headers = _requestDefaults$opti3.headers;
var permissions = _requestDefaults$opti3.permissions;
var data = _requestDefaults$opti3.data;
var safe = _requestDefaults$opti3.safe;
// XXX checks that provided data can't override schema when provided

@@ -165,3 +166,3 @@

path: path,
headers: _extends({}, headers, doNotOverwrite(safe)),
headers: _extends({}, headers, safeHeader(safe)),
body: { data: data, permissions: permissions }

@@ -184,12 +185,12 @@ };

var _requestDefaults$opti5 = _extends({}, requestDefaults, options);
var _requestDefaults$opti4 = _extends({}, requestDefaults, options);
var bucket = _requestDefaults$opti5.bucket;
var headers = _requestDefaults$opti5.headers;
var permissions = _requestDefaults$opti5.permissions;
var schema = _requestDefaults$opti5.schema;
var metadata = _requestDefaults$opti5.metadata;
var safe = _requestDefaults$opti5.safe;
var patch = _requestDefaults$opti5.patch;
var last_modified = _requestDefaults$opti5.last_modified;
var bucket = _requestDefaults$opti4.bucket;
var headers = _requestDefaults$opti4.headers;
var permissions = _requestDefaults$opti4.permissions;
var schema = _requestDefaults$opti4.schema;
var metadata = _requestDefaults$opti4.metadata;
var safe = _requestDefaults$opti4.safe;
var patch = _requestDefaults$opti4.patch;
var last_modified = _requestDefaults$opti4.last_modified;

@@ -203,3 +204,3 @@ var collectionData = _extends({}, metadata, collection);

path: (0, _endpoint2.default)("collection", bucket, collection.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || collection.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified || collection.last_modified)),
body: {

@@ -225,13 +226,18 @@ data: collectionData,

var _requestDefaults$opti6 = _extends({}, requestDefaults, options);
var _requestDefaults$last2 = _extends({}, requestDefaults, {
last_modified: collection.last_modified
}, options);
var bucket = _requestDefaults$opti6.bucket;
var headers = _requestDefaults$opti6.headers;
var safe = _requestDefaults$opti6.safe;
var last_modified = _requestDefaults$opti6.last_modified;
var bucket = _requestDefaults$last2.bucket;
var headers = _requestDefaults$last2.headers;
var safe = _requestDefaults$last2.safe;
var last_modified = _requestDefaults$last2.last_modified;
if (safe && !last_modified) {
throw new Error("Safe concurrency check requires a last_modified value.");
}
return {
method: "DELETE",
path: (0, _endpoint2.default)("collection", bucket, collection.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || collection.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified)),
body: {

@@ -253,8 +259,8 @@ data: collection

var _requestDefaults$opti7 = _extends({}, requestDefaults, options);
var _requestDefaults$opti5 = _extends({}, requestDefaults, options);
var bucket = _requestDefaults$opti7.bucket;
var headers = _requestDefaults$opti7.headers;
var permissions = _requestDefaults$opti7.permissions;
var safe = _requestDefaults$opti7.safe;
var bucket = _requestDefaults$opti5.bucket;
var headers = _requestDefaults$opti5.headers;
var permissions = _requestDefaults$opti5.permissions;
var safe = _requestDefaults$opti5.safe;

@@ -266,3 +272,3 @@ return {

path: record.id ? (0, _endpoint2.default)("record", bucket, collName, record.id) : (0, _endpoint2.default)("records", bucket, collName),
headers: _extends({}, headers, doNotOverwrite(safe)),
headers: _extends({}, headers, safeHeader(safe)),
body: {

@@ -288,10 +294,10 @@ data: record,

var _requestDefaults$opti8 = _extends({}, requestDefaults, options);
var _requestDefaults$opti6 = _extends({}, requestDefaults, options);
var bucket = _requestDefaults$opti8.bucket;
var headers = _requestDefaults$opti8.headers;
var permissions = _requestDefaults$opti8.permissions;
var safe = _requestDefaults$opti8.safe;
var patch = _requestDefaults$opti8.patch;
var last_modified = _requestDefaults$opti8.last_modified;
var bucket = _requestDefaults$opti6.bucket;
var headers = _requestDefaults$opti6.headers;
var permissions = _requestDefaults$opti6.permissions;
var safe = _requestDefaults$opti6.safe;
var patch = _requestDefaults$opti6.patch;
var last_modified = _requestDefaults$opti6.last_modified;

@@ -301,3 +307,3 @@ return {

path: (0, _endpoint2.default)("record", bucket, collName, record.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || record.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified || record.last_modified)),
body: {

@@ -326,13 +332,18 @@ data: record,

var _requestDefaults$opti9 = _extends({}, requestDefaults, options);
var _requestDefaults$last3 = _extends({}, requestDefaults, {
last_modified: record.last_modified
}, options);
var bucket = _requestDefaults$opti9.bucket;
var headers = _requestDefaults$opti9.headers;
var safe = _requestDefaults$opti9.safe;
var last_modified = _requestDefaults$opti9.last_modified;
var bucket = _requestDefaults$last3.bucket;
var headers = _requestDefaults$last3.headers;
var safe = _requestDefaults$last3.safe;
var last_modified = _requestDefaults$last3.last_modified;
if (safe && !last_modified) {
throw new Error("Safe concurrency check requires a last_modified value.");
}
return {
method: "DELETE",
path: (0, _endpoint2.default)("record", bucket, collName, record.id),
headers: _extends({}, headers, concurrencyCheck(safe, last_modified || record.last_modified)),
headers: _extends({}, headers, safeHeader(safe, last_modified)),
body: {

@@ -339,0 +350,0 @@ data: record

{
"name": "kinto-client",
"version": "0.4.1",
"version": "0.4.2",
"description": "JavaScript HTTP client for the Kinto API.",

@@ -41,9 +41,9 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.6.0",
"babel-core": "^6.6.0",
"babel-cli": "^6.6.5",
"babel-core": "^6.6.5",
"babel-eslint": "^5.0.0-beta6",
"babel-istanbul": "^0.6.1",
"babel-loader": "^6.2.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.3",
"babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.5",
"babel-plugin-transform-object-rest-spread": "^6.5.5",
"babel-polyfill": "^6.6.1",

@@ -57,6 +57,6 @@ "babel-preset-es2015": "^6.6.0",

"coveralls": "^2.11.8",
"esdoc": "^0.4.0",
"esdoc": "^0.4.6",
"esdoc-es7-plugin": "0.0.3",
"esdoc-importpath-plugin": "0.0.1",
"eslint": "^2.2.0",
"eslint": "2.2.0",
"mocha": "^2.3.4",

@@ -63,0 +63,0 @@ "sinon": "^1.17.2",

@@ -170,3 +170,3 @@ kinto-client

- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `safe`: If `last_modified` is provided, ensures the resource hasn't been modified since that timestamp. Otherwise ensures no existing resource with the provided id will be overriden (default: `false`);
- `last_modified`: The last timestamp we know the resource has been updated on the server.

@@ -372,3 +372,3 @@

- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `safe`: If `last_modified` is provided, ensures the resource hasn't been modified since that timestamp. Otherwise ensures no existing resource with the provided id will be overriden (default: `false`);
- `last_modified`: The last timestamp we know the resource has been updated on the server.

@@ -440,3 +440,3 @@

- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `safe`: If `last_modified` is provided, ensures the resource hasn't been modified since that timestamp. Otherwise ensures no existing resource with the provided id will be overriden (default: `false`);
- `last_modified`: The last timestamp we know the resource has been updated on the server.

@@ -479,3 +479,3 @@

- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `safe`: If `last_modified` is provided, ensures the resource hasn't been modified since that timestamp. Otherwise ensures no existing resource with the provided id will be overriden (default: `false`);
- `last_modified`: The last timestamp we know the resource has been updated on the server.

@@ -533,3 +533,3 @@

- `headers`: Custom headers object to send along the HTTP request;
XXX
- `safe`: Whether to override existing resource if it already exists and if an id is provided (default: `false`)

@@ -602,3 +602,3 @@ ### Retrieving an existing record

- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided; otherwise ensures the record won't be overridden if it already exists on the server (default: `false`).
- `safe`: If `last_modified` is provided, ensures the resource hasn't been modified since that timestamp. Otherwise ensures no existing resource with the provided id will be overriden (default: `false`);

@@ -629,3 +629,3 @@ ### Deleting record

- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `last_modified`: The last timestamp we know the resource has been updated on the server.
- `last_modified`: When `safe` is true, the last timestamp we know the resource has been updated on the server.

@@ -738,5 +738,4 @@ ### Listing records

- `filters`: An object defining the filters to apply; read more about [what's supported](http://kinto.readthedocs.org/en/latest/api/1.x/cliquet/resource.html#filtering);
- `since`: The ETag header value received from the last response from the server.
- `headers`: Custom headers object to send along the HTTP request;
- `safe`: Ensures the resource hasn't been modified in the meanwhile if `last_modified` is provided (default: `false`);
- `since`: The ETag header value received from the last response from the server.

@@ -892,3 +891,3 @@ ### Batching operations

- when creating a new resource, to ensure that any already existing record matching the provided ID won't be overridden if it exists on the server;
- when creating or updating a resource, to ensure that any already existing record matching the provided ID won't be overridden if it exists on the server;
- when updating or deleting a resource, to ensure it won't be overridden remotely if it has changed in the meanwhile on the server (requires a `last_modified` value to be provided).

@@ -919,2 +918,4 @@

If no `last_modified` value is provided at all, a safe update will simply guarantee that an existing resource with the provided ID won't be overriden.
### Safe deletions

@@ -921,0 +922,0 @@

Sorry, the diff of this file is too big to display

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