@zeniai/client-epic-state 5.3.6 → 5.3.7-betaRD0
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/lib/entity/tenant/epic/fetchAllTenantsEpic.js +45 -38
- package/lib/esm/entity/tenant/epic/fetchAllTenantsEpic.js +46 -39
- package/lib/esm/index.js +2 -2
- package/lib/esm/init.js +14 -3
- package/lib/esm/sessionEndpointsLoader.js +7 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +53 -51
- package/lib/init.d.ts +9 -0
- package/lib/init.js +17 -4
- package/lib/sessionEndpointsLoader.d.ts +9 -0
- package/lib/sessionEndpointsLoader.js +11 -0
- package/lib/tsconfig.mocks.tsbuildinfo +1 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/zeniAPI.d.ts +2 -2
- package/package.json +26 -1
package/lib/init.js
CHANGED
|
@@ -36,9 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.injectFeatureEpics = exports.injectFeatureModules = exports.store = exports.pusher = exports.initializePusher = exports.disconnectPusher = exports.zeniAPI = void 0;
|
|
39
|
+
exports.injectFeatureEpics = exports.injectFeatureModules = exports.store = exports.pusher = exports.initializePusher = exports.disconnectPusher = exports.setSessionEndpointsLoader = exports.zeniAPI = void 0;
|
|
40
40
|
exports.default = initialize;
|
|
41
41
|
exports.updateZeniAPIClientConfig = updateZeniAPIClientConfig;
|
|
42
|
+
exports.updateZeniAPIEndpoints = updateZeniAPIEndpoints;
|
|
42
43
|
exports.zeniAPIClientConfig = zeniAPIClientConfig;
|
|
43
44
|
exports.initializeWithNewStore = initializeWithNewStore;
|
|
44
45
|
exports.initialize3rdPartyExtensions = initialize3rdPartyExtensions;
|
|
@@ -47,6 +48,8 @@ const zeniAPI_1 = require("./zeniAPI");
|
|
|
47
48
|
const zeniAPIClientState_1 = require("./zeniAPIClientState");
|
|
48
49
|
var zeniAPIClientState_2 = require("./zeniAPIClientState");
|
|
49
50
|
Object.defineProperty(exports, "zeniAPI", { enumerable: true, get: function () { return zeniAPIClientState_2.zeniAPI; } });
|
|
51
|
+
var sessionEndpointsLoader_1 = require("./sessionEndpointsLoader");
|
|
52
|
+
Object.defineProperty(exports, "setSessionEndpointsLoader", { enumerable: true, get: function () { return sessionEndpointsLoader_1.setSessionEndpointsLoader; } });
|
|
50
53
|
var pusherClient_1 = require("./pusherClient");
|
|
51
54
|
Object.defineProperty(exports, "disconnectPusher", { enumerable: true, get: function () { return pusherClient_1.disconnectPusher; } });
|
|
52
55
|
Object.defineProperty(exports, "initializePusher", { enumerable: true, get: function () { return pusherClient_1.initializePusher; } });
|
|
@@ -60,11 +63,10 @@ let initialized = false;
|
|
|
60
63
|
*/
|
|
61
64
|
function initialize(restEndPoints, userId, sessionId, tenantId, isSandboxEnv, onSessionInvalidated) {
|
|
62
65
|
if (initialized) {
|
|
63
|
-
console.warn(
|
|
66
|
+
console.warn('client-epic-state is already initialized');
|
|
64
67
|
return exports.store;
|
|
65
68
|
}
|
|
66
69
|
initialized = true;
|
|
67
|
-
console.info(`initializing with ${JSON.stringify(restEndPoints)}`);
|
|
68
70
|
initialize3rdPartyExtensions();
|
|
69
71
|
(0, zeniAPIClientState_1.setZeniAPIClient)(new zeniAPI_1.ZeniAPIClient(restEndPoints, userId, sessionId, tenantId, onSessionInvalidated));
|
|
70
72
|
exports.store = (0, configureStore_1.default)(zeniAPIClientState_1.zeniAPI, isSandboxEnv);
|
|
@@ -84,6 +86,18 @@ Object.defineProperty(exports, "injectFeatureEpics", { enumerable: true, get: fu
|
|
|
84
86
|
function updateZeniAPIClientConfig(userId, sessionId, tenantId) {
|
|
85
87
|
zeniAPIClientState_1.zeniAPI.update(userId, sessionId, tenantId);
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Replace the REST endpoints the API client calls. Epics read the endpoints
|
|
91
|
+
* at request time, so every request made after this uses the new ones.
|
|
92
|
+
* Note: This version SHOULD BE used only in the client side.
|
|
93
|
+
* @param restEndPoints
|
|
94
|
+
*/
|
|
95
|
+
function updateZeniAPIEndpoints(restEndPoints) {
|
|
96
|
+
if (zeniAPIClientState_1.zeniAPI == null) {
|
|
97
|
+
throw new Error('Call initialize() before updateZeniAPIEndpoints()');
|
|
98
|
+
}
|
|
99
|
+
zeniAPIClientState_1.zeniAPI.apiEndPoints = restEndPoints;
|
|
100
|
+
}
|
|
87
101
|
/**
|
|
88
102
|
* Returns current Zeni REST API client config.
|
|
89
103
|
* @returns
|
|
@@ -110,7 +124,6 @@ function zeniAPIClientConfig() {
|
|
|
110
124
|
* @param tenantId tenant id
|
|
111
125
|
*/
|
|
112
126
|
async function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
|
|
113
|
-
console.info(`initializeWithNewStore with ${JSON.stringify(restEndPoints)}`);
|
|
114
127
|
initialize3rdPartyExtensions();
|
|
115
128
|
const zeniHttpClient = new zeniAPI_1.ZeniAPIClient(restEndPoints, userId, sessionId, tenantId);
|
|
116
129
|
const store = (0, configureStore_1.default)(zeniHttpClient, false);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Called after sign-in, before the user's tenants are fetched. The app uses it
|
|
3
|
+
* to fetch the endpoints that are only served to a signed-in session and to
|
|
4
|
+
* hand them to `updateZeniAPIEndpoints`. Without a loader, tenants are fetched
|
|
5
|
+
* straight away with the endpoints given to `initialize`.
|
|
6
|
+
*/
|
|
7
|
+
export type SessionEndpointsLoader = (userId: string, sessionId?: string) => Promise<void>;
|
|
8
|
+
export declare function setSessionEndpointsLoader(loader: SessionEndpointsLoader | undefined): void;
|
|
9
|
+
export declare function getSessionEndpointsLoader(): SessionEndpointsLoader | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setSessionEndpointsLoader = setSessionEndpointsLoader;
|
|
4
|
+
exports.getSessionEndpointsLoader = getSessionEndpointsLoader;
|
|
5
|
+
let sessionEndpointsLoader;
|
|
6
|
+
function setSessionEndpointsLoader(loader) {
|
|
7
|
+
sessionEndpointsLoader = loader;
|
|
8
|
+
}
|
|
9
|
+
function getSessionEndpointsLoader() {
|
|
10
|
+
return sessionEndpointsLoader;
|
|
11
|
+
}
|