state-decorator 6.13.1 → 6.14.0-dev.1

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/v5_test.d.ts DELETED
@@ -1,70 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) GlobalSport SAS.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- import type { StoreAction } from './types';
16
- import { setGlobalConfig, ConflictPolicy } from './index';
17
- import { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingProps, LoadingMapParallelActions, AsynchAction } from './v5_types';
18
- export { AdvancedSynchAction, AsynchActionPromiseGet, StateDecoratorAction, StateDecoratorActions, StateDecoratorOptions, AsynchActionPromise, SynchAction, LoadingMap, LoadingMapParallelActions, LoadingProps, ConflictPolicy, setGlobalConfig, };
19
- /**
20
- * Type guard function to test if an action is a asynchronous action.
21
- */
22
- export declare function isAsyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>): action is AsynchAction<S, F, A, P>;
23
- /**
24
- * Type guard function to test if an action is a asynchronous action.
25
- */
26
- export declare function isAsyncPromiseGetAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>): action is AsynchActionPromiseGet<S, F, A, P>;
27
- /**
28
- * Type guard function to test if an action is a synchronous action.
29
- */
30
- export declare function isSyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>): action is SynchAction<S, F, P>;
31
- /**
32
- * Type guard function to test if an action is a synchronous action.
33
- */
34
- export declare function isAdvancedSyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>): action is AdvancedSynchAction<S, F, A, P>;
35
- /**
36
- * Utility to test an asynchronous action.
37
- * @param action The action to test
38
- * @param test The test function that takes the discrimined action type and cam return a promise
39
- */
40
- export declare function testAsyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>, test: (action: AsynchActionPromise<S, F, A, P>) => any | Promise<any>): any;
41
- /**
42
- * Utility to test an synchronous action.
43
- * @param action The action to test
44
- * @param test The test function that takes the discrimined action type and cam return a promise
45
- */
46
- export declare function testSyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>, test: (action: SynchAction<S, F, P>) => any | Promise<any>): any;
47
- /**
48
- * Utility to test an advanced synchronous action.
49
- * @param action The action to test
50
- * @param test The test function that takes the discrimined action type and cam return a promise
51
- */
52
- export declare function testAdvancedSyncAction<S, F extends (...args: any[]) => any, A, P>(action: StateDecoratorAction<S, F, A, P>, test: (action: AdvancedSynchAction<S, F, A, P>) => any | Promise<any>): any;
53
- /**
54
- * Utility to test a V6 synchronous action using v5 test.
55
- * @param action The action to test
56
- * @param test The test function that takes the discrimined action type and cam return a promise
57
- */
58
- export declare function testV6SyncAction<S, F extends (...args: any[]) => any, A, P>(action: StoreAction<S, F, A, P>, test: (action: SynchAction<S, F, P>) => any | Promise<any>): Promise<void>;
59
- /**
60
- * Utility to test a V6 synchronous action using v5 test.
61
- * @param actionIn The action to test
62
- * @param test The test function that takes the discrimined action type and cam return a promise
63
- */
64
- export declare function testV6AdvancedSyncAction<S, F extends (...args: any[]) => any, A, P>(actionIn: StoreAction<S, F, A, P>, test: (action: AdvancedSynchAction<S, F, A, P>) => any | Promise<any>): Promise<void>;
65
- /**
66
- * Utility to test a V6 synchronous action using v5 test.
67
- * @param actionIn The action to test
68
- * @param test The test function that takes the discrimined action type and cam return a promise
69
- */
70
- export declare function testV6AsyncAction<S, F extends (...args: any[]) => any, A, P>(actionIn: StoreAction<S, F, A, P>, test: (action: AsynchAction<S, F, A, P>) => any | Promise<any>): any;
package/dist/v5_test.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("./index"),e=require("./impl"),n=function(){return(n=Object.assign||function(r){for(var e,n=1,t=arguments.length;n<t;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function t(r,e,n){if(n||2===arguments.length)for(var t,o=0,s=e.length;o<s;o++)!t&&o in e||(t||(t=Array.prototype.slice.call(e,0,o)),t[o]=e[o]);return r.concat(t||Array.prototype.slice.call(e))}function o(r){return!(r instanceof Function)&&(r.hasOwnProperty("promise")||r.hasOwnProperty("promiseGet"))}function s(r){return r instanceof Function}function i(r){return!(r instanceof Function||r.hasOwnProperty("promise")||r.hasOwnProperty("promiseGet"))}Object.defineProperty(exports,"ConflictPolicy",{enumerable:!0,get:function(){return r.ConflictPolicy}}),Object.defineProperty(exports,"setGlobalConfig",{enumerable:!0,get:function(){return r.setGlobalConfig}}),exports.isAdvancedSyncAction=i,exports.isAsyncAction=o,exports.isAsyncPromiseGetAction=function(r){return!(r instanceof Function||r.hasOwnProperty("promise")&&r.hasOwnProperty("promiseGet"))},exports.isSyncAction=s,exports.testAdvancedSyncAction=function(r,e){return i(r)?e(r):Promise.reject(new Error("This action is not a synchronous advanced action"))},exports.testAsyncAction=function(e,t){return o(e)?t(function(e){return"promiseGet"in e?n(n({},e),{promise:e.promiseGet,retryCount:3,conflictPolicy:r.ConflictPolicy.REUSE}):e}(e)):Promise.reject(new Error("This action is not an asynchronous action"))},exports.testSyncAction=function(r,e){return s(r)?e(r):Promise.reject(new Error("This action is not a synchronous action"))},exports.testV6AdvancedSyncAction=function(r,n){return e.isSyncAction(r)?(n({action:function(e,n,t){return r.effects({s:e,args:n,p:t,ds:null,derived:null,state:e,props:t,res:null,result:null,promiseId:null})},onActionDone:function(e,n,t,o,s){r.sideEffects({s:e,args:n,p:t,a:o,notifyWarning:s,ds:null,derived:null,state:e,props:t,actions:o,res:null,result:null,promiseId:null})}}),Promise.resolve()):Promise.reject(new Error("This action is not a synchronous action"))},exports.testV6AsyncAction=function(r,n){return e.isAsyncAction(r)?n({abortable:r.abortable,rejectPromiseOnError:r.rejectPromiseOnError,retryCount:r.retryCount,retryDelaySeed:r.retryDelaySeed,isTriggerRetryError:r.isTriggerRetryError,conflictPolicy:r.conflictPolicy,getPromiseId:r.getPromiseId,promise:function(n,t,o,s,i){return e.isAsyncGetPromiseAction(r)?r.getPromise({s:t,args:n,p:o,a:s,abortSignal:i,ds:null,derived:null,state:t,props:o,actions:s,promiseId:null}):r.getGetPromise({s:t,args:n,p:o,a:s,abortSignal:i,ds:null,derived:null,state:t,props:o,actions:s,promiseId:null})},promiseGet:function(n,t,o,s,i){return e.isAsyncGetPromiseGetAction(r)?r.getGetPromise({s:t,args:n,p:o,a:s,abortSignal:i,ds:null,derived:null,state:t,props:o,actions:s,promiseId:null}):null},reducer:function(e,n,t,o){return r.effects?r.effects({s:e,args:t,p:o,res:n,ds:null,derived:null,state:e,props:o,result:n,promiseId:null}):null},preReducer:function(e,n,t){return r.preEffects?r.preEffects({s:e,args:n,p:t,ds:null,derived:null,state:e,props:t,promiseId:null}):null},optimisticReducer:function(e,n,o){var s;return r.optimisticEffects?r.optimisticEffects({s:e,args:n,p:o,ds:null,derived:null,state:e,props:o,promiseId:null===(s=r.getPromiseId)||void 0===s?void 0:s.call.apply(s,t([r],n))}):null},errorReducer:function(e,n,o,s){var i;return r.errorEffects?r.errorEffects({s:e,args:o,p:s,err:n,ds:null,derived:null,state:e,props:s,error:n,promiseId:null===(i=r.getPromiseId)||void 0===i?void 0:i.call.apply(i,t([r],o))}):null},onDone:function(e,n,o,s,i,l){var c,u;null===(c=r.sideEffects)||void 0===c||c.call(r,{s:e,args:o,p:s,a:i,res:n,notifyWarning:l,ds:null,derived:null,state:e,props:s,actions:i,result:n,promiseId:null===(u=r.getPromiseId)||void 0===u?void 0:u.call.apply(u,t([r],o))})},onFail:function(e,n,o,s,i,l){var c,u;null===(c=r.errorSideEffects)||void 0===c||c.call(r,{s:e,args:o,p:s,a:i,err:n,notifyWarning:l,ds:null,derived:null,state:e,props:s,actions:i,error:n,promiseId:null===(u=r.getPromiseId)||void 0===u?void 0:u.call.apply(u,t([r],o))})},getErrorMessage:function(e,n,o){var s,i;return null===(s=r.getErrorMessage)||void 0===s?void 0:s.call(r,{err:e,p:o,args:n,ds:null,derived:null,state:null,s:null,error:e,props:o,promiseId:null===(i=r.getPromiseId)||void 0===i?void 0:i.call.apply(i,t([r],n))})},getSuccessMessage:function(e,n,o){var s,i;return null===(s=r.getSuccessMessage)||void 0===s?void 0:s.call(r,{res:e,args:n,p:o,ds:null,derived:null,state:null,s:null,result:e,props:o,promiseId:null===(i=r.getPromiseId)||void 0===i?void 0:i.call.apply(i,t([r],n))})}}):Promise.reject(new Error("This action is not a synchronous action"))},exports.testV6SyncAction=function(r,n){if(e.isSimpleSyncAction(r)){return n((function(e,n,t){return r({s:e,args:n,p:t,ds:null,derived:null,state:e,props:t,promiseId:null})})),Promise.resolve()}return Promise.reject(new Error("This action is not a synchronous action"))};
2
- //# sourceMappingURL=v5_test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v5_test.js","sources":["../../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__spreadArray","to","from","pack","ar","l","Array","slice","concat"],"mappings":"iHA+BWA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YA6HzB,SAASQ,EAAcC,EAAIC,EAAMC,GACpC,GAAIA,GAA6B,IAArBX,UAAUC,OAAc,IAAK,IAA4BW,EAAxBd,EAAI,EAAGe,EAAIH,EAAKT,OAAYH,EAAIe,EAAGf,KACxEc,GAAQd,KAAKY,IACRE,IAAIA,EAAKE,MAAMX,UAAUY,MAAMV,KAAKK,EAAM,EAAGZ,IAClDc,EAAGd,GAAKY,EAAKZ,IAGrB,OAAOW,EAAGO,OAAOJ,GAAME,MAAMX,UAAUY,MAAMV,KAAKK"}
@@ -1,227 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) GlobalSport SAS.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- import { ConflictPolicy, DecoratedActions, NotifyFunc, PromiseResult } from './types';
16
- export declare type PromiseProvider<S, F extends (...args: any[]) => any, A, P> = (args: Parameters<F>, state: S, props: P, actions: A, abortSignal: AbortSignal) => ReturnType<F> | null;
17
- /**
18
- * Simple form of a synchronous action.
19
- */
20
- export declare type SynchAction<S, F extends (...args: any[]) => any, P> = (state: S, args: Parameters<F>, props: P) => S | null;
21
- /**
22
- * Advanced synchronous action.
23
- * Allows to set advanced properties to a synchronous action.
24
- */
25
- export declare type AdvancedSynchAction<S, F extends (...args: any[]) => any, A, P> = {
26
- /**
27
- * The action to execute.
28
- */
29
- action: (state: S, args: Parameters<F>, props: P) => S | null;
30
- /**
31
- * Debounces the side effects if this parameter is defined.
32
- */
33
- debounceSideEffectsTimeout?: number;
34
- /**
35
- * Debounces the action if this parameter is defined.
36
- */
37
- debounceTimeout?: number;
38
- /**
39
- * Action to call when the action is done. Used to trigger other actions (even asynchronous),
40
- */
41
- onActionDone?: (state: S, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
42
- };
43
- export declare type PromiseIdMap = {
44
- [promiseId: string]: boolean;
45
- };
46
- export declare type InternalLoadingMap<A> = {
47
- [name: string]: undefined | boolean | PromiseIdMap;
48
- };
49
- export declare type LoadingMap<A> = {
50
- [P in keyof A]?: undefined | boolean;
51
- };
52
- export declare type LoadingMapParallelActions<A> = {
53
- [P in keyof A]?: PromiseIdMap;
54
- };
55
- export declare type LoadingProps<A> = {
56
- loading: boolean;
57
- loadingMap: LoadingMap<A>;
58
- loadingParallelMap: LoadingMapParallelActions<A>;
59
- };
60
- /**
61
- * Try to abort an action, if the action is <code>abortable</code>.
62
- * @param actionName The action name
63
- * @param promiseId If the action conflict type is <code>ConflictType.PARALLEL</code>, the identifier of the promise.
64
- * @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.
65
- */
66
- export declare type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;
67
- export declare type GetErrorMessage<F extends (...args: any[]) => any, P> = (e: any, args: Parameters<F>, props: P) => string;
68
- export interface AsynchActionBase<S, F extends (...args: any[]) => any, A, P> {
69
- /**
70
- * This action can be aborted. An abortSignal will be injected to the <code>promise</code> / <code>promiseGet</code>.
71
- */
72
- abortable?: boolean;
73
- /**
74
- * The success message to pass to the notifySuccess function passed as property to the StateDecorator.
75
- */
76
- successMessage?: string;
77
- /**
78
- * A function that provides the success message to pass to the notifySuccess function passed as property to the StateDecorator.
79
- */
80
- getSuccessMessage?: (result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P) => string;
81
- /**
82
- * The error message to pass to the notifyError function passed as property to the StateDecorator.
83
- */
84
- errorMessage?: string;
85
- /**
86
- * A function that provides the error message to pass to the notifyError function passed as property to the StateDecorator.
87
- */
88
- getErrorMessage?: GetErrorMessage<F, P>;
89
- /**
90
- * If set, called with the result of the promise to update the current state.
91
- */
92
- reducer?: (state: S, result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P) => S | null;
93
- /**
94
- * If set, called with the error of the promise to update the current state.
95
- */
96
- errorReducer?: (state: S, error: any, args: Parameters<F>, props: P) => S | null;
97
- /**
98
- * Whether reject the promise instead of handling it.
99
- */
100
- rejectPromiseOnError?: boolean;
101
- /**
102
- * Handle side effects when the request succeeded.
103
- * @param result The result of the request
104
- * @param newData The data after the reducer is applied
105
- * @param args The argument during the call of the request function
106
- * @param props The props passed to the state decorator
107
- * @param actions The actions available
108
- * @param notifyWarning If specified, a notify function to indicate that the action is a semi success (use successMessage / getSuccessMessage otherwise).
109
- */
110
- onDone?: (state: S, result: PromiseResult<ReturnType<F>>, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
111
- /**
112
- * Handle side effects when the request failed.
113
- * @param error The error of the request
114
- * @param args The argument during the call of the request function
115
- * @param props The props passed to the state decorator
116
- * @param actions The actions available
117
- * @param notifyWarning If specified, a notify function to indicate that the action is a semi failure (use errorMessage / getErrorMessage otherwise).
118
- */
119
- onFail?: (state: S, error: Error, args: Parameters<F>, props: P, actions: A, notifyWarning: NotifyFunc) => void;
120
- /**
121
- * Retrieve the state to set as current data before the promise is resolved.
122
- * If the there's no reducer, this data will be used after the promise is done.
123
- */
124
- preReducer?: (state: S, args: Parameters<F>, props: P) => S | null;
125
- /**
126
- * Retrieve the state to set as current data before the promise is resolved.
127
- * If the there's no reducer, this data will be used after the promise is done.
128
- */
129
- optimisticReducer?: (state: S, args: Parameters<F>, props: P) => S | null;
130
- /**
131
- * Policy to apply when a call to an asynchronous action is done but a previous call is still not resolved.
132
- */
133
- conflictPolicy?: ConflictPolicy;
134
- /**
135
- * Get an identifier for an action call. Used only when conflictPolicy is ConflictPolicy.PARALLEL.
136
- * This information will be available in loadingMap. loadingMap[actionName] will be an array of promise identifiers.
137
- */
138
- getPromiseId?: (...args: Parameters<F>) => string;
139
- /**
140
- * Number of retries in case of error (failed to fetch).
141
- * Do not use this if you are creating objects...
142
- * Default value is 0 (no retry).
143
- */
144
- retryCount?: number;
145
- /**
146
- * Seed of delay between each retry in milliseconds.
147
- * The applied delay is retryDelaySeed * retry count.
148
- * Default value is 1000 (1 second).
149
- */
150
- retryDelaySeed?: number;
151
- /**
152
- * Function to test if the error will trigger an action retry or will fail directly.
153
- */
154
- isTriggerRetryError?: (e: Error) => boolean;
155
- }
156
- export interface AsynchActionPromise<S, F extends (...args: any[]) => any, A, P> extends AsynchActionBase<S, F, A, P> {
157
- /**
158
- * The request, returns a promise
159
- */
160
- promise: PromiseProvider<S, F, A, P>;
161
- }
162
- export interface AsynchActionPromiseGet<S, F extends (...args: any[]) => any, A, P> extends AsynchActionBase<S, F, A, P> {
163
- /**
164
- * The request, returns a promise that is a GET request.
165
- * A shortcut to set:
166
- * - retryCount: 3
167
- * - conflictPolicy: ConflictPolicy.REUSE
168
- */
169
- promiseGet: PromiseProvider<S, F, A, P>;
170
- }
171
- export declare type AsynchAction<S, F extends (...args: any[]) => any, A, P> = AsynchActionPromise<S, F, A, P> | AsynchActionPromiseGet<S, F, A, P>;
172
- export declare type StateDecoratorAction<S, F extends (...args: any[]) => any, A, P> = AsynchAction<S, F, A, P> | SynchAction<S, F, P> | AdvancedSynchAction<S, F, A, P>;
173
- /**
174
- * S: The type of the state
175
- * A: The type of the actions to pass to the children (used to check keys only).
176
- */
177
- export declare type StateDecoratorActions<S, A extends DecoratedActions, P = {}> = {
178
- [Prop in keyof A]: StateDecoratorAction<S, A[Prop], A, P>;
179
- };
180
- declare type OnPropsChangeReducer<S, P> = (s: S, newProps: P, updatedIndices: number[]) => S;
181
- export declare type StateDecoratorOptions<S, A, P = {}> = {
182
- /**
183
- * The state decorator name. Use in debug traces to identify the useStateDecorator instance.
184
- */
185
- name?: string;
186
- /**
187
- * Show logs in the console in development mode.
188
- */
189
- logEnabled?: boolean;
190
- /**
191
- * List of action names that are marked as loading at initial time.
192
- * As a render is done before first actions can be trigerred, some actions can be marked as loading at
193
- * initial time.
194
- */
195
- initialActionsMarkedLoading?: (keyof A)[];
196
- /**
197
- * Get a list of values that will be use as reference values.
198
- * If they are different (shallow compare), onPropsChangeReducer then onPropsChange will be called.
199
- */
200
- getPropsRefValues?: (props: P) => any[];
201
- /**
202
- * Triggered when values of reference from props have changed. Allow to call actions after a prop change.
203
- */
204
- onPropsChange?: (s: S, newProps: any, actions: A, updatedIndices: number[]) => void;
205
- /**
206
- * Triggered when values of reference from props have changed. Allow to update state after a prop change.
207
- * <b>null</b> means no change.
208
- */
209
- onPropsChangeReducer?: OnPropsChangeReducer<S, P>;
210
- /**
211
- * The callback function called if an asynchronous function succeeded and a success messsage is defined.
212
- */
213
- notifySuccess?: NotifyFunc;
214
- /**
215
- * The callback function called if an asynchronous function fails and an error messsage is defined.
216
- */
217
- notifyError?: NotifyFunc;
218
- /**
219
- * The callback function injected in onDone and onFail of asynchronous functions to notify a semi success / failed request.
220
- */
221
- notifyWarning?: NotifyFunc;
222
- /**
223
- * Initial actions. They are executed outside of a side effect to trigger asynchronous actions.
224
- */
225
- onMount?: (actions: A, props: P, state: S) => void;
226
- };
227
- export {};