@frontegg/redux-store 7.78.0-alpha.1 → 7.78.0-alpha.2

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.78.0-alpha.1
1
+ /** @license Frontegg v7.78.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/mocks/index.d.ts CHANGED
@@ -45,7 +45,12 @@ declare const buildMockActions: (store: FronteggState, api: RestApi, actions: Sh
45
45
  };
46
46
  subscriptionsActions: import("..").SubscriptionsActions;
47
47
  subscriptionsStateActions: import("..").SubscriptionsStateActions;
48
- vendorActions: import("..").VendorActions;
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
+ };
49
54
  auditsActions: {
50
55
  setAuditsMetadataState: (state: Partial<import("..").AuditsMetadataState>) => void;
51
56
  resetAuditsMetadataState: () => void;
@@ -1,2 +1,7 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
- export declare const buildVendorActions: (store: FronteggState, api: RestApi, actions: SharedActions) => import("../../vendor").VendorActions;
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
+ };
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.78.0-alpha.1
1
+ /** @license Frontegg v7.78.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -6,28 +6,41 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _helpers = require("../../helpers");
10
- var _default = (store, api, actions) => {
9
+ var _state = require("./state");
10
+ var _helpers = require("../helpers");
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
+ };
11
18
  const loadVendorPublicInfo = async payload => {
12
- actions.setVendorState({
19
+ setVendorState({
13
20
  loading: true
14
21
  });
15
22
  try {
16
23
  var _vendorInfo$whiteLabe;
17
24
  const vendorInfo = await (0, _helpers.retryIfNeeded)(() => api.vendor.getVendorPublicInfo(), payload == null ? void 0 : payload.retryConfig);
18
25
  vendorInfo.whiteLabelMode = (_vendorInfo$whiteLabe = vendorInfo.whiteLabelMode) != null ? _vendorInfo$whiteLabe : false;
19
- actions.setVendorState((0, _extends2.default)({}, vendorInfo, {
26
+ setVendorState((0, _extends2.default)({}, vendorInfo, {
20
27
  loading: false
21
28
  }));
22
29
  } catch (e) {
23
- actions.setVendorState({
30
+ setVendorState({
24
31
  loading: false
25
32
  });
26
33
  console.error('failed to getVendorPublicInfo - ', e);
27
34
  }
28
35
  };
29
36
  return {
30
- loadVendorPublicInfo
37
+ setVendorState,
38
+ resetVendorState,
39
+ loadVendorPublicInfo,
40
+ /**
41
+ * @deprecated use loadVendorPublicInfo instead
42
+ */
43
+ loadVendorPublicConfiguration: loadVendorPublicInfo
31
44
  };
32
45
  };
33
46
  exports.default = _default;
@@ -4,10 +4,6 @@ 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
- };
11
7
  Object.defineProperty(exports, "buildVendorActions", {
12
8
  enumerable: true,
13
9
  get: function () {
@@ -21,16 +17,4 @@ Object.defineProperty(exports, "createVendorState", {
21
17
  }
22
18
  });
23
19
  var _state = _interopRequireDefault(require("./state"));
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
- });
20
+ var _actions = _interopRequireDefault(require("./actions"));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "7.78.0-alpha.1",
3
+ "version": "7.78.0-alpha.2",
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.78.0-alpha.1",
10
+ "@frontegg/rest-api": "7.78.0-alpha.2",
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,12 @@
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;
@@ -1,25 +1,38 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { retryIfNeeded } from '../../helpers';
3
- export default ((store, api, actions) => {
2
+ import { initialState } from './state';
3
+ import { deepResetState, retryIfNeeded } from '../helpers';
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
+ };
4
11
  const loadVendorPublicInfo = async payload => {
5
- actions.setVendorState({
12
+ setVendorState({
6
13
  loading: true
7
14
  });
8
15
  try {
9
16
  var _vendorInfo$whiteLabe;
10
17
  const vendorInfo = await retryIfNeeded(() => api.vendor.getVendorPublicInfo(), payload == null ? void 0 : payload.retryConfig);
11
18
  vendorInfo.whiteLabelMode = (_vendorInfo$whiteLabe = vendorInfo.whiteLabelMode) != null ? _vendorInfo$whiteLabe : false;
12
- actions.setVendorState(_extends({}, vendorInfo, {
19
+ setVendorState(_extends({}, vendorInfo, {
13
20
  loading: false
14
21
  }));
15
22
  } catch (e) {
16
- actions.setVendorState({
23
+ setVendorState({
17
24
  loading: false
18
25
  });
19
26
  console.error('failed to getVendorPublicInfo - ', e);
20
27
  }
21
28
  };
22
29
  return {
23
- loadVendorPublicInfo
30
+ setVendorState,
31
+ resetVendorState,
32
+ loadVendorPublicInfo,
33
+ /**
34
+ * @deprecated use loadVendorPublicInfo instead
35
+ */
36
+ loadVendorPublicConfiguration: loadVendorPublicInfo
24
37
  };
25
38
  });
package/vendor/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import createVendorState from './state';
2
2
  import buildVendorActions from './actions';
3
3
  export { createVendorState, buildVendorActions };
4
- export * from './interfaces';
4
+ export type VendorActions = ReturnType<typeof buildVendorActions>;
package/vendor/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import createVendorState from './state';
2
2
  import buildVendorActions from './actions';
3
- export { createVendorState, buildVendorActions };
4
- export * from './interfaces';
3
+ export { createVendorState, buildVendorActions };
@@ -1,4 +1,3 @@
1
- import { WithRetryConfig } from '../interfaces';
2
1
  export interface VendorState {
3
2
  loading: boolean;
4
3
  name?: string;
@@ -6,15 +5,3 @@ export interface VendorState {
6
5
  icon?: string;
7
6
  whiteLabelMode?: boolean;
8
7
  }
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
- }
@@ -1,43 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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;
@@ -1,4 +0,0 @@
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]>>;
@@ -1,37 +0,0 @@
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,4 +0,0 @@
1
- import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
- import { AsyncVendorActions } from '../interfaces';
3
- declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => AsyncVendorActions;
4
- export default _default;
@@ -1,4 +0,0 @@
1
- import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
- import { VendorActions } from '../interfaces';
3
- declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => VendorActions;
4
- export default _default;
@@ -1,22 +0,0 @@
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
- });