@monorise/react 8.4.0 → 9.0.0-dev.0

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/index.js CHANGED
@@ -171,76 +171,8 @@ var initAppActions = (store2) => {
171
171
  };
172
172
  };
173
173
 
174
- // actions/auth.action.ts
175
- import { produce as produce2 } from "immer";
176
- var initAuthActions = (store2, authService2) => {
177
- const requestLogin2 = async (entityType, payload) => {
178
- const { data } = await authService2.requestLoginMagicLink(
179
- entityType,
180
- payload
181
- );
182
- return data;
183
- };
184
- const useProfile2 = () => {
185
- const profile = store2((state) => state.auth.profile);
186
- return profile;
187
- };
188
- const getProfile2 = async () => {
189
- try {
190
- const {
191
- data: _a
192
- } = await authService2.getSessionProfile(), _b = _a, { displayName, email, accountId } = _b, rest = __objRest(_b, ["displayName", "email", "accountId"]);
193
- store2.setState(
194
- produce2((state) => {
195
- state.auth.profile = __spreadValues({ displayName, email, accountId }, rest);
196
- state.auth.isUnauthorized = false;
197
- state.auth.isLoading = false;
198
- }),
199
- void 0,
200
- "mr/auth/get-profile"
201
- );
202
- } catch (e) {
203
- store2.setState(
204
- produce2((state) => {
205
- state.auth.profile = {};
206
- state.auth.isUnauthorized = true;
207
- state.auth.isLoading = false;
208
- }),
209
- void 0,
210
- "mr/auth/get-profile"
211
- );
212
- }
213
- };
214
- const useIsUnauthorized2 = () => {
215
- const { isUnauthorized, profile, isLoading } = store2((state) => state.auth);
216
- return { isUnauthorized: isUnauthorized && !profile.accountId, isLoading };
217
- };
218
- const setIsUnauthorized2 = (isUnauthorized) => store2.setState(
219
- produce2((state) => {
220
- state.auth.isUnauthorized = isUnauthorized;
221
- })
222
- );
223
- const logout2 = () => {
224
- authService2.logout();
225
- store2.setState(
226
- produce2((state) => {
227
- state.auth.isUnauthorized = true;
228
- state.auth.profile = {};
229
- })
230
- );
231
- };
232
- return {
233
- requestLogin: requestLogin2,
234
- useProfile: useProfile2,
235
- getProfile: getProfile2,
236
- useIsUnauthorized: useIsUnauthorized2,
237
- setIsUnauthorized: setIsUnauthorized2,
238
- logout: logout2
239
- };
240
- };
241
-
242
174
  // actions/config.action.ts
