nolo-cli 0.107.0-alpha.4 → 0.107.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/README.md +1 -1
- package/{_executeModel-UDCSOTD2.js → _executeModel-C4EH5TZG.js} +77 -69
- package/action-GVA5ARSJ.js +20 -0
- package/{addContentAction-MB2HHMDZ.js → addContentAction-M2WOWZCL.js} +13 -12
- package/{addDialogAgentAction-MCEABSBA.js → addDialogAgentAction-QMAQ5Z6N.js} +19 -20
- package/{agentDeleteCommand-OWYHN6D6.js → agentDeleteCommand-D3RICSHX.js} +118 -43
- package/{agentEmailCommands-AU5I4M4W.js → agentEmailCommands-YC2A4USQ.js} +99 -89
- package/agentListCommands-UDJELMYP.js +741 -0
- package/{agentMachineCommands-YMNME2L6.js → agentMachineCommands-XH4IBGTO.js} +48 -44
- package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-CMVTBY5X.js} +97 -2
- package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
- package/agentRecordCommands-3EOC2QMN.js +138 -0
- package/agentRunCommand-BTHYOVVS.js +167 -0
- package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
- package/{agentRuntimeLocal-KCMC2TBD.js → agentRuntimeLocal-N4YGKL7M.js} +44 -40
- package/{agentSlice-R7PR6KYM.js → agentSlice-NIN4T6CF.js} +15 -14
- package/{appDeleteCommands-JEPA3EWE.js → appDeleteCommands-7DAF33AM.js} +46 -42
- package/{appDeployCommands-UTB76XFM.js → appDeployCommands-ZPZSMFGZ.js} +46 -42
- package/{appDeployStatusCommands-LGHF2SBD.js → appDeployStatusCommands-FWBDSSS5.js} +46 -42
- package/{appGetCommands-PX2BFHOB.js → appGetCommands-SZZOHGEP.js} +46 -42
- package/{appListCommands-BSMPTWKC.js → appListCommands-FPMUBDPM.js} +46 -42
- package/{authCommand-YW42YZA4.js → authCommand-VL3G26NQ.js} +119 -25
- package/{authCommands-RGOGCPP6.js → authCommands-5RTUDYZW.js} +7 -5
- package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-ZK4K67Y5.js} +11 -9
- package/{chromeCommands-FZYAU75D.js → chromeCommands-AU5ZJXBG.js} +289 -37
- package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-ZYTCMNHG.js} +156 -22
- package/{chunk-JDPFV2JV.js → chunk-2NNRWRM5.js} +20 -11
- package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
- package/{chunk-HVURBGF3.js → chunk-2U3NHADM.js} +6 -6
- package/{chunk-UVA7OYO3.js → chunk-2ZHBFX5R.js} +29 -9
- package/{chunk-QTGQ2LTL.js → chunk-3DQY5IFB.js} +6 -10
- package/chunk-4LCOCOR5.js +50 -0
- package/{chunk-JPGCXHNM.js → chunk-4LKMZ3RR.js} +1 -1
- package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
- package/{chunk-6D6VBVEW.js → chunk-4W24JM32.js} +80 -14
- package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
- package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
- package/chunk-5MMAK75Q.js +15 -0
- package/{chunk-7S4YWN7P.js → chunk-5UUIGN6I.js} +4 -4
- package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
- package/{chunk-IBOOZVVD.js → chunk-6IJDSYUA.js} +849 -279
- package/{chunk-4MK3I7Y4.js → chunk-6MAW4XOF.js} +5 -5
- package/chunk-76HO2DP6.js +15 -0
- package/chunk-7AY2H3GA.js +13692 -0
- package/{chunk-4CR5I7BD.js → chunk-7HYOPBUW.js} +47 -67
- package/{chunk-VLTIYV3X.js → chunk-7I25CBT5.js} +34 -8
- package/chunk-AGIM7IMJ.js +147 -0
- package/{chunk-5UTFL4QJ.js → chunk-AOTBKDRK.js} +7 -0
- package/{chunk-6OZ36FXI.js → chunk-BIPGGSJS.js} +22 -4
- package/{chunk-EYAQT56M.js → chunk-BNQMNUKZ.js} +9 -6
- package/{chunk-62CATUYY.js → chunk-CBUMFIFE.js} +834 -962
- package/{chunk-OIVSQH2O.js → chunk-CDEEFJXN.js} +308 -11
- package/chunk-CHOZJMJS.js +78 -0
- package/{chunk-ETI2NYVF.js → chunk-CIP3AAMT.js} +4 -4
- package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
- package/{chunk-IBOZNTG2.js → chunk-DGEUP3DK.js} +23 -28
- package/{chunk-Q554LLSI.js → chunk-DMXLXZKL.js} +1 -1
- package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
- package/{chunk-HKNXJGEC.js → chunk-ECFHBYUW.js} +85 -50
- package/{chunk-ACTMNVHM.js → chunk-EHSYSKXV.js} +1 -1
- package/{chunk-WV42OMV7.js → chunk-ELUDRSRD.js} +8 -8
- package/{chunk-ABQYVJBJ.js → chunk-EV235ILT.js} +5 -5
- package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
- package/{chunk-BFDFRLLQ.js → chunk-EZ4VZHAG.js} +5 -5
- package/{chunk-GO3Z72MT.js → chunk-FHLMQIU7.js} +65 -95
- package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
- package/{chunk-SH43IESU.js → chunk-GGC55Q32.js} +199 -29
- package/chunk-GMZLP5DV.js +82 -0
- package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
- package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
- package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
- package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
- package/{chunk-BNGW5ASC.js → chunk-I2RGRVQ7.js} +22 -2
- package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
- package/{chunk-QDSINZM3.js → chunk-IXH3HKY2.js} +1 -22
- package/{chunk-GQBOR3G6.js → chunk-JBKHQOYK.js} +8 -4
- package/{chunk-XD2MJFUG.js → chunk-JEFXP73H.js} +1 -1
- package/{chunk-PBA4UJBK.js → chunk-JIXGJTBU.js} +4 -4
- package/{chunk-AEOE4Z6Q.js → chunk-K6L5PNXK.js} +39 -15
- package/{chunk-Z77CRGTW.js → chunk-KA5O5KQL.js} +1 -1
- package/{chunk-GPCZ7UXG.js → chunk-KD6D6BLA.js} +1 -1
- package/{chunk-UZGQNTVW.js → chunk-KHKTDMYG.js} +8 -6
- package/{chunk-MRIHM22T.js → chunk-LBFL6RZG.js} +58 -9
- package/{chunk-C3M4465B.js → chunk-LKIVH2I2.js} +403 -658
- package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
- package/{chunk-DHDMC6FO.js → chunk-LUBFABMJ.js} +15 -14
- package/{chunk-NA35QHCF.js → chunk-LVBFKW65.js} +1 -1
- package/chunk-LWLNLZC5.js +265 -0
- package/{chunk-EEGDMATE.js → chunk-M3NMHYRB.js} +86 -81
- package/chunk-N4NGJDT6.js +929 -0
- package/{chunk-GL3EHUR4.js → chunk-N7NLLRQQ.js} +68 -46
- package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
- package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
- package/chunk-NWENLDMM.js +42 -0
- package/chunk-O7SVKKLY.js +875 -0
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-6Z7MY3V7.js → chunk-OEJLGVBL.js} +5 -5
- package/{chunk-VMFTFOWF.js → chunk-OKGVNZTL.js} +35 -8
- package/{chunk-GEPUP7OO.js → chunk-OR2UWD6X.js} +3 -3
- package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
- package/{chunk-J4MOO56S.js → chunk-PNXHPLRU.js} +10 -2
- package/{chunk-3BMYXEUW.js → chunk-R5AJODNI.js} +1 -1
- package/{chunk-P5EVSOPA.js → chunk-R6EBQEQE.js} +22 -29
- package/{chunk-NOF3HDSN.js → chunk-RLSF5CSE.js} +11 -9
- package/chunk-RQ6CTX2E.js +164 -0
- package/{chunk-3UZPUAES.js → chunk-RSB4PWX4.js} +1 -1
- package/{chunk-KQ4ONNQD.js → chunk-RXA3HAVW.js} +190 -8
- package/{chunk-IIVGDG4I.js → chunk-SJKULPGX.js} +13 -7
- package/chunk-SQHMSDDU.js +8004 -0
- package/{chunk-Q67DOFOO.js → chunk-SZC4REES.js} +212 -105
- package/{chunk-JRQFUXY7.js → chunk-TBAXFWOS.js} +99 -22
- package/{chunk-PQFHGD77.js → chunk-TBM2RS3U.js} +161 -14
- package/{chunk-XT35TTFG.js → chunk-TCYU7L6V.js} +18 -20
- package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
- package/chunk-TY3TIUJK.js +89 -0
- package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
- package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
- package/chunk-UM7TA3K4.js +1008 -0
- package/{chunk-6YTOJY35.js → chunk-VBG7GWWR.js} +253 -8
- package/chunk-VIWDGTDA.js +8 -0
- package/chunk-VJVNU77E.js +83 -0
- package/{chunk-W7HLWAQ7.js → chunk-VPLUU4IX.js} +118 -90
- package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
- package/chunk-VZLO4XJD.js +17 -0
- package/{chunk-AHAHBQMU.js → chunk-WDLSZMTA.js} +2 -2
- package/{chunk-53HEEOTT.js → chunk-WF5X57VW.js} +83 -16
- package/{chunk-VRTTFDBM.js → chunk-WPHY3VPF.js} +35 -22
- package/{chunk-ASIFZ2WY.js → chunk-YKZLFY5J.js} +66 -54
- package/chunk-YV25TM3R.js +780 -0
- package/{chunk-MS7TSPZR.js → chunk-YXKNBVYW.js} +19 -17
- package/chunk-ZRAU6T47.js +56 -0
- package/commandRegistry-UU6IOTHI.js +833 -0
- package/{contentThunks-IV2T3EJC.js → contentThunks-ARD56LKI.js} +39 -36
- package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-JCOIEYY4.js → createAgentAutomationAction-HWJLU6DD.js} +40 -37
- package/createDialogAction-CHYA6PZE.js +70 -0
- package/{createPageAction-D2VOOLP3.js → createPageAction-TSCYNFX7.js} +47 -43
- package/{chunk-FG3HKPQP.js → cursorProvider-YGGNMVWX.js} +2751 -10185
- package/{dbSlice-A6C6H32X.js → dbSlice-TG4MZ5EB.js} +12 -11
- package/{deleteFile-YG6QMJLU.js → deleteFile-KESP65GC.js} +7 -6
- package/{dialogCommands-H7FPUYUQ.js → dialogCommands-IJYQAQMB.js} +49 -46
- package/{dialogSlice-6JZOOTDS.js → dialogSlice-H476I77R.js} +57 -37
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-WRG2JLGM.js → docCreateCommands-AZSK4NAG.js} +48 -44
- package/{docDeleteCommands-SHWJIBJS.js → docDeleteCommands-DDJMSMFZ.js} +49 -45
- package/{docReadCommands-WJN3WT6O.js → docReadCommands-5F5Q6EBZ.js} +47 -43
- package/{docStore-HUPQ2FSS.js → docStore-HW2RDZDM.js} +17 -13
- package/{docUpdateCommands-IE32IL6O.js → docUpdateCommands-XPNPVZOC.js} +48 -44
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-3PXAHKCR.js} +5 -5
- package/{getPricing-LUSEABA6.js → getPricing-DOBBZLOK.js} +4 -4
- package/{handleSendMessageAction-DFPMQ7YM.js → handleSendMessageAction-IOXE7ILC.js} +109 -42
- package/index.js +87 -884
- package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
- package/{localDialogRead-BTFJ4V2I.js → localDialogRead-UYCKO7YZ.js} +2 -2
- package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
- package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
- package/{machineCommands-M2T2I5NF.js → machineCommands-Q7TDGM6P.js} +96 -86
- package/machineWsRunDispatch-T5VFOQ3R.js +154 -0
- package/{memberThunks-P2ECUJ56.js → memberThunks-5S5D3N4U.js} +20 -18
- package/{models-T3SG6MJ5.js → models-PQU25T6Q.js} +2 -2
- package/oauthTokenStore-ITEB663N.js +23 -0
- package/package.json +1 -1
- package/processSpawn-SOAV3FEV.js +11 -0
- package/profileConfig-ZGOFORWV.js +43 -0
- package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-HAQWVAQX.js} +7 -7
- package/{providerRegistry-757OWH3O.js → providerRegistry-5FGWB3X5.js} +11 -7
- package/{read-COE3ZYR6.js → read-LSYFLSIM.js} +8 -7
- package/{readDocTool-5USN4A6V.js → readDocTool-XWRXV3DR.js} +5 -3
- package/{readlineWorkspace-XQRDGWRZ.js → readlineWorkspace-25U6P3DG.js} +2595 -2031
- package/{removeDialogAgentAction-J6X5QMTA.js → removeDialogAgentAction-4TEFC3VL.js} +22 -26
- package/{runAgentClientLoop-5ZA62FBA.js → runAgentClientLoop-CZOYWHDN.js} +78 -71
- package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
- package/runtimeModeArgs-2Y7BALTO.js +31 -0
- package/{setDialogExtraReferencesAction-WX5VTY6O.js → setDialogExtraReferencesAction-LSEN44OY.js} +16 -14
- package/{setPrimaryDialogAgentAction-FN22THHT.js → setPrimaryDialogAgentAction-SR366X5A.js} +23 -27
- package/{chunk-GP5LKBUZ.js → settingThunks-CTVPPGIN.js} +226 -940
- package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
- package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
- package/{spaceCommands-5GLCWZPO.js → spaceCommands-3UK63WPE.js} +51 -47
- package/{streamAgentChatTurn-6UZJMYRB.js → streamAgentChatTurn-LV6ZWUD4.js} +214 -114
- package/{switchDialogAgentAction-LVTEV3FR.js → switchDialogAgentAction-M6NAFOOU.js} +19 -20
- package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
- package/{toolApiClient-QVJ6HDNN.js → toolApiClient-AD7CXTA4.js} +4 -3
- package/tools-UJOV6CQZ.js +117 -0
- package/{tuiSummaryLlmCaller-OHHFTHMG.js → tuiSummaryLlmCaller-DEH7ZEM6.js} +25 -23
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-QTKNIURB.js → updateDialogTitleAction-JYXKIBNJ.js} +84 -45
- package/action-P4TNFGAD.js +0 -31
- package/agentListCommands-B2V4YAC4.js +0 -410
- package/agentRecordCommands-G4KK4R7H.js +0 -128
- package/agentRunCommand-UTZJA23G.js +0 -156
- package/browser-image-compression-MFDTD7K6.js +0 -1763
- package/chatQueueReduxAdapter-2P6NFX64.js +0 -186
- package/chunk-CQ3WA2NE.js +0 -299
- package/chunk-M76ECQRD.js +0 -13658
- package/chunk-MEYIRKDN.js +0 -8967
- package/chunk-PUOC4YRO.js +0 -394
- package/chunk-Q5FJJ6XI.js +0 -103
- package/chunk-S7Z2HMCN.js +0 -25
- package/chunk-T75QD6AB.js +0 -20923
- package/chunk-Y5GCAMGP.js +0 -9
- package/chunk-YPREESF4.js +0 -225
- package/createDialogAction-NGG7YVNU.js +0 -65
- package/machineWsRunDispatch-ISBKOOD7.js +0 -144
- package/settingSlice-P4ZW7K5X.js +0 -204
- package/syncMapping-N6RGXGBW.js +0 -437
- package/tools-KMGFWO43.js +0 -110
- package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
- package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getAllServers,
|
|
3
|
-
getIsDesktopApp,
|
|
4
2
|
isAbortError
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HIM3FCLF.js";
|
|
6
4
|
import {
|
|
7
|
-
selectIdentityToken
|
|
8
|
-
selectIdentityUser,
|
|
9
|
-
selectIdentityUserId
|
|
5
|
+
selectIdentityToken
|
|
10
6
|
} from "./chunk-SEJ5OS6F.js";
|
|
11
7
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-KUG52IAP.js";
|
|
14
|
-
import {
|
|
15
|
-
asTrimmedString
|
|
16
|
-
} from "./chunk-3EUW3WEO.js";
|
|
17
|
-
import {
|
|
18
|
-
asOptionalPositiveFiniteNumber
|
|
19
|
-
} from "./chunk-U6VC4MU4.js";
|
|
20
|
-
import {
|
|
21
|
-
API_ENDPOINTS,
|
|
22
|
-
SERVERS,
|
|
23
|
-
normalizeKnownServerOrigin
|
|
8
|
+
API_ENDPOINTS
|
|
24
9
|
} from "./chunk-LCBAMY2M.js";
|
|
25
|
-
import {
|
|
26
|
-
isLocalServerUrl
|
|
27
|
-
} from "./chunk-4SN6J65J.js";
|
|
28
|
-
import {
|
|
29
|
-
normalizeServerOrigin
|
|
30
|
-
} from "./chunk-CF7PE763.js";
|
|
31
|
-
import {
|
|
32
|
-
asOptionalTrimmedString
|
|
33
|
-
} from "./chunk-G3SUCT4W.js";
|
|
34
10
|
|
|
35
11
|
// node_modules/reselect/dist/reselect.mjs
|
|
36
12
|
var CACHE_SIZE_CHECK_THRESHOLD = 1e3;
|
|
@@ -941,7 +917,7 @@ var objectTraps = {
|
|
|
941
917
|
const currentState = current2?.[DRAFT_STATE];
|
|
942
918
|
if (currentState && currentState.base_ === value) {
|
|
943
919
|
state.copy_[prop] = value;
|
|
944
|
-
state.assigned_.
|
|
920
|
+
state.assigned_.delete(prop);
|
|
945
921
|
return true;
|
|
946
922
|
}
|
|
947
923
|
if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
|
|
@@ -1268,9 +1244,7 @@ var createDraftSafeSelectorCreator = (...args) => {
|
|
|
1268
1244
|
const wrappedSelector = (value, ...rest) => selector(isDraft(value) ? current(value) : value, ...rest);
|
|
1269
1245
|
Object.assign(wrappedSelector, selector);
|
|
1270
1246
|
return wrappedSelector;
|
|
1271
|
-
}, {
|
|
1272
|
-
withTypes: () => createDraftSafeSelector2
|
|
1273
|
-
});
|
|
1247
|
+
}, { withTypes: () => createDraftSafeSelector2 });
|
|
1274
1248
|
return createDraftSafeSelector2;
|
|
1275
1249
|
};
|
|
1276
1250
|
var createDraftSafeSelector = /* @__PURE__ */ createDraftSafeSelectorCreator(weakMapMemoize);
|
|
@@ -1279,11 +1253,7 @@ var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOO
|
|
|
1279
1253
|
if (typeof arguments[0] === "object") return compose;
|
|
1280
1254
|
return compose.apply(null, arguments);
|
|
1281
1255
|
};
|
|
1282
|
-
|
|
1283
|
-
return function(noop3) {
|
|
1284
|
-
return noop3;
|
|
1285
|
-
};
|
|
1286
|
-
};
|
|
1256
|
+
typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
1287
1257
|
var hasMatchFunction = (v) => {
|
|
1288
1258
|
return v && typeof v.match === "function";
|
|
1289
1259
|
};
|
|
@@ -1291,18 +1261,12 @@ function createAction(type, prepareAction) {
|
|
|
1291
1261
|
function actionCreator(...args) {
|
|
1292
1262
|
if (prepareAction) {
|
|
1293
1263
|
let prepared = prepareAction(...args);
|
|
1294
|
-
if (!prepared)
|
|
1295
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
|
|
1296
|
-
}
|
|
1264
|
+
if (!prepared) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : "prepareAction did not return an object");
|
|
1297
1265
|
return {
|
|
1298
1266
|
type,
|
|
1299
1267
|
payload: prepared.payload,
|
|
1300
|
-
..."meta" in prepared && {
|
|
1301
|
-
|
|
1302
|
-
},
|
|
1303
|
-
..."error" in prepared && {
|
|
1304
|
-
error: prepared.error
|
|
1305
|
-
}
|
|
1268
|
+
..."meta" in prepared && { meta: prepared.meta },
|
|
1269
|
+
..."error" in prepared && { error: prepared.error }
|
|
1306
1270
|
};
|
|
1307
1271
|
}
|
|
1308
1272
|
return {
|
|
@@ -1319,7 +1283,12 @@ function isFSA(action) {
|
|
|
1319
1283
|
return isAction(action) && Object.keys(action).every(isValidKey);
|
|
1320
1284
|
}
|
|
1321
1285
|
function isValidKey(key) {
|
|
1322
|
-
return [
|
|
1286
|
+
return [
|
|
1287
|
+
"type",
|
|
1288
|
+
"payload",
|
|
1289
|
+
"error",
|
|
1290
|
+
"meta"
|
|
1291
|
+
].indexOf(key) > -1;
|
|
1323
1292
|
}
|
|
1324
1293
|
function freezeDraftable(val) {
|
|
1325
1294
|
return isDraftable(val) ? produce(val, () => {
|
|
@@ -1336,28 +1305,18 @@ function executeReducerBuilderCallback(builderCallback) {
|
|
|
1336
1305
|
const builder = {
|
|
1337
1306
|
addCase(typeOrActionCreator, reducer) {
|
|
1338
1307
|
if (process.env.NODE_ENV !== "production") {
|
|
1339
|
-
if (actionMatchers.length > 0)
|
|
1340
|
-
|
|
1341
|
-
}
|
|
1342
|
-
if (defaultCaseReducer) {
|
|
1343
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
1344
|
-
}
|
|
1308
|
+
if (actionMatchers.length > 0) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(26) : "`builder.addCase` should only be called before calling `builder.addMatcher`");
|
|
1309
|
+
if (defaultCaseReducer) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(27) : "`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
1345
1310
|
}
|
|
1346
1311
|
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
1347
|
-
if (!type)
|
|
1348
|
-
|
|
1349
|
-
}
|
|
1350
|
-
if (type in actionsMap) {
|
|
1351
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
1352
|
-
}
|
|
1312
|
+
if (!type) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(28) : "`builder.addCase` cannot be called with an empty action type");
|
|
1313
|
+
if (type in actionsMap) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(29) : `\`builder.addCase\` cannot be called with two reducers for the same action type '${type}'`);
|
|
1353
1314
|
actionsMap[type] = reducer;
|
|
1354
1315
|
return builder;
|
|
1355
1316
|
},
|
|
1356
1317
|
addAsyncThunk(asyncThunk, reducers) {
|
|
1357
1318
|
if (process.env.NODE_ENV !== "production") {
|
|
1358
|
-
if (defaultCaseReducer)
|
|
1359
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
1360
|
-
}
|
|
1319
|
+
if (defaultCaseReducer) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(43) : "`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");
|
|
1361
1320
|
}
|
|
1362
1321
|
if (reducers.pending) actionsMap[asyncThunk.pending.type] = reducers.pending;
|
|
1363
1322
|
if (reducers.rejected) actionsMap[asyncThunk.rejected.type] = reducers.rejected;
|
|
@@ -1370,9 +1329,7 @@ function executeReducerBuilderCallback(builderCallback) {
|
|
|
1370
1329
|
},
|
|
1371
1330
|
addMatcher(matcher, reducer) {
|
|
1372
1331
|
if (process.env.NODE_ENV !== "production") {
|
|
1373
|
-
if (defaultCaseReducer)
|
|
1374
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
1375
|
-
}
|
|
1332
|
+
if (defaultCaseReducer) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(30) : "`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
1376
1333
|
}
|
|
1377
1334
|
actionMatchers.push({
|
|
1378
1335
|
matcher,
|
|
@@ -1382,66 +1339,52 @@ function executeReducerBuilderCallback(builderCallback) {
|
|
|
1382
1339
|
},
|
|
1383
1340
|
addDefaultCase(reducer) {
|
|
1384
1341
|
if (process.env.NODE_ENV !== "production") {
|
|
1385
|
-
if (defaultCaseReducer)
|
|
1386
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
|
|
1387
|
-
}
|
|
1342
|
+
if (defaultCaseReducer) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(31) : "`builder.addDefaultCase` can only be called once");
|
|
1388
1343
|
}
|
|
1389
1344
|
defaultCaseReducer = reducer;
|
|
1390
1345
|
return builder;
|
|
1391
1346
|
}
|
|
1392
1347
|
};
|
|
1393
1348
|
builderCallback(builder);
|
|
1394
|
-
return [
|
|
1349
|
+
return [
|
|
1350
|
+
actionsMap,
|
|
1351
|
+
actionMatchers,
|
|
1352
|
+
defaultCaseReducer
|
|
1353
|
+
];
|
|
1395
1354
|
}
|
|
1396
1355
|
function isStateFunction(x) {
|
|
1397
1356
|
return typeof x === "function";
|
|
1398
1357
|
}
|
|
1399
1358
|
function createReducer(initialState, mapOrBuilderCallback) {
|
|
1400
1359
|
if (process.env.NODE_ENV !== "production") {
|
|
1401
|
-
if (typeof mapOrBuilderCallback === "object")
|
|
1402
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
|
1403
|
-
}
|
|
1360
|
+
if (typeof mapOrBuilderCallback === "object") throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : "The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
|
1404
1361
|
}
|
|
1405
1362
|
let [actionsMap, finalActionMatchers, finalDefaultCaseReducer] = executeReducerBuilderCallback(mapOrBuilderCallback);
|
|
1406
1363
|
let getInitialState;
|
|
1407
|
-
if (isStateFunction(initialState))
|
|
1408
|
-
|
|
1409
|
-
} else {
|
|
1364
|
+
if (isStateFunction(initialState)) getInitialState = () => freezeDraftable(initialState());
|
|
1365
|
+
else {
|
|
1410
1366
|
const frozenInitialState = freezeDraftable(initialState);
|
|
1411
1367
|
getInitialState = () => frozenInitialState;
|
|
1412
1368
|
}
|
|
1413
1369
|
function reducer(state = getInitialState(), action) {
|
|
1414
|
-
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({
|
|
1415
|
-
|
|
1416
|
-
}) => matcher(action)).map(({
|
|
1417
|
-
reducer: reducer2
|
|
1418
|
-
}) => reducer2)];
|
|
1419
|
-
if (caseReducers.filter((cr) => !!cr).length === 0) {
|
|
1420
|
-
caseReducers = [finalDefaultCaseReducer];
|
|
1421
|
-
}
|
|
1370
|
+
let caseReducers = [actionsMap[action.type], ...finalActionMatchers.filter(({ matcher }) => matcher(action)).map(({ reducer: reducer2 }) => reducer2)];
|
|
1371
|
+
if (caseReducers.filter((cr) => !!cr).length === 0) caseReducers = [finalDefaultCaseReducer];
|
|
1422
1372
|
return caseReducers.reduce((previousState, caseReducer) => {
|
|
1423
1373
|
if (caseReducer) {
|
|
1424
1374
|
if (isDraft(previousState)) {
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
if (result === void 0) {
|
|
1428
|
-
return previousState;
|
|
1429
|
-
}
|
|
1375
|
+
const result = caseReducer(previousState, action);
|
|
1376
|
+
if (result === void 0) return previousState;
|
|
1430
1377
|
return result;
|
|
1431
1378
|
} else if (!isDraftable(previousState)) {
|
|
1432
1379
|
const result = caseReducer(previousState, action);
|
|
1433
1380
|
if (result === void 0) {
|
|
1434
|
-
if (previousState === null)
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
throw Error("A case reducer on a non-draftable value must not return undefined");
|
|
1381
|
+
if (previousState === null) return previousState;
|
|
1382
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : "A case reducer on a non-draftable value must not return undefined");
|
|
1438
1383
|
}
|
|
1439
1384
|
return result;
|
|
1440
|
-
} else {
|
|
1441
|
-
return
|
|
1442
|
-
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1385
|
+
} else return produce(previousState, (draft) => {
|
|
1386
|
+
return caseReducer(draft, action);
|
|
1387
|
+
});
|
|
1445
1388
|
}
|
|
1446
1389
|
return previousState;
|
|
1447
1390
|
}, state);
|
|
@@ -1450,11 +1393,8 @@ function createReducer(initialState, mapOrBuilderCallback) {
|
|
|
1450
1393
|
return reducer;
|
|
1451
1394
|
}
|
|
1452
1395
|
var matches = (matcher, action) => {
|
|
1453
|
-
if (hasMatchFunction(matcher))
|
|
1454
|
-
|
|
1455
|
-
} else {
|
|
1456
|
-
return matcher(action);
|
|
1457
|
-
}
|
|
1396
|
+
if (hasMatchFunction(matcher)) return matcher.match(action);
|
|
1397
|
+
else return matcher(action);
|
|
1458
1398
|
};
|
|
1459
1399
|
function isAnyOf(...matchers) {
|
|
1460
1400
|
return (action) => {
|
|
@@ -1465,51 +1405,40 @@ var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXI
|
|
|
1465
1405
|
var nanoid = (size = 21) => {
|
|
1466
1406
|
let id = "";
|
|
1467
1407
|
let i = size;
|
|
1468
|
-
while (i--)
|
|
1469
|
-
id += urlAlphabet[Math.random() * 64 | 0];
|
|
1470
|
-
}
|
|
1408
|
+
while (i--) id += urlAlphabet[Math.random() * 64 | 0];
|
|
1471
1409
|
return id;
|
|
1472
1410
|
};
|
|
1473
|
-
var commonProperties = [
|
|
1411
|
+
var commonProperties = [
|
|
1412
|
+
"name",
|
|
1413
|
+
"message",
|
|
1414
|
+
"stack",
|
|
1415
|
+
"code"
|
|
1416
|
+
];
|
|
1474
1417
|
var RejectWithValue = class {
|
|
1418
|
+
payload;
|
|
1419
|
+
meta;
|
|
1420
|
+
_type;
|
|
1475
1421
|
constructor(payload, meta) {
|
|
1476
1422
|
this.payload = payload;
|
|
1477
1423
|
this.meta = meta;
|
|
1478
1424
|
}
|
|
1425
|
+
};
|
|
1426
|
+
var FulfillWithMeta = class {
|
|
1479
1427
|
payload;
|
|
1480
1428
|
meta;
|
|
1481
|
-
/*
|
|
1482
|
-
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
1483
|
-
does not exist at runtime
|
|
1484
|
-
*/
|
|
1485
1429
|
_type;
|
|
1486
|
-
};
|
|
1487
|
-
var FulfillWithMeta = class {
|
|
1488
1430
|
constructor(payload, meta) {
|
|
1489
1431
|
this.payload = payload;
|
|
1490
1432
|
this.meta = meta;
|
|
1491
1433
|
}
|
|
1492
|
-
payload;
|
|
1493
|
-
meta;
|
|
1494
|
-
/*
|
|
1495
|
-
type-only property to distinguish between RejectWithValue and FulfillWithMeta
|
|
1496
|
-
does not exist at runtime
|
|
1497
|
-
*/
|
|
1498
|
-
_type;
|
|
1499
1434
|
};
|
|
1500
1435
|
var miniSerializeError = (value) => {
|
|
1501
1436
|
if (typeof value === "object" && value !== null) {
|
|
1502
1437
|
const simpleError = {};
|
|
1503
|
-
for (const property of commonProperties)
|
|
1504
|
-
if (typeof value[property] === "string") {
|
|
1505
|
-
simpleError[property] = value[property];
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1438
|
+
for (const property of commonProperties) if (typeof value[property] === "string") simpleError[property] = value[property];
|
|
1508
1439
|
return simpleError;
|
|
1509
1440
|
}
|
|
1510
|
-
return {
|
|
1511
|
-
message: String(value)
|
|
1512
|
-
};
|
|
1441
|
+
return { message: String(value) };
|
|
1513
1442
|
};
|
|
1514
1443
|
var externalAbortMessage = "External signal was aborted";
|
|
1515
1444
|
var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
@@ -1539,15 +1468,13 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1539
1468
|
...meta || {},
|
|
1540
1469
|
arg,
|
|
1541
1470
|
requestId,
|
|
1542
|
-
rejectedWithValue:
|
|
1471
|
+
rejectedWithValue: payload !== void 0,
|
|
1543
1472
|
requestStatus: "rejected",
|
|
1544
1473
|
aborted: error?.name === "AbortError",
|
|
1545
1474
|
condition: error?.name === "ConditionError"
|
|
1546
1475
|
}
|
|
1547
1476
|
}));
|
|
1548
|
-
function actionCreator(arg, {
|
|
1549
|
-
signal
|
|
1550
|
-
} = {}) {
|
|
1477
|
+
function actionCreator(arg, { signal } = {}) {
|
|
1551
1478
|
return (dispatch, getState, extra) => {
|
|
1552
1479
|
const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
|
|
1553
1480
|
const abortController = new AbortController();
|
|
@@ -1558,13 +1485,8 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1558
1485
|
abortController.abort();
|
|
1559
1486
|
}
|
|
1560
1487
|
if (signal) {
|
|
1561
|
-
if (signal.aborted)
|
|
1562
|
-
|
|
1563
|
-
} else {
|
|
1564
|
-
signal.addEventListener("abort", () => abort(externalAbortMessage), {
|
|
1565
|
-
once: true
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1488
|
+
if (signal.aborted) abort(externalAbortMessage);
|
|
1489
|
+
else signal.addEventListener("abort", () => abort(externalAbortMessage), { once: true });
|
|
1568
1490
|
}
|
|
1569
1491
|
const promise = async function() {
|
|
1570
1492
|
let finalAction;
|
|
@@ -1573,15 +1495,15 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1573
1495
|
getState,
|
|
1574
1496
|
extra
|
|
1575
1497
|
});
|
|
1576
|
-
if (isThenable(conditionResult))
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
}
|
|
1498
|
+
if (isThenable(conditionResult)) conditionResult = await conditionResult;
|
|
1499
|
+
if (conditionResult === false) throw {
|
|
1500
|
+
name: "ConditionError",
|
|
1501
|
+
message: "Aborted due to condition callback returning false."
|
|
1502
|
+
};
|
|
1503
|
+
if (abortController.signal.aborted) throw {
|
|
1504
|
+
name: "AbortError",
|
|
1505
|
+
message: abortReason || "Aborted"
|
|
1506
|
+
};
|
|
1585
1507
|
const abortedPromise = new Promise((_, reject) => {
|
|
1586
1508
|
abortHandler = () => {
|
|
1587
1509
|
reject({
|
|
@@ -1589,9 +1511,7 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1589
1511
|
message: abortReason || "Aborted"
|
|
1590
1512
|
});
|
|
1591
1513
|
};
|
|
1592
|
-
abortController.signal.addEventListener("abort", abortHandler, {
|
|
1593
|
-
once: true
|
|
1594
|
-
});
|
|
1514
|
+
abortController.signal.addEventListener("abort", abortHandler, { once: true });
|
|
1595
1515
|
});
|
|
1596
1516
|
dispatch(pending(requestId, arg, options?.getPendingMeta?.({
|
|
1597
1517
|
requestId,
|
|
@@ -1614,25 +1534,16 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1614
1534
|
return new FulfillWithMeta(value, meta);
|
|
1615
1535
|
}
|
|
1616
1536
|
})).then((result) => {
|
|
1617
|
-
if (result instanceof RejectWithValue)
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1620
|
-
if (result instanceof FulfillWithMeta) {
|
|
1621
|
-
return fulfilled(result.payload, requestId, arg, result.meta);
|
|
1622
|
-
}
|
|
1537
|
+
if (result instanceof RejectWithValue) throw result;
|
|
1538
|
+
if (result instanceof FulfillWithMeta) return fulfilled(result.payload, requestId, arg, result.meta);
|
|
1623
1539
|
return fulfilled(result, requestId, arg);
|
|
1624
1540
|
})]);
|
|
1625
1541
|
} catch (err) {
|
|
1626
1542
|
finalAction = err instanceof RejectWithValue ? rejected(null, requestId, arg, err.payload, err.meta) : rejected(err, requestId, arg);
|
|
1627
1543
|
} finally {
|
|
1628
|
-
if (abortHandler)
|
|
1629
|
-
abortController.signal.removeEventListener("abort", abortHandler);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
const skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
|
|
1633
|
-
if (!skipDispatch) {
|
|
1634
|
-
dispatch(finalAction);
|
|
1544
|
+
if (abortHandler) abortController.signal.removeEventListener("abort", abortHandler);
|
|
1635
1545
|
}
|
|
1546
|
+
if (!(options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition)) dispatch(finalAction);
|
|
1636
1547
|
return finalAction;
|
|
1637
1548
|
}();
|
|
1638
1549
|
return Object.assign(promise, {
|
|
@@ -1657,40 +1568,25 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
|
|
|
1657
1568
|
return createAsyncThunk2;
|
|
1658
1569
|
})();
|
|
1659
1570
|
function unwrapResult(action) {
|
|
1660
|
-
if (action.meta && action.meta.rejectedWithValue)
|
|
1661
|
-
|
|
1662
|
-
}
|
|
1663
|
-
if (action.error) {
|
|
1664
|
-
throw action.error;
|
|
1665
|
-
}
|
|
1571
|
+
if (action.meta && action.meta.rejectedWithValue) throw action.payload;
|
|
1572
|
+
if (action.error) throw action.error;
|
|
1666
1573
|
return action.payload;
|
|
1667
1574
|
}
|
|
1668
1575
|
function isThenable(value) {
|
|
1669
1576
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
1670
1577
|
}
|
|
1671
1578
|
var asyncThunkSymbol = /* @__PURE__ */ Symbol.for("rtk-slice-createasyncthunk");
|
|
1672
|
-
var asyncThunkCreator = {
|
|
1673
|
-
[asyncThunkSymbol]: createAsyncThunk
|
|
1674
|
-
};
|
|
1579
|
+
var asyncThunkCreator = { [asyncThunkSymbol]: createAsyncThunk };
|
|
1675
1580
|
function getType(slice, actionKey) {
|
|
1676
1581
|
return `${slice}/${actionKey}`;
|
|
1677
1582
|
}
|
|
1678
|
-
function buildCreateSlice({
|
|
1679
|
-
creators
|
|
1680
|
-
} = {}) {
|
|
1583
|
+
function buildCreateSlice({ creators } = {}) {
|
|
1681
1584
|
const cAT = creators?.asyncThunk?.[asyncThunkSymbol];
|
|
1682
|
-
return function
|
|
1683
|
-
const {
|
|
1684
|
-
|
|
1685
|
-
reducerPath = name
|
|
1686
|
-
} = options;
|
|
1687
|
-
if (!name) {
|
|
1688
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
|
|
1689
|
-
}
|
|
1585
|
+
return function createSlice(options) {
|
|
1586
|
+
const { name, reducerPath = name } = options;
|
|
1587
|
+
if (!name) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "`name` is a required option for createSlice");
|
|
1690
1588
|
if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1691
|
-
if (options.initialState === void 0)
|
|
1692
|
-
console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
1693
|
-
}
|
|
1589
|
+
if (options.initialState === void 0) console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
1694
1590
|
}
|
|
1695
1591
|
const reducers = (typeof options.reducers === "function" ? options.reducers(buildReducerCreators()) : options.reducers) || {};
|
|
1696
1592
|
const reducerNames = Object.keys(reducers);
|
|
@@ -1703,12 +1599,8 @@ function buildCreateSlice({
|
|
|
1703
1599
|
const contextMethods = {
|
|
1704
1600
|
addCase(typeOrActionCreator, reducer2) {
|
|
1705
1601
|
const type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
1706
|
-
if (!type)
|
|
1707
|
-
|
|
1708
|
-
}
|
|
1709
|
-
if (type in context.sliceCaseReducersByType) {
|
|
1710
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
|
1711
|
-
}
|
|
1602
|
+
if (!type) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "`context.addCase` cannot be called with an empty action type");
|
|
1603
|
+
if (type in context.sliceCaseReducersByType) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "`context.addCase` cannot be called with two reducers for the same action type: " + type);
|
|
1712
1604
|
context.sliceCaseReducersByType[type] = reducer2;
|
|
1713
1605
|
return contextMethods;
|
|
1714
1606
|
},
|
|
@@ -1735,17 +1627,12 @@ function buildCreateSlice({
|
|
|
1735
1627
|
type: getType(name, reducerName),
|
|
1736
1628
|
createNotation: typeof options.reducers === "function"
|
|
1737
1629
|
};
|
|
1738
|
-
if (isAsyncThunkSliceReducerDefinition(reducerDefinition))
|
|
1739
|
-
|
|
1740
|
-
} else {
|
|
1741
|
-
handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
1742
|
-
}
|
|
1630
|
+
if (isAsyncThunkSliceReducerDefinition(reducerDefinition)) handleThunkCaseReducerDefinition(reducerDetails, reducerDefinition, contextMethods, cAT);
|
|
1631
|
+
else handleNormalReducerDefinition(reducerDetails, reducerDefinition, contextMethods);
|
|
1743
1632
|
});
|
|
1744
1633
|
function buildReducer() {
|
|
1745
1634
|
if (process.env.NODE_ENV !== "production") {
|
|
1746
|
-
if (typeof options.extraReducers === "object")
|
|
1747
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
|
1748
|
-
}
|
|
1635
|
+
if (typeof options.extraReducers === "object") throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
|
1749
1636
|
}
|
|
1750
1637
|
const [extraReducers = {}, actionMatchers = [], defaultCaseReducer = void 0] = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers];
|
|
1751
1638
|
const finalCaseReducers = {
|
|
@@ -1753,18 +1640,10 @@ function buildCreateSlice({
|
|
|
1753
1640
|
...context.sliceCaseReducersByType
|
|
1754
1641
|
};
|
|
1755
1642
|
return createReducer(options.initialState, (builder) => {
|
|
1756
|
-
for (let key in finalCaseReducers)
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
builder.addMatcher(sM.matcher, sM.reducer);
|
|
1761
|
-
}
|
|
1762
|
-
for (let m of actionMatchers) {
|
|
1763
|
-
builder.addMatcher(m.matcher, m.reducer);
|
|
1764
|
-
}
|
|
1765
|
-
if (defaultCaseReducer) {
|
|
1766
|
-
builder.addDefaultCase(defaultCaseReducer);
|
|
1767
|
-
}
|
|
1643
|
+
for (let key in finalCaseReducers) builder.addCase(key, finalCaseReducers[key]);
|
|
1644
|
+
for (let sM of context.sliceMatchers) builder.addMatcher(sM.matcher, sM.reducer);
|
|
1645
|
+
for (let m of actionMatchers) builder.addMatcher(m.matcher, m.reducer);
|
|
1646
|
+
if (defaultCaseReducer) builder.addDefaultCase(defaultCaseReducer);
|
|
1768
1647
|
});
|
|
1769
1648
|
}
|
|
1770
1649
|
const selectSelf = (state) => state;
|
|
@@ -1783,21 +1662,15 @@ function buildCreateSlice({
|
|
|
1783
1662
|
function selectSlice(state) {
|
|
1784
1663
|
let sliceState = state[reducerPath2];
|
|
1785
1664
|
if (typeof sliceState === "undefined") {
|
|
1786
|
-
if (injected)
|
|
1787
|
-
|
|
1788
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
1789
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
|
1790
|
-
}
|
|
1665
|
+
if (injected) sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
|
|
1666
|
+
else if (process.env.NODE_ENV !== "production") throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : "selectSlice returned undefined for an uninjected slice reducer");
|
|
1791
1667
|
}
|
|
1792
1668
|
return sliceState;
|
|
1793
1669
|
}
|
|
1794
1670
|
function getSelectors(selectState = selectSelf) {
|
|
1795
|
-
|
|
1796
|
-
return getOrInsertComputed(selectorCache, selectState, () => {
|
|
1671
|
+
return getOrInsertComputed(getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap()), selectState, () => {
|
|
1797
1672
|
const map = {};
|
|
1798
|
-
for (const [name2, selector] of Object.entries(options.selectors ?? {}))
|
|
1799
|
-
map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
|
1800
|
-
}
|
|
1673
|
+
for (const [name2, selector] of Object.entries(options.selectors ?? {})) map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
|
|
1801
1674
|
return map;
|
|
1802
1675
|
});
|
|
1803
1676
|
}
|
|
@@ -1817,10 +1690,7 @@ function buildCreateSlice({
|
|
|
1817
1690
|
caseReducers: context.sliceCaseReducersByName,
|
|
1818
1691
|
getInitialState,
|
|
1819
1692
|
...makeSelectorProps(reducerPath),
|
|
1820
|
-
injectInto(injectable, {
|
|
1821
|
-
reducerPath: pathOpt,
|
|
1822
|
-
...config
|
|
1823
|
-
} = {}) {
|
|
1693
|
+
injectInto(injectable, { reducerPath: pathOpt, ...config } = {}) {
|
|
1824
1694
|
const newReducerPath = pathOpt ?? reducerPath;
|
|
1825
1695
|
injectable.inject({
|
|
1826
1696
|
reducerPath: newReducerPath,
|
|
@@ -1839,11 +1709,8 @@ function wrapSelector(selector, selectState, getInitialState, injected) {
|
|
|
1839
1709
|
function wrapper(rootState, ...args) {
|
|
1840
1710
|
let sliceState = selectState(rootState);
|
|
1841
1711
|
if (typeof sliceState === "undefined") {
|
|
1842
|
-
if (injected)
|
|
1843
|
-
|
|
1844
|
-
} else if (process.env.NODE_ENV !== "production") {
|
|
1845
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
|
|
1846
|
-
}
|
|
1712
|
+
if (injected) sliceState = getInitialState();
|
|
1713
|
+
else if (process.env.NODE_ENV !== "production") throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(16) : "selectState returned undefined for an uninjected slice reducer");
|
|
1847
1714
|
}
|
|
1848
1715
|
return selector(sliceState, ...args);
|
|
1849
1716
|
}
|
|
@@ -1861,16 +1728,9 @@ function buildReducerCreators() {
|
|
|
1861
1728
|
asyncThunk.withTypes = () => asyncThunk;
|
|
1862
1729
|
return {
|
|
1863
1730
|
reducer(caseReducer) {
|
|
1864
|
-
return Object.assign({
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
[caseReducer.name](...args) {
|
|
1868
|
-
return caseReducer(...args);
|
|
1869
|
-
}
|
|
1870
|
-
}[caseReducer.name], {
|
|
1871
|
-
_reducerDefinitionType: "reducer"
|
|
1872
|
-
/* reducer */
|
|
1873
|
-
});
|
|
1731
|
+
return Object.assign({ [caseReducer.name](...args) {
|
|
1732
|
+
return caseReducer(...args);
|
|
1733
|
+
} }[caseReducer.name], { _reducerDefinitionType: "reducer" });
|
|
1874
1734
|
},
|
|
1875
1735
|
preparedReducer(prepare, reducer) {
|
|
1876
1736
|
return {
|
|
@@ -1882,22 +1742,14 @@ function buildReducerCreators() {
|
|
|
1882
1742
|
asyncThunk
|
|
1883
1743
|
};
|
|
1884
1744
|
}
|
|
1885
|
-
function handleNormalReducerDefinition({
|
|
1886
|
-
type,
|
|
1887
|
-
reducerName,
|
|
1888
|
-
createNotation
|
|
1889
|
-
}, maybeReducerWithPrepare, context) {
|
|
1745
|
+
function handleNormalReducerDefinition({ type, reducerName, createNotation }, maybeReducerWithPrepare, context) {
|
|
1890
1746
|
let caseReducer;
|
|
1891
1747
|
let prepareCallback;
|
|
1892
1748
|
if ("reducer" in maybeReducerWithPrepare) {
|
|
1893
|
-
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare))
|
|
1894
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
1895
|
-
}
|
|
1749
|
+
if (createNotation && !isCaseReducerWithPrepareDefinition(maybeReducerWithPrepare)) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(17) : "Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");
|
|
1896
1750
|
caseReducer = maybeReducerWithPrepare.reducer;
|
|
1897
1751
|
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
1898
|
-
} else
|
|
1899
|
-
caseReducer = maybeReducerWithPrepare;
|
|
1900
|
-
}
|
|
1752
|
+
} else caseReducer = maybeReducerWithPrepare;
|
|
1901
1753
|
context.addCase(type, caseReducer).exposeCaseReducer(reducerName, caseReducer).exposeAction(reducerName, prepareCallback ? createAction(type, prepareCallback) : createAction(type));
|
|
1902
1754
|
}
|
|
1903
1755
|
function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
|
@@ -1906,43 +1758,23 @@ function isAsyncThunkSliceReducerDefinition(reducerDefinition) {
|
|
|
1906
1758
|
function isCaseReducerWithPrepareDefinition(reducerDefinition) {
|
|
1907
1759
|
return reducerDefinition._reducerDefinitionType === "reducerWithPrepare";
|
|
1908
1760
|
}
|
|
1909
|
-
function handleThunkCaseReducerDefinition({
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}, reducerDefinition, context, cAT) {
|
|
1913
|
-
if (!cAT) {
|
|
1914
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
|
|
1915
|
-
}
|
|
1916
|
-
const {
|
|
1917
|
-
payloadCreator,
|
|
1918
|
-
fulfilled,
|
|
1919
|
-
pending,
|
|
1920
|
-
rejected,
|
|
1921
|
-
settled,
|
|
1922
|
-
options
|
|
1923
|
-
} = reducerDefinition;
|
|
1761
|
+
function handleThunkCaseReducerDefinition({ type, reducerName }, reducerDefinition, context, cAT) {
|
|
1762
|
+
if (!cAT) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(18) : "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");
|
|
1763
|
+
const { payloadCreator, fulfilled, pending, rejected, settled, options } = reducerDefinition;
|
|
1924
1764
|
const thunk = cAT(type, payloadCreator, options);
|
|
1925
1765
|
context.exposeAction(reducerName, thunk);
|
|
1926
|
-
if (fulfilled)
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
if (
|
|
1930
|
-
context.addCase(thunk.pending, pending);
|
|
1931
|
-
}
|
|
1932
|
-
if (rejected) {
|
|
1933
|
-
context.addCase(thunk.rejected, rejected);
|
|
1934
|
-
}
|
|
1935
|
-
if (settled) {
|
|
1936
|
-
context.addMatcher(thunk.settled, settled);
|
|
1937
|
-
}
|
|
1766
|
+
if (fulfilled) context.addCase(thunk.fulfilled, fulfilled);
|
|
1767
|
+
if (pending) context.addCase(thunk.pending, pending);
|
|
1768
|
+
if (rejected) context.addCase(thunk.rejected, rejected);
|
|
1769
|
+
if (settled) context.addMatcher(thunk.settled, settled);
|
|
1938
1770
|
context.exposeCaseReducer(reducerName, {
|
|
1939
|
-
fulfilled: fulfilled || noop,
|
|
1940
|
-
pending: pending || noop,
|
|
1941
|
-
rejected: rejected || noop,
|
|
1942
|
-
settled: settled || noop
|
|
1771
|
+
fulfilled: fulfilled || noop$1,
|
|
1772
|
+
pending: pending || noop$1,
|
|
1773
|
+
rejected: rejected || noop$1,
|
|
1774
|
+
settled: settled || noop$1
|
|
1943
1775
|
});
|
|
1944
1776
|
}
|
|
1945
|
-
function noop() {
|
|
1777
|
+
function noop$1() {
|
|
1946
1778
|
}
|
|
1947
1779
|
function getInitialEntityState() {
|
|
1948
1780
|
return {
|
|
@@ -1955,30 +1787,24 @@ function createInitialStateFactory(stateAdapter) {
|
|
|
1955
1787
|
const state = Object.assign(getInitialEntityState(), additionalState);
|
|
1956
1788
|
return entities ? stateAdapter.setAll(state, entities) : state;
|
|
1957
1789
|
}
|
|
1958
|
-
return {
|
|
1959
|
-
getInitialState
|
|
1960
|
-
};
|
|
1790
|
+
return { getInitialState };
|
|
1961
1791
|
}
|
|
1962
1792
|
function createSelectorsFactory() {
|
|
1963
1793
|
function getSelectors(selectState, options = {}) {
|
|
1964
|
-
const {
|
|
1965
|
-
createSelector: createSelector2 = createDraftSafeSelector
|
|
1966
|
-
} = options;
|
|
1794
|
+
const { createSelector: createSelector2 = createDraftSafeSelector } = options;
|
|
1967
1795
|
const selectIds = (state) => state.ids;
|
|
1968
1796
|
const selectEntities = (state) => state.entities;
|
|
1969
1797
|
const selectAll = createSelector2(selectIds, selectEntities, (ids, entities) => ids.map((id) => entities[id]));
|
|
1970
1798
|
const selectId = (_, id) => id;
|
|
1971
1799
|
const selectById = (entities, id) => entities[id];
|
|
1972
1800
|
const selectTotal = createSelector2(selectIds, (ids) => ids.length);
|
|
1973
|
-
if (!selectState) {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
};
|
|
1981
|
-
}
|
|
1801
|
+
if (!selectState) return {
|
|
1802
|
+
selectIds,
|
|
1803
|
+
selectEntities,
|
|
1804
|
+
selectAll,
|
|
1805
|
+
selectTotal,
|
|
1806
|
+
selectById: createSelector2(selectEntities, selectId, selectById)
|
|
1807
|
+
};
|
|
1982
1808
|
const selectGlobalizedEntities = createSelector2(selectState, selectEntities);
|
|
1983
1809
|
return {
|
|
1984
1810
|
selectIds: createSelector2(selectState, selectIds),
|
|
@@ -1988,9 +1814,7 @@ function createSelectorsFactory() {
|
|
|
1988
1814
|
selectById: createSelector2(selectGlobalizedEntities, selectId, selectById)
|
|
1989
1815
|
};
|
|
1990
1816
|
}
|
|
1991
|
-
return {
|
|
1992
|
-
getSelectors
|
|
1993
|
-
};
|
|
1817
|
+
return { getSelectors };
|
|
1994
1818
|
}
|
|
1995
1819
|
var isDraftTyped = isDraft;
|
|
1996
1820
|
function createSingleArgumentStateOperator(mutator) {
|
|
@@ -2005,11 +1829,8 @@ function createStateOperator(mutator) {
|
|
|
2005
1829
|
return isFSA(arg2);
|
|
2006
1830
|
}
|
|
2007
1831
|
const runMutator = (draft) => {
|
|
2008
|
-
if (isPayloadActionArgument(arg))
|
|
2009
|
-
|
|
2010
|
-
} else {
|
|
2011
|
-
mutator(arg, draft);
|
|
2012
|
-
}
|
|
1832
|
+
if (isPayloadActionArgument(arg)) mutator(arg.payload, draft);
|
|
1833
|
+
else mutator(arg, draft);
|
|
2013
1834
|
};
|
|
2014
1835
|
if (isDraftTyped(state)) {
|
|
2015
1836
|
runMutator(state);
|
|
@@ -2020,15 +1841,11 @@ function createStateOperator(mutator) {
|
|
|
2020
1841
|
}
|
|
2021
1842
|
function selectIdValue(entity, selectId) {
|
|
2022
1843
|
const key = selectId(entity);
|
|
2023
|
-
if (process.env.NODE_ENV !== "production" && key === void 0)
|
|
2024
|
-
console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
|
|
2025
|
-
}
|
|
1844
|
+
if (process.env.NODE_ENV !== "production" && key === void 0) console.warn("The entity passed to the `selectId` implementation returned undefined.", "You should probably provide your own `selectId` implementation.", "The entity that was passed:", entity, "The `selectId` implementation:", selectId.toString());
|
|
2026
1845
|
return key;
|
|
2027
1846
|
}
|
|
2028
1847
|
function ensureEntitiesArray(entities) {
|
|
2029
|
-
if (!Array.isArray(entities))
|
|
2030
|
-
entities = Object.values(entities);
|
|
2031
|
-
}
|
|
1848
|
+
if (!Array.isArray(entities)) entities = Object.values(entities);
|
|
2032
1849
|
return entities;
|
|
2033
1850
|
}
|
|
2034
1851
|
function getCurrent(value) {
|
|
@@ -2043,52 +1860,46 @@ function splitAddedUpdatedEntities(newEntities, selectId, state) {
|
|
|
2043
1860
|
const updated = [];
|
|
2044
1861
|
for (const entity of newEntities) {
|
|
2045
1862
|
const id = selectIdValue(entity, selectId);
|
|
2046
|
-
if (existingIds.has(id) || addedIds.has(id)) {
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
} else {
|
|
1863
|
+
if (existingIds.has(id) || addedIds.has(id)) updated.push({
|
|
1864
|
+
id,
|
|
1865
|
+
changes: entity
|
|
1866
|
+
});
|
|
1867
|
+
else {
|
|
2052
1868
|
addedIds.add(id);
|
|
2053
1869
|
added.push(entity);
|
|
2054
1870
|
}
|
|
2055
1871
|
}
|
|
2056
|
-
return [
|
|
1872
|
+
return [
|
|
1873
|
+
added,
|
|
1874
|
+
updated,
|
|
1875
|
+
existingIdsArray
|
|
1876
|
+
];
|
|
2057
1877
|
}
|
|
2058
1878
|
function createUnsortedStateAdapter(selectId) {
|
|
2059
1879
|
function addOneMutably(entity, state) {
|
|
2060
1880
|
const key = selectIdValue(entity, selectId);
|
|
2061
|
-
if (key in state.entities)
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
1881
|
+
if (key in state.entities) return;
|
|
2064
1882
|
state.ids.push(key);
|
|
2065
1883
|
state.entities[key] = entity;
|
|
2066
1884
|
}
|
|
2067
1885
|
function addManyMutably(newEntities, state) {
|
|
2068
1886
|
newEntities = ensureEntitiesArray(newEntities);
|
|
2069
|
-
for (const entity of newEntities)
|
|
2070
|
-
addOneMutably(entity, state);
|
|
2071
|
-
}
|
|
1887
|
+
for (const entity of newEntities) addOneMutably(entity, state);
|
|
2072
1888
|
}
|
|
2073
1889
|
function setOneMutably(entity, state) {
|
|
2074
1890
|
const key = selectIdValue(entity, selectId);
|
|
2075
|
-
if (!(key in state.entities))
|
|
2076
|
-
state.ids.push(key);
|
|
2077
|
-
}
|
|
2078
|
-
;
|
|
1891
|
+
if (!(key in state.entities)) state.ids.push(key);
|
|
2079
1892
|
state.entities[key] = entity;
|
|
2080
1893
|
}
|
|
2081
1894
|
function setManyMutably(newEntities, state) {
|
|
2082
1895
|
newEntities = ensureEntitiesArray(newEntities);
|
|
2083
|
-
for (const entity of newEntities)
|
|
2084
|
-
setOneMutably(entity, state);
|
|
2085
|
-
}
|
|
1896
|
+
for (const entity of newEntities) setOneMutably(entity, state);
|
|
2086
1897
|
}
|
|
2087
1898
|
function setAllMutably(newEntities, state) {
|
|
2088
1899
|
newEntities = ensureEntitiesArray(newEntities);
|
|
2089
1900
|
state.ids = [];
|
|
2090
1901
|
state.entities = {};
|
|
2091
|
-
|
|
1902
|
+
setManyMutably(newEntities, state);
|
|
2092
1903
|
}
|
|
2093
1904
|
function removeOneMutably(key, state) {
|
|
2094
1905
|
return removeManyMutably([key], state);
|
|
@@ -2101,9 +1912,7 @@ function createUnsortedStateAdapter(selectId) {
|
|
|
2101
1912
|
didMutate = true;
|
|
2102
1913
|
}
|
|
2103
1914
|
});
|
|
2104
|
-
if (didMutate)
|
|
2105
|
-
state.ids = state.ids.filter((id) => id in state.entities);
|
|
2106
|
-
}
|
|
1915
|
+
if (didMutate) state.ids = state.ids.filter((id) => id in state.entities);
|
|
2107
1916
|
}
|
|
2108
1917
|
function removeAllMutably(state) {
|
|
2109
1918
|
Object.assign(state, {
|
|
@@ -2112,18 +1921,15 @@ function createUnsortedStateAdapter(selectId) {
|
|
|
2112
1921
|
});
|
|
2113
1922
|
}
|
|
2114
1923
|
function takeNewKey(keys, update, state) {
|
|
2115
|
-
const
|
|
2116
|
-
if (
|
|
2117
|
-
|
|
2118
|
-
}
|
|
2119
|
-
const updated = Object.assign({}, original3, update.changes);
|
|
1924
|
+
const original2 = state.entities[update.id];
|
|
1925
|
+
if (original2 === void 0) return false;
|
|
1926
|
+
const updated = Object.assign({}, original2, update.changes);
|
|
2120
1927
|
const newKey = selectIdValue(updated, selectId);
|
|
2121
1928
|
const hasNewKey = newKey !== update.id;
|
|
2122
1929
|
if (hasNewKey) {
|
|
2123
1930
|
keys[update.id] = newKey;
|
|
2124
1931
|
delete state.entities[update.id];
|
|
2125
1932
|
}
|
|
2126
|
-
;
|
|
2127
1933
|
state.entities[newKey] = updated;
|
|
2128
1934
|
return hasNewKey;
|
|
2129
1935
|
}
|
|
@@ -2134,25 +1940,17 @@ function createUnsortedStateAdapter(selectId) {
|
|
|
2134
1940
|
const newKeys = {};
|
|
2135
1941
|
const updatesPerEntity = {};
|
|
2136
1942
|
updates.forEach((update) => {
|
|
2137
|
-
if (update.id in state.entities) {
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
...update.changes
|
|
2145
|
-
}
|
|
2146
|
-
};
|
|
2147
|
-
}
|
|
1943
|
+
if (update.id in state.entities) updatesPerEntity[update.id] = {
|
|
1944
|
+
id: update.id,
|
|
1945
|
+
changes: {
|
|
1946
|
+
...updatesPerEntity[update.id]?.changes,
|
|
1947
|
+
...update.changes
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
2148
1950
|
});
|
|
2149
1951
|
updates = Object.values(updatesPerEntity);
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
const didMutateIds = updates.filter((update) => takeNewKey(newKeys, update, state)).length > 0;
|
|
2153
|
-
if (didMutateIds) {
|
|
2154
|
-
state.ids = Object.values(state.entities).map((e) => selectIdValue(e, selectId));
|
|
2155
|
-
}
|
|
1952
|
+
if (updates.length > 0) {
|
|
1953
|
+
if (updates.filter((update) => takeNewKey(newKeys, update, state)).length > 0) state.ids = Object.values(state.entities).map((e) => selectIdValue(e, selectId));
|
|
2156
1954
|
}
|
|
2157
1955
|
}
|
|
2158
1956
|
function upsertOneMutably(entity, state) {
|
|
@@ -2184,12 +1982,8 @@ function findInsertIndex(sortedItems, item, comparisonFunction) {
|
|
|
2184
1982
|
while (lowIndex < highIndex) {
|
|
2185
1983
|
let middleIndex = lowIndex + highIndex >>> 1;
|
|
2186
1984
|
const currentItem = sortedItems[middleIndex];
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
lowIndex = middleIndex + 1;
|
|
2190
|
-
} else {
|
|
2191
|
-
highIndex = middleIndex;
|
|
2192
|
-
}
|
|
1985
|
+
if (comparisonFunction(item, currentItem) >= 0) lowIndex = middleIndex + 1;
|
|
1986
|
+
else highIndex = middleIndex;
|
|
2193
1987
|
}
|
|
2194
1988
|
return lowIndex;
|
|
2195
1989
|
}
|
|
@@ -2199,11 +1993,7 @@ function insert(sortedItems, item, comparisonFunction) {
|
|
|
2199
1993
|
return sortedItems;
|
|
2200
1994
|
}
|
|
2201
1995
|
function createSortedStateAdapter(selectId, comparer) {
|
|
2202
|
-
const {
|
|
2203
|
-
removeOne,
|
|
2204
|
-
removeMany,
|
|
2205
|
-
removeAll
|
|
2206
|
-
} = createUnsortedStateAdapter(selectId);
|
|
1996
|
+
const { removeOne, removeMany, removeAll } = createUnsortedStateAdapter(selectId);
|
|
2207
1997
|
function addOneMutably(entity, state) {
|
|
2208
1998
|
return addManyMutably([entity], state);
|
|
2209
1999
|
}
|
|
@@ -2217,9 +2007,7 @@ function createSortedStateAdapter(selectId, comparer) {
|
|
|
2217
2007
|
if (notAdded) addedKeys.add(modelId);
|
|
2218
2008
|
return !existingKeys.has(modelId) && notAdded;
|
|
2219
2009
|
});
|
|
2220
|
-
if (models.length !== 0)
|
|
2221
|
-
mergeFunction(state, models);
|
|
2222
|
-
}
|
|
2010
|
+
if (models.length !== 0) mergeFunction(state, models);
|
|
2223
2011
|
}
|
|
2224
2012
|
function setOneMutably(entity, state) {
|
|
2225
2013
|
return setManyMutably([entity], state);
|
|
@@ -2241,7 +2029,7 @@ function createSortedStateAdapter(selectId, comparer) {
|
|
|
2241
2029
|
newEntities = ensureEntitiesArray(newEntities);
|
|
2242
2030
|
state.entities = {};
|
|
2243
2031
|
state.ids = [];
|
|
2244
|
-
|
|
2032
|
+
setManyMutably(newEntities, state);
|
|
2245
2033
|
}
|
|
2246
2034
|
function updateOneMutably(update, state) {
|
|
2247
2035
|
return updateManyMutably([update], state);
|
|
@@ -2249,11 +2037,17 @@ function createSortedStateAdapter(selectId, comparer) {
|
|
|
2249
2037
|
function updateManyMutably(updates, state) {
|
|
2250
2038
|
let appliedUpdates = false;
|
|
2251
2039
|
let replacedIds = false;
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2040
|
+
const updatesPerEntity = {};
|
|
2041
|
+
for (const update of updates) if (update.id in state.entities) updatesPerEntity[update.id] = {
|
|
2042
|
+
id: update.id,
|
|
2043
|
+
changes: {
|
|
2044
|
+
...updatesPerEntity[update.id]?.changes,
|
|
2045
|
+
...update.changes
|
|
2256
2046
|
}
|
|
2047
|
+
};
|
|
2048
|
+
for (const update of Object.values(updatesPerEntity)) {
|
|
2049
|
+
const entity = state.entities[update.id];
|
|
2050
|
+
if (!entity) continue;
|
|
2257
2051
|
appliedUpdates = true;
|
|
2258
2052
|
Object.assign(entity, update.changes);
|
|
2259
2053
|
const newId = selectId(entity);
|
|
@@ -2265,66 +2059,45 @@ function createSortedStateAdapter(selectId, comparer) {
|
|
|
2265
2059
|
state.entities[newId] = entity;
|
|
2266
2060
|
}
|
|
2267
2061
|
}
|
|
2268
|
-
if (appliedUpdates)
|
|
2269
|
-
mergeFunction(state, [], appliedUpdates, replacedIds);
|
|
2270
|
-
}
|
|
2062
|
+
if (appliedUpdates) mergeFunction(state, [], appliedUpdates, replacedIds);
|
|
2271
2063
|
}
|
|
2272
2064
|
function upsertOneMutably(entity, state) {
|
|
2273
2065
|
return upsertManyMutably([entity], state);
|
|
2274
2066
|
}
|
|
2275
2067
|
function upsertManyMutably(newEntities, state) {
|
|
2276
2068
|
const [added, updated, existingIdsArray] = splitAddedUpdatedEntities(newEntities, selectId, state);
|
|
2277
|
-
if (added.length)
|
|
2278
|
-
|
|
2279
|
-
}
|
|
2280
|
-
if (updated.length) {
|
|
2281
|
-
updateManyMutably(updated, state);
|
|
2282
|
-
}
|
|
2069
|
+
if (added.length) addManyMutably(added, state, existingIdsArray);
|
|
2070
|
+
if (updated.length) updateManyMutably(updated, state);
|
|
2283
2071
|
}
|
|
2284
2072
|
function areArraysEqual(a, b) {
|
|
2285
|
-
if (a.length !== b.length)
|
|
2286
|
-
return false;
|
|
2287
|
-
}
|
|
2073
|
+
if (a.length !== b.length) return false;
|
|
2288
2074
|
for (let i = 0; i < a.length; i++) {
|
|
2289
|
-
if (a[i] === b[i])
|
|
2290
|
-
continue;
|
|
2291
|
-
}
|
|
2075
|
+
if (a[i] === b[i]) continue;
|
|
2292
2076
|
return false;
|
|
2293
2077
|
}
|
|
2294
2078
|
return true;
|
|
2295
2079
|
}
|
|
2296
|
-
|
|
2080
|
+
function mergeFunction(state, addedItems, appliedUpdates, replacedIds) {
|
|
2297
2081
|
const currentEntities = getCurrent(state.entities);
|
|
2298
2082
|
const currentIds = getCurrent(state.ids);
|
|
2299
2083
|
const stateEntities = state.entities;
|
|
2300
2084
|
let ids = currentIds;
|
|
2301
|
-
if (replacedIds)
|
|
2302
|
-
ids = new Set(currentIds);
|
|
2303
|
-
}
|
|
2085
|
+
if (replacedIds) ids = new Set(currentIds);
|
|
2304
2086
|
let sortedEntities = [];
|
|
2305
2087
|
for (const id of ids) {
|
|
2306
2088
|
const entity = currentEntities[id];
|
|
2307
|
-
if (entity)
|
|
2308
|
-
sortedEntities.push(entity);
|
|
2309
|
-
}
|
|
2089
|
+
if (entity) sortedEntities.push(entity);
|
|
2310
2090
|
}
|
|
2311
2091
|
const wasPreviouslyEmpty = sortedEntities.length === 0;
|
|
2312
2092
|
for (const item of addedItems) {
|
|
2313
2093
|
stateEntities[selectId(item)] = item;
|
|
2314
|
-
if (!wasPreviouslyEmpty)
|
|
2315
|
-
insert(sortedEntities, item, comparer);
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
if (wasPreviouslyEmpty) {
|
|
2319
|
-
sortedEntities = addedItems.slice().sort(comparer);
|
|
2320
|
-
} else if (appliedUpdates) {
|
|
2321
|
-
sortedEntities.sort(comparer);
|
|
2094
|
+
if (!wasPreviouslyEmpty) insert(sortedEntities, item, comparer);
|
|
2322
2095
|
}
|
|
2096
|
+
if (wasPreviouslyEmpty) sortedEntities = addedItems.slice().sort(comparer);
|
|
2097
|
+
else if (appliedUpdates) sortedEntities.sort(comparer);
|
|
2323
2098
|
const newSortedIds = sortedEntities.map(selectId);
|
|
2324
|
-
if (!areArraysEqual(currentIds, newSortedIds))
|
|
2325
|
-
|
|
2326
|
-
}
|
|
2327
|
-
};
|
|
2099
|
+
if (!areArraysEqual(currentIds, newSortedIds)) state.ids = newSortedIds;
|
|
2100
|
+
}
|
|
2328
2101
|
return {
|
|
2329
2102
|
removeOne,
|
|
2330
2103
|
removeMany,
|
|
@@ -2341,10 +2114,7 @@ function createSortedStateAdapter(selectId, comparer) {
|
|
|
2341
2114
|
};
|
|
2342
2115
|
}
|
|
2343
2116
|
function createEntityAdapter(options = {}) {
|
|
2344
|
-
const {
|
|
2345
|
-
selectId,
|
|
2346
|
-
sortComparer
|
|
2347
|
-
} = {
|
|
2117
|
+
const { selectId, sortComparer } = {
|
|
2348
2118
|
sortComparer: false,
|
|
2349
2119
|
selectId: (instance) => instance.id,
|
|
2350
2120
|
...options
|
|
@@ -2367,112 +2137,16 @@ var taskCancelled = `task-${cancelled}`;
|
|
|
2367
2137
|
var taskCompleted = `task-${completed}`;
|
|
2368
2138
|
var listenerCancelled = `${listener}-${cancelled}`;
|
|
2369
2139
|
var listenerCompleted = `${listener}-${completed}`;
|
|
2370
|
-
var {
|
|
2371
|
-
assign
|
|
2372
|
-
} = Object;
|
|
2140
|
+
var { assign } = Object;
|
|
2373
2141
|
var alm = "listenerMiddleware";
|
|
2374
|
-
var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), {
|
|
2375
|
-
withTypes: () => addListener
|
|
2376
|
-
});
|
|
2142
|
+
var addListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/add`), { withTypes: () => addListener });
|
|
2377
2143
|
var clearAllListeners = /* @__PURE__ */ createAction(`${alm}/removeAll`);
|
|
2378
|
-
var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), {
|
|
2379
|
-
|
|
2380
|
-
});
|
|
2144
|
+
var removeListener = /* @__PURE__ */ assign(/* @__PURE__ */ createAction(`${alm}/remove`), { withTypes: () => removeListener });
|
|
2145
|
+
var ORIGINAL_STATE = Symbol.for("rtk-state-proxy-original");
|
|
2381
2146
|
function formatProdErrorMessage(code) {
|
|
2382
2147
|
return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
|
2383
2148
|
}
|
|
2384
2149
|
|
|
2385
|
-
// packages/app/stateViews/runtime.ts
|
|
2386
|
-
var selectCurrentToken = (state) => {
|
|
2387
|
-
const token = selectIdentityToken(state);
|
|
2388
|
-
return typeof token === "string" ? token : void 0;
|
|
2389
|
-
};
|
|
2390
|
-
var selectCurrentUserId = (state) => {
|
|
2391
|
-
const userId = selectIdentityUserId(state);
|
|
2392
|
-
return typeof userId === "string" ? userId : void 0;
|
|
2393
|
-
};
|
|
2394
|
-
var EMPTY_SYNC_SERVERS = [];
|
|
2395
|
-
var selectRuntimeRemoteServer = (state) => {
|
|
2396
|
-
const configuredServer = normalizeKnownServerOrigin(state.settings?.currentServer) ?? void 0;
|
|
2397
|
-
if (!getIsDesktopApp()) return configuredServer || SERVERS.MAIN;
|
|
2398
|
-
return isLocalServerUrl(configuredServer) ? SERVERS.MAIN : configuredServer || SERVERS.MAIN;
|
|
2399
|
-
};
|
|
2400
|
-
var selectConfiguredSyncServers = (state) => state.settings?.syncServers;
|
|
2401
|
-
var selectRuntimeRemoteSyncServers = createSelector(
|
|
2402
|
-
[selectConfiguredSyncServers],
|
|
2403
|
-
(syncServers) => {
|
|
2404
|
-
if (!Array.isArray(syncServers) || syncServers.length === 0) {
|
|
2405
|
-
return EMPTY_SYNC_SERVERS;
|
|
2406
|
-
}
|
|
2407
|
-
const normalized = syncServers.map(normalizeKnownServerOrigin).filter((server) => !!server);
|
|
2408
|
-
if (!getIsDesktopApp()) return normalized;
|
|
2409
|
-
return normalized.filter((server) => !isLocalServerUrl(server));
|
|
2410
|
-
}
|
|
2411
|
-
);
|
|
2412
|
-
var selectLocalRuntimeOrigin = () => {
|
|
2413
|
-
if (typeof window !== "undefined" && typeof window.location?.origin === "string" && /^https?:\/\//.test(window.location.origin)) {
|
|
2414
|
-
return window.location.origin.replace(/\/+$/, "");
|
|
2415
|
-
}
|
|
2416
|
-
return void 0;
|
|
2417
|
-
};
|
|
2418
|
-
var selectRuntimeSnapshot = createSelector(
|
|
2419
|
-
[
|
|
2420
|
-
selectCurrentToken,
|
|
2421
|
-
selectCurrentUserId,
|
|
2422
|
-
selectRuntimeRemoteServer,
|
|
2423
|
-
selectRuntimeRemoteSyncServers,
|
|
2424
|
-
selectLocalRuntimeOrigin
|
|
2425
|
-
],
|
|
2426
|
-
(currentToken, currentUserId, currentServer, syncServers, localRuntimeOrigin) => ({
|
|
2427
|
-
currentToken,
|
|
2428
|
-
currentUserId,
|
|
2429
|
-
currentServer,
|
|
2430
|
-
syncServers,
|
|
2431
|
-
localRuntimeOrigin
|
|
2432
|
-
})
|
|
2433
|
-
);
|
|
2434
|
-
var selectRuntimeCurrentServer = createSelector(
|
|
2435
|
-
[selectRuntimeSnapshot],
|
|
2436
|
-
(runtime) => runtime.currentServer
|
|
2437
|
-
);
|
|
2438
|
-
var selectRuntimeRemoteServers = createSelector(
|
|
2439
|
-
[selectRuntimeSnapshot],
|
|
2440
|
-
(runtime) => getAllServers(runtime.currentServer, runtime.syncServers)
|
|
2441
|
-
);
|
|
2442
|
-
|
|
2443
|
-
// packages/database/runtimeServerContext.ts
|
|
2444
|
-
var getRuntimeServerContext = (state, preferredServerOrigin) => {
|
|
2445
|
-
const {
|
|
2446
|
-
currentToken,
|
|
2447
|
-
currentUserId,
|
|
2448
|
-
currentServer,
|
|
2449
|
-
syncServers = []
|
|
2450
|
-
} = selectRuntimeSnapshot(state);
|
|
2451
|
-
return {
|
|
2452
|
-
currentToken,
|
|
2453
|
-
currentUserId,
|
|
2454
|
-
currentServer,
|
|
2455
|
-
syncServers,
|
|
2456
|
-
userAuthorityRegistry: resolveRuntimeUserAuthorityRegistry(state),
|
|
2457
|
-
remoteServers: getAllServers(
|
|
2458
|
-
currentServer,
|
|
2459
|
-
syncServers,
|
|
2460
|
-
preferredServerOrigin
|
|
2461
|
-
)
|
|
2462
|
-
};
|
|
2463
|
-
};
|
|
2464
|
-
var resolveRuntimeUserAuthorityRegistry = (state) => {
|
|
2465
|
-
const settingsRegistry = state.settings?.userAuthorityRegistry;
|
|
2466
|
-
if (settingsRegistry && typeof settingsRegistry === "object") {
|
|
2467
|
-
return settingsRegistry;
|
|
2468
|
-
}
|
|
2469
|
-
const userRegistry = selectIdentityUser(state)?.authorityRegistry;
|
|
2470
|
-
if (userRegistry && typeof userRegistry === "object") {
|
|
2471
|
-
return userRegistry;
|
|
2472
|
-
}
|
|
2473
|
-
return void 0;
|
|
2474
|
-
};
|
|
2475
|
-
|
|
2476
2150
|
// packages/database/requests.ts
|
|
2477
2151
|
var TIMEOUT = 5e3;
|
|
2478
2152
|
var logRequestFailure = (level, message) => {
|
|
@@ -2679,606 +2353,6 @@ var noloDeleteRequest = async (server, dbKey, options, state, signal) => {
|
|
|
2679
2353
|
}
|
|
2680
2354
|
};
|
|
2681
2355
|
|
|
2682
|
-
// packages/database/authority/ownerKey.ts
|
|
2683
|
-
var USER_OWNED_SECOND_SEGMENT_PREFIXES = /* @__PURE__ */ new Set([
|
|
2684
|
-
"agent",
|
|
2685
|
-
"dialog",
|
|
2686
|
-
"page",
|
|
2687
|
-
"doc",
|
|
2688
|
-
"notification",
|
|
2689
|
-
"email",
|
|
2690
|
-
"meta",
|
|
2691
|
-
"row",
|
|
2692
|
-
"view",
|
|
2693
|
-
"file",
|
|
2694
|
-
"job"
|
|
2695
|
-
]);
|
|
2696
|
-
var PUBLIC_OWNER_SENTINELS = /* @__PURE__ */ new Set(["pub", "id", "stats", "index"]);
|
|
2697
|
-
var cleanSegment = (value) => {
|
|
2698
|
-
const trimmed = asTrimmedString(value);
|
|
2699
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
2700
|
-
};
|
|
2701
|
-
var normalizeCandidateOwners = (candidateOwnerUserIds) => {
|
|
2702
|
-
const out = [];
|
|
2703
|
-
for (const candidate of candidateOwnerUserIds ?? []) {
|
|
2704
|
-
const normalized = cleanSegment(candidate ?? void 0);
|
|
2705
|
-
if (!normalized || PUBLIC_OWNER_SENTINELS.has(normalized)) continue;
|
|
2706
|
-
if (!out.includes(normalized)) out.push(normalized);
|
|
2707
|
-
}
|
|
2708
|
-
return out.sort((left, right) => right.length - left.length);
|
|
2709
|
-
};
|
|
2710
|
-
var resolveCandidateOwnerFromKeyRemainder = (remainder, candidateOwnerUserIds) => {
|
|
2711
|
-
const normalizedRemainder = cleanSegment(remainder);
|
|
2712
|
-
if (!normalizedRemainder) return null;
|
|
2713
|
-
for (const candidate of normalizeCandidateOwners(candidateOwnerUserIds)) {
|
|
2714
|
-
if (normalizedRemainder === candidate || normalizedRemainder.startsWith(`${candidate}-`)) {
|
|
2715
|
-
return candidate;
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
return null;
|
|
2719
|
-
};
|
|
2720
|
-
var parseOwnerUserIdFromDbKey = (dbKey, options = {}) => {
|
|
2721
|
-
const normalized = cleanSegment(dbKey);
|
|
2722
|
-
if (!normalized) return null;
|
|
2723
|
-
const parts = normalized.split("-");
|
|
2724
|
-
const [prefix] = parts;
|
|
2725
|
-
if (!prefix) return null;
|
|
2726
|
-
if (!USER_OWNED_SECOND_SEGMENT_PREFIXES.has(prefix)) {
|
|
2727
|
-
if (prefix === "grant" && parts[1] === "agent" && parts.length >= 5) {
|
|
2728
|
-
const ownerAndRest2 = normalized.slice(prefix.length + 1 + parts[1].length + 1);
|
|
2729
|
-
const [owner2] = ownerAndRest2.split("-");
|
|
2730
|
-
return cleanSegment(owner2);
|
|
2731
|
-
}
|
|
2732
|
-
return null;
|
|
2733
|
-
}
|
|
2734
|
-
if (parts[0] === "dialog" && parts[2] === "msg") {
|
|
2735
|
-
return null;
|
|
2736
|
-
}
|
|
2737
|
-
const ownerAndRest = normalized.slice(prefix.length + 1);
|
|
2738
|
-
const candidateOwner = resolveCandidateOwnerFromKeyRemainder(
|
|
2739
|
-
ownerAndRest,
|
|
2740
|
-
options.candidateOwnerUserIds
|
|
2741
|
-
);
|
|
2742
|
-
if (candidateOwner) return candidateOwner;
|
|
2743
|
-
const [owner] = ownerAndRest.split("-");
|
|
2744
|
-
const ownerUserId = cleanSegment(owner);
|
|
2745
|
-
if (!ownerUserId) return null;
|
|
2746
|
-
if (PUBLIC_OWNER_SENTINELS.has(ownerUserId)) return null;
|
|
2747
|
-
return ownerUserId;
|
|
2748
|
-
};
|
|
2749
|
-
|
|
2750
|
-
// packages/database/authority/userAuthorityRegistry.ts
|
|
2751
|
-
var normalizeAuthorityServerOrigin = (value) => {
|
|
2752
|
-
const normalized = normalizeServerOrigin(value);
|
|
2753
|
-
return /^https?:\/\//i.test(normalized) ? normalized : null;
|
|
2754
|
-
};
|
|
2755
|
-
var normalizeUserId = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2756
|
-
var readEntryAuthorityServer = (entry) => {
|
|
2757
|
-
if (typeof entry === "string") {
|
|
2758
|
-
return normalizeAuthorityServerOrigin(entry);
|
|
2759
|
-
}
|
|
2760
|
-
if (!isRecord(entry)) {
|
|
2761
|
-
return null;
|
|
2762
|
-
}
|
|
2763
|
-
return normalizeAuthorityServerOrigin(entry.authorityServer) ?? normalizeAuthorityServerOrigin(entry.homeServer) ?? normalizeAuthorityServerOrigin(entry.primaryServer);
|
|
2764
|
-
};
|
|
2765
|
-
var resolveUserAuthorityServer = ({
|
|
2766
|
-
ownerUserId,
|
|
2767
|
-
registry
|
|
2768
|
-
}) => {
|
|
2769
|
-
const normalizedOwner = normalizeUserId(ownerUserId);
|
|
2770
|
-
if (!normalizedOwner || !registry || typeof registry !== "object") {
|
|
2771
|
-
return null;
|
|
2772
|
-
}
|
|
2773
|
-
return readEntryAuthorityServer(registry[normalizedOwner]);
|
|
2774
|
-
};
|
|
2775
|
-
|
|
2776
|
-
// packages/database/authority/recordAuthority.ts
|
|
2777
|
-
var normalizeUserId2 = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2778
|
-
var getRegistryOwnerCandidates = (registry) => isRecord(registry) ? Object.keys(registry) : [];
|
|
2779
|
-
var resolveRecordAuthority = ({
|
|
2780
|
-
dbKey,
|
|
2781
|
-
record,
|
|
2782
|
-
currentUserId,
|
|
2783
|
-
currentServer,
|
|
2784
|
-
userAuthorityRegistry
|
|
2785
|
-
}) => {
|
|
2786
|
-
const ownerUserId = parseOwnerUserIdFromDbKey(dbKey, {
|
|
2787
|
-
candidateOwnerUserIds: [
|
|
2788
|
-
normalizeUserId2(record?.userId),
|
|
2789
|
-
normalizeUserId2(currentUserId),
|
|
2790
|
-
...getRegistryOwnerCandidates(userAuthorityRegistry)
|
|
2791
|
-
]
|
|
2792
|
-
}) ?? normalizeUserId2(record?.userId);
|
|
2793
|
-
const serverOrigin = normalizeAuthorityServerOrigin(record?.serverOrigin);
|
|
2794
|
-
const explicitAuthority = normalizeAuthorityServerOrigin(record?.authorityServer);
|
|
2795
|
-
const registryAuthority = resolveUserAuthorityServer({
|
|
2796
|
-
ownerUserId,
|
|
2797
|
-
registry: userAuthorityRegistry
|
|
2798
|
-
});
|
|
2799
|
-
const currentUserAuthority = ownerUserId && ownerUserId === normalizeUserId2(currentUserId) ? normalizeAuthorityServerOrigin(currentServer) : null;
|
|
2800
|
-
return {
|
|
2801
|
-
ownerUserId,
|
|
2802
|
-
authorityServer: explicitAuthority ?? registryAuthority ?? currentUserAuthority ?? serverOrigin,
|
|
2803
|
-
serverOrigin
|
|
2804
|
-
};
|
|
2805
|
-
};
|
|
2806
|
-
|
|
2807
|
-
// packages/database/actions/readResolution.ts
|
|
2808
|
-
var toComparableTimestamp = (data) => {
|
|
2809
|
-
if (!data || typeof data !== "object") return 0;
|
|
2810
|
-
const updatedAtMs = asOptionalPositiveFiniteNumber(
|
|
2811
|
-
new Date(data.updatedAt).getTime()
|
|
2812
|
-
);
|
|
2813
|
-
if (updatedAtMs !== void 0) return updatedAtMs;
|
|
2814
|
-
const createdAtMs = asOptionalPositiveFiniteNumber(
|
|
2815
|
-
new Date(data.createdAt).getTime()
|
|
2816
|
-
);
|
|
2817
|
-
if (createdAtMs !== void 0) return createdAtMs;
|
|
2818
|
-
return asOptionalPositiveFiniteNumber(Number(data?.meta?.createdAt)) ?? 0;
|
|
2819
|
-
};
|
|
2820
|
-
var partitionReadServers = ({
|
|
2821
|
-
allServers,
|
|
2822
|
-
preferredServerOrigin
|
|
2823
|
-
}) => {
|
|
2824
|
-
const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
|
|
2825
|
-
const fallbackServers = preferredServer ? allServers.filter(
|
|
2826
|
-
(server) => normalizeServerOrigin(server) !== preferredServer
|
|
2827
|
-
) : allServers;
|
|
2828
|
-
return {
|
|
2829
|
-
preferredServer,
|
|
2830
|
-
fallbackServers,
|
|
2831
|
-
orderedServersForLocalHit: preferredServer ? [preferredServer, ...fallbackServers] : fallbackServers
|
|
2832
|
-
};
|
|
2833
|
-
};
|
|
2834
|
-
var compareRemoteRecordsByComparableTime = (left, right) => toComparableTimestamp(left) - toComparableTimestamp(right);
|
|
2835
|
-
var pickBestSettledRemoteRecord = ({
|
|
2836
|
-
settledResults,
|
|
2837
|
-
isBetterCandidate
|
|
2838
|
-
}) => {
|
|
2839
|
-
const validResults = settledResults.map((result, index) => ({
|
|
2840
|
-
data: result.status === "fulfilled" ? result.value : null,
|
|
2841
|
-
index
|
|
2842
|
-
})).filter((item) => item.data !== null && typeof item.data === "object");
|
|
2843
|
-
if (validResults.length === 0) return null;
|
|
2844
|
-
const latest2 = validResults.reduce(
|
|
2845
|
-
(best, current2) => isBetterCandidate(current2.data, best.data) ? current2 : best
|
|
2846
|
-
);
|
|
2847
|
-
return { index: latest2.index, data: latest2.data };
|
|
2848
|
-
};
|
|
2849
|
-
var shouldReplaceLocalWithRemoteRecord = ({
|
|
2850
|
-
localData,
|
|
2851
|
-
remoteData,
|
|
2852
|
-
isRemoteNewer
|
|
2853
|
-
}) => {
|
|
2854
|
-
if (!remoteData || typeof remoteData !== "object") return false;
|
|
2855
|
-
if (!localData || typeof localData !== "object") return true;
|
|
2856
|
-
return isRemoteNewer(remoteData, localData);
|
|
2857
|
-
};
|
|
2858
|
-
var shouldReplicateLocalRecord = ({
|
|
2859
|
-
localData,
|
|
2860
|
-
remoteData,
|
|
2861
|
-
remoteTargetCount
|
|
2862
|
-
}) => !!localData && !remoteData && remoteTargetCount > 0;
|
|
2863
|
-
var compactUniqueServers = (servers) => {
|
|
2864
|
-
const out = [];
|
|
2865
|
-
for (const server of servers) {
|
|
2866
|
-
if (typeof server !== "string" || server.trim().length === 0) continue;
|
|
2867
|
-
const normalized = normalizeServerOrigin(server);
|
|
2868
|
-
if (!out.includes(normalized)) out.push(normalized);
|
|
2869
|
-
}
|
|
2870
|
-
return out;
|
|
2871
|
-
};
|
|
2872
|
-
var planAuthorityReadServers = ({
|
|
2873
|
-
allServers,
|
|
2874
|
-
authorityServer,
|
|
2875
|
-
serverOrigin
|
|
2876
|
-
}) => compactUniqueServers([authorityServer, serverOrigin, ...allServers]);
|
|
2877
|
-
|
|
2878
|
-
// packages/core/fnv1a32.ts
|
|
2879
|
-
var fnv1a32 = (str) => {
|
|
2880
|
-
let hash = 2166136261;
|
|
2881
|
-
for (let i = 0; i < str.length; i++) {
|
|
2882
|
-
hash ^= str.charCodeAt(i);
|
|
2883
|
-
hash = hash * 16777619 >>> 0;
|
|
2884
|
-
}
|
|
2885
|
-
return hash >>> 0;
|
|
2886
|
-
};
|
|
2887
|
-
var fnv1a32Hex = (str) => fnv1a32(str).toString(16).padStart(8, "0");
|
|
2888
|
-
|
|
2889
|
-
// packages/database/fileRing.ts
|
|
2890
|
-
var chooseServersByKey = (allServers, key, replicaCount) => {
|
|
2891
|
-
if (!allServers.length || replicaCount <= 0) return [];
|
|
2892
|
-
const uniqueServers = Array.from(new Set(allServers)).filter((s) => !!s);
|
|
2893
|
-
if (uniqueServers.length === 0) return [];
|
|
2894
|
-
const scored = uniqueServers.map((server) => ({
|
|
2895
|
-
server,
|
|
2896
|
-
score: fnv1a32(`${server}::${key}`)
|
|
2897
|
-
}));
|
|
2898
|
-
scored.sort((a, b) => a.score - b.score);
|
|
2899
|
-
const limit = Math.min(replicaCount, scored.length);
|
|
2900
|
-
return scored.slice(0, limit).map((item) => item.server);
|
|
2901
|
-
};
|
|
2902
|
-
|
|
2903
|
-
// packages/database/tenantPlacement.ts
|
|
2904
|
-
var TENANT_REPLICA_COUNT = 2;
|
|
2905
|
-
var planServersForTenant = (allServers, currentServer, tenantId) => {
|
|
2906
|
-
const uniqueServers = Array.from(new Set(allServers)).filter(Boolean);
|
|
2907
|
-
if (!uniqueServers.length) return [];
|
|
2908
|
-
const key = asOptionalTrimmedString(tenantId) ?? "default-tenant";
|
|
2909
|
-
const fromRing = chooseServersByKey(
|
|
2910
|
-
uniqueServers,
|
|
2911
|
-
key,
|
|
2912
|
-
TENANT_REPLICA_COUNT
|
|
2913
|
-
);
|
|
2914
|
-
const set2 = new Set(fromRing);
|
|
2915
|
-
if (currentServer && uniqueServers.includes(currentServer)) {
|
|
2916
|
-
set2.add(currentServer);
|
|
2917
|
-
}
|
|
2918
|
-
return Array.from(set2);
|
|
2919
|
-
};
|
|
2920
|
-
|
|
2921
|
-
// packages/database/authority/deviceLocal.ts
|
|
2922
|
-
var DEVICE_LOCAL_OWNER_ID = "local";
|
|
2923
|
-
var DEVICE_LOCAL_DB_KEY_PREFIXES = [
|
|
2924
|
-
"dialog-local-",
|
|
2925
|
-
"agent-local-"
|
|
2926
|
-
];
|
|
2927
|
-
var clean = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2928
|
-
var isDeviceLocalOwnerId = (userId) => clean(userId) === DEVICE_LOCAL_OWNER_ID;
|
|
2929
|
-
var resolveEffectiveSpaceActorId = (accountUserId) => {
|
|
2930
|
-
const cleaned = clean(accountUserId);
|
|
2931
|
-
if (!cleaned || isDeviceLocalOwnerId(cleaned)) {
|
|
2932
|
-
return DEVICE_LOCAL_OWNER_ID;
|
|
2933
|
-
}
|
|
2934
|
-
return cleaned;
|
|
2935
|
-
};
|
|
2936
|
-
var isDeviceLocalSpaceMembership = (membership) => isDeviceLocalOwnerId(membership?.userId);
|
|
2937
|
-
var isDeviceLocalSpaceBody = (space) => isDeviceLocalOwnerId(space?.userId) || isDeviceLocalOwnerId(space?.ownerId);
|
|
2938
|
-
var isDeviceLocalDbKey = (dbKey) => {
|
|
2939
|
-
const key = clean(dbKey);
|
|
2940
|
-
if (!key) return false;
|
|
2941
|
-
for (const prefix of DEVICE_LOCAL_DB_KEY_PREFIXES) {
|
|
2942
|
-
if (key.startsWith(prefix)) return true;
|
|
2943
|
-
}
|
|
2944
|
-
return parseOwnerUserIdFromDbKey(key, {
|
|
2945
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2946
|
-
}) === DEVICE_LOCAL_OWNER_ID;
|
|
2947
|
-
};
|
|
2948
|
-
var resolveRecordOwnerUserId = (record) => {
|
|
2949
|
-
if (!record) return null;
|
|
2950
|
-
const explicit = clean(record.userId);
|
|
2951
|
-
if (explicit) return explicit;
|
|
2952
|
-
if (isDeviceLocalDbKey(record.dbKey) || isDeviceLocalDbKey(record.id)) {
|
|
2953
|
-
return DEVICE_LOCAL_OWNER_ID;
|
|
2954
|
-
}
|
|
2955
|
-
const fromKey = parseOwnerUserIdFromDbKey(clean(record.dbKey) ?? "", {
|
|
2956
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2957
|
-
}) ?? parseOwnerUserIdFromDbKey(clean(record.id) ?? "", {
|
|
2958
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2959
|
-
});
|
|
2960
|
-
return fromKey;
|
|
2961
|
-
};
|
|
2962
|
-
|
|
2963
|
-
// packages/database/actions/replication.ts
|
|
2964
|
-
var isReadonlyPublicRecordKey = (dbKey) => dbKey.startsWith("agent-pub-");
|
|
2965
|
-
var normalizeCurrentUserId = (state) => {
|
|
2966
|
-
const userId = selectIdentityUserId(state);
|
|
2967
|
-
return asOptionalTrimmedString(userId) ?? null;
|
|
2968
|
-
};
|
|
2969
|
-
var resolveReplicationServers = (currentServer, syncServers, preferredServerOrigin) => getAllServers(currentServer, syncServers, preferredServerOrigin);
|
|
2970
|
-
var resolveAuthorityReplicationServers = ({
|
|
2971
|
-
currentServer,
|
|
2972
|
-
syncServers,
|
|
2973
|
-
preferredServerOrigin,
|
|
2974
|
-
dbKey,
|
|
2975
|
-
record,
|
|
2976
|
-
state
|
|
2977
|
-
}) => {
|
|
2978
|
-
const allServers = resolveReplicationServers(
|
|
2979
|
-
currentServer,
|
|
2980
|
-
syncServers,
|
|
2981
|
-
preferredServerOrigin
|
|
2982
|
-
);
|
|
2983
|
-
const authority = resolveRecordAuthority({
|
|
2984
|
-
dbKey,
|
|
2985
|
-
record,
|
|
2986
|
-
currentUserId: selectIdentityUserId(state),
|
|
2987
|
-
currentServer,
|
|
2988
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
2989
|
-
});
|
|
2990
|
-
if (isDeviceLocalOwnerId(authority.ownerUserId) || isDeviceLocalOwnerId(record?.userId) || isDeviceLocalDbKey(dbKey)) {
|
|
2991
|
-
return [];
|
|
2992
|
-
}
|
|
2993
|
-
return planAuthorityReadServers({
|
|
2994
|
-
allServers,
|
|
2995
|
-
authorityServer: preferredServerOrigin ?? authority.authorityServer,
|
|
2996
|
-
serverOrigin: authority.serverOrigin
|
|
2997
|
-
});
|
|
2998
|
-
};
|
|
2999
|
-
var scheduleWriteReplication = (servers, request, state) => {
|
|
3000
|
-
if (servers.length === 0) return;
|
|
3001
|
-
Promise.resolve().then(async () => {
|
|
3002
|
-
const [primaryServer, ...backupServers] = servers;
|
|
3003
|
-
const primarySucceeded = await noloWriteRequest(primaryServer, request, state);
|
|
3004
|
-
if (!primarySucceeded) {
|
|
3005
|
-
console.warn(`Primary write sync failed for ${request.customKey} on ${primaryServer}`);
|
|
3006
|
-
}
|
|
3007
|
-
if (backupServers.length === 0) {
|
|
3008
|
-
return;
|
|
3009
|
-
}
|
|
3010
|
-
syncWithServers(
|
|
3011
|
-
backupServers,
|
|
3012
|
-
(server, requestConfig, requestState, signal) => noloWriteRequest(server, requestConfig, requestState, signal, {
|
|
3013
|
-
failureLogLevel: "info"
|
|
3014
|
-
}),
|
|
3015
|
-
`Backup write sync failed for ${request.customKey} on`,
|
|
3016
|
-
request,
|
|
3017
|
-
state
|
|
3018
|
-
);
|
|
3019
|
-
});
|
|
3020
|
-
};
|
|
3021
|
-
var resolveTenantReplicationServers = ({
|
|
3022
|
-
currentServer,
|
|
3023
|
-
syncServers,
|
|
3024
|
-
tenantId
|
|
3025
|
-
}) => {
|
|
3026
|
-
const allServers = resolveReplicationServers(currentServer, syncServers);
|
|
3027
|
-
if (allServers.length === 0) {
|
|
3028
|
-
return [];
|
|
3029
|
-
}
|
|
3030
|
-
return planServersForTenant(allServers, currentServer, tenantId);
|
|
3031
|
-
};
|
|
3032
|
-
var resolveUploadReplicationServers = ({
|
|
3033
|
-
currentServer,
|
|
3034
|
-
syncServers,
|
|
3035
|
-
tenantId,
|
|
3036
|
-
uploadConfig,
|
|
3037
|
-
state
|
|
3038
|
-
}) => {
|
|
3039
|
-
const allServers = resolveReplicationServers(currentServer, syncServers);
|
|
3040
|
-
const authority = resolveRecordAuthority({
|
|
3041
|
-
dbKey: uploadConfig.customKey,
|
|
3042
|
-
record: uploadConfig.metadata,
|
|
3043
|
-
currentUserId: selectIdentityUserId(state),
|
|
3044
|
-
currentServer,
|
|
3045
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
3046
|
-
});
|
|
3047
|
-
if (authority.ownerUserId || authority.authorityServer) {
|
|
3048
|
-
return planAuthorityReadServers({
|
|
3049
|
-
allServers,
|
|
3050
|
-
authorityServer: authority.authorityServer,
|
|
3051
|
-
serverOrigin: authority.serverOrigin
|
|
3052
|
-
});
|
|
3053
|
-
}
|
|
3054
|
-
return resolveTenantReplicationServers({
|
|
3055
|
-
currentServer,
|
|
3056
|
-
syncServers,
|
|
3057
|
-
tenantId
|
|
3058
|
-
});
|
|
3059
|
-
};
|
|
3060
|
-
var scheduleExistingRecordReplication = ({
|
|
3061
|
-
currentServer,
|
|
3062
|
-
syncServers,
|
|
3063
|
-
preferredServerOrigin,
|
|
3064
|
-
dbKey,
|
|
3065
|
-
localData,
|
|
3066
|
-
state
|
|
3067
|
-
}) => {
|
|
3068
|
-
if (isReadonlyPublicRecordKey(dbKey)) {
|
|
3069
|
-
return [];
|
|
3070
|
-
}
|
|
3071
|
-
const currentUserId = normalizeCurrentUserId(state);
|
|
3072
|
-
const authority = resolveRecordAuthority({
|
|
3073
|
-
dbKey,
|
|
3074
|
-
record: localData,
|
|
3075
|
-
currentUserId,
|
|
3076
|
-
currentServer,
|
|
3077
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
3078
|
-
});
|
|
3079
|
-
if (authority.ownerUserId && currentUserId && authority.ownerUserId !== currentUserId) {
|
|
3080
|
-
return [];
|
|
3081
|
-
}
|
|
3082
|
-
const servers = resolveAuthorityReplicationServers({
|
|
3083
|
-
currentServer,
|
|
3084
|
-
syncServers,
|
|
3085
|
-
preferredServerOrigin,
|
|
3086
|
-
dbKey,
|
|
3087
|
-
record: localData,
|
|
3088
|
-
state
|
|
3089
|
-
});
|
|
3090
|
-
if (servers.length === 0) {
|
|
3091
|
-
return [];
|
|
3092
|
-
}
|
|
3093
|
-
scheduleWriteReplication(
|
|
3094
|
-
servers,
|
|
3095
|
-
{
|
|
3096
|
-
data: localData,
|
|
3097
|
-
customKey: dbKey,
|
|
3098
|
-
userId: typeof localData?.userId === "string" ? localData.userId : selectIdentityUserId(state)
|
|
3099
|
-
},
|
|
3100
|
-
state
|
|
3101
|
-
);
|
|
3102
|
-
return servers;
|
|
3103
|
-
};
|
|
3104
|
-
var schedulePatchReplication = ({
|
|
3105
|
-
servers,
|
|
3106
|
-
dbKey,
|
|
3107
|
-
changes,
|
|
3108
|
-
state,
|
|
3109
|
-
preferredServerOrigin
|
|
3110
|
-
}) => {
|
|
3111
|
-
if (servers.length === 0) return;
|
|
3112
|
-
Promise.resolve().then(async () => {
|
|
3113
|
-
const primaryServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : servers[0];
|
|
3114
|
-
const backupServers = servers.filter(
|
|
3115
|
-
(server) => normalizeServerOrigin(server) !== primaryServer
|
|
3116
|
-
);
|
|
3117
|
-
const primarySucceeded = await noloPatchRequest(primaryServer, dbKey, changes, state, void 0, {
|
|
3118
|
-
failureLogLevel: "warn"
|
|
3119
|
-
});
|
|
3120
|
-
if (!primarySucceeded) {
|
|
3121
|
-
console.warn(`Primary patch sync failed for ${dbKey} on ${primaryServer}`);
|
|
3122
|
-
}
|
|
3123
|
-
if (backupServers.length > 0) {
|
|
3124
|
-
syncWithServers(
|
|
3125
|
-
backupServers,
|
|
3126
|
-
(server, targetDbKey, nextChanges, requestState, signal) => noloPatchRequest(server, targetDbKey, nextChanges, requestState, signal, {
|
|
3127
|
-
failureLogLevel: "info"
|
|
3128
|
-
}),
|
|
3129
|
-
`Backup patch sync failed for ${dbKey} on`,
|
|
3130
|
-
dbKey,
|
|
3131
|
-
changes,
|
|
3132
|
-
state
|
|
3133
|
-
);
|
|
3134
|
-
}
|
|
3135
|
-
});
|
|
3136
|
-
};
|
|
3137
|
-
var scheduleConfiguredPatchReplication = ({
|
|
3138
|
-
currentServer,
|
|
3139
|
-
syncServers,
|
|
3140
|
-
preferredServerOrigin,
|
|
3141
|
-
dbKey,
|
|
3142
|
-
changes,
|
|
3143
|
-
state
|
|
3144
|
-
}) => {
|
|
3145
|
-
const servers = resolveAuthorityReplicationServers({
|
|
3146
|
-
currentServer,
|
|
3147
|
-
syncServers,
|
|
3148
|
-
preferredServerOrigin,
|
|
3149
|
-
dbKey,
|
|
3150
|
-
record: changes,
|
|
3151
|
-
state
|
|
3152
|
-
});
|
|
3153
|
-
if (servers.length === 0) {
|
|
3154
|
-
return [];
|
|
3155
|
-
}
|
|
3156
|
-
schedulePatchReplication({
|
|
3157
|
-
servers,
|
|
3158
|
-
dbKey,
|
|
3159
|
-
changes,
|
|
3160
|
-
state,
|
|
3161
|
-
preferredServerOrigin
|
|
3162
|
-
});
|
|
3163
|
-
return servers;
|
|
3164
|
-
};
|
|
3165
|
-
var scheduleUploadReplication = ({
|
|
3166
|
-
currentServer,
|
|
3167
|
-
syncServers,
|
|
3168
|
-
tenantId,
|
|
3169
|
-
uploadConfig,
|
|
3170
|
-
state,
|
|
3171
|
-
excludeServers = []
|
|
3172
|
-
}) => {
|
|
3173
|
-
const servers = resolveUploadReplicationServers({
|
|
3174
|
-
currentServer,
|
|
3175
|
-
syncServers,
|
|
3176
|
-
tenantId,
|
|
3177
|
-
uploadConfig,
|
|
3178
|
-
state
|
|
3179
|
-
});
|
|
3180
|
-
const excluded = new Set(
|
|
3181
|
-
excludeServers.filter((server) => typeof server === "string").map((server) => normalizeServerOrigin(server))
|
|
3182
|
-
);
|
|
3183
|
-
const remainingServers = servers.filter(
|
|
3184
|
-
(server) => !excluded.has(normalizeServerOrigin(server))
|
|
3185
|
-
);
|
|
3186
|
-
if (remainingServers.length === 0) {
|
|
3187
|
-
return [];
|
|
3188
|
-
}
|
|
3189
|
-
Promise.resolve().then(() => {
|
|
3190
|
-
syncWithServers(
|
|
3191
|
-
remainingServers,
|
|
3192
|
-
noloUploadRequest,
|
|
3193
|
-
`Upload sync failed for ${uploadConfig.customKey} on`,
|
|
3194
|
-
uploadConfig,
|
|
3195
|
-
state
|
|
3196
|
-
);
|
|
3197
|
-
});
|
|
3198
|
-
return remainingServers;
|
|
3199
|
-
};
|
|
3200
|
-
var uploadToCurrentServer = async ({
|
|
3201
|
-
currentServer,
|
|
3202
|
-
uploadConfig,
|
|
3203
|
-
state
|
|
3204
|
-
}) => {
|
|
3205
|
-
if (!currentServer) {
|
|
3206
|
-
return false;
|
|
3207
|
-
}
|
|
3208
|
-
return noloUploadRequest(currentServer, uploadConfig, state);
|
|
3209
|
-
};
|
|
3210
|
-
var deleteFromReplicationServers = async ({
|
|
3211
|
-
servers,
|
|
3212
|
-
dbKey,
|
|
3213
|
-
deleteOptions = { type: "single" },
|
|
3214
|
-
state,
|
|
3215
|
-
preferredServerOrigin
|
|
3216
|
-
}) => {
|
|
3217
|
-
if (!servers.length) {
|
|
3218
|
-
return { succeeded: [], failed: [] };
|
|
3219
|
-
}
|
|
3220
|
-
const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
|
|
3221
|
-
const remainingServers = preferredServer ? servers.filter((server) => normalizeServerOrigin(server) !== preferredServer) : servers;
|
|
3222
|
-
const succeeded = [];
|
|
3223
|
-
const failed = [];
|
|
3224
|
-
if (preferredServer) {
|
|
3225
|
-
const ok = await noloDeleteRequest(preferredServer, dbKey, deleteOptions, state);
|
|
3226
|
-
if (ok) {
|
|
3227
|
-
succeeded.push(preferredServer);
|
|
3228
|
-
} else {
|
|
3229
|
-
failed.push(preferredServer);
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
|
-
if (remainingServers.length > 0) {
|
|
3233
|
-
const results = await Promise.all(
|
|
3234
|
-
remainingServers.map(async (server) => ({
|
|
3235
|
-
server,
|
|
3236
|
-
ok: await noloDeleteRequest(server, dbKey, deleteOptions, state)
|
|
3237
|
-
}))
|
|
3238
|
-
);
|
|
3239
|
-
results.forEach(({ server, ok }) => {
|
|
3240
|
-
if (ok) succeeded.push(server);
|
|
3241
|
-
else failed.push(server);
|
|
3242
|
-
});
|
|
3243
|
-
}
|
|
3244
|
-
return { succeeded, failed };
|
|
3245
|
-
};
|
|
3246
|
-
var scheduleDeleteReplication = ({
|
|
3247
|
-
currentServer,
|
|
3248
|
-
syncServers,
|
|
3249
|
-
preferredServerOrigin,
|
|
3250
|
-
dbKey,
|
|
3251
|
-
deleteOptions,
|
|
3252
|
-
state,
|
|
3253
|
-
onResult,
|
|
3254
|
-
onError
|
|
3255
|
-
}) => {
|
|
3256
|
-
const servers = resolveAuthorityReplicationServers({
|
|
3257
|
-
currentServer,
|
|
3258
|
-
syncServers,
|
|
3259
|
-
preferredServerOrigin,
|
|
3260
|
-
dbKey,
|
|
3261
|
-
state
|
|
3262
|
-
});
|
|
3263
|
-
if (servers.length === 0) {
|
|
3264
|
-
return [];
|
|
3265
|
-
}
|
|
3266
|
-
void Promise.resolve().then(
|
|
3267
|
-
() => deleteFromReplicationServers({
|
|
3268
|
-
servers,
|
|
3269
|
-
dbKey,
|
|
3270
|
-
deleteOptions,
|
|
3271
|
-
state,
|
|
3272
|
-
preferredServerOrigin
|
|
3273
|
-
})
|
|
3274
|
-
).then((result) => {
|
|
3275
|
-
onResult?.(result);
|
|
3276
|
-
}).catch((error) => {
|
|
3277
|
-
onError?.(error);
|
|
3278
|
-
});
|
|
3279
|
-
return servers;
|
|
3280
|
-
};
|
|
3281
|
-
|
|
3282
2356
|
export {
|
|
3283
2357
|
createSelector,
|
|
3284
2358
|
createAction,
|
|
@@ -3286,33 +2360,9 @@ export {
|
|
|
3286
2360
|
asyncThunkCreator,
|
|
3287
2361
|
buildCreateSlice,
|
|
3288
2362
|
createEntityAdapter,
|
|
3289
|
-
|
|
3290
|
-
selectRuntimeCurrentServer,
|
|
3291
|
-
getRuntimeServerContext,
|
|
2363
|
+
noloPatchRequest,
|
|
3292
2364
|
noloWriteRequest,
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
DEVICE_LOCAL_OWNER_ID,
|
|
3297
|
-
isDeviceLocalOwnerId,
|
|
3298
|
-
resolveEffectiveSpaceActorId,
|
|
3299
|
-
isDeviceLocalSpaceMembership,
|
|
3300
|
-
isDeviceLocalSpaceBody,
|
|
3301
|
-
resolveRecordOwnerUserId,
|
|
3302
|
-
resolveRecordAuthority,
|
|
3303
|
-
partitionReadServers,
|
|
3304
|
-
compareRemoteRecordsByComparableTime,
|
|
3305
|
-
pickBestSettledRemoteRecord,
|
|
3306
|
-
shouldReplaceLocalWithRemoteRecord,
|
|
3307
|
-
shouldReplicateLocalRecord,
|
|
3308
|
-
planAuthorityReadServers,
|
|
3309
|
-
resolveReplicationServers,
|
|
3310
|
-
resolveAuthorityReplicationServers,
|
|
3311
|
-
scheduleWriteReplication,
|
|
3312
|
-
resolveUploadReplicationServers,
|
|
3313
|
-
scheduleExistingRecordReplication,
|
|
3314
|
-
scheduleConfiguredPatchReplication,
|
|
3315
|
-
scheduleUploadReplication,
|
|
3316
|
-
uploadToCurrentServer,
|
|
3317
|
-
scheduleDeleteReplication
|
|
2365
|
+
noloUploadRequest,
|
|
2366
|
+
syncWithServers,
|
|
2367
|
+
noloDeleteRequest
|
|
3318
2368
|
};
|