@data-client/core 0.11.0 → 0.11.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/index.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/state/RIC.js +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/state/RIC.js +2 -2
- package/package.json +2 -2
- package/src/controller/__tests__/get.ts +1 -1
- package/src/index.ts +1 -0
- package/src/manager/__tests__/logoutManager.ts +0 -2
- package/src/state/RIC.ts +1 -1
- package/ts3.4/index.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var normalizr = require('@data-client/normalizr');
|
|
6
6
|
|
|
7
|
-
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb =>
|
|
7
|
+
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb => cb();
|
|
8
8
|
var RIC$1 = RIC;
|
|
9
9
|
|
|
10
10
|
function expireReducer(state, action) {
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@data-client/normalizr")):"function"==typeof define&&define.amd?define(["exports","@data-client/normalizr"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).RDC=e.RDC||{},e.RDC.Core={}),e.normalizr)}(this,(function(e,t){"use strict";var s="function"==typeof requestIdleCallback?requestIdleCallback:e=>setTimeout(e,0);const i="rdc/fetch",n="rdc/set",r="rdc/optimistic",a="rdc/reset",o="rdc/subscribe",c="rdc/unsubscribe",l="rdc/invalidate",h="rdc/invalidateall",d="rdc/expireall",u="rdc/gc";var p=Object.freeze({__proto__:null,FETCH_TYPE:i,SET_TYPE:n,OPTIMISTIC_TYPE:r,RESET_TYPE:a,SUBSCRIBE_TYPE:o,UNSUBSCRIBE_TYPE:c,INVALIDATE_TYPE:l,INVALIDATEALL_TYPE:h,EXPIREALL_TYPE:d,GC_TYPE:u});function f(e,t){let s;return t.endpoint.getOptimisticResponse&&t.endpoint.sideEffect?(s=function(e,{args:t,fetchedAt:s}){var i;const n=null!=(i=e.dataExpiryLength)?i:6e4,a=Date.now(),o={args:t,fetchedAt:s,date:a,expiresAt:a+n,key:e.key(...t)};return{type:r,endpoint:e,meta:o}}(t.endpoint,{args:t.meta.args,fetchedAt:t.meta.createdAt}),Object.assign({},e,{optimistic:[...e.optimistic,s]})):e}class m extends Error{}function y(e,t,s){return"AbortError"===s.name?Object.assign({},e,{optimistic:g(e,t)}):Object.assign({},e,{meta:Object.assign({},e.meta,{[t.meta.key]:{date:t.meta.date,error:s,expiresAt:t.meta.expiresAt,errorPolicy:null==t.endpoint.errorPolicy?void 0:t.endpoint.errorPolicy(s)}}),optimistic:g(e,t)})}function g(e,t){return e.optimistic.filter((e=>e.meta.key!==t.meta.key||(e.type===r?e.meta.fetchedAt!==t.meta.fetchedAt:e.meta.date>t.meta.date)))}function v(e){return function(s,o){switch(s||(s=E),o.type){case u:return o.entities.forEach((([e,t])=>{var i,n;null==(i=s.entities[e])||delete i[t],null==(n=s.entityMeta[e])||delete n[t]})),o.endpoints.forEach((e=>{delete s.endpoints[e],delete s.meta[e]})),s;case i:return f(s,o);case r:case n:return function(e,s,i){if(s.error)return y(e,s,s.payload);try{var n;let a;if(s.type===r){if(!s.endpoint.getOptimisticResponse)return e;try{a=s.endpoint.getOptimisticResponse.call(s.endpoint,i.snapshot(e,s.meta.fetchedAt),...s.meta.args)}catch(t){if(t.constructor===m)return e;throw t}}else a=s.payload;const{result:o,entities:c,indexes:l,entityMeta:h}=t.normalize(a,s.endpoint.schema,s.meta.args,e.entities,e.indexes,e.entityMeta,s.meta),d=Object.assign({},e.endpoints,{[s.meta.key]:o});try{if(s.endpoint.update){const e=s.endpoint.update(o,...s.meta.args);Object.keys(e).forEach((t=>{d[t]=e[t](d[t])}))}}catch(e){console.error(`The following error occured during Endpoint.update() for ${s.meta.key}`),console.error(e)}return{entities:c,indexes:l,endpoints:d,entityMeta:h,meta:Object.assign({},e.meta,{[s.meta.key]:{date:s.meta.date,expiresAt:s.meta.expiresAt,prevExpiresAt:null==(n=e.meta[s.meta.key])?void 0:n.expiresAt}}),optimistic:g(e,s),lastReset:e.lastReset}}catch(t){return"object"==typeof t&&(t.message=`Error processing ${s.meta.key}\n\nFull Schema: ${JSON.stringify(s.endpoint.schema,void 0,2)}\n\nError:\n${t.message}`,"payload"in s&&(t.payload=s.payload),t.status=400),y(e,s,t)}}(s,o,e);case h:case l:return function(e,t){const s=Object.assign({},e.endpoints),i=Object.assign({},e.meta),n=e=>{delete s[e];const t=Object.assign({},i[e],{expiresAt:0,invalidated:!0});delete t.error,i[e]=t};return t.type===l?n(t.meta.key):Object.keys(s).forEach((e=>{t.testKey(e)&&n(e)})),Object.assign({},e,{endpoints:s,meta:i})}(s,o);case d:return function(e,t){const s=Object.assign({},e.meta);return Object.keys(s).forEach((e=>{t.testKey(e)&&(s[e]=Object.assign({},s[e],{expiresAt:1}))})),Object.assign({},e,{meta:s})}(s,o);case a:return Object.assign({},E,{lastReset:o.date});default:return s}}}const E={entities:{},indexes:{},endpoints:{},meta:{},entityMeta:{},optimistic:[],lastReset:0};var b=Object.freeze({__proto__:null,MemoCache:t.MemoCache,INVALID:t.INVALID,RIC:s,initialState:E});function L(e,{args:t}){const s=e.key(...t);let n=0,r=0;const a=new Promise(((e,t)=>{[n,r]=[e,t]})),o={args:t,key:s,throttle:!e.sideEffect,resolve:n,reject:r,promise:a,createdAt:Date.now(),nm:!1};return{type:i,payload:()=>e(...t),meta:o,endpoint:e}}var O="undefined"!=typeof FormData?e=>e instanceof FormData?Object.fromEntries(e.entries()):e:e=>e;function I(e,{args:t,fetchedAt:s,response:i,error:r=!1}){var a,o;const c=r?null!=(a=e.errorExpiryLength)?a:1e3:null!=(o=e.dataExpiryLength)?o:6e4,l=Date.now(),h={args:t.map(O),fetchedAt:null!=s?s:l,date:l,expiresAt:l+c,key:e.key(...t)},d={type:n,payload:i,endpoint:e,meta:h};return r&&(d.error=!0),d}function S(e,t){return e.meta[t]}const w=e=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},A=()=>E;class x{constructor({dispatch:e=w,getState:s=A,memo:i=new t.MemoCache}={}){this.fetch=(e,...s)=>{const i=L(e,{args:s});return this.dispatch(i),e.schema?i.meta.promise.then((i=>t.denormalize(i,e.schema,{},s))):i.meta.promise},this.fetchIfStale=(e,...s)=>{const{data:i,expiresAt:n,expiryStatus:r}=this.getResponse(e,...s,this.getState());return r!==t.ExpiryStatus.Invalid&&Date.now()<=n?i:this.fetch(e,...s)},this.invalidate=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:l,meta:{key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.invalidateAll=e=>this.dispatch({type:h,testKey:t=>e.testKey(t)}),this.expireAll=e=>this.dispatch({type:d,testKey:t=>e.testKey(t)}),this.resetEntireStore=()=>this.dispatch({type:a,date:Date.now()}),this.setResponse=(e,...t)=>{const s=t[t.length-1],i=I(e,{args:t.slice(0,t.length-1),response:s});return this.dispatch(i)},this.setError=(e,...t)=>{const s=t[t.length-1],i=I(e,{args:t.slice(0,t.length-1),response:s,error:!0});return this.dispatch(i)},this.resolve=(e,t)=>this.dispatch(I(e,t)),this.subscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:o,endpoint:e,meta:{args:t,key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.unsubscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:c,endpoint:e,meta:{args:t,key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.snapshot=(e,t)=>new j(this,e,t),this.getError=(e,...t)=>{if(null===t[0])return;const s=t[t.length-1],i=t.slice(0,t.length-1),n=e.key(...i),r=S(s,n);return void 0===s.endpoints[n]||"soft"!==(null==r?void 0:r.errorPolicy)?null==r?void 0:r.error:void 0},this.dispatch=e,this.getState=s,this.memo=i}getResponse(e,...s){const i=s[s.length-1],n=s.slice(0,s.length-1).map(O),r=1!==n.length||null!==n[0],a=r?e.key(...n):"",o=r?i.endpoints[a]:void 0,c=e.schema,l=S(i,a);let h=null==l?void 0:l.expiresAt;const d=void 0===o&&void 0!==c,u=d?this.memo.buildQueryKey(a,c,n,i.entities,i.indexes):o;if(!r)return{data:u,expiryStatus:t.ExpiryStatus.Valid,expiresAt:1/0};let p=!1;if(d)p=!t.validateQueryKey(u);else if(!c||!k(c))return{data:o,expiryStatus:null!=l&&l.invalidated?t.ExpiryStatus.Invalid:o&&!e.invalidIfStale?t.ExpiryStatus.Valid:t.ExpiryStatus.InvalidIfStale,expiresAt:h||0};const{data:f,paths:m}=this.memo.denormalize(u,c,i.entities,n);return!h&&p&&(h=1),this.getSchemaResponse(f,m,i.entityMeta,h,e.invalidIfStale||p,l)}get(e,...t){const s=t[t.length-1],i=t.slice(0,t.length-1).map(O),n=JSON.stringify(i);return this.memo.query(n,e,i,s.entities,s.indexes)}getSchemaResponse(e,s,i,n,r,a={}){const o="symbol"==typeof e;n||(n=function(e,t){let s=1/0;for(const{pk:n,key:r}of e){var i;const e=null==(i=t[r])||null==(i=i[n])?void 0:i.expiresAt;e<s&&(s=e)}return s}(s,i));return{data:e,expiryStatus:null!=a&&a.invalidated||o&&(null==a||!a.error)?t.ExpiryStatus.Invalid:o||r?t.ExpiryStatus.InvalidIfStale:t.ExpiryStatus.Valid,expiresAt:n}}}function k(e){if(t.isEntity(e))return!0;if(Array.isArray(e))return 0!==e.length&&k(e[0]);if(e&&("object"==typeof e||"function"==typeof e)){const t="schema"in e?e.schema:e;return"function"==typeof t?k(t):Object.values(t).some((e=>k(e)))}return!1}class j{constructor(e,t,s=0){this.state=void 0,this.controller=void 0,this.fetchedAt=void 0,this.abort=new m,this.getError=(e,...t)=>this.controller.getError(e,...t,this.state),this.state=t,this.controller=e,this.fetchedAt=s}getResponse(e,...t){return this.controller.getResponse(e,...t,this.state)}get(e,...t){return this.controller.get(e,...t,this.state)}}class T extends Error{constructor(){super("Aborted due to RESET"),this.name="ResetError"}}class R{isOnline(){return void 0===navigator.onLine||navigator.onLine}addOnlineListener(e){addEventListener("online",e)}removeOnlineListener(e){removeEventListener("online",e)}addOfflineListener(e){addEventListener("offline",e)}removeOfflineListener(e){removeEventListener("offline",e)}}class _{isOnline(){return!0}addOnlineListener(){}removeOnlineListener(){}addOfflineListener(){}removeOfflineListener(){}}let q;q="undefined"!=typeof navigator&&"function"==typeof addEventListener?R:_;var P=q;let D={};Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Object.defineProperty(e,"ExpiryStatus",{enumerable:!0,get:function(){return t.ExpiryStatus}}),e.Controller=x,e.DefaultConnectionListener=P,e.DevToolsManager=class{constructor(e,t){this.started=!1,this.actions=[],this.maxBufferLength=100,this.devTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__.connect(Object.assign({},D,{config:e})),this.devTools?this.middleware=e=>{this.controller=e;const s=v(e);let i=e.getState();return n=>r=>{const a=n(r);return i=this.started?s(i,r):e.getState(),a.then((()=>{null!=t&&t(r)||this.handleAction(r,i.optimistic.reduce(s,i))})),a}}:this.middleware=()=>e=>t=>e(t)}handleAction(e,t){this.started?this.devTools.send(e,t,void 0,"RDC"):(this.actions.length>this.maxBufferLength&&(this.actions=this.actions.slice(this.maxBufferLength/2)),this.actions.push([e,t]))}init(e){this.devTools&&this.devTools.init(e)}cleanup(){}getMiddleware(){return this.middleware}},e.LogoutManager=class{constructor({handleLogout:e,shouldLogout:t}={}){e&&(this.handleLogout=e),t&&(this.shouldLogout=t),this.middleware=e=>t=>async s=>{await t(s),s.type===n&&s.error&&this.shouldLogout(s.payload)&&this.handleLogout(e)}}cleanup(){}getMiddleware(){return this.middleware}shouldLogout(e){return 401===e.status}handleLogout(e){e.resetEntireStore()}},e.NetworkManager=class{constructor(e=6e4,t=1e3){this.fetched=Object.create(null),this.resolvers={},this.rejectors={},this.fetchedAt={},this.controller=new x,this.dataExpiryLength=e,this.errorExpiryLength=t,this.middleware=e=>(this.controller=e,t=>s=>{switch(s.type){case i:return this.handleFetch(s),void 0!==s.endpoint.getOptimisticResponse&&s.endpoint.sideEffect?t(s):Promise.resolve();case n:return t(s).then((()=>{if(s.meta.key in this.fetched){var t;const i=null==(t=e.getState().meta[s.meta.key])?void 0:t.error;i?this.handleSet(I(s.endpoint,{args:s.meta.args,response:i,fetchedAt:s.meta.fetchedAt,error:!0})):this.handleSet(s)}}));case a:{const e=Object.assign({},this.rejectors);return this.clearAll(),t(s).then((()=>{for(const t in e)e[t](new T)}))}default:return t(s)}})}skipLogging(e){return e.type===i&&e.meta.key in this.fetched}init(){delete this.cleanupDate}cleanup(){this.cleanupDate=Date.now()}allSettled(){const e=Object.values(this.fetched);if(e.length)return Promise.allSettled(e)}clearAll(){for(const e in this.rejectors)this.clear(e)}clear(e){this.fetched[e].catch((()=>{})),delete this.resolvers[e],delete this.rejectors[e],delete this.fetched[e],delete this.fetchedAt[e]}getLastReset(){return this.cleanupDate?this.cleanupDate:this.controller.getState().lastReset}handleFetch(e){const t=e.payload,{key:s,throttle:i,resolve:n,reject:r,createdAt:a}=e.meta,o=()=>{let s=t();return i||(s=(e=>e.then((e=>(n(e),e))).catch((e=>{throw r(e),e})))(s)),s=s.then((t=>{let s=this.getLastReset();return a>=s&&this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:a}),t})).catch((t=>{const s=this.getLastReset();throw a>=s&&this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:a,error:!0}),t})),s};return i?this.throttle(s,o,a).then((e=>n(e))).catch((e=>r(e))):o().catch((()=>{}))}handleSet(e){if(e.meta.key in this.fetched){let t;t=e.error?this.rejectors[e.meta.key]:this.resolvers[e.meta.key],t(e.payload),this.clear(e.meta.key)}}getMiddleware(){return this.middleware}throttle(e,t,i){const n=this.getLastReset();return e in this.fetched&&this.fetchedAt[e]>n||(this.fetched[e]=new Promise(((t,s)=>{this.resolvers[e]=t,this.rejectors[e]=s})),this.fetchedAt[e]=i,s((()=>{t().catch((()=>null))}),{timeout:500})),this.fetched[e]}},e.PollingSubscription=class{constructor(e,t,s){if(this.frequencyHistogram=new Map,this.offlineListener=()=>{this.cleanup(),this.connectionListener.addOnlineListener(this.onlineListener)},this.onlineListener=()=>{this.connectionListener.removeOnlineListener(this.onlineListener);const e=Date.now();this.startId=setTimeout((()=>{this.startId&&(delete this.startId,this.update(),this.run())}),Math.max(0,this.lastFetchTime()-e+this.frequency)),this.connectionListener.addOfflineListener(this.offlineListener)},void 0===e.endpoint.pollFrequency)throw new Error("frequency needed for polling subscription");this.endpoint=e.endpoint,this.frequency=e.endpoint.pollFrequency,this.args=e.meta.args,this.key=e.meta.key,this.frequencyHistogram.set(this.frequency,1),this.controller=t,this.connectionListener=s||new P,this.connectionListener.isOnline()?this.onlineListener():this.offlineListener()}add(e){void 0!==e&&(this.frequencyHistogram.has(e)?this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)+1):(this.frequencyHistogram.set(e,1),e<this.frequency&&(this.frequency=e,this.run())))}remove(e){if(void 0===e)return!1;if(this.frequencyHistogram.has(e)&&(this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)-1),this.frequencyHistogram.get(e)<1)){if(this.frequencyHistogram.delete(e),0===this.frequencyHistogram.size)return this.cleanup(),!0;e<=this.frequency&&(this.frequency=Math.min(...this.frequencyHistogram.keys()),this.run())}return!1}cleanup(){this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId),this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.startId&&(clearTimeout(this.startId),delete this.startId),this.connectionListener.removeOnlineListener(this.onlineListener),this.connectionListener.removeOfflineListener(this.offlineListener)}update(){const e=this.endpoint,t=function(...t){return e.call(this,...t)};Object.assign(t,this.endpoint),t.dataExpiryLength=this.frequency/2,t.errorExpiryLength=this.frequency/10,t.errorPolicy=()=>"soft",t.key=()=>this.key,this.controller.fetch(t,...this.args).catch((()=>null))}run(){this.startId||(this.intervalId&&(this.lastIntervalId=this.intervalId),this.intervalId=setInterval((()=>{this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.intervalId&&this.update()}),this.frequency))}lastFetchTime(){var e,t;return null!=(e=null==(t=this.controller.getState().meta[this.key])?void 0:t.date)?e:0}},e.ResetError=T,e.SubscriptionManager=class{constructor(e){this.subscriptions={},this.controller=new x,this.Subscription=e,this.middleware=e=>(this.controller=e,e=>t=>{switch(t.type){case o:try{this.handleSubscribe(t)}catch(e){console.error(e)}return Promise.resolve();case c:return this.handleUnsubscribe(t),Promise.resolve();default:return e(t)}})}cleanup(){for(const e in this.subscriptions)this.subscriptions[e].cleanup()}handleSubscribe(e){const t=e.meta.key;if(t in this.subscriptions){const s=e.endpoint.pollFrequency;this.subscriptions[t].add(s)}else this.subscriptions[t]=new this.Subscription(e,this.controller)}handleUnsubscribe(e){const t=e.meta.key;if(t in this.subscriptions){const s=e.endpoint.pollFrequency;this.subscriptions[t].remove(s)&&delete this.subscriptions[t]}}getMiddleware(){return this.middleware}},e.__INTERNAL__=b,e.actionTypes=p,e.applyManager=function(e,t){return e.map((e=>{const s=e.getMiddleware();return({dispatch:e,getState:i})=>(t.dispatch=e,t.getState=i,s(t))}))},e.createFetch=L,e.createReducer=v,e.createSet=I,e.initialState=E,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@data-client/normalizr")):"function"==typeof define&&define.amd?define(["exports","@data-client/normalizr"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).RDC=e.RDC||{},e.RDC.Core={}),e.normalizr)}(this,(function(e,t){"use strict";var s="function"==typeof requestIdleCallback?requestIdleCallback:e=>e();const i="rdc/fetch",n="rdc/set",r="rdc/optimistic",a="rdc/reset",o="rdc/subscribe",c="rdc/unsubscribe",l="rdc/invalidate",h="rdc/invalidateall",d="rdc/expireall",u="rdc/gc";var p=Object.freeze({__proto__:null,FETCH_TYPE:i,SET_TYPE:n,OPTIMISTIC_TYPE:r,RESET_TYPE:a,SUBSCRIBE_TYPE:o,UNSUBSCRIBE_TYPE:c,INVALIDATE_TYPE:l,INVALIDATEALL_TYPE:h,EXPIREALL_TYPE:d,GC_TYPE:u});function f(e,t){let s;return t.endpoint.getOptimisticResponse&&t.endpoint.sideEffect?(s=function(e,{args:t,fetchedAt:s}){var i;const n=null!=(i=e.dataExpiryLength)?i:6e4,a=Date.now(),o={args:t,fetchedAt:s,date:a,expiresAt:a+n,key:e.key(...t)};return{type:r,endpoint:e,meta:o}}(t.endpoint,{args:t.meta.args,fetchedAt:t.meta.createdAt}),Object.assign({},e,{optimistic:[...e.optimistic,s]})):e}class m extends Error{}function y(e,t,s){return"AbortError"===s.name?Object.assign({},e,{optimistic:g(e,t)}):Object.assign({},e,{meta:Object.assign({},e.meta,{[t.meta.key]:{date:t.meta.date,error:s,expiresAt:t.meta.expiresAt,errorPolicy:null==t.endpoint.errorPolicy?void 0:t.endpoint.errorPolicy(s)}}),optimistic:g(e,t)})}function g(e,t){return e.optimistic.filter((e=>e.meta.key!==t.meta.key||(e.type===r?e.meta.fetchedAt!==t.meta.fetchedAt:e.meta.date>t.meta.date)))}function v(e){return function(s,o){switch(s||(s=E),o.type){case u:return o.entities.forEach((([e,t])=>{var i,n;null==(i=s.entities[e])||delete i[t],null==(n=s.entityMeta[e])||delete n[t]})),o.endpoints.forEach((e=>{delete s.endpoints[e],delete s.meta[e]})),s;case i:return f(s,o);case r:case n:return function(e,s,i){if(s.error)return y(e,s,s.payload);try{var n;let a;if(s.type===r){if(!s.endpoint.getOptimisticResponse)return e;try{a=s.endpoint.getOptimisticResponse.call(s.endpoint,i.snapshot(e,s.meta.fetchedAt),...s.meta.args)}catch(t){if(t.constructor===m)return e;throw t}}else a=s.payload;const{result:o,entities:c,indexes:l,entityMeta:h}=t.normalize(a,s.endpoint.schema,s.meta.args,e.entities,e.indexes,e.entityMeta,s.meta),d=Object.assign({},e.endpoints,{[s.meta.key]:o});try{if(s.endpoint.update){const e=s.endpoint.update(o,...s.meta.args);Object.keys(e).forEach((t=>{d[t]=e[t](d[t])}))}}catch(e){console.error(`The following error occured during Endpoint.update() for ${s.meta.key}`),console.error(e)}return{entities:c,indexes:l,endpoints:d,entityMeta:h,meta:Object.assign({},e.meta,{[s.meta.key]:{date:s.meta.date,expiresAt:s.meta.expiresAt,prevExpiresAt:null==(n=e.meta[s.meta.key])?void 0:n.expiresAt}}),optimistic:g(e,s),lastReset:e.lastReset}}catch(t){return"object"==typeof t&&(t.message=`Error processing ${s.meta.key}\n\nFull Schema: ${JSON.stringify(s.endpoint.schema,void 0,2)}\n\nError:\n${t.message}`,"payload"in s&&(t.payload=s.payload),t.status=400),y(e,s,t)}}(s,o,e);case h:case l:return function(e,t){const s=Object.assign({},e.endpoints),i=Object.assign({},e.meta),n=e=>{delete s[e];const t=Object.assign({},i[e],{expiresAt:0,invalidated:!0});delete t.error,i[e]=t};return t.type===l?n(t.meta.key):Object.keys(s).forEach((e=>{t.testKey(e)&&n(e)})),Object.assign({},e,{endpoints:s,meta:i})}(s,o);case d:return function(e,t){const s=Object.assign({},e.meta);return Object.keys(s).forEach((e=>{t.testKey(e)&&(s[e]=Object.assign({},s[e],{expiresAt:1}))})),Object.assign({},e,{meta:s})}(s,o);case a:return Object.assign({},E,{lastReset:o.date});default:return s}}}const E={entities:{},indexes:{},endpoints:{},meta:{},entityMeta:{},optimistic:[],lastReset:0};var b=Object.freeze({__proto__:null,MemoCache:t.MemoCache,INVALID:t.INVALID,RIC:s,initialState:E});function L(e,{args:t}){const s=e.key(...t);let n=0,r=0;const a=new Promise(((e,t)=>{[n,r]=[e,t]})),o={args:t,key:s,throttle:!e.sideEffect,resolve:n,reject:r,promise:a,createdAt:Date.now(),nm:!1};return{type:i,payload:()=>e(...t),meta:o,endpoint:e}}var O="undefined"!=typeof FormData?e=>e instanceof FormData?Object.fromEntries(e.entries()):e:e=>e;function I(e,{args:t,fetchedAt:s,response:i,error:r=!1}){var a,o;const c=r?null!=(a=e.errorExpiryLength)?a:1e3:null!=(o=e.dataExpiryLength)?o:6e4,l=Date.now(),h={args:t.map(O),fetchedAt:null!=s?s:l,date:l,expiresAt:l+c,key:e.key(...t)},d={type:n,payload:i,endpoint:e,meta:h};return r&&(d.error=!0),d}function S(e,t){return e.meta[t]}const w=e=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},A=()=>E;class x{constructor({dispatch:e=w,getState:s=A,memo:i=new t.MemoCache}={}){this.fetch=(e,...s)=>{const i=L(e,{args:s});return this.dispatch(i),e.schema?i.meta.promise.then((i=>t.denormalize(i,e.schema,{},s))):i.meta.promise},this.fetchIfStale=(e,...s)=>{const{data:i,expiresAt:n,expiryStatus:r}=this.getResponse(e,...s,this.getState());return r!==t.ExpiryStatus.Invalid&&Date.now()<=n?i:this.fetch(e,...s)},this.invalidate=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:l,meta:{key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.invalidateAll=e=>this.dispatch({type:h,testKey:t=>e.testKey(t)}),this.expireAll=e=>this.dispatch({type:d,testKey:t=>e.testKey(t)}),this.resetEntireStore=()=>this.dispatch({type:a,date:Date.now()}),this.setResponse=(e,...t)=>{const s=t[t.length-1],i=I(e,{args:t.slice(0,t.length-1),response:s});return this.dispatch(i)},this.setError=(e,...t)=>{const s=t[t.length-1],i=I(e,{args:t.slice(0,t.length-1),response:s,error:!0});return this.dispatch(i)},this.resolve=(e,t)=>this.dispatch(I(e,t)),this.subscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:o,endpoint:e,meta:{args:t,key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.unsubscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:c,endpoint:e,meta:{args:t,key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.snapshot=(e,t)=>new j(this,e,t),this.getError=(e,...t)=>{if(null===t[0])return;const s=t[t.length-1],i=t.slice(0,t.length-1),n=e.key(...i),r=S(s,n);return void 0===s.endpoints[n]||"soft"!==(null==r?void 0:r.errorPolicy)?null==r?void 0:r.error:void 0},this.dispatch=e,this.getState=s,this.memo=i}getResponse(e,...s){const i=s[s.length-1],n=s.slice(0,s.length-1).map(O),r=1!==n.length||null!==n[0],a=r?e.key(...n):"",o=r?i.endpoints[a]:void 0,c=e.schema,l=S(i,a);let h=null==l?void 0:l.expiresAt;const d=void 0===o&&void 0!==c,u=d?this.memo.buildQueryKey(a,c,n,i.entities,i.indexes):o;if(!r)return{data:u,expiryStatus:t.ExpiryStatus.Valid,expiresAt:1/0};let p=!1;if(d)p=!t.validateQueryKey(u);else if(!c||!k(c))return{data:o,expiryStatus:null!=l&&l.invalidated?t.ExpiryStatus.Invalid:o&&!e.invalidIfStale?t.ExpiryStatus.Valid:t.ExpiryStatus.InvalidIfStale,expiresAt:h||0};const{data:f,paths:m}=this.memo.denormalize(u,c,i.entities,n);return!h&&p&&(h=1),this.getSchemaResponse(f,m,i.entityMeta,h,e.invalidIfStale||p,l)}get(e,...t){const s=t[t.length-1],i=t.slice(0,t.length-1).map(O),n=JSON.stringify(i);return this.memo.query(n,e,i,s.entities,s.indexes)}getSchemaResponse(e,s,i,n,r,a={}){const o="symbol"==typeof e;n||(n=function(e,t){let s=1/0;for(const{pk:n,key:r}of e){var i;const e=null==(i=t[r])||null==(i=i[n])?void 0:i.expiresAt;e<s&&(s=e)}return s}(s,i));return{data:e,expiryStatus:null!=a&&a.invalidated||o&&(null==a||!a.error)?t.ExpiryStatus.Invalid:o||r?t.ExpiryStatus.InvalidIfStale:t.ExpiryStatus.Valid,expiresAt:n}}}function k(e){if(t.isEntity(e))return!0;if(Array.isArray(e))return 0!==e.length&&k(e[0]);if(e&&("object"==typeof e||"function"==typeof e)){const t="schema"in e?e.schema:e;return"function"==typeof t?k(t):Object.values(t).some((e=>k(e)))}return!1}class j{constructor(e,t,s=0){this.state=void 0,this.controller=void 0,this.fetchedAt=void 0,this.abort=new m,this.getError=(e,...t)=>this.controller.getError(e,...t,this.state),this.state=t,this.controller=e,this.fetchedAt=s}getResponse(e,...t){return this.controller.getResponse(e,...t,this.state)}get(e,...t){return this.controller.get(e,...t,this.state)}}class T extends Error{constructor(){super("Aborted due to RESET"),this.name="ResetError"}}class R{isOnline(){return void 0===navigator.onLine||navigator.onLine}addOnlineListener(e){addEventListener("online",e)}removeOnlineListener(e){removeEventListener("online",e)}addOfflineListener(e){addEventListener("offline",e)}removeOfflineListener(e){removeEventListener("offline",e)}}class _{isOnline(){return!0}addOnlineListener(){}removeOnlineListener(){}addOfflineListener(){}removeOfflineListener(){}}let q;q="undefined"!=typeof navigator&&"function"==typeof addEventListener?R:_;var P=q;let D={};Object.hasOwn=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Object.defineProperty(e,"ExpiryStatus",{enumerable:!0,get:function(){return t.ExpiryStatus}}),e.Controller=x,e.DefaultConnectionListener=P,e.DevToolsManager=class{constructor(e,t){this.started=!1,this.actions=[],this.maxBufferLength=100,this.devTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__.connect(Object.assign({},D,{config:e})),this.devTools?this.middleware=e=>{this.controller=e;const s=v(e);let i=e.getState();return n=>r=>{const a=n(r);return i=this.started?s(i,r):e.getState(),a.then((()=>{null!=t&&t(r)||this.handleAction(r,i.optimistic.reduce(s,i))})),a}}:this.middleware=()=>e=>t=>e(t)}handleAction(e,t){this.started?this.devTools.send(e,t,void 0,"RDC"):(this.actions.length>this.maxBufferLength&&(this.actions=this.actions.slice(this.maxBufferLength/2)),this.actions.push([e,t]))}init(e){this.devTools&&this.devTools.init(e)}cleanup(){}getMiddleware(){return this.middleware}},e.LogoutManager=class{constructor({handleLogout:e,shouldLogout:t}={}){e&&(this.handleLogout=e),t&&(this.shouldLogout=t),this.middleware=e=>t=>async s=>{await t(s),s.type===n&&s.error&&this.shouldLogout(s.payload)&&this.handleLogout(e)}}cleanup(){}getMiddleware(){return this.middleware}shouldLogout(e){return 401===e.status}handleLogout(e){e.resetEntireStore()}},e.NetworkManager=class{constructor(e=6e4,t=1e3){this.fetched=Object.create(null),this.resolvers={},this.rejectors={},this.fetchedAt={},this.controller=new x,this.dataExpiryLength=e,this.errorExpiryLength=t,this.middleware=e=>(this.controller=e,t=>s=>{switch(s.type){case i:return this.handleFetch(s),void 0!==s.endpoint.getOptimisticResponse&&s.endpoint.sideEffect?t(s):Promise.resolve();case n:return t(s).then((()=>{if(s.meta.key in this.fetched){var t;const i=null==(t=e.getState().meta[s.meta.key])?void 0:t.error;i?this.handleSet(I(s.endpoint,{args:s.meta.args,response:i,fetchedAt:s.meta.fetchedAt,error:!0})):this.handleSet(s)}}));case a:{const e=Object.assign({},this.rejectors);return this.clearAll(),t(s).then((()=>{for(const t in e)e[t](new T)}))}default:return t(s)}})}skipLogging(e){return e.type===i&&e.meta.key in this.fetched}init(){delete this.cleanupDate}cleanup(){this.cleanupDate=Date.now()}allSettled(){const e=Object.values(this.fetched);if(e.length)return Promise.allSettled(e)}clearAll(){for(const e in this.rejectors)this.clear(e)}clear(e){this.fetched[e].catch((()=>{})),delete this.resolvers[e],delete this.rejectors[e],delete this.fetched[e],delete this.fetchedAt[e]}getLastReset(){return this.cleanupDate?this.cleanupDate:this.controller.getState().lastReset}handleFetch(e){const t=e.payload,{key:s,throttle:i,resolve:n,reject:r,createdAt:a}=e.meta,o=()=>{let s=t();return i||(s=(e=>e.then((e=>(n(e),e))).catch((e=>{throw r(e),e})))(s)),s=s.then((t=>{let s=this.getLastReset();return a>=s&&this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:a}),t})).catch((t=>{const s=this.getLastReset();throw a>=s&&this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:a,error:!0}),t})),s};return i?this.throttle(s,o,a).then((e=>n(e))).catch((e=>r(e))):o().catch((()=>{}))}handleSet(e){if(e.meta.key in this.fetched){let t;t=e.error?this.rejectors[e.meta.key]:this.resolvers[e.meta.key],t(e.payload),this.clear(e.meta.key)}}getMiddleware(){return this.middleware}throttle(e,t,i){const n=this.getLastReset();return e in this.fetched&&this.fetchedAt[e]>n||(this.fetched[e]=new Promise(((t,s)=>{this.resolvers[e]=t,this.rejectors[e]=s})),this.fetchedAt[e]=i,s((()=>{t().catch((()=>null))}),{timeout:500})),this.fetched[e]}},e.PollingSubscription=class{constructor(e,t,s){if(this.frequencyHistogram=new Map,this.offlineListener=()=>{this.cleanup(),this.connectionListener.addOnlineListener(this.onlineListener)},this.onlineListener=()=>{this.connectionListener.removeOnlineListener(this.onlineListener);const e=Date.now();this.startId=setTimeout((()=>{this.startId&&(delete this.startId,this.update(),this.run())}),Math.max(0,this.lastFetchTime()-e+this.frequency)),this.connectionListener.addOfflineListener(this.offlineListener)},void 0===e.endpoint.pollFrequency)throw new Error("frequency needed for polling subscription");this.endpoint=e.endpoint,this.frequency=e.endpoint.pollFrequency,this.args=e.meta.args,this.key=e.meta.key,this.frequencyHistogram.set(this.frequency,1),this.controller=t,this.connectionListener=s||new P,this.connectionListener.isOnline()?this.onlineListener():this.offlineListener()}add(e){void 0!==e&&(this.frequencyHistogram.has(e)?this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)+1):(this.frequencyHistogram.set(e,1),e<this.frequency&&(this.frequency=e,this.run())))}remove(e){if(void 0===e)return!1;if(this.frequencyHistogram.has(e)&&(this.frequencyHistogram.set(e,this.frequencyHistogram.get(e)-1),this.frequencyHistogram.get(e)<1)){if(this.frequencyHistogram.delete(e),0===this.frequencyHistogram.size)return this.cleanup(),!0;e<=this.frequency&&(this.frequency=Math.min(...this.frequencyHistogram.keys()),this.run())}return!1}cleanup(){this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId),this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.startId&&(clearTimeout(this.startId),delete this.startId),this.connectionListener.removeOnlineListener(this.onlineListener),this.connectionListener.removeOfflineListener(this.offlineListener)}update(){const e=this.endpoint,t=function(...t){return e.call(this,...t)};Object.assign(t,this.endpoint),t.dataExpiryLength=this.frequency/2,t.errorExpiryLength=this.frequency/10,t.errorPolicy=()=>"soft",t.key=()=>this.key,this.controller.fetch(t,...this.args).catch((()=>null))}run(){this.startId||(this.intervalId&&(this.lastIntervalId=this.intervalId),this.intervalId=setInterval((()=>{this.lastIntervalId&&(clearInterval(this.lastIntervalId),delete this.lastIntervalId),this.intervalId&&this.update()}),this.frequency))}lastFetchTime(){var e,t;return null!=(e=null==(t=this.controller.getState().meta[this.key])?void 0:t.date)?e:0}},e.ResetError=T,e.SubscriptionManager=class{constructor(e){this.subscriptions={},this.controller=new x,this.Subscription=e,this.middleware=e=>(this.controller=e,e=>t=>{switch(t.type){case o:try{this.handleSubscribe(t)}catch(e){console.error(e)}return Promise.resolve();case c:return this.handleUnsubscribe(t),Promise.resolve();default:return e(t)}})}cleanup(){for(const e in this.subscriptions)this.subscriptions[e].cleanup()}handleSubscribe(e){const t=e.meta.key;if(t in this.subscriptions){const s=e.endpoint.pollFrequency;this.subscriptions[t].add(s)}else this.subscriptions[t]=new this.Subscription(e,this.controller)}handleUnsubscribe(e){const t=e.meta.key;if(t in this.subscriptions){const s=e.endpoint.pollFrequency;this.subscriptions[t].remove(s)&&delete this.subscriptions[t]}}getMiddleware(){return this.middleware}},e.__INTERNAL__=b,e.actionTypes=p,e.applyManager=function(e,t){return e.map((e=>{const s=e.getMiddleware();return({dispatch:e,getState:i})=>(t.dispatch=e,t.getState=i,s(t))}))},e.createFetch=L,e.createReducer=v,e.createSet=I,e.initialState=E,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/legacy/index.js
CHANGED
|
@@ -16,4 +16,4 @@ export { _actionTypes as actionTypes };
|
|
|
16
16
|
/* istanbul ignore next */
|
|
17
17
|
export * from './types.js';
|
|
18
18
|
export * from './manager/index.js';
|
|
19
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJPYmplY3QiLCJoYXNPd24iLCJpdCIsImtleSIsInByb3RvdHlwZSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsIl9JTlRFUk5BTF9fIiwiX19JTlRFUk5BTF9fIiwiRXhwaXJ5U3RhdHVzIiwiZGVmYXVsdCIsIk5ldHdvcmtNYW5hZ2VyIiwiUmVzZXRFcnJvciIsImNyZWF0ZVJlZHVjZXIiLCJpbml0aWFsU3RhdGUiLCJhcHBseU1hbmFnZXIiLCJDb250cm9sbGVyIiwiY3JlYXRlRmV0Y2giLCJjcmVhdGVTZXQiLCJfYWN0aW9uVHlwZXMiLCJhY3Rpb25UeXBlcyJdLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJPYmplY3QuaGFzT3duID1cbiAgT2JqZWN0Lmhhc093biB8fFxuICAvKiBpc3RhbmJ1bCBpZ25vcmUgbmV4dCAqLyBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkge1xuICAgIHJldHVybiBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoaXQsIGtleSk7XG4gIH07XG5cbmV4cG9ydCAqIGFzIF9fSU5URVJOQUxfXyBmcm9tICcuL2ludGVybmFsLmpzJztcbmV4cG9ydCB0eXBlIHtcbiAgTmV0d29ya0Vycm9yLFxuICBVbmtub3duRXJyb3IsXG4gIEVycm9yVHlwZXMsXG4gIFNjaGVtYSxcbiAgRW5kcG9pbnRJbnRlcmZhY2UsXG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BRWhFLGNBQWMsdUJBQXVCO0FBQUMsWUFBQUMsWUFBQSxNQUNULGtCQUFrQjtBQUFBLFNBQUFBLFlBQUEsSUFBbkNDLFdBQVc7QUFDdkI7QUFDQSxjQUFjLFlBQVk7QUFDMUIsY0FBYyxvQkFBb0IiLCJpZ25vcmVMaXN0IjpbXX0=
|
package/legacy/state/RIC.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb =>
|
|
1
|
+
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb => cb();
|
|
2
2
|
export default RIC;
|
|
3
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJSSUMiLCJyZXF1ZXN0SWRsZUNhbGxiYWNrIiwiY2IiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RhdGUvUklDLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImNvbnN0IFJJQzogKGNiOiAoLi4uYXJnczogYW55W10pID0+IHZvaWQsIG9wdGlvbnM6IGFueSkgPT4gdm9pZCA9IChcbiAgdHlwZW9mIHJlcXVlc3RJZGxlQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicgPyByZXF1ZXN0SWRsZUNhbGxiYWNrIDogKFxuICAgIChjYjogYW55KSA9PiBjYigpXG4gICkpIGFzIGFueTtcbmV4cG9ydCBkZWZhdWx0IFJJQztcbiJdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTUEsR0FBeUQsR0FDN0QsT0FBT0MsbUJBQW1CLEtBQUssVUFBVSxHQUFHQSxtQkFBbUIsR0FDNURDLEVBQU8sSUFBS0EsRUFBRSxDQUFDLENBQ1Q7QUFDWCxlQUFlRixHQUFHIiwiaWdub3JlTGlzdCI6W119
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as __INTERNAL__ from './internal.js';
|
|
2
|
-
export type { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, } from '@data-client/normalizr';
|
|
2
|
+
export type { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, NI, } from '@data-client/normalizr';
|
|
3
3
|
export { ExpiryStatus } from '@data-client/normalizr';
|
|
4
4
|
export { default as NetworkManager, ResetError, } from './manager/NetworkManager.js';
|
|
5
5
|
export { default as createReducer, initialState, } from './state/reducer/createReducer.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,EAAE,GACH,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,UAAU,GACX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EACV,kBAAkB,EAClB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEjE,cAAc,uBAAuB,CAAC;AACtC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -16,4 +16,4 @@ export { _actionTypes as actionTypes };
|
|
|
16
16
|
/* istanbul ignore next */
|
|
17
17
|
export * from './types.js';
|
|
18
18
|
export * from './manager/index.js';
|
|
19
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJPYmplY3QiLCJoYXNPd24iLCJpdCIsImtleSIsInByb3RvdHlwZSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsIl9JTlRFUk5BTF9fIiwiX19JTlRFUk5BTF9fIiwiRXhwaXJ5U3RhdHVzIiwiZGVmYXVsdCIsIk5ldHdvcmtNYW5hZ2VyIiwiUmVzZXRFcnJvciIsImNyZWF0ZVJlZHVjZXIiLCJpbml0aWFsU3RhdGUiLCJhcHBseU1hbmFnZXIiLCJDb250cm9sbGVyIiwiY3JlYXRlRmV0Y2giLCJjcmVhdGVTZXQiLCJfYWN0aW9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RELENBQUM7QUFBQyxZQUFBSSxXQUFBLE1BRTBCLGVBQWU7QUFBQSxTQUFBQSxXQUFBLElBQWpDQyxZQUFZO0FBbUJ4QixTQUFTQyxZQUFZLFFBQVEsd0JBQXdCO0FBQ3JELFNBQ0VDLE9BQU8sSUFBSUMsY0FBYyxFQUN6QkMsVUFBVSxRQUNMLDZCQUE2QjtBQUNwQyxTQUNFRixPQUFPLElBQUlHLGFBQWEsRUFDeEJDLFlBQVksUUFDUCxrQ0FBa0M7QUFDekMsU0FBU0osT0FBTyxJQUFJSyxZQUFZLFFBQVEsMkJBQTJCO0FBRW5FLFNBQVNMLE9BQU8sSUFBSU0sVUFBVSxRQUFRLDRCQUE0QjtBQUtsRSxTQUFTTixPQUFPLElBQUlPLFdBQVcsUUFBUSw2QkFBNkI7QUFDcEUsU0FBU1AsT0FBTyxJQUFJUSxTQUFTLFFBQVEsMkJBQTJCO0FBRWhFLGNBQWMsdUJBQXVCO0FBQUMsWUFBQUMsWUFBQSxNQUNULGtCQUFrQjtBQUFBLFNBQUFBLFlBQUEsSUFBbkNDLFdBQVc7QUFDdkI7QUFDQSxjQUFjLFlBQVk7QUFDMUIsY0FBYyxvQkFBb0IiLCJpZ25vcmVMaXN0IjpbXX0=
|
package/lib/state/RIC.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb =>
|
|
1
|
+
const RIC = typeof requestIdleCallback === 'function' ? requestIdleCallback : cb => cb();
|
|
2
2
|
export default RIC;
|
|
3
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJSSUMiLCJyZXF1ZXN0SWRsZUNhbGxiYWNrIiwiY2IiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RhdGUvUklDLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImNvbnN0IFJJQzogKGNiOiAoLi4uYXJnczogYW55W10pID0+IHZvaWQsIG9wdGlvbnM6IGFueSkgPT4gdm9pZCA9IChcbiAgdHlwZW9mIHJlcXVlc3RJZGxlQ2FsbGJhY2sgPT09ICdmdW5jdGlvbicgPyByZXF1ZXN0SWRsZUNhbGxiYWNrIDogKFxuICAgIChjYjogYW55KSA9PiBjYigpXG4gICkpIGFzIGFueTtcbmV4cG9ydCBkZWZhdWx0IFJJQztcbiJdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTUEsR0FBeUQsR0FDN0QsT0FBT0MsbUJBQW1CLEtBQUssVUFBVSxHQUFHQSxtQkFBbUIsR0FDNURDLEVBQU8sSUFBS0EsRUFBRSxDQUFDLENBQ1Q7QUFDWCxlQUFlRixHQUFHIiwiaWdub3JlTGlzdCI6W119
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-client/core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "High performance mutable data framework.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
122
|
"@babel/runtime": "^7.17.0",
|
|
123
|
-
"@data-client/normalizr": "^0.11.
|
|
123
|
+
"@data-client/normalizr": "^0.11.4",
|
|
124
124
|
"flux-standard-action": "^2.1.1"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
@@ -212,7 +212,7 @@ describe('Controller.get()', () => {
|
|
|
212
212
|
entities,
|
|
213
213
|
};
|
|
214
214
|
const tacoCount = new schema.Query(TacoList, tacos => {
|
|
215
|
-
return tacos
|
|
215
|
+
return tacos.length ?? 0;
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
expect(controller.get(tacoCount, { type: 'foo' }, state)).toBe(1);
|
package/src/index.ts
CHANGED
|
@@ -65,7 +65,6 @@ describe('LogoutManager', () => {
|
|
|
65
65
|
expect(dispatch.mock.calls.length).toBe(0);
|
|
66
66
|
});
|
|
67
67
|
it('should dispatch reset on 401', async () => {
|
|
68
|
-
jest.setSystemTime(0);
|
|
69
68
|
const error: any = new Error('network failed');
|
|
70
69
|
error.status = 401;
|
|
71
70
|
const action = createSet(CoolerArticleResource.get, {
|
|
@@ -87,7 +86,6 @@ describe('LogoutManager', () => {
|
|
|
87
86
|
},
|
|
88
87
|
handleLogout,
|
|
89
88
|
}).getMiddleware();
|
|
90
|
-
jest.setSystemTime(0);
|
|
91
89
|
const error: any = new Error('network failed');
|
|
92
90
|
error.status = 403;
|
|
93
91
|
const action = createSet(CoolerArticleResource.get, {
|
package/src/state/RIC.ts
CHANGED
package/ts3.4/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as __INTERNAL__1 from './internal.js';
|
|
2
2
|
export { __INTERNAL__1 as __INTERNAL__ };
|
|
3
|
-
export { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, } from '@data-client/normalizr';
|
|
3
|
+
export { NetworkError, UnknownError, ErrorTypes, Schema, EndpointInterface, EntityInterface, ResolveType, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchFunction, EndpointExtraOptions, Queryable, SchemaArgs, NI, } from '@data-client/normalizr';
|
|
4
4
|
export { ExpiryStatus } from '@data-client/normalizr';
|
|
5
5
|
export { default as NetworkManager, ResetError, } from './manager/NetworkManager.js';
|
|
6
6
|
export { default as createReducer, initialState, } from './state/reducer/createReducer.js';
|