@data-client/rest 0.14.8 → 0.14.9

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.
package/README.md CHANGED
@@ -130,6 +130,14 @@ const allRemainingTodos = useQuery(queryRemainingTodos);
130
130
  const firstUserRemainingTodos = useQuery(queryRemainingTodos, { userId: 1 });
131
131
  ```
132
132
 
133
+ ```typescript
134
+ const groupTodoByUser = new schema.Query(
135
+ TodoResource.getList.schema,
136
+ todos => Object.groupBy(todos, todo => todo.userId),
137
+ );
138
+ const todosByUser = useQuery(groupTodoByUser);
139
+ ```
140
+
133
141
  ### TypeScript requirements
134
142
 
135
143
  TypeScript is optional, but will only work with 4.0 or above. 4.1 is needed for stronger types as it
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ function mapCollection(s, mapper) {
71
71
  */
72
72
  class NetworkError extends Error {
73
73
  constructor(response) {
74
- super(response.statusText || `Network response not 'ok': ${response.status}`);
74
+ super(`${response.url}: ${response.statusText || `Status not 'ok': ${response.status}`}`);
75
75
  this.name = 'NetworkError';
76
76
  this.status = response.status;
77
77
  this.response = response;
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Rest={})}(this,(function(e){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t(n((function(e){e.exports=function(e){if(null==e)throw new TypeError("Cannot destructure "+e)},e.exports.__esModule=!0,e.exports.default=e.exports}))),s=t(n((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}))),i=t(n((function(e){var t=0;e.exports=function(e){return"__private_"+t+++"_"+e},e.exports.__esModule=!0,e.exports.default=e.exports})));function o(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}class c{constructor(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){"_schemaAttribute"in e&&!this._schemaAttribute?(this.schema=e.schema,this._schemaAttribute=e._schemaAttribute):this.schema=e}getSchemaAttribute(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}inferSchema(e,t,n){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,n);return this.schema[r]}schemaKey(){return this.isSingleSchema?this.schema.key:Object.values(this.schema).join(";")}normalizeValue(e,t,n,r,s){if(!e)return e;const i=this.inferSchema(e,t,n);if(!i)return e;const o=s(i,e,t,n,r);return this.isSingleSchema||null==o?o:{id:o,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(e,t){const n=!this.isSingleSchema&&e&&(o(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!n){if("object"==typeof e&&null!==e){const n=this.inferSchema(e,void 0,void 0);if(n)return t(n,e)}return e}const r=this.isSingleSchema?void 0:o(e)?e.get("id"):e.id;return t(this.isSingleSchema?this.schema:this.schema[n],r||e)}}class a extends c{normalize(e,t,n,r,s,i,o,c){return Object.keys(e).reduce(((t,n,i)=>{const o=e[n];return null!=o?Object.assign({},t,{[n]:this.normalizeValue(o,e,n,r,s)}):t}),{})}denormalize(e,t,n){return Object.keys(e).reduce(((t,r)=>{const s=e[r],i=this.denormalizeValue(s,n);return i&&"symbol"!=typeof i?Object.assign({},t,{[r]:i}):t}),{})}queryKey(e,t,n,r){}}const u=e=>void 0!==e&&"symbol"!=typeof e;class h extends c{normalize(e,t,n,r,s,i,o,c){const a=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return a.map(((e,i)=>this.normalizeValue(e,t,n,r,s)))}denormalize(e,t,n){return e.map?e.map((e=>this.denormalizeValue(e,n))).filter(u):e}queryKey(e,t,n,r){}toJSON(){return[this.schema]}}const l=Symbol("INVALID");function f(e,t,n,r){if(o(t))return function(e,t,n){var r;let s;const i=Object.keys(e).reduce(((t,r)=>{const i=`${r}`,o=n(e[i],t.get(i));return"symbol"==typeof o&&(s=o),t.has(i)?t.set(i,o):t}),t);return null!=(r=s)?r:i}(e,t,r);const s=Object.assign({},t);for(const t of Object.keys(e)){const n=r(e[t],s[t]);if(void 0!==s[t]&&(s[t]=n),"symbol"==typeof n)return n}return s}class d{constructor(e){this.schema=void 0,this.define(e)}define(e){this.schema=Object.keys(e).reduce(((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})}),this.schema||{})}normalize(...e){return((e,t,n,r,s,i,o,c,a)=>{const u=Object.assign({},t);return Object.keys(e).forEach((n=>{const r=e[n],o=i(r,t[n],t,n,s);void 0===o?delete u[n]:u[n]=o})),u})(this.schema,...e)}denormalize(e,t,n){return f(this.schema,e,0,n)}queryKey(e,t,n,r){return function(e,t,n,r,s){const i={};return Object.keys(e).forEach((o=>{i[o]=n(e[o],t,r,s)})),i}(this.schema,e,t,n,r)}}const p=(e,t)=>[...e,...t],m=(e,t)=>[...t,...e],y=(e,t)=>Object.assign({},e,t),g=e=>[...e],b=e=>Object.assign({},e);class v{addWith(e,t){return O(this,e,t)}createCollectionFilter(...e){return t=>Object.entries(t).every((([t,n])=>{var r;return this.nonFilterArgumentKeys(t)||`${e[0][t]}`===n||`${null==(r=e[1])?void 0:r[t]}`===n}))}nonFilterArgumentKeys(e){return e.startsWith("order")}constructor(e,t){if(this.schema=Array.isArray(e)?new h(e[0]):e,t?"nestKey"in t?this.nestKey=t.nestKey:this.argsKey="argsKey"in t?t.argsKey:e=>Object.assign({},e):this.argsKey=e=>Object.assign({},e),this.key=function(e){if(e instanceof h)return`[${e.schemaKey()}]`;if(e instanceof a)return`{${e.schemaKey()}}`;return`(${e.schemaKey()})`}(this.schema),null!=t&&t.nonFilterArgumentKeys){const{nonFilterArgumentKeys:e}=t;"function"==typeof e?this.nonFilterArgumentKeys=e:e instanceof RegExp?this.nonFilterArgumentKeys=t=>e.test(t):this.nonFilterArgumentKeys=t=>e.includes(t)}else null!=t&&t.createCollectionFilter&&(this.createCollectionFilter=t.createCollectionFilter.bind(this));this.schema instanceof h?(this.createIfValid=g,this.push=O(this,p),this.unshift=O(this,m)):e instanceof a&&(this.createIfValid=b,this.assign=O(this,y))}get cacheWith(){return this.schema.schema}toString(){return this.key}toJSON(){return{key:this.key,schema:this.schema.schema.toJSON()}}pk(e,t,n,r){const s=this.argsKey?this.argsKey(...r):this.nestKey(t,n);for(const e in s)"string"!=typeof s[e]&&void 0!==s[e]&&(s[e]=`${s[e]}`);return function(e){const t=Object.keys(e).sort(),n={};for(const r of t)n[r]=e[r];return JSON.stringify(n)}(s)}normalize(e,t,n,r,s,i,o,c){const a=this.schema.normalize(e,t,n,r,s,i,o,c),u=this.pk(a,t,n,r);return i(this,a,u),u}merge(e,t){return t}shouldReorder(e,t,n,r){return t.fetchedAt<e.fetchedAt}mergeWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?this.merge(r,n):this.merge(n,r)}mergeMetaWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?e:t}queryKey(e,t,n,r){if(this.argsKey){const t=this.pk(void 0,void 0,"",e);if(n(this.key,t))return t}}denormalize(e,t,n){return this.schema.denormalize(e,t,n)}}function O(e,t,n){const r={merge:{value:t},normalize:{value:j},infer:{value:x}};return e.schema instanceof h&&(r.createIfValid={value:E},r.denormalize={value:w}),n&&(r.createCollectionFilter={value:n}),Object.create(e,r)}function x(){}function j(e,t,n,r,s,i,o,c){const a=this.schema.normalize(this.schema instanceof h&&!Array.isArray(e)?[e]:e,t,n,r,s,i,o,c),u=this.createCollectionFilter(...r),l=o(this.key);return l&&Object.keys(l).forEach((e=>{u(JSON.parse(e))&&i(this,a,e)})),a}function E(e){return Array.isArray(e)?[...e]:Object.assign({},e)}function w(e,t,n){return Array.isArray(e)?this.schema.denormalize(e,t,n):this.schema.denormalize([e],t,n)[0]}var k=t(n((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,s={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(s[n]=e[n]);return s},e.exports.__esModule=!0,e.exports.default=e.exports})));const S=["pk","schema","key"];function A(e,t={}){class n extends e{static toString(){return this.key}static toJSON(){return{key:this.key,schema:this.schema}}static pk(e,t,n,r){return this.prototype.pk.call(e,t,n,r)}static shouldUpdate(e,t,n,r){return!0}static shouldReorder(e,t,n,r){return t.fetchedAt<e.fetchedAt}static merge(e,t){return Object.assign({},e,t)}static mergeWithStore(e,t,n,r){return this.shouldUpdate(e,t,n,r)?typeof r!=typeof n?r:this.shouldReorder(e,t,n,r)?this.merge(r,n):this.merge(n,r):n}static mergeMetaWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?e:t}static fromJS(e={}){const t=new this(e);return Object.assign(t,e),t}static createIfValid(e){if(!this.validate(e))return this.fromJS(e)}static process(e,t,n,r){return Object.assign({},e)}static normalize(e,t,n,r,s,i,o,c){const a=this.process(e,t,n,r);let u=this.pk(a,t,n,r);if(u=void 0===u||""===u||"undefined"===u?`MISS-${Math.random()}`:`${u}`,c(this.key,u,e))return u;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(a)),Object.keys(this.schema).forEach((e=>{Object.hasOwn(a,e)&&(a[e]=s(this.schema[e],a[e],a,e,r))})),i(this,a,u),u}static validate(e){}static queryKey(e,t,n,r){if(!e[0])return;const s=function(e,t,n){if(["string","number"].includes(typeof t[0]))return`${t[0]}`;const r=e.pk(t[0],void 0,"",t);if(void 0!==r&&""!==r)return r;const s=(i=t[0],o=e.indexes,o?o.find((e=>Object.hasOwn(i,e))):void 0);var i,o;if(!s)return;const c=t[0][s];return n(e.key,s,c)[c]}(this,e,r);return n(this.key,s)?s:void 0}static denormalize(e,t,n){if("symbol"==typeof e)return e;for(const t of Object.keys(this.schema)){const r=n(this.schema[t],e[t]);if("symbol"==typeof r){if(this.defaults[t])return r;e[t]=void 0}else e[t]=r}return e}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const r=k(t,S);if(Object.assign(n,r),"schema"in t?n.schema=t.schema:e.schema||(n.schema={}),"pk"in t?"function"==typeof t.pk?n.prototype.pk=function(e,n){return t.pk(this,e,n)}:n.prototype.pk=function(){return this[t.pk]}:"function"!=typeof e.prototype.pk&&(n.prototype.pk=function(){return this.id}),"key"in t)Object.defineProperty(n,"key",{value:t.key,configurable:!0,writable:!0,enumerable:!0});else if(!("key"in e)){function s(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0,configurable:!0})}const i=function(){return"EntityMixin"===this.name?e.name:this.name},o="undefined"!=typeof document&&document.CLS_MANGLE?function(){return null==document.CLS_MANGLE||document.CLS_MANGLE(this),Object.defineProperty(n,"key",{get:i,set:s,enumerable:!0,configurable:!0}),i.call(this)}:i;Object.defineProperty(n,"key",{get:o,set:s,enumerable:!0,configurable:!0})}return n}var _=Object.freeze({__proto__:null,Union:class extends c{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,n,r,s,i,o,c){return this.normalizeValue(e,t,n,r,s)}denormalize(e,t,n){return this.denormalizeValue(e,n)}queryKey(e,t,n,r){if(!e[0])return;const s=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[s];if(void 0===i)return;const o=t(i,e,n,r);return void 0!==o?{id:o,schema:s}:void 0}},Values:a,Array:h,All:class extends h{constructor(e,t){super(e,t)}normalize(e,t,n,r,s,i,o,c){super.normalize(e,t,n,r,s,i,o,c)}queryKey(e,t,n,r){if(this.isSingleSchema){const e=n(this.schema.key);return void 0===e?l:Object.values(e).map((e=>e&&this.schema.pk(e)))}let s=!1;const i=Object.values(this.schema).flatMap((e=>{const t=n(e.key);return void 0===t?[]:(s=!0,Object.values(t).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)}))))}));return s?i:l}},Object:d,Invalidate:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,n,r,s,i,o,c){const a=this._entity.process(e,t,n,r),u=this._entity.pk(a,t,n,r);return i(this,l,u),u}merge(e,t){return t}mergeWithStore(e,t,n,r){return this.merge(n,r)}mergeMetaWithStore(e,t,n,r){return t}queryKey(e,t,n,r){}denormalize(e,t,n){return n(this._entity,e)}_denormalizeNullable(){return{}}_normalizeNullable(){return{}}},Collection:v,Entity:A,Query:class{constructor(e,t){this.schema=e,this.process=t}normalize(...e){return this.schema.normalize(...e)}denormalize(e,t,n){const r=n(this.schema,e);return"symbol"==typeof r?r:this.process(r,...t)}queryKey(e,t,n,r){return t(this.schema,e,n,r)}}});const P=class{};class R extends(A(P)){static process(e,t,n,r){return super.process(e,t,n,r)}}var T;const C="undefined"!=typeof document;let z=C&&!(null!=(T=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&T.getAttribute("content"));try{z||Function()}catch(e){z=!0,C&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @data-client/endpoint will use setPrototypeOf instead")}var N;class K extends Function{constructor(e,t){let n,r;return z?(n=(...e)=>n.fetch(...e),Object.setPrototypeOf(n,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),n=this),e&&(n.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(r=e.name),Object.defineProperty(n,"name",{get(){return r||this.__name},set(e){this.__name=e}}),Object.assign(n,t),n}key(...e){return`${this.name} ${JSON.stringify(e)}`}testKey(e){return e.startsWith(this.name)}bind(e,...t){const n=this.fetch,r=this.key;return this.extend({fetch(){return n.apply(null!=e?e:this,t)},key(){return r.apply(this,t)}})}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(e.fetch,e)}}N=K,(()=>{if("undefined"!=typeof document&&document.FUNC_MANGLE){const e=N.prototype.key;N.prototype.key=function(...t){return null==document.FUNC_MANGLE||document.FUNC_MANGLE(this),this.prototype.key=e,e.call(this,...t)}}})();const $=K;function M(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 s=1,i="";if("?"===e[c=n+1])throw new TypeError('Pattern cannot start with "?" at '.concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--s){c++;break}}else if("("===e[c]&&(s++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));i+=e[c++]}else i+=e[c++]+e[c++];if(s)throw new TypeError("Unbalanced pattern at ".concat(n));if(!i)throw new TypeError("Missing pattern at ".concat(n));t.push({type:"PATTERN",index:n,value:i}),n=c}else{for(var o="",c=n+1;c<e.length;){var a=e.charCodeAt(c);if(!(a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||95===a))break;o+=e[c++]}if(!o)throw new TypeError("Missing parameter name at ".concat(n));t.push({type:"NAME",index:n,value:o}),n=c}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,s=void 0===r?"./":r,i="[^".concat(I(t.delimiter||"/#?"),"]+?"),o=[],c=0,a=0,u="",h=function(e){if(a<n.length&&n[a].type===e)return n[a++].value},l=function(e){var t=h(e);if(void 0!==t)return t;var r=n[a],s=r.type,i=r.index;throw new TypeError("Unexpected ".concat(s," at ").concat(i,", expected ").concat(e))},f=function(){for(var e,t="";e=h("CHAR")||h("ESCAPED_CHAR");)t+=e;return t};a<n.length;){var d=h("CHAR"),p=h("NAME"),m=h("PATTERN");if(p||m){var y=d||"";-1===s.indexOf(y)&&(u+=y,y=""),u&&(o.push(u),u=""),o.push({name:p||c++,prefix:y,suffix:"",pattern:m||i,modifier:h("MODIFIER")||""})}else{var g=d||h("ESCAPED_CHAR");if(g)u+=g;else if(u&&(o.push(u),u=""),h("OPEN")){y=f();var b=h("NAME")||"",v=h("PATTERN")||"",O=f();l("CLOSE"),o.push({name:b||(v?c++:""),pattern:b&&!v?i:v,prefix:y,suffix:O,modifier:h("MODIFIER")||""})}else l("END")}}return o}function F(e,t){return function(e,t){void 0===t&&(t={});var n=L(t),r=t.encode,s=void 0===r?function(e){return e}:r,i=t.validate,o=void 0===i||i,c=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 i=e[r];if("string"!=typeof i){var a=t?t[i.name]:void 0,u="?"===i.modifier||"*"===i.modifier,h="*"===i.modifier||"+"===i.modifier;if(Array.isArray(a)){if(!h)throw new TypeError('Expected "'.concat(i.name,'" to not repeat, but got an array'));if(0===a.length){if(u)continue;throw new TypeError('Expected "'.concat(i.name,'" to not be empty'))}for(var l=0;l<a.length;l++){var f=s(a[l],i);if(o&&!c[r].test(f))throw new TypeError('Expected all "'.concat(i.name,'" to match "').concat(i.pattern,'", but got "').concat(f,'"'));n+=i.prefix+f+i.suffix}}else if("string"!=typeof a&&"number"!=typeof a){if(!u){var d=h?"an array":"a string";throw new TypeError('Expected "'.concat(i.name,'" to be ').concat(d))}}else{f=s(String(a),i);if(o&&!c[r].test(f))throw new TypeError('Expected "'.concat(i.name,'" to match "').concat(i.pattern,'", but got "').concat(f,'"'));n+=i.prefix+f+i.suffix}}else n+=i}return n}}(M(e,t),t)}function I(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function L(e){return e&&e.sensitive?"":"i"}function U(e,t,n){return function(e,t,n){void 0===n&&(n={});for(var r=n.strict,s=void 0!==r&&r,i=n.start,o=void 0===i||i,c=n.end,a=void 0===c||c,u=n.encode,h=void 0===u?function(e){return e}:u,l=n.delimiter,f=void 0===l?"/#?":l,d=n.endsWith,p="[".concat(I(void 0===d?"":d),"]|$"),m="[".concat(I(f),"]"),y=o?"^":"",g=0,b=e;g<b.length;g++){var v=b[g];if("string"==typeof v)y+=I(h(v));else{var O=I(h(v.prefix)),x=I(h(v.suffix));if(v.pattern)if(t&&t.push(v),O||x)if("+"===v.modifier||"*"===v.modifier){var j="*"===v.modifier?"?":"";y+="(?:".concat(O,"((?:").concat(v.pattern,")(?:").concat(x).concat(O,"(?:").concat(v.pattern,"))*)").concat(x,")").concat(j)}else y+="(?:".concat(O,"(").concat(v.pattern,")").concat(x,")").concat(v.modifier);else"+"===v.modifier||"*"===v.modifier?y+="((?:".concat(v.pattern,")").concat(v.modifier,")"):y+="(".concat(v.pattern,")").concat(v.modifier);else y+="(?:".concat(O).concat(x,")").concat(v.modifier)}}if(a)s||(y+="".concat(m,"?")),y+=n.endsWith?"(?=".concat(p,")"):"$";else{var E=e[e.length-1],w="string"==typeof E?m.indexOf(E[E.length-1])>-1:void 0===E;s||(y+="(?:".concat(m,"(?=").concat(p,"))?")),w||(y+="(?=".concat(m,"|").concat(p,")"))}return new RegExp(y,L(n))}(M(e,n),t,n)}function q(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;for(var n=/\((?:\?<(.*?)>)?(?!\?)/g,r=0,s=n.exec(e.source);s;)t.push({name:s[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),s=n.exec(e.source);return e}(e,t):Array.isArray(e)?function(e,t,n){var r=e.map((function(e){return q(e,t,n).source}));return new RegExp("(?:".concat(r.join("|"),")"),L(n))}(e,t,n):U(e,t,n)}function D(e,t){if("object"!=typeof e||void 0===e||Array.isArray(e))return;if(e instanceof v)return t(e);const n=Object.assign({},e instanceof d?e.schema:e);for(const e in n){if(!n[e])continue;const r=D(n[e],t);if(r)return r}}function V(e,t){if("object"!=typeof e||void 0===e)return e;if(e instanceof v)return t(e);const n=Object.assign({},e instanceof d?e.schema:e);for(const e in n)n[e]&&(n[e]=V(n[e],t));return n}class W extends Error{constructor(e){super(e.statusText||`Network response not 'ok': ${e.status}`),this.name="NetworkError",this.status=e.status,this.response=e}}function J(e,t){const n=new Set(e),r=[...e];for(const e of t)n.has(e)||r.push(e);return r}const G=Object.create(null);function H(e){return e in G||(G[e]=F(e,{encode:encodeURIComponent,validate:!1})),G[e]}const B=Object.create(null);function Q(e){return e in B||(B[e]=new Set(M(e).map((e=>"string"==typeof e?e:`${e.name}`)))),B[e]}const X=Object.prototype,Y=Object.getPrototypeOf;var Z=i("hasBody");class ee extends K{constructor(e){var t;super(null!=(t=e.fetch)?t:async function(...e){const t=s(this,Z)[Z]&&e.length<2?{}:e[0]||{},n=s(this,Z)[Z]?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,Z,{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=""),s(this,Z)[Z]=!("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(s(this,Z)[Z]&&e.length<2?{}:e[0]||{})}`}url(e={}){const t=H(this.path)(e),n=Q(this.path),r={};return Object.keys(e).forEach((t=>{n.has(t)||(r[t]=e[t])})),Object.keys(r).length?`${this.urlPrefix}${t}?${this.searchToString(r)}`:`${this.urlPrefix}${t}`}searchToString(e){return function(e){const t=new URLSearchParams(e);return t.sort(),t.toString()}(e)}getHeaders(e){return e}async getRequestInit(e){const t=null!==(n=e)&&"object"==typeof n&&Y(n)===X;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 W(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!==ee.prototype.process)return t;const n=new W(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 q(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({},(r(e),e));return delete n[t],[n]}}let t=!1;const n=V(this.schema,(n=>(t=!0,function(e,t){return Object.create(t,{name:{value:`Pagination(${t.schema})`},merge:{value:J},pk:{value:function(n,r,s,i){return t.pk.call(this,n,r,s,e(...i))}}})}(e,n))));if(!t)throw new Error("Missing Collection");const s=this;return this.extend({schema:n,key(...t){return s.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"})}}const te=["path","schema","Endpoint","Collection","optimistic","paginationField"],{Invalidate:ne,Collection:re}=_;function se(e){let{path:t,schema:n,Endpoint:r=ee,Collection:s=re,optimistic:i,paginationField:o}=e,c=k(e,te);const a=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}(t),u=e=>`${null==n?void 0:n.name}.${e}`;function h(e,t,n){e[t]=e[t].extend(n)}const l=Object.assign({},c),f=Object.assign({},c),d=new r(Object.assign({},c,{path:t,schema:n,name:u("get")}));i&&(l.getOptimisticResponse=ie,f.getOptimisticResponse=function(e){return function(t,n,r){const s=t.get(e,n);if(!s)throw t.abort;return Object.assign({},n,s,ce(r))}}(n));const p=new r(Object.assign({},l,{paginationField:o,path:a,schema:new s([n]),name:u("getList")}));return{get:d,getList:p,create:p.push.extend({name:u("create")}),update:new r(Object.assign({},l,{path:t,schema:n,method:"PUT",name:u("update")})),partialUpdate:new r(Object.assign({},f,{path:t,schema:n,method:"PATCH",name:u("partialUpdate")})),delete:new r(Object.assign({},l,{path:t,schema:n.process?new ne(n):n,method:"DELETE",name:u("delete"),process:(e,t)=>e&&Object.keys(e).length?e:t,getOptimisticResponse:i?oe: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}}}function ie(e,t,n){return Object.assign({},t,ce(n))}function oe(e,t){return t}function ce(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.Endpoint=K,e.Entity=R,e.ExtendableEndpoint=$,e.INVALID=l,e.NetworkError=W,e.RestEndpoint=ee,e.createResource=se,e.getUrlBase=H,e.getUrlTokens=Q,e.hookifyResource=function(e,t){const n={};return Object.keys(e).forEach((r=>{const s=e[r];var i;void 0!==s.extend&&(n[`use${i=r,i.charAt(0).toUpperCase()+i.slice(1)}`]=()=>{const e=t();return s.extend({requestInit:e})})})),n},e.resource=se,e.schema=_,e.validateRequired=function(e,t){let n="";if(Object.keys(t).some((t=>!Object.hasOwn(e,t)&&(n=t,!0))))return`Missing key ${n}`},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Rest={})}(this,(function(e){"use strict";function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=t(n((function(e){e.exports=function(e){if(null==e)throw new TypeError("Cannot destructure "+e)},e.exports.__esModule=!0,e.exports.default=e.exports}))),s=t(n((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}))),i=t(n((function(e){var t=0;e.exports=function(e){return"__private_"+t+++"_"+e},e.exports.__esModule=!0,e.exports.default=e.exports})));function o(e){return!("function"!=typeof e.hasOwnProperty||!(Object.hasOwnProperty.call(e,"__ownerID")||e._map&&Object.hasOwnProperty.call(e._map,"__ownerID")))}class c{constructor(e,t){this.schema=void 0,t&&(this._schemaAttribute="string"==typeof t?e=>e[t]:t),this.define(e)}get isSingleSchema(){return!this._schemaAttribute}define(e){"_schemaAttribute"in e&&!this._schemaAttribute?(this.schema=e.schema,this._schemaAttribute=e._schemaAttribute):this.schema=e}getSchemaAttribute(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}inferSchema(e,t,n){if(this.isSingleSchema)return this.schema;const r=this.getSchemaAttribute(e,t,n);return this.schema[r]}schemaKey(){return this.isSingleSchema?this.schema.key:Object.values(this.schema).join(";")}normalizeValue(e,t,n,r,s){if(!e)return e;const i=this.inferSchema(e,t,n);if(!i)return e;const o=s(i,e,t,n,r);return this.isSingleSchema||null==o?o:{id:o,schema:this.getSchemaAttribute(e,t,n)}}denormalizeValue(e,t){const n=!this.isSingleSchema&&e&&(o(e)?e.get("schema"):e.schema);if(!this.isSingleSchema&&!n){if("object"==typeof e&&null!==e){const n=this.inferSchema(e,void 0,void 0);if(n)return t(n,e)}return e}const r=this.isSingleSchema?void 0:o(e)?e.get("id"):e.id;return t(this.isSingleSchema?this.schema:this.schema[n],r||e)}}class a extends c{normalize(e,t,n,r,s,i,o,c){return Object.keys(e).reduce(((t,n,i)=>{const o=e[n];return null!=o?Object.assign({},t,{[n]:this.normalizeValue(o,e,n,r,s)}):t}),{})}denormalize(e,t,n){return Object.keys(e).reduce(((t,r)=>{const s=e[r],i=this.denormalizeValue(s,n);return i&&"symbol"!=typeof i?Object.assign({},t,{[r]:i}):t}),{})}queryKey(e,t,n,r){}}const u=e=>void 0!==e&&"symbol"!=typeof e;class h extends c{normalize(e,t,n,r,s,i,o,c){const a=(e=>Array.isArray(e)?e:Object.keys(e).map((t=>e[t])))(e);return a.map(((e,i)=>this.normalizeValue(e,t,n,r,s)))}denormalize(e,t,n){return e.map?e.map((e=>this.denormalizeValue(e,n))).filter(u):e}queryKey(e,t,n,r){}toJSON(){return[this.schema]}}const l=Symbol("INVALID");function f(e,t,n,r){if(o(t))return function(e,t,n){var r;let s;const i=Object.keys(e).reduce(((t,r)=>{const i=`${r}`,o=n(e[i],t.get(i));return"symbol"==typeof o&&(s=o),t.has(i)?t.set(i,o):t}),t);return null!=(r=s)?r:i}(e,t,r);const s=Object.assign({},t);for(const t of Object.keys(e)){const n=r(e[t],s[t]);if(void 0!==s[t]&&(s[t]=n),"symbol"==typeof n)return n}return s}class d{constructor(e){this.schema=void 0,this.define(e)}define(e){this.schema=Object.keys(e).reduce(((t,n)=>{const r=e[n];return Object.assign({},t,{[n]:r})}),this.schema||{})}normalize(...e){return((e,t,n,r,s,i,o,c,a)=>{const u=Object.assign({},t);return Object.keys(e).forEach((n=>{const r=e[n],o=i(r,t[n],t,n,s);void 0===o?delete u[n]:u[n]=o})),u})(this.schema,...e)}denormalize(e,t,n){return f(this.schema,e,0,n)}queryKey(e,t,n,r){return function(e,t,n,r,s){const i={};return Object.keys(e).forEach((o=>{i[o]=n(e[o],t,r,s)})),i}(this.schema,e,t,n,r)}}const p=(e,t)=>[...e,...t],m=(e,t)=>[...t,...e],y=(e,t)=>Object.assign({},e,t),g=e=>[...e],b=e=>Object.assign({},e);class v{addWith(e,t){return O(this,e,t)}createCollectionFilter(...e){return t=>Object.entries(t).every((([t,n])=>{var r;return this.nonFilterArgumentKeys(t)||`${e[0][t]}`===n||`${null==(r=e[1])?void 0:r[t]}`===n}))}nonFilterArgumentKeys(e){return e.startsWith("order")}constructor(e,t){if(this.schema=Array.isArray(e)?new h(e[0]):e,t?"nestKey"in t?this.nestKey=t.nestKey:this.argsKey="argsKey"in t?t.argsKey:e=>Object.assign({},e):this.argsKey=e=>Object.assign({},e),this.key=function(e){if(e instanceof h)return`[${e.schemaKey()}]`;if(e instanceof a)return`{${e.schemaKey()}}`;return`(${e.schemaKey()})`}(this.schema),null!=t&&t.nonFilterArgumentKeys){const{nonFilterArgumentKeys:e}=t;"function"==typeof e?this.nonFilterArgumentKeys=e:e instanceof RegExp?this.nonFilterArgumentKeys=t=>e.test(t):this.nonFilterArgumentKeys=t=>e.includes(t)}else null!=t&&t.createCollectionFilter&&(this.createCollectionFilter=t.createCollectionFilter.bind(this));this.schema instanceof h?(this.createIfValid=g,this.push=O(this,p),this.unshift=O(this,m)):e instanceof a&&(this.createIfValid=b,this.assign=O(this,y))}get cacheWith(){return this.schema.schema}toString(){return this.key}toJSON(){return{key:this.key,schema:this.schema.schema.toJSON()}}pk(e,t,n,r){const s=this.argsKey?this.argsKey(...r):this.nestKey(t,n);for(const e in s)"string"!=typeof s[e]&&void 0!==s[e]&&(s[e]=`${s[e]}`);return function(e){const t=Object.keys(e).sort(),n={};for(const r of t)n[r]=e[r];return JSON.stringify(n)}(s)}normalize(e,t,n,r,s,i,o,c){const a=this.schema.normalize(e,t,n,r,s,i,o,c),u=this.pk(a,t,n,r);return i(this,a,u),u}merge(e,t){return t}shouldReorder(e,t,n,r){return t.fetchedAt<e.fetchedAt}mergeWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?this.merge(r,n):this.merge(n,r)}mergeMetaWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?e:t}queryKey(e,t,n,r){if(this.argsKey){const t=this.pk(void 0,void 0,"",e);if(n(this.key,t))return t}}denormalize(e,t,n){return this.schema.denormalize(e,t,n)}}function O(e,t,n){const r={merge:{value:t},normalize:{value:j},infer:{value:x}};return e.schema instanceof h&&(r.createIfValid={value:E},r.denormalize={value:w}),n&&(r.createCollectionFilter={value:n}),Object.create(e,r)}function x(){}function j(e,t,n,r,s,i,o,c){const a=this.schema.normalize(this.schema instanceof h&&!Array.isArray(e)?[e]:e,t,n,r,s,i,o,c),u=this.createCollectionFilter(...r),l=o(this.key);return l&&Object.keys(l).forEach((e=>{u(JSON.parse(e))&&i(this,a,e)})),a}function E(e){return Array.isArray(e)?[...e]:Object.assign({},e)}function w(e,t,n){return Array.isArray(e)?this.schema.denormalize(e,t,n):this.schema.denormalize([e],t,n)[0]}var k=t(n((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,s={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(s[n]=e[n]);return s},e.exports.__esModule=!0,e.exports.default=e.exports})));const S=["pk","schema","key"];function A(e,t={}){class n extends e{static toString(){return this.key}static toJSON(){return{key:this.key,schema:this.schema}}static pk(e,t,n,r){return this.prototype.pk.call(e,t,n,r)}static shouldUpdate(e,t,n,r){return!0}static shouldReorder(e,t,n,r){return t.fetchedAt<e.fetchedAt}static merge(e,t){return Object.assign({},e,t)}static mergeWithStore(e,t,n,r){return this.shouldUpdate(e,t,n,r)?typeof r!=typeof n?r:this.shouldReorder(e,t,n,r)?this.merge(r,n):this.merge(n,r):n}static mergeMetaWithStore(e,t,n,r){return this.shouldReorder(e,t,n,r)?e:t}static fromJS(e={}){const t=new this(e);return Object.assign(t,e),t}static createIfValid(e){if(!this.validate(e))return this.fromJS(e)}static process(e,t,n,r){return Object.assign({},e)}static normalize(e,t,n,r,s,i,o,c){const a=this.process(e,t,n,r);let u=this.pk(a,t,n,r);if(u=void 0===u||""===u||"undefined"===u?`MISS-${Math.random()}`:`${u}`,c(this.key,u,e))return u;return function(e){if(e){const t=new Error(e);throw t.status=400,t}}(this.validate(a)),Object.keys(this.schema).forEach((e=>{Object.hasOwn(a,e)&&(a[e]=s(this.schema[e],a[e],a,e,r))})),i(this,a,u),u}static validate(e){}static queryKey(e,t,n,r){if(!e[0])return;const s=function(e,t,n){if(["string","number"].includes(typeof t[0]))return`${t[0]}`;const r=e.pk(t[0],void 0,"",t);if(void 0!==r&&""!==r)return r;const s=(i=t[0],o=e.indexes,o?o.find((e=>Object.hasOwn(i,e))):void 0);var i,o;if(!s)return;const c=t[0][s];return n(e.key,s,c)[c]}(this,e,r);return n(this.key,s)?s:void 0}static denormalize(e,t,n){if("symbol"==typeof e)return e;for(const t of Object.keys(this.schema)){const r=n(this.schema[t],e[t]);if("symbol"==typeof r){if(this.defaults[t])return r;e[t]=void 0}else e[t]=r}return e}static get defaults(){return Object.hasOwn(this,"__defaults")||Object.defineProperty(this,"__defaults",{value:new this,writable:!0,configurable:!0}),this.__defaults}}const r=k(t,S);if(Object.assign(n,r),"schema"in t?n.schema=t.schema:e.schema||(n.schema={}),"pk"in t?"function"==typeof t.pk?n.prototype.pk=function(e,n){return t.pk(this,e,n)}:n.prototype.pk=function(){return this[t.pk]}:"function"!=typeof e.prototype.pk&&(n.prototype.pk=function(){return this.id}),"key"in t)Object.defineProperty(n,"key",{value:t.key,configurable:!0,writable:!0,enumerable:!0});else if(!("key"in e)){function s(e){Object.defineProperty(this,"key",{value:e,writable:!0,enumerable:!0,configurable:!0})}const i=function(){return"EntityMixin"===this.name?e.name:this.name},o="undefined"!=typeof document&&document.CLS_MANGLE?function(){return null==document.CLS_MANGLE||document.CLS_MANGLE(this),Object.defineProperty(n,"key",{get:i,set:s,enumerable:!0,configurable:!0}),i.call(this)}:i;Object.defineProperty(n,"key",{get:o,set:s,enumerable:!0,configurable:!0})}return n}var _=Object.freeze({__proto__:null,Union:class extends c{constructor(e,t){if(!t)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');super(e,t)}normalize(e,t,n,r,s,i,o,c){return this.normalizeValue(e,t,n,r,s)}denormalize(e,t,n){return this.denormalizeValue(e,n)}queryKey(e,t,n,r){if(!e[0])return;const s=this.getSchemaAttribute(e[0],void 0,""),i=this.schema[s];if(void 0===i)return;const o=t(i,e,n,r);return void 0!==o?{id:o,schema:s}:void 0}},Values:a,Array:h,All:class extends h{constructor(e,t){super(e,t)}normalize(e,t,n,r,s,i,o,c){super.normalize(e,t,n,r,s,i,o,c)}queryKey(e,t,n,r){if(this.isSingleSchema){const e=n(this.schema.key);return void 0===e?l:Object.values(e).map((e=>e&&this.schema.pk(e)))}let s=!1;const i=Object.values(this.schema).flatMap((e=>{const t=n(e.key);return void 0===t?[]:(s=!0,Object.values(t).map((t=>({id:t&&e.pk(t),schema:this.getSchemaAttribute(t,void 0,void 0)}))))}));return s?i:l}},Object:d,Invalidate:class{constructor(e){this._entity=e}get key(){return this._entity.key}normalize(e,t,n,r,s,i,o,c){const a=this._entity.process(e,t,n,r),u=this._entity.pk(a,t,n,r);return i(this,l,u),u}merge(e,t){return t}mergeWithStore(e,t,n,r){return this.merge(n,r)}mergeMetaWithStore(e,t,n,r){return t}queryKey(e,t,n,r){}denormalize(e,t,n){return n(this._entity,e)}_denormalizeNullable(){return{}}_normalizeNullable(){return{}}},Collection:v,Entity:A,Query:class{constructor(e,t){this.schema=e,this.process=t}normalize(...e){return this.schema.normalize(...e)}denormalize(e,t,n){const r=n(this.schema,e);return"symbol"==typeof r?r:this.process(r,...t)}queryKey(e,t,n,r){return t(this.schema,e,n,r)}}});const P=class{};class R extends(A(P)){static process(e,t,n,r){return super.process(e,t,n,r)}}var T;const C="undefined"!=typeof document;let z=C&&!(null!=(T=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&T.getAttribute("content"));try{z||Function()}catch(e){z=!0,C&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @data-client/endpoint will use setPrototypeOf instead")}var $;class K extends Function{constructor(e,t){let n,r;return z?(n=(...e)=>n.fetch(...e),Object.setPrototypeOf(n,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),n=this),e&&(n.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(r=e.name),Object.defineProperty(n,"name",{get(){return r||this.__name},set(e){this.__name=e}}),Object.assign(n,t),n}key(...e){return`${this.name} ${JSON.stringify(e)}`}testKey(e){return e.startsWith(this.name)}bind(e,...t){const n=this.fetch,r=this.key;return this.extend({fetch(){return n.apply(null!=e?e:this,t)},key(){return r.apply(this,t)}})}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(e.fetch,e)}}$=K,(()=>{if("undefined"!=typeof document&&document.FUNC_MANGLE){const e=$.prototype.key;$.prototype.key=function(...t){return null==document.FUNC_MANGLE||document.FUNC_MANGLE(this),this.prototype.key=e,e.call(this,...t)}}})();const N=K;function M(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 s=1,i="";if("?"===e[c=n+1])throw new TypeError('Pattern cannot start with "?" at '.concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--s){c++;break}}else if("("===e[c]&&(s++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));i+=e[c++]}else i+=e[c++]+e[c++];if(s)throw new TypeError("Unbalanced pattern at ".concat(n));if(!i)throw new TypeError("Missing pattern at ".concat(n));t.push({type:"PATTERN",index:n,value:i}),n=c}else{for(var o="",c=n+1;c<e.length;){var a=e.charCodeAt(c);if(!(a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||95===a))break;o+=e[c++]}if(!o)throw new TypeError("Missing parameter name at ".concat(n));t.push({type:"NAME",index:n,value:o}),n=c}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,s=void 0===r?"./":r,i="[^".concat(I(t.delimiter||"/#?"),"]+?"),o=[],c=0,a=0,u="",h=function(e){if(a<n.length&&n[a].type===e)return n[a++].value},l=function(e){var t=h(e);if(void 0!==t)return t;var r=n[a],s=r.type,i=r.index;throw new TypeError("Unexpected ".concat(s," at ").concat(i,", expected ").concat(e))},f=function(){for(var e,t="";e=h("CHAR")||h("ESCAPED_CHAR");)t+=e;return t};a<n.length;){var d=h("CHAR"),p=h("NAME"),m=h("PATTERN");if(p||m){var y=d||"";-1===s.indexOf(y)&&(u+=y,y=""),u&&(o.push(u),u=""),o.push({name:p||c++,prefix:y,suffix:"",pattern:m||i,modifier:h("MODIFIER")||""})}else{var g=d||h("ESCAPED_CHAR");if(g)u+=g;else if(u&&(o.push(u),u=""),h("OPEN")){y=f();var b=h("NAME")||"",v=h("PATTERN")||"",O=f();l("CLOSE"),o.push({name:b||(v?c++:""),pattern:b&&!v?i:v,prefix:y,suffix:O,modifier:h("MODIFIER")||""})}else l("END")}}return o}function F(e,t){return function(e,t){void 0===t&&(t={});var n=L(t),r=t.encode,s=void 0===r?function(e){return e}:r,i=t.validate,o=void 0===i||i,c=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 i=e[r];if("string"!=typeof i){var a=t?t[i.name]:void 0,u="?"===i.modifier||"*"===i.modifier,h="*"===i.modifier||"+"===i.modifier;if(Array.isArray(a)){if(!h)throw new TypeError('Expected "'.concat(i.name,'" to not repeat, but got an array'));if(0===a.length){if(u)continue;throw new TypeError('Expected "'.concat(i.name,'" to not be empty'))}for(var l=0;l<a.length;l++){var f=s(a[l],i);if(o&&!c[r].test(f))throw new TypeError('Expected all "'.concat(i.name,'" to match "').concat(i.pattern,'", but got "').concat(f,'"'));n+=i.prefix+f+i.suffix}}else if("string"!=typeof a&&"number"!=typeof a){if(!u){var d=h?"an array":"a string";throw new TypeError('Expected "'.concat(i.name,'" to be ').concat(d))}}else{f=s(String(a),i);if(o&&!c[r].test(f))throw new TypeError('Expected "'.concat(i.name,'" to match "').concat(i.pattern,'", but got "').concat(f,'"'));n+=i.prefix+f+i.suffix}}else n+=i}return n}}(M(e,t),t)}function I(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function L(e){return e&&e.sensitive?"":"i"}function U(e,t,n){return function(e,t,n){void 0===n&&(n={});for(var r=n.strict,s=void 0!==r&&r,i=n.start,o=void 0===i||i,c=n.end,a=void 0===c||c,u=n.encode,h=void 0===u?function(e){return e}:u,l=n.delimiter,f=void 0===l?"/#?":l,d=n.endsWith,p="[".concat(I(void 0===d?"":d),"]|$"),m="[".concat(I(f),"]"),y=o?"^":"",g=0,b=e;g<b.length;g++){var v=b[g];if("string"==typeof v)y+=I(h(v));else{var O=I(h(v.prefix)),x=I(h(v.suffix));if(v.pattern)if(t&&t.push(v),O||x)if("+"===v.modifier||"*"===v.modifier){var j="*"===v.modifier?"?":"";y+="(?:".concat(O,"((?:").concat(v.pattern,")(?:").concat(x).concat(O,"(?:").concat(v.pattern,"))*)").concat(x,")").concat(j)}else y+="(?:".concat(O,"(").concat(v.pattern,")").concat(x,")").concat(v.modifier);else"+"===v.modifier||"*"===v.modifier?y+="((?:".concat(v.pattern,")").concat(v.modifier,")"):y+="(".concat(v.pattern,")").concat(v.modifier);else y+="(?:".concat(O).concat(x,")").concat(v.modifier)}}if(a)s||(y+="".concat(m,"?")),y+=n.endsWith?"(?=".concat(p,")"):"$";else{var E=e[e.length-1],w="string"==typeof E?m.indexOf(E[E.length-1])>-1:void 0===E;s||(y+="(?:".concat(m,"(?=").concat(p,"))?")),w||(y+="(?=".concat(m,"|").concat(p,")"))}return new RegExp(y,L(n))}(M(e,n),t,n)}function q(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;for(var n=/\((?:\?<(.*?)>)?(?!\?)/g,r=0,s=n.exec(e.source);s;)t.push({name:s[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),s=n.exec(e.source);return e}(e,t):Array.isArray(e)?function(e,t,n){var r=e.map((function(e){return q(e,t,n).source}));return new RegExp("(?:".concat(r.join("|"),")"),L(n))}(e,t,n):U(e,t,n)}function D(e,t){if("object"!=typeof e||void 0===e||Array.isArray(e))return;if(e instanceof v)return t(e);const n=Object.assign({},e instanceof d?e.schema:e);for(const e in n){if(!n[e])continue;const r=D(n[e],t);if(r)return r}}function V(e,t){if("object"!=typeof e||void 0===e)return e;if(e instanceof v)return t(e);const n=Object.assign({},e instanceof d?e.schema:e);for(const e in n)n[e]&&(n[e]=V(n[e],t));return n}class W extends Error{constructor(e){super(`${e.url}: ${e.statusText||`Status not 'ok': ${e.status}`}`),this.name="NetworkError",this.status=e.status,this.response=e}}function J(e,t){const n=new Set(e),r=[...e];for(const e of t)n.has(e)||r.push(e);return r}const G=Object.create(null);function H(e){return e in G||(G[e]=F(e,{encode:encodeURIComponent,validate:!1})),G[e]}const B=Object.create(null);function Q(e){return e in B||(B[e]=new Set(M(e).map((e=>"string"==typeof e?e:`${e.name}`)))),B[e]}const X=Object.prototype,Y=Object.getPrototypeOf;var Z=i("hasBody");class ee extends K{constructor(e){var t;super(null!=(t=e.fetch)?t:async function(...e){const t=s(this,Z)[Z]&&e.length<2?{}:e[0]||{},n=s(this,Z)[Z]?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,Z,{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=""),s(this,Z)[Z]=!("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(s(this,Z)[Z]&&e.length<2?{}:e[0]||{})}`}url(e={}){const t=H(this.path)(e),n=Q(this.path),r={};return Object.keys(e).forEach((t=>{n.has(t)||(r[t]=e[t])})),Object.keys(r).length?`${this.urlPrefix}${t}?${this.searchToString(r)}`:`${this.urlPrefix}${t}`}searchToString(e){return function(e){const t=new URLSearchParams(e);return t.sort(),t.toString()}(e)}getHeaders(e){return e}async getRequestInit(e){const t=null!==(n=e)&&"object"==typeof n&&Y(n)===X;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 W(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!==ee.prototype.process)return t;const n=new W(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 q(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({},(r(e),e));return delete n[t],[n]}}let t=!1;const n=V(this.schema,(n=>(t=!0,function(e,t){return Object.create(t,{name:{value:`Pagination(${t.schema})`},merge:{value:J},pk:{value:function(n,r,s,i){return t.pk.call(this,n,r,s,e(...i))}}})}(e,n))));if(!t)throw new Error("Missing Collection");const s=this;return this.extend({schema:n,key(...t){return s.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"})}}const te=["path","schema","Endpoint","Collection","optimistic","paginationField"],{Invalidate:ne,Collection:re}=_;function se(e){let{path:t,schema:n,Endpoint:r=ee,Collection:s=re,optimistic:i,paginationField:o}=e,c=k(e,te);const a=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}(t),u=e=>`${null==n?void 0:n.name}.${e}`;function h(e,t,n){e[t]=e[t].extend(n)}const l=Object.assign({},c),f=Object.assign({},c),d=new r(Object.assign({},c,{path:t,schema:n,name:u("get")}));i&&(l.getOptimisticResponse=ie,f.getOptimisticResponse=function(e){return function(t,n,r){const s=t.get(e,n);if(!s)throw t.abort;return Object.assign({},n,s,ce(r))}}(n));const p=new r(Object.assign({},l,{paginationField:o,path:a,schema:new s([n]),name:u("getList")}));return{get:d,getList:p,create:p.push.extend({name:u("create")}),update:new r(Object.assign({},l,{path:t,schema:n,method:"PUT",name:u("update")})),partialUpdate:new r(Object.assign({},f,{path:t,schema:n,method:"PATCH",name:u("partialUpdate")})),delete:new r(Object.assign({},l,{path:t,schema:n.process?new ne(n):n,method:"DELETE",name:u("delete"),process:(e,t)=>e&&Object.keys(e).length?e:t,getOptimisticResponse:i?oe: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}}}function ie(e,t,n){return Object.assign({},t,ce(n))}function oe(e,t){return t}function ce(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.Endpoint=K,e.Entity=R,e.ExtendableEndpoint=N,e.INVALID=l,e.NetworkError=W,e.RestEndpoint=ee,e.createResource=se,e.getUrlBase=H,e.getUrlTokens=Q,e.hookifyResource=function(e,t){const n={};return Object.keys(e).forEach((r=>{const s=e[r];var i;void 0!==s.extend&&(n[`use${i=r,i.charAt(0).toUpperCase()+i.slice(1)}`]=()=>{const e=t();return s.extend({requestInit:e})})})),n},e.resource=se,e.schema=_,e.validateRequired=function(e,t){let n="";if(Object.keys(t).some((t=>!Object.hasOwn(e,t)&&(n=t,!0))))return`Missing key ${n}`},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -4,10 +4,10 @@
4
4
  */
5
5
  export default class NetworkError extends Error {
6
6
  constructor(response) {
7
- super(response.statusText || `Network response not 'ok': ${response.status}`);
7
+ super(`${response.url}: ${response.statusText || `Status not 'ok': ${response.status}`}`);
8
8
  this.name = 'NetworkError';
9
9
  this.status = response.status;
10
10
  this.response = response;
11
11
  }
12
12
  }
13
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJOZXR3b3JrRXJyb3IiLCJFcnJvciIsImNvbnN0cnVjdG9yIiwicmVzcG9uc2UiLCJzdGF0dXNUZXh0Iiwic3RhdHVzIiwibmFtZSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9OZXR3b3JrRXJyb3IudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqIEFuIGVycm9yIHdpdGggYSBSZXN0IEVuZHBvaW50IGZldGNoXG4gKlxuICogQHNlZSBodHRwczovL2RhdGFjbGllbnQuaW8vcmVzdC9hcGkvTmV0d29ya0Vycm9yXG4gKi9cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIE5ldHdvcmtFcnJvciBleHRlbmRzIEVycm9yIHtcbiAgZGVjbGFyZSBzdGF0dXM6IG51bWJlcjtcbiAgZGVjbGFyZSByZXNwb25zZTogUmVzcG9uc2U7XG4gIG5hbWUgPSAnTmV0d29ya0Vycm9yJztcblxuICBjb25zdHJ1Y3RvcihyZXNwb25zZTogUmVzcG9uc2UpIHtcbiAgICBzdXBlcihcbiAgICAgIHJlc3BvbnNlLnN0YXR1c1RleHQgfHwgYE5ldHdvcmsgcmVzcG9uc2Ugbm90ICdvayc6ICR7cmVzcG9uc2Uuc3RhdHVzfWAsXG4gICAgKTtcbiAgICB0aGlzLnN0YXR1cyA9IHJlc3BvbnNlLnN0YXR1cztcbiAgICB0aGlzLnJlc3BvbnNlID0gcmVzcG9uc2U7XG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQSxlQUFlLE1BQU1BLFlBQVksU0FBU0MsS0FBSyxDQUFDO0VBSzlDQyxXQUFXQSxDQUFDQyxRQUFrQixFQUFFO0lBQzlCLEtBQUssQ0FDSEEsUUFBUSxDQUFDQyxVQUFVLElBQUksOEJBQThCRCxRQUFRLENBQUNFLE1BQU0sRUFDdEUsQ0FBQztJQUFDLEtBTEpDLElBQUksR0FBRyxjQUFjO0lBTW5CLElBQUksQ0FBQ0QsTUFBTSxHQUFHRixRQUFRLENBQUNFLE1BQU07SUFDN0IsSUFBSSxDQUFDRixRQUFRLEdBQUdBLFFBQVE7RUFDMUI7QUFDRiIsImlnbm9yZUxpc3QiOltdfQ==
13
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJOZXR3b3JrRXJyb3IiLCJFcnJvciIsImNvbnN0cnVjdG9yIiwicmVzcG9uc2UiLCJ1cmwiLCJzdGF0dXNUZXh0Iiwic3RhdHVzIiwibmFtZSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9OZXR3b3JrRXJyb3IudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqIEFuIGVycm9yIHdpdGggYSBSZXN0IEVuZHBvaW50IGZldGNoXG4gKlxuICogQHNlZSBodHRwczovL2RhdGFjbGllbnQuaW8vcmVzdC9hcGkvTmV0d29ya0Vycm9yXG4gKi9cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIE5ldHdvcmtFcnJvciBleHRlbmRzIEVycm9yIHtcbiAgZGVjbGFyZSBzdGF0dXM6IG51bWJlcjtcbiAgZGVjbGFyZSByZXNwb25zZTogUmVzcG9uc2U7XG4gIG5hbWUgPSAnTmV0d29ya0Vycm9yJztcblxuICBjb25zdHJ1Y3RvcihyZXNwb25zZTogUmVzcG9uc2UpIHtcbiAgICBzdXBlcihcbiAgICAgIGAke3Jlc3BvbnNlLnVybH06ICR7cmVzcG9uc2Uuc3RhdHVzVGV4dCB8fCBgU3RhdHVzIG5vdCAnb2snOiAke3Jlc3BvbnNlLnN0YXR1c31gfWAsXG4gICAgKTtcbiAgICB0aGlzLnN0YXR1cyA9IHJlc3BvbnNlLnN0YXR1cztcbiAgICB0aGlzLnJlc3BvbnNlID0gcmVzcG9uc2U7XG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQSxlQUFlLE1BQU1BLFlBQVksU0FBU0MsS0FBSyxDQUFDO0VBSzlDQyxXQUFXQSxDQUFDQyxRQUFrQixFQUFFO0lBQzlCLEtBQUssQ0FDSCxHQUFHQSxRQUFRLENBQUNDLEdBQUcsS0FBS0QsUUFBUSxDQUFDRSxVQUFVLElBQUksb0JBQW9CRixRQUFRLENBQUNHLE1BQU0sRUFBRSxFQUNsRixDQUFDO0lBQUMsS0FMSkMsSUFBSSxHQUFHLGNBQWM7SUFNbkIsSUFBSSxDQUFDRCxNQUFNLEdBQUdILFFBQVEsQ0FBQ0csTUFBTTtJQUM3QixJQUFJLENBQUNILFFBQVEsR0FBR0EsUUFBUTtFQUMxQjtBQUNGIiwiaWdub3JlTGlzdCI6W119
@@ -4,10 +4,10 @@
4
4
  */
5
5
  export default class NetworkError extends Error {
6
6
  constructor(response) {
7
- super(response.statusText || `Network response not 'ok': ${response.status}`);
7
+ super(`${response.url}: ${response.statusText || `Status not 'ok': ${response.status}`}`);
8
8
  this.name = 'NetworkError';
9
9
  this.status = response.status;
10
10
  this.response = response;
11
11
  }
12
12
  }
13
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJOZXR3b3JrRXJyb3IiLCJFcnJvciIsImNvbnN0cnVjdG9yIiwicmVzcG9uc2UiLCJzdGF0dXNUZXh0Iiwic3RhdHVzIiwibmFtZSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9OZXR3b3JrRXJyb3IudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqIEFuIGVycm9yIHdpdGggYSBSZXN0IEVuZHBvaW50IGZldGNoXG4gKlxuICogQHNlZSBodHRwczovL2RhdGFjbGllbnQuaW8vcmVzdC9hcGkvTmV0d29ya0Vycm9yXG4gKi9cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIE5ldHdvcmtFcnJvciBleHRlbmRzIEVycm9yIHtcbiAgZGVjbGFyZSBzdGF0dXM6IG51bWJlcjtcbiAgZGVjbGFyZSByZXNwb25zZTogUmVzcG9uc2U7XG4gIG5hbWUgPSAnTmV0d29ya0Vycm9yJztcblxuICBjb25zdHJ1Y3RvcihyZXNwb25zZTogUmVzcG9uc2UpIHtcbiAgICBzdXBlcihcbiAgICAgIHJlc3BvbnNlLnN0YXR1c1RleHQgfHwgYE5ldHdvcmsgcmVzcG9uc2Ugbm90ICdvayc6ICR7cmVzcG9uc2Uuc3RhdHVzfWAsXG4gICAgKTtcbiAgICB0aGlzLnN0YXR1cyA9IHJlc3BvbnNlLnN0YXR1cztcbiAgICB0aGlzLnJlc3BvbnNlID0gcmVzcG9uc2U7XG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQSxlQUFlLE1BQU1BLFlBQVksU0FBU0MsS0FBSyxDQUFDO0VBSzlDQyxXQUFXQSxDQUFDQyxRQUFrQixFQUFFO0lBQzlCLEtBQUssQ0FDSEEsUUFBUSxDQUFDQyxVQUFVLElBQUksOEJBQThCRCxRQUFRLENBQUNFLE1BQU0sRUFDdEUsQ0FBQztJQUFDLEtBTEpDLElBQUksR0FBRyxjQUFjO0lBTW5CLElBQUksQ0FBQ0QsTUFBTSxHQUFHRixRQUFRLENBQUNFLE1BQU07SUFDN0IsSUFBSSxDQUFDRixRQUFRLEdBQUdBLFFBQVE7RUFDMUI7QUFDRiIsImlnbm9yZUxpc3QiOltdfQ==
13
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJOZXR3b3JrRXJyb3IiLCJFcnJvciIsImNvbnN0cnVjdG9yIiwicmVzcG9uc2UiLCJ1cmwiLCJzdGF0dXNUZXh0Iiwic3RhdHVzIiwibmFtZSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9OZXR3b3JrRXJyb3IudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqIEFuIGVycm9yIHdpdGggYSBSZXN0IEVuZHBvaW50IGZldGNoXG4gKlxuICogQHNlZSBodHRwczovL2RhdGFjbGllbnQuaW8vcmVzdC9hcGkvTmV0d29ya0Vycm9yXG4gKi9cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIE5ldHdvcmtFcnJvciBleHRlbmRzIEVycm9yIHtcbiAgZGVjbGFyZSBzdGF0dXM6IG51bWJlcjtcbiAgZGVjbGFyZSByZXNwb25zZTogUmVzcG9uc2U7XG4gIG5hbWUgPSAnTmV0d29ya0Vycm9yJztcblxuICBjb25zdHJ1Y3RvcihyZXNwb25zZTogUmVzcG9uc2UpIHtcbiAgICBzdXBlcihcbiAgICAgIGAke3Jlc3BvbnNlLnVybH06ICR7cmVzcG9uc2Uuc3RhdHVzVGV4dCB8fCBgU3RhdHVzIG5vdCAnb2snOiAke3Jlc3BvbnNlLnN0YXR1c31gfWAsXG4gICAgKTtcbiAgICB0aGlzLnN0YXR1cyA9IHJlc3BvbnNlLnN0YXR1cztcbiAgICB0aGlzLnJlc3BvbnNlID0gcmVzcG9uc2U7XG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQSxlQUFlLE1BQU1BLFlBQVksU0FBU0MsS0FBSyxDQUFDO0VBSzlDQyxXQUFXQSxDQUFDQyxRQUFrQixFQUFFO0lBQzlCLEtBQUssQ0FDSCxHQUFHQSxRQUFRLENBQUNDLEdBQUcsS0FBS0QsUUFBUSxDQUFDRSxVQUFVLElBQUksb0JBQW9CRixRQUFRLENBQUNHLE1BQU0sRUFBRSxFQUNsRixDQUFDO0lBQUMsS0FMSkMsSUFBSSxHQUFHLGNBQWM7SUFNbkIsSUFBSSxDQUFDRCxNQUFNLEdBQUdILFFBQVEsQ0FBQ0csTUFBTTtJQUM3QixJQUFJLENBQUNILFFBQVEsR0FBR0EsUUFBUTtFQUMxQjtBQUNGIiwiaWdub3JlTGlzdCI6W119
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-client/rest",
3
- "version": "0.14.8",
3
+ "version": "0.14.9",
4
4
  "description": "Quickly define typed REST resources and endpoints",
5
5
  "homepage": "https://dataclient.io/rest",
6
6
  "repository": {
@@ -136,6 +136,6 @@
136
136
  },
137
137
  "devDependencies": {
138
138
  "@anansi/browserslist-config": "^1.4.2",
139
- "@types/node": "^20.0.0"
139
+ "@types/node": "^22.0.0"
140
140
  }
141
141
  }
@@ -9,7 +9,7 @@ export default class NetworkError extends Error {
9
9
 
10
10
  constructor(response: Response) {
11
11
  super(
12
- response.statusText || `Network response not 'ok': ${response.status}`,
12
+ `${response.url}: ${response.statusText || `Status not 'ok': ${response.status}`}`,
13
13
  );
14
14
  this.status = response.status;
15
15
  this.response = response;