243
- import { produce as produce3 } from "immer";
175
+ import { produce as produce2 } from "immer";
244
176
  var initConfigActions = (store2) => {
245
177
  const setConfig2 = (config) => {
246
178
  const entityMaps = Object.keys(config).reduce(
@@ -255,7 +187,7 @@ var initConfigActions = (store2) => {
255
187
  {}
256
188
  );
257
189
  store2.setState(
258
- produce3((state) => {
190
+ produce2((state) => {
259
191
  state.config = config;
260
192
  state.entity = entityMaps;
261
193
  })
@@ -276,8 +208,8 @@ var initConfigActions = (store2) => {
276
208
  };
277
209
 
278
210
  // actions/core.action.ts
279
- import { produce as produce4 } from "immer";
280
- import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
211
+ import { produce as produce3 } from "immer";
212
+ import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
281
213
 
282
214
  // lib/utils.ts
283
215
  import { nanoid } from "nanoid";
@@ -477,6 +409,7 @@ var byEntityId = (a, b) => {
477
409
  };
478
410
 
479
411
  // actions/core.action.ts
412
+ var EMPTY_MAP = /* @__PURE__ */ new Map();
480
413
  var defaultOnError = (error) => {
481
414
  if (!(error instanceof Error) && error.status >= 500) {
482
415
  throw error;
@@ -529,7 +462,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
529
462
  ...store2.entity[entityType].dataMap
530
463
  ]);
531
464
  monoriseStore.setState(
532
- produce4((state) => {
465
+ produce3((state) => {
533
466
  state.entity[entityType] = {
534
467
  dataMap: params.skRange ? newEntityMap : mergedMap,
535
468
  isFirstFetched: true,
@@ -569,7 +502,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
569
502
  opts
570
503
  );
571
504
  monoriseStore.setState(
572
- produce4((state) => {
505
+ produce3((state) => {
573
506
  state.entity[entityType].isFirstFetched = true;
574
507
  state.entity[entityType].lastKey = result.lastKey;
575
508
  for (const i in result.data) {
@@ -600,7 +533,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
600
533
  try {
601
534
  const { data: result } = await entityService.searchEntities(query, opts);
602
535
  monoriseStore.setState(
603
- produce4((state) => {
536
+ produce3((state) => {
604
537
  state.entity[entityType].searchResults = result.data;
605
538
  for (const i in result.data) {
606
539
  state.entity[entityType].dataMap.set(
@@ -652,14 +585,14 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
652
585
  }));
653
586
  const { entities, lastKey } = data;
654
587
  monoriseStore.setState(
655
- produce4((state2) => {
588
+ produce3((state2) => {
656
589
  for (const entity of entities) {
657
590
  state2.entity[entityType].dataMap.set(entity.entityId, entity);
658
591
  }
659
592
  })
660
593
  );
661
594
  monoriseStore.setState(
662
- produce4((state2) => {
595
+ produce3((state2) => {
663
596
  if (!state2.tag[tagKey]) {
664
597
  state2.tag[tagKey] = {
665
598
  dataMap: /* @__PURE__ */ new Map(),
@@ -706,7 +639,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
706
639
  try {
707
640
  ({ data: entity } = await entityService.getEntity(id, opts));
708
641
  monoriseStore.setState(
709
- produce4((state) => {
642
+ produce3((state) => {
710
643
  state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
711
644
  }),
712
645
  void 0,
@@ -750,7 +683,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
750
683
  opts
751
684
  ));
752
685
  monoriseStore.setState(
753
- produce4((state) => {
686
+ produce3((state) => {
754
687
  state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
755
688
  state.entity[entityType].dataMap.set(`${stateKey}`, entity);
756
689
  }),
@@ -797,7 +730,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
797
730
  try {
798
731
  const { data } = await entityService.createEntity(entity, opts);
799
732
  monoriseStore.setState(
800
- produce4((state) => {
733
+ produce3((state) => {
801
734
  var _a2, _b;
802
735
  state.entity[entityType].dataMap.set(data.entityId, data);
803
736
  const tagConfigs = (_a2 = state.config[entityType]) == null ? void 0 : _a2.tags;
@@ -869,7 +802,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
869
802
  try {
870
803
  const { data } = await entityService.upsertEntity(id, entity, opts);
871
804
  monoriseStore.setState(
872
- produce4((state) => {
805
+ produce3((state) => {
873
806
  state.entity[entityType].dataMap.set(data.entityId, data);
874
807
  }),
875
808
  void 0,
@@ -974,7 +907,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
974
907
  try {
975
908
  const { data } = await entityService.editEntity(id, entity, opts);
976
909
  monoriseStore.setState(
977
- produce4((state) => {
910
+ produce3((state) => {
978
911
  state.entity[entityType].dataMap.set(data.entityId, data);
979
912
  propagateEntityDataToMutuals(state, entityType, id, data.data);
980
913
  reconcileTaggedEntityStore(
@@ -1001,7 +934,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1001
934
  try {
1002
935
  const { data } = await entityService.adjustEntity(id, adjustments, opts);
1003
936
  monoriseStore.setState(
1004
- produce4((state) => {
937
+ produce3((state) => {
1005
938
  state.entity[entityType].dataMap.set(data.entityId, data);
1006
939
  propagateEntityDataToMutuals(state, entityType, id, data.data);
1007
940
  reconcileTaggedEntityStore(
@@ -1032,7 +965,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1032
965
  await entityService.deleteEntity(id, opts);
1033
966
  deleteLocalMutualsByEntity(entityType, id);
1034
967
  monoriseStore.setState(
1035
- produce4((state) => {
968
+ produce3((state) => {
1036
969
  deleteEntityFromStores(state, entityType, id);
1037
970
  }),
1038
971
  void 0,
@@ -1073,7 +1006,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1073
1006
  settled = true;
1074
1007
  const deletedEntities = [];
1075
1008
  monoriseStore.setState(
1076
- produce4((state) => {
1009
+ produce3((state) => {
1077
1010
  data.results.forEach((entry, index) => {
1078
1011
  var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l;
1079
1012
  const { entityType, entityId } = entry;
@@ -1249,7 +1182,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1249
1182
  newEntityDataMap.set(entities[i].entityId, entities[i]);
1250
1183
  }
1251
1184
  monoriseStore.setState(
1252
- produce4((state) => {
1185
+ produce3((state) => {
1253
1186
  var _a2;
1254
1187
  for (const [key, value] of newEntityDataMap) {
1255
1188
  (_a2 = state.entity[entityType]) == null ? void 0 : _a2.dataMap.set(key, value);
@@ -1343,7 +1276,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1343
1276
  const newEntityDataMap = new Map(entityDataMap);
1344
1277
  newEntityDataMap.set(mutual.entityId, mutual);
1345
1278
  monoriseStore.setState(
1346
- produce4((state) => {
1279
+ produce3((state) => {
1347
1280
  state.mutual[selfKey] = __spreadProps(__spreadValues({}, state.mutual[selfKey] || {}), {
1348
1281
  dataMap: newMutualDataMap
1349
1282
  });
@@ -1372,7 +1305,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1372
1305
  opts
1373
1306
  );
1374
1307
  monoriseStore.setState(
1375
- produce4((state) => {
1308
+ produce3((state) => {
1376
1309
  var _a2, _b, _c, _d, _e;
1377
1310
  const bySide = getMutualStateKey(
1378
1311
  byEntityType,
@@ -1419,7 +1352,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1419
1352
  data
1420
1353
  );
1421
1354
  monoriseStore.setState(
1422
- produce4((state) => {
1355
+ produce3((state) => {
1423
1356
  var _a, _b, _c, _d, _e;
1424
1357
  const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
1425
1358
  const side = getMutualStateKey(entityType, entityId, byEntityType);
@@ -1449,7 +1382,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1449
1382
  const updateLocalEntity2 = async (entityType, entityId, data = {}) => {
1450
1383
  const createdEntity = constructLocal(entityType, entityId, data);
1451
1384
  monoriseStore.setState(
1452
- produce4((state) => {
1385
+ produce3((state) => {
1453
1386
  state.entity[entityType].dataMap.set(entityId, createdEntity);
1454
1387
  }),
1455
1388
  void 0,
@@ -1466,7 +1399,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1466
1399
  data
1467
1400
  );
1468
1401
  monoriseStore.setState(
1469
- produce4((state) => {
1402
+ produce3((state) => {
1470
1403
  var _a, _b, _c, _d, _e;
1471
1404
  const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
1472
1405
  const side = getMutualStateKey(entityType, entityId, byEntityType);
@@ -1505,7 +1438,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1505
1438
  opts
1506
1439
  );
1507
1440
  monoriseStore.setState(
1508
- produce4((state) => {
1441
+ produce3((state) => {
1509
1442
  var _a2, _b, _c, _d, _e;
1510
1443
  const bySide = getMutualStateKey(
1511
1444
  byEntityType,
@@ -1553,7 +1486,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1553
1486
  opts
1554
1487
  );
1555
1488
  monoriseStore.setState(
1556
- produce4((state) => {
1489
+ produce3((state) => {
1557
1490
  var _a2, _b;
1558
1491
  const bySide = getMutualStateKey(
1559
1492
  byEntityType,
@@ -1576,7 +1509,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1576
1509
  };
1577
1510
  const deleteLocalMutual2 = (byEntityType, entityType, byEntityId2, entityId) => {
1578
1511
  monoriseStore.setState(
1579
- produce4((state) => {
1512
+ produce3((state) => {
1580
1513
  var _a, _b;
1581
1514
  const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
1582
1515
  const side = getMutualStateKey(entityType, entityId, byEntityType);
@@ -1624,7 +1557,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1624
1557
  {}
1625
1558
  );
1626
1559
  monoriseStore.setState(
1627
- produce4((state) => {
1560
+ produce3((state) => {
1628
1561
  for (const key in updatedState) {
1629
1562
  state.mutual[key] = updatedState[key];
1630
1563
  }
@@ -1913,9 +1846,8 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1913
1846
  const error = useErrorStore2(requestKey);
1914
1847
  const state = monoriseStore((state2) => state2.entity[entityType]);
1915
1848
  const { dataMap, searchResults, isFirstFetched, lastKey } = state != null ? state : {
1916
- dataMap: /* @__PURE__ */ new Map()
1849
+ dataMap: EMPTY_MAP
1917
1850
  };
1918
- const [entities, setEntities] = useState2();
1919
1851
  const [query, setQuery] = useState2("");
1920
1852
  const [skRange, setBetween] = useState2(params.skRange);
1921
1853
  const [all, setAll] = useState2(params.all);
@@ -1944,40 +1876,22 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
1944
1876
  }, [all, entityType, skRange, opts, isFirstFetched, opts == null ? void 0 : opts.forceFetch, limit]);
1945
1877
  useEffect2(() => {
1946
1878
  var _a;
1947
- let queryTimeout;
1948
- if (query == null ? void 0 : query.length) {
1949
- setIsSearching(true);
1950
- queryTimeout = setTimeout(async () => {
1951
- await searchEntities(entityType, query);
1952
- setIsSearching(false);
1953
- }, (_a = opts.searchInterval) != null ? _a : 700);
1879
+ if (!(query == null ? void 0 : query.length)) {
1880
+ setIsSearching(false);
1881
+ return;
1954
1882
  }
1955
- return () => queryTimeout && clearTimeout(queryTimeout);
1883
+ setIsSearching(true);
1884
+ const queryTimeout = setTimeout(async () => {
1885
+ await searchEntities(entityType, query);
1886
+ setIsSearching(false);
1887
+ }, (_a = opts.searchInterval) != null ? _a : 700);
1888
+ return () => clearTimeout(queryTimeout);
1956
1889
  }, [entityType, query]);
1957
- useEffect2(() => {
1958
- if (!query) {
1959
- const dataMapArray = Array.from(dataMap.values()).sort(
1960
- byEntityId
1961
- );
1962
- if (dataMap.size !== (entities == null ? void 0 : entities.length) || dataMapArray.some(
1963
- (item, index) => JSON.stringify(item) !== JSON.stringify(entities == null ? void 0 : entities[index])
1964
- )) {
1965
- setIsSearching(false);
1966
- setEntities(dataMapArray);
1967
- }
1968
- }
1969
- if (query) {
1970
- setEntities(searchResults);
1971
- }
1972
- }, [
1973
- dataMap,
1974
- dataMap.size,
1975
- entities,
1976
- entities == null ? void 0 : entities.length,
1977
- query,
1978
- searchResults,
1979
- searchResults == null ? void 0 : searchResults.length
1980
- ]);
1890
+ const listed = useMemo(
1891
+ () => Array.from(dataMap.values()).sort(byEntityId),
1892
+ [dataMap]
1893
+ );
1894
+ const entities = query ? searchResults : listed;
1981
1895
  const handleQueryChange = (event) => {
1982
1896
  setQuery(event.target.value);
1983
1897
  };
@@ -2053,9 +1967,12 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2053
1967
  );
2054
1968
  const state = monoriseStore((state2) => state2.mutual[stateKey]);
2055
1969
  const { dataMap, isFirstFetched, lastKey } = state || {
2056
- dataMap: /* @__PURE__ */ new Map()
1970
+ dataMap: EMPTY_MAP
2057
1971
  };
2058
- const [mutuals, setMutuals] = useState2([]);
1972
+ const mutuals = useMemo(
1973
+ () => Array.from(dataMap.values()),
1974
+ [dataMap]
1975
+ );
2059
1976
  const requestKey = getMutualRequestKey(
2060
1977
  "list",
2061
1978
  byEntityType,
@@ -2087,14 +2004,6 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2087
2004
  opts == null ? void 0 : opts.forceFetch,
2088
2005
  opts == null ? void 0 : opts.noData
2089
2006
  ]);
2090
- useEffect2(() => {
2091
- const dataMapArray = Array.from(dataMap.values());
2092
- if (dataMap.size !== (mutuals == null ? void 0 : mutuals.length) || dataMapArray.some(
2093
- (item, index) => JSON.stringify(item) !== JSON.stringify(mutuals[index])
2094
- )) {
2095
- setMutuals(dataMapArray);
2096
- }
2097
- }, [dataMap, dataMap.size, mutuals == null ? void 0 : mutuals.length]);
2098
2007
  return __spreadValues({
2099
2008
  mutuals,
2100
2009
  mutualsMap: dataMap,
@@ -2154,9 +2063,18 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2154
2063
  const stateKey = getTagStateKey(entityType, tagName, params);
2155
2064
  const state = monoriseStore((state2) => state2.tag[stateKey]);
2156
2065
  const { dataMap, isFirstFetched, lastKey } = state || {
2157
- dataMap: /* @__PURE__ */ new Map()
2066
+ dataMap: EMPTY_MAP
2158
2067
  };
2159
- const [entities, setEntities] = useState2([]);
2068
+ const group = params == null ? void 0 : params.group;
2069
+ const entities = useMemo(
2070
+ () => sortTaggedEntitiesLikeServer(
2071
+ Array.from(dataMap.values()),
2072
+ entityType,
2073
+ tagName,
2074
+ group
2075
+ ),
2076
+ [dataMap, entityType, tagName, group]
2077
+ );
2160
2078
  const requestKey = getTagRequestKey("list", entityType, tagName, params);
2161
2079
  const isLoading = useLoadStore2(requestKey);
2162
2080
  const error = useErrorStore2(requestKey);
@@ -2165,19 +2083,6 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2165
2083
  listEntitiesByTag(entityType, tagName, opts);
2166
2084
  }
2167
2085
  }, [entityType, opts, tagName, params, opts == null ? void 0 : opts.forceFetch]);
2168
- useEffect2(() => {
2169
- const dataMapArray = sortTaggedEntitiesLikeServer(
2170
- Array.from(dataMap.values()),
2171
- entityType,
2172
- tagName,
2173
- params == null ? void 0 : params.group
2174
- );
2175
- if (dataMap.size !== (entities == null ? void 0 : entities.length) || dataMapArray.some(
2176
- (item, index) => JSON.stringify(item) !== JSON.stringify(entities[index])
2177
- )) {
2178
- setEntities(dataMapArray);
2179
- }
2180
- }, [dataMap, dataMap.size, entities == null ? void 0 : entities.length]);
2181
2086
  return {
2182
2087
  entities,
2183
2088
  entitiesMap: dataMap,
@@ -2213,7 +2118,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2213
2118
  params
2214
2119
  );
2215
2120
  monoriseStore.setState(
2216
- produce4((state) => {
2121
+ produce3((state) => {
2217
2122
  var _a, _b;
2218
2123
  const entity = (_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.get(entityId);
2219
2124
  if (entity) {
@@ -2233,7 +2138,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2233
2138
  params
2234
2139
  );
2235
2140
  monoriseStore.setState(
2236
- produce4((state) => {
2141
+ produce3((state) => {
2237
2142
  var _a, _b;
2238
2143
  if ((_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.has(entityId)) {
2239
2144
  state.tag[tagKey].dataMap.delete(entityId);
@@ -2283,7 +2188,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
2283
2188
 
2284
2189
  // actions/websocket.action.ts
2285
2190
  import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
2286
- import { produce as produce5 } from "immer";
2191
+ import { produce as produce4 } from "immer";
2287
2192
  var globalWsManager = null;
2288
2193
  var wsEndpoint;
2289
2194
  var initializeWebSocketManager = (WebSocketManagerClass, endpoint, token) => {
@@ -2327,7 +2232,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2327
2232
  lastKey: fetchLastKey
2328
2233
  });
2329
2234
  monoriseStore.setState(
2330
- produce5((state) => {
2235
+ produce4((state) => {
2331
2236
  if (type === "refresh") {
2332
2237
  state.entity[entityType].dataMap.clear();
2333
2238
  }
@@ -2375,7 +2280,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2375
2280
  if (msg.type === "entity.created" || msg.type === "entity.updated") {
2376
2281
  if (payload.data) {
2377
2282
  monoriseStore.setState(
2378
- produce5((state) => {
2283
+ produce4((state) => {
2379
2284
  const key = entityType;
2380
2285
  if (!state.entity[key]) {
2381
2286
  state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
@@ -2389,7 +2294,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2389
2294
  }
2390
2295
  } else if (msg.type === "entity.deleted") {
2391
2296
  monoriseStore.setState(
2392
- produce5((state) => {
2297
+ produce4((state) => {
2393
2298
  var _a;
2394
2299
  const key = entityType;
2395
2300
  if ((_a = state.entity[key]) == null ? void 0 : _a.dataMap) {
@@ -2459,7 +2364,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2459
2364
  { limit, lastKey: fetchLastKey }
2460
2365
  );
2461
2366
  monoriseStore.setState(
2462
- produce5((state) => {
2367
+ produce4((state) => {
2463
2368
  if (!state.mutual[mutualKey]) {
2464
2369
  state.mutual[mutualKey] = {
2465
2370
  dataMap: /* @__PURE__ */ new Map(),
@@ -2526,7 +2431,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2526
2431
  if (msg.type === "mutual.created" || msg.type === "mutual.updated") {
2527
2432
  if (payload.data) {
2528
2433
  monoriseStore.setState(
2529
- produce5((state) => {
2434
+ produce4((state) => {
2530
2435
  if (!state.mutual[mutualKey]) {
2531
2436
  state.mutual[mutualKey] = {
2532
2437
  dataMap: /* @__PURE__ */ new Map(),
@@ -2543,7 +2448,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2543
2448
  }
2544
2449
  } else if (msg.type === "mutual.deleted") {
2545
2450
  monoriseStore.setState(
2546
- produce5((state) => {
2451
+ produce4((state) => {
2547
2452
  var _a;
2548
2453
  (_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap.delete(payload.entityId);
2549
2454
  })
@@ -2632,7 +2537,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2632
2537
  );
2633
2538
  if (!isMountedRef.current) return;
2634
2539
  monoriseStore.setState(
2635
- produce5((draft) => {
2540
+ produce4((draft) => {
2636
2541
  const slice = draft.mutual[key];
2637
2542
  if (!slice) return;
2638
2543
  slice.dataMap.clear();
@@ -2747,7 +2652,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2747
2652
  const payload = msg.payload;
2748
2653
  if (payload.data) {
2749
2654
  monoriseStore.setState(
2750
- produce5((state) => {
2655
+ produce4((state) => {
2751
2656
  const key = payload.entityType;
2752
2657
  if (!state.entity[key]) {
2753
2658
  state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
@@ -2759,7 +2664,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2759
2664
  } else if (msg.type === "entity.deleted") {
2760
2665
  const payload = msg.payload;
2761
2666
  monoriseStore.setState(
2762
- produce5((state) => {
2667
+ produce4((state) => {
2763
2668
  var _a, _b;
2764
2669
  (_b = (_a = state.entity[payload.entityType]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
2765
2670
  })
@@ -2769,7 +2674,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2769
2674
  if (payload.data) {
2770
2675
  const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
2771
2676
  monoriseStore.setState(
2772
- produce5((state) => {
2677
+ produce4((state) => {
2773
2678
  if (!state.mutual[mutualKey]) {
2774
2679
  state.mutual[mutualKey] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
2775
2680
  }
@@ -2781,7 +2686,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
2781
2686
  const payload = msg.payload;
2782
2687
  const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
2783
2688
  monoriseStore.setState(
2784
- produce5((state) => {
2689
+ produce4((state) => {
2785
2690
  var _a, _b;
2786
2691
  (_b = (_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
2787
2692
  })
@@ -2899,10 +2804,9 @@ var initAxiosInterceptor = (store2, appActions) => {
2899
2804
  });
2900
2805
  return axios2;
2901
2806
  };
2902
- var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
2807
+ var injectAxiosInterceptor = (appActions, axios2, opts) => {
2903
2808
  let options = opts || {};
2904
2809
  const { endLoading: endLoading2, setError: setError2, clearError: clearError2 } = appActions;
2905
- const { setIsUnauthorized: setIsUnauthorized2 } = authActions;
2906
2810
  const unknownError = {
2907
2811
  status: 500,
2908
2812
  code: "UNKNOWN_EXCEPTION",
@@ -2939,7 +2843,7 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
2939
2843
  return Promise.resolve(response);
2940
2844
  },
2941
2845
  (error) => {
2942
- var _a, _b, _c, _d, _e;
2846
+ var _a, _b, _c, _d;
2943
2847
  const config = error.config;
2944
2848
  settleLoading(config);
2945
2849
  const appError = ((_a = error.response) == null ? void 0 : _a.data) ? {
@@ -2950,9 +2854,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
2950
2854
  for (const errorKey of getErrorKeys(config)) {
2951
2855
  setError2({ requestKey: errorKey, error: appError });
2952
2856
  }
2953
- if (((_e = error.response) == null ? void 0 : _e.status) === 401) {
2954
- setIsUnauthorized2(true);
2955
- }
2956
2857
  return Promise.reject(error);
2957
2858
  }
2958
2859
  );
@@ -2962,43 +2863,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
2962
2863
  return { setOptions };
2963
2864
  };
2964
2865
 
2965
- // services/auth.service.ts
2966
- var initAuthService = (axios2) => {
2967
- let options = {};
2968
- const { apiBaseUrl = "/api/auth" } = options;
2969
- const requestLoginMagicLink = (entityType, payload) => {
2970
- return axios2.post(
2971
- `${apiBaseUrl}/${entityType}`,
2972
- {
2973
- body: __spreadValues({}, payload)
2974
- },
2975
- {
2976
- requestKey: `auth/${entityType}/request-login`,
2977
- isInterruptive: true,
2978
- feedback: {
2979
- loading: "Requesting login link"
2980
- }
2981
- }
2982
- );
2983
- };
2984
- const getSessionProfile = () => axios2.get("/session", {
2985
- requestKey: "auth/session"
2986
- });
2987
- const logout2 = () => axios2.get("/logout", {
2988
- requestKey: "auth/logout"
2989
- });
2990
- const setOptions = (opts) => {
2991
- options = __spreadValues(__spreadValues({}, options), opts);
2992
- };
2993
- return {
2994
- requestLoginMagicLink,
2995
- getSessionProfile,
2996
- logout: logout2,
2997
- setOptions
2998
- };
2999
- };
3000
- var auth_service_default = initAuthService;
3001
-
3002
2866
  // services/core.service.ts
3003
2867
  var ENTITY_API_BASE_URL = "/api/core/entity";
3004
2868
  var MUTUAL_API_BASE_URL = "/api/core/mutual";
@@ -3553,16 +3417,7 @@ var initMonoriseStore = () => {
3553
3417
  config: {},
3554
3418
  entity: {},
3555
3419
  mutual: {},
3556
- tag: {},
3557
- auth: {
3558
- isUnauthorized: false,
3559
- profile: {
3560
- displayName: "",
3561
- email: "",
3562
- accountId: ""
3563
- },
3564
- isLoading: true
3565
- }
3420
+ tag: {}
3566
3421
  }),
3567
3422
  configureDevtools("monorise")
3568
3423
  )
@@ -3579,10 +3434,8 @@ var initMonorise = () => {
3579
3434
  const appActions = initAppActions(store2);
3580
3435
  const configActions = initConfigActions(store2);
3581
3436
  const axios2 = initAxiosInterceptor(store2, appActions);
3582
- const authService2 = auth_service_default(axios2);
3583
3437
  const filestoreService2 = filestore_service_default(axios2);
3584
3438
  const coreService2 = core_service_default(store2, axios2);
3585
- const authActions = initAuthActions(store2, authService2);
3586
3439
  const coreActions = initCoreActions(store2, appActions, coreService2);
3587
3440
  const websocketActions = initWebSocketActions(store2, {
3588
3441
  listEntities: async (entityType, params) => {
@@ -3597,19 +3450,12 @@ var initMonorise = () => {
3597
3450
  return { entities: data.entities, lastKey: data.lastKey };
3598
3451
  }
3599
3452
  });
3600
- const axiosInterceptor = injectAxiosInterceptor(
3601
- appActions,
3602
- authActions,
3603
- axios2
3604
- );
3453
+ const axiosInterceptor = injectAxiosInterceptor(appActions, axios2);
3605
3454
  const config = (opts) => {
3606
3455
  setMonoriseOptions({
3607
3456
  modals: opts.modals
3608
3457
  });
3609
3458
  configActions.setConfig(opts.entityConfig);
3610
- authService2.setOptions({
3611
- apiBaseUrl: opts.authBaseUrl
3612
- });
3613
3459
  filestoreService2.setOptions({
3614
3460
  apiBaseUrl: opts.filestoreBaseUrl
3615
3461
  });
@@ -3622,20 +3468,18 @@ var initMonorise = () => {
3622
3468
  onApiSuccess: opts.onApiSuccess
3623
3469
  });
3624
3470
  };
3625
- return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
3471
+ return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
3626
3472
  config,
3627
3473
  store: store2,
3628
3474
  axios: axios2,
3629
- authService: authService2,
3630
3475
  filestoreService: filestoreService2,
3631
3476
  coreService: coreService2
3632
- }, configActions), appActions), authActions), coreActions), websocketActions);
3477
+ }, configActions), appActions), coreActions), websocketActions);
3633
3478
  };
3634
3479
  var Monorise = initMonorise();
3635
3480
  var {
3636
3481
  store,
3637
3482
  axios,
3638
- authService,
3639
3483
  filestoreService,
3640
3484
  coreService,
3641
3485
  setConfig,
@@ -3652,12 +3496,6 @@ var {
3652
3496
  useInterruptiveLoadStore,
3653
3497
  useErrorStore,
3654
3498
  useModalStore,
3655
- requestLogin,
3656
- useProfile,
3657
- getProfile,
3658
- useIsUnauthorized,
3659
- setIsUnauthorized,
3660
- logout,
3661
3499
  listMoreEntities,
3662
3500
  createEntity,
3663
3501
  upsertEntity,
@@ -3701,7 +3539,6 @@ var index_default = Monorise;
3701
3539
  export {
3702
3540
  WebSocketManager,
3703
3541
  adjustEntity,
3704
- authService,
3705
3542
  axios,
3706
3543
  clearError,
3707
3544
  closeModal,
@@ -3725,18 +3562,14 @@ export {
3725
3562
  getError,
3726
3563
  getMutual,
3727
3564
  getMutualRequestKey,
3728
- getProfile,
3729
3565
  getTagRequestKey,
3730
3566
  getUniqueFieldRequestKey,
3731
3567
  getWebSocketManager,
3732
3568
  initializeWebSocketManager,
3733
3569
  listMoreEntities,
3734
- logout,
3735
3570
  openModal,
3736
- requestLogin,
3737
3571
  setConfig,
3738
3572
  setError,
3739
- setIsUnauthorized,
3740
3573
  startLoading,
3741
3574
  store,
3742
3575
  transactional,
@@ -3762,13 +3595,11 @@ export {
3762
3595
  useErrorStore,
3763
3596
  useExecuteTransaction,
3764
3597
  useInterruptiveLoadStore,
3765
- useIsUnauthorized,
3766
3598
  useLoadStore,
3767
3599
  useModalStore,
3768
3600
  useMutual,
3769
3601
  useMutualSocket,
3770
3602
  useMutuals,
3771
- useProfile,
3772
3603
  useTaggedEntities,
3773
3604
  useUpsertEntity
3774
3605
  };