@data-client/rest 0.9.2 → 0.9.3

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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@data-client/endpoint"),require("path-to-regexp")):"function"==typeof define&&define.amd?define(["exports","@data-client/endpoint","path-to-regexp"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).dataClientRest={},t.endpoint,t.pathToRegexp)}(this,(function(t,e,n){"use strict";function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}var i=s(r((function(t){t.exports=function(t){if(null==t)throw new TypeError("Cannot destructure "+t)},t.exports.__esModule=!0,t.exports.default=t.exports}))),o=s(r((function(t){t.exports=function(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t},t.exports.__esModule=!0,t.exports.default=t.exports}))),a=s(r((function(t){var e=0;t.exports=function(t){return"__private_"+e+++"_"+t},t.exports.__esModule=!0,t.exports.default=t.exports})));function c(t,n){if("object"!=typeof t||void 0===t||Array.isArray(t))return;if(t instanceof e.schema.Collection)return n(t);const s=Object.assign({},t instanceof e.schema.Object?t.schema:t);for(const t in s){if(!s[t])continue;const e=c(s[t],n);if(e)return e}}function h(t,n){if("object"!=typeof t||void 0===t)return t;if(t instanceof e.schema.Collection)return n(t);const s=Object.assign({},t instanceof e.schema.Object?t.schema:t);for(const t in s)s[t]&&(s[t]=h(s[t],n));return s}class u extends Error{constructor(t){super(t.statusText||`Network response not 'ok': ${t.status}`),this.name="NetworkError",this.status=t.status,this.response=t}}function p(t,e){const n=new Set(t),s=[...t];for(const t of e)n.has(t)||s.push(t);return s}const f=Object.create(null);const d=Object.create(null);const l=Object.prototype,g=Object.getPrototypeOf;var m=a("hasBody");class O extends e.Endpoint{constructor(t){var e;super(null!=(e=t.fetch)?e:async function(...t){const e=o(this,m)[m]&&t.length<2?{}:t[0]||{},n=o(this,m)[m]?t[t.length-1]:void 0;return this.fetchResponse(this.url(e),await this.getRequestInit(n)).then((t=>this.parseResponse(t))).then((e=>this.process(e,...t)))},t),Object.defineProperty(this,m,{writable:!0,value:void 0}),(!("sideEffect"in this)||"method"in t&&!("sideEffect"in t))&&(this.sideEffect="GET"!==t.method&&void 0!==t.method||void 0),void 0===this.method&&(this.method=this.sideEffect?"POST":"GET"),void 0===this.urlPrefix&&(this.urlPrefix=""),o(this,m)[m]=!("body"in this&&void 0===this.body||["GET","DELETE"].includes(this.method)),Object.defineProperty(this,"name",{get(){return"__name"in this?this.__name:this.urlPrefix+this.path}})}key(...t){return`${this.method} ${this.url(o(this,m)[m]&&t.length<2?{}:t[0]||{})}`}url(t={}){const e=((s=this.path)in f||(f[s]=n.compile(s,{encode:encodeURIComponent,validate:!1})),f[s])(t);var s;const r=function(t){return t in d||(d[t]=new Set(n.parse(t).map((t=>"string"==typeof t?t:`${t.name}`)))),d[t]}(this.path),i={};return Object.keys(t).forEach((e=>{r.has(e)||(i[e]=t[e])})),Object.keys(i).length?`${this.urlPrefix}${e}?${function(t){const e=new URLSearchParams(t);return e.sort(),e.toString()}(i)}`:`${this.urlPrefix}${e}`}getHeaders(t){return t}async getRequestInit(t){const e=null!==(n=t)&&"object"==typeof n&&g(n)===l;var n;e&&(t=JSON.stringify(t));const s=Object.assign({},this.requestInit,{method:this.method,signal:this.signal,body:t});return t&&!e||(s.headers=Object.assign({"Content-Type":"application/json"},s.headers)),s.headers=await this.getHeaders(s.headers),s}fetchResponse(t,e){return fetch(t,e).then((t=>{if(!t.ok)throw new u(t);return t})).catch((t=>{throw t instanceof TypeError&&(t.status=500),t}))}parseResponse(t){var e;return 204===t.status?Promise.resolve(null):null!=(e=t.headers.get("content-type"))&&e.includes("json")?t.json().catch((t=>{throw t.status=400,t})):t.text().then((e=>{if(["string","undefined"].includes(typeof this.schema)||null===this.schema||this.process!==O.prototype.process)return e;const n=new u(t);throw n.status=404,n.message=`Unexpected text response for schema ${this.schema}`,n}))}process(t){return t}errorPolicy(t){return t.status>=500?"soft":void 0}get pathRegex(){return n.pathToRegexp(this.path)}testKey(t){const e=this.method+" "+this.urlPrefix;if(!t.startsWith(e))return!1;let n=t.lastIndexOf("?");return-1===n&&(n=void 0),this.pathRegex.test(t.substring(e.length,n))}extend(t){class e extends this.constructor{}return Object.assign(e.prototype,this),new e(Object.assign({fetch:this.fetch},t))}paginated(t){if("string"==typeof t){const e=t;t=t=>{let n=Object.assign({},(i(t),t));return delete n[e],[n]}}let e=!1;const n=h(this.schema,(n=>(e=!0,function(t,e){return Object.create(e,{name:{value:`Pagination(${e.schema})`},merge:{value:p},pk:{value:function(n,s,r,i){return e.pk.call(this,n,s,r,t(...i))}}})}(t,n))));if(!e)throw new Error("Missing Collection");const s=this;return this.extend({schema:n,key(...e){return s.key.call(this,...t(...e))},name:this.name+".getPage"})}get getPage(){return this.paginated(this.paginationField)}get push(){return this.extend({method:"POST",schema:c(this.schema,(t=>t.push)),name:this.name+".create"})}get unshift(){return this.extend({method:"POST",schema:c(this.schema,(t=>t.unshift)),name:this.name+".create"})}get assign(){return this.extend({method:"POST",schema:c(this.schema,(t=>t.assign)),name:this.name+".create"})}}var b=s(r((function(t){t.exports=function(t,e){if(null==t)return{};var n,s,r={},i=Object.keys(t);for(s=0;s<i.length;s++)n=i[s],e.indexOf(n)>=0||(r[n]=t[n]);return r},t.exports.__esModule=!0,t.exports.default=t.exports})));const x=["path","schema","Endpoint","Collection","optimistic","paginationField"],{Invalidate:y,Collection:j}=e.schema;function w(t,e,n){return Object.assign({},e,E(n))}function v(t,e){return e}function E(t){return t instanceof FormData?Object.fromEntries(t.entries()):t}Object.hasOwn=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.NetworkError=u,t.RestEndpoint=O,t.createResource=function(t){let{path:n,schema:s,Endpoint:r=O,Collection:i=j,optimistic:o,paginationField:a}=t,c=b(t,x);const h=function(t){const e=t.lastIndexOf(":");if(-1===e)throw new Error("Resource path requires at least one :parameter");let n=t.substring(0,e);return"/"===n[n.length-1]&&(n=n.substring(0,n.length-1)),n}(n),u=t=>`${null==s?void 0:s.name}.${t}`;function p(t,e,n){t[e]=t[e].extend(n)}const f=Object.assign({},c),d=Object.assign({},c),l=new r(Object.assign({},c,{path:n,schema:s,name:u("get")}));var g;o&&(f.getOptimisticResponse=w,d.getOptimisticResponse=(g=l,function(t,n,s){const{data:r}=t.getResponse(g,n);if(!r)throw new e.AbortOptimistic;return Object.assign({},n,r,E(s))}));const m=new r(Object.assign({},f,{paginationField:a,path:h,schema:new i([s]),name:u("getList")}));return{get:l,getList:m,create:m.push.extend({name:u("create")}),update:new r(Object.assign({},f,{path:n,schema:s,method:"PUT",name:u("update")})),partialUpdate:new r(Object.assign({},d,{path:n,schema:s,method:"PATCH",name:u("partialUpdate")})),delete:new r(Object.assign({},f,{path:n,schema:s.process?new y(s):s,method:"DELETE",name:u("delete"),process:(t,e)=>t&&Object.keys(t).length?t:e,getOptimisticResponse:o?v:void 0})),extend(...t){if("string"==typeof t[0]){const[e,n]=t;if(e in this){const t=Object.assign({},this);return p(t,e,n),t}return Object.assign({},this,{[e]:this.get.extend(n)})}if("function"==typeof t[0]){const e=t[0](this);return Object.assign({},this,e)}const e=t[0],n=Object.assign({},this);for(const t in e)p(n,t,e[t]);return n}}},t.hookifyResource=function(t,e){const n={};return Object.keys(t).forEach((s=>{const r=t[s];var i;void 0!==r.extend&&(n[`use${i=s,i.charAt(0).toUpperCase()+i.slice(1)}`]=()=>{const t=e();return r.extend({requestInit:t})})})),n},Object.keys(e).forEach((function(n){"default"===n||t.hasOwnProperty(n)||Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@data-client/endpoint")):"function"==typeof define&&define.amd?define(["exports","@data-client/endpoint"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Rest={},e.endpoint)}(this,(function(e,t){"use strict";function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e,t){return e(t={exports:{}},t.exports),t.exports}var i=n(r((function(e){e.exports=function(e){if(null==e)throw new TypeError("Cannot destructure "+e)},e.exports.__esModule=!0,e.exports.default=e.exports}))),o=n(r((function(e){e.exports=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e},e.exports.__esModule=!0,e.exports.default=e.exports}))),s=n(r((function(e){var t=0;e.exports=function(e){return"__private_"+t+++"_"+e},e.exports.__esModule=!0,e.exports.default=e.exports})));function a(e,t){void 0===t&&(t={});for(var n=function(e){for(var t=[],n=0;n<e.length;){var r=e[n];if("*"!==r&&"+"!==r&&"?"!==r)if("\\"!==r)if("{"!==r)if("}"!==r)if(":"!==r)if("("!==r)t.push({type:"CHAR",index:n,value:e[n++]});else{var i=1,o="";if("?"===e[a=n+1])throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;)if("\\"!==e[a]){if(")"===e[a]){if(0==--i){a++;break}}else if("("===e[a]&&(i++,"?"!==e[a+1]))throw new TypeError("Capturing groups are not allowed at ".concat(a));o+=e[a++]}else o+=e[a++]+e[a++];if(i)throw new TypeError("Unbalanced pattern at ".concat(n));if(!o)throw new TypeError("Missing pattern at ".concat(n));t.push({type:"PATTERN",index:n,value:o}),n=a}else{for(var s="",a=n+1;a<e.length;){var c=e.charCodeAt(a);if(!(c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||95===c))break;s+=e[a++]}if(!s)throw new TypeError("Missing parameter name at ".concat(n));t.push({type:"NAME",index:n,value:s}),n=a}else t.push({type:"CLOSE",index:n,value:e[n++]});else t.push({type:"OPEN",index:n,value:e[n++]});else t.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});else t.push({type:"MODIFIER",index:n,value:e[n++]})}return t.push({type:"END",index:n,value:""}),t}(e),r=t.prefixes,i=void 0===r?"./":r,o="[^".concat(u(t.delimiter||"/#?"),"]+?"),s=[],a=0,c=0,f="",h=function(e){if(c<n.length&&n[c].type===e)return n[c++].value},p=function(e){var t=h(e);if(void 0!==t)return t;var r=n[c],i=r.type,o=r.index;throw new TypeError("Unexpected ".concat(i," at ").concat(o,", expected ").concat(e))},d=function(){for(var e,t="";e=h("CHAR")||h("ESCAPED_CHAR");)t+=e;return t};c<n.length;){var l=h("CHAR"),m=h("NAME"),g=h("PATTERN");if(m||g){var v=l||"";-1===i.indexOf(v)&&(f+=v,v=""),f&&(s.push(f),f=""),s.push({name:m||a++,prefix:v,suffix:"",pattern:g||o,modifier:h("MODIFIER")||""})}else{var x=l||h("ESCAPED_CHAR");if(x)f+=x;else if(f&&(s.push(f),f=""),h("OPEN")){v=d();var y=h("NAME")||"",O=h("PATTERN")||"",E=d();p("CLOSE"),s.push({name:y||(O?a++:""),pattern:y&&!O?o:O,prefix:v,suffix:E,modifier:h("MODIFIER")||""})}else p("END")}}return s}function c(e,t){return function(e,t){void 0===t&&(t={});var n=f(t),r=t.encode,i=void 0===r?function(e){return e}:r,o=t.validate,s=void 0===o||o,a=e.map((function(e){if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),n)}));return function(t){for(var n="",r=0;r<e.length;r++){var o=e[r];if("string"!=typeof o){var c=t?t[o.name]:void 0,u="?"===o.modifier||"*"===o.modifier,f="*"===o.modifier||"+"===o.modifier;if(Array.isArray(c)){if(!f)throw new TypeError('Expected "'.concat(o.name,'" to not repeat, but got an array'));if(0===c.length){if(u)continue;throw new TypeError('Expected "'.concat(o.name,'" to not be empty'))}for(var h=0;h<c.length;h++){var p=i(c[h],o);if(s&&!a[r].test(p))throw new TypeError('Expected all "'.concat(o.name,'" to match "').concat(o.pattern,'", but got "').concat(p,'"'));n+=o.prefix+p+o.suffix}}else if("string"!=typeof c&&"number"!=typeof c){if(!u){var d=f?"an array":"a string";throw new TypeError('Expected "'.concat(o.name,'" to be ').concat(d))}}else{p=i(String(c),o);if(s&&!a[r].test(p))throw new TypeError('Expected "'.concat(o.name,'" to match "').concat(o.pattern,'", but got "').concat(p,'"'));n+=o.prefix+p+o.suffix}}else n+=o}return n}}(a(e,t),t)}function u(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function f(e){return e&&e.sensitive?"":"i"}function h(e,t,n){return function(e,t,n){void 0===n&&(n={});for(var r=n.strict,i=void 0!==r&&r,o=n.start,s=void 0===o||o,a=n.end,c=void 0===a||a,h=n.encode,p=void 0===h?function(e){return e}:h,d=n.delimiter,l=void 0===d?"/#?":d,m=n.endsWith,g="[".concat(u(void 0===m?"":m),"]|$"),v="[".concat(u(l),"]"),x=s?"^":"",y=0,O=e;y<O.length;y++){var E=O[y];if("string"==typeof E)x+=u(p(E));else{var b=u(p(E.prefix)),w=u(p(E.suffix));if(E.pattern)if(t&&t.push(E),b||w)if("+"===E.modifier||"*"===E.modifier){var j="*"===E.modifier?"?":"";x+="(?:".concat(b,"((?:").concat(E.pattern,")(?:").concat(w).concat(b,"(?:").concat(E.pattern,"))*)").concat(w,")").concat(j)}else x+="(?:".concat(b,"(").concat(E.pattern,")").concat(w,")").concat(E.modifier);else"+"===E.modifier||"*"===E.modifier?x+="((?:".concat(E.pattern,")").concat(E.modifier,")"):x+="(".concat(E.pattern,")").concat(E.modifier);else x+="(?:".concat(b).concat(w,")").concat(E.modifier)}}if(c)i||(x+="".concat(v,"?")),x+=n.endsWith?"(?=".concat(g,")"):"$";else{var P=e[e.length-1],R="string"==typeof P?v.indexOf(P[P.length-1])>-1:void 0===P;i||(x+="(?:".concat(v,"(?=").concat(g,"))?")),R||(x+="(?=".concat(v,"|").concat(g,")"))}return new RegExp(x,f(n))}(a(e,n),t,n)}function p(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;for(var n=/\((?:\?<(.*?)>)?(?!\?)/g,r=0,i=n.exec(e.source);i;)t.push({name:i[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),i=n.exec(e.source);return e}(e,t):Array.isArray(e)?function(e,t,n){var r=e.map((function(e){return p(e,t,n).source}));return new RegExp("(?:".concat(r.join("|"),")"),f(n))}(e,t,n):h(e,t,n)}function d(e,n){if("object"!=typeof e||void 0===e||Array.isArray(e))return;if(e instanceof t.schema.Collection)return n(e);const r=Object.assign({},e instanceof t.schema.Object?e.schema:e);for(const e in r){if(!r[e])continue;const t=d(r[e],n);if(t)return t}}function l(e,n){if("object"!=typeof e||void 0===e)return e;if(e instanceof t.schema.Collection)return n(e);const r=Object.assign({},e instanceof t.schema.Object?e.schema:e);for(const e in r)r[e]&&(r[e]=l(r[e],n));return r}class m extends Error{constructor(e){super(e.statusText||`Network response not 'ok': ${e.status}`),this.name="NetworkError",this.status=e.status,this.response=e}}function g(e,t){const n=new Set(e),r=[...e];for(const e of t)n.has(e)||r.push(e);return r}const v=Object.create(null);const x=Object.create(null);const y=Object.prototype,O=Object.getPrototypeOf;var E=s("hasBody");class b extends t.Endpoint{constructor(e){var t;super(null!=(t=e.fetch)?t:async function(...e){const t=o(this,E)[E]&&e.length<2?{}:e[0]||{},n=o(this,E)[E]?e[e.length-1]:void 0;return this.fetchResponse(this.url(t),await this.getRequestInit(n)).then((e=>this.parseResponse(e))).then((t=>this.process(t,...e)))},e),Object.defineProperty(this,E,{writable:!0,value:void 0}),(!("sideEffect"in this)||"method"in e&&!("sideEffect"in e))&&(this.sideEffect="GET"!==e.method&&void 0!==e.method||void 0),void 0===this.method&&(this.method=this.sideEffect?"POST":"GET"),void 0===this.urlPrefix&&(this.urlPrefix=""),o(this,E)[E]=!("body"in this&&void 0===this.body||["GET","DELETE"].includes(this.method)),Object.defineProperty(this,"name",{get(){return"__name"in this?this.__name:this.urlPrefix+this.path}})}key(...e){return`${this.method} ${this.url(o(this,E)[E]&&e.length<2?{}:e[0]||{})}`}url(e={}){const t=((n=this.path)in v||(v[n]=c(n,{encode:encodeURIComponent,validate:!1})),v[n])(e);var n;const r=function(e){return e in x||(x[e]=new Set(a(e).map((e=>"string"==typeof e?e:`${e.name}`)))),x[e]}(this.path),i={};return Object.keys(e).forEach((t=>{r.has(t)||(i[t]=e[t])})),Object.keys(i).length?`${this.urlPrefix}${t}?${function(e){const t=new URLSearchParams(e);return t.sort(),t.toString()}(i)}`:`${this.urlPrefix}${t}`}getHeaders(e){return e}async getRequestInit(e){const t=null!==(n=e)&&"object"==typeof n&&O(n)===y;var n;t&&(e=JSON.stringify(e));const r=Object.assign({},this.requestInit,{method:this.method,signal:this.signal,body:e});return e&&!t||(r.headers=Object.assign({"Content-Type":"application/json"},r.headers)),r.headers=await this.getHeaders(r.headers),r}fetchResponse(e,t){return fetch(e,t).then((e=>{if(!e.ok)throw new m(e);return e})).catch((e=>{throw e instanceof TypeError&&(e.status=500),e}))}parseResponse(e){var t;return 204===e.status?Promise.resolve(null):null!=(t=e.headers.get("content-type"))&&t.includes("json")?e.json().catch((e=>{throw e.status=400,e})):e.text().then((t=>{if(["string","undefined"].includes(typeof this.schema)||null===this.schema||this.process!==b.prototype.process)return t;const n=new m(e);throw n.status=404,n.message=`Unexpected text response for schema ${this.schema}`,n}))}process(e){return e}errorPolicy(e){return e.status>=500?"soft":void 0}get pathRegex(){return p(this.path)}testKey(e){const t=this.method+" "+this.urlPrefix;if(!e.startsWith(t))return!1;let n=e.lastIndexOf("?");return-1===n&&(n=void 0),this.pathRegex.test(e.substring(t.length,n))}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(Object.assign({fetch:this.fetch},e))}paginated(e){if("string"==typeof e){const t=e;e=e=>{let n=Object.assign({},(i(e),e));return delete n[t],[n]}}let t=!1;const n=l(this.schema,(n=>(t=!0,function(e,t){return Object.create(t,{name:{value:`Pagination(${t.schema})`},merge:{value:g},pk:{value:function(n,r,i,o){return t.pk.call(this,n,r,i,e(...o))}}})}(e,n))));if(!t)throw new Error("Missing Collection");const r=this;return this.extend({schema:n,key(...t){return r.key.call(this,...e(...t))},name:this.name+".getPage"})}get getPage(){return this.paginated(this.paginationField)}get push(){return this.extend({method:"POST",schema:d(this.schema,(e=>e.push)),name:this.name+".create"})}get unshift(){return this.extend({method:"POST",schema:d(this.schema,(e=>e.unshift)),name:this.name+".create"})}get assign(){return this.extend({method:"POST",schema:d(this.schema,(e=>e.assign)),name:this.name+".create"})}}var w=n(r((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i},e.exports.__esModule=!0,e.exports.default=e.exports})));const j=["path","schema","Endpoint","Collection","optimistic","paginationField"],{Invalidate:P,Collection:R}=t.schema;function T(e,t,n){return Object.assign({},t,C(n))}function A(e,t){return t}function C(e){return e instanceof FormData?Object.fromEntries(e.entries()):e}Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e.NetworkError=m,e.RestEndpoint=b,e.createResource=function(e){let{path:n,schema:r,Endpoint:i=b,Collection:o=R,optimistic:s,paginationField:a}=e,c=w(e,j);const u=function(e){const t=e.lastIndexOf(":");if(-1===t)throw new Error("Resource path requires at least one :parameter");let n=e.substring(0,t);return"/"===n[n.length-1]&&(n=n.substring(0,n.length-1)),n}(n),f=e=>`${null==r?void 0:r.name}.${e}`;function h(e,t,n){e[t]=e[t].extend(n)}const p=Object.assign({},c),d=Object.assign({},c),l=new i(Object.assign({},c,{path:n,schema:r,name:f("get")}));var m;s&&(p.getOptimisticResponse=T,d.getOptimisticResponse=(m=l,function(e,n,r){const{data:i}=e.getResponse(m,n);if(!i)throw new t.AbortOptimistic;return Object.assign({},n,i,C(r))}));const g=new i(Object.assign({},p,{paginationField:a,path:u,schema:new o([r]),name:f("getList")}));return{get:l,getList:g,create:g.push.extend({name:f("create")}),update:new i(Object.assign({},p,{path:n,schema:r,method:"PUT",name:f("update")})),partialUpdate:new i(Object.assign({},d,{path:n,schema:r,method:"PATCH",name:f("partialUpdate")})),delete:new i(Object.assign({},p,{path:n,schema:r.process?new P(r):r,method:"DELETE",name:f("delete"),process:(e,t)=>e&&Object.keys(e).length?e:t,getOptimisticResponse:s?A:void 0})),extend(...e){if("string"==typeof e[0]){const[t,n]=e;if(t in this){const e=Object.assign({},this);return h(e,t,n),e}return Object.assign({},this,{[t]:this.get.extend(n)})}if("function"==typeof e[0]){const t=e[0](this);return Object.assign({},this,t)}const t=e[0],n=Object.assign({},this);for(const e in t)h(n,e,t[e]);return n}}},e.hookifyResource=function(e,t){const n={};return Object.keys(e).forEach((r=>{const i=e[r];var o;void 0!==i.extend&&(n[`use${o=r,o.charAt(0).toUpperCase()+o.slice(1)}`]=()=>{const e=t();return i.extend({requestInit:e})})})),n},Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-client/rest",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Endpoints for REST APIs",
5
5
  "homepage": "https://dataclient.io/rest",
6
6
  "repository": {
@@ -124,7 +124,7 @@
124
124
  "license": "Apache-2.0",
125
125
  "dependencies": {
126
126
  "@babel/runtime": "^7.17.0",
127
- "@data-client/endpoint": "^0.9.2",
127
+ "@data-client/endpoint": "^0.9.3",
128
128
  "path-to-regexp": "^6.2.1"
129
129
  },
130
130
  "devDependencies": {