monorise 1.15.0 → 2.0.0-dev.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/dist/base/index.d.ts +227 -1
- package/dist/base/index.js +382 -0
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +300 -131
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/templates/files/api-keys.ts +12 -0
- package/dist/cli/templates/files/monorise.config.ts +2 -0
- package/dist/cli/templates/files/proxy-route.ts +12 -22
- package/dist/cli/templates/files/sst.config.ts +4 -1
- package/dist/cli/templates/files/ws-ticket-route.ts +21 -0
- package/dist/core/index.d.ts +63 -36
- package/dist/core/index.js +785 -208
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +24 -7
- package/dist/proxy/index.d.ts +275 -2
- package/dist/proxy/index.js +696 -37
- package/dist/proxy/index.js.map +1 -1
- package/dist/react/index.d.ts +2 -164
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +47 -189
- package/dist/react/index.js.map +1 -1
- package/dist/react/lib/api.d.ts +1 -2
- package/dist/react/lib/api.d.ts.map +1 -1
- package/dist/react/store/monorise.store.d.ts +0 -54
- package/dist/react/store/monorise.store.d.ts.map +1 -1
- package/dist/sst/components/monorise-core.d.ts.map +1 -1
- package/dist/sst/index.js +4 -1
- package/dist/sst/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/templates/files/proxy-request.ts +0 -50
- package/dist/react/actions/auth.action.d.ts +0 -24
- package/dist/react/actions/auth.action.d.ts.map +0 -1
- package/dist/react/services/auth.service.d.ts +0 -21
- package/dist/react/services/auth.service.d.ts.map +0 -1
package/dist/react/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
|
|
@@ -567,7 +499,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
567
499
|
...store2.entity[entityType].dataMap
|
|
568
500
|
]);
|
|
569
501
|
monoriseStore.setState(
|
|
570
|
-
|
|
502
|
+
produce3((state) => {
|
|
571
503
|
state.entity[entityType] = {
|
|
572
504
|
dataMap: params.skRange ? newEntityMap : mergedMap,
|
|
573
505
|
isFirstFetched: true,
|
|
@@ -607,7 +539,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
607
539
|
opts
|
|
608
540
|
);
|
|
609
541
|
monoriseStore.setState(
|
|
610
|
-
|
|
542
|
+
produce3((state) => {
|
|
611
543
|
state.entity[entityType].isFirstFetched = true;
|
|
612
544
|
state.entity[entityType].lastKey = result.lastKey;
|
|
613
545
|
for (const i in result.data) {
|
|
@@ -630,7 +562,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
630
562
|
latestSearchQueries.set(entityType, query);
|
|
631
563
|
if (!canSearch(monoriseStore.getState(), entityType, query)) {
|
|
632
564
|
monoriseStore.setState(
|
|
633
|
-
|
|
565
|
+
produce3((state) => {
|
|
634
566
|
applySearchResults(state, entityType, query, []);
|
|
635
567
|
})
|
|
636
568
|
);
|
|
@@ -640,7 +572,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
640
572
|
const { data: result } = await entityService.searchEntities(query, opts);
|
|
641
573
|
if (latestSearchQueries.get(entityType) !== query) return;
|
|
642
574
|
monoriseStore.setState(
|
|
643
|
-
|
|
575
|
+
produce3((state) => {
|
|
644
576
|
applySearchResults(
|
|
645
577
|
state,
|
|
646
578
|
entityType,
|
|
@@ -691,14 +623,14 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
691
623
|
}));
|
|
692
624
|
const { entities, lastKey } = data;
|
|
693
625
|
monoriseStore.setState(
|
|
694
|
-
|
|
626
|
+
produce3((state2) => {
|
|
695
627
|
for (const entity of entities) {
|
|
696
628
|
state2.entity[entityType].dataMap.set(entity.entityId, entity);
|
|
697
629
|
}
|
|
698
630
|
})
|
|
699
631
|
);
|
|
700
632
|
monoriseStore.setState(
|
|
701
|
-
|
|
633
|
+
produce3((state2) => {
|
|
702
634
|
if (!state2.tag[tagKey]) {
|
|
703
635
|
state2.tag[tagKey] = {
|
|
704
636
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -745,7 +677,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
745
677
|
try {
|
|
746
678
|
({ data: entity } = await entityService.getEntity(id, opts));
|
|
747
679
|
monoriseStore.setState(
|
|
748
|
-
|
|
680
|
+
produce3((state) => {
|
|
749
681
|
state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
|
|
750
682
|
}),
|
|
751
683
|
void 0,
|
|
@@ -789,7 +721,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
789
721
|
opts
|
|
790
722
|
));
|
|
791
723
|
monoriseStore.setState(
|
|
792
|
-
|
|
724
|
+
produce3((state) => {
|
|
793
725
|
state.entity[entityType].dataMap.set(entity == null ? void 0 : entity.entityId, entity);
|
|
794
726
|
state.entity[entityType].dataMap.set(`${stateKey}`, entity);
|
|
795
727
|
}),
|
|
@@ -836,7 +768,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
836
768
|
try {
|
|
837
769
|
const { data } = await entityService.createEntity(entity, opts);
|
|
838
770
|
monoriseStore.setState(
|
|
839
|
-
|
|
771
|
+
produce3((state) => {
|
|
840
772
|
var _a2, _b;
|
|
841
773
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
842
774
|
const tagConfigs = (_a2 = state.config[entityType]) == null ? void 0 : _a2.tags;
|
|
@@ -908,7 +840,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
908
840
|
try {
|
|
909
841
|
const { data } = await entityService.upsertEntity(id, entity, opts);
|
|
910
842
|
monoriseStore.setState(
|
|
911
|
-
|
|
843
|
+
produce3((state) => {
|
|
912
844
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
913
845
|
updateSearchResult(
|
|
914
846
|
state,
|
|
@@ -1019,7 +951,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1019
951
|
try {
|
|
1020
952
|
const { data } = await entityService.editEntity(id, entity, opts);
|
|
1021
953
|
monoriseStore.setState(
|
|
1022
|
-
|
|
954
|
+
produce3((state) => {
|
|
1023
955
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
1024
956
|
propagateEntityDataToMutuals(state, entityType, id, data.data);
|
|
1025
957
|
reconcileTaggedEntityStore(
|
|
@@ -1051,7 +983,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1051
983
|
try {
|
|
1052
984
|
const { data } = await entityService.adjustEntity(id, adjustments, opts);
|
|
1053
985
|
monoriseStore.setState(
|
|
1054
|
-
|
|
986
|
+
produce3((state) => {
|
|
1055
987
|
state.entity[entityType].dataMap.set(data.entityId, data);
|
|
1056
988
|
propagateEntityDataToMutuals(state, entityType, id, data.data);
|
|
1057
989
|
reconcileTaggedEntityStore(
|
|
@@ -1087,7 +1019,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1087
1019
|
await entityService.deleteEntity(id, opts);
|
|
1088
1020
|
deleteLocalMutualsByEntity(entityType, id);
|
|
1089
1021
|
monoriseStore.setState(
|
|
1090
|
-
|
|
1022
|
+
produce3((state) => {
|
|
1091
1023
|
deleteEntityFromStores(state, entityType, id);
|
|
1092
1024
|
}),
|
|
1093
1025
|
void 0,
|
|
@@ -1128,7 +1060,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1128
1060
|
settled = true;
|
|
1129
1061
|
const deletedEntities = [];
|
|
1130
1062
|
monoriseStore.setState(
|
|
1131
|
-
|
|
1063
|
+
produce3((state) => {
|
|
1132
1064
|
data.results.forEach((entry, index) => {
|
|
1133
1065
|
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l;
|
|
1134
1066
|
const { entityType, entityId } = entry;
|
|
@@ -1305,7 +1237,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1305
1237
|
newEntityDataMap.set(entities[i].entityId, entities[i]);
|
|
1306
1238
|
}
|
|
1307
1239
|
monoriseStore.setState(
|
|
1308
|
-
|
|
1240
|
+
produce3((state) => {
|
|
1309
1241
|
var _a2;
|
|
1310
1242
|
for (const [key, value] of newEntityDataMap) {
|
|
1311
1243
|
(_a2 = state.entity[entityType]) == null ? void 0 : _a2.dataMap.set(key, value);
|
|
@@ -1399,7 +1331,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1399
1331
|
const newEntityDataMap = new Map(entityDataMap);
|
|
1400
1332
|
newEntityDataMap.set(mutual.entityId, mutual);
|
|
1401
1333
|
monoriseStore.setState(
|
|
1402
|
-
|
|
1334
|
+
produce3((state) => {
|
|
1403
1335
|
state.mutual[selfKey] = __spreadProps(__spreadValues({}, state.mutual[selfKey] || {}), {
|
|
1404
1336
|
dataMap: newMutualDataMap
|
|
1405
1337
|
});
|
|
@@ -1428,7 +1360,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1428
1360
|
opts
|
|
1429
1361
|
);
|
|
1430
1362
|
monoriseStore.setState(
|
|
1431
|
-
|
|
1363
|
+
produce3((state) => {
|
|
1432
1364
|
var _a2, _b, _c, _d, _e;
|
|
1433
1365
|
const bySide = getMutualStateKey(
|
|
1434
1366
|
byEntityType,
|
|
@@ -1475,7 +1407,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1475
1407
|
data
|
|
1476
1408
|
);
|
|
1477
1409
|
monoriseStore.setState(
|
|
1478
|
-
|
|
1410
|
+
produce3((state) => {
|
|
1479
1411
|
var _a, _b, _c, _d, _e;
|
|
1480
1412
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1481
1413
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1505,7 +1437,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1505
1437
|
const updateLocalEntity2 = async (entityType, entityId, data = {}) => {
|
|
1506
1438
|
const createdEntity = constructLocal(entityType, entityId, data);
|
|
1507
1439
|
monoriseStore.setState(
|
|
1508
|
-
|
|
1440
|
+
produce3((state) => {
|
|
1509
1441
|
state.entity[entityType].dataMap.set(entityId, createdEntity);
|
|
1510
1442
|
updateSearchResult(
|
|
1511
1443
|
state,
|
|
@@ -1527,7 +1459,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1527
1459
|
data
|
|
1528
1460
|
);
|
|
1529
1461
|
monoriseStore.setState(
|
|
1530
|
-
|
|
1462
|
+
produce3((state) => {
|
|
1531
1463
|
var _a, _b, _c, _d, _e;
|
|
1532
1464
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1533
1465
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1566,7 +1498,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1566
1498
|
opts
|
|
1567
1499
|
);
|
|
1568
1500
|
monoriseStore.setState(
|
|
1569
|
-
|
|
1501
|
+
produce3((state) => {
|
|
1570
1502
|
var _a2, _b, _c, _d, _e;
|
|
1571
1503
|
const bySide = getMutualStateKey(
|
|
1572
1504
|
byEntityType,
|
|
@@ -1614,7 +1546,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1614
1546
|
opts
|
|
1615
1547
|
);
|
|
1616
1548
|
monoriseStore.setState(
|
|
1617
|
-
|
|
1549
|
+
produce3((state) => {
|
|
1618
1550
|
var _a2, _b;
|
|
1619
1551
|
const bySide = getMutualStateKey(
|
|
1620
1552
|
byEntityType,
|
|
@@ -1637,7 +1569,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1637
1569
|
};
|
|
1638
1570
|
const deleteLocalMutual2 = (byEntityType, entityType, byEntityId2, entityId) => {
|
|
1639
1571
|
monoriseStore.setState(
|
|
1640
|
-
|
|
1572
|
+
produce3((state) => {
|
|
1641
1573
|
var _a, _b;
|
|
1642
1574
|
const bySide = getMutualStateKey(byEntityType, byEntityId2, entityType);
|
|
1643
1575
|
const side = getMutualStateKey(entityType, entityId, byEntityType);
|
|
@@ -1685,7 +1617,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1685
1617
|
{}
|
|
1686
1618
|
);
|
|
1687
1619
|
monoriseStore.setState(
|
|
1688
|
-
|
|
1620
|
+
produce3((state) => {
|
|
1689
1621
|
for (const key in updatedState) {
|
|
1690
1622
|
state.mutual[key] = updatedState[key];
|
|
1691
1623
|
}
|
|
@@ -2254,7 +2186,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2254
2186
|
params
|
|
2255
2187
|
);
|
|
2256
2188
|
monoriseStore.setState(
|
|
2257
|
-
|
|
2189
|
+
produce3((state) => {
|
|
2258
2190
|
var _a, _b;
|
|
2259
2191
|
const entity = (_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.get(entityId);
|
|
2260
2192
|
if (entity) {
|
|
@@ -2274,7 +2206,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2274
2206
|
params
|
|
2275
2207
|
);
|
|
2276
2208
|
monoriseStore.setState(
|
|
2277
|
-
|
|
2209
|
+
produce3((state) => {
|
|
2278
2210
|
var _a, _b;
|
|
2279
2211
|
if ((_b = (_a = state.tag[tagKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.has(entityId)) {
|
|
2280
2212
|
state.tag[tagKey].dataMap.delete(entityId);
|
|
@@ -2324,7 +2256,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2324
2256
|
|
|
2325
2257
|
// actions/websocket.action.ts
|
|
2326
2258
|
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
2327
|
-
import { produce as
|
|
2259
|
+
import { produce as produce4 } from "immer";
|
|
2328
2260
|
var globalWsManager = null;
|
|
2329
2261
|
var wsEndpoint;
|
|
2330
2262
|
var initializeWebSocketManager = (WebSocketManagerClass, endpoint, token) => {
|
|
@@ -2368,7 +2300,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2368
2300
|
lastKey: fetchLastKey
|
|
2369
2301
|
});
|
|
2370
2302
|
monoriseStore.setState(
|
|
2371
|
-
|
|
2303
|
+
produce4((state) => {
|
|
2372
2304
|
if (type === "refresh") {
|
|
2373
2305
|
state.entity[entityType].dataMap.clear();
|
|
2374
2306
|
}
|
|
@@ -2416,7 +2348,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2416
2348
|
if (msg.type === "entity.created" || msg.type === "entity.updated") {
|
|
2417
2349
|
if (payload.data) {
|
|
2418
2350
|
monoriseStore.setState(
|
|
2419
|
-
|
|
2351
|
+
produce4((state) => {
|
|
2420
2352
|
const key = entityType;
|
|
2421
2353
|
if (!state.entity[key]) {
|
|
2422
2354
|
state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
@@ -2435,7 +2367,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2435
2367
|
}
|
|
2436
2368
|
} else if (msg.type === "entity.deleted") {
|
|
2437
2369
|
monoriseStore.setState(
|
|
2438
|
-
|
|
2370
|
+
produce4((state) => {
|
|
2439
2371
|
var _a;
|
|
2440
2372
|
const key = entityType;
|
|
2441
2373
|
if ((_a = state.entity[key]) == null ? void 0 : _a.dataMap) {
|
|
@@ -2506,7 +2438,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2506
2438
|
{ limit, lastKey: fetchLastKey }
|
|
2507
2439
|
);
|
|
2508
2440
|
monoriseStore.setState(
|
|
2509
|
-
|
|
2441
|
+
produce4((state) => {
|
|
2510
2442
|
if (!state.mutual[mutualKey]) {
|
|
2511
2443
|
state.mutual[mutualKey] = {
|
|
2512
2444
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -2573,7 +2505,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2573
2505
|
if (msg.type === "mutual.created" || msg.type === "mutual.updated") {
|
|
2574
2506
|
if (payload.data) {
|
|
2575
2507
|
monoriseStore.setState(
|
|
2576
|
-
|
|
2508
|
+
produce4((state) => {
|
|
2577
2509
|
if (!state.mutual[mutualKey]) {
|
|
2578
2510
|
state.mutual[mutualKey] = {
|
|
2579
2511
|
dataMap: /* @__PURE__ */ new Map(),
|
|
@@ -2590,7 +2522,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2590
2522
|
}
|
|
2591
2523
|
} else if (msg.type === "mutual.deleted") {
|
|
2592
2524
|
monoriseStore.setState(
|
|
2593
|
-
|
|
2525
|
+
produce4((state) => {
|
|
2594
2526
|
var _a;
|
|
2595
2527
|
(_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap.delete(payload.entityId);
|
|
2596
2528
|
})
|
|
@@ -2679,7 +2611,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2679
2611
|
);
|
|
2680
2612
|
if (!isMountedRef.current) return;
|
|
2681
2613
|
monoriseStore.setState(
|
|
2682
|
-
|
|
2614
|
+
produce4((draft) => {
|
|
2683
2615
|
const slice = draft.mutual[key];
|
|
2684
2616
|
if (!slice) return;
|
|
2685
2617
|
slice.dataMap.clear();
|
|
@@ -2794,7 +2726,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2794
2726
|
const payload = msg.payload;
|
|
2795
2727
|
if (payload.data) {
|
|
2796
2728
|
monoriseStore.setState(
|
|
2797
|
-
|
|
2729
|
+
produce4((state) => {
|
|
2798
2730
|
const key = payload.entityType;
|
|
2799
2731
|
if (!state.entity[key]) {
|
|
2800
2732
|
state.entity[key] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
@@ -2811,7 +2743,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2811
2743
|
} else if (msg.type === "entity.deleted") {
|
|
2812
2744
|
const payload = msg.payload;
|
|
2813
2745
|
monoriseStore.setState(
|
|
2814
|
-
|
|
2746
|
+
produce4((state) => {
|
|
2815
2747
|
var _a, _b;
|
|
2816
2748
|
(_b = (_a = state.entity[payload.entityType]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
|
|
2817
2749
|
removeFromSearchResults(
|
|
@@ -2826,7 +2758,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2826
2758
|
if (payload.data) {
|
|
2827
2759
|
const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
|
|
2828
2760
|
monoriseStore.setState(
|
|
2829
|
-
|
|
2761
|
+
produce4((state) => {
|
|
2830
2762
|
if (!state.mutual[mutualKey]) {
|
|
2831
2763
|
state.mutual[mutualKey] = { dataMap: /* @__PURE__ */ new Map(), isFirstFetched: false, lastKey: void 0 };
|
|
2832
2764
|
}
|
|
@@ -2838,7 +2770,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2838
2770
|
const payload = msg.payload;
|
|
2839
2771
|
const mutualKey = `${payload.byEntityType}/${payload.byEntityId}/${payload.mutualEntityType}`;
|
|
2840
2772
|
monoriseStore.setState(
|
|
2841
|
-
|
|
2773
|
+
produce4((state) => {
|
|
2842
2774
|
var _a, _b;
|
|
2843
2775
|
(_b = (_a = state.mutual[mutualKey]) == null ? void 0 : _a.dataMap) == null ? void 0 : _b.delete(payload.entityId);
|
|
2844
2776
|
})
|
|
@@ -2956,10 +2888,9 @@ var initAxiosInterceptor = (store2, appActions) => {
|
|
|
2956
2888
|
});
|
|
2957
2889
|
return axios2;
|
|
2958
2890
|
};
|
|
2959
|
-
var injectAxiosInterceptor = (appActions,
|
|
2891
|
+
var injectAxiosInterceptor = (appActions, axios2, opts) => {
|
|
2960
2892
|
let options = opts || {};
|
|
2961
2893
|
const { endLoading: endLoading2, setError: setError2, clearError: clearError2 } = appActions;
|
|
2962
|
-
const { setIsUnauthorized: setIsUnauthorized2 } = authActions;
|
|
2963
2894
|
const unknownError = {
|
|
2964
2895
|
status: 500,
|
|
2965
2896
|
code: "UNKNOWN_EXCEPTION",
|
|
@@ -2996,7 +2927,7 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2996
2927
|
return Promise.resolve(response);
|
|
2997
2928
|
},
|
|
2998
2929
|
(error) => {
|
|
2999
|
-
var _a, _b, _c, _d
|
|
2930
|
+
var _a, _b, _c, _d;
|
|
3000
2931
|
const config = error.config;
|
|
3001
2932
|
settleLoading(config);
|
|
3002
2933
|
const appError = ((_a = error.response) == null ? void 0 : _a.data) ? {
|
|
@@ -3007,9 +2938,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
3007
2938
|
for (const errorKey of getErrorKeys(config)) {
|
|
3008
2939
|
setError2({ requestKey: errorKey, error: appError });
|
|
3009
2940
|
}
|
|
3010
|
-
if (((_e = error.response) == null ? void 0 : _e.status) === 401) {
|
|
3011
|
-
setIsUnauthorized2(true);
|
|
3012
|
-
}
|
|
3013
2941
|
return Promise.reject(error);
|
|
3014
2942
|
}
|
|
3015
2943
|
);
|
|
@@ -3019,43 +2947,6 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
3019
2947
|
return { setOptions };
|
|
3020
2948
|
};
|
|
3021
2949
|
|
|
3022
|
-
// services/auth.service.ts
|
|
3023
|
-
var initAuthService = (axios2) => {
|
|
3024
|
-
let options = {};
|
|
3025
|
-
const { apiBaseUrl = "/api/auth" } = options;
|
|
3026
|
-
const requestLoginMagicLink = (entityType, payload) => {
|
|
3027
|
-
return axios2.post(
|
|
3028
|
-
`${apiBaseUrl}/${entityType}`,
|
|
3029
|
-
{
|
|
3030
|
-
body: __spreadValues({}, payload)
|
|
3031
|
-
},
|
|
3032
|
-
{
|
|
3033
|
-
requestKey: `auth/${entityType}/request-login`,
|
|
3034
|
-
isInterruptive: true,
|
|
3035
|
-
feedback: {
|
|
3036
|
-
loading: "Requesting login link"
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
);
|
|
3040
|
-
};
|
|
3041
|
-
const getSessionProfile = () => axios2.get("/session", {
|
|
3042
|
-
requestKey: "auth/session"
|
|
3043
|
-
});
|
|
3044
|
-
const logout2 = () => axios2.get("/logout", {
|
|
3045
|
-
requestKey: "auth/logout"
|
|
3046
|
-
});
|
|
3047
|
-
const setOptions = (opts) => {
|
|
3048
|
-
options = __spreadValues(__spreadValues({}, options), opts);
|
|
3049
|
-
};
|
|
3050
|
-
return {
|
|
3051
|
-
requestLoginMagicLink,
|
|
3052
|
-
getSessionProfile,
|
|
3053
|
-
logout: logout2,
|
|
3054
|
-
setOptions
|
|
3055
|
-
};
|
|
3056
|
-
};
|
|
3057
|
-
var auth_service_default = initAuthService;
|
|
3058
|
-
|
|
3059
2950
|
// services/core.service.ts
|
|
3060
2951
|
var ENTITY_API_BASE_URL = "/api/core/entity";
|
|
3061
2952
|
var MUTUAL_API_BASE_URL = "/api/core/mutual";
|
|
@@ -3614,16 +3505,7 @@ var initMonoriseStore = () => {
|
|
|
3614
3505
|
config: {},
|
|
3615
3506
|
entity: {},
|
|
3616
3507
|
mutual: {},
|
|
3617
|
-
tag: {}
|
|
3618
|
-
auth: {
|
|
3619
|
-
isUnauthorized: false,
|
|
3620
|
-
profile: {
|
|
3621
|
-
displayName: "",
|
|
3622
|
-
email: "",
|
|
3623
|
-
accountId: ""
|
|
3624
|
-
},
|
|
3625
|
-
isLoading: true
|
|
3626
|
-
}
|
|
3508
|
+
tag: {}
|
|
3627
3509
|
}),
|
|
3628
3510
|
configureDevtools("monorise")
|
|
3629
3511
|
)
|
|
@@ -3640,10 +3522,8 @@ var initMonorise = () => {
|
|
|
3640
3522
|
const appActions = initAppActions(store2);
|
|
3641
3523
|
const configActions = initConfigActions(store2);
|
|
3642
3524
|
const axios2 = initAxiosInterceptor(store2, appActions);
|
|
3643
|
-
const authService2 = auth_service_default(axios2);
|
|
3644
3525
|
const filestoreService2 = filestore_service_default(axios2);
|
|
3645
3526
|
const coreService2 = core_service_default(store2, axios2);
|
|
3646
|
-
const authActions = initAuthActions(store2, authService2);
|
|
3647
3527
|
const coreActions = initCoreActions(store2, appActions, coreService2);
|
|
3648
3528
|
const websocketActions = initWebSocketActions(store2, {
|
|
3649
3529
|
listEntities: async (entityType, params) => {
|
|
@@ -3658,19 +3538,12 @@ var initMonorise = () => {
|
|
|
3658
3538
|
return { entities: data.entities, lastKey: data.lastKey };
|
|
3659
3539
|
}
|
|
3660
3540
|
});
|
|
3661
|
-
const axiosInterceptor = injectAxiosInterceptor(
|
|
3662
|
-
appActions,
|
|
3663
|
-
authActions,
|
|
3664
|
-
axios2
|
|
3665
|
-
);
|
|
3541
|
+
const axiosInterceptor = injectAxiosInterceptor(appActions, axios2);
|
|
3666
3542
|
const config = (opts) => {
|
|
3667
3543
|
setMonoriseOptions({
|
|
3668
3544
|
modals: opts.modals
|
|
3669
3545
|
});
|
|
3670
3546
|
configActions.setConfig(opts.entityConfig);
|
|
3671
|
-
authService2.setOptions({
|
|
3672
|
-
apiBaseUrl: opts.authBaseUrl
|
|
3673
|
-
});
|
|
3674
3547
|
filestoreService2.setOptions({
|
|
3675
3548
|
apiBaseUrl: opts.filestoreBaseUrl
|
|
3676
3549
|
});
|
|
@@ -3683,20 +3556,18 @@ var initMonorise = () => {
|
|
|
3683
3556
|
onApiSuccess: opts.onApiSuccess
|
|
3684
3557
|
});
|
|
3685
3558
|
};
|
|
3686
|
-
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(
|
|
3559
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
3687
3560
|
config,
|
|
3688
3561
|
store: store2,
|
|
3689
3562
|
axios: axios2,
|
|
3690
|
-
authService: authService2,
|
|
3691
3563
|
filestoreService: filestoreService2,
|
|
3692
3564
|
coreService: coreService2
|
|
3693
|
-
}, configActions), appActions),
|
|
3565
|
+
}, configActions), appActions), coreActions), websocketActions);
|
|
3694
3566
|
};
|
|
3695
3567
|
var Monorise = initMonorise();
|
|
3696
3568
|
var {
|
|
3697
3569
|
store,
|
|
3698
3570
|
axios,
|
|
3699
|
-
authService,
|
|
3700
3571
|
filestoreService,
|
|
3701
3572
|
coreService,
|
|
3702
3573
|
setConfig,
|
|
@@ -3713,12 +3584,6 @@ var {
|
|
|
3713
3584
|
useInterruptiveLoadStore,
|
|
3714
3585
|
useErrorStore,
|
|
3715
3586
|
useModalStore,
|
|
3716
|
-
requestLogin,
|
|
3717
|
-
useProfile,
|
|
3718
|
-
getProfile,
|
|
3719
|
-
useIsUnauthorized,
|
|
3720
|
-
setIsUnauthorized,
|
|
3721
|
-
logout,
|
|
3722
3587
|
listMoreEntities,
|
|
3723
3588
|
createEntity,
|
|
3724
3589
|
upsertEntity,
|
|
@@ -3762,7 +3627,6 @@ var index_default = Monorise;
|
|
|
3762
3627
|
export {
|
|
3763
3628
|
WebSocketManager,
|
|
3764
3629
|
adjustEntity,
|
|
3765
|
-
authService,
|
|
3766
3630
|
axios,
|
|
3767
3631
|
clearError,
|
|
3768
3632
|
closeModal,
|
|
@@ -3786,18 +3650,14 @@ export {
|
|
|
3786
3650
|
getError,
|
|
3787
3651
|
getMutual,
|
|
3788
3652
|
getMutualRequestKey,
|
|
3789
|
-
getProfile,
|
|
3790
3653
|
getTagRequestKey,
|
|
3791
3654
|
getUniqueFieldRequestKey,
|
|
3792
3655
|
getWebSocketManager,
|
|
3793
3656
|
initializeWebSocketManager,
|
|
3794
3657
|
listMoreEntities,
|
|
3795
|
-
logout,
|
|
3796
3658
|
openModal,
|
|
3797
|
-
requestLogin,
|
|
3798
3659
|
setConfig,
|
|
3799
3660
|
setError,
|
|
3800
|
-
setIsUnauthorized,
|
|
3801
3661
|
startLoading,
|
|
3802
3662
|
store,
|
|
3803
3663
|
transactional,
|
|
@@ -3823,13 +3683,11 @@ export {
|
|
|
3823
3683
|
useErrorStore,
|
|
3824
3684
|
useExecuteTransaction,
|
|
3825
3685
|
useInterruptiveLoadStore,
|
|
3826
|
-
useIsUnauthorized,
|
|
3827
3686
|
useLoadStore,
|
|
3828
3687
|
useModalStore,
|
|
3829
3688
|
useMutual,
|
|
3830
3689
|
useMutualSocket,
|
|
3831
3690
|
useMutuals,
|
|
3832
|
-
useProfile,
|
|
3833
3691
|
useTaggedEntities,
|
|
3834
3692
|
useUpsertEntity
|
|
3835
3693
|
};
|