@monorise/react 8.3.2 → 8.4.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/actions/core.action.d.ts +138 -1
- package/dist/actions/core.action.d.ts.map +1 -1
- package/dist/helpers/transactional.d.ts +2 -0
- package/dist/helpers/transactional.d.ts.map +1 -1
- package/dist/index.d.ts +277 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +424 -137
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +1 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +6 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/services/core.service.d.ts.map +1 -1
- package/dist/types/axios.type.d.ts +2 -0
- package/dist/types/axios.type.d.ts.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -277,47 +277,10 @@ var initConfigActions = (store2) => {
|
|
|
277
277
|
|
|
278
278
|
// actions/core.action.ts
|
|
279
279
|
import { produce as produce4 } from "immer";
|
|
280
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
281
|
-
|
|
282
|
-
// lib/entity.ts
|
|
283
|
-
var constructLocal = (entityType, entityId, data) => {
|
|
284
|
-
return {
|
|
285
|
-
entityType,
|
|
286
|
-
entityId,
|
|
287
|
-
data,
|
|
288
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
289
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
var constructMutual = (byEntityType, byEntityId2, entityType, entityId, mutualData, data) => {
|
|
293
|
-
return {
|
|
294
|
-
mutualId: `${byEntityId2}-${entityId}`,
|
|
295
|
-
byEntityType,
|
|
296
|
-
byEntityId: byEntityId2,
|
|
297
|
-
entityType,
|
|
298
|
-
entityId,
|
|
299
|
-
mutualData,
|
|
300
|
-
data,
|
|
301
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
302
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
303
|
-
mutualUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
304
|
-
};
|
|
305
|
-
};
|
|
306
|
-
var flipMutual = (mutual, byEntityData) => {
|
|
307
|
-
return __spreadProps(__spreadValues({}, mutual), {
|
|
308
|
-
entityId: mutual.byEntityId,
|
|
309
|
-
entityType: mutual.byEntityType,
|
|
310
|
-
byEntityId: mutual.entityId,
|
|
311
|
-
byEntityType: mutual.entityType,
|
|
312
|
-
data: byEntityData
|
|
313
|
-
});
|
|
314
|
-
};
|
|
315
|
-
var byEntityId = (a, b) => {
|
|
316
|
-
if (b.entityId < a.entityId) return -1;
|
|
317
|
-
return 1;
|
|
318
|
-
};
|
|
280
|
+
import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
319
281
|
|
|
320
282
|
// lib/utils.ts
|
|
283
|
+
import { nanoid } from "nanoid";
|
|
321
284
|
var convertToMap = (data, mapKey) => {
|
|
322
285
|
const map = /* @__PURE__ */ new Map();
|
|
323
286
|
for (const i in data) {
|
|
@@ -352,6 +315,7 @@ var getUniqueFieldStateKey = (fieldName, fieldValue) => {
|
|
|
352
315
|
var getEntityRequestKey = (mode, entityType, entityId) => {
|
|
353
316
|
return `entity/${entityType}/${mode}${entityId ? `/${entityId}` : ""}`;
|
|
354
317
|
};
|
|
318
|
+
var createMutationCallRequestKey = (requestKey) => `${requestKey}#${nanoid()}`;
|
|
355
319
|
var getMutualRequestKey = (mode, byEntityType, entityType, byEntityId2, entityId, chainEntityQuery) => {
|
|
356
320
|
return `mutual/${getMutualStateKey(byEntityType, byEntityId2, entityType, entityId, chainEntityQuery)}/${mode}`;
|
|
357
321
|
};
|
|
@@ -363,7 +327,6 @@ var getUniqueFieldRequestKey = (entityType, fieldName, value) => {
|
|
|
363
327
|
};
|
|
364
328
|
|
|
365
329
|
// helpers/transactional.ts
|
|
366
|
-
import { nanoid } from "nanoid";
|
|
367
330
|
var getTransactionOperationRequestKey = (op) => {
|
|
368
331
|
switch (op.operation) {
|
|
369
332
|
case "createEntity":
|
|
@@ -381,7 +344,8 @@ var getTransactionOperationRequestKey = (op) => {
|
|
|
381
344
|
"create",
|
|
382
345
|
op.byEntityType,
|
|
383
346
|
op.entityType,
|
|
384
|
-
op.byEntityId
|
|
347
|
+
op.byEntityId,
|
|
348
|
+
op.entityId
|
|
385
349
|
);
|
|
386
350
|
case "updateMutual":
|
|
387
351
|
return getMutualRequestKey(
|
|
@@ -401,14 +365,21 @@ var getTransactionOperationRequestKey = (op) => {
|
|
|
401
365
|
);
|
|
402
366
|
}
|
|
403
367
|
};
|
|
404
|
-
var
|
|
405
|
-
|
|
406
|
-
op.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
368
|
+
var getTransactionOperationRequestKeys = (op) => {
|
|
369
|
+
const requestKey = getTransactionOperationRequestKey(op);
|
|
370
|
+
if (op.operation !== "createMutual") return [requestKey];
|
|
371
|
+
return [
|
|
372
|
+
requestKey,
|
|
373
|
+
getMutualRequestKey(
|
|
374
|
+
"create",
|
|
375
|
+
op.byEntityType,
|
|
376
|
+
op.entityType,
|
|
377
|
+
op.byEntityId
|
|
378
|
+
)
|
|
379
|
+
];
|
|
380
|
+
};
|
|
381
|
+
var getTransactionRequestKey = (operations) => `transaction/${operations.map(getTransactionOperationRequestKey).join("|")}`;
|
|
382
|
+
var createTransactionCallRequestKey = (operations) => createMutationCallRequestKey(getTransactionRequestKey(operations));
|
|
412
383
|
var transactional = {
|
|
413
384
|
createEntity: (entityType, payload) => {
|
|
414
385
|
const _a = payload, { entityId } = _a, rest = __objRest(_a, ["entityId"]);
|
|
@@ -467,6 +438,44 @@ var transactional = {
|
|
|
467
438
|
})
|
|
468
439
|
};
|
|
469
440
|
|
|
441
|
+
// lib/entity.ts
|
|
442
|
+
var constructLocal = (entityType, entityId, data) => {
|
|
443
|
+
return {
|
|
444
|
+
entityType,
|
|
445
|
+
entityId,
|
|
446
|
+
data,
|
|
447
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
448
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
var constructMutual = (byEntityType, byEntityId2, entityType, entityId, mutualData, data) => {
|
|
452
|
+
return {
|
|
453
|
+
mutualId: `${byEntityId2}-${entityId}`,
|
|
454
|
+
byEntityType,
|
|
455
|
+
byEntityId: byEntityId2,
|
|
456
|
+
entityType,
|
|
457
|
+
entityId,
|
|
458
|
+
mutualData,
|
|
459
|
+
data,
|
|
460
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
461
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
462
|
+
mutualUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
var flipMutual = (mutual, byEntityData) => {
|
|
466
|
+
return __spreadProps(__spreadValues({}, mutual), {
|
|
467
|
+
entityId: mutual.byEntityId,
|
|
468
|
+
entityType: mutual.byEntityType,
|
|
469
|
+
byEntityId: mutual.entityId,
|
|
470
|
+
byEntityType: mutual.entityType,
|
|
471
|
+
data: byEntityData
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
var byEntityId = (a, b) => {
|
|
475
|
+
if (b.entityId < a.entityId) return -1;
|
|
476
|
+
return 1;
|
|
477
|
+
};
|
|
478
|
+
|
|
470
479
|
// actions/core.action.ts
|
|
471
480
|
var defaultOnError = (error) => {
|
|
472
481
|
if (!(error instanceof Error) && error.status >= 500) {
|
|
@@ -816,18 +825,20 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
816
825
|
if (keyParams.query) {
|
|
817
826
|
continue;
|
|
818
827
|
}
|
|
819
|
-
const matches = processorResults.some(
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
+
const matches = processorResults.some(
|
|
829
|
+
(result) => {
|
|
830
|
+
if (keyParams.group && result.group !== keyParams.group) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
if (keyParams.start && (!result.sortValue || result.sortValue < keyParams.start)) {
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
if (keyParams.end && (!result.sortValue || result.sortValue > keyParams.end)) {
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
return true;
|
|
828
840
|
}
|
|
829
|
-
|
|
830
|
-
});
|
|
841
|
+
);
|
|
831
842
|
if (matches) {
|
|
832
843
|
state.tag[tagKey].dataMap.set(data.entityId, data);
|
|
833
844
|
}
|
|
@@ -1035,22 +1046,27 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1035
1046
|
}
|
|
1036
1047
|
};
|
|
1037
1048
|
const executeTransaction2 = async (operations, opts = {}) => {
|
|
1038
|
-
var _a, _b, _c, _d;
|
|
1049
|
+
var _a, _b, _c, _d, _e;
|
|
1039
1050
|
const onError = (_a = opts.onError) != null ? _a : defaultOnError;
|
|
1040
1051
|
const isInterruptive = (_b = opts.isInterruptive) != null ? _b : true;
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1052
|
+
const stateRequestKeys = Array.from(
|
|
1053
|
+
/* @__PURE__ */ new Set([
|
|
1054
|
+
getTransactionRequestKey(operations),
|
|
1055
|
+
...operations.flatMap(getTransactionOperationRequestKeys)
|
|
1056
|
+
])
|
|
1057
|
+
);
|
|
1058
|
+
const callRequestKey = (_c = opts.requestKey) != null ? _c : createTransactionCallRequestKey(operations);
|
|
1043
1059
|
const callPromise = coreService2.executeTransaction(operations, __spreadProps(__spreadValues({}, opts), {
|
|
1044
1060
|
requestKey: callRequestKey
|
|
1045
1061
|
}));
|
|
1046
|
-
const loadingMessage = (
|
|
1047
|
-
for (const requestKey of
|
|
1062
|
+
const loadingMessage = (_e = (_d = opts.feedback) == null ? void 0 : _d.loading) != null ? _e : "Processing transaction";
|
|
1063
|
+
for (const requestKey of stateRequestKeys) {
|
|
1048
1064
|
startLoading2({ requestKey, isInterruptive, message: loadingMessage });
|
|
1049
1065
|
}
|
|
1050
1066
|
let settled = false;
|
|
1051
1067
|
try {
|
|
1052
1068
|
const { data } = await callPromise;
|
|
1053
|
-
for (const requestKey of
|
|
1069
|
+
for (const requestKey of stateRequestKeys) {
|
|
1054
1070
|
endLoading2({ requestKey, isInterruptive, skipDedupe: true });
|
|
1055
1071
|
clearError2(requestKey);
|
|
1056
1072
|
}
|
|
@@ -1059,7 +1075,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1059
1075
|
monoriseStore.setState(
|
|
1060
1076
|
produce4((state) => {
|
|
1061
1077
|
data.results.forEach((entry, index) => {
|
|
1062
|
-
var _a2, _b2, _c2, _d2,
|
|
1078
|
+
var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l;
|
|
1063
1079
|
const { entityType, entityId } = entry;
|
|
1064
1080
|
if (entry.operation === "deleteEntity") {
|
|
1065
1081
|
deleteEntityFromStores(state, entityType, entityId);
|
|
@@ -1103,7 +1119,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1103
1119
|
state.mutual[bySide] = { dataMap: /* @__PURE__ */ new Map() };
|
|
1104
1120
|
}
|
|
1105
1121
|
state.mutual[bySide].dataMap = new Map(
|
|
1106
|
-
(
|
|
1122
|
+
(_e2 = state.mutual[bySide]) == null ? void 0 : _e2.dataMap
|
|
1107
1123
|
).set(entityId, mutual);
|
|
1108
1124
|
if (!state.mutual[side]) {
|
|
1109
1125
|
state.mutual[side] = { dataMap: /* @__PURE__ */ new Map() };
|
|
@@ -1167,7 +1183,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1167
1183
|
} catch (err) {
|
|
1168
1184
|
if (!settled) {
|
|
1169
1185
|
const callAppError = getError2(callRequestKey);
|
|
1170
|
-
for (const requestKey of
|
|
1186
|
+
for (const requestKey of stateRequestKeys) {
|
|
1171
1187
|
endLoading2({ requestKey, isInterruptive, skipDedupe: true });
|
|
1172
1188
|
if (callAppError) {
|
|
1173
1189
|
setError2({ requestKey, error: callAppError });
|
|
@@ -1617,6 +1633,192 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
1617
1633
|
`mr/mutual/local-delete-by-entity/${entityType}/${id}`
|
|
1618
1634
|
);
|
|
1619
1635
|
};
|
|
1636
|
+
const mergeMutationOptions = (hookOptions, mutateOptions) => __spreadValues(__spreadValues(__spreadValues({}, hookOptions), mutateOptions), (hookOptions.feedback || mutateOptions.feedback) && {
|
|
1637
|
+
feedback: __spreadValues(__spreadValues({}, hookOptions.feedback), mutateOptions.feedback)
|
|
1638
|
+
});
|
|
1639
|
+
const useLatestRef = (value) => {
|
|
1640
|
+
const ref = useRef(value);
|
|
1641
|
+
ref.current = value;
|
|
1642
|
+
return ref;
|
|
1643
|
+
};
|
|
1644
|
+
const useMutationState = (requestKey) => {
|
|
1645
|
+
const isLoading = useLoadStore2(requestKey);
|
|
1646
|
+
const error = monoriseStore(
|
|
1647
|
+
(state) => state.app.errorStack.get(requestKey)
|
|
1648
|
+
);
|
|
1649
|
+
const clearMutationError = useCallback(
|
|
1650
|
+
() => clearError2(requestKey),
|
|
1651
|
+
[requestKey]
|
|
1652
|
+
);
|
|
1653
|
+
return {
|
|
1654
|
+
isLoading,
|
|
1655
|
+
error,
|
|
1656
|
+
requestKey,
|
|
1657
|
+
clearError: clearMutationError
|
|
1658
|
+
};
|
|
1659
|
+
};
|
|
1660
|
+
const useCreateEntity2 = (entityType, opts = {}) => {
|
|
1661
|
+
const optsRef = useLatestRef(opts);
|
|
1662
|
+
const mutation = useMutationState(
|
|
1663
|
+
getEntityRequestKey("create", entityType)
|
|
1664
|
+
);
|
|
1665
|
+
const mutate = useCallback(
|
|
1666
|
+
(entity, mutateOpts = {}) => createEntity2(
|
|
1667
|
+
entityType,
|
|
1668
|
+
entity,
|
|
1669
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1670
|
+
),
|
|
1671
|
+
[entityType, optsRef]
|
|
1672
|
+
);
|
|
1673
|
+
return __spreadValues({ mutate }, mutation);
|
|
1674
|
+
};
|
|
1675
|
+
const useUpsertEntity2 = (entityType, id, opts = {}) => {
|
|
1676
|
+
const optsRef = useLatestRef(opts);
|
|
1677
|
+
const mutation = useMutationState(
|
|
1678
|
+
getEntityRequestKey("upsert", entityType, id)
|
|
1679
|
+
);
|
|
1680
|
+
const mutate = useCallback(
|
|
1681
|
+
(entity, mutateOpts = {}) => upsertEntity2(
|
|
1682
|
+
entityType,
|
|
1683
|
+
id,
|
|
1684
|
+
entity,
|
|
1685
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1686
|
+
),
|
|
1687
|
+
[entityType, id, optsRef]
|
|
1688
|
+
);
|
|
1689
|
+
return __spreadValues({ mutate }, mutation);
|
|
1690
|
+
};
|
|
1691
|
+
const useEditEntity2 = (entityType, id, opts = {}) => {
|
|
1692
|
+
const optsRef = useLatestRef(opts);
|
|
1693
|
+
const mutation = useMutationState(
|
|
1694
|
+
getEntityRequestKey("edit", entityType, id)
|
|
1695
|
+
);
|
|
1696
|
+
const mutate = useCallback(
|
|
1697
|
+
(entity, mutateOpts = {}) => editEntity2(
|
|
1698
|
+
entityType,
|
|
1699
|
+
id,
|
|
1700
|
+
entity,
|
|
1701
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1702
|
+
),
|
|
1703
|
+
[entityType, id, optsRef]
|
|
1704
|
+
);
|
|
1705
|
+
return __spreadValues({ mutate }, mutation);
|
|
1706
|
+
};
|
|
1707
|
+
const useAdjustEntity2 = (entityType, id, opts = {}) => {
|
|
1708
|
+
const optsRef = useLatestRef(opts);
|
|
1709
|
+
const mutation = useMutationState(
|
|
1710
|
+
getEntityRequestKey("adjust", entityType, id)
|
|
1711
|
+
);
|
|
1712
|
+
const mutate = useCallback(
|
|
1713
|
+
(adjustments, mutateOpts = {}) => adjustEntity2(
|
|
1714
|
+
entityType,
|
|
1715
|
+
id,
|
|
1716
|
+
adjustments,
|
|
1717
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1718
|
+
),
|
|
1719
|
+
[entityType, id, optsRef]
|
|
1720
|
+
);
|
|
1721
|
+
return __spreadValues({ mutate }, mutation);
|
|
1722
|
+
};
|
|
1723
|
+
const useDeleteEntity2 = (entityType, id, opts = {}) => {
|
|
1724
|
+
const optsRef = useLatestRef(opts);
|
|
1725
|
+
const mutation = useMutationState(
|
|
1726
|
+
getEntityRequestKey("delete", entityType, id)
|
|
1727
|
+
);
|
|
1728
|
+
const mutate = useCallback(
|
|
1729
|
+
(mutateOpts = {}) => deleteEntity2(
|
|
1730
|
+
entityType,
|
|
1731
|
+
id,
|
|
1732
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1733
|
+
),
|
|
1734
|
+
[entityType, id, optsRef]
|
|
1735
|
+
);
|
|
1736
|
+
return __spreadValues({ mutate }, mutation);
|
|
1737
|
+
};
|
|
1738
|
+
const useCreateMutual2 = (byEntityType, entityType, byEntityId2, entityId, opts = {}) => {
|
|
1739
|
+
const optsRef = useLatestRef(opts);
|
|
1740
|
+
const mutation = useMutationState(
|
|
1741
|
+
getMutualRequestKey(
|
|
1742
|
+
"create",
|
|
1743
|
+
byEntityType,
|
|
1744
|
+
entityType,
|
|
1745
|
+
byEntityId2,
|
|
1746
|
+
entityId
|
|
1747
|
+
)
|
|
1748
|
+
);
|
|
1749
|
+
const mutate = useCallback(
|
|
1750
|
+
(payload = {}, mutateOpts = {}) => createMutual2(
|
|
1751
|
+
byEntityType,
|
|
1752
|
+
entityType,
|
|
1753
|
+
byEntityId2,
|
|
1754
|
+
entityId,
|
|
1755
|
+
payload,
|
|
1756
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1757
|
+
),
|
|
1758
|
+
[byEntityType, entityType, byEntityId2, entityId, optsRef]
|
|
1759
|
+
);
|
|
1760
|
+
return __spreadValues({ mutate }, mutation);
|
|
1761
|
+
};
|
|
1762
|
+
const useEditMutual2 = (byEntityType, entityType, byEntityId2, entityId, opts = {}) => {
|
|
1763
|
+
const optsRef = useLatestRef(opts);
|
|
1764
|
+
const mutation = useMutationState(
|
|
1765
|
+
getMutualRequestKey(
|
|
1766
|
+
"update",
|
|
1767
|
+
byEntityType,
|
|
1768
|
+
entityType,
|
|
1769
|
+
byEntityId2,
|
|
1770
|
+
entityId
|
|
1771
|
+
)
|
|
1772
|
+
);
|
|
1773
|
+
const mutate = useCallback(
|
|
1774
|
+
(payload = {}, mutateOpts = {}) => editMutual2(
|
|
1775
|
+
byEntityType,
|
|
1776
|
+
entityType,
|
|
1777
|
+
byEntityId2,
|
|
1778
|
+
entityId,
|
|
1779
|
+
payload,
|
|
1780
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1781
|
+
),
|
|
1782
|
+
[byEntityType, entityType, byEntityId2, entityId, optsRef]
|
|
1783
|
+
);
|
|
1784
|
+
return __spreadValues({ mutate }, mutation);
|
|
1785
|
+
};
|
|
1786
|
+
const useDeleteMutual2 = (byEntityType, entityType, byEntityId2, entityId, opts = {}) => {
|
|
1787
|
+
const optsRef = useLatestRef(opts);
|
|
1788
|
+
const mutation = useMutationState(
|
|
1789
|
+
getMutualRequestKey(
|
|
1790
|
+
"delete",
|
|
1791
|
+
byEntityType,
|
|
1792
|
+
entityType,
|
|
1793
|
+
byEntityId2,
|
|
1794
|
+
entityId
|
|
1795
|
+
)
|
|
1796
|
+
);
|
|
1797
|
+
const mutate = useCallback(
|
|
1798
|
+
(mutateOpts = {}) => deleteMutual2(
|
|
1799
|
+
byEntityType,
|
|
1800
|
+
entityType,
|
|
1801
|
+
byEntityId2,
|
|
1802
|
+
entityId,
|
|
1803
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1804
|
+
),
|
|
1805
|
+
[byEntityType, entityType, byEntityId2, entityId, optsRef]
|
|
1806
|
+
);
|
|
1807
|
+
return __spreadValues({ mutate }, mutation);
|
|
1808
|
+
};
|
|
1809
|
+
const useExecuteTransaction2 = (operations, opts = {}) => {
|
|
1810
|
+
const operationsRef = useLatestRef(operations);
|
|
1811
|
+
const optsRef = useLatestRef(opts);
|
|
1812
|
+
const mutation = useMutationState(getTransactionRequestKey(operations));
|
|
1813
|
+
const mutate = useCallback(
|
|
1814
|
+
(mutateOpts = {}) => executeTransaction2(
|
|
1815
|
+
operationsRef.current,
|
|
1816
|
+
mergeMutationOptions(optsRef.current, mutateOpts)
|
|
1817
|
+
),
|
|
1818
|
+
[operationsRef, optsRef]
|
|
1819
|
+
);
|
|
1820
|
+
return __spreadValues({ mutate }, mutation);
|
|
1821
|
+
};
|
|
1620
1822
|
const useEntity2 = (entityType, id, opts = {}) => {
|
|
1621
1823
|
const dataMap = monoriseStore(
|
|
1622
1824
|
(state) => {
|
|
@@ -2058,6 +2260,15 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2058
2260
|
editMutual: editMutual2,
|
|
2059
2261
|
deleteMutual: deleteMutual2,
|
|
2060
2262
|
deleteLocalMutual: deleteLocalMutual2,
|
|
2263
|
+
useCreateEntity: useCreateEntity2,
|
|
2264
|
+
useUpsertEntity: useUpsertEntity2,
|
|
2265
|
+
useEditEntity: useEditEntity2,
|
|
2266
|
+
useAdjustEntity: useAdjustEntity2,
|
|
2267
|
+
useDeleteEntity: useDeleteEntity2,
|
|
2268
|
+
useExecuteTransaction: useExecuteTransaction2,
|
|
2269
|
+
useCreateMutual: useCreateMutual2,
|
|
2270
|
+
useEditMutual: useEditMutual2,
|
|
2271
|
+
useDeleteMutual: useDeleteMutual2,
|
|
2061
2272
|
useEntity: useEntity2,
|
|
2062
2273
|
useEntityByUniqueField: useEntityByUniqueField2,
|
|
2063
2274
|
useEntities: useEntities2,
|
|
@@ -2071,7 +2282,7 @@ var initCoreActions = (monoriseStore, appActions, coreService2) => {
|
|
|
2071
2282
|
};
|
|
2072
2283
|
|
|
2073
2284
|
// actions/websocket.action.ts
|
|
2074
|
-
import { useCallback, useEffect as useEffect3, useRef, useState as useState3 } from "react";
|
|
2285
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
2075
2286
|
import { produce as produce5 } from "immer";
|
|
2076
2287
|
var globalWsManager = null;
|
|
2077
2288
|
var wsEndpoint;
|
|
@@ -2092,8 +2303,8 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2092
2303
|
const [isSubscribed, setIsSubscribed] = useState3(false);
|
|
2093
2304
|
const [error, setError2] = useState3(null);
|
|
2094
2305
|
const [hasMore, setHasMore] = useState3(true);
|
|
2095
|
-
const lastKeyRef =
|
|
2096
|
-
const isFirstFetchRef =
|
|
2306
|
+
const lastKeyRef = useRef2(void 0);
|
|
2307
|
+
const isFirstFetchRef = useRef2(true);
|
|
2097
2308
|
const entities = monoriseStore((state) => {
|
|
2098
2309
|
var _a;
|
|
2099
2310
|
const entityState = state.entity[entityType];
|
|
@@ -2222,8 +2433,8 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2222
2433
|
const [isSubscribed, setIsSubscribed] = useState3(false);
|
|
2223
2434
|
const [error, setError2] = useState3(null);
|
|
2224
2435
|
const [hasMore, setHasMore] = useState3(true);
|
|
2225
|
-
const lastKeyRef =
|
|
2226
|
-
const isFirstFetchRef =
|
|
2436
|
+
const lastKeyRef = useRef2(void 0);
|
|
2437
|
+
const isFirstFetchRef = useRef2(true);
|
|
2227
2438
|
const mutualKey = byEntityId2 ? `${byEntityType}/${byEntityId2}/${mutualEntityType}` : "";
|
|
2228
2439
|
const mutuals = monoriseStore((state) => {
|
|
2229
2440
|
var _a, _b;
|
|
@@ -2388,7 +2599,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2388
2599
|
setIsSubscribed(false);
|
|
2389
2600
|
};
|
|
2390
2601
|
}, [channel]);
|
|
2391
|
-
const send =
|
|
2602
|
+
const send = useCallback2(
|
|
2392
2603
|
(data) => {
|
|
2393
2604
|
if (!globalWsManager || !channel) return;
|
|
2394
2605
|
globalWsManager.sendEphemeral(channel, data);
|
|
@@ -2401,8 +2612,8 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2401
2612
|
const { entityType, entityId, ticketEndpoint } = opts;
|
|
2402
2613
|
const [isConnected, setIsConnected] = useState3(false);
|
|
2403
2614
|
const [error, setError2] = useState3(null);
|
|
2404
|
-
const refreshTimerRef =
|
|
2405
|
-
const hasConnectedOnceRef =
|
|
2615
|
+
const refreshTimerRef = useRef2(null);
|
|
2616
|
+
const hasConnectedOnceRef = useRef2(false);
|
|
2406
2617
|
const resyncFromHttp = async () => {
|
|
2407
2618
|
var _a, _b;
|
|
2408
2619
|
if (!httpActions) return;
|
|
@@ -2435,14 +2646,14 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2435
2646
|
}
|
|
2436
2647
|
}
|
|
2437
2648
|
};
|
|
2438
|
-
const wsManagerRef =
|
|
2439
|
-
const isMountedRef =
|
|
2440
|
-
const connectingRef =
|
|
2441
|
-
const reconnectCountRef =
|
|
2442
|
-
const connectRef =
|
|
2649
|
+
const wsManagerRef = useRef2(null);
|
|
2650
|
+
const isMountedRef = useRef2(true);
|
|
2651
|
+
const connectingRef = useRef2(false);
|
|
2652
|
+
const reconnectCountRef = useRef2(0);
|
|
2653
|
+
const connectRef = useRef2(() => {
|
|
2443
2654
|
});
|
|
2444
|
-
const lastConnectedAtRef =
|
|
2445
|
-
const fetchTicket =
|
|
2655
|
+
const lastConnectedAtRef = useRef2(0);
|
|
2656
|
+
const fetchTicket = useCallback2(async () => {
|
|
2446
2657
|
try {
|
|
2447
2658
|
const url = ticketEndpoint || `/api/core/ws/ticket/${entityType}/${entityId}`;
|
|
2448
2659
|
const fetchOpts = {
|
|
@@ -2465,7 +2676,7 @@ var initWebSocketActions = (monoriseStore, httpActions) => {
|
|
|
2465
2676
|
return { error: { code: "TICKET_FAILED", message: err.message } };
|
|
2466
2677
|
}
|
|
2467
2678
|
}, [entityType, entityId, ticketEndpoint]);
|
|
2468
|
-
const connectWithTicket =
|
|
2679
|
+
const connectWithTicket = useCallback2(async () => {
|
|
2469
2680
|
if (connectingRef.current) return;
|
|
2470
2681
|
connectingRef.current = true;
|
|
2471
2682
|
let result = null;
|
|
@@ -2645,7 +2856,12 @@ var initAxiosInterceptor = (store2, appActions) => {
|
|
|
2645
2856
|
const { startLoading: startLoading2 } = appActions;
|
|
2646
2857
|
const axiosInstance = request.create();
|
|
2647
2858
|
function makeRequest(url, config, data) {
|
|
2648
|
-
const {
|
|
2859
|
+
const {
|
|
2860
|
+
requestKey,
|
|
2861
|
+
stateKeys = [],
|
|
2862
|
+
isInterruptive = false,
|
|
2863
|
+
feedback
|
|
2864
|
+
} = config;
|
|
2649
2865
|
const { ongoingRequests } = store2.getState().app;
|
|
2650
2866
|
if (ongoingRequests.has(requestKey)) {
|
|
2651
2867
|
return ongoingRequests.get(requestKey);
|
|
@@ -2663,6 +2879,15 @@ var initAxiosInterceptor = (store2, appActions) => {
|
|
|
2663
2879
|
message: feedback == null ? void 0 : feedback.loading,
|
|
2664
2880
|
request: promise
|
|
2665
2881
|
});
|
|
2882
|
+
for (const stateKey of new Set(stateKeys)) {
|
|
2883
|
+
if (stateKey !== requestKey) {
|
|
2884
|
+
startLoading2({
|
|
2885
|
+
requestKey: stateKey,
|
|
2886
|
+
isInterruptive,
|
|
2887
|
+
message: feedback == null ? void 0 : feedback.loading
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2666
2891
|
return promise;
|
|
2667
2892
|
}
|
|
2668
2893
|
const axios2 = __spreadProps(__spreadValues({}, axiosInstance), {
|
|
@@ -2683,12 +2908,31 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2683
2908
|
code: "UNKNOWN_EXCEPTION",
|
|
2684
2909
|
message: "Ops, something doesn't seems right"
|
|
2685
2910
|
};
|
|
2911
|
+
const settleLoading = (config) => {
|
|
2912
|
+
const { requestKey, stateKeys = [], isInterruptive } = config;
|
|
2913
|
+
endLoading2({ requestKey, isInterruptive });
|
|
2914
|
+
for (const stateKey of new Set(stateKeys)) {
|
|
2915
|
+
if (stateKey !== requestKey) {
|
|
2916
|
+
endLoading2({
|
|
2917
|
+
requestKey: stateKey,
|
|
2918
|
+
isInterruptive,
|
|
2919
|
+
skipDedupe: true
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
const getErrorKeys = (config) => {
|
|
2925
|
+
const { requestKey, stateKeys = [] } = config;
|
|
2926
|
+
return stateKeys.length > 0 ? new Set(stateKeys) : /* @__PURE__ */ new Set([requestKey]);
|
|
2927
|
+
};
|
|
2686
2928
|
axios2.interceptors.response.use(
|
|
2687
2929
|
(response) => {
|
|
2688
2930
|
var _a;
|
|
2689
|
-
const {
|
|
2690
|
-
|
|
2691
|
-
|
|
2931
|
+
const { feedback } = response.config;
|
|
2932
|
+
settleLoading(response.config);
|
|
2933
|
+
for (const errorKey of getErrorKeys(response.config)) {
|
|
2934
|
+
clearError2(errorKey);
|
|
2935
|
+
}
|
|
2692
2936
|
if (feedback == null ? void 0 : feedback.success) {
|
|
2693
2937
|
(_a = options.onApiSuccess) == null ? void 0 : _a.call(options, response, feedback.success);
|
|
2694
2938
|
}
|
|
@@ -2696,14 +2940,16 @@ var injectAxiosInterceptor = (appActions, authActions, axios2, opts) => {
|
|
|
2696
2940
|
},
|
|
2697
2941
|
(error) => {
|
|
2698
2942
|
var _a, _b, _c, _d, _e;
|
|
2699
|
-
const
|
|
2700
|
-
|
|
2943
|
+
const config = error.config;
|
|
2944
|
+
settleLoading(config);
|
|
2701
2945
|
const appError = ((_a = error.response) == null ? void 0 : _a.data) ? {
|
|
2702
2946
|
code: (_b = error.response) == null ? void 0 : _b.statusText,
|
|
2703
2947
|
status: (_c = error.response) == null ? void 0 : _c.status,
|
|
2704
2948
|
message: (_d = error.response) == null ? void 0 : _d.data
|
|
2705
2949
|
} : unknownError;
|
|
2706
|
-
|
|
2950
|
+
for (const errorKey of getErrorKeys(config)) {
|
|
2951
|
+
setError2({ requestKey: errorKey, error: appError });
|
|
2952
|
+
}
|
|
2707
2953
|
if (((_e = error.response) == null ? void 0 : _e.status) === 401) {
|
|
2708
2954
|
setIsUnauthorized2(true);
|
|
2709
2955
|
}
|
|
@@ -2760,6 +3006,22 @@ var TAG_API_BASE_URL = "/api/core/tag";
|
|
|
2760
3006
|
var TRANSACTION_API_BASE_URL = "/api/core/transaction";
|
|
2761
3007
|
var initCoreService = (monoriseStore, axios2, opts) => {
|
|
2762
3008
|
let options = opts || {};
|
|
3009
|
+
const getMutationRequestConfig = (stateKey, opts2, compatibilityStateKeys = []) => {
|
|
3010
|
+
var _a;
|
|
3011
|
+
return {
|
|
3012
|
+
requestKey: (_a = opts2.requestKey) != null ? _a : createMutationCallRequestKey(stateKey),
|
|
3013
|
+
// Keep the stable mutation key reactive while requestKey remains unique
|
|
3014
|
+
// per write. An explicit key and any legacy observation keys remain
|
|
3015
|
+
// observable for backwards compatibility with useLoadStore/useErrorStore.
|
|
3016
|
+
stateKeys: Array.from(
|
|
3017
|
+
/* @__PURE__ */ new Set([
|
|
3018
|
+
stateKey,
|
|
3019
|
+
...compatibilityStateKeys,
|
|
3020
|
+
...opts2.requestKey ? [opts2.requestKey] : []
|
|
3021
|
+
])
|
|
3022
|
+
)
|
|
3023
|
+
};
|
|
3024
|
+
};
|
|
2763
3025
|
const listEntities = (entityType, payload, opts2 = {}) => {
|
|
2764
3026
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2765
3027
|
return axios2.get(opts2.customUrl || `${entityApiBaseUrl}/${entityType}`, {
|
|
@@ -2823,89 +3085,89 @@ var initCoreService = (monoriseStore, axios2, opts) => {
|
|
|
2823
3085
|
var _a;
|
|
2824
3086
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2825
3087
|
const entityConfig = monoriseStore.getState().config;
|
|
3088
|
+
const stateKey = getEntityRequestKey("create", entityType);
|
|
2826
3089
|
return axios2.post(
|
|
2827
3090
|
opts2.customUrl || `${entityApiBaseUrl}/${entityType}`,
|
|
2828
3091
|
__spreadValues(__spreadValues({}, values), opts2.entityId && { entityId: opts2.entityId }),
|
|
2829
|
-
{
|
|
2830
|
-
requestKey: opts2.requestKey || getEntityRequestKey("create", entityType),
|
|
3092
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
2831
3093
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2832
3094
|
feedback: __spreadValues({
|
|
2833
3095
|
loading: `Creating ${entityConfig[entityType].displayName}`,
|
|
2834
3096
|
success: `${entityConfig[entityType].displayName} created`
|
|
2835
3097
|
}, opts2.feedback || {})
|
|
2836
|
-
}
|
|
3098
|
+
})
|
|
2837
3099
|
);
|
|
2838
3100
|
};
|
|
2839
3101
|
const upsertEntity2 = (entityType, id, values, opts2 = {}) => {
|
|
2840
3102
|
var _a;
|
|
2841
3103
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2842
3104
|
const entityConfig = monoriseStore.getState().config;
|
|
3105
|
+
const stateKey = getEntityRequestKey("upsert", entityType, id);
|
|
2843
3106
|
return axios2.put(
|
|
2844
3107
|
opts2.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`,
|
|
2845
3108
|
values,
|
|
2846
|
-
{
|
|
2847
|
-
requestKey: getEntityRequestKey("upsert", entityType, id),
|
|
3109
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
2848
3110
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2849
3111
|
feedback: __spreadValues({
|
|
2850
3112
|
loading: `Updating ${entityConfig[entityType].displayName}`,
|
|
2851
3113
|
success: `${entityConfig[entityType].displayName} updated`
|
|
2852
3114
|
}, opts2.feedback || {})
|
|
2853
|
-
}
|
|
3115
|
+
})
|
|
2854
3116
|
);
|
|
2855
3117
|
};
|
|
2856
3118
|
const editEntity2 = (entityType, id, values, opts2 = {}) => {
|
|
2857
3119
|
var _a;
|
|
2858
3120
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2859
3121
|
const entityConfig = monoriseStore.getState().config;
|
|
3122
|
+
const stateKey = getEntityRequestKey("edit", entityType, id);
|
|
2860
3123
|
return axios2.patch(
|
|
2861
3124
|
opts2.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`,
|
|
2862
3125
|
values,
|
|
2863
|
-
{
|
|
2864
|
-
requestKey: getEntityRequestKey("edit", entityType, id),
|
|
3126
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
2865
3127
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2866
3128
|
feedback: __spreadValues({
|
|
2867
3129
|
loading: `Updating ${entityConfig[entityType].displayName}`,
|
|
2868
3130
|
success: `${entityConfig[entityType].displayName} updated`
|
|
2869
3131
|
}, opts2.feedback || {})
|
|
2870
|
-
}
|
|
3132
|
+
})
|
|
2871
3133
|
);
|
|
2872
3134
|
};
|
|
2873
3135
|
const adjustEntity2 = (entityType, id, adjustments, opts2 = {}) => {
|
|
2874
3136
|
var _a;
|
|
2875
3137
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2876
3138
|
const entityConfig = monoriseStore.getState().config;
|
|
3139
|
+
const stateKey = getEntityRequestKey("adjust", entityType, id);
|
|
2877
3140
|
const body = opts2.condition ? __spreadProps(__spreadValues({}, adjustments), { $condition: opts2.condition }) : adjustments;
|
|
2878
3141
|
return axios2.post(
|
|
2879
3142
|
opts2.customUrl || `${entityApiBaseUrl}/${entityType}/${id}/adjust`,
|
|
2880
3143
|
body,
|
|
2881
|
-
{
|
|
2882
|
-
requestKey: getEntityRequestKey("adjust", entityType, id),
|
|
3144
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
2883
3145
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2884
3146
|
feedback: __spreadValues({
|
|
2885
3147
|
loading: `Updating ${entityConfig[entityType].displayName}`,
|
|
2886
3148
|
success: `${entityConfig[entityType].displayName} updated`
|
|
2887
3149
|
}, opts2.feedback || {})
|
|
2888
|
-
}
|
|
3150
|
+
})
|
|
2889
3151
|
);
|
|
2890
3152
|
};
|
|
2891
3153
|
const deleteEntity2 = (entityType, id, opts2 = {}) => {
|
|
2892
3154
|
var _a;
|
|
2893
3155
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
2894
3156
|
const entityConfig = monoriseStore.getState().config;
|
|
3157
|
+
const stateKey = getEntityRequestKey("delete", entityType, id);
|
|
2895
3158
|
return axios2.delete(
|
|
2896
3159
|
opts2.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`,
|
|
2897
|
-
{
|
|
2898
|
-
requestKey: getEntityRequestKey("delete", entityType, id),
|
|
3160
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
2899
3161
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2900
3162
|
feedback: __spreadValues({
|
|
2901
3163
|
loading: `Deleting ${entityConfig[entityType].displayName}`,
|
|
2902
3164
|
success: `${entityConfig[entityType].displayName} deleted`
|
|
2903
3165
|
}, opts2.feedback || {})
|
|
2904
|
-
}
|
|
3166
|
+
})
|
|
2905
3167
|
);
|
|
2906
3168
|
};
|
|
2907
3169
|
const executeTransaction2 = (operations, opts2 = {}) => {
|
|
2908
|
-
var _a;
|
|
3170
|
+
var _a, _b;
|
|
2909
3171
|
const { transactionApiBaseUrl = TRANSACTION_API_BASE_URL } = options;
|
|
2910
3172
|
return axios2.post(
|
|
2911
3173
|
opts2.customUrl || transactionApiBaseUrl,
|
|
@@ -2920,8 +3182,8 @@ var initCoreService = (monoriseStore, axios2, opts) => {
|
|
|
2920
3182
|
// namespaced so it can never match a single-entity key and unique per
|
|
2921
3183
|
// call so non-idempotent transaction writes cannot be silently
|
|
2922
3184
|
// deduplicated. Callers can pass opts.requestKey to opt into dedupe.
|
|
2923
|
-
requestKey: opts2.requestKey
|
|
2924
|
-
isInterruptive: (
|
|
3185
|
+
requestKey: (_a = opts2.requestKey) != null ? _a : createTransactionCallRequestKey(operations),
|
|
3186
|
+
isInterruptive: (_b = opts2.isInterruptive) != null ? _b : true,
|
|
2925
3187
|
feedback: __spreadValues({
|
|
2926
3188
|
loading: "Processing transaction",
|
|
2927
3189
|
success: "Transaction completed"
|
|
@@ -2972,65 +3234,72 @@ var initCoreService = (monoriseStore, axios2, opts) => {
|
|
|
2972
3234
|
const createMutual2 = (byEntityType, entityType, byEntityId2, entityId, payload, opts2 = {}) => {
|
|
2973
3235
|
var _a;
|
|
2974
3236
|
const { mutualApiBaseUrl = MUTUAL_API_BASE_URL } = options;
|
|
3237
|
+
const stateKey = getMutualRequestKey(
|
|
3238
|
+
"create",
|
|
3239
|
+
byEntityType,
|
|
3240
|
+
entityType,
|
|
3241
|
+
byEntityId2,
|
|
3242
|
+
entityId
|
|
3243
|
+
);
|
|
3244
|
+
const legacyStateKey = getMutualRequestKey(
|
|
3245
|
+
"create",
|
|
3246
|
+
byEntityType,
|
|
3247
|
+
entityType,
|
|
3248
|
+
byEntityId2
|
|
3249
|
+
);
|
|
2975
3250
|
return axios2.post(
|
|
2976
3251
|
opts2.customUrl || `${mutualApiBaseUrl}/${getMutualStateKey(byEntityType, byEntityId2, entityType, entityId)}`,
|
|
2977
3252
|
payload,
|
|
2978
|
-
{
|
|
2979
|
-
requestKey: getMutualRequestKey(
|
|
2980
|
-
"create",
|
|
2981
|
-
byEntityType,
|
|
2982
|
-
entityType,
|
|
2983
|
-
byEntityId2
|
|
2984
|
-
),
|
|
3253
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2, [legacyStateKey])), {
|
|
2985
3254
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
2986
3255
|
feedback: __spreadValues({
|
|
2987
3256
|
loading: "Creating linkage",
|
|
2988
3257
|
success: "Linkage created"
|
|
2989
3258
|
}, opts2.feedback || {})
|
|
2990
|
-
}
|
|
3259
|
+
})
|
|
2991
3260
|
);
|
|
2992
3261
|
};
|
|
2993
3262
|
const editMutual2 = (byEntityType, entityType, byEntityId2, entityId, payload, opts2 = {}) => {
|
|
2994
3263
|
var _a;
|
|
2995
3264
|
const { mutualApiBaseUrl = MUTUAL_API_BASE_URL } = options;
|
|
3265
|
+
const stateKey = getMutualRequestKey(
|
|
3266
|
+
"update",
|
|
3267
|
+
byEntityType,
|
|
3268
|
+
entityType,
|
|
3269
|
+
byEntityId2,
|
|
3270
|
+
entityId
|
|
3271
|
+
);
|
|
2996
3272
|
return axios2.patch(
|
|
2997
3273
|
opts2.customUrl || `${mutualApiBaseUrl}/${getMutualStateKey(byEntityType, byEntityId2, entityType, entityId)}`,
|
|
2998
3274
|
payload,
|
|
2999
|
-
{
|
|
3000
|
-
requestKey: getMutualRequestKey(
|
|
3001
|
-
"update",
|
|
3002
|
-
byEntityType,
|
|
3003
|
-
entityType,
|
|
3004
|
-
byEntityId2,
|
|
3005
|
-
entityId
|
|
3006
|
-
),
|
|
3275
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
3007
3276
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
3008
3277
|
feedback: __spreadValues({
|
|
3009
3278
|
loading: "Updating linkage",
|
|
3010
3279
|
success: "Linkage updated"
|
|
3011
3280
|
}, opts2.feedback || {})
|
|
3012
|
-
}
|
|
3281
|
+
})
|
|
3013
3282
|
);
|
|
3014
3283
|
};
|
|
3015
3284
|
const deleteMutual2 = (byEntityType, entityType, byEntityId2, entityId, opts2 = {}) => {
|
|
3016
3285
|
var _a;
|
|
3017
3286
|
const { mutualApiBaseUrl = MUTUAL_API_BASE_URL } = options;
|
|
3287
|
+
const stateKey = getMutualRequestKey(
|
|
3288
|
+
"delete",
|
|
3289
|
+
byEntityType,
|
|
3290
|
+
entityType,
|
|
3291
|
+
byEntityId2,
|
|
3292
|
+
entityId
|
|
3293
|
+
);
|
|
3018
3294
|
return axios2.delete(
|
|
3019
3295
|
opts2.customUrl || `${mutualApiBaseUrl}/${getMutualStateKey(byEntityType, byEntityId2, entityType, entityId)}`,
|
|
3020
|
-
{
|
|
3021
|
-
requestKey: getMutualRequestKey(
|
|
3022
|
-
"delete",
|
|
3023
|
-
byEntityType,
|
|
3024
|
-
entityType,
|
|
3025
|
-
byEntityId2,
|
|
3026
|
-
entityId
|
|
3027
|
-
),
|
|
3296
|
+
__spreadProps(__spreadValues({}, getMutationRequestConfig(stateKey, opts2)), {
|
|
3028
3297
|
isInterruptive: (_a = opts2.isInterruptive) != null ? _a : true,
|
|
3029
3298
|
feedback: __spreadValues({
|
|
3030
3299
|
loading: "Removing linkage",
|
|
3031
3300
|
success: "Linkage removed"
|
|
3032
3301
|
}, opts2.feedback || {})
|
|
3033
|
-
}
|
|
3302
|
+
})
|
|
3034
3303
|
);
|
|
3035
3304
|
};
|
|
3036
3305
|
const makeEntityService = (entityType) => ({
|
|
@@ -3404,6 +3673,15 @@ var {
|
|
|
3404
3673
|
editMutual,
|
|
3405
3674
|
deleteMutual,
|
|
3406
3675
|
deleteLocalMutual,
|
|
3676
|
+
useCreateEntity,
|
|
3677
|
+
useUpsertEntity,
|
|
3678
|
+
useEditEntity,
|
|
3679
|
+
useAdjustEntity,
|
|
3680
|
+
useDeleteEntity,
|
|
3681
|
+
useExecuteTransaction,
|
|
3682
|
+
useCreateMutual,
|
|
3683
|
+
useEditMutual,
|
|
3684
|
+
useDeleteMutual,
|
|
3407
3685
|
useEntity,
|
|
3408
3686
|
useEntityByUniqueField,
|
|
3409
3687
|
useEntities,
|
|
@@ -3466,7 +3744,14 @@ export {
|
|
|
3466
3744
|
updateLocalTaggedEntity,
|
|
3467
3745
|
upsertEntity,
|
|
3468
3746
|
upsertLocalMutual,
|
|
3747
|
+
useAdjustEntity,
|
|
3469
3748
|
useConfig,
|
|
3749
|
+
useCreateEntity,
|
|
3750
|
+
useCreateMutual,
|
|
3751
|
+
useDeleteEntity,
|
|
3752
|
+
useDeleteMutual,
|
|
3753
|
+
useEditEntity,
|
|
3754
|
+
useEditMutual,
|
|
3470
3755
|
useEntities,
|
|
3471
3756
|
useEntity,
|
|
3472
3757
|
useEntityByUniqueField,
|
|
@@ -3475,6 +3760,7 @@ export {
|
|
|
3475
3760
|
useEntityState,
|
|
3476
3761
|
useEphemeralSocket,
|
|
3477
3762
|
useErrorStore,
|
|
3763
|
+
useExecuteTransaction,
|
|
3478
3764
|
useInterruptiveLoadStore,
|
|
3479
3765
|
useIsUnauthorized,
|
|
3480
3766
|
useLoadStore,
|
|
@@ -3483,6 +3769,7 @@ export {
|
|
|
3483
3769
|
useMutualSocket,
|
|
3484
3770
|
useMutuals,
|
|
3485
3771
|
useProfile,
|
|
3486
|
-
useTaggedEntities
|
|
3772
|
+
useTaggedEntities,
|
|
3773
|
+
useUpsertEntity
|
|
3487
3774
|
};
|
|
3488
3775
|
//# sourceMappingURL=index.js.map
|