@monorise/react 8.4.1 → 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.d.ts +2 -164
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -188
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +1 -2
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/store/monorise.store.d.ts +0 -54
- package/dist/store/monorise.store.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/actions/auth.action.d.ts +0 -24
- package/dist/actions/auth.action.d.ts.map +0 -1
- package/dist/services/auth.service.d.ts +0 -21
- package/dist/services/auth.service.d.ts.map +0 -1
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
|
|
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
|
-
|
|
190
|
+
produce2((state) => {
|
|
259
191
|
state.config = config;
|
|
260
192
|
state.entity = entityMaps;
|
|
261
193
|
})
|
|
@@ -276,7 +208,7 @@ var initConfigActions = (store2) => {
|
|
|
276
208
|
};
|
|
277
209
|
|
|
278
210
|
// actions/core.action.ts
|
|
279
|
-
import { produce as
|
|
211
|
+
import { produce as produce3 } from "immer";
|
|
280
212
|
import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
|
|
281
213
|
|
|
282
214
|
// lib/utils.ts
|
|
@@ -530,7 +462,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
530
462
|
...store2.entity[entityType].dataMap
|
|
531
463
|
]);
|
|
532
464
|
monoriseStore.setState(
|
|
533
|
-
|
|
465
|
+
produce3((state) => {
|
|
534
466
|
state.entity[entityType] = {
|
|
535
467
|
dataMap: params.skRange ? newEntityMap : mergedMap,
|
|
536
468
|
isFirstFetched: true,
|
|
@@ -570,7 +502,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
570
502
|
opts
|
|
571
503
|
);
|
|
572
504
|
monoriseStore.setState(
|
|
573
|
-
|
|
505
|
+
produce3((state) => {
|
|
574
506
|
state.entity[entityType].isFirstFetched = true;
|
|
575
507
|
state.entity[entityType].lastKey = result.lastKey;
|
|
576
508
|
for (const i in result.data) {
|
|
@@ -601,7 +533,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
601
533
|
try {
|
|
602
534
|
const { data: result } = await entityService.searchEntities(query, opts);
|
|
603
535
|
monoriseStore.setState(
|
|
604
|
-
|
|
536
|
+
produce3((state) => {
|
|
605
537
|
state.entity[entityType].searchResults = result.data;
|
|
606
538
|
for (const i in result.data) {
|
|
607
539
|
state.entity[entityType].dataMap.set(
|
|
@@ -653,14 +585,14 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
653
585
|
}));
|
|
654
586
|
const { entities, lastKey } = data;
|
|
655
587
|
monoriseStore.setState(
|
|
656
|
-
|
|
588
|
+
produce3((state2) => {
|
|
657
589
|
for (const entity of entities) {
|
|
658
590
|
state2.entity[entityType].dataMap.set(entity.entityId, entity);
|
|
659
591
|
}
|
|
660
592
|
})
|
|
661
593
|
);
|
|
662
594
|
monoriseStore.setState(
|
|
663
|
-
|
|
595
|
+
produce3((state2) => {
|
|
664
596
|
if (!state2.tag[tagKey]) {
|
|
665
597
|
state2.tag[tagKey] = {
|
|
666
598
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -707,7 +639,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
707
639
|
try {
|
|
708
640
|
({ data: entity } = await entityService.getEntity(id, opts));
|
|
709
641
|
monoriseStore.setState(
|
|
710
|
-
|
|
642
|
+
produce3((state) => {
|
|
711
643
|
state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
|
|
712
644
|
}),
|
|
713
645
|
void 0,
|
|
@@ -751,7 +683,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
751
683
|
opts
|
|
752
684
|
));
|
|
753
685
|
monoriseStore.setState(
|
|
754
|
-
|
|
686
|
+
produce3((state) => {
|
|
755
687
|
state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
|
|
756
688
|
state.entity[entityType].dataMap.set(`${stateKey}`, entity);
|
|
757
689
|
}),
|
|
@@ -798,7 +730,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
798
730
|
try {
|
|
799
731
|
const { data } = await entityService.createEntity(entity, opts);
|
|
800
732
|
monoriseStore.setState(
|
|
801
|
-
|
|
733
|
+
produce3((state) => {
|
|
802
734
|
var _a2, _b;
|
|
803
735
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
804
736
|
const tagConfigs = (_a2 = state.config[entityType]) == null ? void 0 : _a2.tags;
|
|
@@ -870,7 +802,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
870
802
|
try {
|
|
871
803
|
const { data } = await entityService.upsertEntity(id, entity, opts);
|
|
872
804
|
monoriseStore.setState(
|
|
873
|
-
|
|
805
|
+
produce3((state) => {
|
|
874
806
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
875
807
|
}),
|
|
876
808
|
void 0,
|
|
@@ -975,7 +907,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
975
907
|
try {
|
|
976
908
|
const { data } = await entityService.editEntity(id, entity, opts);
|
|
977
909
|
monoriseStore.setState(
|
|
978
|
-
|
|
910
|
+
produce3((state) => {
|
|
979
911
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
980
912
|
propagateEntityDataToMutuals(state, entityType, id, data.data);
|
|
981
913
|
reconcileTaggedEntityStore(
|
|
@@ -1002,7 +934,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1002
934
|
try {
|
|
1003
935
|
const { data } = await entityService.adjustEntity(id, adjustments, opts);
|
|
1004
936
|
monoriseStore.setState(
|
|
1005
|
-
|
|
937
|
+
produce3((state) => {
|
|
1006
938
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
1007
939
|
propagateEntityDataToMutuals(state, entityType, id, data.data);
|
|
1008
940
|
reconcileTaggedEntityStore(
|
|
@@ -1033,7 +965,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1033
965
|
await entityService.deleteEntity(id, opts);
|
|
1034
966
|
deleteLocalMutualsByEntity(entityType, id);
|
|
1035
967
|
monoriseStore.setState(
|
|
1036
|
-
|
|
968
|
+
produce3((state) => {
|
|
1037
969
|
deleteEntityFromStores(state, entityType, id);
|
|
1038
970
|
}),
|
|
1039
971
|
void 0,
|
|
@@ -1074,7 +1006,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1074
1006
|
settled = true;
|
|
1075
1007
|
const deletedEntities = [];
|
|
1076
1008
|
monoriseStore.setState(
|
|
1077
|
-
|
|
1009
|
+
produce3((state) => {
|
|
1078
1010
|
data.results.forEach((entry, index) => {
|
|
1079
1011
|
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l;
|
|
1080
1012
|
const { entityType, entityId } = entry;
|
|
@@ -1250,7 +1182,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1250
1182
|
newEntityDataMap.set(entities[i].entityId, entities[i]);
|
|
1251
1183
|
}
|
|
1252
1184
|
monoriseStore.setState(
|
|
1253
|
-
|
|
1185
|
+
produce3((state) => {
|
|
1254
1186
|
var _a2;
|
|
1255
1187
|
for (const [key, value] of newEntityDataMap) {
|
|
1256
1188
|
(_a2 = state.entity[entityType]) == null ? void 0 : _a2.dataMap.set(key, value);
|
|
@@ -1344,7 +1276,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1344
1276
|
const newEntityDataMap = new Map(entityDataMap);
|
|
1345
1277
|
newEntityDataMap.set(mutual.entityId, mutual);
|
|
1346
1278
|
monoriseStore.setState(
|
|
1347
|
-
|
|
1279
|
+
produce3((state) => {
|
|
1348
1280
|
state.mutual[selfKey] = __spreadProps(__spreadValues({}, state.mutual[selfKey] || {}), {
|
|
1349
1281
|
dataMap: newMutualDataMap
|
|
1350
1282
|
});
|
|
@@ -1373,7 +1305,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1373
1305
|
opts
|
|
1374
1306
|
);
|
|
1375
1307
|
monoriseStore.setState(
|
|
1376
|
-
|
|
1308
|
+
produce3((state) => {
|
|
1377
1309
|
var _a2, _b, _c, _d, _e;
|
|
1378
1310
|
const bySide = getMutualStateKey(
|
|
1379
1311
|
byEntityType,
|
|
@@ -1420,7 +1352,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1420
1352
|
data
|
|
1421
1353
|
);
|
|
1422
1354
|
monoriseStore.setState(
|
|
1423
|
-
|
|
1355
|
+
produce3((state) => {
|
|
1424
1356
|
var _a, _b, _c, _d, _e;
|
|
1425
1357
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1426
1358
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1450,7 +1382,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1450
1382
|
const updateLocalEntity2 = async (entityType, entityId, data = {}) => {
|
|
1451
1383
|
const createdEntity = constructLocal(entityType, entityId, data);
|
|
1452
1384
|
monoriseStore.setState(
|
|
1453
|
-
|
|
1385
|
+
produce3((state) => {
|
|
1454
1386
|
state.entity[entityType].dataMap.set(entityId, createdEntity);
|
|
1455
1387
|
}),
|
|
1456
1388
|
void 0,
|
|
@@ -1467,7 +1399,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1467
1399
|
data
|
|
1468
1400
|
);
|
|
1469
1401
|
monoriseStore.setState(
|
|
1470
|
-
|
|
1402
|
+
produce3((state) => {
|
|
1471
1403
|
var _a, _b, _c, _d, _e;
|
|
1472
1404
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1473
1405
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1506,7 +1438,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1506
1438
|
opts
|
|
1507
1439
|
);
|
|
1508
1440
|
monoriseStore.setState(
|
|
1509
|
-
|
|
1441
|
+
produce3((state) => {
|
|
1510
1442
|
var _a2, _b, _c, _d, _e;
|
|
1511
1443
|
const bySide = getMutualStateKey(
|
|
1512
1444
|
byEntityType,
|
|
@@ -1554,7 +1486,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1554
1486
|
opts
|
|
1555
1487
|
);
|
|
1556
1488
|
monoriseStore.setState(
|
|
1557
|
-
|
|
1489
|
+
produce3((state) => {
|
|
1558
1490
|
var _a2, _b;
|
|
1559
1491
|
const bySide = getMutualStateKey(
|
|
1560
1492
|
byEntityType,
|
|
@@ -1577,7 +1509,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1577
1509
|
};
|
|
1578
1510
|
const deleteLocalMutual2 = (byEntityType, entityType, byEntityId2, entityId) => {
|
|
1579
1511
|
monoriseStore.setState(
|
|
1580
|
-
|
|
1512
|
+
produce3((state) => {
|
|
1581
1513
|
var _a, _b;
|
|
1582
1514
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1583
1515
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1625,7 +1557,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1625
1557
|
{}
|
|
1626
1558
|
);
|
|
1627
1559
|
monoriseStore.setState(
|
|
1628
|
-
|
|
1560
|
+
produce3((state) => {
|
|
1629
1561
|
for (const key in updatedState) {
|
|
1630
1562
|
state.mutual[key] = updatedState[key];
|
|
1631
1563
|
}
|
|
@@ -2186,7 +2118,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2186
2118
|
params
|
|
2187
2119
|
);
|
|
2188
2120
|
monoriseStore.setState(
|
|
2189
|
-
|
|
2121
|
+
produce3((state) => {
|
|
2190
2122
|
var _a, _b;
|
|
2191
2123
|
const entity = (_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.get(entityId);
|
|
2192
2124
|
if (entity) {
|
|
@@ -2206,7 +2138,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2206
2138
|
params
|
|
2207
2139
|
);
|
|
2208
2140
|
monoriseStore.setState(
|
|
2209
|
-
|
|
2141
|
+
produce3((state) => {
|
|
2210
2142
|
var _a, _b;
|
|
2211
2143
|
if ((_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.has(entityId)) {
|
|
2212
2144
|
state.tag[tagKey].dataMap.delete(entityId);
|
|
@@ -2256,7 +2188,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2256
2188
|
|
|
2257
2189
|
// actions/websocket.action.ts
|
|
2258
2190
|
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
2259
|
-
import { produce as
|
|
2191
|
+
import { produce as produce4 } from "immer";
|
|
2260
2192
|
var globalWsManager = null;
|
|
2261
2193
|
var wsEndpoint;
|
|
2262
2194
|
var initializeWebSocketManager = (WebSocketManagerClass, endpoint, token) => {
|
|
@@ -2300,7 +2232,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2300
2232
|
lastKey: fetchLastKey
|
|
2301
2233
|
});
|
|
2302
2234
|
monoriseStore.setState(
|
|
2303
|
-
|
|
2235
|
+
produce4((state) => {
|
|
2304
2236
|
if (type === "refresh") {
|
|
2305
2237
|
state.entity[entityType].dataMap.clear();
|
|
2306
2238
|
}
|
|
@@ -2348,7 +2280,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2348
2280
|
if (msg.type === "entity.created" || msg.type === "entity.updated") {
|
|
2349
2281
|
if (payload.data) {
|
|
2350
2282
|
monoriseStore.setState(
|
|
2351
|
-
|
|
2283
|
+
produce4((state) => {
|
|
2352
2284
|
const key = entityType;
|
|
2353
2285
|
if (!state.entity[key]) {
|
|
2354
2286
|
state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
@@ -2362,7 +2294,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2362
2294
|
}
|
|
2363
2295
|
} else if (msg.type === "entity.deleted") {
|
|
2364
2296
|
monoriseStore.setState(
|
|
2365
|
-
|
|
2297
|
+
produce4((state) => {
|
|
2366
2298
|
var _a;
|
|
2367
2299
|
const key = entityType;
|
|
2368
2300
|
if ((_a = state.entity[key]) == null ? void 0 : _a.dataMap) {
|
|
@@ -2432,7 +2364,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2432
2364
|
{ limit, lastKey: fetchLastKey }
|
|
2433
2365
|
);
|
|
2434
2366
|
monoriseStore.setState(
|
|
2435
|
-
|
|
2367
|
+
produce4((state) => {
|
|
2436
2368
|
if (!state.mutual[mutualKey]) {
|
|
2437
2369
|
state.mutual[mutualKey] = {
|
|
2438
2370
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -2499,7 +2431,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2499
2431
|
if (msg.type === "mutual.created" || msg.type === "mutual.updated") {
|
|
2500
2432
|
if (payload.data) {
|
|
2501
2433
|
monoriseStore.setState(
|
|
2502
|
-
|
|
2434
|
+
produce4((state) => {
|
|
2503
2435
|
if (!state.mutual[mutualKey]) {
|
|
2504
2436
|
state.mutual[mutualKey] = {
|
|
2505
2437
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -2516,7 +2448,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2516
2448
|
}
|
|
2517
2449
|
} else if (msg.type === "mutual.deleted") {
|
|
2518
2450
|
monoriseStore.setState(
|
|
2519
|
-
|
|
2451
|
+
produce4((state) => {
|
|
2520
2452
|
var _a;
|
|
2521
2453
|
(_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap.delete(payload.entityId);
|
|
2522
2454
|
})
|
|
@@ -2605,7 +2537,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2605
2537
|
);
|
|
2606
2538
|
if (!isMountedRef.current) return;
|
|
2607
2539
|
monoriseStore.setState(
|
|
2608
|
-
|
|
2540
|
+
produce4((draft) => {
|
|
2609
2541
|
const slice = draft.mutual[key];
|
|
2610
2542
|
if (!slice) return;
|
|
2611
2543
|
slice.dataMap.clear();
|
|
@@ -2720,7 +2652,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2720
2652
|
const payload = msg.payload;
|
|
2721
2653
|
if (payload.data) {
|
|
2722
2654
|
monoriseStore.setState(
|
|
2723
|
-
|
|
2655
|
+
produce4((state) => {
|
|
2724
2656
|
const key = payload.entityType;
|
|
2725
2657
|
if (!state.entity[key]) {
|
|
2726
2658
|
state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
@@ -2732,7 +2664,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2732
2664
|
} else if (msg.type === "entity.deleted") {
|
|
2733
2665
|
const payload = msg.payload;
|
|
2734
2666
|
monoriseStore.setState(
|
|
2735
|
-
|
|
2667
|
+
produce4((state) => {
|
|
2736
2668
|
var _a, _b;
|
|
2737
2669
|
(_b = (_a = state.entity[payload.entityType]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
|
|
2738
2670
|
})
|
|
@@ -2742,7 +2674,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2742
2674
|
if (payload.data) {
|
|
2743
2675
|
const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
|
|
2744
2676
|
monoriseStore.setState(
|
|
2745
|
-
|
|
2677
|
+
produce4((state) => {
|
|
2746
2678
|
if (!state.mutual[mutualKey]) {
|
|
2747
2679
|
state.mutual[mutualKey] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
2748
2680
|
}
|
|
@@ -2754,7 +2686,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2754
2686
|
const payload = msg.payload;
|
|
2755
2687
|
const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
|
|
2756
2688
|
monoriseStore.setState(
|
|
2757
|
-
|
|
2689
|
+
produce4((state) => {
|
|
2758
2690
|
var _a, _b;
|
|
2759
2691
|
(_b = (_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
|
|
2760
2692
|
})
|
|
@@ -2872,10 +2804,9 @@ var initAxiosInterceptor = (store2, appActions) => {
|
|
|
2872
2804
|
});
|
|
2873
2805
|
return axios2;
|
|
2874
2806
|
};
|
|
2875
|
-
var injectAxiosInterceptor = (appActions,
|
|
2807
|
+
var injectAxiosInterceptor = (appActions, axios2, opts) => {
|
|
2876
2808
|
let options = opts || {};
|
|
2877
2809
|
const { endLoading: endLoading2, setError: setError2, clearError: clearError2 } = appActions;
|
|
2878
|
-
const { setIsUnauthorized: setIsUnauthorized2 } = authActions;
|
|
2879
2810
|
const unknownError = {
|
|
2880
2811
|
status: 500,
|
|
2881
2812
|
code: "UNKNOWN_EXCEPTION",
|
|
@@ -2912,7 +2843,7 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2912
2843
|
return Promise.resolve(response);
|
|
2913
2844
|
},
|
|
2914
2845
|
(error) => {
|
|
2915
|
-
var _a, _b, _c, _d
|
|
2846
|
+
var _a, _b, _c, _d;
|
|
2916
2847
|
const config = error.config;
|
|
2917
2848
|
settleLoading(config);
|
|
2918
2849
|
const appError = ((_a = error.response) == null ? void 0 : _a.data) ? {
|
|
@@ -2923,9 +2854,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2923
2854
|
for (const errorKey of getErrorKeys(config)) {
|
|
2924
2855
|
setError2({ requestKey: errorKey, error: appError });
|
|
2925
2856
|
}
|
|
2926
|
-
if (((_e = error.response) == null ? void 0 : _e.status) === 401) {
|
|
2927
|
-
setIsUnauthorized2(true);
|
|
2928
|
-
}
|
|
2929
2857
|
return Promise.reject(error);
|
|
2930
2858
|
}
|
|
2931
2859
|
);
|
|
@@ -2935,43 +2863,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2935
2863
|
return { setOptions };
|
|
2936
2864
|
};
|
|
2937
2865
|
|
|
2938
|
-
// services/auth.service.ts
|
|
2939
|
-
var initAuthService = (axios2) => {
|
|
2940
|
-
let options = {};
|
|
2941
|
-
const { apiBaseUrl = "/api/auth" } = options;
|
|
2942
|
-
const requestLoginMagicLink = (entityType, payload) => {
|
|
2943
|
-
return axios2.post(
|
|
2944
|
-
`${apiBaseUrl}/${entityType}`,
|
|
2945
|
-
{
|
|
2946
|
-
body: __spreadValues({}, payload)
|
|
2947
|
-
},
|
|
2948
|
-
{
|
|
2949
|
-
requestKey: `auth/${entityType}/request-login`,
|
|
2950
|
-
isInterruptive: true,
|
|
2951
|
-
feedback: {
|
|
2952
|
-
loading: "Requesting login link"
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
);
|
|
2956
|
-
};
|
|
2957
|
-
const getSessionProfile = () => axios2.get("/session", {
|
|
2958
|
-
requestKey: "auth/session"
|
|
2959
|
-
});
|
|
2960
|
-
const logout2 = () => axios2.get("/logout", {
|
|
2961
|
-
requestKey: "auth/logout"
|
|
2962
|
-
});
|
|
2963
|
-
const setOptions = (opts) => {
|
|
2964
|
-
options = __spreadValues(__spreadValues({}, options), opts);
|
|
2965
|
-
};
|
|
2966
|
-
return {
|
|
2967
|
-
requestLoginMagicLink,
|
|
2968
|
-
getSessionProfile,
|
|
2969
|
-
logout: logout2,
|
|
2970
|
-
setOptions
|
|
2971
|
-
};
|
|
2972
|
-
};
|
|
2973
|
-
var auth_service_default = initAuthService;
|
|
2974
|
-
|
|
2975
2866
|
// services/core.service.ts
|
|
2976
2867
|
var ENTITY_API_BASE_URL = "/api/core/entity";
|
|
2977
2868
|
var MUTUAL_API_BASE_URL = "/api/core/mutual";
|
|
@@ -3526,16 +3417,7 @@ var initMonoriseStore = () => {
|
|
|
3526
3417
|
config: {},
|
|
3527
3418
|
entity: {},
|
|
3528
3419
|
mutual: {},
|
|
3529
|
-
tag: {}
|
|
3530
|
-
auth: {
|
|
3531
|
-
isUnauthorized: false,
|
|
3532
|
-
profile: {
|
|
3533
|
-
displayName: "",
|
|
3534
|
-
email: "",
|
|
3535
|
-
accountId: ""
|
|
3536
|
-
},
|
|
3537
|
-
isLoading: true
|
|
3538
|
-
}
|
|
3420
|
+
tag: {}
|
|
3539
3421
|
}),
|
|
3540
3422
|
configureDevtools("monorise")
|
|
3541
3423
|
)
|
|
@@ -3552,10 +3434,8 @@ var initMonorise = () => {
|
|
|
3552
3434
|
const appActions = initAppActions(store2);
|
|
3553
3435
|
const configActions = initConfigActions(store2);
|
|
3554
3436
|
const axios2 = initAxiosInterceptor(store2, appActions);
|
|
3555
|
-
const authService2 = auth_service_default(axios2);
|
|
3556
3437
|
const filestoreService2 = filestore_service_default(axios2);
|
|
3557
3438
|
const coreService2 = core_service_default(store2, axios2);
|
|
3558
|
-
const authActions = initAuthActions(store2, authService2);
|
|
3559
3439
|
const coreActions = initCoreActions(store2, appActions, coreService2);
|
|
3560
3440
|
const websocketActions = initWebSocketActions(store2, {
|
|
3561
3441
|
listEntities: async (entityType, params) => {
|
|
@@ -3570,19 +3450,12 @@ var initMonorise = () => {
|
|
|
3570
3450
|
return { entities: data.entities, lastKey: data.lastKey };
|
|
3571
3451
|
}
|
|
3572
3452
|
});
|
|
3573
|
-
const axiosInterceptor = injectAxiosInterceptor(
|
|
3574
|
-
appActions,
|
|
3575
|
-
authActions,
|
|
3576
|
-
axios2
|
|
3577
|
-
);
|
|
3453
|
+
const axiosInterceptor = injectAxiosInterceptor(appActions, axios2);
|
|
3578
3454
|
const config = (opts) => {
|
|
3579
3455
|
setMonoriseOptions({
|
|
3580
3456
|
modals: opts.modals
|
|
3581
3457
|
});
|
|
3582
3458
|
configActions.setConfig(opts.entityConfig);
|
|
3583
|
-
authService2.setOptions({
|
|
3584
|
-
apiBaseUrl: opts.authBaseUrl
|
|
3585
|
-
});
|
|
3586
3459
|
filestoreService2.setOptions({
|
|
3587
3460
|
apiBaseUrl: opts.filestoreBaseUrl
|
|
3588
3461
|
});
|
|
@@ -3595,20 +3468,18 @@ var initMonorise = () => {
|
|
|
3595
3468
|
onApiSuccess: opts.onApiSuccess
|
|
3596
3469
|
});
|
|
3597
3470
|
};
|
|
3598
|
-
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(
|
|
3471
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
3599
3472
|
config,
|
|
3600
3473
|
store: store2,
|
|
3601
3474
|
axios: axios2,
|
|
3602
|
-
authService: authService2,
|
|
3603
3475
|
filestoreService: filestoreService2,
|
|
3604
3476
|
coreService: coreService2
|
|
3605
|
-
}, configActions), appActions),
|
|
3477
|
+
}, configActions), appActions), coreActions), websocketActions);
|
|
3606
3478
|
};
|
|
3607
3479
|
var Monorise = initMonorise();
|
|
3608
3480
|
var {
|
|
3609
3481
|
store,
|
|
3610
3482
|
axios,
|
|
3611
|
-
authService,
|
|
3612
3483
|
filestoreService,
|
|
3613
3484
|
coreService,
|
|
3614
3485
|
setConfig,
|
|
@@ -3625,12 +3496,6 @@ var {
|
|
|
3625
3496
|
useInterruptiveLoadStore,
|
|
3626
3497
|
useErrorStore,
|
|
3627
3498
|
useModalStore,
|
|
3628
|
-
requestLogin,
|
|
3629
|
-
useProfile,
|
|
3630
|
-
getProfile,
|
|
3631
|
-
useIsUnauthorized,
|
|
3632
|
-
setIsUnauthorized,
|
|
3633
|
-
logout,
|
|
3634
3499
|
listMoreEntities,
|
|
3635
3500
|
createEntity,
|
|
3636
3501
|
upsertEntity,
|
|
@@ -3674,7 +3539,6 @@ var index_default = Monorise;
|
|
|
3674
3539
|
export {
|
|
3675
3540
|
WebSocketManager,
|
|
3676
3541
|
adjustEntity,
|
|
3677
|
-
authService,
|
|
3678
3542
|
axios,
|
|
3679
3543
|
clearError,
|
|
3680
3544
|
closeModal,
|
|
@@ -3698,18 +3562,14 @@ export {
|
|
|
3698
3562
|
getError,
|
|
3699
3563
|
getMutual,
|
|
3700
3564
|
getMutualRequestKey,
|
|
3701
|
-
getProfile,
|
|
3702
3565
|
getTagRequestKey,
|
|
3703
3566
|
getUniqueFieldRequestKey,
|
|
3704
3567
|
getWebSocketManager,
|
|
3705
3568
|
initializeWebSocketManager,
|
|
3706
3569
|
listMoreEntities,
|
|
3707
|
-
logout,
|
|
3708
3570
|
openModal,
|
|
3709
|
-
requestLogin,
|
|
3710
3571
|
setConfig,
|
|
3711
3572
|
setError,
|
|
3712
|
-
setIsUnauthorized,
|
|
3713
3573
|
startLoading,
|
|
3714
3574
|
store,
|
|
3715
3575
|
transactional,
|
|
@@ -3735,13 +3595,11 @@ export {
|
|
|
3735
3595
|
useErrorStore,
|
|
3736
3596
|
useExecuteTransaction,
|
|
3737
3597
|
useInterruptiveLoadStore,
|
|
3738
|
-
useIsUnauthorized,
|
|
3739
3598
|
useLoadStore,
|
|
3740
3599
|
useModalStore,
|
|
3741
3600
|
useMutual,
|
|
3742
3601
|
useMutualSocket,
|
|
3743
3602
|
useMutuals,
|
|
3744
|
-
useProfile,
|
|
3745
3603
|
useTaggedEntities,
|
|
3746
3604
|
useUpsertEntity
|
|
3747
3605
|
};
|