@data-client/core 0.1.0
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/LICENSE +201 -0
- package/README.md +71 -0
- package/dist/index.js +1643 -0
- package/dist/index.umd.min.js +1 -0
- package/dist/next.js +461 -0
- package/dist/package.json +1 -0
- package/legacy/actionTypes.js +12 -0
- package/legacy/compatibleActions.js +2 -0
- package/legacy/controller/BaseController.js +289 -0
- package/legacy/controller/Controller.js +20 -0
- package/legacy/controller/createFetch.js +42 -0
- package/legacy/controller/createInvalidate.js +12 -0
- package/legacy/controller/createInvalidateAll.js +8 -0
- package/legacy/controller/createOptimistic.js +33 -0
- package/legacy/controller/createReceive.js +36 -0
- package/legacy/controller/createReset.js +8 -0
- package/legacy/controller/createSubscription.js +30 -0
- package/legacy/controller/types.js +2 -0
- package/legacy/endpoint/index.js +2 -0
- package/legacy/endpoint/shapes.js +2 -0
- package/legacy/endpoint/types.js +2 -0
- package/legacy/fsa.js +2 -0
- package/legacy/index.js +22 -0
- package/legacy/internal.js +4 -0
- package/legacy/legacyActions.js +2 -0
- package/legacy/manager/ConnectionListener.js +2 -0
- package/legacy/manager/DefaultConnectionListener.js +40 -0
- package/legacy/manager/DevtoolsManager.js +73 -0
- package/legacy/manager/LogoutManager.js +34 -0
- package/legacy/manager/NetworkManager.js +291 -0
- package/legacy/manager/PollingSubscription.js +159 -0
- package/legacy/manager/SubscriptionManager.js +117 -0
- package/legacy/manager/applyManager.js +23 -0
- package/legacy/manager/devtoolsTypes.js +2 -0
- package/legacy/manager/index.js +6 -0
- package/legacy/middlewareTypes.js +2 -0
- package/legacy/newActions.js +2 -0
- package/legacy/next/Controller.js +24 -0
- package/legacy/next/index.js +3 -0
- package/legacy/previousActions.js +2 -0
- package/legacy/state/RIC.js +3 -0
- package/legacy/state/applyUpdatersToResults.js +4 -0
- package/legacy/state/legacy-actions/createFetch.js +62 -0
- package/legacy/state/legacy-actions/createReceive.js +37 -0
- package/legacy/state/legacy-actions/createReceiveError.js +28 -0
- package/legacy/state/legacy-actions/index.js +4 -0
- package/legacy/state/reducer/createReducer.js +54 -0
- package/legacy/state/reducer/fetchReducer.js +32 -0
- package/legacy/state/reducer/invalidateReducer.js +28 -0
- package/legacy/state/reducer/setReducer.js +113 -0
- package/legacy/state/reducerInstance.js +9 -0
- package/legacy/state/selectMeta.js +4 -0
- package/legacy/types.js +8 -0
- package/lib/actionTypes.d.ts +11 -0
- package/lib/actionTypes.d.ts.map +1 -0
- package/lib/actionTypes.js +12 -0
- package/lib/compatibleActions.d.ts +47 -0
- package/lib/compatibleActions.d.ts.map +1 -0
- package/lib/compatibleActions.js +2 -0
- package/lib/controller/BaseController.d.ts +128 -0
- package/lib/controller/BaseController.d.ts.map +1 -0
- package/lib/controller/BaseController.js +289 -0
- package/lib/controller/Controller.d.ts +14 -0
- package/lib/controller/Controller.d.ts.map +1 -0
- package/lib/controller/Controller.js +20 -0
- package/lib/controller/createFetch.d.ts +12 -0
- package/lib/controller/createFetch.d.ts.map +1 -0
- package/lib/controller/createFetch.js +42 -0
- package/lib/controller/createInvalidate.d.ts +6 -0
- package/lib/controller/createInvalidate.d.ts.map +1 -0
- package/lib/controller/createInvalidate.js +12 -0
- package/lib/controller/createInvalidateAll.d.ts +3 -0
- package/lib/controller/createInvalidateAll.d.ts.map +1 -0
- package/lib/controller/createInvalidateAll.js +8 -0
- package/lib/controller/createOptimistic.d.ts +10 -0
- package/lib/controller/createOptimistic.d.ts.map +1 -0
- package/lib/controller/createOptimistic.js +33 -0
- package/lib/controller/createReceive.d.ts +20 -0
- package/lib/controller/createReceive.d.ts.map +1 -0
- package/lib/controller/createReceive.js +36 -0
- package/lib/controller/createReset.d.ts +3 -0
- package/lib/controller/createReset.d.ts.map +1 -0
- package/lib/controller/createReset.js +8 -0
- package/lib/controller/createSubscription.d.ts +9 -0
- package/lib/controller/createSubscription.d.ts.map +1 -0
- package/lib/controller/createSubscription.js +30 -0
- package/lib/controller/types.d.ts +6 -0
- package/lib/controller/types.d.ts.map +1 -0
- package/lib/controller/types.js +2 -0
- package/lib/endpoint/index.d.ts +3 -0
- package/lib/endpoint/index.d.ts.map +1 -0
- package/lib/endpoint/index.js +2 -0
- package/lib/endpoint/shapes.d.ts +25 -0
- package/lib/endpoint/shapes.d.ts.map +1 -0
- package/lib/endpoint/shapes.js +2 -0
- package/lib/endpoint/types.d.ts +45 -0
- package/lib/endpoint/types.d.ts.map +1 -0
- package/lib/endpoint/types.js +2 -0
- package/lib/fsa.d.ts +41 -0
- package/lib/fsa.d.ts.map +1 -0
- package/lib/fsa.js +2 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/internal.d.ts +4 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +4 -0
- package/lib/legacyActions.d.ts +92 -0
- package/lib/legacyActions.d.ts.map +1 -0
- package/lib/legacyActions.js +2 -0
- package/lib/manager/ConnectionListener.d.ts +8 -0
- package/lib/manager/ConnectionListener.d.ts.map +1 -0
- package/lib/manager/ConnectionListener.js +2 -0
- package/lib/manager/DefaultConnectionListener.d.ts +20 -0
- package/lib/manager/DefaultConnectionListener.d.ts.map +1 -0
- package/lib/manager/DefaultConnectionListener.js +40 -0
- package/lib/manager/DevtoolsManager.d.ts +24 -0
- package/lib/manager/DevtoolsManager.d.ts.map +1 -0
- package/lib/manager/DevtoolsManager.js +74 -0
- package/lib/manager/LogoutManager.d.ts +25 -0
- package/lib/manager/LogoutManager.d.ts.map +1 -0
- package/lib/manager/LogoutManager.js +34 -0
- package/lib/manager/NetworkManager.d.ts +82 -0
- package/lib/manager/NetworkManager.d.ts.map +1 -0
- package/lib/manager/NetworkManager.js +295 -0
- package/lib/manager/PollingSubscription.d.ts +45 -0
- package/lib/manager/PollingSubscription.d.ts.map +1 -0
- package/lib/manager/PollingSubscription.js +159 -0
- package/lib/manager/SubscriptionManager.d.ts +55 -0
- package/lib/manager/SubscriptionManager.d.ts.map +1 -0
- package/lib/manager/SubscriptionManager.js +117 -0
- package/lib/manager/applyManager.d.ts +10 -0
- package/lib/manager/applyManager.d.ts.map +1 -0
- package/lib/manager/applyManager.js +23 -0
- package/lib/manager/devtoolsTypes.d.ts +205 -0
- package/lib/manager/devtoolsTypes.d.ts.map +1 -0
- package/lib/manager/devtoolsTypes.js +2 -0
- package/lib/manager/index.d.ts +8 -0
- package/lib/manager/index.d.ts.map +1 -0
- package/lib/manager/index.js +6 -0
- package/lib/middlewareTypes.d.ts +18 -0
- package/lib/middlewareTypes.d.ts.map +1 -0
- package/lib/middlewareTypes.js +2 -0
- package/lib/newActions.d.ts +85 -0
- package/lib/newActions.d.ts.map +1 -0
- package/lib/newActions.js +2 -0
- package/lib/next/Controller.d.ts +14 -0
- package/lib/next/Controller.d.ts.map +1 -0
- package/lib/next/Controller.js +24 -0
- package/lib/next/index.d.ts +3 -0
- package/lib/next/index.d.ts.map +1 -0
- package/lib/next/index.js +3 -0
- package/lib/previousActions.d.ts +91 -0
- package/lib/previousActions.d.ts.map +1 -0
- package/lib/previousActions.js +2 -0
- package/lib/state/RIC.d.ts +2 -0
- package/lib/state/RIC.js +3 -0
- package/lib/state/applyUpdatersToResults.d.ts +13 -0
- package/lib/state/applyUpdatersToResults.d.ts.map +1 -0
- package/lib/state/applyUpdatersToResults.js +7 -0
- package/lib/state/legacy-actions/createFetch.d.ts +19 -0
- package/lib/state/legacy-actions/createFetch.d.ts.map +1 -0
- package/lib/state/legacy-actions/createFetch.js +62 -0
- package/lib/state/legacy-actions/createReceive.d.ts +14 -0
- package/lib/state/legacy-actions/createReceive.d.ts.map +1 -0
- package/lib/state/legacy-actions/createReceive.js +37 -0
- package/lib/state/legacy-actions/createReceiveError.d.ts +9 -0
- package/lib/state/legacy-actions/createReceiveError.d.ts.map +1 -0
- package/lib/state/legacy-actions/createReceiveError.js +28 -0
- package/lib/state/legacy-actions/index.d.ts +4 -0
- package/lib/state/legacy-actions/index.d.ts.map +1 -0
- package/lib/state/legacy-actions/index.js +4 -0
- package/lib/state/reducer/createReducer.d.ts +7 -0
- package/lib/state/reducer/createReducer.d.ts.map +1 -0
- package/lib/state/reducer/createReducer.js +55 -0
- package/lib/state/reducer/fetchReducer.d.ts +4 -0
- package/lib/state/reducer/fetchReducer.d.ts.map +1 -0
- package/lib/state/reducer/fetchReducer.js +34 -0
- package/lib/state/reducer/invalidateReducer.d.ts +37 -0
- package/lib/state/reducer/invalidateReducer.d.ts.map +1 -0
- package/lib/state/reducer/invalidateReducer.js +34 -0
- package/lib/state/reducer/setReducer.d.ts +40 -0
- package/lib/state/reducer/setReducer.d.ts.map +1 -0
- package/lib/state/reducer/setReducer.js +119 -0
- package/lib/state/reducerInstance.d.ts +7 -0
- package/lib/state/reducerInstance.d.ts.map +1 -0
- package/lib/state/reducerInstance.js +9 -0
- package/lib/state/selectMeta.d.ts +3 -0
- package/lib/state/selectMeta.d.ts.map +1 -0
- package/lib/state/selectMeta.js +4 -0
- package/lib/types.d.ts +71 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/node.mjs +1 -0
- package/package.json +127 -0
- package/src/actionTypes.ts +11 -0
- package/src/compatibleActions.ts +96 -0
- package/src/controller/BaseController.ts +508 -0
- package/src/controller/Controller.ts +32 -0
- package/src/controller/__tests__/Controller.ts +29 -0
- package/src/controller/__tests__/__snapshots__/getResponse.ts.snap +35 -0
- package/src/controller/__tests__/getResponse.ts +182 -0
- package/src/controller/createFetch.ts +54 -0
- package/src/controller/createInvalidate.ts +16 -0
- package/src/controller/createInvalidateAll.ts +11 -0
- package/src/controller/createOptimistic.ts +47 -0
- package/src/controller/createReceive.ts +85 -0
- package/src/controller/createReset.ts +9 -0
- package/src/controller/createSubscription.ts +39 -0
- package/src/controller/types.ts +22 -0
- package/src/endpoint/index.ts +14 -0
- package/src/endpoint/shapes.ts +53 -0
- package/src/endpoint/types.ts +72 -0
- package/src/fsa.ts +99 -0
- package/src/index.ts +61 -0
- package/src/internal.ts +3 -0
- package/src/legacyActions.ts +163 -0
- package/src/manager/ConnectionListener.ts +7 -0
- package/src/manager/DefaultConnectionListener.ts +54 -0
- package/src/manager/DevtoolsManager.ts +99 -0
- package/src/manager/LogoutManager.ts +57 -0
- package/src/manager/NetworkManager.ts +346 -0
- package/src/manager/PollingSubscription.ts +190 -0
- package/src/manager/SubscriptionManager.ts +156 -0
- package/src/manager/__tests__/__snapshots__/pollingSubscription-endpoint.ts.snap +49 -0
- package/src/manager/__tests__/__snapshots__/pollingSubscription.ts.snap +43 -0
- package/src/manager/__tests__/logoutManager.ts +112 -0
- package/src/manager/__tests__/manager.ts +44 -0
- package/src/manager/__tests__/networkManager-legacy.ts +394 -0
- package/src/manager/__tests__/networkManager.ts +426 -0
- package/src/manager/__tests__/pollingSubscription-endpoint.ts +423 -0
- package/src/manager/__tests__/pollingSubscription.ts +313 -0
- package/src/manager/__tests__/subscriptionManager.ts +208 -0
- package/src/manager/applyManager.ts +33 -0
- package/src/manager/devtoolsTypes.ts +210 -0
- package/src/manager/index.ts +7 -0
- package/src/middlewareTypes.ts +49 -0
- package/src/newActions.ts +140 -0
- package/src/next/Controller.ts +39 -0
- package/src/next/index.ts +2 -0
- package/src/package.json +1 -0
- package/src/previousActions.ts +159 -0
- package/src/state/RIC.d.ts +2 -0
- package/src/state/RIC.js +5 -0
- package/src/state/__tests__/RIC.web.ts +16 -0
- package/src/state/__tests__/__snapshots__/reducer.ts.snap +56 -0
- package/src/state/__tests__/applyUpdatersToResults.ts +40 -0
- package/src/state/__tests__/reducer.ts +868 -0
- package/src/state/applyUpdatersToResults.ts +29 -0
- package/src/state/legacy-actions/createFetch.ts +95 -0
- package/src/state/legacy-actions/createReceive.ts +68 -0
- package/src/state/legacy-actions/createReceiveError.ts +43 -0
- package/src/state/legacy-actions/index.ts +3 -0
- package/src/state/reducer/createReducer.ts +80 -0
- package/src/state/reducer/fetchReducer.ts +48 -0
- package/src/state/reducer/invalidateReducer.ts +39 -0
- package/src/state/reducer/setReducer.ts +157 -0
- package/src/state/reducerInstance.ts +14 -0
- package/src/state/selectMeta.ts +8 -0
- package/src/types.ts +125 -0
- package/ts3.4/actionTypes.d.ts +11 -0
- package/ts3.4/compatibleActions.d.ts +47 -0
- package/ts3.4/controller/BaseController.d.ts +170 -0
- package/ts3.4/controller/Controller.d.ts +14 -0
- package/ts3.4/controller/createFetch.d.ts +14 -0
- package/ts3.4/controller/createInvalidate.d.ts +8 -0
- package/ts3.4/controller/createInvalidateAll.d.ts +3 -0
- package/ts3.4/controller/createOptimistic.d.ts +12 -0
- package/ts3.4/controller/createReceive.d.ts +24 -0
- package/ts3.4/controller/createReset.d.ts +3 -0
- package/ts3.4/controller/createSubscription.d.ts +13 -0
- package/ts3.4/controller/types.d.ts +6 -0
- package/ts3.4/endpoint/index.d.ts +3 -0
- package/ts3.4/endpoint/shapes.d.ts +25 -0
- package/ts3.4/endpoint/types.d.ts +45 -0
- package/ts3.4/fsa.d.ts +41 -0
- package/ts3.4/index.d.ts +22 -0
- package/ts3.4/internal.d.ts +4 -0
- package/ts3.4/legacyActions.d.ts +95 -0
- package/ts3.4/manager/ConnectionListener.d.ts +8 -0
- package/ts3.4/manager/DefaultConnectionListener.d.ts +20 -0
- package/ts3.4/manager/DevtoolsManager.d.ts +24 -0
- package/ts3.4/manager/LogoutManager.d.ts +25 -0
- package/ts3.4/manager/NetworkManager.d.ts +82 -0
- package/ts3.4/manager/PollingSubscription.d.ts +45 -0
- package/ts3.4/manager/SubscriptionManager.d.ts +55 -0
- package/ts3.4/manager/applyManager.d.ts +10 -0
- package/ts3.4/manager/devtoolsTypes.d.ts +205 -0
- package/ts3.4/manager/index.d.ts +8 -0
- package/ts3.4/middlewareTypes.d.ts +18 -0
- package/ts3.4/newActions.d.ts +88 -0
- package/ts3.4/next/Controller.d.ts +14 -0
- package/ts3.4/next/index.d.ts +3 -0
- package/ts3.4/previousActions.d.ts +94 -0
- package/ts3.4/state/RIC.d.ts +2 -0
- package/ts3.4/state/applyUpdatersToResults.d.ts +13 -0
- package/ts3.4/state/legacy-actions/createFetch.d.ts +19 -0
- package/ts3.4/state/legacy-actions/createReceive.d.ts +14 -0
- package/ts3.4/state/legacy-actions/createReceiveError.d.ts +9 -0
- package/ts3.4/state/legacy-actions/index.d.ts +4 -0
- package/ts3.4/state/reducer/createReducer.d.ts +7 -0
- package/ts3.4/state/reducer/fetchReducer.d.ts +4 -0
- package/ts3.4/state/reducer/invalidateReducer.d.ts +37 -0
- package/ts3.4/state/reducer/setReducer.d.ts +40 -0
- package/ts3.4/state/reducerInstance.d.ts +7 -0
- package/ts3.4/state/selectMeta.d.ts +3 -0
- package/ts3.4/types.d.ts +73 -0
- package/typescript.svg +8 -0
|
@@ -0,0 +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).dataClientCore={},e.normalizr)}(this,(function(e,t){"use strict";var s="function"==typeof requestIdleCallback?requestIdleCallback:e=>setTimeout(e,0);const i="rest-hooks/fetch",r="rest-hooks/receive",n=r,a="rest-hooks/optimistic",o="rest-hooks/reset",c="rest-hooks/subscribe",l="rest-hook/unsubscribe",h="rest-hooks/invalidate",d="rest-hooks/invalidateall",u="rest-hooks/gc";var p=Object.freeze({__proto__:null,FETCH_TYPE:i,RECEIVE_TYPE:r,SET_TYPE:n,OPTIMISTIC_TYPE:a,RESET_TYPE:o,SUBSCRIBE_TYPE:c,UNSUBSCRIBE_TYPE:l,INVALIDATE_TYPE:h,INVALIDATEALL_TYPE:d,GC_TYPE:u});function m(e,{schema:t,key:s,args:i,updaters:n,fetchedAt:a=0,update:o,dataExpiryLength:c}){const l=Date.now(),h={schema:t,key:s,args:i,date:l,fetchedAt:a,expiresAt:l+c};return h.updaters=n,h.update=o,{type:r,payload:e,meta:h}}function f(e,{schema:t,key:s,options:i,errorExpiryLength:n=6e4,fetchedAt:a=0}){const o=Date.now();return{type:r,payload:e,meta:{schema:t,key:s,date:o,fetchedAt:a,expiresAt:o+n,errorPolicy:null==i?void 0:i.errorPolicy},error:!0}}var y=Object.freeze({__proto__:null,createFetch:function(e,{params:t,body:s,throttle:r,updateParams:n}){const{schema:a,type:o,getFetchKey:c,options:l}=e,h=c(t);let d=0,u=0;const p=new Promise(((e,t)=>{[d,u]=[e,t]})),m={schema:a,type:o,args:[t,s],key:h,throttle:r,options:l,resolve:d,reject:u,promise:p,createdAt:Date.now()};return e.update&&(m.update=e.update),n&&(m.update=e=>{const t={};return n.forEach((([s,i,r])=>{t[s.getFetchKey(i)]=t=>r(e,t)})),t}),null!=l&&l.optimisticUpdate&&(m.optimisticResponse=l.optimisticUpdate(t,s)),{type:i,payload:()=>e.fetch(t,s),meta:m}},createReceive:m,createReceiveError:f});function g(e,t){var s;const i=t.meta.optimisticResponse;let r;if((null==(s=t.endpoint)?void 0:s.getOptimisticResponse)&&t.endpoint&&t.endpoint.sideEffect)r=function(e,{args:t,fetchedAt:s}){var i;const r=null!=(i=e.dataExpiryLength)?i:6e4,n=Date.now(),o={args:t,fetchedAt:s,date:n,expiresAt:n+r,schema:e.schema,key:e.key(...t)};return e.update&&(o.update=e.update),e.errorPolicy&&(o.errorPolicy=e.errorPolicy),{type:a,endpoint:e,meta:o}}(t.endpoint,{args:t.meta.args,fetchedAt:"number"!=typeof t.meta.createdAt?t.meta.createdAt.getTime():t.meta.createdAt});else{if(!i)return e;r=m(i,Object.assign({},t.meta,{dataExpiryLength:1/0}))}return Object.assign({},e,{optimistic:[...e.optimistic,r]})}function v(e,s,i){if(s.error)return E(e,s,s.payload);try{var r;let o;if(s.type===a){if(!s.endpoint.getOptimisticResponse)return e;try{o=s.endpoint.getOptimisticResponse.call(s.endpoint,i.snapshot(e,s.meta.fetchedAt),...s.meta.args)}catch(t){var n;if("AbortOptimistic"===(null==(n=t.constructor)?void 0:n.name))return e;throw t}}else o=s.payload;const{result:c,entities:l,indexes:h,entityMeta:d}=t.normalize(o,s.meta.schema,s.meta.args,e.entities,e.indexes,e.entityMeta,Object.assign({fetchedAt:s.meta.date},s.meta));let u=Object.assign({},e.results,{[s.meta.key]:c});try{if("updaters"in s.meta&&s.meta.updaters&&(u=function(e,t,s){return Object.assign({},e,Object.fromEntries(Object.entries(s).map((([s,i])=>[s,i(t,e[s])]))))}(u,c,s.meta.updaters)),s.meta.update){const e=s.meta.update(c,...s.meta.args||[]);Object.keys(e).forEach((t=>{u[t]=e[t](u[t])}))}}catch(e){console.error(`The following error occured during Endpoint.update() for ${s.meta.key}`),console.error(e)}return{entities:l,indexes:h,results:u,entityMeta:d,meta:Object.assign({},e.meta,{[s.meta.key]:{date:s.meta.date,expiresAt:s.meta.expiresAt,prevExpiresAt:null==(r=e.meta[s.meta.key])?void 0:r.expiresAt}}),optimistic:b(e,s),lastReset:e.lastReset}}catch(t){return"object"==typeof t&&(t.message=`Error processing ${s.meta.key}\n\nFull Schema: ${JSON.stringify(s.meta.schema,void 0,2)}\n\nError:\n${t.message}`,"payload"in s&&(t.payload=s.payload),t.status=400),E(e,s,t)}}function E(e,t,s){return"AbortError"===s.name?Object.assign({},e,{optimistic:b(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.meta.errorPolicy?void 0:t.meta.errorPolicy(s)}}),optimistic:b(e,t)})}function b(e,t){return e.optimistic.filter((e=>e.meta.key!==t.meta.key||(e.type===a?e.meta.fetchedAt!==t.meta.fetchedAt:e.meta.date>t.meta.date)))}function L(e){return function(t,s){var r;switch(t||(t=O),s.type){case u:return s.entities.forEach((([e,s])=>{var i,r;null==(i=t.entities[e])||delete i[s],null==(r=t.entityMeta[e])||delete r[s]})),s.results.forEach((e=>{delete t.results[e],delete t.meta[e]})),t;case i:return g(t,s);case a:case n:return v(t,s,e);case d:case h:return function(e,t){const s=Object.assign({},e.results),i=Object.assign({},e.meta),r=e=>{delete s[e];const t=Object.assign({},i[e],{expiresAt:0,invalidated:!0});delete t.error,i[e]=t};return t.type===h?r(t.meta.key):Object.keys(s).forEach((e=>{t.testKey(e)&&r(e)})),Object.assign({},e,{results:s,meta:i})}(t,s);case o:return Object.assign({},O,{lastReset:null!=(r=s.date)?r:Date.now()});default:return t}}}const O={entities:{},indexes:{},results:{},meta:{},entityMeta:{},optimistic:[],lastReset:0};var k=Object.freeze({__proto__:null,inferResults:t.inferResults,DELETED:t.DELETED,RIC:s,initialState:O});function A(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,fetchedAt:null!=s?s:l,date:l,expiresAt:l+c,schema:e.schema,key:e.key(...t)};e.update&&(h.update=e.update),e.errorPolicy&&(h.errorPolicy=e.errorPolicy);const d={type:n,payload:i,endpoint:e,meta:h};return r&&(d.error=!0),d}function w(e,t){return e.meta[t]}const S=e=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},I=()=>O;class x{constructor({dispatch:e=S,getState:s=I,globalCache:i={entities:{},results:{}}}={}){this.invalidate=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:h,meta:{key:e.key(...t)}}}(e,{args:t})):Promise.resolve(),this.invalidateAll=e=>this.dispatch({type:d,testKey:t=>e.testKey(t)}),this.resetEntireStore=()=>this.dispatch({type:o,date:Date.now()}),this.setResponse=(e,...t)=>{const s=t[t.length-1],i=A(e,{args:t.slice(0,t.length-1),response:s});return this.dispatch(i)},this.receive=(e,...t)=>this.setResponse(e,...t),this.setError=(e,...t)=>{const s=t[t.length-1],i=A(e,{args:t.slice(0,t.length-1),response:s,error:!0});return this.dispatch(i)},this.receiveError=(e,...t)=>this.setError(e,...t),this.resolve=(e,t)=>this.dispatch(A(e,t)),this.subscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:c,endpoint:e,meta:{args:t,key:e.key(...t),fetch:()=>e(...t),schema:e.schema,options:e}}}(e,{args:t})):Promise.resolve(),this.unsubscribe=(e,...t)=>null!==t[0]?this.dispatch(function(e,{args:t}){return{type:l,endpoint:e,meta:{args:t,key:e.key(...t),options:e}}}(e,{args:t})):Promise.resolve(),this.snapshot=(e,t)=>new R(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),r=e.key(...i),n=w(s,r);return void 0===s.results[r]||"soft"!==(null==n?void 0:n.errorPolicy)?null==n?void 0:n.error:void 0},this.getResponse=(e,...s)=>{const i=s[s.length-1],r=s.slice(0,s.length-1),n=1!==r.length||null!==r[0],a=n?e.key(...r):"",o=n?i.results[a]:void 0,c=e.schema,l=w(i,a);let h,d=null==l?void 0:l.expiresAt,u=!1;if(void 0===o&&void 0!==e.schema?(h=t.inferResults(e.schema,r,i.indexes,i.entities),u=!t.validateInference(h),!d&&u&&(d=1)):h=o,!n)return{data:h,expiryStatus:t.ExpiryStatus.Valid,expiresAt:1/0};if(!e.schema||!j(e.schema))return{data:h,expiryStatus:null!=l&&l.invalidated?t.ExpiryStatus.Invalid:o&&!e.invalidIfStale?t.ExpiryStatus.Valid:t.ExpiryStatus.InvalidIfStale,expiresAt:d||0};this.globalCache.results[a]||(this.globalCache.results[a]=new t.WeakEntityMap);const{data:p,paths:m}=t.denormalizeCached(h,c,i.entities,this.globalCache.entities,this.globalCache.results[a],r),f="symbol"==typeof p;d||(d=function(e,t){let s=1/0;for(const{pk:n,key:a}of e){var i,r;const e=null==(i=t[a])||null==(r=i[n])?void 0:r.expiresAt;e<s&&(s=e)}return s}(m,i.entityMeta));return{data:p,expiryStatus:null!=l&&l.invalidated||f&&(null==l||!l.error)?t.ExpiryStatus.Invalid:f||e.invalidIfStale||u?t.ExpiryStatus.InvalidIfStale:t.ExpiryStatus.Valid,expiresAt:d}},this.dispatch=e,this.getState=s,this.globalCache=i}}function j(e){if(t.isEntity(e))return!0;if(Array.isArray(e))return 0!==e.length&&j(e[0]);if(e&&("object"==typeof e||"function"==typeof e)){const t="schema"in e?e.schema:e;return"function"==typeof t?j(t):Object.values(t).some((e=>j(e)))}return!1}class R{constructor(e,t,s=0){this.state=void 0,this.controller=void 0,this.fetchedAt=void 0,this.getResponse=(e,...t)=>this.controller.getResponse(e,...t,this.state),this.getError=(e,...t)=>this.controller.getError(e,...t,this.state),this.state=t,this.controller=e,this.fetchedAt=s}}function T(e,{args:t}){const s=e.key(...t);let r=0,n=0;const a=new Promise(((e,t)=>{[r,n]=[e,t]})),o={schema:e.schema,type:e.sideEffect?"mutate":"read",args:t,key:s,throttle:!e.sideEffect,options:e,resolve:r,reject:n,promise:a,createdAt:Date.now()};return e.update&&(o.update=e.update),e.optimisticUpdate&&(o.optimisticResponse=e.optimisticUpdate(...t)),{type:i,payload:()=>e(...t),meta:o,endpoint:e}}class _ extends x{constructor(...e){super(...e),this.fetch=(e,...t)=>{const s=T(e,{args:t});return this.dispatch(s),s.meta.promise}}}class P extends Error{constructor(){super("Aborted due to RESET"),this.name="ResetError"}}var q=L(new _);var D=Object.freeze({__proto__:null});class M{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 C{isOnline(){return!0}addOnlineListener(){}removeOnlineListener(){}addOfflineListener(){}removeOfflineListener(){}}let H;H="undefined"!=typeof navigator&&"function"==typeof addEventListener?M:C;var F,U=H;const z="undefined"!=typeof Intl,N={name:`Rest Hooks: ${null==(F=globalThis.document)?void 0:F.title}`,autoPause:!0,serialize:{options:void 0,replacer:z?(e,t)=>"number"==typeof t&&"string"==typeof e&&isFinite(t)&&("date"===e||e.endsWith("At"))?Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}).format(t):t:void 0}};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=_,e.DefaultConnectionListener=U,e.DevToolsManager=class{constructor(e,t){this.devTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__.connect(Object.assign({},N,{config:e})),this.devTools?this.middleware=e=>{const s=L(e);return i=>r=>{const n=i(r);return n.then((()=>{if(null!=t&&t(r))return;const i=e.getState();this.devTools.send(r,i.optimistic.reduce(s,i),void 0,"REST_HOOKS")})),n}}:this.middleware=()=>e=>t=>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.getState=()=>O,this.controller=new _,this.dataExpiryLength=e,this.errorExpiryLength=t,this.middleware=({dispatch:e,getState:t,controller:s})=>(this.getState=t,this.controller=s,t=>r=>{var a;switch(r.type){case i:return this.handleFetch(r,e,s),void 0!==r.meta.optimisticResponse||void 0!==(null==(a=r.endpoint)?void 0:a.getOptimisticResponse)&&r.endpoint.sideEffect?t(r):Promise.resolve();case n:return t(r).then((()=>{if(r.meta.key in this.fetched){var e;const t=null==(e=s.getState().meta[r.meta.key])?void 0:e.error;t?this.handleReceive(f(t,r.meta)):this.handleReceive(r)}}));case o:{const e=Object.assign({},this.rejectors);return this.clearAll(),t(r).then((()=>{for(const t in e)e[t](new P)}))}default:return t(r)}})}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(){if(this.cleanupDate)return this.cleanupDate;const e=this.controller.getState().lastReset;return e instanceof Date?e.valueOf():"number"!=typeof e?-1/0:e}handleFetch(e,t,s){const i=e.payload,{key:r,throttle:n,resolve:a,reject:o}=e.meta,c="number"!=typeof e.meta.createdAt?e.meta.createdAt.getTime():e.meta.createdAt,l=()=>{let t=i();const s=e=>e.then((e=>(a(e),e))).catch((e=>{throw o(e),e}));return!n&&e.endpoint&&(t=s(t)),t=t.then((t=>{let s=this.getLastReset();var i,r;c>=s&&(e.endpoint&&this.controller?this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:c}):this.controller.dispatch(m(t,Object.assign({},e.meta,{fetchedAt:c,dataExpiryLength:null!=(i=null==(r=e.meta.options)?void 0:r.dataExpiryLength)?i:this.dataExpiryLength}))));return t})).catch((t=>{const s=this.getLastReset();var i,r;c>=s&&(e.endpoint&&this.controller?this.controller.resolve(e.endpoint,{args:e.meta.args,response:t,fetchedAt:c,error:!0}):this.controller.dispatch(f(t,Object.assign({},e.meta,{errorExpiryLength:null!=(i=null==(r=e.meta.options)?void 0:r.errorExpiryLength)?i:this.errorExpiryLength,fetchedAt:c}))));throw t})),n||e.endpoint||(t=s(t)),t};return n?this.throttle(r,l,c).then((e=>a(e))).catch((e=>o(e))):l().catch((()=>{}))}handleReceive(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 r=this.getLastReset();return e in this.fetched&&this.fetchedAt[e]>r||(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({key:e,schema:t,fetch:s,frequency:i,getState:r},n,a){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===i)throw new Error("frequency needed for polling subscription");this.schema=t,this.fetch=s,this.frequency=i,this.key=e,this.frequencyHistogram.set(this.frequency,1),this.dispatch=n,this.getState=r,this.connectionListener=a||new U,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.fetch();e.schema=this.schema,e.key=()=>this.key,e.dataExpiryLength=this.frequency/2,e.errorExpiryLength=this.frequency/10,e.errorPolicy=()=>"soft";const t=T(e,{args:[]});t.meta.promise.catch((e=>null)),this.dispatch(t)}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.getState().meta[this.key])?void 0:t.date)?e:0}},e.ResetError=P,e.SubscriptionManager=class{constructor(e){this.subscriptions={},this.Subscription=e,this.middleware=({dispatch:e,getState:t})=>s=>i=>{switch(i.type){case c:try{this.handleSubscribe(i,e,t)}catch(e){console.error(e)}return Promise.resolve();case l:return this.handleUnsubscribe(i,e),Promise.resolve();default:return s(i)}}}cleanup(){for(const e in this.subscriptions)this.subscriptions[e].cleanup()}handleSubscribe(e,t,s){let i;if(e.endpoint){const{endpoint:t}=e,{args:r}=e.meta;i={schema:t.schema,fetch:()=>t(...r),frequency:t.pollFrequency,key:t.key(...r),getState:s}}else{var r;i={key:e.meta.key,frequency:null==(r=e.meta.options)?void 0:r.pollFrequency,schema:e.meta.schema,fetch:e.meta.fetch,getState:s}}i.key in this.subscriptions?this.subscriptions[i.key].add(i.frequency):this.subscriptions[i.key]=new this.Subscription(i,t)}handleUnsubscribe(e,t){var s;const i=e.meta.key,r=null==(s=e.meta.options)?void 0:s.pollFrequency;if(i in this.subscriptions){this.subscriptions[i].remove(r)&&delete this.subscriptions[i]}}getMiddleware(){return this.middleware}},e.__INTERNAL__=k,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;const r=Object.create(t,{controller:{value:t}});return s(r)}}))},e.createFetch=T,e.createReceive=A,e.createReducer=L,e.initialState=O,e.legacyActions=y,e.newActions=D,e.reducer=q,Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var normalizr = require('@data-client/normalizr');
|
|
6
|
+
|
|
7
|
+
const FETCH_TYPE = 'rest-hooks/fetch';
|
|
8
|
+
// TODO(breaking): deprecate this
|
|
9
|
+
const RECEIVE_TYPE = 'rest-hooks/receive';
|
|
10
|
+
const SET_TYPE = RECEIVE_TYPE;
|
|
11
|
+
const RESET_TYPE = 'rest-hooks/reset';
|
|
12
|
+
const SUBSCRIBE_TYPE = 'rest-hooks/subscribe';
|
|
13
|
+
const UNSUBSCRIBE_TYPE = 'rest-hook/unsubscribe';
|
|
14
|
+
const INVALIDATE_TYPE = 'rest-hooks/invalidate';
|
|
15
|
+
const INVALIDATEALL_TYPE = 'rest-hooks/invalidateall';
|
|
16
|
+
|
|
17
|
+
function createInvalidate(endpoint, {
|
|
18
|
+
args
|
|
19
|
+
}) {
|
|
20
|
+
return {
|
|
21
|
+
type: INVALIDATE_TYPE,
|
|
22
|
+
meta: {
|
|
23
|
+
key: endpoint.key(...args)
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createInvalidateAll(testKey) {
|
|
29
|
+
return {
|
|
30
|
+
type: INVALIDATEALL_TYPE,
|
|
31
|
+
testKey
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createReceive(endpoint, {
|
|
36
|
+
args,
|
|
37
|
+
fetchedAt,
|
|
38
|
+
response,
|
|
39
|
+
error = false
|
|
40
|
+
}) {
|
|
41
|
+
var _endpoint$errorExpiry, _endpoint$dataExpiryL;
|
|
42
|
+
const expiryLength = error ? (_endpoint$errorExpiry = endpoint.errorExpiryLength) != null ? _endpoint$errorExpiry : 1000 : (_endpoint$dataExpiryL = endpoint.dataExpiryLength) != null ? _endpoint$dataExpiryL : 60000;
|
|
43
|
+
/* istanbul ignore next */
|
|
44
|
+
if (process.env.NODE_ENV === 'development' && expiryLength < 0) {
|
|
45
|
+
throw new Error('Negative expiry length are not allowed.');
|
|
46
|
+
}
|
|
47
|
+
const now = Date.now();
|
|
48
|
+
const meta = {
|
|
49
|
+
args,
|
|
50
|
+
fetchedAt: fetchedAt != null ? fetchedAt : now,
|
|
51
|
+
date: now,
|
|
52
|
+
expiresAt: now + expiryLength,
|
|
53
|
+
// For legacy support; TODO: remove
|
|
54
|
+
schema: endpoint.schema,
|
|
55
|
+
key: endpoint.key(...args)
|
|
56
|
+
};
|
|
57
|
+
// For legacy support; TODO: remove
|
|
58
|
+
if (endpoint.update) meta.update = endpoint.update;
|
|
59
|
+
if (endpoint.errorPolicy) meta.errorPolicy = endpoint.errorPolicy;
|
|
60
|
+
const action = {
|
|
61
|
+
type: SET_TYPE,
|
|
62
|
+
payload: response,
|
|
63
|
+
endpoint: endpoint,
|
|
64
|
+
meta
|
|
65
|
+
};
|
|
66
|
+
if (error) action.error = true;
|
|
67
|
+
return action;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function createReset() {
|
|
71
|
+
return {
|
|
72
|
+
type: RESET_TYPE,
|
|
73
|
+
date: Date.now()
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function createSubscription(endpoint, {
|
|
78
|
+
args
|
|
79
|
+
}) {
|
|
80
|
+
return {
|
|
81
|
+
type: SUBSCRIBE_TYPE,
|
|
82
|
+
endpoint,
|
|
83
|
+
meta: {
|
|
84
|
+
args,
|
|
85
|
+
key: endpoint.key(...args),
|
|
86
|
+
fetch: () => endpoint(...args),
|
|
87
|
+
schema: endpoint.schema,
|
|
88
|
+
options: endpoint
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function createUnsubscription(endpoint, {
|
|
93
|
+
args
|
|
94
|
+
}) {
|
|
95
|
+
return {
|
|
96
|
+
type: UNSUBSCRIBE_TYPE,
|
|
97
|
+
endpoint,
|
|
98
|
+
meta: {
|
|
99
|
+
args,
|
|
100
|
+
key: endpoint.key(...args),
|
|
101
|
+
options: endpoint
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const initialState = {
|
|
107
|
+
entities: {},
|
|
108
|
+
indexes: {},
|
|
109
|
+
results: {},
|
|
110
|
+
meta: {},
|
|
111
|
+
entityMeta: {},
|
|
112
|
+
optimistic: [],
|
|
113
|
+
lastReset: 0
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function selectMeta(state, fetchKey) {
|
|
117
|
+
return state.meta[fetchKey];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const unsetDispatch = action => {
|
|
121
|
+
throw new Error(`Dispatching while constructing your middleware is not allowed. ` + `Other middleware would not be applied to this dispatch.`);
|
|
122
|
+
};
|
|
123
|
+
const unsetState = () => {
|
|
124
|
+
// This is only the value until it is set by the CacheProvider
|
|
125
|
+
/* istanbul ignore next */
|
|
126
|
+
return initialState;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Imperative control of Rest Hooks store
|
|
131
|
+
* @see https://resthooks.io/docs/api/Controller
|
|
132
|
+
*/
|
|
133
|
+
class Controller$1 {
|
|
134
|
+
/**
|
|
135
|
+
* Dispatches an action to Rest Hooks reducer.
|
|
136
|
+
*
|
|
137
|
+
* @see https://resthooks.io/docs/api/Controller#dispatch
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Gets the latest state snapshot that is fully committed.
|
|
142
|
+
*
|
|
143
|
+
* This can be useful for imperative use-cases like event handlers.
|
|
144
|
+
* This should *not* be used to render; instead useSuspense() or useCache()
|
|
145
|
+
* @see https://resthooks.io/docs/api/Controller#getState
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
constructor({
|
|
149
|
+
dispatch = unsetDispatch,
|
|
150
|
+
getState = unsetState,
|
|
151
|
+
globalCache = {
|
|
152
|
+
entities: {},
|
|
153
|
+
results: {}
|
|
154
|
+
}
|
|
155
|
+
} = {}) {
|
|
156
|
+
/*************** Action Dispatchers ***************/
|
|
157
|
+
/**
|
|
158
|
+
* Forces refetching and suspense on useSuspense with the same Endpoint and parameters.
|
|
159
|
+
* @see https://resthooks.io/docs/api/Controller#invalidate
|
|
160
|
+
*/
|
|
161
|
+
this.invalidate = (endpoint, ...args) => args[0] !== null ? this.dispatch(createInvalidate(endpoint, {
|
|
162
|
+
args: args
|
|
163
|
+
})) : Promise.resolve();
|
|
164
|
+
/**
|
|
165
|
+
* Forces refetching and suspense on useSuspense on all matching endpoint result keys.
|
|
166
|
+
* @see https://resthooks.io/docs/api/Controller#invalidateAll
|
|
167
|
+
*/
|
|
168
|
+
this.invalidateAll = options => this.dispatch(createInvalidateAll(key => options.testKey(key)));
|
|
169
|
+
/**
|
|
170
|
+
* Resets the entire Rest Hooks cache. All inflight requests will not resolve.
|
|
171
|
+
* @see https://resthooks.io/docs/api/Controller#resetEntireStore
|
|
172
|
+
*/
|
|
173
|
+
this.resetEntireStore = () => this.dispatch(createReset());
|
|
174
|
+
/**
|
|
175
|
+
* Stores response in cache for given Endpoint and args.
|
|
176
|
+
* @see https://resthooks.io/docs/api/Controller#set
|
|
177
|
+
*/
|
|
178
|
+
this.setResponse = (endpoint, ...rest) => {
|
|
179
|
+
const response = rest[rest.length - 1];
|
|
180
|
+
const action = createReceive(endpoint, {
|
|
181
|
+
args: rest.slice(0, rest.length - 1),
|
|
182
|
+
response
|
|
183
|
+
});
|
|
184
|
+
return this.dispatch(action);
|
|
185
|
+
};
|
|
186
|
+
// TODO: deprecate
|
|
187
|
+
/**
|
|
188
|
+
* Another name for setResponse
|
|
189
|
+
* @see https://resthooks.io/docs/api/Controller#setResponse
|
|
190
|
+
*/
|
|
191
|
+
/* istanbul ignore next */
|
|
192
|
+
this.receive = (endpoint, ...rest) => {
|
|
193
|
+
/* istanbul ignore next */
|
|
194
|
+
return this.setResponse(endpoint, ...rest);
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Stores the result of Endpoint and args as the error provided.
|
|
198
|
+
* @see https://resthooks.io/docs/api/Controller#setError
|
|
199
|
+
*/
|
|
200
|
+
this.setError = (endpoint, ...rest) => {
|
|
201
|
+
const response = rest[rest.length - 1];
|
|
202
|
+
const action = createReceive(endpoint, {
|
|
203
|
+
args: rest.slice(0, rest.length - 1),
|
|
204
|
+
response,
|
|
205
|
+
error: true
|
|
206
|
+
});
|
|
207
|
+
return this.dispatch(action);
|
|
208
|
+
};
|
|
209
|
+
// TODO: deprecate
|
|
210
|
+
/**
|
|
211
|
+
* Another name for setError
|
|
212
|
+
* @see https://resthooks.io/docs/api/Controller#setError
|
|
213
|
+
*/
|
|
214
|
+
/* istanbul ignore next */
|
|
215
|
+
this.receiveError = (endpoint, ...rest) => {
|
|
216
|
+
/* istanbul ignore next */
|
|
217
|
+
return this.setError(endpoint, ...rest);
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Resolves an inflight fetch. `fetchedAt` should `fetch`'s `createdAt`
|
|
221
|
+
* @see https://resthooks.io/docs/api/Controller#resolve
|
|
222
|
+
*/
|
|
223
|
+
this.resolve = (endpoint, meta) => {
|
|
224
|
+
return this.dispatch(createReceive(endpoint, meta));
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Marks a new subscription to a given Endpoint.
|
|
228
|
+
* @see https://resthooks.io/docs/api/Controller#subscribe
|
|
229
|
+
*/
|
|
230
|
+
this.subscribe = (endpoint, ...args) => args[0] !== null ? this.dispatch(createSubscription(endpoint, {
|
|
231
|
+
args: args
|
|
232
|
+
})) : Promise.resolve();
|
|
233
|
+
/**
|
|
234
|
+
* Marks completion of subscription to a given Endpoint.
|
|
235
|
+
* @see https://resthooks.io/docs/api/Controller#unsubscribe
|
|
236
|
+
*/
|
|
237
|
+
this.unsubscribe = (endpoint, ...args) => args[0] !== null ? this.dispatch(createUnsubscription(endpoint, {
|
|
238
|
+
args: args
|
|
239
|
+
})) : Promise.resolve();
|
|
240
|
+
/*************** More ***************/
|
|
241
|
+
/* TODO:
|
|
242
|
+
abort = <E extends EndpointInterface>(
|
|
243
|
+
endpoint: E,
|
|
244
|
+
...args: readonly [...Parameters<E>]
|
|
245
|
+
): Promise<void>
|
|
246
|
+
*/
|
|
247
|
+
/**
|
|
248
|
+
* Gets a snapshot (https://resthooks.io/docs/api/Snapshot)
|
|
249
|
+
* @see https://resthooks.io/docs/api/Controller#snapshot
|
|
250
|
+
*/
|
|
251
|
+
this.snapshot = (state, fetchedAt) => {
|
|
252
|
+
return new Snapshot(this, state, fetchedAt);
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Gets the error, if any, for a given endpoint. Returns undefined for no errors.
|
|
256
|
+
* @see https://resthooks.io/docs/api/Controller#getError
|
|
257
|
+
*/
|
|
258
|
+
this.getError = (endpoint, ...rest) => {
|
|
259
|
+
if (rest[0] === null) return;
|
|
260
|
+
const state = rest[rest.length - 1];
|
|
261
|
+
// this is typescript generics breaking
|
|
262
|
+
const args = rest.slice(0, rest.length - 1);
|
|
263
|
+
const key = endpoint.key(...args);
|
|
264
|
+
const meta = selectMeta(state, key);
|
|
265
|
+
const results = state.results[key];
|
|
266
|
+
if (results !== undefined && (meta == null ? void 0 : meta.errorPolicy) === 'soft') return;
|
|
267
|
+
return meta == null ? void 0 : meta.error;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
|
|
271
|
+
* @see https://resthooks.io/docs/api/Controller#getResponse
|
|
272
|
+
*/
|
|
273
|
+
this.getResponse = (endpoint, ...rest) => {
|
|
274
|
+
const state = rest[rest.length - 1];
|
|
275
|
+
// this is typescript generics breaking
|
|
276
|
+
const args = rest.slice(0, rest.length - 1);
|
|
277
|
+
const isActive = args.length !== 1 || args[0] !== null;
|
|
278
|
+
const key = isActive ? endpoint.key(...args) : '';
|
|
279
|
+
const cacheResults = isActive ? state.results[key] : undefined;
|
|
280
|
+
const schema = endpoint.schema;
|
|
281
|
+
const meta = selectMeta(state, key);
|
|
282
|
+
let expiresAt = meta == null ? void 0 : meta.expiresAt;
|
|
283
|
+
let invalidResults = false;
|
|
284
|
+
let results;
|
|
285
|
+
if (cacheResults === undefined && endpoint.schema !== undefined) {
|
|
286
|
+
results = normalizr.inferResults(endpoint.schema, args, state.indexes, state.entities);
|
|
287
|
+
invalidResults = !normalizr.validateInference(results);
|
|
288
|
+
if (!expiresAt && invalidResults) expiresAt = 1;
|
|
289
|
+
} else {
|
|
290
|
+
results = cacheResults;
|
|
291
|
+
}
|
|
292
|
+
if (!isActive) {
|
|
293
|
+
return {
|
|
294
|
+
data: results,
|
|
295
|
+
expiryStatus: normalizr.ExpiryStatus.Valid,
|
|
296
|
+
expiresAt: Infinity
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
if (!endpoint.schema || !schemaHasEntity(endpoint.schema)) {
|
|
300
|
+
return {
|
|
301
|
+
data: results,
|
|
302
|
+
expiryStatus: meta != null && meta.invalidated ? normalizr.ExpiryStatus.Invalid : cacheResults && !endpoint.invalidIfStale ? normalizr.ExpiryStatus.Valid : normalizr.ExpiryStatus.InvalidIfStale,
|
|
303
|
+
expiresAt: expiresAt || 0
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Warn users with bad configurations
|
|
308
|
+
/* istanbul ignore next */
|
|
309
|
+
if (process.env.NODE_ENV !== 'production' && schema && normalizr.isEntity(schema)) {
|
|
310
|
+
if (Array.isArray(results)) {
|
|
311
|
+
throw new Error(`fetch key ${key} has list results when single result is expected`);
|
|
312
|
+
}
|
|
313
|
+
if (typeof results === 'object') {
|
|
314
|
+
throw new Error(`fetch key ${key} has object results when entity's primary key (string) result is expected`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (!this.globalCache.results[key]) this.globalCache.results[key] = new normalizr.WeakEntityMap();
|
|
318
|
+
|
|
319
|
+
// second argument is false if any entities are missing
|
|
320
|
+
// eslint-disable-next-line prefer-const
|
|
321
|
+
const {
|
|
322
|
+
data,
|
|
323
|
+
paths
|
|
324
|
+
} = normalizr.denormalizeCached(results, schema, state.entities, this.globalCache.entities, this.globalCache.results[key], args);
|
|
325
|
+
const invalidDenormalize = typeof data === 'symbol';
|
|
326
|
+
|
|
327
|
+
// fallback to entity expiry time
|
|
328
|
+
if (!expiresAt) {
|
|
329
|
+
expiresAt = entityExpiresAt(paths, state.entityMeta);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// https://resthooks.io/docs/concepts/expiry-policy#expiry-status
|
|
333
|
+
// we don't track the difference between stale or fresh because that is tied to triggering
|
|
334
|
+
// conditions
|
|
335
|
+
const expiryStatus = meta != null && meta.invalidated || invalidDenormalize && !(meta != null && meta.error) ? normalizr.ExpiryStatus.Invalid : invalidDenormalize || endpoint.invalidIfStale || invalidResults ? normalizr.ExpiryStatus.InvalidIfStale : normalizr.ExpiryStatus.Valid;
|
|
336
|
+
return {
|
|
337
|
+
data,
|
|
338
|
+
expiryStatus,
|
|
339
|
+
expiresAt
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
this.dispatch = dispatch;
|
|
343
|
+
this.getState = getState;
|
|
344
|
+
this.globalCache = globalCache;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// benchmark: https://www.measurethat.net/Benchmarks/Show/24691/0/min-reducer-vs-imperative-with-paths
|
|
349
|
+
// earliest expiry dictates age
|
|
350
|
+
function entityExpiresAt(paths, entityMeta) {
|
|
351
|
+
let expiresAt = Infinity;
|
|
352
|
+
for (const {
|
|
353
|
+
pk,
|
|
354
|
+
key
|
|
355
|
+
} of paths) {
|
|
356
|
+
var _entityMeta$key, _entityMeta$key$pk;
|
|
357
|
+
const entityExpiry = (_entityMeta$key = entityMeta[key]) == null ? void 0 : (_entityMeta$key$pk = _entityMeta$key[pk]) == null ? void 0 : _entityMeta$key$pk.expiresAt;
|
|
358
|
+
// expiresAt will always resolve to false with any comparison
|
|
359
|
+
if (entityExpiry < expiresAt) expiresAt = entityExpiry;
|
|
360
|
+
}
|
|
361
|
+
return expiresAt;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Determine whether the schema has any entities.
|
|
365
|
+
*
|
|
366
|
+
* Without entities, denormalization is not needed, and results should not be inferred.
|
|
367
|
+
*/
|
|
368
|
+
function schemaHasEntity(schema) {
|
|
369
|
+
if (normalizr.isEntity(schema)) return true;
|
|
370
|
+
if (Array.isArray(schema)) return schema.length !== 0 && schemaHasEntity(schema[0]);
|
|
371
|
+
if (schema && (typeof schema === 'object' || typeof schema === 'function')) {
|
|
372
|
+
const nestedSchema = 'schema' in schema ? schema.schema : schema;
|
|
373
|
+
if (typeof nestedSchema === 'function') {
|
|
374
|
+
return schemaHasEntity(nestedSchema);
|
|
375
|
+
}
|
|
376
|
+
return Object.values(nestedSchema).some(x => schemaHasEntity(x));
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
class Snapshot {
|
|
381
|
+
constructor(controller, state, fetchedAt = 0) {
|
|
382
|
+
this.state = void 0;
|
|
383
|
+
this.controller = void 0;
|
|
384
|
+
this.fetchedAt = void 0;
|
|
385
|
+
/*************** Data Access ***************/
|
|
386
|
+
/** @see https://resthooks.io/docs/api/Snapshot#getResponse */
|
|
387
|
+
this.getResponse = (endpoint, ...args) => {
|
|
388
|
+
return this.controller.getResponse(endpoint, ...args, this.state);
|
|
389
|
+
};
|
|
390
|
+
/** @see https://resthooks.io/docs/api/Snapshot#getError */
|
|
391
|
+
this.getError = (endpoint, ...args) => {
|
|
392
|
+
return this.controller.getError(endpoint, ...args, this.state);
|
|
393
|
+
};
|
|
394
|
+
this.state = state;
|
|
395
|
+
this.controller = controller;
|
|
396
|
+
this.fetchedAt = fetchedAt;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Requesting a fetch to begin
|
|
402
|
+
*/
|
|
403
|
+
function createFetch(endpoint, {
|
|
404
|
+
args
|
|
405
|
+
}) {
|
|
406
|
+
const key = endpoint.key(...args);
|
|
407
|
+
let resolve = 0;
|
|
408
|
+
let reject = 0;
|
|
409
|
+
const promise = new Promise((a, b) => {
|
|
410
|
+
[resolve, reject] = [a, b];
|
|
411
|
+
});
|
|
412
|
+
const meta = {
|
|
413
|
+
schema: endpoint.schema,
|
|
414
|
+
type: endpoint.sideEffect ? 'mutate' : 'read',
|
|
415
|
+
args,
|
|
416
|
+
key,
|
|
417
|
+
throttle: !endpoint.sideEffect,
|
|
418
|
+
options: endpoint,
|
|
419
|
+
resolve,
|
|
420
|
+
reject,
|
|
421
|
+
promise,
|
|
422
|
+
createdAt: Date.now()
|
|
423
|
+
};
|
|
424
|
+
if (endpoint.update) {
|
|
425
|
+
meta.update = endpoint.update;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// TODO: Remove once EOL on this deprecated piece
|
|
429
|
+
/* istanbul ignore if */
|
|
430
|
+
if (endpoint.optimisticUpdate) {
|
|
431
|
+
meta.optimisticResponse = endpoint.optimisticUpdate(...args);
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
type: FETCH_TYPE,
|
|
435
|
+
payload: () => endpoint(...args),
|
|
436
|
+
meta,
|
|
437
|
+
endpoint
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
class Controller extends Controller$1 {
|
|
442
|
+
constructor(..._args) {
|
|
443
|
+
super(..._args);
|
|
444
|
+
/**
|
|
445
|
+
* Fetches the endpoint with given args, updating the Rest Hooks cache with the response or error upon completion.
|
|
446
|
+
* @see https://resthooks.io/docs/api/Controller#fetch
|
|
447
|
+
*/
|
|
448
|
+
this.fetch = (endpoint, ...args) => {
|
|
449
|
+
const action = createFetch(endpoint, {
|
|
450
|
+
args
|
|
451
|
+
});
|
|
452
|
+
this.dispatch(action);
|
|
453
|
+
if (endpoint.schema) {
|
|
454
|
+
return action.meta.promise.then(input => normalizr.denormalize(input, endpoint.schema, {}, args));
|
|
455
|
+
}
|
|
456
|
+
return action.meta.promise;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
exports.Controller = Controller;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const FETCH_TYPE = 'rest-hooks/fetch';
|
|
2
|
+
// TODO(breaking): deprecate this
|
|
3
|
+
export const RECEIVE_TYPE = 'rest-hooks/receive';
|
|
4
|
+
export const SET_TYPE = RECEIVE_TYPE;
|
|
5
|
+
export const OPTIMISTIC_TYPE = 'rest-hooks/optimistic';
|
|
6
|
+
export const RESET_TYPE = 'rest-hooks/reset';
|
|
7
|
+
export const SUBSCRIBE_TYPE = 'rest-hooks/subscribe';
|
|
8
|
+
export const UNSUBSCRIBE_TYPE = 'rest-hook/unsubscribe';
|
|
9
|
+
export const INVALIDATE_TYPE = 'rest-hooks/invalidate';
|
|
10
|
+
export const INVALIDATEALL_TYPE = 'rest-hooks/invalidateall';
|
|
11
|
+
export const GC_TYPE = 'rest-hooks/gc';
|
|
12
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJGRVRDSF9UWVBFIiwiUkVDRUlWRV9UWVBFIiwiU0VUX1RZUEUiLCJPUFRJTUlTVElDX1RZUEUiLCJSRVNFVF9UWVBFIiwiU1VCU0NSSUJFX1RZUEUiLCJVTlNVQlNDUklCRV9UWVBFIiwiSU5WQUxJREFURV9UWVBFIiwiSU5WQUxJREFURUFMTF9UWVBFIiwiR0NfVFlQRSJdLCJzb3VyY2VzIjpbIi4uL3NyYy9hY3Rpb25UeXBlcy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgRkVUQ0hfVFlQRSA9ICdyZXN0LWhvb2tzL2ZldGNoJyBhcyBjb25zdDtcbi8vIFRPRE8oYnJlYWtpbmcpOiBkZXByZWNhdGUgdGhpc1xuZXhwb3J0IGNvbnN0IF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