nolo-cli 0.97.5 → 0.97.6
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/{_executeModel-GWED52PB.js → _executeModel-E64QIKWF.js} +69 -67
- package/action-PNPQLJHG.js +20 -0
- package/{addContentAction-B2DRF7P6.js → addContentAction-DX6T34JR.js} +13 -12
- package/{addDialogAgentAction-T3I7IXPK.js → addDialogAgentAction-6SGG37BF.js} +17 -16
- package/{agentDeleteCommand-FH462XO5.js → agentDeleteCommand-76VXVM3N.js} +40 -39
- package/{agentEmailCommands-6UNG6QKI.js → agentEmailCommands-URGNKPPJ.js} +79 -77
- package/{agentListCommands-7QQZXKMN.js → agentListCommands-62NGDFOS.js} +50 -49
- package/{agentMachineCommands-DCBE3CPT.js → agentMachineCommands-SDIABR4D.js} +38 -37
- package/{agentProviderCommands-EMZCM6VA.js → agentProviderCommands-SG535ZMY.js} +1 -1
- package/{agentPullCommand-HF4A42D4.js → agentPullCommand-5DOL6RGF.js} +1 -1
- package/{agentRecordCommands-TNOVFCQ3.js → agentRecordCommands-ZICUGEEH.js} +73 -71
- package/{agentRunCommand-PAUTLE6D.js → agentRunCommand-66NCRPQ7.js} +76 -74
- package/{agentRunControl-2TTTUTSW.js → agentRunControl-3HWA2LLQ.js} +2 -2
- package/{agentRuntimeLocal-AY6YNUAL.js → agentRuntimeLocal-EZPUCRMS.js} +35 -34
- package/{agentSlice-FRLSN5HD.js → agentSlice-V2EDVUXC.js} +15 -14
- package/{appDeleteCommands-DFA4W66A.js → appDeleteCommands-7WLUFWPE.js} +35 -34
- package/{appDeployCommands-RDTG2IGP.js → appDeployCommands-NK22AMAW.js} +35 -34
- package/{appDeployStatusCommands-43XL5KEM.js → appDeployStatusCommands-PIWSMQET.js} +35 -34
- package/{appGetCommands-AKEAHGIG.js → appGetCommands-J3H6IHUT.js} +35 -34
- package/{appListCommands-F2H37K7K.js → appListCommands-CF4NYHRY.js} +35 -34
- package/{authCommand-2YPMMIJN.js → authCommand-T6UO5KPG.js} +20 -20
- package/{authCommands-FFDS4FVX.js → authCommands-KTIUCVVG.js} +4 -4
- package/{builtinSkillRegistry-CALVIJTX.js → builtinSkillRegistry-MAR5LPAC.js} +7 -6
- package/{chunk-4J3Q2KJL.js → chunk-2LM7XUCX.js} +10 -8
- package/{chunk-EKS2APRJ.js → chunk-2TYM4V33.js} +2 -2
- package/{chunk-O26PCYLS.js → chunk-2WJ57RJA.js} +6 -6
- package/{chunk-XVLDUNF7.js → chunk-3PELUSVV.js} +4 -4
- package/{chunk-C53ZG23R.js → chunk-4XYBLM4D.js} +4 -4
- package/{chunk-ZOVKKMF6.js → chunk-74D5HEDI.js} +1 -1
- package/{chunk-UQNS32WZ.js → chunk-7MTCBOOS.js} +1 -1
- package/chunk-A4SQRTZ6.js +15 -0
- package/chunk-AGIM7IMJ.js +147 -0
- package/{chunk-7WCQEMPB.js → chunk-ANRWQGOV.js} +27 -27
- package/{chunk-5UTFL4QJ.js → chunk-AOTBKDRK.js} +7 -0
- package/{chunk-4HXY5QQG.js → chunk-APVTZ66V.js} +1 -1
- package/{chunk-OTEMQQZI.js → chunk-BFWQ65IZ.js} +1 -1
- package/{chunk-QMX4FNL4.js → chunk-BS7YHAQP.js} +84 -84
- package/{chunk-6D2JFXLY.js → chunk-BZ7NPA6G.js} +0 -2
- package/{chunk-34TW5T2M.js → chunk-CERE5KFG.js} +1 -1
- package/{chunk-TU5NE4U3.js → chunk-CV366NXM.js} +7 -7
- package/{chunk-KLMW4NNN.js → chunk-DBOMSOYX.js} +1 -1
- package/{chunk-AWF3WO5R.js → chunk-DHA6B3LS.js} +7 -7
- package/chunk-DZ7R5V3Y.js +164 -0
- package/{chunk-I3QNET24.js → chunk-E3YWHWCR.js} +20 -1
- package/{chunk-Z4CSIXYP.js → chunk-ELIMCKNX.js} +5 -5
- package/{chunk-CTUQJVQM.js → chunk-EMQZSES6.js} +1 -1
- package/{chunk-RSEEDUMS.js → chunk-EPCAQM3U.js} +2 -2
- package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
- package/{chunk-DCLMZ5TX.js → chunk-HP57OUJO.js} +5 -5
- package/{chunk-WILHZY7K.js → chunk-JNXHAQPJ.js} +4 -4
- package/{chunk-AZRHIN5B.js → chunk-K6U4NKFJ.js} +1 -1
- package/{chunk-3R7EAVTC.js → chunk-KFJ7ZWBF.js} +38 -38
- package/{chunk-PQ3B6KI6.js → chunk-LYKHXIQC.js} +92 -92
- package/{chunk-HYZIYH2H.js → chunk-NVRC52JS.js} +22 -20
- package/chunk-NWENLDMM.js +42 -0
- package/{chunk-YXXI6MJ2.js → chunk-OCZQEXMX.js} +56 -60
- package/{chunk-P6GMCCAT.js → chunk-OW4APERY.js} +1 -1
- package/{chunk-RJK4MLDC.js → chunk-OXEHLZNH.js} +18 -20
- package/{chunk-DSSTTEKI.js → chunk-PQ6BKMXB.js} +2 -2
- package/{chunk-VN45QM57.js → chunk-QNTL2KFU.js} +76 -76
- package/{chunk-QJC7X767.js → chunk-RJYTVNWD.js} +1 -1
- package/{chunk-CPUFH46E.js → chunk-ROFPWC4X.js} +12 -12
- package/{chunk-IAESIMK7.js → chunk-RX4HD4H7.js} +8 -8
- package/{chunk-7AEF6ZXP.js → chunk-SBFHKTI7.js} +7 -7
- package/{chunk-VVXRRZXE.js → chunk-SESH42J6.js} +3 -3
- package/{chunk-DDBBIUXZ.js → chunk-SH7KLR4U.js} +20 -20
- package/{chunk-DAWDCRIG.js → chunk-TAWF7YAW.js} +1 -1
- package/{chunk-ZYWQNCBN.js → chunk-TVCAR26G.js} +1 -1
- package/{chunk-APMUYAPK.js → chunk-U3C3IA32.js} +1 -1
- package/chunk-UJXNKP5V.js +760 -0
- package/{chunk-O2OWEFII.js → chunk-VCAQFMVN.js} +1 -1
- package/{chunk-KCDUTE5V.js → chunk-VEYL5MO5.js} +4 -4
- package/{chunk-WIWM4FE3.js → chunk-VY6VFGKR.js} +7 -746
- package/{chunk-XAYSAKSS.js → chunk-VZZUQTBR.js} +2 -2
- package/{chunk-CU3QB4HW.js → chunk-W72ISAKC.js} +3 -3
- package/{chunk-QKUMVP3O.js → chunk-WCGC6S77.js} +4 -4
- package/{chunk-SEZZCP3H.js → chunk-WGPKQLZO.js} +27 -27
- package/{chunk-QDSINZM3.js → chunk-WJ3B6FX6.js} +1 -14
- package/{chunk-6ZWMH6TJ.js → chunk-WS2VEVHS.js} +4 -5
- package/{chunk-7CHC4W22.js → chunk-XBIYSBSG.js} +5 -5
- package/{chunk-NR4IWY23.js → chunk-YWLAWZYQ.js} +40 -260
- package/{chunk-R5VLGKMK.js → chunk-Z7A2EDGT.js} +15 -15
- package/{chunk-VFWN2MLE.js → chunk-ZGNDLCYH.js} +170 -153
- package/{commandRegistry-PUSRUY6V.js → commandRegistry-N47CRDOH.js} +70 -70
- package/{contentThunks-JFPH7ZGN.js → contentThunks-RRD2XMWB.js} +32 -32
- package/{createAgentAutomationAction-AYUD3TVG.js → createAgentAutomationAction-OW4WEVHP.js} +35 -35
- package/{createDialogAction-5EJGAQL5.js → createDialogAction-L3WMTD5Z.js} +36 -35
- package/{createPageAction-OJVJJSAD.js → createPageAction-PWG3K3K7.js} +43 -42
- package/{dbSlice-DQ32LYTJ.js → dbSlice-BUB77DHH.js} +12 -11
- package/{deleteFile-NX6QHCWZ.js → deleteFile-HG4BF3CS.js} +8 -7
- package/{dialogCommands-TQ2EYOO3.js → dialogCommands-CNXJGME5.js} +38 -38
- package/{dialogSlice-L5SA2HCW.js → dialogSlice-M7ZWTW5D.js} +31 -31
- package/{docCreateCommands-YGTVED6F.js → docCreateCommands-U2TEDZHS.js} +34 -33
- package/{docDeleteCommands-Y2K6UBU5.js → docDeleteCommands-K4ME6F6S.js} +35 -34
- package/{docReadCommands-JSJTTCVY.js → docReadCommands-ZUAVR3HH.js} +34 -33
- package/{docStore-DAAP4WFC.js → docStore-IX7ASJUP.js} +13 -12
- package/{docUpdateCommands-X2ZC37D3.js → docUpdateCommands-UKEOVRTF.js} +34 -33
- package/{fetchMessages-67MEFPZR.js → fetchMessages-N2BW2L62.js} +4 -4
- package/getPricing-NMMFT3YI.js +1 -1
- package/{handleSendMessageAction-NCZABULQ.js → handleSendMessageAction-KMPC6UD4.js} +36 -36
- package/index.js +3 -3
- package/{localDialogRead-EBRS242U.js → localDialogRead-3FHUPYAR.js} +1 -1
- package/{localRuntimeDb-3LRMNLCM.js → localRuntimeDb-AXJREE2T.js} +1 -1
- package/{machineCommands-GRIO3LQG.js → machineCommands-U4RRZGU6.js} +79 -77
- package/{machineWsRunDispatch-65IU4CLA.js → machineWsRunDispatch-V3IOP2P2.js} +71 -69
- package/{memberThunks-5ZXPR63F.js → memberThunks-LEUNURN2.js} +21 -19
- package/package.json +1 -1
- package/{providerPresetApply-76AVU3HD.js → providerPresetApply-76AHT34P.js} +4 -4
- package/{providerRegistry-Z62NC45X.js → providerRegistry-6HAQAQXB.js} +4 -4
- package/{read-EPTJRAEF.js → read-TBK4DFHP.js} +8 -7
- package/{readDocTool-W4NDXNEX.js → readDocTool-TJFCZ3ND.js} +1 -1
- package/{readlineWorkspace-6F27WVAV.js → readlineWorkspace-QTCU2BC4.js} +327 -110
- package/{removeDialogAgentAction-BVAWQKXE.js → removeDialogAgentAction-CT5HGRZH.js} +20 -22
- package/{runAgentClientLoop-CKC7RYAK.js → runAgentClientLoop-4VOARXQF.js} +65 -63
- package/{runtimeDoctorCommands-3USD722U.js → runtimeDoctorCommands-EQJA4MGD.js} +2 -2
- package/{setDialogExtraReferencesAction-LYY45IAD.js → setDialogExtraReferencesAction-JOENKFTX.js} +14 -13
- package/{setPrimaryDialogAgentAction-73IL7DLU.js → setPrimaryDialogAgentAction-MHWOGXP3.js} +20 -22
- package/{chunk-SONWNI3L.js → settingThunks-KLPZNA6L.js} +104 -921
- package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
- package/{spaceCommands-JZO2QK77.js → spaceCommands-ZESRWSTC.js} +36 -35
- package/{streamAgentChatTurn-4PBF5RK5.js → streamAgentChatTurn-VDAVK7N3.js} +110 -108
- package/{switchDialogAgentAction-UUXDSQ6X.js → switchDialogAgentAction-JHA4JEYA.js} +14 -13
- package/{tableCommands-G7RV3RU3.js → tableCommands-6U4BMLRR.js} +7 -7
- package/{toolApiClient-INIQCPGY.js → toolApiClient-EJT6TMFG.js} +4 -4
- package/{tools-BQ375D2L.js → tools-VJ3L5V6D.js} +53 -51
- package/{tuiSummaryLlmCaller-74NRRLVW.js → tuiSummaryLlmCaller-QUCBFGZK.js} +18 -17
- package/{updateDialogTitleAction-DTREH6RR.js → updateDialogTitleAction-GBUSLAQR.js} +39 -39
- package/action-GI44T4DR.js +0 -31
- package/browser-image-compression-MFDTD7K6.js +0 -1763
- package/chatQueueReduxAdapter-B3PSJ3GC.js +0 -187
- package/chunk-MEYIRKDN.js +0 -8967
- package/chunk-Y5GCAMGP.js +0 -9
- package/chunk-YPREESF4.js +0 -225
- package/settingSlice-Q6EKL7EQ.js +0 -204
- package/syncMapping-N6RGXGBW.js +0 -437
- package/{chunk-6PHKBY2Q.js → chunk-4YSOUKUR.js} +8 -8
- package/{chunk-S5XGT6GB.js → chunk-UA324D4O.js} +3 -3
- package/{chunk-MX574M24.js → chunk-V4UYSDTH.js} +3 -3
- package/{chunk-ESRMFY7G.js → chunk-XFUBXRVI.js} +5 -5
- package/{localRuntimeAuthority-5W6IJRAD.js → localRuntimeAuthority-AENMRPGX.js} +5 -5
|
@@ -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;
|
|
@@ -2171,97 +2147,6 @@ function formatProdErrorMessage(code) {
|
|
|
2171
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. `;
|
|
2172
2148
|
}
|
|
2173
2149
|
|
|
2174
|
-
// packages/app/stateViews/runtime.ts
|
|
2175
|
-
var selectCurrentToken = (state) => {
|
|
2176
|
-
const token = selectIdentityToken(state);
|
|
2177
|
-
return typeof token === "string" ? token : void 0;
|
|
2178
|
-
};
|
|
2179
|
-
var selectCurrentUserId = (state) => {
|
|
2180
|
-
const userId = selectIdentityUserId(state);
|
|
2181
|
-
return typeof userId === "string" ? userId : void 0;
|
|
2182
|
-
};
|
|
2183
|
-
var EMPTY_SYNC_SERVERS = [];
|
|
2184
|
-
var selectRuntimeRemoteServer = (state) => {
|
|
2185
|
-
const configuredServer = normalizeKnownServerOrigin(state.settings?.currentServer) ?? void 0;
|
|
2186
|
-
if (!getIsDesktopApp()) return configuredServer || SERVERS.MAIN;
|
|
2187
|
-
return isLocalServerUrl(configuredServer) ? SERVERS.MAIN : configuredServer || SERVERS.MAIN;
|
|
2188
|
-
};
|
|
2189
|
-
var selectConfiguredSyncServers = (state) => state.settings?.syncServers;
|
|
2190
|
-
var selectRuntimeRemoteSyncServers = createSelector(
|
|
2191
|
-
[selectConfiguredSyncServers],
|
|
2192
|
-
(syncServers) => {
|
|
2193
|
-
if (!Array.isArray(syncServers) || syncServers.length === 0) {
|
|
2194
|
-
return EMPTY_SYNC_SERVERS;
|
|
2195
|
-
}
|
|
2196
|
-
const normalized = syncServers.map(normalizeKnownServerOrigin).filter((server) => !!server);
|
|
2197
|
-
if (!getIsDesktopApp()) return normalized;
|
|
2198
|
-
return normalized.filter((server) => !isLocalServerUrl(server));
|
|
2199
|
-
}
|
|
2200
|
-
);
|
|
2201
|
-
var selectLocalRuntimeOrigin = () => {
|
|
2202
|
-
if (typeof window !== "undefined" && typeof window.location?.origin === "string" && /^https?:\/\//.test(window.location.origin)) {
|
|
2203
|
-
return window.location.origin.replace(/\/+$/, "");
|
|
2204
|
-
}
|
|
2205
|
-
return void 0;
|
|
2206
|
-
};
|
|
2207
|
-
var selectRuntimeSnapshot = createSelector(
|
|
2208
|
-
[
|
|
2209
|
-
selectCurrentToken,
|
|
2210
|
-
selectCurrentUserId,
|
|
2211
|
-
selectRuntimeRemoteServer,
|
|
2212
|
-
selectRuntimeRemoteSyncServers,
|
|
2213
|
-
selectLocalRuntimeOrigin
|
|
2214
|
-
],
|
|
2215
|
-
(currentToken, currentUserId, currentServer, syncServers, localRuntimeOrigin) => ({
|
|
2216
|
-
currentToken,
|
|
2217
|
-
currentUserId,
|
|
2218
|
-
currentServer,
|
|
2219
|
-
syncServers,
|
|
2220
|
-
localRuntimeOrigin
|
|
2221
|
-
})
|
|
2222
|
-
);
|
|
2223
|
-
var selectRuntimeCurrentServer = createSelector(
|
|
2224
|
-
[selectRuntimeSnapshot],
|
|
2225
|
-
(runtime) => runtime.currentServer
|
|
2226
|
-
);
|
|
2227
|
-
var selectRuntimeRemoteServers = createSelector(
|
|
2228
|
-
[selectRuntimeSnapshot],
|
|
2229
|
-
(runtime) => getAllServers(runtime.currentServer, runtime.syncServers)
|
|
2230
|
-
);
|
|
2231
|
-
|
|
2232
|
-
// packages/database/runtimeServerContext.ts
|
|
2233
|
-
var getRuntimeServerContext = (state, preferredServerOrigin) => {
|
|
2234
|
-
const {
|
|
2235
|
-
currentToken,
|
|
2236
|
-
currentUserId,
|
|
2237
|
-
currentServer,
|
|
2238
|
-
syncServers = []
|
|
2239
|
-
} = selectRuntimeSnapshot(state);
|
|
2240
|
-
return {
|
|
2241
|
-
currentToken,
|
|
2242
|
-
currentUserId,
|
|
2243
|
-
currentServer,
|
|
2244
|
-
syncServers,
|
|
2245
|
-
userAuthorityRegistry: resolveRuntimeUserAuthorityRegistry(state),
|
|
2246
|
-
remoteServers: getAllServers(
|
|
2247
|
-
currentServer,
|
|
2248
|
-
syncServers,
|
|
2249
|
-
preferredServerOrigin
|
|
2250
|
-
)
|
|
2251
|
-
};
|
|
2252
|
-
};
|
|
2253
|
-
var resolveRuntimeUserAuthorityRegistry = (state) => {
|
|
2254
|
-
const settingsRegistry = state.settings?.userAuthorityRegistry;
|
|
2255
|
-
if (settingsRegistry && typeof settingsRegistry === "object") {
|
|
2256
|
-
return settingsRegistry;
|
|
2257
|
-
}
|
|
2258
|
-
const userRegistry = selectIdentityUser(state)?.authorityRegistry;
|
|
2259
|
-
if (userRegistry && typeof userRegistry === "object") {
|
|
2260
|
-
return userRegistry;
|
|
2261
|
-
}
|
|
2262
|
-
return void 0;
|
|
2263
|
-
};
|
|
2264
|
-
|
|
2265
2150
|
// packages/database/requests.ts
|
|
2266
2151
|
var TIMEOUT = 5e3;
|
|
2267
2152
|
var logRequestFailure = (level, message) => {
|
|
@@ -2468,606 +2353,6 @@ var noloDeleteRequest = async (server, dbKey, options, state, signal) => {
|
|
|
2468
2353
|
}
|
|
2469
2354
|
};
|
|
2470
2355
|
|
|
2471
|
-
// packages/database/authority/ownerKey.ts
|
|
2472
|
-
var USER_OWNED_SECOND_SEGMENT_PREFIXES = /* @__PURE__ */ new Set([
|
|
2473
|
-
"agent",
|
|
2474
|
-
"dialog",
|
|
2475
|
-
"page",
|
|
2476
|
-
"doc",
|
|
2477
|
-
"notification",
|
|
2478
|
-
"email",
|
|
2479
|
-
"meta",
|
|
2480
|
-
"row",
|
|
2481
|
-
"view",
|
|
2482
|
-
"file",
|
|
2483
|
-
"job"
|
|
2484
|
-
]);
|
|
2485
|
-
var PUBLIC_OWNER_SENTINELS = /* @__PURE__ */ new Set(["pub", "id", "stats", "index"]);
|
|
2486
|
-
var cleanSegment = (value) => {
|
|
2487
|
-
const trimmed = asTrimmedString(value);
|
|
2488
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
2489
|
-
};
|
|
2490
|
-
var normalizeCandidateOwners = (candidateOwnerUserIds) => {
|
|
2491
|
-
const out = [];
|
|
2492
|
-
for (const candidate of candidateOwnerUserIds ?? []) {
|
|
2493
|
-
const normalized = cleanSegment(candidate ?? void 0);
|
|
2494
|
-
if (!normalized || PUBLIC_OWNER_SENTINELS.has(normalized)) continue;
|
|
2495
|
-
if (!out.includes(normalized)) out.push(normalized);
|
|
2496
|
-
}
|
|
2497
|
-
return out.sort((left, right) => right.length - left.length);
|
|
2498
|
-
};
|
|
2499
|
-
var resolveCandidateOwnerFromKeyRemainder = (remainder, candidateOwnerUserIds) => {
|
|
2500
|
-
const normalizedRemainder = cleanSegment(remainder);
|
|
2501
|
-
if (!normalizedRemainder) return null;
|
|
2502
|
-
for (const candidate of normalizeCandidateOwners(candidateOwnerUserIds)) {
|
|
2503
|
-
if (normalizedRemainder === candidate || normalizedRemainder.startsWith(`${candidate}-`)) {
|
|
2504
|
-
return candidate;
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
return null;
|
|
2508
|
-
};
|
|
2509
|
-
var parseOwnerUserIdFromDbKey = (dbKey, options = {}) => {
|
|
2510
|
-
const normalized = cleanSegment(dbKey);
|
|
2511
|
-
if (!normalized) return null;
|
|
2512
|
-
const parts = normalized.split("-");
|
|
2513
|
-
const [prefix] = parts;
|
|
2514
|
-
if (!prefix) return null;
|
|
2515
|
-
if (!USER_OWNED_SECOND_SEGMENT_PREFIXES.has(prefix)) {
|
|
2516
|
-
if (prefix === "grant" && parts[1] === "agent" && parts.length >= 5) {
|
|
2517
|
-
const ownerAndRest2 = normalized.slice(prefix.length + 1 + parts[1].length + 1);
|
|
2518
|
-
const [owner2] = ownerAndRest2.split("-");
|
|
2519
|
-
return cleanSegment(owner2);
|
|
2520
|
-
}
|
|
2521
|
-
return null;
|
|
2522
|
-
}
|
|
2523
|
-
if (parts[0] === "dialog" && parts[2] === "msg") {
|
|
2524
|
-
return null;
|
|
2525
|
-
}
|
|
2526
|
-
const ownerAndRest = normalized.slice(prefix.length + 1);
|
|
2527
|
-
const candidateOwner = resolveCandidateOwnerFromKeyRemainder(
|
|
2528
|
-
ownerAndRest,
|
|
2529
|
-
options.candidateOwnerUserIds
|
|
2530
|
-
);
|
|
2531
|
-
if (candidateOwner) return candidateOwner;
|
|
2532
|
-
const [owner] = ownerAndRest.split("-");
|
|
2533
|
-
const ownerUserId = cleanSegment(owner);
|
|
2534
|
-
if (!ownerUserId) return null;
|
|
2535
|
-
if (PUBLIC_OWNER_SENTINELS.has(ownerUserId)) return null;
|
|
2536
|
-
return ownerUserId;
|
|
2537
|
-
};
|
|
2538
|
-
|
|
2539
|
-
// packages/database/authority/userAuthorityRegistry.ts
|
|
2540
|
-
var normalizeAuthorityServerOrigin = (value) => {
|
|
2541
|
-
const normalized = normalizeServerOrigin(value);
|
|
2542
|
-
return /^https?:\/\//i.test(normalized) ? normalized : null;
|
|
2543
|
-
};
|
|
2544
|
-
var normalizeUserId = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2545
|
-
var readEntryAuthorityServer = (entry) => {
|
|
2546
|
-
if (typeof entry === "string") {
|
|
2547
|
-
return normalizeAuthorityServerOrigin(entry);
|
|
2548
|
-
}
|
|
2549
|
-
if (!isRecord(entry)) {
|
|
2550
|
-
return null;
|
|
2551
|
-
}
|
|
2552
|
-
return normalizeAuthorityServerOrigin(entry.authorityServer) ?? normalizeAuthorityServerOrigin(entry.homeServer) ?? normalizeAuthorityServerOrigin(entry.primaryServer);
|
|
2553
|
-
};
|
|
2554
|
-
var resolveUserAuthorityServer = ({
|
|
2555
|
-
ownerUserId,
|
|
2556
|
-
registry
|
|
2557
|
-
}) => {
|
|
2558
|
-
const normalizedOwner = normalizeUserId(ownerUserId);
|
|
2559
|
-
if (!normalizedOwner || !registry || typeof registry !== "object") {
|
|
2560
|
-
return null;
|
|
2561
|
-
}
|
|
2562
|
-
return readEntryAuthorityServer(registry[normalizedOwner]);
|
|
2563
|
-
};
|
|
2564
|
-
|
|
2565
|
-
// packages/database/authority/recordAuthority.ts
|
|
2566
|
-
var normalizeUserId2 = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2567
|
-
var getRegistryOwnerCandidates = (registry) => isRecord(registry) ? Object.keys(registry) : [];
|
|
2568
|
-
var resolveRecordAuthority = ({
|
|
2569
|
-
dbKey,
|
|
2570
|
-
record,
|
|
2571
|
-
currentUserId,
|
|
2572
|
-
currentServer,
|
|
2573
|
-
userAuthorityRegistry
|
|
2574
|
-
}) => {
|
|
2575
|
-
const ownerUserId = parseOwnerUserIdFromDbKey(dbKey, {
|
|
2576
|
-
candidateOwnerUserIds: [
|
|
2577
|
-
normalizeUserId2(record?.userId),
|
|
2578
|
-
normalizeUserId2(currentUserId),
|
|
2579
|
-
...getRegistryOwnerCandidates(userAuthorityRegistry)
|
|
2580
|
-
]
|
|
2581
|
-
}) ?? normalizeUserId2(record?.userId);
|
|
2582
|
-
const serverOrigin = normalizeAuthorityServerOrigin(record?.serverOrigin);
|
|
2583
|
-
const explicitAuthority = normalizeAuthorityServerOrigin(record?.authorityServer);
|
|
2584
|
-
const registryAuthority = resolveUserAuthorityServer({
|
|
2585
|
-
ownerUserId,
|
|
2586
|
-
registry: userAuthorityRegistry
|
|
2587
|
-
});
|
|
2588
|
-
const currentUserAuthority = ownerUserId && ownerUserId === normalizeUserId2(currentUserId) ? normalizeAuthorityServerOrigin(currentServer) : null;
|
|
2589
|
-
return {
|
|
2590
|
-
ownerUserId,
|
|
2591
|
-
authorityServer: explicitAuthority ?? registryAuthority ?? currentUserAuthority ?? serverOrigin,
|
|
2592
|
-
serverOrigin
|
|
2593
|
-
};
|
|
2594
|
-
};
|
|
2595
|
-
|
|
2596
|
-
// packages/database/actions/readResolution.ts
|
|
2597
|
-
var toComparableTimestamp = (data) => {
|
|
2598
|
-
if (!data || typeof data !== "object") return 0;
|
|
2599
|
-
const updatedAtMs = asOptionalPositiveFiniteNumber(
|
|
2600
|
-
new Date(data.updatedAt).getTime()
|
|
2601
|
-
);
|
|
2602
|
-
if (updatedAtMs !== void 0) return updatedAtMs;
|
|
2603
|
-
const createdAtMs = asOptionalPositiveFiniteNumber(
|
|
2604
|
-
new Date(data.createdAt).getTime()
|
|
2605
|
-
);
|
|
2606
|
-
if (createdAtMs !== void 0) return createdAtMs;
|
|
2607
|
-
return asOptionalPositiveFiniteNumber(Number(data?.meta?.createdAt)) ?? 0;
|
|
2608
|
-
};
|
|
2609
|
-
var partitionReadServers = ({
|
|
2610
|
-
allServers,
|
|
2611
|
-
preferredServerOrigin
|
|
2612
|
-
}) => {
|
|
2613
|
-
const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
|
|
2614
|
-
const fallbackServers = preferredServer ? allServers.filter(
|
|
2615
|
-
(server) => normalizeServerOrigin(server) !== preferredServer
|
|
2616
|
-
) : allServers;
|
|
2617
|
-
return {
|
|
2618
|
-
preferredServer,
|
|
2619
|
-
fallbackServers,
|
|
2620
|
-
orderedServersForLocalHit: preferredServer ? [preferredServer, ...fallbackServers] : fallbackServers
|
|
2621
|
-
};
|
|
2622
|
-
};
|
|
2623
|
-
var compareRemoteRecordsByComparableTime = (left, right) => toComparableTimestamp(left) - toComparableTimestamp(right);
|
|
2624
|
-
var pickBestSettledRemoteRecord = ({
|
|
2625
|
-
settledResults,
|
|
2626
|
-
isBetterCandidate
|
|
2627
|
-
}) => {
|
|
2628
|
-
const validResults = settledResults.map((result, index) => ({
|
|
2629
|
-
data: result.status === "fulfilled" ? result.value : null,
|
|
2630
|
-
index
|
|
2631
|
-
})).filter((item) => item.data !== null && typeof item.data === "object");
|
|
2632
|
-
if (validResults.length === 0) return null;
|
|
2633
|
-
const latest2 = validResults.reduce(
|
|
2634
|
-
(best, current2) => isBetterCandidate(current2.data, best.data) ? current2 : best
|
|
2635
|
-
);
|
|
2636
|
-
return { index: latest2.index, data: latest2.data };
|
|
2637
|
-
};
|
|
2638
|
-
var shouldReplaceLocalWithRemoteRecord = ({
|
|
2639
|
-
localData,
|
|
2640
|
-
remoteData,
|
|
2641
|
-
isRemoteNewer
|
|
2642
|
-
}) => {
|
|
2643
|
-
if (!remoteData || typeof remoteData !== "object") return false;
|
|
2644
|
-
if (!localData || typeof localData !== "object") return true;
|
|
2645
|
-
return isRemoteNewer(remoteData, localData);
|
|
2646
|
-
};
|
|
2647
|
-
var shouldReplicateLocalRecord = ({
|
|
2648
|
-
localData,
|
|
2649
|
-
remoteData,
|
|
2650
|
-
remoteTargetCount
|
|
2651
|
-
}) => !!localData && !remoteData && remoteTargetCount > 0;
|
|
2652
|
-
var compactUniqueServers = (servers) => {
|
|
2653
|
-
const out = [];
|
|
2654
|
-
for (const server of servers) {
|
|
2655
|
-
if (typeof server !== "string" || server.trim().length === 0) continue;
|
|
2656
|
-
const normalized = normalizeServerOrigin(server);
|
|
2657
|
-
if (!out.includes(normalized)) out.push(normalized);
|
|
2658
|
-
}
|
|
2659
|
-
return out;
|
|
2660
|
-
};
|
|
2661
|
-
var planAuthorityReadServers = ({
|
|
2662
|
-
allServers,
|
|
2663
|
-
authorityServer,
|
|
2664
|
-
serverOrigin
|
|
2665
|
-
}) => compactUniqueServers([authorityServer, serverOrigin, ...allServers]);
|
|
2666
|
-
|
|
2667
|
-
// packages/core/fnv1a32.ts
|
|
2668
|
-
var fnv1a32 = (str) => {
|
|
2669
|
-
let hash = 2166136261;
|
|
2670
|
-
for (let i = 0; i < str.length; i++) {
|
|
2671
|
-
hash ^= str.charCodeAt(i);
|
|
2672
|
-
hash = hash * 16777619 >>> 0;
|
|
2673
|
-
}
|
|
2674
|
-
return hash >>> 0;
|
|
2675
|
-
};
|
|
2676
|
-
var fnv1a32Hex = (str) => fnv1a32(str).toString(16).padStart(8, "0");
|
|
2677
|
-
|
|
2678
|
-
// packages/database/fileRing.ts
|
|
2679
|
-
var chooseServersByKey = (allServers, key, replicaCount) => {
|
|
2680
|
-
if (!allServers.length || replicaCount <= 0) return [];
|
|
2681
|
-
const uniqueServers = Array.from(new Set(allServers)).filter((s) => !!s);
|
|
2682
|
-
if (uniqueServers.length === 0) return [];
|
|
2683
|
-
const scored = uniqueServers.map((server) => ({
|
|
2684
|
-
server,
|
|
2685
|
-
score: fnv1a32(`${server}::${key}`)
|
|
2686
|
-
}));
|
|
2687
|
-
scored.sort((a, b) => a.score - b.score);
|
|
2688
|
-
const limit = Math.min(replicaCount, scored.length);
|
|
2689
|
-
return scored.slice(0, limit).map((item) => item.server);
|
|
2690
|
-
};
|
|
2691
|
-
|
|
2692
|
-
// packages/database/tenantPlacement.ts
|
|
2693
|
-
var TENANT_REPLICA_COUNT = 2;
|
|
2694
|
-
var planServersForTenant = (allServers, currentServer, tenantId) => {
|
|
2695
|
-
const uniqueServers = Array.from(new Set(allServers)).filter(Boolean);
|
|
2696
|
-
if (!uniqueServers.length) return [];
|
|
2697
|
-
const key = asOptionalTrimmedString(tenantId) ?? "default-tenant";
|
|
2698
|
-
const fromRing = chooseServersByKey(
|
|
2699
|
-
uniqueServers,
|
|
2700
|
-
key,
|
|
2701
|
-
TENANT_REPLICA_COUNT
|
|
2702
|
-
);
|
|
2703
|
-
const set2 = new Set(fromRing);
|
|
2704
|
-
if (currentServer && uniqueServers.includes(currentServer)) {
|
|
2705
|
-
set2.add(currentServer);
|
|
2706
|
-
}
|
|
2707
|
-
return Array.from(set2);
|
|
2708
|
-
};
|
|
2709
|
-
|
|
2710
|
-
// packages/database/authority/deviceLocal.ts
|
|
2711
|
-
var DEVICE_LOCAL_OWNER_ID = "local";
|
|
2712
|
-
var DEVICE_LOCAL_DB_KEY_PREFIXES = [
|
|
2713
|
-
"dialog-local-",
|
|
2714
|
-
"agent-local-"
|
|
2715
|
-
];
|
|
2716
|
-
var clean = (value) => asOptionalTrimmedString(value) ?? null;
|
|
2717
|
-
var isDeviceLocalOwnerId = (userId) => clean(userId) === DEVICE_LOCAL_OWNER_ID;
|
|
2718
|
-
var resolveEffectiveSpaceActorId = (accountUserId) => {
|
|
2719
|
-
const cleaned = clean(accountUserId);
|
|
2720
|
-
if (!cleaned || isDeviceLocalOwnerId(cleaned)) {
|
|
2721
|
-
return DEVICE_LOCAL_OWNER_ID;
|
|
2722
|
-
}
|
|
2723
|
-
return cleaned;
|
|
2724
|
-
};
|
|
2725
|
-
var isDeviceLocalSpaceMembership = (membership) => isDeviceLocalOwnerId(membership?.userId);
|
|
2726
|
-
var isDeviceLocalSpaceBody = (space) => isDeviceLocalOwnerId(space?.userId) || isDeviceLocalOwnerId(space?.ownerId);
|
|
2727
|
-
var isDeviceLocalDbKey = (dbKey) => {
|
|
2728
|
-
const key = clean(dbKey);
|
|
2729
|
-
if (!key) return false;
|
|
2730
|
-
for (const prefix of DEVICE_LOCAL_DB_KEY_PREFIXES) {
|
|
2731
|
-
if (key.startsWith(prefix)) return true;
|
|
2732
|
-
}
|
|
2733
|
-
return parseOwnerUserIdFromDbKey(key, {
|
|
2734
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2735
|
-
}) === DEVICE_LOCAL_OWNER_ID;
|
|
2736
|
-
};
|
|
2737
|
-
var resolveRecordOwnerUserId = (record) => {
|
|
2738
|
-
if (!record) return null;
|
|
2739
|
-
const explicit = clean(record.userId);
|
|
2740
|
-
if (explicit) return explicit;
|
|
2741
|
-
if (isDeviceLocalDbKey(record.dbKey) || isDeviceLocalDbKey(record.id)) {
|
|
2742
|
-
return DEVICE_LOCAL_OWNER_ID;
|
|
2743
|
-
}
|
|
2744
|
-
const fromKey = parseOwnerUserIdFromDbKey(clean(record.dbKey) ?? "", {
|
|
2745
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2746
|
-
}) ?? parseOwnerUserIdFromDbKey(clean(record.id) ?? "", {
|
|
2747
|
-
candidateOwnerUserIds: [DEVICE_LOCAL_OWNER_ID]
|
|
2748
|
-
});
|
|
2749
|
-
return fromKey;
|
|
2750
|
-
};
|
|
2751
|
-
|
|
2752
|
-
// packages/database/actions/replication.ts
|
|
2753
|
-
var isReadonlyPublicRecordKey = (dbKey) => dbKey.startsWith("agent-pub-");
|
|
2754
|
-
var normalizeCurrentUserId = (state) => {
|
|
2755
|
-
const userId = selectIdentityUserId(state);
|
|
2756
|
-
return asOptionalTrimmedString(userId) ?? null;
|
|
2757
|
-
};
|
|
2758
|
-
var resolveReplicationServers = (currentServer, syncServers, preferredServerOrigin) => getAllServers(currentServer, syncServers, preferredServerOrigin);
|
|
2759
|
-
var resolveAuthorityReplicationServers = ({
|
|
2760
|
-
currentServer,
|
|
2761
|
-
syncServers,
|
|
2762
|
-
preferredServerOrigin,
|
|
2763
|
-
dbKey,
|
|
2764
|
-
record,
|
|
2765
|
-
state
|
|
2766
|
-
}) => {
|
|
2767
|
-
const allServers = resolveReplicationServers(
|
|
2768
|
-
currentServer,
|
|
2769
|
-
syncServers,
|
|
2770
|
-
preferredServerOrigin
|
|
2771
|
-
);
|
|
2772
|
-
const authority = resolveRecordAuthority({
|
|
2773
|
-
dbKey,
|
|
2774
|
-
record,
|
|
2775
|
-
currentUserId: selectIdentityUserId(state),
|
|
2776
|
-
currentServer,
|
|
2777
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
2778
|
-
});
|
|
2779
|
-
if (isDeviceLocalOwnerId(authority.ownerUserId) || isDeviceLocalOwnerId(record?.userId) || isDeviceLocalDbKey(dbKey)) {
|
|
2780
|
-
return [];
|
|
2781
|
-
}
|
|
2782
|
-
return planAuthorityReadServers({
|
|
2783
|
-
allServers,
|
|
2784
|
-
authorityServer: preferredServerOrigin ?? authority.authorityServer,
|
|
2785
|
-
serverOrigin: authority.serverOrigin
|
|
2786
|
-
});
|
|
2787
|
-
};
|
|
2788
|
-
var scheduleWriteReplication = (servers, request, state) => {
|
|
2789
|
-
if (servers.length === 0) return;
|
|
2790
|
-
Promise.resolve().then(async () => {
|
|
2791
|
-
const [primaryServer, ...backupServers] = servers;
|
|
2792
|
-
const primarySucceeded = await noloWriteRequest(primaryServer, request, state);
|
|
2793
|
-
if (!primarySucceeded) {
|
|
2794
|
-
console.warn(`Primary write sync failed for ${request.customKey} on ${primaryServer}`);
|
|
2795
|
-
}
|
|
2796
|
-
if (backupServers.length === 0) {
|
|
2797
|
-
return;
|
|
2798
|
-
}
|
|
2799
|
-
syncWithServers(
|
|
2800
|
-
backupServers,
|
|
2801
|
-
(server, requestConfig, requestState, signal) => noloWriteRequest(server, requestConfig, requestState, signal, {
|
|
2802
|
-
failureLogLevel: "info"
|
|
2803
|
-
}),
|
|
2804
|
-
`Backup write sync failed for ${request.customKey} on`,
|
|
2805
|
-
request,
|
|
2806
|
-
state
|
|
2807
|
-
);
|
|
2808
|
-
});
|
|
2809
|
-
};
|
|
2810
|
-
var resolveTenantReplicationServers = ({
|
|
2811
|
-
currentServer,
|
|
2812
|
-
syncServers,
|
|
2813
|
-
tenantId
|
|
2814
|
-
}) => {
|
|
2815
|
-
const allServers = resolveReplicationServers(currentServer, syncServers);
|
|
2816
|
-
if (allServers.length === 0) {
|
|
2817
|
-
return [];
|
|
2818
|
-
}
|
|
2819
|
-
return planServersForTenant(allServers, currentServer, tenantId);
|
|
2820
|
-
};
|
|
2821
|
-
var resolveUploadReplicationServers = ({
|
|
2822
|
-
currentServer,
|
|
2823
|
-
syncServers,
|
|
2824
|
-
tenantId,
|
|
2825
|
-
uploadConfig,
|
|
2826
|
-
state
|
|
2827
|
-
}) => {
|
|
2828
|
-
const allServers = resolveReplicationServers(currentServer, syncServers);
|
|
2829
|
-
const authority = resolveRecordAuthority({
|
|
2830
|
-
dbKey: uploadConfig.customKey,
|
|
2831
|
-
record: uploadConfig.metadata,
|
|
2832
|
-
currentUserId: selectIdentityUserId(state),
|
|
2833
|
-
currentServer,
|
|
2834
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
2835
|
-
});
|
|
2836
|
-
if (authority.ownerUserId || authority.authorityServer) {
|
|
2837
|
-
return planAuthorityReadServers({
|
|
2838
|
-
allServers,
|
|
2839
|
-
authorityServer: authority.authorityServer,
|
|
2840
|
-
serverOrigin: authority.serverOrigin
|
|
2841
|
-
});
|
|
2842
|
-
}
|
|
2843
|
-
return resolveTenantReplicationServers({
|
|
2844
|
-
currentServer,
|
|
2845
|
-
syncServers,
|
|
2846
|
-
tenantId
|
|
2847
|
-
});
|
|
2848
|
-
};
|
|
2849
|
-
var scheduleExistingRecordReplication = ({
|
|
2850
|
-
currentServer,
|
|
2851
|
-
syncServers,
|
|
2852
|
-
preferredServerOrigin,
|
|
2853
|
-
dbKey,
|
|
2854
|
-
localData,
|
|
2855
|
-
state
|
|
2856
|
-
}) => {
|
|
2857
|
-
if (isReadonlyPublicRecordKey(dbKey)) {
|
|
2858
|
-
return [];
|
|
2859
|
-
}
|
|
2860
|
-
const currentUserId = normalizeCurrentUserId(state);
|
|
2861
|
-
const authority = resolveRecordAuthority({
|
|
2862
|
-
dbKey,
|
|
2863
|
-
record: localData,
|
|
2864
|
-
currentUserId,
|
|
2865
|
-
currentServer,
|
|
2866
|
-
userAuthorityRegistry: state?.settings?.userAuthorityRegistry ?? selectIdentityUser(state)?.authorityRegistry
|
|
2867
|
-
});
|
|
2868
|
-
if (authority.ownerUserId && currentUserId && authority.ownerUserId !== currentUserId) {
|
|
2869
|
-
return [];
|
|
2870
|
-
}
|
|
2871
|
-
const servers = resolveAuthorityReplicationServers({
|
|
2872
|
-
currentServer,
|
|
2873
|
-
syncServers,
|
|
2874
|
-
preferredServerOrigin,
|
|
2875
|
-
dbKey,
|
|
2876
|
-
record: localData,
|
|
2877
|
-
state
|
|
2878
|
-
});
|
|
2879
|
-
if (servers.length === 0) {
|
|
2880
|
-
return [];
|
|
2881
|
-
}
|
|
2882
|
-
scheduleWriteReplication(
|
|
2883
|
-
servers,
|
|
2884
|
-
{
|
|
2885
|
-
data: localData,
|
|
2886
|
-
customKey: dbKey,
|
|
2887
|
-
userId: typeof localData?.userId === "string" ? localData.userId : selectIdentityUserId(state)
|
|
2888
|
-
},
|
|
2889
|
-
state
|
|
2890
|
-
);
|
|
2891
|
-
return servers;
|
|
2892
|
-
};
|
|
2893
|
-
var schedulePatchReplication = ({
|
|
2894
|
-
servers,
|
|
2895
|
-
dbKey,
|
|
2896
|
-
changes,
|
|
2897
|
-
state,
|
|
2898
|
-
preferredServerOrigin
|
|
2899
|
-
}) => {
|
|
2900
|
-
if (servers.length === 0) return;
|
|
2901
|
-
Promise.resolve().then(async () => {
|
|
2902
|
-
const primaryServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : servers[0];
|
|
2903
|
-
const backupServers = servers.filter(
|
|
2904
|
-
(server) => normalizeServerOrigin(server) !== primaryServer
|
|
2905
|
-
);
|
|
2906
|
-
const primarySucceeded = await noloPatchRequest(primaryServer, dbKey, changes, state, void 0, {
|
|
2907
|
-
failureLogLevel: "warn"
|
|
2908
|
-
});
|
|
2909
|
-
if (!primarySucceeded) {
|
|
2910
|
-
console.warn(`Primary patch sync failed for ${dbKey} on ${primaryServer}`);
|
|
2911
|
-
}
|
|
2912
|
-
if (backupServers.length > 0) {
|
|
2913
|
-
syncWithServers(
|
|
2914
|
-
backupServers,
|
|
2915
|
-
(server, targetDbKey, nextChanges, requestState, signal) => noloPatchRequest(server, targetDbKey, nextChanges, requestState, signal, {
|
|
2916
|
-
failureLogLevel: "info"
|
|
2917
|
-
}),
|
|
2918
|
-
`Backup patch sync failed for ${dbKey} on`,
|
|
2919
|
-
dbKey,
|
|
2920
|
-
changes,
|
|
2921
|
-
state
|
|
2922
|
-
);
|
|
2923
|
-
}
|
|
2924
|
-
});
|
|
2925
|
-
};
|
|
2926
|
-
var scheduleConfiguredPatchReplication = ({
|
|
2927
|
-
currentServer,
|
|
2928
|
-
syncServers,
|
|
2929
|
-
preferredServerOrigin,
|
|
2930
|
-
dbKey,
|
|
2931
|
-
changes,
|
|
2932
|
-
state
|
|
2933
|
-
}) => {
|
|
2934
|
-
const servers = resolveAuthorityReplicationServers({
|
|
2935
|
-
currentServer,
|
|
2936
|
-
syncServers,
|
|
2937
|
-
preferredServerOrigin,
|
|
2938
|
-
dbKey,
|
|
2939
|
-
record: changes,
|
|
2940
|
-
state
|
|
2941
|
-
});
|
|
2942
|
-
if (servers.length === 0) {
|
|
2943
|
-
return [];
|
|
2944
|
-
}
|
|
2945
|
-
schedulePatchReplication({
|
|
2946
|
-
servers,
|
|
2947
|
-
dbKey,
|
|
2948
|
-
changes,
|
|
2949
|
-
state,
|
|
2950
|
-
preferredServerOrigin
|
|
2951
|
-
});
|
|
2952
|
-
return servers;
|
|
2953
|
-
};
|
|
2954
|
-
var scheduleUploadReplication = ({
|
|
2955
|
-
currentServer,
|
|
2956
|
-
syncServers,
|
|
2957
|
-
tenantId,
|
|
2958
|
-
uploadConfig,
|
|
2959
|
-
state,
|
|
2960
|
-
excludeServers = []
|
|
2961
|
-
}) => {
|
|
2962
|
-
const servers = resolveUploadReplicationServers({
|
|
2963
|
-
currentServer,
|
|
2964
|
-
syncServers,
|
|
2965
|
-
tenantId,
|
|
2966
|
-
uploadConfig,
|
|
2967
|
-
state
|
|
2968
|
-
});
|
|
2969
|
-
const excluded = new Set(
|
|
2970
|
-
excludeServers.filter((server) => typeof server === "string").map((server) => normalizeServerOrigin(server))
|
|
2971
|
-
);
|
|
2972
|
-
const remainingServers = servers.filter(
|
|
2973
|
-
(server) => !excluded.has(normalizeServerOrigin(server))
|
|
2974
|
-
);
|
|
2975
|
-
if (remainingServers.length === 0) {
|
|
2976
|
-
return [];
|
|
2977
|
-
}
|
|
2978
|
-
Promise.resolve().then(() => {
|
|
2979
|
-
syncWithServers(
|
|
2980
|
-
remainingServers,
|
|
2981
|
-
noloUploadRequest,
|
|
2982
|
-
`Upload sync failed for ${uploadConfig.customKey} on`,
|
|
2983
|
-
uploadConfig,
|
|
2984
|
-
state
|
|
2985
|
-
);
|
|
2986
|
-
});
|
|
2987
|
-
return remainingServers;
|
|
2988
|
-
};
|
|
2989
|
-
var uploadToCurrentServer = async ({
|
|
2990
|
-
currentServer,
|
|
2991
|
-
uploadConfig,
|
|
2992
|
-
state
|
|
2993
|
-
}) => {
|
|
2994
|
-
if (!currentServer) {
|
|
2995
|
-
return false;
|
|
2996
|
-
}
|
|
2997
|
-
return noloUploadRequest(currentServer, uploadConfig, state);
|
|
2998
|
-
};
|
|
2999
|
-
var deleteFromReplicationServers = async ({
|
|
3000
|
-
servers,
|
|
3001
|
-
dbKey,
|
|
3002
|
-
deleteOptions = { type: "single" },
|
|
3003
|
-
state,
|
|
3004
|
-
preferredServerOrigin
|
|
3005
|
-
}) => {
|
|
3006
|
-
if (!servers.length) {
|
|
3007
|
-
return { succeeded: [], failed: [] };
|
|
3008
|
-
}
|
|
3009
|
-
const preferredServer = typeof preferredServerOrigin === "string" && preferredServerOrigin.trim().length > 0 ? normalizeServerOrigin(preferredServerOrigin) : null;
|
|
3010
|
-
const remainingServers = preferredServer ? servers.filter((server) => normalizeServerOrigin(server) !== preferredServer) : servers;
|
|
3011
|
-
const succeeded = [];
|
|
3012
|
-
const failed = [];
|
|
3013
|
-
if (preferredServer) {
|
|
3014
|
-
const ok = await noloDeleteRequest(preferredServer, dbKey, deleteOptions, state);
|
|
3015
|
-
if (ok) {
|
|
3016
|
-
succeeded.push(preferredServer);
|
|
3017
|
-
} else {
|
|
3018
|
-
failed.push(preferredServer);
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
if (remainingServers.length > 0) {
|
|
3022
|
-
const results = await Promise.all(
|
|
3023
|
-
remainingServers.map(async (server) => ({
|
|
3024
|
-
server,
|
|
3025
|
-
ok: await noloDeleteRequest(server, dbKey, deleteOptions, state)
|
|
3026
|
-
}))
|
|
3027
|
-
);
|
|
3028
|
-
results.forEach(({ server, ok }) => {
|
|
3029
|
-
if (ok) succeeded.push(server);
|
|
3030
|
-
else failed.push(server);
|
|
3031
|
-
});
|
|
3032
|
-
}
|
|
3033
|
-
return { succeeded, failed };
|
|
3034
|
-
};
|
|
3035
|
-
var scheduleDeleteReplication = ({
|
|
3036
|
-
currentServer,
|
|
3037
|
-
syncServers,
|
|
3038
|
-
preferredServerOrigin,
|
|
3039
|
-
dbKey,
|
|
3040
|
-
deleteOptions,
|
|
3041
|
-
state,
|
|
3042
|
-
onResult,
|
|
3043
|
-
onError
|
|
3044
|
-
}) => {
|
|
3045
|
-
const servers = resolveAuthorityReplicationServers({
|
|
3046
|
-
currentServer,
|
|
3047
|
-
syncServers,
|
|
3048
|
-
preferredServerOrigin,
|
|
3049
|
-
dbKey,
|
|
3050
|
-
state
|
|
3051
|
-
});
|
|
3052
|
-
if (servers.length === 0) {
|
|
3053
|
-
return [];
|
|
3054
|
-
}
|
|
3055
|
-
void Promise.resolve().then(
|
|
3056
|
-
() => deleteFromReplicationServers({
|
|
3057
|
-
servers,
|
|
3058
|
-
dbKey,
|
|
3059
|
-
deleteOptions,
|
|
3060
|
-
state,
|
|
3061
|
-
preferredServerOrigin
|
|
3062
|
-
})
|
|
3063
|
-
).then((result) => {
|
|
3064
|
-
onResult?.(result);
|
|
3065
|
-
}).catch((error) => {
|
|
3066
|
-
onError?.(error);
|
|
3067
|
-
});
|
|
3068
|
-
return servers;
|
|
3069
|
-
};
|
|
3070
|
-
|
|
3071
2356
|
export {
|
|
3072
2357
|
createSelector,
|
|
3073
2358
|
createAction,
|
|
@@ -3075,33 +2360,9 @@ export {
|
|
|
3075
2360
|
asyncThunkCreator,
|
|
3076
2361
|
buildCreateSlice,
|
|
3077
2362
|
createEntityAdapter,
|
|
3078
|
-
|
|
3079
|
-
selectRuntimeCurrentServer,
|
|
3080
|
-
getRuntimeServerContext,
|
|
2363
|
+
noloPatchRequest,
|
|
3081
2364
|
noloWriteRequest,
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
DEVICE_LOCAL_OWNER_ID,
|
|
3086
|
-
isDeviceLocalOwnerId,
|
|
3087
|
-
resolveEffectiveSpaceActorId,
|
|
3088
|
-
isDeviceLocalSpaceMembership,
|
|
3089
|
-
isDeviceLocalSpaceBody,
|
|
3090
|
-
resolveRecordOwnerUserId,
|
|
3091
|
-
resolveRecordAuthority,
|
|
3092
|
-
partitionReadServers,
|
|
3093
|
-
compareRemoteRecordsByComparableTime,
|
|
3094
|
-
pickBestSettledRemoteRecord,
|
|
3095
|
-
shouldReplaceLocalWithRemoteRecord,
|
|
3096
|
-
shouldReplicateLocalRecord,
|
|
3097
|
-
planAuthorityReadServers,
|
|
3098
|
-
resolveReplicationServers,
|
|
3099
|
-
resolveAuthorityReplicationServers,
|
|
3100
|
-
scheduleWriteReplication,
|
|
3101
|
-
resolveUploadReplicationServers,
|
|
3102
|
-
scheduleExistingRecordReplication,
|
|
3103
|
-
scheduleConfiguredPatchReplication,
|
|
3104
|
-
scheduleUploadReplication,
|
|
3105
|
-
uploadToCurrentServer,
|
|
3106
|
-
scheduleDeleteReplication
|
|
2365
|
+
noloUploadRequest,
|
|
2366
|
+
syncWithServers,
|
|
2367
|
+
noloDeleteRequest
|
|
3107
2368
|
};
|