@frontegg/redux-store 7.77.0 → 7.78.0-alpha.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/auth/ForgotPasswordState/actions.js +3 -3
- package/auth/ForgotPasswordState/interfaces.d.ts +2 -1
- package/auth/ForgotPasswordState/interfaces.js +2 -1
- package/index.js +1 -1
- package/mocks/index.d.ts +1 -6
- package/mocks/vendor-mocks/index.d.ts +1 -6
- package/node/auth/ForgotPasswordState/actions.js +3 -3
- package/node/auth/ForgotPasswordState/interfaces.js +2 -1
- package/node/index.js +1 -1
- package/node/toolkit/loadDynamicAction.js +43 -0
- package/node/vendor/{actions.js → actions/actions.js} +6 -19
- package/node/vendor/actions/index.js +31 -0
- package/node/vendor/index.js +17 -1
- package/package.json +2 -2
- package/toolkit/loadDynamicAction.d.ts +4 -0
- package/toolkit/loadDynamicAction.js +37 -0
- package/vendor/actions/actions.d.ts +4 -0
- package/vendor/{actions.js → actions/actions.js} +6 -19
- package/vendor/actions/index.d.ts +4 -0
- package/vendor/actions/index.js +22 -0
- package/vendor/index.d.ts +1 -1
- package/vendor/index.js +2 -1
- package/vendor/interfaces.d.ts +13 -0
- package/vendor/actions.d.ts +0 -12
|
@@ -22,7 +22,7 @@ export default ((store, api, sharedActions) => {
|
|
|
22
22
|
setForgotPasswordState({
|
|
23
23
|
loading: false,
|
|
24
24
|
error: undefined,
|
|
25
|
-
step: ForgotPasswordStep.
|
|
25
|
+
step: ForgotPasswordStep.forgotPasswordEmailSuccess
|
|
26
26
|
});
|
|
27
27
|
(_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload, true);
|
|
28
28
|
} catch (e) {
|
|
@@ -50,7 +50,7 @@ export default ((store, api, sharedActions) => {
|
|
|
50
50
|
setForgotPasswordState({
|
|
51
51
|
loading: false,
|
|
52
52
|
error: undefined,
|
|
53
|
-
step: ForgotPasswordStep.
|
|
53
|
+
step: ForgotPasswordStep.forgotPasswordEmailSuccess
|
|
54
54
|
});
|
|
55
55
|
} catch (e) {
|
|
56
56
|
setForgotPasswordState({
|
|
@@ -175,7 +175,7 @@ export default ((store, api, sharedActions) => {
|
|
|
175
175
|
setForgotPasswordState({
|
|
176
176
|
loading: false,
|
|
177
177
|
error: undefined,
|
|
178
|
-
step: ForgotPasswordStep.
|
|
178
|
+
step: ForgotPasswordStep.resetPasswordSuccess
|
|
179
179
|
});
|
|
180
180
|
callback == null ? void 0 : callback(true);
|
|
181
181
|
} catch (e) {
|
|
@@ -5,7 +5,8 @@ export declare enum ForgotPasswordStep {
|
|
|
5
5
|
'resetPasswordViaSms' = "resetPasswordViaSms",
|
|
6
6
|
'passwordRecoverySelector' = "passwordRecoverySelector",
|
|
7
7
|
'resetPasswordPage' = "resetPasswordPage",
|
|
8
|
-
'
|
|
8
|
+
'forgotPasswordEmailSuccess' = "forgotPasswordEmailSuccess",
|
|
9
|
+
'resetPasswordSuccess' = "resetPasswordSuccess"
|
|
9
10
|
}
|
|
10
11
|
export interface TestConfig {
|
|
11
12
|
allowPassphrases: boolean;
|
|
@@ -4,5 +4,6 @@ export let ForgotPasswordStep;
|
|
|
4
4
|
ForgotPasswordStep["resetPasswordViaSms"] = "resetPasswordViaSms";
|
|
5
5
|
ForgotPasswordStep["passwordRecoverySelector"] = "passwordRecoverySelector";
|
|
6
6
|
ForgotPasswordStep["resetPasswordPage"] = "resetPasswordPage";
|
|
7
|
-
ForgotPasswordStep["
|
|
7
|
+
ForgotPasswordStep["forgotPasswordEmailSuccess"] = "forgotPasswordEmailSuccess";
|
|
8
|
+
ForgotPasswordStep["resetPasswordSuccess"] = "resetPasswordSuccess";
|
|
8
9
|
})(ForgotPasswordStep || (ForgotPasswordStep = {}));
|
package/index.js
CHANGED
package/mocks/index.d.ts
CHANGED
|
@@ -45,12 +45,7 @@ declare const buildMockActions: (store: FronteggState, api: RestApi, actions: Sh
|
|
|
45
45
|
};
|
|
46
46
|
subscriptionsActions: import("..").SubscriptionsActions;
|
|
47
47
|
subscriptionsStateActions: import("..").SubscriptionsStateActions;
|
|
48
|
-
vendorActions:
|
|
49
|
-
setVendorState: (state: Partial<import("..").VendorState>) => void;
|
|
50
|
-
resetVendorState: () => void;
|
|
51
|
-
loadVendorPublicInfo: (payload?: import("../interfaces").WithRetryConfig<{}>) => Promise<void>;
|
|
52
|
-
loadVendorPublicConfiguration: (payload?: import("../interfaces").WithRetryConfig<{}>) => Promise<void>;
|
|
53
|
-
};
|
|
48
|
+
vendorActions: import("..").VendorActions;
|
|
54
49
|
auditsActions: {
|
|
55
50
|
setAuditsMetadataState: (state: Partial<import("..").AuditsMetadataState>) => void;
|
|
56
51
|
resetAuditsMetadataState: () => void;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import { FronteggState, RestApi, SharedActions } from '../../interfaces';
|
|
2
|
-
export declare const buildVendorActions: (store: FronteggState, api: RestApi, actions: SharedActions) =>
|
|
3
|
-
setVendorState: (state: Partial<import("../..").VendorState>) => void;
|
|
4
|
-
resetVendorState: () => void;
|
|
5
|
-
loadVendorPublicInfo: (payload?: import("../../interfaces").WithRetryConfig<{}>) => Promise<void>;
|
|
6
|
-
loadVendorPublicConfiguration: (payload?: import("../../interfaces").WithRetryConfig<{}>) => Promise<void>;
|
|
7
|
-
};
|
|
2
|
+
export declare const buildVendorActions: (store: FronteggState, api: RestApi, actions: SharedActions) => import("../../vendor").VendorActions;
|
|
@@ -29,7 +29,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
29
29
|
setForgotPasswordState({
|
|
30
30
|
loading: false,
|
|
31
31
|
error: undefined,
|
|
32
|
-
step: _interfaces.ForgotPasswordStep.
|
|
32
|
+
step: _interfaces.ForgotPasswordStep.forgotPasswordEmailSuccess
|
|
33
33
|
});
|
|
34
34
|
(_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload, true);
|
|
35
35
|
} catch (e) {
|
|
@@ -57,7 +57,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
57
57
|
setForgotPasswordState({
|
|
58
58
|
loading: false,
|
|
59
59
|
error: undefined,
|
|
60
|
-
step: _interfaces.ForgotPasswordStep.
|
|
60
|
+
step: _interfaces.ForgotPasswordStep.forgotPasswordEmailSuccess
|
|
61
61
|
});
|
|
62
62
|
} catch (e) {
|
|
63
63
|
setForgotPasswordState({
|
|
@@ -182,7 +182,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
182
182
|
setForgotPasswordState({
|
|
183
183
|
loading: false,
|
|
184
184
|
error: undefined,
|
|
185
|
-
step: _interfaces.ForgotPasswordStep.
|
|
185
|
+
step: _interfaces.ForgotPasswordStep.resetPasswordSuccess
|
|
186
186
|
});
|
|
187
187
|
callback == null ? void 0 : callback(true);
|
|
188
188
|
} catch (e) {
|
|
@@ -11,5 +11,6 @@ exports.ForgotPasswordStep = ForgotPasswordStep;
|
|
|
11
11
|
ForgotPasswordStep["resetPasswordViaSms"] = "resetPasswordViaSms";
|
|
12
12
|
ForgotPasswordStep["passwordRecoverySelector"] = "passwordRecoverySelector";
|
|
13
13
|
ForgotPasswordStep["resetPasswordPage"] = "resetPasswordPage";
|
|
14
|
-
ForgotPasswordStep["
|
|
14
|
+
ForgotPasswordStep["forgotPasswordEmailSuccess"] = "forgotPasswordEmailSuccess";
|
|
15
|
+
ForgotPasswordStep["resetPasswordSuccess"] = "resetPasswordSuccess";
|
|
15
16
|
})(ForgotPasswordStep || (exports.ForgotPasswordStep = ForgotPasswordStep = {}));
|
package/node/index.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadDynamicAction = loadDynamicAction;
|
|
7
|
+
/** Global caches so *all* lazy actions that share the same loader
|
|
8
|
+
* reuse the same import() and the same built-actions object */
|
|
9
|
+
const moduleCache = new WeakMap();
|
|
10
|
+
const actionsCache = new WeakMap();
|
|
11
|
+
function loadDynamicAction(store, api, shared, loader, key) {
|
|
12
|
+
/** step ① import() once per loader function */
|
|
13
|
+
function getModule() {
|
|
14
|
+
let p = moduleCache.get(loader);
|
|
15
|
+
if (!p) {
|
|
16
|
+
p = loader(); // dynamic import
|
|
17
|
+
moduleCache.set(loader, p);
|
|
18
|
+
}
|
|
19
|
+
return p;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** step ② build actions once per (store, loader) combo */
|
|
23
|
+
async function getActions() {
|
|
24
|
+
let perStore = actionsCache.get(store);
|
|
25
|
+
if (!perStore) {
|
|
26
|
+
perStore = new WeakMap();
|
|
27
|
+
actionsCache.set(store, perStore);
|
|
28
|
+
}
|
|
29
|
+
let acts = perStore.get(loader);
|
|
30
|
+
if (!acts) {
|
|
31
|
+
const mod = await getModule();
|
|
32
|
+
acts = mod.default(store, api, shared); // 👈 pass sharedActions here
|
|
33
|
+
perStore.set(loader, acts);
|
|
34
|
+
}
|
|
35
|
+
return acts;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ----- the proxy function returned to the slice ----- */
|
|
39
|
+
return async (...args) => {
|
|
40
|
+
const fn = (await getActions())[key];
|
|
41
|
+
return fn(...args);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -6,41 +6,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _default = (store, api, sharedActions) => {
|
|
12
|
-
const setVendorState = state => {
|
|
13
|
-
Object.assign(store.vendor, state);
|
|
14
|
-
};
|
|
15
|
-
const resetVendorState = () => {
|
|
16
|
-
(0, _helpers.deepResetState)(store, ['vendor'], _state.initialState);
|
|
17
|
-
};
|
|
9
|
+
var _helpers = require("../../helpers");
|
|
10
|
+
var _default = (store, api, actions) => {
|
|
18
11
|
const loadVendorPublicInfo = async payload => {
|
|
19
|
-
setVendorState({
|
|
12
|
+
actions.setVendorState({
|
|
20
13
|
loading: true
|
|
21
14
|
});
|
|
22
15
|
try {
|
|
23
16
|
var _vendorInfo$whiteLabe;
|
|
24
17
|
const vendorInfo = await (0, _helpers.retryIfNeeded)(() => api.vendor.getVendorPublicInfo(), payload == null ? void 0 : payload.retryConfig);
|
|
25
18
|
vendorInfo.whiteLabelMode = (_vendorInfo$whiteLabe = vendorInfo.whiteLabelMode) != null ? _vendorInfo$whiteLabe : false;
|
|
26
|
-
setVendorState((0, _extends2.default)({}, vendorInfo, {
|
|
19
|
+
actions.setVendorState((0, _extends2.default)({}, vendorInfo, {
|
|
27
20
|
loading: false
|
|
28
21
|
}));
|
|
29
22
|
} catch (e) {
|
|
30
|
-
setVendorState({
|
|
23
|
+
actions.setVendorState({
|
|
31
24
|
loading: false
|
|
32
25
|
});
|
|
33
26
|
console.error('failed to getVendorPublicInfo - ', e);
|
|
34
27
|
}
|
|
35
28
|
};
|
|
36
29
|
return {
|
|
37
|
-
|
|
38
|
-
resetVendorState,
|
|
39
|
-
loadVendorPublicInfo,
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated use loadVendorPublicInfo instead
|
|
42
|
-
*/
|
|
43
|
-
loadVendorPublicConfiguration: loadVendorPublicInfo
|
|
30
|
+
loadVendorPublicInfo
|
|
44
31
|
};
|
|
45
32
|
};
|
|
46
33
|
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _helpers = require("../../helpers");
|
|
8
|
+
var _state = require("../state");
|
|
9
|
+
var _loadDynamicAction = require("../../toolkit/loadDynamicAction");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
var _default = (store, api, actions) => {
|
|
13
|
+
const setVendorState = state => {
|
|
14
|
+
Object.assign(store.vendor, state);
|
|
15
|
+
};
|
|
16
|
+
const resetVendorState = () => {
|
|
17
|
+
(0, _helpers.deepResetState)(store, ['vendor'], _state.initialState);
|
|
18
|
+
};
|
|
19
|
+
const actionsLoader = () => Promise.resolve().then(() => _interopRequireWildcard(require('./actions')));
|
|
20
|
+
const loadVendorPublicInfo = (0, _loadDynamicAction.loadDynamicAction)(store, api, actions, actionsLoader, 'loadVendorPublicInfo');
|
|
21
|
+
return {
|
|
22
|
+
setVendorState,
|
|
23
|
+
resetVendorState,
|
|
24
|
+
loadVendorPublicInfo,
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated use loadVendorPublicInfo instead
|
|
27
|
+
*/
|
|
28
|
+
loadVendorPublicConfiguration: loadVendorPublicInfo
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.default = _default;
|
package/node/vendor/index.js
CHANGED
|
@@ -4,6 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
createVendorState: true,
|
|
9
|
+
buildVendorActions: true
|
|
10
|
+
};
|
|
7
11
|
Object.defineProperty(exports, "buildVendorActions", {
|
|
8
12
|
enumerable: true,
|
|
9
13
|
get: function () {
|
|
@@ -17,4 +21,16 @@ Object.defineProperty(exports, "createVendorState", {
|
|
|
17
21
|
}
|
|
18
22
|
});
|
|
19
23
|
var _state = _interopRequireDefault(require("./state"));
|
|
20
|
-
var _actions = _interopRequireDefault(require("./actions"));
|
|
24
|
+
var _actions = _interopRequireDefault(require("./actions"));
|
|
25
|
+
var _interfaces = require("./interfaces");
|
|
26
|
+
Object.keys(_interfaces).forEach(function (key) {
|
|
27
|
+
if (key === "default" || key === "__esModule") return;
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
+
if (key in exports && exports[key] === _interfaces[key]) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _interfaces[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.78.0-alpha.1",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
9
|
"@frontegg/entitlements-javascript-commons": "1.1.2",
|
|
10
|
-
"@frontegg/rest-api": "7.
|
|
10
|
+
"@frontegg/rest-api": "7.78.0-alpha.1",
|
|
11
11
|
"fast-deep-equal": "3.1.3",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"proxy-compare": "^3.0.0",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FronteggState, RestApi, SharedActions } from '../interfaces';
|
|
2
|
+
export declare function loadDynamicAction<TMod extends {
|
|
3
|
+
default: (s: FronteggState, a: RestApi, sh: SharedActions) => TActs;
|
|
4
|
+
}, TActs extends Record<string, (...args: any[]) => any>, K extends keyof TActs>(store: FronteggState, api: RestApi, shared: SharedActions, loader: () => Promise<TMod>, key: K): (...args: Parameters<TActs[K]>) => Promise<ReturnType<TActs[K]>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Global caches so *all* lazy actions that share the same loader
|
|
2
|
+
* reuse the same import() and the same built-actions object */
|
|
3
|
+
const moduleCache = new WeakMap();
|
|
4
|
+
const actionsCache = new WeakMap();
|
|
5
|
+
export function loadDynamicAction(store, api, shared, loader, key) {
|
|
6
|
+
/** step ① import() once per loader function */
|
|
7
|
+
function getModule() {
|
|
8
|
+
let p = moduleCache.get(loader);
|
|
9
|
+
if (!p) {
|
|
10
|
+
p = loader(); // dynamic import
|
|
11
|
+
moduleCache.set(loader, p);
|
|
12
|
+
}
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** step ② build actions once per (store, loader) combo */
|
|
17
|
+
async function getActions() {
|
|
18
|
+
let perStore = actionsCache.get(store);
|
|
19
|
+
if (!perStore) {
|
|
20
|
+
perStore = new WeakMap();
|
|
21
|
+
actionsCache.set(store, perStore);
|
|
22
|
+
}
|
|
23
|
+
let acts = perStore.get(loader);
|
|
24
|
+
if (!acts) {
|
|
25
|
+
const mod = await getModule();
|
|
26
|
+
acts = mod.default(store, api, shared); // 👈 pass sharedActions here
|
|
27
|
+
perStore.set(loader, acts);
|
|
28
|
+
}
|
|
29
|
+
return acts;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* ----- the proxy function returned to the slice ----- */
|
|
33
|
+
return async (...args) => {
|
|
34
|
+
const fn = (await getActions())[key];
|
|
35
|
+
return fn(...args);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export default ((store, api, sharedActions) => {
|
|
5
|
-
const setVendorState = state => {
|
|
6
|
-
Object.assign(store.vendor, state);
|
|
7
|
-
};
|
|
8
|
-
const resetVendorState = () => {
|
|
9
|
-
deepResetState(store, ['vendor'], initialState);
|
|
10
|
-
};
|
|
2
|
+
import { retryIfNeeded } from '../../helpers';
|
|
3
|
+
export default ((store, api, actions) => {
|
|
11
4
|
const loadVendorPublicInfo = async payload => {
|
|
12
|
-
setVendorState({
|
|
5
|
+
actions.setVendorState({
|
|
13
6
|
loading: true
|
|
14
7
|
});
|
|
15
8
|
try {
|
|
16
9
|
var _vendorInfo$whiteLabe;
|
|
17
10
|
const vendorInfo = await retryIfNeeded(() => api.vendor.getVendorPublicInfo(), payload == null ? void 0 : payload.retryConfig);
|
|
18
11
|
vendorInfo.whiteLabelMode = (_vendorInfo$whiteLabe = vendorInfo.whiteLabelMode) != null ? _vendorInfo$whiteLabe : false;
|
|
19
|
-
setVendorState(_extends({}, vendorInfo, {
|
|
12
|
+
actions.setVendorState(_extends({}, vendorInfo, {
|
|
20
13
|
loading: false
|
|
21
14
|
}));
|
|
22
15
|
} catch (e) {
|
|
23
|
-
setVendorState({
|
|
16
|
+
actions.setVendorState({
|
|
24
17
|
loading: false
|
|
25
18
|
});
|
|
26
19
|
console.error('failed to getVendorPublicInfo - ', e);
|
|
27
20
|
}
|
|
28
21
|
};
|
|
29
22
|
return {
|
|
30
|
-
|
|
31
|
-
resetVendorState,
|
|
32
|
-
loadVendorPublicInfo,
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use loadVendorPublicInfo instead
|
|
35
|
-
*/
|
|
36
|
-
loadVendorPublicConfiguration: loadVendorPublicInfo
|
|
23
|
+
loadVendorPublicInfo
|
|
37
24
|
};
|
|
38
25
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { deepResetState } from '../../helpers';
|
|
2
|
+
import { initialState } from '../state';
|
|
3
|
+
import { loadDynamicAction } from '../../toolkit/loadDynamicAction';
|
|
4
|
+
export default ((store, api, actions) => {
|
|
5
|
+
const setVendorState = state => {
|
|
6
|
+
Object.assign(store.vendor, state);
|
|
7
|
+
};
|
|
8
|
+
const resetVendorState = () => {
|
|
9
|
+
deepResetState(store, ['vendor'], initialState);
|
|
10
|
+
};
|
|
11
|
+
const actionsLoader = () => import('./actions');
|
|
12
|
+
const loadVendorPublicInfo = loadDynamicAction(store, api, actions, actionsLoader, 'loadVendorPublicInfo');
|
|
13
|
+
return {
|
|
14
|
+
setVendorState,
|
|
15
|
+
resetVendorState,
|
|
16
|
+
loadVendorPublicInfo,
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated use loadVendorPublicInfo instead
|
|
19
|
+
*/
|
|
20
|
+
loadVendorPublicConfiguration: loadVendorPublicInfo
|
|
21
|
+
};
|
|
22
|
+
});
|
package/vendor/index.d.ts
CHANGED
package/vendor/index.js
CHANGED
package/vendor/interfaces.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WithRetryConfig } from '../interfaces';
|
|
1
2
|
export interface VendorState {
|
|
2
3
|
loading: boolean;
|
|
3
4
|
name?: string;
|
|
@@ -5,3 +6,15 @@ export interface VendorState {
|
|
|
5
6
|
icon?: string;
|
|
6
7
|
whiteLabelMode?: boolean;
|
|
7
8
|
}
|
|
9
|
+
export interface AsyncVendorActions {
|
|
10
|
+
loadVendorPublicInfo: (payload?: WithRetryConfig<{}>) => Promise<void>;
|
|
11
|
+
[key: string]: (...args: any[]) => any;
|
|
12
|
+
}
|
|
13
|
+
export interface VendorActions extends AsyncVendorActions {
|
|
14
|
+
setVendorState: (state: Partial<VendorState>) => void;
|
|
15
|
+
resetVendorState: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use loadVendorPublicInfo instead
|
|
18
|
+
*/
|
|
19
|
+
loadVendorPublicConfiguration: (payload?: WithRetryConfig<{}>) => Promise<void>;
|
|
20
|
+
}
|
package/vendor/actions.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FronteggState, RestApi, SharedActions, WithRetryConfig } from '../interfaces';
|
|
2
|
-
import { VendorState } from './interfaces';
|
|
3
|
-
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
4
|
-
setVendorState: (state: Partial<VendorState>) => void;
|
|
5
|
-
resetVendorState: () => void;
|
|
6
|
-
loadVendorPublicInfo: (payload?: WithRetryConfig<{}>) => Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated use loadVendorPublicInfo instead
|
|
9
|
-
*/
|
|
10
|
-
loadVendorPublicConfiguration: (payload?: WithRetryConfig<{}>) => Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|