@recats/cdeebee 2.3.3 → 2.3.5

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/dist/cdeebee.js CHANGED
@@ -184,7 +184,7 @@ const de = (e) => ne(["__entity", "__state"], e), he = (e) => e.filter((t) => t.
184
184
  return e;
185
185
  const i = N([t, r, "__entity"], n[r], e);
186
186
  return N([t, r, "__entity", "__state"], U.EDITING, i);
187
- }, me = (e, t, r) => {
187
+ }, Ae = (e, t, r) => {
188
188
  const n = r || [];
189
189
  let s = e;
190
190
  for (let i = 0; i < t.length; i++) {
@@ -192,7 +192,7 @@ const de = (e) => ne(["__entity", "__state"], e), he = (e) => e.filter((t) => t.
192
192
  s = N([...n, ...l.key], l.value, s);
193
193
  }
194
194
  return s;
195
- }, Ae = ({
195
+ }, me = ({
196
196
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
197
197
  response: { responseStatus: e, ...t },
198
198
  cdeebee: r,
@@ -211,10 +211,10 @@ const de = (e) => ne(["__entity", "__state"], e), he = (e) => e.filter((t) => t.
211
211
  return t;
212
212
  }, ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
213
213
  __proto__: null,
214
- batchingUpdate: me,
214
+ batchingUpdate: Ae,
215
215
  checkNetworkActivity: je,
216
216
  commitEntity: ke,
217
- defaultNormalize: Ae,
217
+ defaultNormalize: me,
218
218
  dropRequestFromArray: he,
219
219
  editEntity: ve,
220
220
  getEntityState: X,
@@ -229,7 +229,7 @@ const de = (e) => ne(["__entity", "__state"], e), he = (e) => e.filter((t) => t.
229
229
  return { ...e, ...n.response };
230
230
  case y.CDEEBEE_ENTITY_CHANGE_FIELD: {
231
231
  const s = ve(e, n.entityList, n.entityID);
232
- return me(s, n.valueList, [n.entityList, n.entityID, "__entity"]);
232
+ return Ae(s, n.valueList, [n.entityList, n.entityID, "__entity"]);
233
233
  }
234
234
  case y.CDEEBEE_ENTITY_UNSAFE_UPDATE_STORE:
235
235
  return N([n.entityList, n.entityID], n.value, e);
@@ -653,24 +653,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
653
653
  })), fe;
654
654
  }
655
655
  Me();
656
- var m = typeof globalThis < "u" && globalThis || typeof self < "u" && self || // eslint-disable-next-line no-undef
657
- typeof global < "u" && global || {}, A = {
658
- searchParams: "URLSearchParams" in m,
659
- iterable: "Symbol" in m && "iterator" in Symbol,
660
- blob: "FileReader" in m && "Blob" in m && function() {
656
+ var A = typeof globalThis < "u" && globalThis || typeof self < "u" && self || // eslint-disable-next-line no-undef
657
+ typeof global < "u" && global || {}, m = {
658
+ searchParams: "URLSearchParams" in A,
659
+ iterable: "Symbol" in A && "iterator" in Symbol,
660
+ blob: "FileReader" in A && "Blob" in A && function() {
661
661
  try {
662
662
  return new Blob(), !0;
663
663
  } catch {
664
664
  return !1;
665
665
  }
666
666
  }(),
667
- formData: "FormData" in m,
668
- arrayBuffer: "ArrayBuffer" in m
667
+ formData: "FormData" in A,
668
+ arrayBuffer: "ArrayBuffer" in A
669
669
  };
670
670
  function Ge(e) {
671
671
  return e && DataView.prototype.isPrototypeOf(e);
672
672
  }
673
- if (A.arrayBuffer)
673
+ if (m.arrayBuffer)
674
674
  var Ye = [
675
675
  "[object Int8Array]",
676
676
  "[object Uint8Array]",
@@ -699,7 +699,7 @@ function ie(e) {
699
699
  return { done: r === void 0, value: r };
700
700
  }
701
701
  };
702
- return A.iterable && (t[Symbol.iterator] = function() {
702
+ return m.iterable && (t[Symbol.iterator] = function() {
703
703
  return t;
704
704
  }), t;
705
705
  }
@@ -753,7 +753,7 @@ _.prototype.entries = function() {
753
753
  e.push([r, t]);
754
754
  }), ie(e);
755
755
  };
756
- A.iterable && (_.prototype[Symbol.iterator] = _.prototype.entries);
756
+ m.iterable && (_.prototype[Symbol.iterator] = _.prototype.entries);
757
757
  function re(e) {
758
758
  if (!e._noBody) {
759
759
  if (e.bodyUsed)
@@ -791,8 +791,8 @@ function ye(e) {
791
791
  }
792
792
  function ge() {
793
793
  return this.bodyUsed = !1, this._initBody = function(e) {
794
- this.bodyUsed = this.bodyUsed, this._bodyInit = e, e ? typeof e == "string" ? this._bodyText = e : A.blob && Blob.prototype.isPrototypeOf(e) ? this._bodyBlob = e : A.formData && FormData.prototype.isPrototypeOf(e) ? this._bodyFormData = e : A.searchParams && URLSearchParams.prototype.isPrototypeOf(e) ? this._bodyText = e.toString() : A.arrayBuffer && A.blob && Ge(e) ? (this._bodyArrayBuffer = ye(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : A.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || Ke(e)) ? this._bodyArrayBuffer = ye(e) : this._bodyText = e = Object.prototype.toString.call(e) : (this._noBody = !0, this._bodyText = ""), this.headers.get("content-type") || (typeof e == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : A.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
795
- }, A.blob && (this.blob = function() {
794
+ this.bodyUsed = this.bodyUsed, this._bodyInit = e, e ? typeof e == "string" ? this._bodyText = e : m.blob && Blob.prototype.isPrototypeOf(e) ? this._bodyBlob = e : m.formData && FormData.prototype.isPrototypeOf(e) ? this._bodyFormData = e : m.searchParams && URLSearchParams.prototype.isPrototypeOf(e) ? this._bodyText = e.toString() : m.arrayBuffer && m.blob && Ge(e) ? (this._bodyArrayBuffer = ye(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : m.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || Ke(e)) ? this._bodyArrayBuffer = ye(e) : this._bodyText = e = Object.prototype.toString.call(e) : (this._noBody = !0, this._bodyText = ""), this.headers.get("content-type") || (typeof e == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : m.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
795
+ }, m.blob && (this.blob = function() {
796
796
  var e = re(this);
797
797
  if (e)
798
798
  return e;
@@ -813,7 +813,7 @@ function ge() {
813
813
  )
814
814
  ) : Promise.resolve(this._bodyArrayBuffer));
815
815
  } else {
816
- if (A.blob)
816
+ if (m.blob)
817
817
  return this.blob().then(Qe);
818
818
  throw new Error("could not read as ArrayBuffer");
819
819
  }
@@ -828,7 +828,7 @@ function ge() {
828
828
  if (this._bodyFormData)
829
829
  throw new Error("could not read FormData body as text");
830
830
  return Promise.resolve(this._bodyText);
831
- }, A.formData && (this.formData = function() {
831
+ }, m.formData && (this.formData = function() {
832
832
  return this.text().then(Xe);
833
833
  }), this.json = function() {
834
834
  return this.text().then(JSON.parse);
@@ -851,7 +851,7 @@ function L(e, t) {
851
851
  } else
852
852
  this.url = String(e);
853
853
  if (this.credentials = t.credentials || this.credentials || "same-origin", (t.headers || !this.headers) && (this.headers = new _(t.headers)), this.method = Ve(t.method || this.method || "GET"), this.mode = t.mode || this.mode || null, this.signal = t.signal || this.signal || function() {
854
- if ("AbortController" in m) {
854
+ if ("AbortController" in A) {
855
855
  var i = new AbortController();
856
856
  return i.signal;
857
857
  }
@@ -923,7 +923,7 @@ P.redirect = function(e, t) {
923
923
  throw new RangeError("Invalid status code");
924
924
  return new P(null, { status: t, headers: { location: e } });
925
925
  };
926
- var I = m.DOMException;
926
+ var I = A.DOMException;
927
927
  try {
928
928
  new I();
929
929
  } catch {
@@ -967,12 +967,12 @@ function se(e, t) {
967
967
  };
968
968
  function v(d) {
969
969
  try {
970
- return d === "" && m.location.href ? m.location.href : d;
970
+ return d === "" && A.location.href ? A.location.href : d;
971
971
  } catch {
972
972
  return d;
973
973
  }
974
974
  }
975
- if (i.open(s.method, v(s.url), !0), s.credentials === "include" ? i.withCredentials = !0 : s.credentials === "omit" && (i.withCredentials = !1), "responseType" in i && (A.blob ? i.responseType = "blob" : A.arrayBuffer && (i.responseType = "arraybuffer")), t && typeof t.headers == "object" && !(t.headers instanceof _ || m.Headers && t.headers instanceof m.Headers)) {
975
+ if (i.open(s.method, v(s.url), !0), s.credentials === "include" ? i.withCredentials = !0 : s.credentials === "omit" && (i.withCredentials = !1), "responseType" in i && (m.blob ? i.responseType = "blob" : m.arrayBuffer && (i.responseType = "arraybuffer")), t && typeof t.headers == "object" && !(t.headers instanceof _ || A.Headers && t.headers instanceof A.Headers)) {
976
976
  var R = [];
977
977
  Object.getOwnPropertyNames(t.headers).forEach(function(d) {
978
978
  R.push(j(d)), i.setRequestHeader(d, oe(t.headers[d]));
@@ -989,7 +989,7 @@ function se(e, t) {
989
989
  });
990
990
  }
991
991
  se.polyfill = !0;
992
- m.fetch || (m.fetch = se, m.Headers = _, m.Request = L, m.Response = P);
992
+ A.fetch || (A.fetch = se, A.Headers = _, A.Request = L, A.Response = P);
993
993
  let k = {};
994
994
  const et = typeof window < "u" ? "signal" in new Request("") ? window.fetch : se : fetch;
995
995
  class ft {
@@ -1104,8 +1104,7 @@ class ft {
1104
1104
  fileKey: "files",
1105
1105
  bodyKey: "body",
1106
1106
  method: "POST",
1107
- primaryKey: "primaryKey",
1108
- normalize: Ae,
1107
+ normalize: me,
1109
1108
  responseKeyCode: "responseStatus",
1110
1109
  headers: { "content-type": "application/json" },
1111
1110
  ...r
@@ -1,3 +1,3 @@
1
1
  (function(R,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(R=typeof globalThis<"u"?globalThis:R||self,d(R.cdeebee={}))})(this,function(R){"use strict";function d(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function B(e){return function t(r){return arguments.length===0||d(r)?t:e.apply(this,arguments)}}function P(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return d(r)?t:B(function(s){return e(r,s)});default:return d(r)&&d(n)?t:d(r)?B(function(s){return e(s,n)}):d(n)?B(function(s){return e(r,s)}):e(r,n)}}}function j(e){return function t(r,n,s){switch(arguments.length){case 0:return t;case 1:return d(r)?t:P(function(i,l){return e(r,i,l)});case 2:return d(r)&&d(n)?t:d(r)?P(function(i,l){return e(i,n,l)}):d(n)?P(function(i,l){return e(r,i,l)}):B(function(i){return e(r,n,i)});default:return d(r)&&d(n)&&d(s)?t:d(r)&&d(n)?P(function(i,l){return e(i,l,s)}):d(r)&&d(s)?P(function(i,l){return e(i,n,l)}):d(n)&&d(s)?P(function(i,l){return e(r,i,l)}):d(r)?B(function(i){return e(i,n,s)}):d(n)?B(function(i){return e(r,i,s)}):d(s)?B(function(i){return e(r,n,i)}):e(r,n,s)}}}const G=Array.isArray||function(t){return t!=null&&t.length>=0&&Object.prototype.toString.call(t)==="[object Array]"};function k(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function ce(e){return Object.prototype.toString.call(e)==="[object Object]"}const Y=Number.isInteger||function(t){return t<<0===t};function we(e,t,r){if(Y(e)&&G(r)){var n=[].concat(r);return n[e]=t,n}var s={};for(var i in r)s[i]=r[i];return s[e]=t,s}var Oe=B(function(t){return t==null}),I=j(function e(t,r,n){if(t.length===0)return r;var s=t[0];if(t.length>1){var i=!Oe(n)&&k(s,n)&&typeof n[s]=="object"?n[s]:Y(t[1])?[]:{};r=e(Array.prototype.slice.call(t,1),r,i)}return we(s,r,n)}),De=j(function(t,r,n){return I([t],r,n)});function Pe(e,t){return function(){var r=arguments.length;if(r===0)return t();var n=arguments[r-1];return G(n)||typeof n[e]!="function"?t.apply(this,arguments):n[e].apply(n,Array.prototype.slice.call(arguments,0,r-1))}}var Se=j(Pe("slice",function(t,r,n){return Array.prototype.slice.call(n,t,r)})),Be=j(function(t,r,n){var s=Array.prototype.slice.call(n,0);return s.splice(t,r),s});function Ce(e,t){if(t==null)return t;if(Y(e)&&G(t))return Be(e,1,t);var r={};for(var n in t)r[n]=t[n];return delete r[e],r}function Ie(e,t){if(Y(e)&&G(t))return[].concat(t);var r={};for(var n in t)r[n]=t[n];return r}var Ne=P(function e(t,r){if(r==null)return r;switch(t.length){case 0:return r;case 1:return Ce(t[0],r);default:var n=t[0],s=Array.prototype.slice.call(t,1);return r[n]==null?Ie(n,r):De(n,e(s,r[n]),r)}}),le=P(function(t,r){return Ne([t],r)}),Ue=j(function(t,r,n){var s={},i;r=r||{},n=n||{};for(i in r)k(i,r)&&(s[i]=k(i,n)?t(i,r[i],n[i]):r[i]);for(i in n)k(i,n)&&!k(i,s)&&(s[i]=n[i]);return s}),Le=j(function e(t,r,n){return Ue(function(s,i,l){return ce(i)&&ce(l)?e(t,i,l):t(s,i,l)},r,n)}),K=P(function(t,r){return Le(function(n,s,i){return i},t,r)}),Z=P(function(t,r){for(var n={},s={},i=0,l=t.length;i<l;)s[t[i]]=1,i+=1;for(var m in r)s.hasOwnProperty(m)||(n[m]=r[m]);return n}),y=(e=>(e.CDEEBEE_REQUESTMANAGER_SHIFT="@@cdeebee/REQUESTMANAGER_SHIFT",e.CDEEBEE_REQUESTMANAGER_SET="@@cdeebee/REQUESTMANAGER_SET",e.CDEEBEE_ERRORHANDLER_SET="@@cdeebee/ERRORHANDLER_SET",e.CDEEBEE_ENTITY_CHANGE_FIELD="@@cdeebee/ENTITY_CHANGE_FIELD",e.CDEEBEE_ENTITY_UNSAFE_UPDATE_STORE="@@cdeebee/ENTITY_UNSAFE_UPDATE_STORE",e.CDEEBEE_RESET_ENTITY="@@cdeebee/RESET_ENTITY",e.CDEEBEE_SET_ENTITY="@@cdeebee/SET_ENTITY",e.CDEEBEEE_UPDATE="@@cdeebee/UPDATE",e.CDEEBEEE_DROP="@@cdeebee/DROP",e.CDEEBEEE_DROP_PATH="@@cdeebee/DROP_PATH",e.CDEEBEE_INTERNAL_ERROR="@@cdeebee/INTERNAL_ERROR",e.CDEEBEE_REQUEST_ABORTED="@@cdeebee/REQUEST_ABORTED",e.CDEEBEEE_DROP_REQUEST_BY_API_URL="@@cdeebee/DROP_REQUEST_BY_API_URL",e.CDEEBEEE_DROP_ERROR_BY_API_URL="@@cdeebee/DROP_ERROR_BY_API_URL",e.CHANGE_ROUTE="@@router/LOCATION_CHANGE",e))(y||{}),C=(e=>(e.NEW="NEW",e.EDITING="EDITING",e.NORMAL="NORMAL",e))(C||{}),ee=(e=>(e.merge="merge",e.replace="replace",e))(ee||{});const fe=e=>Z(["__entity","__state"],e),Ee=e=>e.filter(t=>t.requestCancel?(ye(t),!1):!0),ye=e=>{e.controller&&e.controller.abort instanceof Function&&e.controller.abort()},qe=(e,t)=>{if(!t||e.length===0)return!1;const r=t instanceof Array?t:[t],n=e.map(s=>s.api);for(let s=0;s<r.length;s+=1)if(n.includes(r[s]))return!0;return!1},je=e=>Object.prototype.hasOwnProperty.call(e,"__entity")?e.__entity:e,Q=e=>{var r;const t=((r=e==null?void 0:e.__entity)==null?void 0:r.__state)||(e==null?void 0:e.__state);return t||C.NORMAL},He=e=>(e.__state=C.NEW,e),ke=e=>Q(e)===C.NORMAL?(console.warn("commit works only in editing and new states"),e):fe(e),de=e=>Q(e)===C.NORMAL?(console.warn("reset works only in editing and new states"),e):fe(e),pe=(e,t,r)=>{const n=e[t];if(Q(n[r])===C.EDITING)return e;const i=I([t,r,"__entity"],n[r],e);return I([t,r,"__entity","__state"],C.EDITING,i)},he=(e,t,r)=>{const n=r||[];let s=e;for(let i=0;i<t.length;i++){const l=t[i];s=I([...n,...l.key],l.value,s)}return s},_e=({response:{responseStatus:e,...t},cdeebee:r,mergeListStrategy:n,primaryKey:s})=>{const i=Object.keys(t);for(const l of i){const m={};if(t[l]instanceof Object&&Object.prototype.hasOwnProperty.call(t[l],s)){for(const g of t[l].data)m[g[t[l][s]]]=g;n[l]===ee.replace?t[l]=m:t[l]=K(r[l],m)}else(t[l]===null||t[l]===void 0||typeof t[l]=="string")&&(t=Z([l],t))}return t},Fe=Object.freeze(Object.defineProperty({__proto__:null,batchingUpdate:he,checkNetworkActivity:qe,commitEntity:ke,defaultNormalize:_e,dropRequestFromArray:Ee,editEntity:pe,getEntityState:Q,getSubEntity:je,insertEntity:He,requestCancel:ye,resetEntity:de},Symbol.toStringTag,{value:"Module"})),be={},xe=(e=be,t)=>{const{type:r,payload:n}=t;switch(r){case y.CDEEBEEE_UPDATE:return{...e,...n.response};case y.CDEEBEE_ENTITY_CHANGE_FIELD:{const s=pe(e,n.entityList,n.entityID);return he(s,n.valueList,[n.entityList,n.entityID,"__entity"])}case y.CDEEBEE_ENTITY_UNSAFE_UPDATE_STORE:return I([n.entityList,n.entityID],n.value,e);case y.CDEEBEE_SET_ENTITY:return I([n.entityList,n.entityID],n.entity,e);case y.CDEEBEE_RESET_ENTITY:{const s=e[n.entityList];return I([n.entityList,n.entityID],de(s[n.entityID]),e)}case y.CDEEBEEE_DROP:return be;case y.CDEEBEEE_DROP_PATH:return Z(n.path,e);default:return e}},ve={activeRequest:[],requestByApiUrl:{},errorHandler:{}},Me=(e=ve,t)=>{const{type:r,payload:n}=t;switch(r){case y.CDEEBEE_REQUESTMANAGER_SET:return{...e,activeRequest:[...e.activeRequest,n]};case y.CDEEBEE_REQUESTMANAGER_SHIFT:return{...e,activeRequest:Se(1,1/0,e.activeRequest)};case y.CDEEBEEE_UPDATE:return{...e,requestByApiUrl:{...e.requestByApiUrl,[n.api]:n.cleanResponse}};case y.CDEEBEEE_DROP_REQUEST_BY_API_URL:return{...e,requestByApiUrl:le(n.api,e.requestByApiUrl)};case y.CDEEBEEE_DROP_ERROR_BY_API_URL:return{...e,errorHandler:le(n.api,e.errorHandler)};case y.CDEEBEE_ERRORHANDLER_SET:return{...e,errorHandler:{...e.errorHandler,[n.api]:n.cleanResponse}};case y.CDEEBEE_INTERNAL_ERROR:return{...e,activeRequest:[],requestByApiUrl:{}};case y.CHANGE_ROUTE:return{...ve,activeRequest:Ee(e.activeRequest)};default:return e}};var Ge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},me={},Ae;function Ye(){return Ae||(Ae=1,function(e){e()}(function(){function e(o,a){(a==null||a>o.length)&&(a=o.length);for(var u=0,c=Array(a);u<a;u++)c[u]=o[u];return c}function t(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function r(o,a,u){return a=g(a),x(o,T()?Reflect.construct(a,[],g(o).constructor):a.apply(o,u))}function n(o,a){if(!(o instanceof a))throw new TypeError("Cannot call a class as a function")}function s(o,a){for(var u=0;u<a.length;u++){var c=a[u];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(o,se(c.key),c)}}function i(o,a,u){return a&&s(o.prototype,a),u&&s(o,u),Object.defineProperty(o,"prototype",{writable:!1}),o}function l(o,a){var u=typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(!u){if(Array.isArray(o)||(u=W(o))||a){u&&(o=u);var c=0,E=function(){};return{s:E,n:function(){return c>=o.length?{done:!0}:{done:!1,value:o[c++]}},e:function(f){throw f},f:E}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _,w=!0,b=!1;return{s:function(){u=u.call(o)},n:function(){var f=u.next();return w=f.done,f},e:function(f){b=!0,_=f},f:function(){try{w||u.return==null||u.return()}finally{if(b)throw _}}}}function m(){return m=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(o,a,u){var c=z(o,a);if(c){var E=Object.getOwnPropertyDescriptor(c,a);return E.get?E.get.call(arguments.length<3?o:u):E.value}},m.apply(null,arguments)}function g(o){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},g(o)}function p(o,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(a&&a.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),Object.defineProperty(o,"prototype",{writable:!1}),a&&L(o,a)}function T(){try{var o=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(T=function(){return!!o})()}function x(o,a){if(a&&(typeof a=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return t(o)}function L(o,a){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,c){return u.__proto__=c,u},L(o,a)}function z(o,a){for(;!{}.hasOwnProperty.call(o,a)&&(o=g(o))!==null;);return o}function ie(o,a,u,c){var E=m(g(o.prototype),a,u);return typeof E=="function"?function(_){return E.apply(u,_)}:E}function $(o,a){if(typeof o!="object"||!o)return o;var u=o[Symbol.toPrimitive];if(u!==void 0){var c=u.call(o,a);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}function se(o){var a=$(o,"string");return typeof a=="symbol"?a:a+""}function W(o,a){if(o){if(typeof o=="string")return e(o,a);var u={}.toString.call(o).slice(8,-1);return u==="Object"&&o.constructor&&(u=o.constructor.name),u==="Map"||u==="Set"?Array.from(o):u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u)?e(o,a):void 0}}function ae(o){var a;try{a=new Event("abort")}catch{typeof document<"u"?document.createEvent?(a=document.createEvent("Event"),a.initEvent("abort",!1,!1)):(a=document.createEventObject(),a.type="abort"):a={type:"abort",bubbles:!1,cancelable:!1}}return a.reason=o,a}function ue(o){if(o===void 0)if(typeof document>"u")o=new Error("This operation was aborted"),o.name="AbortError";else try{o=new DOMException("signal is aborted without reason"),Object.defineProperty(o,"name",{value:"AbortError"})}catch{o=new Error("This operation was aborted"),o.name="AbortError"}return o}var V=function(){function o(){n(this,o),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return i(o,[{key:"addEventListener",value:function(u,c,E){u in this.listeners||(this.listeners[u]=[]),this.listeners[u].push({callback:c,options:E})}},{key:"removeEventListener",value:function(u,c){if(u in this.listeners){for(var E=this.listeners[u],_=0,w=E.length;_<w;_++)if(E[_].callback===c){E.splice(_,1);return}}}},{key:"dispatchEvent",value:function(u){var c=this;if(u.type in this.listeners){for(var E=this.listeners[u.type],_=E.slice(),w=function(){var D=_[b];try{D.callback.call(c,u)}catch(J){Promise.resolve().then(function(){throw J})}D.options&&D.options.once&&c.removeEventListener(u.type,D.callback)},b=0,f=_.length;b<f;b++)w();return!u.defaultPrevented}}}])}(),M=function(o){function a(){var u;return n(this,a),u=r(this,a),u.listeners||V.call(u),Object.defineProperty(u,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(u,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(u,"reason",{value:void 0,writable:!0,configurable:!0}),u}return p(a,o),i(a,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(c){c.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,c)),ie(a,"dispatchEvent",this)([c])}},{key:"throwIfAborted",value:function(){var c=this.aborted,E=this.reason,_=E===void 0?"Aborted":E;if(c)throw _}}],[{key:"timeout",value:function(c){var E=new q;return setTimeout(function(){return E.abort(new DOMException("This signal is timeout in ".concat(c,"ms"),"TimeoutError"))},c),E.signal}},{key:"any",value:function(c){var E=new q;function _(){E.abort(this.reason),w()}function w(){var D=l(c),J;try{for(D.s();!(J=D.n()).done;){var Et=J.value;Et.removeEventListener("abort",_)}}catch(yt){D.e(yt)}finally{D.f()}}var b=l(c),f;try{for(b.s();!(f=b.n()).done;){var X=f.value;if(X.aborted){E.abort(X.reason);break}else X.addEventListener("abort",_)}}catch(D){b.e(D)}finally{b.f()}return E.signal}}])}(V),q=function(){function o(){n(this,o),Object.defineProperty(this,"signal",{value:new M,writable:!0,configurable:!0})}return i(o,[{key:"abort",value:function(u){var c=ue(u),E=ae(c);this.signal.reason=c,this.signal.dispatchEvent(E)}},{key:"toString",value:function(){return"[object AbortController]"}}])}();typeof Symbol<"u"&&Symbol.toStringTag&&(q.prototype[Symbol.toStringTag]="AbortController",M.prototype[Symbol.toStringTag]="AbortSignal");function O(o){return o.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof o.Request=="function"&&!o.Request.prototype.hasOwnProperty("signal")||!o.AbortController}(function(o){O(o)&&(o.AbortController=q,o.AbortSignal=M)})(typeof self<"u"?self:Ge)})),me}Ye();var v=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},A={searchParams:"URLSearchParams"in v,iterable:"Symbol"in v&&"iterator"in Symbol,blob:"FileReader"in v&&"Blob"in v&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in v,arrayBuffer:"ArrayBuffer"in v};function Ke(e){return e&&DataView.prototype.isPrototypeOf(e)}if(A.arrayBuffer)var Qe=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],ze=ArrayBuffer.isView||function(e){return e&&Qe.indexOf(Object.prototype.toString.call(e))>-1};function H(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function te(e){return typeof e!="string"&&(e=String(e)),e}function re(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return A.iterable&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){if(t.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}h.prototype.append=function(e,t){e=H(e),t=te(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},h.prototype.delete=function(e){delete this.map[H(e)]},h.prototype.get=function(e){return e=H(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(H(e))},h.prototype.set=function(e,t){this.map[H(e)]=te(t)},h.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},h.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),re(e)},h.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),re(e)},h.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),re(e)},A.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);function ne(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}}function ge(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function $e(e){var t=new FileReader,r=ge(t);return t.readAsArrayBuffer(e),r}function We(e){var t=new FileReader,r=ge(t),n=/charset=([A-Za-z0-9_-]+)/.exec(e.type),s=n?n[1]:"utf-8";return t.readAsText(e,s),r}function Ve(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function Re(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Te(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:A.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:A.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():A.arrayBuffer&&A.blob&&Ke(e)?(this._bodyArrayBuffer=Re(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||ze(e))?this._bodyArrayBuffer=Re(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):A.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var e=ne(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=ne(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(A.blob)return this.blob().then($e);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var e=ne(this);if(e)return e;if(this._bodyBlob)return We(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Ve(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(Ze)}),this.json=function(){return this.text().then(JSON.parse)},this}var Xe=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function Je(e){var t=e.toUpperCase();return Xe.indexOf(t)>-1?t:e}function N(e,t){if(!(this instanceof N))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof N){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new h(t.headers)),this.method=Je(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in v){var i=new AbortController;return i.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var s=/\?/;this.url+=(s.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}N.prototype.clone=function(){return new N(this,{body:this._bodyInit})};function Ze(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),s=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(s),decodeURIComponent(i))}}),t}function et(e){var t=new h,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
3
- `)===0?n.substr(1,n.length):n}).forEach(function(n){var s=n.split(":"),i=s.shift().trim();if(i){var l=s.join(":").trim();try{t.append(i,l)}catch(m){console.warn("Response "+m.message)}}}),t}Te.call(N.prototype);function S(e,t){if(!(this instanceof S))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}Te.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var tt=[301,302,303,307,308];S.redirect=function(e,t){if(tt.indexOf(t)===-1)throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})};var U=v.DOMException;try{new U}catch{U=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},U.prototype=Object.create(Error.prototype),U.prototype.constructor=U}function oe(e,t){return new Promise(function(r,n){var s=new N(e,t);if(s.signal&&s.signal.aborted)return n(new U("Aborted","AbortError"));var i=new XMLHttpRequest;function l(){i.abort()}i.onload=function(){var p={statusText:i.statusText,headers:et(i.getAllResponseHeaders()||"")};s.url.indexOf("file://")===0&&(i.status<200||i.status>599)?p.status=200:p.status=i.status,p.url="responseURL"in i?i.responseURL:p.headers.get("X-Request-URL");var T="response"in i?i.response:i.responseText;setTimeout(function(){r(new S(T,p))},0)},i.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},i.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},i.onabort=function(){setTimeout(function(){n(new U("Aborted","AbortError"))},0)};function m(p){try{return p===""&&v.location.href?v.location.href:p}catch{return p}}if(i.open(s.method,m(s.url),!0),s.credentials==="include"?i.withCredentials=!0:s.credentials==="omit"&&(i.withCredentials=!1),"responseType"in i&&(A.blob?i.responseType="blob":A.arrayBuffer&&(i.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof h||v.Headers&&t.headers instanceof v.Headers)){var g=[];Object.getOwnPropertyNames(t.headers).forEach(function(p){g.push(H(p)),i.setRequestHeader(p,te(t.headers[p]))}),s.headers.forEach(function(p,T){g.indexOf(T)===-1&&i.setRequestHeader(T,p)})}else s.headers.forEach(function(p,T){i.setRequestHeader(T,p)});s.signal&&(s.signal.addEventListener("abort",l),i.onreadystatechange=function(){i.readyState===4&&s.signal.removeEventListener("abort",l)}),i.send(typeof s._bodyInit>"u"?null:s._bodyInit)})}oe.polyfill=!0,v.fetch||(v.fetch=oe,v.Headers=h,v.Request=N,v.Response=S);let F={};const rt=typeof window<"u"?"signal"in new Request("")?window.fetch:oe:fetch;class nt{constructor(t,r){this.send=n=>async(s,i)=>{var a,u;const{api:l,preUpdate:m,postUpdate:g,preError:p,postError:T,data:x,files:L,requestCancel:z=!0,updateStore:ie=!0,fileKey:$=this.options.fileKey,primaryKey:se=this.options.primaryKey,bodyKey:W=this.options.bodyKey,method:ae=this.options.method,normalize:ue=this.options.normalize,mergeListStrategy:V=this.options.mergeListStrategy,headers:M=this.options.headers,responseKeyCode:q=this.options.responseKeyCode}=K(this.requestObject,n),O=Math.random().toString(36).substr(2),o=new Date;try{let c=JSON.stringify({...x,requestID:O});const E=new AbortController,{signal:_}=E;if(s({type:y.CDEEBEE_REQUESTMANAGER_SET,payload:{requestID:O,api:l,controller:E,data:x,requestCancel:z,requestStartTime:o,requestEndTime:void 0}}),L){const b=new FormData;for(let f=0;f<L.length;f+=1)$&&b.append($,L[f]);W&&b.append(W,c),c=b}const w=await(await rt(l,{method:ae,signal:_,headers:{"ui-request-id":O,...M},body:c})).json();if(w)for(F=Object.assign({[O]:{requestID:O,response:w,requestApi:l,requestStartTime:o,preUpdate:m,postUpdate:g,normalize:ue,preError:p,postError:T,mergeListStrategy:V,updateStore:ie,data:x,requestCancel:z,controller:E}},F);F[(u=(a=i().requestManager.activeRequest)==null?void 0:a[0])==null?void 0:u.requestID];){const b=i().requestManager.activeRequest[0].requestID,f=F[b];q&&f.response[q]===0?(f.preUpdate&&f.preUpdate(f.response),f.updateStore&&s({type:y.CDEEBEEE_UPDATE,payload:{response:f.normalize instanceof Function&&f.normalize({response:f.response,cdeebee:i().cdeebee,mergeListStrategy:f.mergeListStrategy,primaryKey:se}),cleanResponse:f.response,api:f.requestApi,mergeListStrategy:f.mergeListStrategy}}),f.postUpdate&&f.postUpdate(f.response)):(f.preError&&f.preError(f.response),s({type:y.CDEEBEE_ERRORHANDLER_SET,payload:{api:f.requestApi,cleanResponse:f.response}}),f.postError&&f.postError(w)),s({type:y.CDEEBEE_REQUESTMANAGER_SHIFT,payload:{requestID:f.requestID,api:f.requestApi,controller:f.controller,data:f.data,requestCancel:f.requestCancel,requestStartTime:f.requestStartTime,requestEndTime:new Date}}),delete F[b]}}catch(c){if(c.name==="AbortError")s({type:y.CDEEBEE_REQUEST_ABORTED,payload:{requestID:O,api:l}});else{const E=new Date;s({type:y.CDEEBEE_INTERNAL_ERROR,payload:{requestStartTime:o,requestEndTime:E,requestID:O,api:l}}),console.warn("@@makeRequest-error",c),console.warn("@@makeRequest-object",K(this.requestObject,n)),console.warn("@@makeRequest-info",{requestStartTime:o,requestEndTime:E,requestID:O}),Object.prototype.hasOwnProperty.call(this.options,"globalErrorHandler")&&this.options.globalErrorHandler instanceof Function&&this.options.globalErrorHandler(c,K(this.requestObject,n),{requestStartTime:o,requestEndTime:E,requestID:O})(s,i)}}},this.requestObject=t,this.options={fileKey:"files",bodyKey:"body",method:"POST",primaryKey:"primaryKey",normalize:_e,responseKeyCode:"responseStatus",headers:{"content-type":"application/json"},...r}}}function ot(e,t,r){return n=>{n({type:y.CDEEBEE_ENTITY_UNSAFE_UPDATE_STORE,payload:{entityList:e,entityID:t,value:r}})}}function it(e,t,r){return n=>{n({type:y.CDEEBEE_ENTITY_CHANGE_FIELD,payload:{entityList:e,entityID:t,valueList:r}})}}function st(e,t,r){return n=>{n({type:y.CDEEBEE_SET_ENTITY,payload:{entityList:e,entityID:t,entity:r}})}}function at(e,t){return r=>{r({type:y.CDEEBEE_RESET_ENTITY,payload:{entityList:e,entityID:t}})}}function ut(e){return t=>t({type:y.CDEEBEEE_DROP_PATH,payload:{path:e}})}function ct(e){return t=>t({type:y.CDEEBEEE_DROP_REQUEST_BY_API_URL,payload:{api:e}})}function lt(e){return t=>t({type:y.CDEEBEEE_DROP_ERROR_BY_API_URL,payload:{api:e}})}const ft=Object.freeze(Object.defineProperty({__proto__:null,commitEntity:st,dropCdeebeePath:ut,dropErrorsByApiUrl:lt,dropRequestByApiUrl:ct,resetEntity:at,setKeyValue:it,unsafe_updateStore:ot},Symbol.toStringTag,{value:"Module"}));R.CdeebeeRequest=nt,R.cdeebee=xe,R.cdeebeeActions=ft,R.cdeebeeEntityState=C,R.cdeebeeHelpers=Fe,R.cdeebeeMergeStrategy=ee,R.cdeebeeTypes=y,R.requestManager=Me,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
3
+ `)===0?n.substr(1,n.length):n}).forEach(function(n){var s=n.split(":"),i=s.shift().trim();if(i){var l=s.join(":").trim();try{t.append(i,l)}catch(m){console.warn("Response "+m.message)}}}),t}Te.call(N.prototype);function S(e,t){if(!(this instanceof S))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}Te.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var tt=[301,302,303,307,308];S.redirect=function(e,t){if(tt.indexOf(t)===-1)throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})};var U=v.DOMException;try{new U}catch{U=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},U.prototype=Object.create(Error.prototype),U.prototype.constructor=U}function oe(e,t){return new Promise(function(r,n){var s=new N(e,t);if(s.signal&&s.signal.aborted)return n(new U("Aborted","AbortError"));var i=new XMLHttpRequest;function l(){i.abort()}i.onload=function(){var p={statusText:i.statusText,headers:et(i.getAllResponseHeaders()||"")};s.url.indexOf("file://")===0&&(i.status<200||i.status>599)?p.status=200:p.status=i.status,p.url="responseURL"in i?i.responseURL:p.headers.get("X-Request-URL");var T="response"in i?i.response:i.responseText;setTimeout(function(){r(new S(T,p))},0)},i.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},i.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},i.onabort=function(){setTimeout(function(){n(new U("Aborted","AbortError"))},0)};function m(p){try{return p===""&&v.location.href?v.location.href:p}catch{return p}}if(i.open(s.method,m(s.url),!0),s.credentials==="include"?i.withCredentials=!0:s.credentials==="omit"&&(i.withCredentials=!1),"responseType"in i&&(A.blob?i.responseType="blob":A.arrayBuffer&&(i.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof h||v.Headers&&t.headers instanceof v.Headers)){var g=[];Object.getOwnPropertyNames(t.headers).forEach(function(p){g.push(H(p)),i.setRequestHeader(p,te(t.headers[p]))}),s.headers.forEach(function(p,T){g.indexOf(T)===-1&&i.setRequestHeader(T,p)})}else s.headers.forEach(function(p,T){i.setRequestHeader(T,p)});s.signal&&(s.signal.addEventListener("abort",l),i.onreadystatechange=function(){i.readyState===4&&s.signal.removeEventListener("abort",l)}),i.send(typeof s._bodyInit>"u"?null:s._bodyInit)})}oe.polyfill=!0,v.fetch||(v.fetch=oe,v.Headers=h,v.Request=N,v.Response=S);let F={};const rt=typeof window<"u"?"signal"in new Request("")?window.fetch:oe:fetch;class nt{constructor(t,r){this.send=n=>async(s,i)=>{var a,u;const{api:l,preUpdate:m,postUpdate:g,preError:p,postError:T,data:x,files:L,requestCancel:z=!0,updateStore:ie=!0,fileKey:$=this.options.fileKey,primaryKey:se=this.options.primaryKey,bodyKey:W=this.options.bodyKey,method:ae=this.options.method,normalize:ue=this.options.normalize,mergeListStrategy:V=this.options.mergeListStrategy,headers:M=this.options.headers,responseKeyCode:q=this.options.responseKeyCode}=K(this.requestObject,n),O=Math.random().toString(36).substr(2),o=new Date;try{let c=JSON.stringify({...x,requestID:O});const E=new AbortController,{signal:_}=E;if(s({type:y.CDEEBEE_REQUESTMANAGER_SET,payload:{requestID:O,api:l,controller:E,data:x,requestCancel:z,requestStartTime:o,requestEndTime:void 0}}),L){const b=new FormData;for(let f=0;f<L.length;f+=1)$&&b.append($,L[f]);W&&b.append(W,c),c=b}const w=await(await rt(l,{method:ae,signal:_,headers:{"ui-request-id":O,...M},body:c})).json();if(w)for(F=Object.assign({[O]:{requestID:O,response:w,requestApi:l,requestStartTime:o,preUpdate:m,postUpdate:g,normalize:ue,preError:p,postError:T,mergeListStrategy:V,updateStore:ie,data:x,requestCancel:z,controller:E}},F);F[(u=(a=i().requestManager.activeRequest)==null?void 0:a[0])==null?void 0:u.requestID];){const b=i().requestManager.activeRequest[0].requestID,f=F[b];q&&f.response[q]===0?(f.preUpdate&&f.preUpdate(f.response),f.updateStore&&s({type:y.CDEEBEEE_UPDATE,payload:{response:f.normalize instanceof Function&&f.normalize({response:f.response,cdeebee:i().cdeebee,mergeListStrategy:f.mergeListStrategy,primaryKey:se}),cleanResponse:f.response,api:f.requestApi,mergeListStrategy:f.mergeListStrategy}}),f.postUpdate&&f.postUpdate(f.response)):(f.preError&&f.preError(f.response),s({type:y.CDEEBEE_ERRORHANDLER_SET,payload:{api:f.requestApi,cleanResponse:f.response}}),f.postError&&f.postError(w)),s({type:y.CDEEBEE_REQUESTMANAGER_SHIFT,payload:{requestID:f.requestID,api:f.requestApi,controller:f.controller,data:f.data,requestCancel:f.requestCancel,requestStartTime:f.requestStartTime,requestEndTime:new Date}}),delete F[b]}}catch(c){if(c.name==="AbortError")s({type:y.CDEEBEE_REQUEST_ABORTED,payload:{requestID:O,api:l}});else{const E=new Date;s({type:y.CDEEBEE_INTERNAL_ERROR,payload:{requestStartTime:o,requestEndTime:E,requestID:O,api:l}}),console.warn("@@makeRequest-error",c),console.warn("@@makeRequest-object",K(this.requestObject,n)),console.warn("@@makeRequest-info",{requestStartTime:o,requestEndTime:E,requestID:O}),Object.prototype.hasOwnProperty.call(this.options,"globalErrorHandler")&&this.options.globalErrorHandler instanceof Function&&this.options.globalErrorHandler(c,K(this.requestObject,n),{requestStartTime:o,requestEndTime:E,requestID:O})(s,i)}}},this.requestObject=t,this.options={fileKey:"files",bodyKey:"body",method:"POST",normalize:_e,responseKeyCode:"responseStatus",headers:{"content-type":"application/json"},...r}}}function ot(e,t,r){return n=>{n({type:y.CDEEBEE_ENTITY_UNSAFE_UPDATE_STORE,payload:{entityList:e,entityID:t,value:r}})}}function it(e,t,r){return n=>{n({type:y.CDEEBEE_ENTITY_CHANGE_FIELD,payload:{entityList:e,entityID:t,valueList:r}})}}function st(e,t,r){return n=>{n({type:y.CDEEBEE_SET_ENTITY,payload:{entityList:e,entityID:t,entity:r}})}}function at(e,t){return r=>{r({type:y.CDEEBEE_RESET_ENTITY,payload:{entityList:e,entityID:t}})}}function ut(e){return t=>t({type:y.CDEEBEEE_DROP_PATH,payload:{path:e}})}function ct(e){return t=>t({type:y.CDEEBEEE_DROP_REQUEST_BY_API_URL,payload:{api:e}})}function lt(e){return t=>t({type:y.CDEEBEEE_DROP_ERROR_BY_API_URL,payload:{api:e}})}const ft=Object.freeze(Object.defineProperty({__proto__:null,commitEntity:st,dropCdeebeePath:ut,dropErrorsByApiUrl:lt,dropRequestByApiUrl:ct,resetEntity:at,setKeyValue:it,unsafe_updateStore:ot},Symbol.toStringTag,{value:"Module"}));R.CdeebeeRequest=nt,R.cdeebee=xe,R.cdeebeeActions=ft,R.cdeebeeEntityState=C,R.cdeebeeHelpers=Fe,R.cdeebeeMergeStrategy=ee,R.cdeebeeTypes=y,R.requestManager=Me,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
@@ -30,7 +30,7 @@ export type IDefaultOption = {
30
30
  files?: File[];
31
31
  fileKey?: string;
32
32
  bodyKey?: string;
33
- primaryKey?: string;
33
+ primaryKey: string;
34
34
  responseKeyCode?: string;
35
35
  requestCancel?: boolean;
36
36
  updateStore?: boolean;
@@ -38,10 +38,6 @@ export type IDefaultOption = {
38
38
  [key: string]: cdeebeeMergeStrategy;
39
39
  };
40
40
  normalize?: (t: any) => void;
41
- preUpdate?: (payload: object) => void;
42
- postUpdate?: (payload: object) => void;
43
- preError?: (payload: object) => void;
44
- postError?: (payload: object) => void;
45
41
  method?: 'POST' | 'GET' | 'PUT' | 'DELETE';
46
42
  globalErrorHandler?: (error: object, request: object, meta: {
47
43
  requestStartTime: Date;
@@ -49,29 +45,30 @@ export type IDefaultOption = {
49
45
  requestID: string;
50
46
  }) => (dispatch: Dispatch, getState: () => object) => void;
51
47
  };
52
- export type IResponsePropObject = {
48
+ interface ResponseCallbacks<R> {
49
+ normalize?: (t: any) => void;
50
+ preUpdate?: (payload: R) => void;
51
+ postUpdate?: (payload: R) => void;
52
+ preError?: (payload: R) => void;
53
+ postError?: (payload: R) => void;
54
+ }
55
+ export interface IRequestOptions<T, R> extends Omit<IDefaultOption, 'primaryKey'>, ResponseCallbacks<R> {
56
+ api: string;
57
+ primaryKey?: string;
58
+ data?: T;
59
+ }
60
+ export interface IResponsePropObject<R> extends ResponseCallbacks<R> {
53
61
  requestID: string;
54
62
  controller: AbortController;
55
63
  updateStore: boolean;
56
64
  data: object;
57
65
  requestCancel: boolean;
58
66
  requestApi: string;
59
- response: {
60
- [params: string]: unknown;
61
- };
67
+ response: R;
62
68
  requestStartTime?: Date;
63
69
  mergeListStrategy?: {
64
70
  [key: string]: cdeebeeMergeStrategy;
65
71
  };
66
- normalize?: (t: any) => void;
67
- preUpdate?: (payload: object) => void;
68
- postUpdate?: (payload: object) => void;
69
- preError?: (payload: object) => void;
70
- postError?: (payload: object) => void;
71
- };
72
- export interface IRequestOptions<T> extends IDefaultOption {
73
- api: string;
74
- data?: T;
75
72
  }
76
73
  export interface IEntity {
77
74
  __entity?: {
@@ -206,3 +203,4 @@ export interface IDefaultNormalize {
206
203
  [key: string]: cdeebeeMergeStrategy;
207
204
  };
208
205
  }
206
+ export {};
package/dist/request.d.ts CHANGED
@@ -4,5 +4,5 @@ export default class requestManager {
4
4
  requestObject: object;
5
5
  private options;
6
6
  constructor(requestObject: object, options: IDefaultOption);
7
- send: <T>(rq: IRequestOptions<T>) => (dispatch: Dispatch, getState: () => any) => Promise<void>;
7
+ send: <T, R>(rq: IRequestOptions<T, R>) => (dispatch: Dispatch, getState: () => any) => Promise<void>;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recats/cdeebee",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "React Redux data-logic library",
5
5
  "repository": "git@github.com:recats/cdeebee.git",
6
6
  "author": "recats",