@zeniai/client-epic-state 4.19.33 → 4.19.35

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/esm/init.js CHANGED
@@ -105,16 +105,29 @@ export function zeniAPIClientConfig() {
105
105
  /**
106
106
  * Initialize client-epic-state with new store.
107
107
  * Should be used in the node server.
108
+ *
109
+ * Loads the full epic tree (~526 epics) so that server-side handlers
110
+ * (report generation, data fetching, etc.) have all feature epics
111
+ * available. The browser app uses `initialize()` + `injectFeatureModules()`
112
+ * instead to enable lazy loading.
113
+ *
108
114
  * @param restEndPoints rest endpoints for the micro services
109
115
  * @param userId user id
110
116
  * @param sessionId session id
111
117
  * @param tenantId tenant id
112
118
  */
113
- export function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
119
+ export async function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
114
120
  console.info(`initializeWithNewStore with ${JSON.stringify(restEndPoints)}`);
115
121
  initialize3rdPartyExtensions();
116
122
  const zeniHttpClient = new ZeniAPIClient(restEndPoints, userId, sessionId, tenantId);
117
- return configureNewStore(zeniHttpClient, false);
123
+ const store = configureNewStore(zeniHttpClient, false);
124
+ // Server-side stores need the full epic tree, not just the 24 core epics.
125
+ // Feature epics handle report generation, data fetching, etc. that the
126
+ // download server relies on. We use the store's own epicManager (not the
127
+ // module-level variable) so each store gets its own full epic subscription.
128
+ const epicModule = await import('./epic');
129
+ store.epicManager.setEpic(epicModule.default);
130
+ return store;
118
131
  }
119
132
  /**
120
133
  * Exported for testing purpose. Not intended to be used in any other place!
package/lib/init.d.ts CHANGED
@@ -49,10 +49,16 @@ export declare function zeniAPIClientConfig(): {
49
49
  /**
50
50
  * Initialize client-epic-state with new store.
51
51
  * Should be used in the node server.
52
+ *
53
+ * Loads the full epic tree (~526 epics) so that server-side handlers
54
+ * (report generation, data fetching, etc.) have all feature epics
55
+ * available. The browser app uses `initialize()` + `injectFeatureModules()`
56
+ * instead to enable lazy loading.
57
+ *
52
58
  * @param restEndPoints rest endpoints for the micro services
53
59
  * @param userId user id
54
60
  * @param sessionId session id
55
61
  * @param tenantId tenant id
56
62
  */
57
- export declare function initializeWithNewStore(restEndPoints: RESTAPIEndpoints, userId: string, sessionId: string, tenantId: string): ZeniStore;
63
+ export declare function initializeWithNewStore(restEndPoints: RESTAPIEndpoints, userId: string, sessionId: string, tenantId: string): Promise<ZeniStore>;
58
64
  export declare function initialize3rdPartyExtensions(): void;
package/lib/init.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -117,16 +150,29 @@ function zeniAPIClientConfig() {
117
150
  /**
118
151
  * Initialize client-epic-state with new store.
119
152
  * Should be used in the node server.
153
+ *
154
+ * Loads the full epic tree (~526 epics) so that server-side handlers
155
+ * (report generation, data fetching, etc.) have all feature epics
156
+ * available. The browser app uses `initialize()` + `injectFeatureModules()`
157
+ * instead to enable lazy loading.
158
+ *
120
159
  * @param restEndPoints rest endpoints for the micro services
121
160
  * @param userId user id
122
161
  * @param sessionId session id
123
162
  * @param tenantId tenant id
124
163
  */
125
- function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
164
+ async function initializeWithNewStore(restEndPoints, userId, sessionId, tenantId) {
126
165
  console.info(`initializeWithNewStore with ${JSON.stringify(restEndPoints)}`);
127
166
  initialize3rdPartyExtensions();
128
167
  const zeniHttpClient = new zeniAPI_1.ZeniAPIClient(restEndPoints, userId, sessionId, tenantId);
129
- return (0, configureStore_1.default)(zeniHttpClient, false);
168
+ const store = (0, configureStore_1.default)(zeniHttpClient, false);
169
+ // Server-side stores need the full epic tree, not just the 24 core epics.
170
+ // Feature epics handle report generation, data fetching, etc. that the
171
+ // download server relies on. We use the store's own epicManager (not the
172
+ // module-level variable) so each store gets its own full epic subscription.
173
+ const epicModule = await Promise.resolve().then(() => __importStar(require('./epic')));
174
+ store.epicManager.setEpic(epicModule.default);
175
+ return store;
130
176
  }
131
177
  /**
132
178
  * Exported for testing purpose. Not intended to be used in any other place!