nolo-cli 0.265.0-alpha.1 → 0.266.0-alpha.1
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/{chunk-LXP53WGF.js → chunk-05wkntba.js} +44 -40
- package/{chunk-XFYFMTOM.js → chunk-08ts2q1n.js} +9 -11
- package/{chromeCommands-MVEEIY4R.js → chunk-0a3m1n6h.js} +182 -238
- package/chunk-0gfvc7g8.js +13 -0
- package/{chunk-CF7PE763.js → chunk-0h0sncy4.js} +3 -4
- package/{chunk-3UH7SS4W.js → chunk-0nsxwrge.js} +232 -241
- package/chunk-0ra8cne4.js +11 -0
- package/{chunk-MRACVEPZ.js → chunk-0sgwk7am.js} +1 -3
- package/{chunk-PEXGRTTQ.js → chunk-0tsfn0dk.js} +44 -45
- package/{chunk-WOAZVUSN.js → chunk-0y8cbwzy.js} +26 -30
- package/chunk-12gz55kk.js +6 -0
- package/{chunk-GLKOYSRU.js → chunk-186gshgw.js} +3 -6
- package/chunk-19w4ss38.js +44 -0
- package/{chunk-RF576RYE.js → chunk-1cakzp6r.js} +23 -23
- package/chunk-1fbfwbzp.js +27 -0
- package/{chunk-4IVMDQBA.js → chunk-1fv9k8zt.js} +103 -68
- package/{chunk-Q5FJJ6XI.js → chunk-1js4cdzp.js} +11 -19
- package/{chunk-YECCIUYU.js → chunk-1nhx0er5.js} +63 -63
- package/chunk-1p152b7g.js +12 -0
- package/{chunk-LBPW6OCD.js → chunk-1ynbq3yr.js} +322 -353
- package/{chunk-6UBGXX2W.js → chunk-1zrg4h5n.js} +3 -4
- package/{chunk-Y5GCAMGP.js → chunk-2g6zsfq8.js} +1 -3
- package/chunk-2hekb0eh.js +17 -0
- package/chunk-2pj6qzq5.js +12 -0
- package/chunk-2tvd4jyp.js +226 -0
- package/chunk-2ygg7azv.js +846 -0
- package/chunk-33405wtv.js +50 -0
- package/chunk-34axejtd.js +30 -0
- package/{tableCommands-FCPDULSU.js → chunk-3700dvt3.js} +224 -276
- package/{pdf-KE3QI2V7.js → chunk-3j08t1nm.js} +12505 -10133
- package/chunk-3j9gq18v.js +111 -0
- package/{chunk-2QKIWEZS.js → chunk-3qfpcdkm.js} +486 -505
- package/{settingThunks-PNC7ZISV.js → chunk-3r2x7h64.js} +189 -272
- package/{agentGrantCommands-2VLLXGIU.js → chunk-3tbj5fxt.js} +61 -56
- package/chunk-40whhjj5.js +168 -0
- package/chunk-4301919y.js +7 -0
- package/chunk-43adz39e.js +77 -0
- package/{chunk-5ZUL4CUO.js → chunk-49v3zc4g.js} +1 -3
- package/chunk-4dd7mxkb.js +72 -0
- package/{chunk-BKP325XS.js → chunk-4hapfzpq.js} +66 -62
- package/chunk-4mm7dz0m.js +95 -0
- package/chunk-4pqxempz.js +440 -0
- package/chunk-4x9zf5pv.js +10 -0
- package/{chunk-CA7LGAHV.js → chunk-511q8qzv.js} +66 -57
- package/{chunk-S52BPZ7A.js → chunk-53v9g0np.js} +49 -64
- package/chunk-572mg6q5.js +19 -0
- package/{chunk-DXDCL3Z6.js → chunk-57eyhmwr.js} +17173 -16165
- package/chunk-5hsr0zjm.js +156 -0
- package/chunk-5k883yyd.js +20 -0
- package/chunk-5m0wsee4.js +639 -0
- package/{memberThunks-IPS3SLOF.js → chunk-5r1sq2gt.js} +299 -373
- package/chunk-648rq4np.js +255 -0
- package/{chunk-IYRZKHA6.js → chunk-666yjw5c.js} +63 -86
- package/{chunk-4O22PGNQ.js → chunk-6cdcbmtp.js} +19 -19
- package/chunk-6dbyqcf7.js +59 -0
- package/{agentProviderCommands-2W3VXDLV.js → chunk-6e8mgp1x.js} +82 -105
- package/chunk-6n0pw7sx.js +44 -0
- package/chunk-6q1b7381.js +361 -0
- package/chunk-6sj756ry.js +23 -0
- package/{chunk-XGYQCBWS.js → chunk-6t7a7zck.js} +14785 -14454
- package/chunk-6yarwtxh.js +776 -0
- package/chunk-708h542p.js +18 -0
- package/chunk-76f076t8.js +266 -0
- package/chunk-782rrrwv.js +523 -0
- package/{workloadLifecycle-P2SJVV3S.js → chunk-7gk330wp.js} +77 -84
- package/{chunk-EZKIRVLJ.js → chunk-7ks60vxy.js} +146 -128
- package/{chunk-FI4DPLR7.js → chunk-7mrqbxe8.js} +342 -228
- package/chunk-7sztayrd.js +169 -0
- package/chunk-7vgt2mxz.js +15 -0
- package/{localFirstLog-OIETGK66.js → chunk-7z8y4k6y.js} +0 -2
- package/{chunk-KDDXC2IH.js → chunk-82htft2m.js} +49 -11
- package/{updateDialogTitleAction-OPAZF5VC.js → chunk-88vrtxxg.js} +65 -137
- package/{chunk-LS5KAVFQ.js → chunk-8dtjbp79.js} +293 -229
- package/chunk-8fajbkaz.js +50 -0
- package/chunk-8m1ebxpw.js +65 -0
- package/{accountResolver-JYG5L7YP.js → chunk-8mgfeg0w.js} +37 -30
- package/{chunk-LPXBBC32.js → chunk-8myksy35.js} +156 -160
- package/{chunk-BMQ2MJUK.js → chunk-8nrj7dc7.js} +75 -66
- package/{commandRegistry-XPLM5SWC.js → chunk-8t8x64ec.js} +228 -286
- package/chunk-8yj4pq79.js +458 -0
- package/{chunk-5MKPNTJP.js → chunk-8z6pepcx.js} +43 -48
- package/{chunk-UYQILGDR.js → chunk-90egc9vb.js} +122 -102
- package/{chunk-Z6LVL5MC.js → chunk-91q5dc5r.js} +10 -14
- package/{chunk-U6VC4MU4.js → chunk-96jtrqk1.js} +2 -4
- package/{chunk-H57T64RA.js → chunk-996j61av.js} +28 -31
- package/{chunk-Q6FKWH66.js → chunk-9cxgb9jy.js} +137 -243
- package/{chunk-2ZBPWX7N.js → chunk-9q1gbmet.js} +62 -104
- package/chunk-9qtjh73q.js +344 -0
- package/{chunk-SR57FDTX.js → chunk-9raka469.js} +72 -155
- package/{chunk-V6K5U4YE.js → chunk-9vh4v046.js} +32 -41
- package/{chunk-AGIM7IMJ.js → chunk-9yr1fy7j.js} +14 -49
- package/{chunk-FGFJUFPS.js → chunk-a16x0wt6.js} +11 -18
- package/chunk-a5b2rvzs.js +131 -0
- package/{chunk-7DPNBQSV.js → chunk-a7bz6nc3.js} +3 -4
- package/chunk-ac85azv9.js +29 -0
- package/{chunk-VXL2FZTP.js → chunk-ahhbkad4.js} +16 -20
- package/{chunk-37DGW762.js → chunk-anhksj2j.js} +16 -29
- package/{cliAuthorityBrokerServer-27C5YBYP.js → chunk-atvmx76t.js} +180 -186
- package/{chunk-E6A5NHDH.js → chunk-av2mzeqz.js} +16 -17
- package/chunk-avbwrb0z.js +614 -0
- package/chunk-avr6rqe5.js +544 -0
- package/{workContextQueryProjection-CACY5VFE.js → chunk-axx60d5a.js} +7 -7
- package/{chunk-EWQ3HGNZ.js → chunk-b00vzjkb.js} +30 -23
- package/chunk-b0m6ezxr.js +132 -0
- package/chunk-bbd5mgdt.js +47 -0
- package/chunk-bcecft0r.js +28 -0
- package/chunk-beyr4pyp.js +33 -0
- package/{chunk-BR3GT6MR.js → chunk-bge0cagn.js} +7 -18
- package/{offlineMarxistsAgentCommand-MFURGWHL.js → chunk-bh53zg3t.js} +33 -43
- package/chunk-bmx1cw89.js +37 -0
- package/chunk-br2195h4.js +22 -0
- package/chunk-bsqkwveq.js +56 -0
- package/{chunk-DZJWSGCV.js → chunk-c09s2z1m.js} +139 -98
- package/chunk-c235kypv.js +24636 -0
- package/{chunk-2JMYAH5O.js → chunk-c30j6pyh.js} +213 -256
- package/chunk-c3v6r6sq.js +29 -0
- package/{chunk-NACE7NWO.js → chunk-c5z7qspt.js} +1177 -1196
- package/{chunk-GWB6AGME.js → chunk-c6jvz0mp.js} +34 -50
- package/{chunk-PRJ473FK.js → chunk-cd6h9qqs.js} +14 -12
- package/chunk-cdt0amyy.js +37 -0
- package/{chunk-2AJLG6PY.js → chunk-cfh6tfc3.js} +73 -86
- package/{chunk-WIVVNJUS.js → chunk-ch4ck1yz.js} +38 -68
- package/chunk-chtvrtp5.js +55 -0
- package/{chunk-EYLGAEB4.js → chunk-ckvz7abv.js} +170 -165
- package/{chunk-YZMNK53S.js → chunk-csf18m5w.js} +32 -25
- package/{chunk-C36L6ZID.js → chunk-cwnvf8dt.js} +2 -10
- package/chunk-cy7thb6n.js +19877 -0
- package/{dialogPortabilityCommands-YQJNB2KL.js → chunk-d61q9nah.js} +439 -487
- package/chunk-d6xdy0gp.js +142 -0
- package/{chunk-SCEPD46O.js → chunk-dh69vqbd.js} +6386 -6498
- package/{chunk-KJ4J2XQB.js → chunk-dj4ggbc6.js} +17 -19
- package/{chunk-LISC7BD4.js → chunk-djrrhbk3.js} +29 -37
- package/chunk-drqzzzvr.js +822 -0
- package/chunk-e1n7edjk.js +33 -0
- package/chunk-e3atr4hk.js +59 -0
- package/chunk-e9bn2aav.js +13 -0
- package/chunk-ed396rfq.js +87 -0
- package/chunk-eha8ggh6.js +10 -0
- package/{chunk-B7CTVEUV.js → chunk-ek122zzt.js} +893 -948
- package/chunk-epnmvek4.js +22 -0
- package/{chunk-S25VJYXV.js → chunk-eqzvk3xm.js} +69 -80
- package/chunk-ex34n71b.js +2874 -0
- package/{chunk-56OAS5RZ.js → chunk-f3ad6q4h.js} +7 -11
- package/{chunk-3PVYUPXK.js → chunk-f8jepva1.js} +6 -7
- package/{chunk-GH34JXNV.js → chunk-f9yvy9t9.js} +114 -92
- package/chunk-fbdz4f0j.js +90 -0
- package/{chunk-J44TXB4J.js → chunk-fcsc2day.js} +216 -164
- package/chunk-fevdhnbh.js +19 -0
- package/chunk-fkrgqq8w.js +3300 -0
- package/{chunk-TSBJVMNW.js → chunk-fs3bvh2p.js} +42 -57
- package/chunk-fvwzyhah.js +134 -0
- package/chunk-g0mpxdp9.js +101 -0
- package/{chunk-JGUHOA42.js → chunk-g35f20d1.js} +450 -414
- package/{chunk-3L2WKC3W.js → chunk-g5fhtjqg.js} +13 -16
- package/{chunk-APOIIIB4.js → chunk-gcq01td7.js} +270 -227
- package/{chunk-ADMRXWXJ.js → chunk-ge97b11r.js} +121 -42
- package/chunk-ghjtgbkw.js +180 -0
- package/chunk-gkra36c1.js +16 -0
- package/chunk-gmz86t60.js +1000 -0
- package/{localDialogRead-GWGWSL5K.js → chunk-gszpesze.js} +5 -12
- package/chunk-gvsfec9m.js +16536 -0
- package/{chunk-QSJ3HFEF.js → chunk-h1hzmqph.js} +1 -3
- package/chunk-h30dg154.js +17 -0
- package/chunk-h3hkb7cw.js +241 -0
- package/chunk-h40py996.js +28 -0
- package/{chunk-47T3QP4V.js → chunk-h60gnewh.js} +112 -116
- package/{agentPullCommand-XEGOUYQT.js → chunk-hkwsv9xf.js} +33 -45
- package/chunk-hnyg0gwj.js +28 -0
- package/{chunk-KSV6T4AH.js → chunk-hqqqph5w.js} +12 -4
- package/{chunk-YQJEXXDK.js → chunk-hrngs1wy.js} +157 -246
- package/{chunk-LRLLWD4P.js → chunk-htf69s94.js} +14 -12
- package/chunk-j0yxesh3.js +83 -0
- package/{chunk-VF4K2QE6.js → chunk-j22t9g05.js} +3 -6
- package/{chunk-3R4AYHJR.js → chunk-j4a8m2zn.js} +5 -34
- package/chunk-j9p4jnwg.js +27 -0
- package/{chunk-R72QWIFO.js → chunk-jdycmfsm.js} +9 -9
- package/chunk-jdyvrne0.js +52 -0
- package/{spacePruneCommand-YKIEUIDQ.js → chunk-je0b66qf.js} +44 -62
- package/{chunk-HNMXYYJR.js → chunk-jec44fkj.js} +3 -4
- package/{chunk-526GLZJE.js → chunk-jf1ex00r.js} +107 -73
- package/chunk-jgqdec9b.js +31 -0
- package/{chunk-56GBUMO5.js → chunk-jkw9n4h5.js} +16 -25
- package/{chunk-BY2CHBIZ.js → chunk-jmnzdwjt.js} +867 -965
- package/chunk-jqq57s0a.js +58 -0
- package/{chunk-OKUSDVRS.js → chunk-jtkn5aj6.js} +27 -38
- package/chunk-jwvzn9r0.js +316 -0
- package/chunk-k1re0fc7.js +107 -0
- package/chunk-k2ep3rb2.js +103 -0
- package/{chunk-JEXVIMYZ.js → chunk-k6ycb24w.js} +5 -8
- package/{chunk-RI7SXDJW.js → chunk-kawvydbk.js} +383 -195
- package/chunk-kf2ghpzh.js +10 -0
- package/{chunk-S6FAHQDH.js → chunk-kgah9e46.js} +28 -59
- package/{chunk-6A6CTCMC.js → chunk-kjjepkvc.js} +71 -82
- package/chunk-kn4dgg4j.js +4113 -0
- package/{chunk-2LFYMWM3.js → chunk-kn5p91n8.js} +43 -53
- package/{chunk-MVOZ22RZ.js → chunk-kntqrbwc.js} +8 -12
- package/{chunk-I6YIA2TY.js → chunk-kq3vr7mx.js} +25 -20
- package/chunk-kz1x1d8n.js +15 -0
- package/{mcpLocalAuthorizeCommand-IKOFKY5U.js → chunk-m22e7tt2.js} +53 -71
- package/{chunk-ZNFJWEN4.js → chunk-m32rwr4d.js} +11 -8
- package/chunk-m39e9m18.js +93 -0
- package/{chunk-4D4QD7FT.js → chunk-m5518371.js} +64 -56
- package/{chunk-LHTXSC2E.js → chunk-mb5hnfyp.js} +9 -11
- package/chunk-mexet11v.js +11 -0
- package/chunk-mg2hgfgh.js +185 -0
- package/chunk-mmdhm4kx.js +10317 -0
- package/chunk-mz002yz8.js +2821 -0
- package/chunk-mzadqnyq.js +56 -0
- package/{chunk-VIDPVFP3.js → chunk-n3r1ebdm.js} +5 -6
- package/chunk-n438qea7.js +33 -0
- package/chunk-n5ffnhnb.js +93 -0
- package/chunk-nbvd87fy.js +9 -0
- package/{chunk-E36V7MPY.js → chunk-ndej7jc9.js} +53 -43
- package/{chunk-B767MA64.js → chunk-nen6rwe4.js} +62 -22
- package/chunk-nf06tr3v.js +16 -0
- package/chunk-ng8z355q.js +16 -0
- package/{chunk-4MEKE5D3.js → chunk-nhtxfv8k.js} +78 -63
- package/{runAgentClientLoop-ELTV5MSJ.js → chunk-nj62jscj.js} +132 -214
- package/{chunk-GBWGPTA7.js → chunk-nkryrkyp.js} +16 -19
- package/chunk-nmesxem8.js +197 -0
- package/{chunk-YR4J7RFS.js → chunk-nmq0qwbn.js} +117 -164
- package/chunk-nph8brvw.js +7 -0
- package/chunk-nr8fees9.js +10 -0
- package/{chunk-DFI7MVCQ.js → chunk-nvewvf7h.js} +1441 -1427
- package/{chunk-G7Y4GXTY.js → chunk-nyamhphs.js} +70 -79
- package/chunk-nz1c8tcg.js +111 -0
- package/{chunk-GPLUFN2E.js → chunk-nzc5yffh.js} +176 -217
- package/{chunk-G3SUCT4W.js → chunk-p1vg4bx8.js} +2 -4
- package/chunk-p3k3abe8.js +202 -0
- package/chunk-p4zy30q5.js +8 -0
- package/{chunk-ZJACPM5O.js → chunk-p6se1rx0.js} +102 -102
- package/chunk-p9dpshev.js +6968 -0
- package/chunk-pa42wxr0.js +116 -0
- package/{chunk-TA5QI4MM.js → chunk-paxthgqp.js} +56 -107
- package/{readlineWorkspace-5EASNOQ4.js → chunk-pb35s8d9.js} +5395 -5786
- package/{chunk-XT6C2QZW.js → chunk-pbebzbcq.js} +8 -8
- package/chunk-pbx7e1mb.js +11 -0
- package/chunk-pe5czfn9.js +8 -0
- package/chunk-pextk1j4.js +62 -0
- package/chunk-pf5rywc6.js +575 -0
- package/chunk-pjfhd3fz.js +136 -0
- package/chunk-pkhqb0fs.js +243 -0
- package/chunk-pm5xb9jh.js +26 -0
- package/{chunk-Y3KGWZKF.js → chunk-ppdmmdkx.js} +110 -97
- package/chunk-pqp6y2hs.js +9 -0
- package/{chunk-QHEN7NZ7.js → chunk-ptz8fm2n.js} +12 -17
- package/{chunk-EUHMI5KG.js → chunk-pwqnvbt7.js} +65 -46
- package/chunk-pzr31nz7.js +12 -0
- package/{chunk-WWC7I6TA.js → chunk-q3cx89sw.js} +2 -4
- package/chunk-q5pe7be3.js +78 -0
- package/{chunk-ZHWTBHT3.js → chunk-q6zqbxp2.js} +418 -409
- package/chunk-q7r0e1p3.js +15 -0
- package/chunk-q8t2fecd.js +6 -0
- package/{chunk-2QAZCYOM.js → chunk-q94zx4d0.js} +721 -753
- package/{runtimeDoctorCommands-52MBG5JN.js → chunk-qarz1az1.js} +65 -85
- package/{chunk-4INJGWE3.js → chunk-qdcvr25b.js} +72 -53
- package/{streamAgentChatTurn-BL3ESUEN.js → chunk-qxs27wfg.js} +1079 -1475
- package/{chunk-GIXWVN2W.js → chunk-r06ycjjr.js} +50 -47
- package/{chunk-63W5N6P3.js → chunk-r20jw5hb.js} +57 -38
- package/{chunk-I5BYFTYK.js → chunk-r7sfwdka.js} +1201 -1142
- package/{chunk-UMADT6B2.js → chunk-r9sp1yyb.js} +6 -8
- package/{handleSendMessageAction-VQP5HT5I.js → chunk-rbd2vgb3.js} +627 -757
- package/chunk-rc37js46.js +12 -0
- package/{chunk-5YI447UL.js → chunk-rmngk6r3.js} +67 -76
- package/chunk-rnhbnbrq.js +15 -0
- package/{chunk-WRHVVIGI.js → chunk-rsfnmrt5.js} +111 -131
- package/{chunk-YFSM2366.js → chunk-rvvn2rhj.js} +28 -22
- package/{chunk-4Y6CZ2N4.js → chunk-s0fpz7ht.js} +37 -33
- package/{chunk-VI4SWTUO.js → chunk-s1cqzb2r.js} +77 -65
- package/{chunk-6QDYSCPW.js → chunk-s8q81tda.js} +73 -65
- package/chunk-s9hy639e.js +6 -0
- package/{chunk-R5GO3YZP.js → chunk-s9vbwme8.js} +115 -106
- package/chunk-sger1m1b.js +20 -0
- package/chunk-spe6crvk.js +60 -0
- package/chunk-spwsrvh9.js +70 -0
- package/chunk-sr05zpk7.js +573 -0
- package/{chunk-M2EJHDJP.js → chunk-srncrd3f.js} +1 -12
- package/{chunk-QXHFIX7W.js → chunk-sry80bpx.js} +71 -53
- package/{chunk-PSCNXBYA.js → chunk-t6q69p83.js} +3 -4
- package/{chunk-UAD2WT54.js → chunk-t714r4q0.js} +9 -28
- package/chunk-t7vbraqe.js +42 -0
- package/{chunk-CVMMWN6P.js → chunk-td7653rr.js} +10 -20
- package/{chunk-3BQDF4QB.js → chunk-tmytcetz.js} +17 -21
- package/{chunk-AMWMV56B.js → chunk-tta4prwg.js} +16 -15
- package/chunk-tvh8azgq.js +4829 -0
- package/{chunk-ID4G2MAR.js → chunk-v08kbfm8.js} +10 -11
- package/{chunk-IHU2ZFCQ.js → chunk-v1x702q8.js} +801 -852
- package/{chunk-KHCLMKZZ.js → chunk-v39fea91.js} +576 -247
- package/{chunk-OW765XBU.js → chunk-vejtd8p2.js} +3 -4
- package/chunk-vep7zkha.js +368 -0
- package/chunk-vfwn1k7n.js +142 -0
- package/chunk-vg68vxhx.js +20 -0
- package/chunk-vgcqgnsm.js +31 -0
- package/{chunk-NF64D32W.js → chunk-vnzyjdea.js} +1 -3
- package/{chunk-ZCLSM5AK.js → chunk-vqgtw1px.js} +800 -717
- package/chunk-vv1gr5xz.js +76 -0
- package/{spaceCommands-Z2CTQD6G.js → chunk-w1qeadpq.js} +176 -242
- package/chunk-w468ez1p.js +13 -0
- package/chunk-w49s0t79.js +14 -0
- package/{mcpLocalManageCommands-KUDZQRM4.js → chunk-w58zhfbn.js} +91 -93
- package/chunk-w5b74aq6.js +11 -0
- package/chunk-w7y41qyw.js +117 -0
- package/chunk-w820gg1w.js +4165 -0
- package/{chunk-DBJAJ4UD.js → chunk-wdsmaqmt.js} +399 -453
- package/{chunk-3EUW3WEO.js → chunk-wfvvnmmj.js} +1 -3
- package/{chunk-QY4NZCDA.js → chunk-wkr04bhk.js} +432 -651
- package/{chunk-KUG52IAP.js → chunk-ws402twv.js} +1 -3
- package/chunk-wzwh311q.js +164 -0
- package/{runtimeModeArgs-X7DL7PUN.js → chunk-x5vtgvwn.js} +6 -5
- package/{agentMachineCommands-AXPZRHUY.js → chunk-x8h2csmq.js} +152 -195
- package/{chunk-BAZCS5XG.js → chunk-x9zfjnrc.js} +59 -47
- package/{chunk-WTIJKWCI.js → chunk-xcarc2rf.js} +50 -56
- package/chunk-xf33gz0a.js +8 -0
- package/{chunk-PVFYPUIM.js → chunk-y7b3gwx1.js} +78 -71
- package/{memoryCommands-SVLAVFCV.js → chunk-y7sphmnh.js} +119 -95
- package/{agentListCommands-436FHOIT.js → chunk-ycvaafhc.js} +260 -374
- package/chunk-yd7zprb0.js +9 -0
- package/chunk-yfz3d27k.js +40 -0
- package/{chunk-MKR6KDD3.js → chunk-ykv9g3m4.js} +141 -125
- package/chunk-ystjgb9e.js +544 -0
- package/chunk-yysxn7ep.js +12 -0
- package/{chunk-AL3TYDIF.js → chunk-z17eyawk.js} +18 -16
- package/{machineCommands-LHJMILRA.js → chunk-z17q416p.js} +442 -563
- package/chunk-z1n98pcf.js +12 -0
- package/{dialogTraceCommand-HWXGIGZX.js → chunk-z566jx5r.js} +292 -397
- package/chunk-zjxd6942.js +6 -0
- package/{versionChangeNotice-RFABJGJE.js → chunk-zk11x9y5.js} +7 -9
- package/{chunk-TEFD5E2D.js → chunk-zt73yc33.js} +48 -51
- package/chunk-zvs2fra1.js +5 -0
- package/{chunk-SVFFKLMR.js → chunk-zwee84rh.js} +117 -141
- package/chunk-zxgfqv72.js +8 -0
- package/index.js +53 -69
- package/package.json +4 -4
- package/_executeModel-B3ENLKM4.js +0 -341
- package/action-UK3HXGXF.js +0 -30
- package/addContentAction-CAKFVBDM.js +0 -38
- package/addDialogAgentAction-KLJ2YWWM.js +0 -77
- package/agentDeleteCommand-R4LKLXQR.js +0 -523
- package/agentEmailCommands-SUEXVAY4.js +0 -742
- package/agentRecordCommands-NE4OPX5K.js +0 -211
- package/agentRun-NSNLIOM7.js +0 -251
- package/agentRunCommand-T6QTKMCJ.js +0 -249
- package/agentRunControl-U2MV74WR.js +0 -211
- package/agentRuntimeLocal-P4MMGIR6.js +0 -189
- package/agentSlice-FZJZONCT.js +0 -52
- package/appConfigCommands-W4JQHMOJ.js +0 -417
- package/appDeleteCommands-IXR47IAV.js +0 -183
- package/appDeployCommands-LB6DHDF4.js +0 -232
- package/appDeployStatusCommands-UQ6MJL6D.js +0 -204
- package/appGetCommands-M5JCTDDQ.js +0 -185
- package/appListCommands-TE3ZHE3I.js +0 -186
- package/appMigrateCommands-FOXH6R4B.js +0 -230
- package/appSourceCommands-3ACYB6I7.js +0 -279
- package/authCommand-I5OBJP5S.js +0 -66
- package/authCommands-I6KCGOCN.js +0 -54
- package/builtinSkillRegistry-MIXYSZUU.js +0 -35
- package/chromeOpsCommands-IZRCYDSW.js +0 -579
- package/chunk-24BICQPB.js +0 -25
- package/chunk-2E4BYAUE.js +0 -69
- package/chunk-2O72G3U2.js +0 -17157
- package/chunk-2OROOEOQ.js +0 -229
- package/chunk-2R6M34JP.js +0 -27225
- package/chunk-2SXN7LAY.js +0 -15
- package/chunk-35JIFLIG.js +0 -30
- package/chunk-3VXVE2LF.js +0 -12
- package/chunk-4DBTBNTX.js +0 -477
- package/chunk-4JH2UMJR.js +0 -40
- package/chunk-4SN6J65J.js +0 -38
- package/chunk-4TDUT2LC.js +0 -441
- package/chunk-5MMAK75Q.js +0 -15
- package/chunk-6NYQHXMV.js +0 -1737
- package/chunk-6R4IY46J.js +0 -14
- package/chunk-7K4J76JQ.js +0 -917
- package/chunk-7LR2IFUH.js +0 -100
- package/chunk-AETZ7AD6.js +0 -274
- package/chunk-ATNTHIZI.js +0 -13
- package/chunk-BPB3T5EU.js +0 -791
- package/chunk-BV3FLP2L.js +0 -133
- package/chunk-BVYHE6QD.js +0 -110
- package/chunk-BWJLEN6X.js +0 -1388
- package/chunk-CHOZJMJS.js +0 -78
- package/chunk-CYS6HOJ2.js +0 -1710
- package/chunk-D2LTQAGN.js +0 -464
- package/chunk-DALXH7BG.js +0 -3392
- package/chunk-DKEOYC4L.js +0 -15210
- package/chunk-DLXL4NSL.js +0 -1179
- package/chunk-DSBRIUX5.js +0 -23
- package/chunk-DWLEOOGR.js +0 -8
- package/chunk-E2KZNP6C.js +0 -13
- package/chunk-E5JV4DCB.js +0 -272
- package/chunk-EUGTFFO6.js +0 -42
- package/chunk-FBNVJ2TO.js +0 -294
- package/chunk-FGXG6OLW.js +0 -34
- package/chunk-FRFFUKGH.js +0 -3085
- package/chunk-G22P2J7O.js +0 -1775
- package/chunk-G5KDYBTG.js +0 -432
- package/chunk-GBXRKW26.js +0 -613
- package/chunk-HEVRQGGH.js +0 -106
- package/chunk-HHXF57CL.js +0 -180
- package/chunk-HI5RS2O4.js +0 -2109
- package/chunk-HJTI7RZV.js +0 -94
- package/chunk-HRWRIPTB.js +0 -531
- package/chunk-HYCVEESH.js +0 -2824
- package/chunk-I42VC5KR.js +0 -15
- package/chunk-IB5AR52X.js +0 -15
- package/chunk-IIRJ4P4I.js +0 -24
- package/chunk-IT3ZZRJE.js +0 -12
- package/chunk-IV6VUVLJ.js +0 -88
- package/chunk-J42X32PV.js +0 -472
- package/chunk-JDMWYVUF.js +0 -449
- package/chunk-JKVOKKMQ.js +0 -53
- package/chunk-JRTNUU5Z.js +0 -54
- package/chunk-K7HLFORE.js +0 -226
- package/chunk-KGBASAB5.js +0 -74
- package/chunk-KGKTN2NX.js +0 -25
- package/chunk-KX6YBIHG.js +0 -8
- package/chunk-KYHNSSL2.js +0 -62
- package/chunk-KZO2MTVM.js +0 -140
- package/chunk-L2DHCG6C.js +0 -779
- package/chunk-LKZPX6YH.js +0 -0
- package/chunk-LLP2NDED.js +0 -201
- package/chunk-LOFRSJX2.js +0 -47
- package/chunk-M75RM77T.js +0 -3970
- package/chunk-MDAYRIP7.js +0 -1889
- package/chunk-MI6HRMCK.js +0 -25
- package/chunk-MTNQNLSE.js +0 -1029
- package/chunk-NH4PUEWK.js +0 -762
- package/chunk-NHLLXINQ.js +0 -8
- package/chunk-NTUNHTJV.js +0 -40
- package/chunk-OJKUU3LP.js +0 -67
- package/chunk-OQH3TAB7.js +0 -299
- package/chunk-P62DHV4F.js +0 -443
- package/chunk-PHIERFHT.js +0 -574
- package/chunk-PKDFU6MY.js +0 -102
- package/chunk-PL5RKESU.js +0 -40
- package/chunk-PSJJBBWV.js +0 -42
- package/chunk-QKM55LP2.js +0 -739
- package/chunk-QQ56R7KS.js +0 -88
- package/chunk-QYPE3TS3.js +0 -43
- package/chunk-REAE2SZK.js +0 -62
- package/chunk-RGQ4UUWZ.js +0 -208
- package/chunk-RIRFHJTW.js +0 -353
- package/chunk-RYMLMTPZ.js +0 -547
- package/chunk-SSGTV4FC.js +0 -303
- package/chunk-SVKWZ3EG.js +0 -607
- package/chunk-T7KODHYS.js +0 -317
- package/chunk-TZXPT53C.js +0 -8
- package/chunk-U67V476Y.js +0 -35
- package/chunk-UEILX4EV.js +0 -15
- package/chunk-VIWDGTDA.js +0 -8
- package/chunk-VXUQWCEZ.js +0 -138
- package/chunk-W5GKF5ZW.js +0 -32
- package/chunk-WDWZPASX.js +0 -29
- package/chunk-WX266G2C.js +0 -9594
- package/chunk-YCITCYSJ.js +0 -356
- package/chunk-Z3KTXWWB.js +0 -76
- package/chunk-ZC3CMUKU.js +0 -322
- package/chunk-ZV7ZY46L.js +0 -1343
- package/cliAgentConfigHelpers-WB2S7PDO.js +0 -47
- package/cliAuthorityBrokerClient-3SKOA7OZ.js +0 -23
- package/cliAuthorityBrokerProcess-BMBVXPKU.js +0 -24
- package/cliAuthorityStoreDriver-6FE3BJNB.js +0 -20
- package/cliEnvHelpers-7V5ZWUJA.js +0 -34
- package/cliExecutor-N3445G2Z.js +0 -45
- package/cliLocalAgentRecordReader-QKKRK53P.js +0 -113
- package/cloudAutomationCommands-S52NKCLL.js +0 -310
- package/contentThunks-RK6MJWBY.js +0 -100
- package/cooldownCommands-ZFDAL4MR.js +0 -79
- package/createAgentAutomationAction-KN7XLCU2.js +0 -173
- package/createDialogAction-KAG6DBVM.js +0 -87
- package/createPageAction-7XNPH76L.js +0 -91
- package/cursorProvider-2RACMEMF.js +0 -6123
- package/db-LTHLW7QA.js +0 -178
- package/dbSlice-WNUHTF4C.js +0 -76
- package/deleteDbKey-MUCJP6DK.js +0 -87
- package/desktopFolderProjects-4POAMVJN.js +0 -45
- package/dialogCommands-4MOLJW4G.js +0 -165
- package/dialogMessageRecord-2HJTEXQX.js +0 -7
- package/dialogNotifyCommand-YL2GFKLO.js +0 -45
- package/dialogSlice-BD6WOOD3.js +0 -200
- package/dialogUsageCommand-IO2BQKL2.js +0 -31
- package/docCreateCommands-OYLRBK2M.js +0 -255
- package/docDeleteCommands-3NF6QPJU.js +0 -226
- package/docReadCommands-CBAERJAP.js +0 -184
- package/docStore-RK4CD4QN.js +0 -89
- package/docUpdateCommands-BAMCGX6F.js +0 -326
- package/ebookDownloaderAgentCommand-NOIZ6U7Y.js +0 -675
- package/fetchMessages-P7FSCSXV.js +0 -19
- package/getPricing-KNXVEIUI.js +0 -40
- package/hostCredentialCreate-CPIWBALC.js +0 -402
- package/i18n-SAK6DDY4.js +0 -51
- package/keys-FXEGMKSG.js +0 -183
- package/legacyMigration-TF4SYJCZ.js +0 -19
- package/levelAuthorityStore-L5SVDM5O.js +0 -10
- package/localAutomationCommands-WPYIYTDP.js +0 -199
- package/localAutomationRuntime-M7WWU6WY.js +0 -61
- package/localRecall-BDYKXB46.js +0 -17
- package/localRuntimeAdapter-SNE2NUDN.js +0 -310
- package/localRuntimeAuthority-Q5C2KWGF.js +0 -45
- package/localRuntimeDb-MM3DINZM.js +0 -12
- package/machineInfo-HNPJHQFU.js +0 -14
- package/machineWsRunDispatch-VHEIHXWY.js +0 -228
- package/models-TOXYINNM.js +0 -10
- package/oauthTokenStore-RUYNYALS.js +0 -24
- package/overlay-JA3SPVUS.js +0 -15
- package/parityCommands-5OCBPVES.js +0 -613
- package/processSpawn-6GEO77KV.js +0 -11
- package/profileConfig-KOWK4HOG.js +0 -49
- package/projectArchive-HUET56SH.js +0 -132
- package/providerPresetApply-YCVSP2WX.js +0 -235
- package/providerRegistry-26PAUYH2.js +0 -24
- package/read-D4WYJQJQ.js +0 -32
- package/readDocTool-3S3OQFOH.js +0 -22
- package/rememberExplicit-ZPI6KK5M.js +0 -16
- package/remove-AHRMUDMH.js +0 -32
- package/removeDialogAgentAction-AALRBFSA.js +0 -81
- package/secretCommands-2PSS3QNZ.js +0 -24
- package/setDialogExtraReferencesAction-SLHQ3GYL.js +0 -39
- package/setPrimaryDialogAgentAction-XKCSGJ7M.js +0 -96
- package/skillDiscovery-IUEZZG2B.js +0 -29
- package/skillSummaryMarker-62UW7HI7.js +0 -9
- package/slateToRenderMarkdown-R3X74MCX.js +0 -7
- package/slateUtils-ESQAJ6RN.js +0 -19
- package/store-WSAVTR32.js +0 -50
- package/switchDialogAgentAction-YJIWQGIR.js +0 -70
- package/tombstones-FQQMEDOW.js +0 -32
- package/toolApiClient-FVXTIIEN.js +0 -42
- package/tools-KB6CJ2KT.js +0 -147
- package/tuiRestart-LU2BDLAW.js +0 -50
- package/tuiSummaryLlmCaller-Z2ZVBIGN.js +0 -53
- package/updateCommands-4QP7WJLA.js +0 -63
- package/usageCommand-AZX7D3LB.js +0 -31
- package/usageRebuildCommand-XV5QQCHK.js +0 -623
- package/userDataMerge-HT2ZVHBJ.js +0 -13
- package/windowsSelfUpdate-5OFKSW6Y.js +0 -14
- package/workContext-ZAW6VXT7.js +0 -18
- package/workContextAccess-VU5I4LKZ.js +0 -11
- package/workContextWriteNotice-YCSSMHN4.js +0 -7
- /package/{chunk-BYXBJQAS.js → chunk-0bcc25vg.js} +0 -0
package/chunk-6NYQHXMV.js
DELETED
|
@@ -1,1737 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isMediaFile,
|
|
3
|
-
resolveFileCategory
|
|
4
|
-
} from "./chunk-3PVYUPXK.js";
|
|
5
|
-
import {
|
|
6
|
-
getDbEntityStore,
|
|
7
|
-
readAction,
|
|
8
|
-
readRequestManager,
|
|
9
|
-
resolveAgentReadServers
|
|
10
|
-
} from "./chunk-HRWRIPTB.js";
|
|
11
|
-
import {
|
|
12
|
-
emitUserDataUpdated,
|
|
13
|
-
loadFileFromIndexedDb,
|
|
14
|
-
removeAction,
|
|
15
|
-
saveFileToIndexedDb
|
|
16
|
-
} from "./chunk-T7KODHYS.js";
|
|
17
|
-
import {
|
|
18
|
-
beginWriteAck,
|
|
19
|
-
compareRemoteRecordsByComparableTime,
|
|
20
|
-
getRuntimeServerContext,
|
|
21
|
-
pickBestSettledRemoteRecord,
|
|
22
|
-
planAuthorityReadServers,
|
|
23
|
-
resolveAuthorityReplicationServers,
|
|
24
|
-
resolveRecordAuthority,
|
|
25
|
-
resolveUploadReplicationServers,
|
|
26
|
-
scheduleConfiguredPatchReplication,
|
|
27
|
-
scheduleExistingRecordReplication,
|
|
28
|
-
scheduleUploadReplication,
|
|
29
|
-
scheduleWriteReplication,
|
|
30
|
-
shouldPreferRemoteBodyOverLocalProjection,
|
|
31
|
-
shouldReplaceLocalWithRemoteRecord,
|
|
32
|
-
shouldReplicateLocalRecord,
|
|
33
|
-
uploadToCurrentServer
|
|
34
|
-
} from "./chunk-MTNQNLSE.js";
|
|
35
|
-
import {
|
|
36
|
-
noloDeleteRequest
|
|
37
|
-
} from "./chunk-YCITCYSJ.js";
|
|
38
|
-
import {
|
|
39
|
-
fetchFromClientDb,
|
|
40
|
-
fetchFromServer,
|
|
41
|
-
googleSessionRequestToken,
|
|
42
|
-
googleSessionServer,
|
|
43
|
-
logger,
|
|
44
|
-
normalizeTimeFields,
|
|
45
|
-
scopeGoogleSessionServers
|
|
46
|
-
} from "./chunk-K7HLFORE.js";
|
|
47
|
-
import {
|
|
48
|
-
isTombstoneRecord
|
|
49
|
-
} from "./chunk-BV3FLP2L.js";
|
|
50
|
-
import {
|
|
51
|
-
isPublicBuiltinPlatformAgentKey
|
|
52
|
-
} from "./chunk-4DBTBNTX.js";
|
|
53
|
-
import {
|
|
54
|
-
isRecord
|
|
55
|
-
} from "./chunk-KUG52IAP.js";
|
|
56
|
-
import {
|
|
57
|
-
fileKey,
|
|
58
|
-
getFileIdFromKey
|
|
59
|
-
} from "./chunk-DLXL4NSL.js";
|
|
60
|
-
import {
|
|
61
|
-
ulid
|
|
62
|
-
} from "./chunk-OJKUU3LP.js";
|
|
63
|
-
import {
|
|
64
|
-
API_ENDPOINTS
|
|
65
|
-
} from "./chunk-JKVOKKMQ.js";
|
|
66
|
-
|
|
67
|
-
// packages/database/protectedRecordProtocol.ts
|
|
68
|
-
var PROTECTED_RECORD_PROTOCOL_VERSION = 1;
|
|
69
|
-
function assertJson(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
70
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
71
|
-
if (typeof value === "number" && Number.isFinite(value)) return;
|
|
72
|
-
if (typeof value !== "object" || value === null || ancestors.has(value)) {
|
|
73
|
-
throw new TypeError("Invalid JSON value");
|
|
74
|
-
}
|
|
75
|
-
const array = Array.isArray(value);
|
|
76
|
-
const proto = Object.getPrototypeOf(value);
|
|
77
|
-
if (!array && proto !== Object.prototype && proto !== null) throw new TypeError("Invalid JSON object");
|
|
78
|
-
const keys = Reflect.ownKeys(value);
|
|
79
|
-
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
80
|
-
if (array && keys.length !== value.length + 1) throw new TypeError("Invalid JSON array");
|
|
81
|
-
ancestors.add(value);
|
|
82
|
-
try {
|
|
83
|
-
for (const key of keys) {
|
|
84
|
-
if (array && key === "length") continue;
|
|
85
|
-
if (typeof key !== "string") throw new TypeError("Invalid JSON key");
|
|
86
|
-
const descriptor = descriptors[key];
|
|
87
|
-
if (!descriptor.enumerable || !("value" in descriptor)) throw new TypeError("Invalid JSON property");
|
|
88
|
-
if (array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= value.length)) {
|
|
89
|
-
throw new TypeError("Invalid JSON array index");
|
|
90
|
-
}
|
|
91
|
-
assertJson(descriptor.value, ancestors);
|
|
92
|
-
}
|
|
93
|
-
} finally {
|
|
94
|
-
ancestors.delete(value);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function assertRecord(value) {
|
|
98
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected JSON record");
|
|
99
|
-
assertJson(value);
|
|
100
|
-
}
|
|
101
|
-
function envelope(value, fields) {
|
|
102
|
-
assertRecord(value);
|
|
103
|
-
if (value.protocolVersion !== PROTECTED_RECORD_PROTOCOL_VERSION) throw new TypeError("Unsupported protocolVersion");
|
|
104
|
-
if (Object.keys(value).some((key) => !fields.includes(key))) throw new TypeError("Unknown protocol field");
|
|
105
|
-
for (const key of ["mutationId", "authorityServer", "authorityEpoch"]) nonEmpty(value[key], key);
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
function nonEmpty(value, field) {
|
|
109
|
-
if (typeof value !== "string" || value.trim().length === 0) throw new TypeError(`Invalid ${field}`);
|
|
110
|
-
}
|
|
111
|
-
var identityFields = ["protocolVersion", "mutationId", "authorityServer", "authorityEpoch"];
|
|
112
|
-
function assertProtectedMutation(input) {
|
|
113
|
-
const value = envelope(input, [...identityFields, "operation", "payload", "expectedRevision", "createOnly"]);
|
|
114
|
-
if (value.operation !== "replace" && value.operation !== "patch") throw new TypeError("Unsupported operation");
|
|
115
|
-
assertRecord(value.payload);
|
|
116
|
-
if (Object.hasOwn(value, "createOnly")) {
|
|
117
|
-
if (value.createOnly !== true || Object.hasOwn(value, "expectedRevision") || value.operation !== "replace") {
|
|
118
|
-
throw new TypeError("Invalid create-only baseline");
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
nonEmpty(value.expectedRevision, "expectedRevision");
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function parseProtectedMutation(input) {
|
|
125
|
-
assertProtectedMutation(input);
|
|
126
|
-
return input;
|
|
127
|
-
}
|
|
128
|
-
function parseProtectedMutationAck(input) {
|
|
129
|
-
const value = envelope(input, [...identityFields, "revision", "record"]);
|
|
130
|
-
nonEmpty(value.revision, "revision");
|
|
131
|
-
assertRecord(value.record);
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// packages/database/actions/protectedRecordSync.ts
|
|
136
|
-
var PROTECTED_SYNC_PREFIX = "\0protected-record-sync:v1:";
|
|
137
|
-
var ProtectedSyncError = class extends Error {
|
|
138
|
-
constructor(code, message) {
|
|
139
|
-
super(message ?? code);
|
|
140
|
-
this.code = code;
|
|
141
|
-
this.name = "ProtectedSyncError";
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
var protectedPageBaselineKey = (actorId, dbKey) => `\0page-read-baseline:v1:${encodeURIComponent(actorId)}:${encodeURIComponent(dbKey)}`;
|
|
145
|
-
var encodeSegment = (value) => encodeURIComponent(value);
|
|
146
|
-
var protectedSyncWorkingCopyKey = (actorId, dbKey) => `${PROTECTED_SYNC_PREFIX}working:${encodeSegment(actorId)}:${encodeSegment(dbKey)}`;
|
|
147
|
-
var protectedSyncStateKey = (actorId, dbKey) => `${PROTECTED_SYNC_PREFIX}state:${encodeSegment(actorId)}:${encodeSegment(dbKey)}`;
|
|
148
|
-
var protectedSyncLockName = (actorId, dbKey) => `protected-record-sync:${encodeSegment(actorId)}:${encodeSegment(dbKey)}`;
|
|
149
|
-
var protectedSyncSendLockName = (actorId, dbKey) => `protected-record-send:${encodeSegment(actorId)}:${encodeSegment(dbKey)}`;
|
|
150
|
-
var isNotFound = (error) => !!error && typeof error === "object" && error.notFound === true;
|
|
151
|
-
async function readOptional(db, key) {
|
|
152
|
-
try {
|
|
153
|
-
return await db.get(key);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
if (isNotFound(error)) return void 0;
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function protectedSyncCopy(value) {
|
|
160
|
-
if (value === void 0) return value;
|
|
161
|
-
return JSON.parse(JSON.stringify(value));
|
|
162
|
-
}
|
|
163
|
-
function protectedSyncJsonEqual(left, right) {
|
|
164
|
-
if (left === right) return true;
|
|
165
|
-
if (typeof left !== typeof right) return false;
|
|
166
|
-
if (left === null || right === null) return false;
|
|
167
|
-
if (Array.isArray(left) || Array.isArray(right)) {
|
|
168
|
-
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
|
|
169
|
-
return left.every((item, index) => protectedSyncJsonEqual(item, right[index]));
|
|
170
|
-
}
|
|
171
|
-
if (typeof left === "object") {
|
|
172
|
-
const leftKeys = Object.keys(left).sort();
|
|
173
|
-
const rightKeys = Object.keys(right).sort();
|
|
174
|
-
if (leftKeys.length !== rightKeys.length) return false;
|
|
175
|
-
if (leftKeys.some((key, index) => key !== rightKeys[index])) return false;
|
|
176
|
-
return leftKeys.every(
|
|
177
|
-
(key) => protectedSyncJsonEqual(left[key], right[key])
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
var requireNonEmptyString = (value, field) => {
|
|
183
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
184
|
-
throw new ProtectedSyncError("INVALID_INPUT", `${field} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32`);
|
|
185
|
-
}
|
|
186
|
-
return value;
|
|
187
|
-
};
|
|
188
|
-
var requireJsonValue = (value, field) => {
|
|
189
|
-
if (value === void 0) {
|
|
190
|
-
throw new ProtectedSyncError("INVALID_INPUT", `${field} \u4E0D\u80FD\u662F undefined`);
|
|
191
|
-
}
|
|
192
|
-
try {
|
|
193
|
-
JSON.stringify(value);
|
|
194
|
-
} catch {
|
|
195
|
-
throw new ProtectedSyncError("INVALID_INPUT", `${field} \u5FC5\u987B\u662F\u53EF JSON \u5E8F\u5217\u5316\u7684\u6570\u636E`);
|
|
196
|
-
}
|
|
197
|
-
return value;
|
|
198
|
-
};
|
|
199
|
-
function createNavigatorLocksLock(namespace = "state") {
|
|
200
|
-
return async (scope, task) => {
|
|
201
|
-
const locks = globalThis.navigator?.locks;
|
|
202
|
-
if (!locks || typeof locks.request !== "function") {
|
|
203
|
-
throw new ProtectedSyncError(
|
|
204
|
-
"LOCK_UNAVAILABLE",
|
|
205
|
-
`navigator.locks \u4E0D\u53EF\u7528\uFF08${namespace} \u9501\uFF09\uFF1A\u6CA1\u6709\u53EF\u9760\u7684\u8DE8\u6807\u7B7E\u534F\u8C03\u5668\uFF0C\u62D2\u7EDD\u4EE5\u8FDB\u7A0B\u5185\u9501\u5192\u5145\u8DE8\u6807\u7B7E\u4E92\u65A5`
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
const name = (scope.namespace ?? namespace) === "send" ? protectedSyncSendLockName(scope.actorId, scope.dbKey) : protectedSyncLockName(scope.actorId, scope.dbKey);
|
|
209
|
-
const result = await locks.request(name, { mode: "exclusive" }, async () => task());
|
|
210
|
-
return result;
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function createProtectedRecordSync(deps) {
|
|
214
|
-
const { db } = deps;
|
|
215
|
-
const stateLock = deps.lock ?? createNavigatorLocksLock("state");
|
|
216
|
-
const sendLock = deps.sendLock ?? createNavigatorLocksLock("send");
|
|
217
|
-
const withStateLock = (scope, task) => stateLock({ ...scope, namespace: "state" }, task);
|
|
218
|
-
const withSendLock = (scope, task) => sendLock({ ...scope, namespace: "send" }, task);
|
|
219
|
-
const loadState = async (actorId, dbKey) => {
|
|
220
|
-
const [workingRaw, stateRaw] = await Promise.all([
|
|
221
|
-
readOptional(db, protectedSyncWorkingCopyKey(actorId, dbKey)),
|
|
222
|
-
readOptional(db, protectedSyncStateKey(actorId, dbKey))
|
|
223
|
-
]);
|
|
224
|
-
const working = workingRaw?.workingCopy ?? null;
|
|
225
|
-
const persisted = stateRaw ?? {};
|
|
226
|
-
const outbox = (Array.isArray(persisted.outbox) ? persisted.outbox : []).map((entry) => ({
|
|
227
|
-
...entry,
|
|
228
|
-
// 旧版本持久化的认领标志不再解释为占用:重启后队列必须可继续。
|
|
229
|
-
inFlight: false
|
|
230
|
-
}));
|
|
231
|
-
return protectedSyncCopy({
|
|
232
|
-
actorId,
|
|
233
|
-
dbKey,
|
|
234
|
-
workingCopy: working,
|
|
235
|
-
outbox,
|
|
236
|
-
baselineRevision: persisted.baselineRevision ?? null,
|
|
237
|
-
lastAck: persisted.lastAck ?? null,
|
|
238
|
-
legacyCandidates: Array.isArray(persisted.legacyCandidates) ? persisted.legacyCandidates : [],
|
|
239
|
-
remoteCandidate: persisted.remoteCandidate ?? null,
|
|
240
|
-
blocked: persisted.blocked ?? null,
|
|
241
|
-
nextSeq: typeof persisted.nextSeq === "number" ? persisted.nextSeq : 1
|
|
242
|
-
});
|
|
243
|
-
};
|
|
244
|
-
const persist = async (state, extra, discovery) => {
|
|
245
|
-
const operations = [
|
|
246
|
-
{
|
|
247
|
-
type: "put",
|
|
248
|
-
key: protectedSyncWorkingCopyKey(state.actorId, state.dbKey),
|
|
249
|
-
value: { workingCopy: state.workingCopy }
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
type: "put",
|
|
253
|
-
key: protectedSyncStateKey(state.actorId, state.dbKey),
|
|
254
|
-
value: {
|
|
255
|
-
outbox: state.outbox,
|
|
256
|
-
baselineRevision: state.baselineRevision,
|
|
257
|
-
lastAck: state.lastAck,
|
|
258
|
-
legacyCandidates: state.legacyCandidates,
|
|
259
|
-
remoteCandidate: state.remoteCandidate,
|
|
260
|
-
blocked: state.blocked,
|
|
261
|
-
nextSeq: state.nextSeq
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
];
|
|
265
|
-
if (extra) operations.push({ type: "put", key: extra.key, value: extra.value });
|
|
266
|
-
if (discovery) operations.push({ type: "put", key: discovery.key, value: discovery.value });
|
|
267
|
-
try {
|
|
268
|
-
await db.batch(operations);
|
|
269
|
-
} catch (error) {
|
|
270
|
-
throw new ProtectedSyncError(
|
|
271
|
-
"BATCH_FAILED",
|
|
272
|
-
`protected record sync \u843D\u76D8\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
const validateScope = (actorId, dbKey) => {
|
|
277
|
-
const actor = requireNonEmptyString(actorId, "actorId");
|
|
278
|
-
const key = requireNonEmptyString(dbKey, "dbKey");
|
|
279
|
-
if (key.startsWith("\0")) {
|
|
280
|
-
throw new ProtectedSyncError("INVALID_INPUT", "dbKey \u4E0D\u80FD\u4F7F\u7528\u5185\u90E8\u4FDD\u7559\u524D\u7F00");
|
|
281
|
-
}
|
|
282
|
-
return { actorId: actor, dbKey: key };
|
|
283
|
-
};
|
|
284
|
-
const applyAckUnlocked = async (state, mutationId, revision, record) => {
|
|
285
|
-
state.outbox = state.outbox.slice(1);
|
|
286
|
-
state.baselineRevision = revision;
|
|
287
|
-
state.lastAck = { mutationId, revision, record };
|
|
288
|
-
state.outbox = state.outbox.map((entry) => ({ ...entry, baseRevision: revision }));
|
|
289
|
-
if (state.workingCopy) {
|
|
290
|
-
state.workingCopy = state.workingCopy.mutationId === mutationId ? null : { ...state.workingCopy, baseRevision: revision };
|
|
291
|
-
}
|
|
292
|
-
await persist(state, { key: state.dbKey, value: protectedSyncCopy(record) });
|
|
293
|
-
return state;
|
|
294
|
-
};
|
|
295
|
-
const saveLocalDraft = async (input) => {
|
|
296
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
297
|
-
const authorityServer = requireNonEmptyString(input.authorityServer, "authorityServer");
|
|
298
|
-
const mutationId = requireNonEmptyString(input.mutationId, "mutationId");
|
|
299
|
-
const data = requireJsonValue(input.data, "data");
|
|
300
|
-
const baseRevision = input.baseRevision ?? null;
|
|
301
|
-
const intent = {};
|
|
302
|
-
if (input.operation !== void 0) {
|
|
303
|
-
const mutation = parseProtectedMutation({
|
|
304
|
-
protocolVersion: 1,
|
|
305
|
-
operation: input.operation,
|
|
306
|
-
payload: input.payload,
|
|
307
|
-
authorityEpoch: input.authorityEpoch,
|
|
308
|
-
authorityServer,
|
|
309
|
-
mutationId,
|
|
310
|
-
expectedRevision: baseRevision
|
|
311
|
-
});
|
|
312
|
-
intent.operation = "patch";
|
|
313
|
-
intent.payload = protectedSyncCopy(mutation.payload);
|
|
314
|
-
intent.authorityEpoch = mutation.authorityEpoch;
|
|
315
|
-
} else if (input.payload !== void 0 || input.authorityEpoch !== void 0) {
|
|
316
|
-
throw new ProtectedSyncError("INVALID_INPUT", "patch intent requires explicit operation");
|
|
317
|
-
}
|
|
318
|
-
return withStateLock(scope, async () => {
|
|
319
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
320
|
-
const existing = state.outbox.find((entry2) => entry2.mutationId === mutationId);
|
|
321
|
-
if (existing) {
|
|
322
|
-
if (!protectedSyncJsonEqual(existing.data, data) || existing.authorityServer !== authorityServer || existing.operation !== intent.operation || existing.authorityEpoch !== intent.authorityEpoch || !protectedSyncJsonEqual(existing.payload, intent.payload)) {
|
|
323
|
-
throw new ProtectedSyncError(
|
|
324
|
-
"MUTATION_ID_CONFLICT",
|
|
325
|
-
`mutationId ${mutationId} \u5DF2\u5B58\u5728\u4E14 payload \u4E0D\u540C\uFF1A\u62D2\u7EDD\u6539\u5199\u961F\u5217\u4E2D\u7684\u4E0D\u53EF\u53D8 payload`
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
return protectedSyncCopy(state);
|
|
329
|
-
}
|
|
330
|
-
const entry = {
|
|
331
|
-
...intent,
|
|
332
|
-
mutationId,
|
|
333
|
-
data: protectedSyncCopy(data),
|
|
334
|
-
baseRevision: baseRevision ?? state.baselineRevision,
|
|
335
|
-
authorityServer,
|
|
336
|
-
seq: state.nextSeq
|
|
337
|
-
};
|
|
338
|
-
state.outbox = [...state.outbox, entry];
|
|
339
|
-
state.nextSeq = state.nextSeq + 1;
|
|
340
|
-
state.workingCopy = {
|
|
341
|
-
...intent,
|
|
342
|
-
mutationId,
|
|
343
|
-
data: protectedSyncCopy(data),
|
|
344
|
-
baseRevision: entry.baseRevision,
|
|
345
|
-
authorityServer,
|
|
346
|
-
seq: entry.seq
|
|
347
|
-
};
|
|
348
|
-
await persist(state);
|
|
349
|
-
return protectedSyncCopy(state);
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
|
-
const ackMutation = async (input) => {
|
|
353
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
354
|
-
const mutationId = requireNonEmptyString(input.mutationId, "mutationId");
|
|
355
|
-
const revision = requireNonEmptyString(input.revision, "revision");
|
|
356
|
-
const record = requireJsonValue(input.record, "record");
|
|
357
|
-
return withStateLock(scope, async () => {
|
|
358
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
359
|
-
if (state.lastAck?.mutationId === mutationId) return protectedSyncCopy(state);
|
|
360
|
-
const head = state.outbox[0];
|
|
361
|
-
if (!head) {
|
|
362
|
-
throw new ProtectedSyncError("MUTATION_NOT_FOUND", `\u672A\u627E\u5230\u5F85\u786E\u8BA4\u7684 mutation\uFF1A${mutationId}`);
|
|
363
|
-
}
|
|
364
|
-
if (head.mutationId !== mutationId) {
|
|
365
|
-
const known = state.outbox.some((entry) => entry.mutationId === mutationId);
|
|
366
|
-
throw new ProtectedSyncError(
|
|
367
|
-
known ? "OUT_OF_ORDER" : "MUTATION_NOT_FOUND",
|
|
368
|
-
known ? `\u53EA\u5141\u8BB8\u786E\u8BA4\u961F\u9996\uFF1A\u5F53\u524D\u961F\u9996\u662F ${head.mutationId}\uFF0C\u4E0D\u662F ${mutationId}` : `\u672A\u627E\u5230\u5F85\u786E\u8BA4\u7684 mutation\uFF1A${mutationId}`
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
const next = await applyAckUnlocked(state, mutationId, revision, protectedSyncCopy(record));
|
|
372
|
-
return protectedSyncCopy(next);
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
const readState = async (input) => {
|
|
376
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
377
|
-
return withStateLock(scope, async () => protectedSyncCopy(await loadState(scope.actorId, scope.dbKey)));
|
|
378
|
-
};
|
|
379
|
-
const acceptRemote = async (input) => {
|
|
380
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
381
|
-
const record = requireJsonValue(input.record, "record");
|
|
382
|
-
const discovery = input.authority ? {
|
|
383
|
-
key: protectedPageBaselineKey(scope.actorId, scope.dbKey),
|
|
384
|
-
value: {
|
|
385
|
-
authorityServer: requireNonEmptyString(input.authority.authorityServer, "authorityServer"),
|
|
386
|
-
authorityEpoch: requireNonEmptyString(input.authority.authorityEpoch, "authorityEpoch"),
|
|
387
|
-
revision: input.revision
|
|
388
|
-
}
|
|
389
|
-
} : void 0;
|
|
390
|
-
return withStateLock(scope, async () => {
|
|
391
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
392
|
-
if (Array.isArray(input.legacyCandidates) && input.legacyCandidates.length > 0) {
|
|
393
|
-
const merged = [...state.legacyCandidates];
|
|
394
|
-
for (const candidate of input.legacyCandidates) {
|
|
395
|
-
const position = merged.findIndex((item) => item.candidateId === candidate.candidateId);
|
|
396
|
-
if (position === -1) merged.push(protectedSyncCopy(candidate));
|
|
397
|
-
else merged[position] = { ...merged[position], ...protectedSyncCopy(candidate) };
|
|
398
|
-
}
|
|
399
|
-
state.legacyCandidates = merged;
|
|
400
|
-
}
|
|
401
|
-
const hasPending = state.outbox.length > 0;
|
|
402
|
-
const hasWorking = state.workingCopy !== null;
|
|
403
|
-
const hasLegacy = state.legacyCandidates.length > 0;
|
|
404
|
-
if (hasPending || hasWorking || hasLegacy) {
|
|
405
|
-
state.remoteCandidate = { revision: input.revision ?? null, record: protectedSyncCopy(record) };
|
|
406
|
-
input.assertCurrentAccess?.();
|
|
407
|
-
await persist(state, void 0, discovery);
|
|
408
|
-
return {
|
|
409
|
-
applied: false,
|
|
410
|
-
reason: hasPending ? "pending-mutations" : hasWorking ? "working-copy" : "legacy-candidates",
|
|
411
|
-
state: protectedSyncCopy(state)
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
state.baselineRevision = input.revision ?? state.baselineRevision;
|
|
415
|
-
state.remoteCandidate = null;
|
|
416
|
-
state.workingCopy = null;
|
|
417
|
-
input.assertCurrentAccess?.();
|
|
418
|
-
await persist(state, { key: scope.dbKey, value: protectedSyncCopy(record) }, discovery);
|
|
419
|
-
return { applied: true, reason: null, state: protectedSyncCopy(state) };
|
|
420
|
-
});
|
|
421
|
-
};
|
|
422
|
-
const markBlocked = async (input) => {
|
|
423
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
424
|
-
const reason = requireNonEmptyString(input.reason, "reason");
|
|
425
|
-
return withStateLock(scope, async () => {
|
|
426
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
427
|
-
state.blocked = { reason, detail: input.detail ?? null, at: Date.now() };
|
|
428
|
-
await persist(state);
|
|
429
|
-
return protectedSyncCopy(state);
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
const clearBlocked = async (input) => {
|
|
433
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
434
|
-
return withStateLock(scope, async () => {
|
|
435
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
436
|
-
state.blocked = null;
|
|
437
|
-
await persist(state);
|
|
438
|
-
return protectedSyncCopy(state);
|
|
439
|
-
});
|
|
440
|
-
};
|
|
441
|
-
const beginInFlight = async (input) => {
|
|
442
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
443
|
-
return withStateLock(scope, async () => {
|
|
444
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
445
|
-
if (state.blocked) {
|
|
446
|
-
throw new ProtectedSyncError("BLOCKED", `\u8BB0\u5F55\u5904\u4E8E blocked \u72B6\u6001\uFF1A${state.blocked.reason}`);
|
|
447
|
-
}
|
|
448
|
-
const head = state.outbox[0];
|
|
449
|
-
if (!head) {
|
|
450
|
-
throw new ProtectedSyncError("MUTATION_NOT_FOUND", "\u5F85\u53D1\u961F\u5217\u4E3A\u7A7A");
|
|
451
|
-
}
|
|
452
|
-
if (input.mutationId !== void 0 && input.mutationId !== head.mutationId) {
|
|
453
|
-
throw new ProtectedSyncError(
|
|
454
|
-
"OUT_OF_ORDER",
|
|
455
|
-
`\u961F\u5217\u5FC5\u987B\u6309\u5E8F\u53D1\u9001\uFF1A\u5F53\u524D\u961F\u9996\u662F ${head.mutationId}\uFF0C\u4E0D\u662F ${input.mutationId}`
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
return protectedSyncCopy(state);
|
|
459
|
-
});
|
|
460
|
-
};
|
|
461
|
-
const releaseInFlight = async (input) => {
|
|
462
|
-
const scope = validateScope(input?.actorId, input?.dbKey);
|
|
463
|
-
requireNonEmptyString(input.mutationId, "mutationId");
|
|
464
|
-
return withStateLock(scope, async () => protectedSyncCopy(await loadState(scope.actorId, scope.dbKey)));
|
|
465
|
-
};
|
|
466
|
-
const withNextMutation = async (scopeInput, send) => {
|
|
467
|
-
const scope = validateScope(scopeInput?.actorId, scopeInput?.dbKey);
|
|
468
|
-
if (typeof send !== "function") {
|
|
469
|
-
throw new ProtectedSyncError("INVALID_INPUT", "send \u5FC5\u987B\u662F\u51FD\u6570");
|
|
470
|
-
}
|
|
471
|
-
const snapshot = await withStateLock(scope, async () => {
|
|
472
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
473
|
-
if (state.blocked) {
|
|
474
|
-
throw new ProtectedSyncError("BLOCKED", `\u8BB0\u5F55\u5904\u4E8E blocked \u72B6\u6001\uFF1A${state.blocked.reason}`);
|
|
475
|
-
}
|
|
476
|
-
const head = state.outbox[0];
|
|
477
|
-
return { state: protectedSyncCopy(state), entry: head ? protectedSyncCopy(head) : null };
|
|
478
|
-
});
|
|
479
|
-
if (!snapshot.entry) {
|
|
480
|
-
return { mutationId: null, outcome: "none", state: snapshot.state };
|
|
481
|
-
}
|
|
482
|
-
const entry = snapshot.entry;
|
|
483
|
-
return withSendLock(scope, async () => {
|
|
484
|
-
const ready = await withStateLock(scope, async () => {
|
|
485
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
486
|
-
const head = state.outbox[0];
|
|
487
|
-
const same = !!head && head.mutationId === entry.mutationId && head.baseRevision === entry.baseRevision;
|
|
488
|
-
return { state, same };
|
|
489
|
-
});
|
|
490
|
-
if (!ready.same) {
|
|
491
|
-
return {
|
|
492
|
-
mutationId: null,
|
|
493
|
-
outcome: "none",
|
|
494
|
-
skipped: true,
|
|
495
|
-
state: protectedSyncCopy(ready.state)
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
const result = await send(protectedSyncCopy(entry));
|
|
499
|
-
return withStateLock(scope, async () => {
|
|
500
|
-
const state = await loadState(scope.actorId, scope.dbKey);
|
|
501
|
-
if (result?.outcome === "acked") {
|
|
502
|
-
const revision = requireNonEmptyString(result.revision, "revision");
|
|
503
|
-
const record = requireJsonValue(result.record, "record");
|
|
504
|
-
if (state.lastAck?.mutationId === entry.mutationId) {
|
|
505
|
-
return { mutationId: entry.mutationId, outcome: "acked", state: protectedSyncCopy(state) };
|
|
506
|
-
}
|
|
507
|
-
const head = state.outbox[0];
|
|
508
|
-
if (!head || head.mutationId !== entry.mutationId) {
|
|
509
|
-
return {
|
|
510
|
-
mutationId: null,
|
|
511
|
-
outcome: "none",
|
|
512
|
-
skipped: true,
|
|
513
|
-
state: protectedSyncCopy(state)
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
const next = await applyAckUnlocked(state, entry.mutationId, revision, protectedSyncCopy(record));
|
|
517
|
-
return { mutationId: entry.mutationId, outcome: "acked", state: protectedSyncCopy(next) };
|
|
518
|
-
}
|
|
519
|
-
if (result?.outcome === "pending") {
|
|
520
|
-
return {
|
|
521
|
-
mutationId: entry.mutationId,
|
|
522
|
-
outcome: "pending",
|
|
523
|
-
reason: result.reason,
|
|
524
|
-
state: protectedSyncCopy(state)
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
if (result?.outcome === "conflict" || result?.outcome === "blocked") {
|
|
528
|
-
const reason = requireNonEmptyString(result.reason, "reason");
|
|
529
|
-
const stillPending = state.outbox.some((item) => item.mutationId === entry.mutationId);
|
|
530
|
-
if (stillPending) {
|
|
531
|
-
state.blocked = { reason, detail: result.detail ?? null, at: Date.now() };
|
|
532
|
-
await persist(state);
|
|
533
|
-
}
|
|
534
|
-
return {
|
|
535
|
-
mutationId: entry.mutationId,
|
|
536
|
-
outcome: result.outcome,
|
|
537
|
-
reason,
|
|
538
|
-
state: protectedSyncCopy(state)
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
throw new ProtectedSyncError("INVALID_INPUT", "send \u5FC5\u987B\u8FD4\u56DE acked/conflict/blocked/pending");
|
|
542
|
-
});
|
|
543
|
-
});
|
|
544
|
-
};
|
|
545
|
-
return {
|
|
546
|
-
saveLocalDraft,
|
|
547
|
-
ackMutation,
|
|
548
|
-
readState,
|
|
549
|
-
acceptRemote,
|
|
550
|
-
markBlocked,
|
|
551
|
-
clearBlocked,
|
|
552
|
-
beginInFlight,
|
|
553
|
-
releaseInFlight,
|
|
554
|
-
withNextMutation
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// packages/database/actions/protectedRecordTransport.ts
|
|
559
|
-
function createProtectedRecordTransport(options) {
|
|
560
|
-
return {
|
|
561
|
-
sendNext(scope) {
|
|
562
|
-
return options.sync.withNextMutation(scope, async (entry) => {
|
|
563
|
-
const blocked = (reason) => ({ outcome: "blocked", reason });
|
|
564
|
-
if (entry.operation !== "patch") return blocked("PATCH_INTENT_REQUIRED");
|
|
565
|
-
if (!entry.authorityEpoch?.trim()) return blocked("AUTHORITY_EPOCH_REQUIRED");
|
|
566
|
-
if (!entry.baseRevision?.trim()) return blocked("BASE_REVISION_REQUIRED");
|
|
567
|
-
if (!/^page-[A-Za-z0-9_-]+$/.test(scope.dbKey)) return blocked("UNSUPPORTED_DB_KEY");
|
|
568
|
-
let mutation;
|
|
569
|
-
let origin;
|
|
570
|
-
try {
|
|
571
|
-
origin = new URL(entry.authorityServer);
|
|
572
|
-
if (!["http:", "https:"].includes(origin.protocol) || origin.username || origin.password || origin.search || origin.hash || origin.pathname !== "/") return blocked("INVALID_AUTHORITY");
|
|
573
|
-
mutation = parseProtectedMutation({
|
|
574
|
-
protocolVersion: 1,
|
|
575
|
-
operation: "patch",
|
|
576
|
-
payload: entry.payload,
|
|
577
|
-
expectedRevision: entry.baseRevision,
|
|
578
|
-
mutationId: entry.mutationId,
|
|
579
|
-
authorityServer: entry.authorityServer,
|
|
580
|
-
authorityEpoch: entry.authorityEpoch
|
|
581
|
-
});
|
|
582
|
-
} catch {
|
|
583
|
-
return blocked("INVALID_PATCH_INTENT");
|
|
584
|
-
}
|
|
585
|
-
let response;
|
|
586
|
-
try {
|
|
587
|
-
if (!await options.isAuthorityAllowed(origin.origin)) return blocked("AUTHORITY_NOT_CONFIGURED");
|
|
588
|
-
const token = await options.getToken({ actorId: scope.actorId, authorityServer: entry.authorityServer });
|
|
589
|
-
if (!token) return blocked("AUTH_REQUIRED");
|
|
590
|
-
response = await options.fetch(`${origin.origin}/api/v1/db/patch/${scope.dbKey}`, {
|
|
591
|
-
method: "PATCH",
|
|
592
|
-
redirect: "error",
|
|
593
|
-
credentials: "omit",
|
|
594
|
-
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
595
|
-
body: JSON.stringify(mutation)
|
|
596
|
-
});
|
|
597
|
-
} catch {
|
|
598
|
-
return { outcome: "pending", reason: "NETWORK_OR_CREDENTIALS_UNAVAILABLE" };
|
|
599
|
-
}
|
|
600
|
-
if (response.status === 409) return { outcome: "conflict", reason: "HTTP_409" };
|
|
601
|
-
if (response.status === 401 || response.status === 403) return blocked(`HTTP_${response.status}`);
|
|
602
|
-
if (response.status === 503) return { outcome: "pending", reason: "PROTOCOL_UNAVAILABLE" };
|
|
603
|
-
if (!response.ok) return blocked(`HTTP_${response.status}`);
|
|
604
|
-
try {
|
|
605
|
-
const ack = parseProtectedMutationAck(await response.json());
|
|
606
|
-
if (ack.mutationId !== entry.mutationId || ack.authorityServer !== entry.authorityServer || ack.authorityEpoch !== entry.authorityEpoch) return blocked("ACK_IDENTITY_MISMATCH");
|
|
607
|
-
return { outcome: "acked", revision: ack.revision, record: ack.record };
|
|
608
|
-
} catch {
|
|
609
|
-
return blocked("INVALID_ACK");
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// packages/database/actions/protectedPageRead.ts
|
|
617
|
-
var baselineKey = protectedPageBaselineKey;
|
|
618
|
-
var originOf = (value) => {
|
|
619
|
-
try {
|
|
620
|
-
const url = new URL(value ?? "");
|
|
621
|
-
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && url.pathname === "/" && !url.search && !url.hash ? url.origin : null;
|
|
622
|
-
} catch {
|
|
623
|
-
return null;
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
async function getPageReadBaseline(db, actorId, dbKey) {
|
|
627
|
-
try {
|
|
628
|
-
const value = await db.get(baselineKey(actorId, dbKey));
|
|
629
|
-
if (!value) {
|
|
630
|
-
const state = await db.get(protectedSyncStateKey(actorId, dbKey));
|
|
631
|
-
if (state) throw Error("\u6587\u6863\u4FDD\u62A4\u72B6\u6001\u5B58\u5728\u4F46\u57FA\u7EBF\u7F3A\u5931\uFF0C\u5DF2\u963B\u6B62\u9000\u56DE\u65E7\u8BFB\u5199\u8DEF\u5F84");
|
|
632
|
-
}
|
|
633
|
-
return value ?? null;
|
|
634
|
-
} catch (error) {
|
|
635
|
-
if (error && typeof error === "object" && "notFound" in error && error.notFound === true) {
|
|
636
|
-
let state;
|
|
637
|
-
try {
|
|
638
|
-
state = await db.get(protectedSyncStateKey(actorId, dbKey));
|
|
639
|
-
} catch (stateError) {
|
|
640
|
-
if (!(stateError && typeof stateError === "object" && "notFound" in stateError && stateError.notFound === true)) throw stateError;
|
|
641
|
-
}
|
|
642
|
-
if (state) throw Error("\u6587\u6863\u4FDD\u62A4\u72B6\u6001\u5B58\u5728\u4F46\u57FA\u7EBF\u7F3A\u5931\uFF0C\u5DF2\u963B\u6B62\u9000\u56DE\u65E7\u8BFB\u5199\u8DEF\u5F84");
|
|
643
|
-
return null;
|
|
644
|
-
}
|
|
645
|
-
throw error;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
async function readProtectedPage(options) {
|
|
649
|
-
const { db, actorId, dbKey } = options;
|
|
650
|
-
const assertAccess = (origin) => {
|
|
651
|
-
const access2 = options.getCurrentAccess?.() ?? options;
|
|
652
|
-
if (access2.actorId !== actorId || !access2.token?.trim()) {
|
|
653
|
-
throw Error("\u6587\u6863\u8BFB\u53D6\u8EAB\u4EFD\u5DF2\u53D8\u5316\u6216\u8BA4\u8BC1\u5DF2\u64A4\u9500\uFF0C\u5DF2\u505C\u6B62\u8BFB\u53D6");
|
|
654
|
-
}
|
|
655
|
-
if (origin && !access2.servers.some((server) => originOf(server) === origin)) {
|
|
656
|
-
throw Error("\u6587\u6863\u5F52\u5C5E\u670D\u52A1\u5668\u4E0D\u5728\u5DF2\u914D\u7F6E\u670D\u52A1\u5668\u4E2D\u6216\u5DF2\u79FB\u9664\uFF0C\u672A\u53D1\u9001\u8BA4\u8BC1\u4FE1\u606F\uFF0C\u672A\u8F6C\u53D1\u8BA4\u8BC1\u4FE1\u606F");
|
|
657
|
-
}
|
|
658
|
-
return origin ? googleSessionRequestToken(access2.token, origin) : access2.token;
|
|
659
|
-
};
|
|
660
|
-
assertAccess();
|
|
661
|
-
const sync = options.sync ?? createProtectedRecordSync({ db });
|
|
662
|
-
const saved = await getPageReadBaseline(db, actorId, dbKey);
|
|
663
|
-
assertAccess(saved?.authorityServer);
|
|
664
|
-
if (saved) {
|
|
665
|
-
const state = await sync.readState({ actorId, dbKey });
|
|
666
|
-
if (state.workingCopy) {
|
|
667
|
-
if (options.getCurrentAccess && !state.blocked && !state.legacyCandidates.length) {
|
|
668
|
-
const transport = createProtectedRecordTransport({
|
|
669
|
-
sync,
|
|
670
|
-
fetch: options.fetch,
|
|
671
|
-
isAuthorityAllowed: (origin) => {
|
|
672
|
-
const access2 = options.getCurrentAccess();
|
|
673
|
-
return access2.actorId === actorId && access2.servers.some((server) => originOf(server) === origin);
|
|
674
|
-
},
|
|
675
|
-
getToken: async ({ authorityServer }) => assertAccess(authorityServer)
|
|
676
|
-
});
|
|
677
|
-
for (let count = 0; count < state.outbox.length; count++) {
|
|
678
|
-
if ((await transport.sendNext({ actorId, dbKey })).outcome !== "acked") break;
|
|
679
|
-
}
|
|
680
|
-
const latest = await sync.readState({ actorId, dbKey });
|
|
681
|
-
assertAccess(saved.authorityServer);
|
|
682
|
-
return latest.workingCopy?.data ?? latest.lastAck?.record ?? state.workingCopy.data;
|
|
683
|
-
}
|
|
684
|
-
assertAccess(saved.authorityServer);
|
|
685
|
-
return state.workingCopy.data;
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
const access = options.getCurrentAccess?.() ?? options;
|
|
689
|
-
const googleAuthority = googleSessionServer(access.token);
|
|
690
|
-
const servers = saved ? [saved.authorityServer] : options.servers.filter((server) => access.servers.some((candidate) => originOf(candidate) === originOf(server)) && (!googleAuthority || originOf(server) === googleAuthority));
|
|
691
|
-
for (const server of servers) {
|
|
692
|
-
const origin = originOf(server);
|
|
693
|
-
if (!origin) continue;
|
|
694
|
-
const token = assertAccess(origin);
|
|
695
|
-
let response;
|
|
696
|
-
try {
|
|
697
|
-
response = await options.fetch(`${origin}/api/v1/db/read/${encodeURIComponent(dbKey)}`, {
|
|
698
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
699
|
-
redirect: "error",
|
|
700
|
-
credentials: "omit",
|
|
701
|
-
signal: AbortSignal.timeout(5e3)
|
|
702
|
-
});
|
|
703
|
-
} catch {
|
|
704
|
-
assertAccess(origin);
|
|
705
|
-
continue;
|
|
706
|
-
}
|
|
707
|
-
assertAccess(origin);
|
|
708
|
-
if (!response.ok) continue;
|
|
709
|
-
const authorityServer = originOf(response.headers.get("X-Nolo-Authority-Server"));
|
|
710
|
-
const authorityEpoch = response.headers.get("X-Nolo-Authority-Epoch");
|
|
711
|
-
if (!authorityServer || !authorityEpoch?.trim()) continue;
|
|
712
|
-
const authorityToken = assertAccess(authorityServer);
|
|
713
|
-
if (authorityServer !== origin) {
|
|
714
|
-
response = await options.fetch(`${authorityServer}/api/v1/db/read/${encodeURIComponent(dbKey)}`, {
|
|
715
|
-
headers: { Authorization: `Bearer ${authorityToken}` },
|
|
716
|
-
redirect: "error",
|
|
717
|
-
credentials: "omit",
|
|
718
|
-
signal: AbortSignal.timeout(5e3)
|
|
719
|
-
});
|
|
720
|
-
if (!response.ok || response.headers.get("X-Nolo-Authority-Server") !== authorityServer || response.headers.get("X-Nolo-Authority-Epoch") !== authorityEpoch) throw Error("\u6587\u6863\u5F52\u5C5E\u6821\u9A8C\u5931\u8D25\uFF0C\u672A\u91C7\u7528\u526F\u672C");
|
|
721
|
-
}
|
|
722
|
-
if (saved && (saved.authorityServer !== authorityServer || saved.authorityEpoch !== authorityEpoch)) {
|
|
723
|
-
throw Error("\u6587\u6863\u5F52\u5C5E\u5DF2\u5207\u6362\uFF0C\u4FDD\u7559\u672C\u5730\u5185\u5BB9\uFF0C\u9700\u91CD\u65B0\u786E\u8BA4\u5F52\u5C5E");
|
|
724
|
-
}
|
|
725
|
-
const etag = response.headers.get("ETag");
|
|
726
|
-
if (!etag || !/^"[^"\r\n]+"$/.test(etag)) throw Error("\u6587\u6863\u670D\u52A1\u5668\u672A\u8FD4\u56DE\u6709\u6548\u7248\u672C\u57FA\u7EBF");
|
|
727
|
-
const record = await response.json();
|
|
728
|
-
if (!record || record.type !== "page") throw Error("\u6587\u6863\u5F52\u5C5E\u670D\u52A1\u5668\u8FD4\u56DE\u4E86\u65E0\u6548\u8BB0\u5F55");
|
|
729
|
-
const local = await db.get(dbKey).catch((error) => {
|
|
730
|
-
if (error && typeof error === "object" && "notFound" in error && error.notFound === true) return void 0;
|
|
731
|
-
throw error;
|
|
732
|
-
});
|
|
733
|
-
const localIsProjection = shouldPreferRemoteBodyOverLocalProjection(local, record);
|
|
734
|
-
const candidates = !saved && local && !localIsProjection && JSON.stringify(local) !== JSON.stringify(record) ? [{ candidateId: "legacy-local", source: "local", record: local, revision: null, observedAt: null }] : void 0;
|
|
735
|
-
assertAccess(authorityServer);
|
|
736
|
-
const result = await sync.acceptRemote({
|
|
737
|
-
actorId,
|
|
738
|
-
dbKey,
|
|
739
|
-
record,
|
|
740
|
-
revision: etag.slice(1, -1),
|
|
741
|
-
authority: { authorityServer, authorityEpoch },
|
|
742
|
-
legacyCandidates: candidates,
|
|
743
|
-
assertCurrentAccess: () => {
|
|
744
|
-
assertAccess(authorityServer);
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
assertAccess(authorityServer);
|
|
748
|
-
return result.state.workingCopy?.data ?? (!result.applied && local ? local : record);
|
|
749
|
-
}
|
|
750
|
-
if (saved) {
|
|
751
|
-
const local = await db.get(dbKey);
|
|
752
|
-
assertAccess(saved.authorityServer);
|
|
753
|
-
if (local) return local;
|
|
754
|
-
throw Error("\u6587\u6863\u6743\u5A01\u670D\u52A1\u5668\u4E0D\u53EF\u7528\uFF0C\u4E14\u6CA1\u6709\u672C\u5730\u7F13\u5B58");
|
|
755
|
-
}
|
|
756
|
-
assertAccess();
|
|
757
|
-
return void 0;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// packages/database/actions/readAndWait.ts
|
|
761
|
-
var hashTokenScope = (currentToken) => {
|
|
762
|
-
const token = currentToken || "";
|
|
763
|
-
if (!token) return "anonymous";
|
|
764
|
-
let hash = 0;
|
|
765
|
-
for (let index = 0; index < token.length; index += 1) {
|
|
766
|
-
hash = (hash << 5) - hash + token.charCodeAt(index) | 0;
|
|
767
|
-
}
|
|
768
|
-
return `token:${Math.abs(hash).toString(36)}`;
|
|
769
|
-
};
|
|
770
|
-
var buildReadAndWaitRequestKey = (dbKey, currentToken) => `${dbKey}\0auth:${hashTokenScope(currentToken)}`;
|
|
771
|
-
var isRemoteDataNewer = (remoteData, localData) => {
|
|
772
|
-
return compareRemoteRecordsByComparableTime(remoteData, localData) > 0;
|
|
773
|
-
};
|
|
774
|
-
var syncLocalDataToServer = async (replicationContext, dbKey, localData) => {
|
|
775
|
-
try {
|
|
776
|
-
scheduleExistingRecordReplication({
|
|
777
|
-
currentServer: replicationContext.currentServer,
|
|
778
|
-
syncServers: replicationContext.syncServers,
|
|
779
|
-
dbKey,
|
|
780
|
-
localData,
|
|
781
|
-
state: replicationContext.state
|
|
782
|
-
});
|
|
783
|
-
} catch {
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
var processRemoteData = async (db, dbKey, remotePromises, localData, replicationContext) => {
|
|
787
|
-
try {
|
|
788
|
-
const settledResults = await Promise.allSettled(remotePromises);
|
|
789
|
-
const remoteResult = pickBestSettledRemoteRecord({
|
|
790
|
-
settledResults,
|
|
791
|
-
isBetterCandidate: (current, latest) => compareRemoteRecordsByComparableTime(current, latest) > 0
|
|
792
|
-
});
|
|
793
|
-
const validRemoteData = remoteResult ? remoteResult.data : null;
|
|
794
|
-
if (shouldReplaceLocalWithRemoteRecord({
|
|
795
|
-
localData,
|
|
796
|
-
remoteData: validRemoteData,
|
|
797
|
-
isRemoteNewer: isRemoteDataNewer,
|
|
798
|
-
fromDetailRead: true
|
|
799
|
-
})) {
|
|
800
|
-
await db.put(dbKey, validRemoteData);
|
|
801
|
-
return validRemoteData;
|
|
802
|
-
}
|
|
803
|
-
if (localData) {
|
|
804
|
-
if (shouldReplicateLocalRecord({
|
|
805
|
-
localData,
|
|
806
|
-
remoteData: validRemoteData,
|
|
807
|
-
remoteTargetCount: remotePromises.length
|
|
808
|
-
})) {
|
|
809
|
-
void syncLocalDataToServer(replicationContext, dbKey, localData);
|
|
810
|
-
}
|
|
811
|
-
return localData;
|
|
812
|
-
}
|
|
813
|
-
throw new Error("Failed to fetch data from all sources");
|
|
814
|
-
} catch (err) {
|
|
815
|
-
if (localData) {
|
|
816
|
-
return localData;
|
|
817
|
-
}
|
|
818
|
-
throw err;
|
|
819
|
-
}
|
|
820
|
-
};
|
|
821
|
-
var readAndWaitAction = async (payload, thunkApi) => {
|
|
822
|
-
const dbKey = typeof payload === "string" ? payload : payload.dbKey;
|
|
823
|
-
const preferredServerOrigin = typeof payload === "string" ? void 0 : payload.preferredServerOrigin;
|
|
824
|
-
const { db } = thunkApi.extra;
|
|
825
|
-
if (!db) {
|
|
826
|
-
throw new Error(
|
|
827
|
-
"Database instance is not available in thunk extra argument."
|
|
828
|
-
);
|
|
829
|
-
}
|
|
830
|
-
const state = thunkApi.getState();
|
|
831
|
-
const {
|
|
832
|
-
currentToken,
|
|
833
|
-
remoteServers: configuredServers,
|
|
834
|
-
currentServer,
|
|
835
|
-
currentUserId,
|
|
836
|
-
syncServers,
|
|
837
|
-
userAuthorityRegistry
|
|
838
|
-
} = getRuntimeServerContext(state, preferredServerOrigin);
|
|
839
|
-
const allServers = resolveAgentReadServers({ dbKey, configuredServers });
|
|
840
|
-
const fetchScopedFromServer = (server, key, token, signal) => signal === void 0 ? fetchFromServer(server, key, googleSessionRequestToken(token, server, isPublicBuiltinPlatformAgentKey(key))) : fetchFromServer(server, key, googleSessionRequestToken(token, server, isPublicBuiltinPlatformAgentKey(key)), signal);
|
|
841
|
-
const isLoggedIn = !!currentToken;
|
|
842
|
-
const executeReadAndWait = async () => {
|
|
843
|
-
if (dbKey.startsWith("page-") && currentUserId && currentToken && typeof db.batch === "function") {
|
|
844
|
-
const protectedData = await readProtectedPage({
|
|
845
|
-
db,
|
|
846
|
-
actorId: currentUserId,
|
|
847
|
-
dbKey,
|
|
848
|
-
servers: preferredServerOrigin ? [preferredServerOrigin, ...allServers] : allServers,
|
|
849
|
-
token: currentToken,
|
|
850
|
-
fetch,
|
|
851
|
-
getCurrentAccess: () => {
|
|
852
|
-
const context = getRuntimeServerContext(thunkApi.getState());
|
|
853
|
-
return { actorId: context.currentUserId, token: context.currentToken, servers: context.remoteServers };
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
if (protectedData !== void 0) return { ...protectedData, dbKey };
|
|
857
|
-
}
|
|
858
|
-
const localData = await fetchFromClientDb(db, dbKey);
|
|
859
|
-
const authority = resolveRecordAuthority({
|
|
860
|
-
dbKey,
|
|
861
|
-
record: localData,
|
|
862
|
-
currentUserId,
|
|
863
|
-
currentServer,
|
|
864
|
-
userAuthorityRegistry
|
|
865
|
-
});
|
|
866
|
-
let readServers = planAuthorityReadServers({
|
|
867
|
-
allServers,
|
|
868
|
-
authorityServer: preferredServerOrigin ?? authority.authorityServer,
|
|
869
|
-
serverOrigin: authority.serverOrigin
|
|
870
|
-
});
|
|
871
|
-
if (!isPublicBuiltinPlatformAgentKey(dbKey)) readServers = scopeGoogleSessionServers(currentToken, currentServer, readServers);
|
|
872
|
-
const hasPreferredAuthorityServer = !!preferredServerOrigin || !!authority.authorityServer;
|
|
873
|
-
const preferredAuthorityServer = hasPreferredAuthorityServer ? readServers[0] : null;
|
|
874
|
-
if (readServers.length === 0) {
|
|
875
|
-
if (localData) {
|
|
876
|
-
return { ...localData, dbKey };
|
|
877
|
-
}
|
|
878
|
-
throw new Error(
|
|
879
|
-
`Failed to fetch data for key "${dbKey}" because network is offline and no local data is available.`
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
if (preferredAuthorityServer) {
|
|
883
|
-
try {
|
|
884
|
-
const preferredRemoteData = await fetchScopedFromServer(
|
|
885
|
-
preferredAuthorityServer,
|
|
886
|
-
dbKey,
|
|
887
|
-
isLoggedIn ? currentToken : void 0
|
|
888
|
-
);
|
|
889
|
-
if (preferredRemoteData) {
|
|
890
|
-
await db.put(dbKey, preferredRemoteData);
|
|
891
|
-
return { ...preferredRemoteData, dbKey };
|
|
892
|
-
}
|
|
893
|
-
} catch {
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
const remainingReadServers = preferredAuthorityServer ? readServers.filter((server) => server !== preferredAuthorityServer) : readServers;
|
|
897
|
-
const remotePromises = remainingReadServers.map(
|
|
898
|
-
(server) => fetchScopedFromServer(server, dbKey, isLoggedIn ? currentToken : void 0)
|
|
899
|
-
);
|
|
900
|
-
const chosenData = await processRemoteData(
|
|
901
|
-
db,
|
|
902
|
-
dbKey,
|
|
903
|
-
remotePromises,
|
|
904
|
-
localData,
|
|
905
|
-
{ currentServer, syncServers, state }
|
|
906
|
-
);
|
|
907
|
-
return { ...chosenData, dbKey };
|
|
908
|
-
};
|
|
909
|
-
const inFlightKey = buildReadAndWaitRequestKey(dbKey, currentToken);
|
|
910
|
-
const existing = readRequestManager.getInFlight(inFlightKey);
|
|
911
|
-
if (existing) return existing;
|
|
912
|
-
let inFlightPromise;
|
|
913
|
-
inFlightPromise = executeReadAndWait().finally(() => {
|
|
914
|
-
readRequestManager.clearInFlight(inFlightKey, inFlightPromise);
|
|
915
|
-
});
|
|
916
|
-
readRequestManager.setInFlight(inFlightKey, inFlightPromise);
|
|
917
|
-
return inFlightPromise;
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
// packages/database/actions/actionToast.ts
|
|
921
|
-
var registeredToast = null;
|
|
922
|
-
var actionToast = {
|
|
923
|
-
success: (message) => registeredToast?.success(message),
|
|
924
|
-
error: (message) => {
|
|
925
|
-
if (registeredToast) registeredToast.error(message);
|
|
926
|
-
else console.warn(message);
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
// packages/database/actions/write.ts
|
|
931
|
-
var SPACE_MEMBER_PREFIX = "space-member-";
|
|
932
|
-
var getMemberUserIdFromSpaceMemberKey = (dbKey) => {
|
|
933
|
-
if (!dbKey.startsWith(SPACE_MEMBER_PREFIX)) return null;
|
|
934
|
-
const rest = dbKey.slice(SPACE_MEMBER_PREFIX.length);
|
|
935
|
-
const lastDash = rest.lastIndexOf("-");
|
|
936
|
-
if (lastDash <= 0) return null;
|
|
937
|
-
return rest.slice(0, lastDash);
|
|
938
|
-
};
|
|
939
|
-
var saveToClientDb = async (clientDb, dbKey, data) => {
|
|
940
|
-
if (!clientDb) {
|
|
941
|
-
logger.error({ dbKey }, "Client database is undefined in saveToClientDb");
|
|
942
|
-
throw new Error("Client database instance is required");
|
|
943
|
-
}
|
|
944
|
-
try {
|
|
945
|
-
await clientDb.put(dbKey, data);
|
|
946
|
-
logger.debug({ dbKey }, "Data saved successfully to local database.");
|
|
947
|
-
} catch (err) {
|
|
948
|
-
logger.error({ err, dbKey }, "Failed to save data to local database");
|
|
949
|
-
throw new Error(`Local database put failed for ${dbKey}: ${err.message}`);
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
var writeAction = async (writeConfig, thunkApi) => {
|
|
953
|
-
const { db: clientDb } = thunkApi.extra;
|
|
954
|
-
if (!clientDb) {
|
|
955
|
-
throw new Error("Client database instance is required in writeAction");
|
|
956
|
-
}
|
|
957
|
-
const state = thunkApi.getState();
|
|
958
|
-
const { currentServer, syncServers, currentUserId } = getRuntimeServerContext(state);
|
|
959
|
-
const { data, customKey } = writeConfig;
|
|
960
|
-
const userId = writeConfig.userId || currentUserId;
|
|
961
|
-
const isSpaceMemberRecord = customKey.startsWith(SPACE_MEMBER_PREFIX);
|
|
962
|
-
const recordUserId = isSpaceMemberRecord ? data.userId || getMemberUserIdFromSpaceMemberKey(customKey) || userId : userId;
|
|
963
|
-
if (!data || !customKey) {
|
|
964
|
-
const errorMsg = "Invalid arguments for writeAction: data and customKey are required.";
|
|
965
|
-
logger.error({ writeConfig }, errorMsg);
|
|
966
|
-
actionToast.error(errorMsg);
|
|
967
|
-
throw new Error(errorMsg);
|
|
968
|
-
}
|
|
969
|
-
const VALID_TYPES = [
|
|
970
|
-
"msg" /* MSG */,
|
|
971
|
-
"page" /* DOC */,
|
|
972
|
-
"dialog" /* DIALOG */,
|
|
973
|
-
"notification" /* NOTIFICATION */,
|
|
974
|
-
"token" /* TOKEN */,
|
|
975
|
-
"transaction" /* TRANSACTION */,
|
|
976
|
-
"space" /* SPACE */,
|
|
977
|
-
"setting" /* SETTING */,
|
|
978
|
-
"table" /* TABLE */,
|
|
979
|
-
"table_row" /* TABLE_ROW */,
|
|
980
|
-
"email" /* EMAIL */,
|
|
981
|
-
"agent" /* AGENT */,
|
|
982
|
-
"agent-automation" /* AGENT_AUTOMATION */
|
|
983
|
-
];
|
|
984
|
-
if (!data.type || !VALID_TYPES.includes(data.type)) {
|
|
985
|
-
logger.warn(
|
|
986
|
-
`Invalid data type "${data.type}" for writeAction with key ${customKey}. Proceeding anyway.`
|
|
987
|
-
);
|
|
988
|
-
}
|
|
989
|
-
let writeAck = null;
|
|
990
|
-
try {
|
|
991
|
-
const willSaveData = normalizeTimeFields({
|
|
992
|
-
...data,
|
|
993
|
-
dbKey: customKey,
|
|
994
|
-
userId: recordUserId
|
|
995
|
-
});
|
|
996
|
-
writeAck = beginWriteAck(customKey);
|
|
997
|
-
await saveToClientDb(clientDb, customKey, willSaveData);
|
|
998
|
-
const servers = resolveAuthorityReplicationServers({
|
|
999
|
-
currentServer,
|
|
1000
|
-
syncServers,
|
|
1001
|
-
dbKey: customKey,
|
|
1002
|
-
record: willSaveData,
|
|
1003
|
-
state
|
|
1004
|
-
});
|
|
1005
|
-
const serverWriteConfig = {
|
|
1006
|
-
data: willSaveData,
|
|
1007
|
-
customKey,
|
|
1008
|
-
userId: recordUserId
|
|
1009
|
-
};
|
|
1010
|
-
if (servers.length > 0) {
|
|
1011
|
-
logger.debug(
|
|
1012
|
-
`[writeAction] Initiating background sync for key: ${customKey} to ${servers.length} servers.`
|
|
1013
|
-
);
|
|
1014
|
-
const replication = scheduleWriteReplication(
|
|
1015
|
-
servers,
|
|
1016
|
-
serverWriteConfig,
|
|
1017
|
-
state
|
|
1018
|
-
);
|
|
1019
|
-
writeAck.settleWithReplication(replication);
|
|
1020
|
-
} else {
|
|
1021
|
-
writeAck.markNotReplicated();
|
|
1022
|
-
logger.warn(
|
|
1023
|
-
{ customKey },
|
|
1024
|
-
"[writeAction] No available servers, data only saved locally."
|
|
1025
|
-
);
|
|
1026
|
-
}
|
|
1027
|
-
return willSaveData;
|
|
1028
|
-
} catch (error) {
|
|
1029
|
-
writeAck?.markAborted();
|
|
1030
|
-
const errorMessage = `Write action failed for ${customKey}: ${error?.message || "Unknown error"}`;
|
|
1031
|
-
logger.error({ error }, "[writeAction] Error");
|
|
1032
|
-
actionToast.error(`Failed to save data for ${customKey}.`);
|
|
1033
|
-
throw new Error(errorMessage);
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
|
-
// packages/database/actions/protectedPagePatch.ts
|
|
1038
|
-
async function patchProtectedPage(options) {
|
|
1039
|
-
const baseline = await getPageReadBaseline(options.db, options.actorId, options.dbKey);
|
|
1040
|
-
if (!baseline) return void 0;
|
|
1041
|
-
const sync = options.sync ?? createProtectedRecordSync({ db: options.db });
|
|
1042
|
-
const scope = { actorId: options.actorId, dbKey: options.dbKey };
|
|
1043
|
-
const state = await sync.readState(scope);
|
|
1044
|
-
if (state.legacyCandidates.length) throw Error("\u672C\u5730\u65E7\u526F\u672C\u5C1A\u672A\u786E\u8BA4\uFF0C\u672A\u8986\u76D6\u4E91\u7AEF\uFF1B\u8BF7\u5148\u5904\u7406\u7248\u672C\u5DEE\u5F02");
|
|
1045
|
-
const current = state.workingCopy?.data ?? await options.db.get(options.dbKey) ?? options.data;
|
|
1046
|
-
const data = options.buildData ? options.buildData(current) : options.data;
|
|
1047
|
-
const draft = await sync.saveLocalDraft({
|
|
1048
|
-
...scope,
|
|
1049
|
-
...baseline,
|
|
1050
|
-
baseRevision: state.baselineRevision ?? baseline.revision,
|
|
1051
|
-
mutationId: crypto.randomUUID(),
|
|
1052
|
-
data,
|
|
1053
|
-
operation: "patch",
|
|
1054
|
-
payload: options.changes
|
|
1055
|
-
});
|
|
1056
|
-
if (draft.blocked) throw Error("\u8349\u7A3F\u5DF2\u4FDD\u5B58\u5728\u672C\u5730\uFF0C\u4F46\u540C\u6B65\u53D7\u963B\uFF1B\u4E91\u7AEF\u5C1A\u672A\u786E\u8BA4");
|
|
1057
|
-
const transport = createProtectedRecordTransport({
|
|
1058
|
-
sync,
|
|
1059
|
-
fetch: options.fetch,
|
|
1060
|
-
isAuthorityAllowed: options.isAuthorityAllowed,
|
|
1061
|
-
getToken: async () => options.token()
|
|
1062
|
-
});
|
|
1063
|
-
let result;
|
|
1064
|
-
for (let count = 0; count < draft.outbox.length; count++) {
|
|
1065
|
-
result = await transport.sendNext(scope);
|
|
1066
|
-
if (result.outcome !== "acked") break;
|
|
1067
|
-
}
|
|
1068
|
-
if (result?.outcome === "conflict" || result?.outcome === "blocked") {
|
|
1069
|
-
throw Error("\u8349\u7A3F\u5DF2\u4FDD\u5B58\u5728\u672C\u5730\uFF0C\u4F46\u5B58\u5728\u7248\u672C\u51B2\u7A81\u6216\u6388\u6743\u95EE\u9898\uFF1B\u672A\u8986\u76D6\u4E91\u7AEF");
|
|
1070
|
-
}
|
|
1071
|
-
const latest = await sync.readState(scope);
|
|
1072
|
-
if (options.requireServerConfirmation && latest.outbox.length) {
|
|
1073
|
-
throw Error("\u8349\u7A3F\u5DF2\u4FDD\u5B58\u5728\u672C\u5730\uFF0C\u7B49\u5F85\u670D\u52A1\u5668\u786E\u8BA4\uFF1B\u8BF7\u8054\u7F51\u540E\u91CD\u8BD5\u4FDD\u5B58");
|
|
1074
|
-
}
|
|
1075
|
-
return latest.workingCopy?.data ?? latest.lastAck?.record ?? options.data;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// packages/core/timestamp.ts
|
|
1079
|
-
function toTimestampMs(value) {
|
|
1080
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1081
|
-
if (typeof value === "string") {
|
|
1082
|
-
const parsed = Date.parse(value);
|
|
1083
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
1084
|
-
}
|
|
1085
|
-
return 0;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
// packages/database/actions/patch.ts
|
|
1089
|
-
var deepMerge = (target, source) => {
|
|
1090
|
-
const output = { ...target };
|
|
1091
|
-
for (const key in source) {
|
|
1092
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1093
|
-
if (source[key] === null && key in output) {
|
|
1094
|
-
delete output[key];
|
|
1095
|
-
} else if (isRecord(source[key])) {
|
|
1096
|
-
output[key] = deepMerge(output[key] || {}, source[key]);
|
|
1097
|
-
} else {
|
|
1098
|
-
output[key] = source[key];
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return output;
|
|
1103
|
-
};
|
|
1104
|
-
var inferNextUpdatedAt = (currentData) => {
|
|
1105
|
-
const previousUpdatedAt = currentData?.updatedAt;
|
|
1106
|
-
const previousCreatedAt = currentData?.createdAt;
|
|
1107
|
-
const previousMetaCreatedAt = currentData?.meta?.createdAt;
|
|
1108
|
-
const previousTimestamp = Math.max(
|
|
1109
|
-
toTimestampMs(previousUpdatedAt),
|
|
1110
|
-
toTimestampMs(previousCreatedAt),
|
|
1111
|
-
toTimestampMs(previousMetaCreatedAt)
|
|
1112
|
-
);
|
|
1113
|
-
const nextTimestamp = Math.max(Date.now(), previousTimestamp + 1);
|
|
1114
|
-
if (typeof previousUpdatedAt === "number" || typeof previousCreatedAt === "number" || typeof previousMetaCreatedAt === "number") {
|
|
1115
|
-
return nextTimestamp;
|
|
1116
|
-
}
|
|
1117
|
-
if (typeof previousUpdatedAt === "string" || typeof previousCreatedAt === "string") {
|
|
1118
|
-
return new Date(nextTimestamp).toISOString();
|
|
1119
|
-
}
|
|
1120
|
-
return void 0;
|
|
1121
|
-
};
|
|
1122
|
-
var patchAction = async ({
|
|
1123
|
-
dbKey,
|
|
1124
|
-
changes,
|
|
1125
|
-
preferredServerOrigin,
|
|
1126
|
-
requireServerConfirmation
|
|
1127
|
-
}, thunkApi) => {
|
|
1128
|
-
const { db } = thunkApi.extra;
|
|
1129
|
-
if (!db) {
|
|
1130
|
-
const errorMsg = "Database instance is not available.";
|
|
1131
|
-
actionToast.error(errorMsg);
|
|
1132
|
-
throw new Error(errorMsg);
|
|
1133
|
-
}
|
|
1134
|
-
if (!dbKey || !changes || typeof changes !== "object") {
|
|
1135
|
-
const errorMsg = "Patch action requires a valid dbKey and changes object.";
|
|
1136
|
-
actionToast.error(errorMsg);
|
|
1137
|
-
throw new Error(errorMsg);
|
|
1138
|
-
}
|
|
1139
|
-
const state = thunkApi.getState();
|
|
1140
|
-
const { currentServer, syncServers: configuredSyncServers, currentToken, currentUserId } = getRuntimeServerContext(state);
|
|
1141
|
-
try {
|
|
1142
|
-
let currentData = await db.get(dbKey);
|
|
1143
|
-
if (!currentData) {
|
|
1144
|
-
const hydrateServer = preferredServerOrigin ?? currentServer;
|
|
1145
|
-
const remoteData = hydrateServer ? await fetchFromServer(hydrateServer, dbKey, currentToken) : null;
|
|
1146
|
-
if (!remoteData) {
|
|
1147
|
-
throw new Error(
|
|
1148
|
-
`Cannot apply patch: Data not found locally or on server for key: ${dbKey}.`
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
const latestLocal = await db.get(dbKey);
|
|
1152
|
-
currentData = latestLocal ?? remoteData;
|
|
1153
|
-
}
|
|
1154
|
-
const patchChanges = Object.prototype.hasOwnProperty.call(changes, "updatedAt") ? changes : {
|
|
1155
|
-
...changes,
|
|
1156
|
-
...inferNextUpdatedAt(currentData) !== void 0 ? { updatedAt: inferNextUpdatedAt(currentData) } : {}
|
|
1157
|
-
};
|
|
1158
|
-
const newData = deepMerge(currentData, patchChanges);
|
|
1159
|
-
const persistedData = newData && typeof newData === "object" ? { ...newData, dbKey } : { dbKey };
|
|
1160
|
-
if (dbKey.startsWith("page-") && currentUserId && typeof db.batch === "function") {
|
|
1161
|
-
const protectedData = await patchProtectedPage({
|
|
1162
|
-
db,
|
|
1163
|
-
actorId: currentUserId,
|
|
1164
|
-
dbKey,
|
|
1165
|
-
data: persistedData,
|
|
1166
|
-
changes: patchChanges,
|
|
1167
|
-
requireServerConfirmation,
|
|
1168
|
-
buildData: (latest) => ({ ...deepMerge(latest, patchChanges), dbKey }),
|
|
1169
|
-
isAuthorityAllowed: (origin) => {
|
|
1170
|
-
const context = getRuntimeServerContext(thunkApi.getState());
|
|
1171
|
-
return context.currentUserId === currentUserId && context.remoteServers.some((server) => {
|
|
1172
|
-
try {
|
|
1173
|
-
return new URL(server).origin === origin;
|
|
1174
|
-
} catch {
|
|
1175
|
-
return false;
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
1178
|
-
},
|
|
1179
|
-
token: async () => {
|
|
1180
|
-
const context = getRuntimeServerContext(thunkApi.getState());
|
|
1181
|
-
return context.currentUserId === currentUserId ? context.currentToken ?? null : null;
|
|
1182
|
-
},
|
|
1183
|
-
fetch
|
|
1184
|
-
});
|
|
1185
|
-
if (protectedData !== void 0) return protectedData;
|
|
1186
|
-
}
|
|
1187
|
-
await db.put(dbKey, persistedData);
|
|
1188
|
-
if (Object.prototype.hasOwnProperty.call(changes, "restoredAt") && changes.restoredAt) {
|
|
1189
|
-
emitUserDataUpdated({ restoredDbKey: dbKey });
|
|
1190
|
-
}
|
|
1191
|
-
scheduleConfiguredPatchReplication({
|
|
1192
|
-
currentServer,
|
|
1193
|
-
syncServers: configuredSyncServers,
|
|
1194
|
-
preferredServerOrigin,
|
|
1195
|
-
dbKey,
|
|
1196
|
-
changes: patchChanges,
|
|
1197
|
-
state
|
|
1198
|
-
});
|
|
1199
|
-
return persistedData;
|
|
1200
|
-
} catch (error) {
|
|
1201
|
-
const errorMessage = `Failed to update data for ${dbKey}.`;
|
|
1202
|
-
actionToast.error(errorMessage);
|
|
1203
|
-
throw new Error(error.message || errorMessage);
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
|
|
1207
|
-
// packages/database/actions/upsert.ts
|
|
1208
|
-
var upsertAction = async (upsertConfig, thunkApi) => {
|
|
1209
|
-
const { dbKey, data } = upsertConfig;
|
|
1210
|
-
if (!dbKey || !data || typeof data !== "object") {
|
|
1211
|
-
const errorMsg = "upsertAction \u53C2\u6570\u65E0\u6548\uFF1AdbKey \u548C data \u5BF9\u8C61\u662F\u5FC5\u9700\u7684\u3002";
|
|
1212
|
-
actionToast.error(errorMsg);
|
|
1213
|
-
throw new Error(errorMsg);
|
|
1214
|
-
}
|
|
1215
|
-
try {
|
|
1216
|
-
const existingData = await readAction({ dbKey }, thunkApi);
|
|
1217
|
-
let finalResult;
|
|
1218
|
-
if (existingData && Object.keys(existingData).length > 0) {
|
|
1219
|
-
finalResult = await patchAction({ dbKey, changes: data }, thunkApi);
|
|
1220
|
-
} else {
|
|
1221
|
-
finalResult = await writeAction({ data, customKey: dbKey }, thunkApi);
|
|
1222
|
-
}
|
|
1223
|
-
return finalResult;
|
|
1224
|
-
} catch (error) {
|
|
1225
|
-
const errorMessage = `Upsert \u534F\u8C03\u64CD\u4F5C\u5931\u8D25 (dbKey: ${dbKey}): ${error.message || "\u672A\u77E5\u9519\u8BEF"}`;
|
|
1226
|
-
actionToast.error("\u6570\u636E\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");
|
|
1227
|
-
throw new Error(errorMessage, { cause: error });
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
// packages/database/actions/purge.ts
|
|
1232
|
-
var purgeAction = async (payload, thunkApi) => {
|
|
1233
|
-
const { db: clientDb } = thunkApi.extra;
|
|
1234
|
-
const dbKey = typeof payload === "string" ? payload : payload.dbKey;
|
|
1235
|
-
const preferredServerOrigin = typeof payload === "string" ? void 0 : payload.preferredServerOrigin;
|
|
1236
|
-
if (!clientDb) {
|
|
1237
|
-
throw new Error("Client database is undefined in purgeAction");
|
|
1238
|
-
}
|
|
1239
|
-
const state = thunkApi.getState();
|
|
1240
|
-
const { currentServer, syncServers } = getRuntimeServerContext(state);
|
|
1241
|
-
const localData = await fetchFromClientDb(clientDb, dbKey);
|
|
1242
|
-
if (localData && !isTombstoneRecord(localData)) {
|
|
1243
|
-
throw new Error(
|
|
1244
|
-
`purgeAction refused: record ${dbKey} is not tombstoned. Use removeAction instead.`
|
|
1245
|
-
);
|
|
1246
|
-
}
|
|
1247
|
-
await clientDb.del(dbKey);
|
|
1248
|
-
emitUserDataUpdated({ deletedDbKey: dbKey });
|
|
1249
|
-
const servers = resolveAuthorityReplicationServers({
|
|
1250
|
-
currentServer,
|
|
1251
|
-
syncServers,
|
|
1252
|
-
preferredServerOrigin,
|
|
1253
|
-
dbKey,
|
|
1254
|
-
state
|
|
1255
|
-
});
|
|
1256
|
-
await Promise.all(
|
|
1257
|
-
servers.map(async (server) => {
|
|
1258
|
-
const ok = await noloDeleteRequest(
|
|
1259
|
-
server,
|
|
1260
|
-
dbKey,
|
|
1261
|
-
{ type: "single", force: true },
|
|
1262
|
-
state
|
|
1263
|
-
);
|
|
1264
|
-
if (!ok) {
|
|
1265
|
-
console.warn("[purgeAction] server force-delete failed", { dbKey, server });
|
|
1266
|
-
}
|
|
1267
|
-
})
|
|
1268
|
-
);
|
|
1269
|
-
return { dbKey, servers };
|
|
1270
|
-
};
|
|
1271
|
-
|
|
1272
|
-
// packages/database/spaceUploadFileMapping.ts
|
|
1273
|
-
function mappings(db) {
|
|
1274
|
-
return db?.sublevel?.("web-space-upload-file-ids", { valueEncoding: "utf8" });
|
|
1275
|
-
}
|
|
1276
|
-
var mappingKey = (userId, pageKey) => JSON.stringify([userId, pageKey]);
|
|
1277
|
-
async function recordWebSpaceUploadFileId(db, userId, pageKey, fileId) {
|
|
1278
|
-
await mappings(db)?.put(mappingKey(userId, pageKey), fileId);
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
// packages/database/actions/upload.ts
|
|
1282
|
-
var saveToClientDb2 = async (clientDb, dbKey, metadata) => {
|
|
1283
|
-
if (!clientDb) {
|
|
1284
|
-
logger.error({ dbKey }, "Client database is undefined in saveToClientDb");
|
|
1285
|
-
throw new Error("Client database instance is required");
|
|
1286
|
-
}
|
|
1287
|
-
try {
|
|
1288
|
-
await clientDb.put(dbKey, metadata);
|
|
1289
|
-
logger.debug(
|
|
1290
|
-
{ dbKey },
|
|
1291
|
-
"File metadata saved successfully to local database."
|
|
1292
|
-
);
|
|
1293
|
-
} catch (err) {
|
|
1294
|
-
logger.error(
|
|
1295
|
-
{ err, dbKey },
|
|
1296
|
-
"Failed to save file metadata to local database"
|
|
1297
|
-
);
|
|
1298
|
-
throw new Error(`Local database put failed for ${dbKey}: ${err.message}`);
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
|
-
var uploadFileAction = async (uploadConfig, thunkApi) => {
|
|
1302
|
-
const { db: clientDb } = thunkApi.extra;
|
|
1303
|
-
const state = thunkApi.getState();
|
|
1304
|
-
const { currentServer, syncServers, currentUserId } = getRuntimeServerContext(state);
|
|
1305
|
-
const { file, customKey, onProgress, signal, ownerType, spaceId } = uploadConfig;
|
|
1306
|
-
const userId = uploadConfig.userId || currentUserId;
|
|
1307
|
-
if (!file) {
|
|
1308
|
-
const errorMsg = "Invalid arguments for uploadFileAction: file is required.";
|
|
1309
|
-
logger.error({ uploadConfig }, errorMsg);
|
|
1310
|
-
throw new Error(errorMsg);
|
|
1311
|
-
}
|
|
1312
|
-
try {
|
|
1313
|
-
const fileId = ulid();
|
|
1314
|
-
const fileExtension = file.name.split(".").pop() || "";
|
|
1315
|
-
const fileName = `${fileId}${fileExtension ? "." + fileExtension : ""}`;
|
|
1316
|
-
let finalDbKey = customKey;
|
|
1317
|
-
if (!finalDbKey || !finalDbKey.startsWith("file-")) {
|
|
1318
|
-
const actualUserId = userId || "unknown";
|
|
1319
|
-
if (actualUserId === "unknown") {
|
|
1320
|
-
console.warn("[uploadFileAction] User ID is unknown during upload. Key will be file-unknown.");
|
|
1321
|
-
}
|
|
1322
|
-
finalDbKey = fileKey.single(actualUserId, fileId);
|
|
1323
|
-
}
|
|
1324
|
-
const fileMetadata = normalizeTimeFields({
|
|
1325
|
-
id: fileId,
|
|
1326
|
-
title: file.name,
|
|
1327
|
-
originalName: file.name,
|
|
1328
|
-
fileName,
|
|
1329
|
-
filePath: "",
|
|
1330
|
-
size: file.size,
|
|
1331
|
-
mimeType: file.type || "application/octet-stream",
|
|
1332
|
-
type: "file" /* FILE */,
|
|
1333
|
-
fileCategory: resolveFileCategory({
|
|
1334
|
-
mimeType: file.type,
|
|
1335
|
-
fileName: file.name
|
|
1336
|
-
}),
|
|
1337
|
-
dbKey: finalDbKey,
|
|
1338
|
-
userId
|
|
1339
|
-
});
|
|
1340
|
-
await saveToClientDb2(clientDb, finalDbKey, fileMetadata);
|
|
1341
|
-
const cacheLocally = async () => {
|
|
1342
|
-
try {
|
|
1343
|
-
await saveFileToIndexedDb(fileId, file);
|
|
1344
|
-
} catch (err) {
|
|
1345
|
-
logger.warn(
|
|
1346
|
-
{ err, fileId },
|
|
1347
|
-
"[uploadFileAction] Failed to cache file locally."
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
const localCachePromise = isMediaFile(file) ? cacheLocally() : null;
|
|
1352
|
-
if (!localCachePromise) {
|
|
1353
|
-
await cacheLocally();
|
|
1354
|
-
}
|
|
1355
|
-
const tenantId = userId || "default";
|
|
1356
|
-
const uploadReplicationConfig = {
|
|
1357
|
-
file,
|
|
1358
|
-
metadata: fileMetadata,
|
|
1359
|
-
customKey: finalDbKey,
|
|
1360
|
-
userId,
|
|
1361
|
-
// 归属声明一律由调用方显式给出(例如 Space 上传传 ownerType:"space");
|
|
1362
|
-
// 服务端 uploadOwnership.ts 会重新校验,声明本身不构成授权。
|
|
1363
|
-
...ownerType ? { ownerType } : {},
|
|
1364
|
-
...spaceId ? { spaceId } : {}
|
|
1365
|
-
};
|
|
1366
|
-
const uploadServers = resolveUploadReplicationServers({
|
|
1367
|
-
currentServer,
|
|
1368
|
-
syncServers,
|
|
1369
|
-
tenantId,
|
|
1370
|
-
uploadConfig: uploadReplicationConfig,
|
|
1371
|
-
state
|
|
1372
|
-
});
|
|
1373
|
-
const primaryUploadServer = uploadServers[0] ?? currentServer;
|
|
1374
|
-
const primaryUploadSucceeded = await uploadToCurrentServer({
|
|
1375
|
-
currentServer: primaryUploadServer,
|
|
1376
|
-
uploadConfig: uploadReplicationConfig,
|
|
1377
|
-
state,
|
|
1378
|
-
...onProgress ? { onProgress } : {},
|
|
1379
|
-
...signal ? { signal } : {}
|
|
1380
|
-
});
|
|
1381
|
-
if (localCachePromise) {
|
|
1382
|
-
await localCachePromise;
|
|
1383
|
-
}
|
|
1384
|
-
if (primaryUploadServer && !primaryUploadSucceeded) {
|
|
1385
|
-
if (ownerType === "space") {
|
|
1386
|
-
throw new Error(
|
|
1387
|
-
`Upload into Space "${spaceId}" failed on ${primaryUploadServer}: the Space may not be synced to that server, or you are not allowed to upload into it there. Sync the Space to ${primaryUploadServer} (or use another upload server) and retry. Ownership is server-decided and is never downgraded to a personal file.`
|
|
1388
|
-
);
|
|
1389
|
-
}
|
|
1390
|
-
throw new Error(`Primary upload failed on authority server ${primaryUploadServer}`);
|
|
1391
|
-
}
|
|
1392
|
-
if (ownerType === "space" && userId && finalDbKey === customKey) {
|
|
1393
|
-
await recordWebSpaceUploadFileId(clientDb, userId, finalDbKey, fileId);
|
|
1394
|
-
}
|
|
1395
|
-
const serversToUse = scheduleUploadReplication({
|
|
1396
|
-
currentServer,
|
|
1397
|
-
syncServers,
|
|
1398
|
-
tenantId,
|
|
1399
|
-
uploadConfig: uploadReplicationConfig,
|
|
1400
|
-
state,
|
|
1401
|
-
excludeServers: primaryUploadServer ? [primaryUploadServer] : []
|
|
1402
|
-
});
|
|
1403
|
-
if (!primaryUploadServer && !serversToUse.length) {
|
|
1404
|
-
logger.warn(
|
|
1405
|
-
{ finalDbKey, fileName, tenantId },
|
|
1406
|
-
"[uploadFileAction] No replication servers available, file metadata only saved locally."
|
|
1407
|
-
);
|
|
1408
|
-
return fileMetadata;
|
|
1409
|
-
}
|
|
1410
|
-
logger.debug(
|
|
1411
|
-
{ primaryUploadServer, currentServer, serversToUse, tenantId },
|
|
1412
|
-
`[uploadFileAction] Uploaded primary copy for ${fileName} and scheduled background sync to ${serversToUse.length} additional servers.`
|
|
1413
|
-
);
|
|
1414
|
-
return fileMetadata;
|
|
1415
|
-
} catch (error) {
|
|
1416
|
-
const errorMessage = `Upload action failed for ${customKey}: ${error?.message || "Unknown error"}`;
|
|
1417
|
-
logger.error({ error }, "[uploadFileAction] Error");
|
|
1418
|
-
throw new Error(errorMessage);
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
|
|
1422
|
-
// packages/database/actions/fileContent.ts
|
|
1423
|
-
var resolveLocalFileId = (fileId) => {
|
|
1424
|
-
if (fileId.startsWith("file-")) {
|
|
1425
|
-
return getFileIdFromKey(fileId) || fileId;
|
|
1426
|
-
}
|
|
1427
|
-
return fileId;
|
|
1428
|
-
};
|
|
1429
|
-
var readFileContentAction = async ({
|
|
1430
|
-
fileId,
|
|
1431
|
-
useServerFallback = true,
|
|
1432
|
-
localFileId
|
|
1433
|
-
}, thunkApi) => {
|
|
1434
|
-
if (!fileId || typeof fileId !== "string") {
|
|
1435
|
-
throw new Error("readFileContentAction requires a valid fileId string.");
|
|
1436
|
-
}
|
|
1437
|
-
const localId = localFileId || resolveLocalFileId(fileId);
|
|
1438
|
-
const localRecord = await loadFileFromIndexedDb(localId);
|
|
1439
|
-
if (localRecord) {
|
|
1440
|
-
return {
|
|
1441
|
-
fileId: localId,
|
|
1442
|
-
blob: localRecord.blob,
|
|
1443
|
-
source: "local"
|
|
1444
|
-
};
|
|
1445
|
-
}
|
|
1446
|
-
if (!useServerFallback) {
|
|
1447
|
-
throw new Error(
|
|
1448
|
-
`Local file not found for id "${fileId}", and server fallback is disabled.`
|
|
1449
|
-
);
|
|
1450
|
-
}
|
|
1451
|
-
const state = thunkApi.getState();
|
|
1452
|
-
const { currentServer, remoteServers: serversToTry } = getRuntimeServerContext(state);
|
|
1453
|
-
if (!currentServer) {
|
|
1454
|
-
throw new Error(
|
|
1455
|
-
`No current server configured. Cannot fetch remote file for id "${fileId}".`
|
|
1456
|
-
);
|
|
1457
|
-
}
|
|
1458
|
-
let lastError = "";
|
|
1459
|
-
for (const server of serversToTry) {
|
|
1460
|
-
const url = `${server}${API_ENDPOINTS.DATABASE}/file/content/${fileId}`;
|
|
1461
|
-
console.debug("[readFileContentAction] trying server:", url);
|
|
1462
|
-
try {
|
|
1463
|
-
const res = await fetch(url);
|
|
1464
|
-
if (!res.ok) {
|
|
1465
|
-
lastError = `HTTP ${res.status} from ${server}`;
|
|
1466
|
-
console.debug("[readFileContentAction] server returned:", lastError);
|
|
1467
|
-
continue;
|
|
1468
|
-
}
|
|
1469
|
-
const blob = await res.blob();
|
|
1470
|
-
if (typeof indexedDB !== "undefined") {
|
|
1471
|
-
void saveFileToIndexedDb(localId, blob).catch((err) => {
|
|
1472
|
-
console.warn(
|
|
1473
|
-
"[readFileContentAction] Failed to cache remote file into IndexedDB:",
|
|
1474
|
-
err
|
|
1475
|
-
);
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
return {
|
|
1479
|
-
fileId: localId,
|
|
1480
|
-
blob,
|
|
1481
|
-
source: "remote"
|
|
1482
|
-
};
|
|
1483
|
-
} catch (err) {
|
|
1484
|
-
lastError = err?.message || "Network error";
|
|
1485
|
-
console.debug(
|
|
1486
|
-
"[readFileContentAction] fetch error from",
|
|
1487
|
-
server,
|
|
1488
|
-
lastError
|
|
1489
|
-
);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
throw new Error(
|
|
1493
|
-
`Failed to fetch remote file content from all servers for id "${fileId}". Last error: ${lastError}`
|
|
1494
|
-
);
|
|
1495
|
-
};
|
|
1496
|
-
|
|
1497
|
-
// packages/database/dbDataAccess.ts
|
|
1498
|
-
var dbDataAccess = {
|
|
1499
|
-
// Resolve the binding at call time: esbuild chunk evaluation can otherwise
|
|
1500
|
-
// capture an uninitialized readAction as a payload creator.
|
|
1501
|
-
async read(payload, context) {
|
|
1502
|
-
const { readAction: readAction2 } = await import("./read-D4WYJQJQ.js");
|
|
1503
|
-
return readAction2(payload, context);
|
|
1504
|
-
},
|
|
1505
|
-
readAndWait: readAndWaitAction,
|
|
1506
|
-
write: writeAction,
|
|
1507
|
-
patch: patchAction,
|
|
1508
|
-
upsert: upsertAction,
|
|
1509
|
-
remove: removeAction,
|
|
1510
|
-
purge: purgeAction,
|
|
1511
|
-
upload: uploadFileAction,
|
|
1512
|
-
readFileContent: readFileContentAction,
|
|
1513
|
-
// A static edge would recreate share/action → settings → dbActionThunks → dbSlice.
|
|
1514
|
-
async share(config, context) {
|
|
1515
|
-
const { shareResourceAction } = await import("./action-UK3HXGXF.js");
|
|
1516
|
-
return shareResourceAction(config, context);
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
|
-
// packages/database/dbOperation.ts
|
|
1521
|
-
var requestIdAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
|
|
1522
|
-
function makeRequestId() {
|
|
1523
|
-
return Array.from({ length: 21 }, () => requestIdAlphabet[Math.floor(Math.random() * 64)]).join("");
|
|
1524
|
-
}
|
|
1525
|
-
var RejectedValue = class {
|
|
1526
|
-
constructor(payload) {
|
|
1527
|
-
this.payload = payload;
|
|
1528
|
-
}
|
|
1529
|
-
};
|
|
1530
|
-
function serializeError(failure) {
|
|
1531
|
-
if (typeof failure !== "object" || failure === null) return { message: String(failure) };
|
|
1532
|
-
const error = {};
|
|
1533
|
-
for (const field of ["name", "message", "stack", "code"]) {
|
|
1534
|
-
const value = failure[field];
|
|
1535
|
-
if (typeof value === "string") error[field] = value;
|
|
1536
|
-
}
|
|
1537
|
-
return error;
|
|
1538
|
-
}
|
|
1539
|
-
function dbAction(type, make) {
|
|
1540
|
-
return Object.assign((...args) => ({ ...make(...args), type }), {
|
|
1541
|
-
type,
|
|
1542
|
-
toString: () => type,
|
|
1543
|
-
match: (action) => typeof action === "object" && action !== null && (Object.getPrototypeOf(action) === null || Object.getPrototypeOf(Object.getPrototypeOf(action)) === null) && action.type === type
|
|
1544
|
-
});
|
|
1545
|
-
}
|
|
1546
|
-
function unwrapDbResult(action) {
|
|
1547
|
-
if (action.meta?.rejectedWithValue) throw action.payload;
|
|
1548
|
-
if (action.error) throw action.error;
|
|
1549
|
-
return action.payload;
|
|
1550
|
-
}
|
|
1551
|
-
function dbOperation(name, run) {
|
|
1552
|
-
const typePrefix = `db/${name}`;
|
|
1553
|
-
const pending = dbAction(`${typePrefix}/pending`, (requestId, arg, meta) => ({
|
|
1554
|
-
payload: void 0,
|
|
1555
|
-
meta: { ...meta, arg, requestId, requestStatus: "pending" }
|
|
1556
|
-
}));
|
|
1557
|
-
const fulfilled = dbAction(`${typePrefix}/fulfilled`, (payload, requestId, arg, meta) => ({
|
|
1558
|
-
payload,
|
|
1559
|
-
meta: { ...meta, arg, requestId, requestStatus: "fulfilled" }
|
|
1560
|
-
}));
|
|
1561
|
-
const rejected = dbAction(
|
|
1562
|
-
`${typePrefix}/rejected`,
|
|
1563
|
-
(failure, requestId, arg, payload, meta, rejectedWithValue = payload !== void 0) => {
|
|
1564
|
-
const error = serializeError(failure === void 0 ? "Rejected" : failure);
|
|
1565
|
-
return { payload, error, meta: {
|
|
1566
|
-
...meta,
|
|
1567
|
-
arg,
|
|
1568
|
-
requestId,
|
|
1569
|
-
requestStatus: "rejected",
|
|
1570
|
-
rejectedWithValue,
|
|
1571
|
-
aborted: error.name === "AbortError",
|
|
1572
|
-
condition: error.name === "ConditionError"
|
|
1573
|
-
} };
|
|
1574
|
-
}
|
|
1575
|
-
);
|
|
1576
|
-
const operation = (arg, options) => (dispatch, getState, extra) => {
|
|
1577
|
-
const controller = new AbortController();
|
|
1578
|
-
const { signal } = controller;
|
|
1579
|
-
const requestId = makeRequestId();
|
|
1580
|
-
const externalSignal = options?.signal;
|
|
1581
|
-
let abortReason;
|
|
1582
|
-
const abort = (reason) => {
|
|
1583
|
-
if (signal.aborted) return;
|
|
1584
|
-
abortReason = reason;
|
|
1585
|
-
controller.abort();
|
|
1586
|
-
};
|
|
1587
|
-
const onExternalAbort = () => abort("External signal was aborted");
|
|
1588
|
-
if (externalSignal?.aborted) onExternalAbort();
|
|
1589
|
-
else externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
1590
|
-
let onAbort;
|
|
1591
|
-
const abortError = () => ({ name: "AbortError", message: abortReason || "Aborted" });
|
|
1592
|
-
const promise = (async () => {
|
|
1593
|
-
let action;
|
|
1594
|
-
try {
|
|
1595
|
-
if (signal.aborted) throw abortError();
|
|
1596
|
-
const cancellation = new Promise((_, reject) => {
|
|
1597
|
-
onAbort = () => reject(abortError());
|
|
1598
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
1599
|
-
});
|
|
1600
|
-
dispatch(pending(requestId, arg));
|
|
1601
|
-
action = await Promise.race([cancellation, Promise.resolve(
|
|
1602
|
-
run(arg, { dispatch, getState, extra, signal, requestId, rejectWithValue: (value) => new RejectedValue(value) })
|
|
1603
|
-
).then((payload) => {
|
|
1604
|
-
if (payload instanceof RejectedValue) throw payload;
|
|
1605
|
-
return fulfilled(payload, requestId, arg);
|
|
1606
|
-
})]);
|
|
1607
|
-
} catch (error) {
|
|
1608
|
-
action = error instanceof RejectedValue ? rejected(void 0, requestId, arg, error.payload, void 0, true) : rejected(error, requestId, arg);
|
|
1609
|
-
} finally {
|
|
1610
|
-
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
1611
|
-
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
1612
|
-
}
|
|
1613
|
-
dispatch(action);
|
|
1614
|
-
return action;
|
|
1615
|
-
})();
|
|
1616
|
-
return Object.assign(promise, {
|
|
1617
|
-
arg,
|
|
1618
|
-
requestId,
|
|
1619
|
-
abort,
|
|
1620
|
-
unwrap: () => promise.then(unwrapDbResult)
|
|
1621
|
-
});
|
|
1622
|
-
};
|
|
1623
|
-
return Object.assign(operation, {
|
|
1624
|
-
pending,
|
|
1625
|
-
fulfilled,
|
|
1626
|
-
rejected,
|
|
1627
|
-
typePrefix,
|
|
1628
|
-
settled: (action) => fulfilled.match(action) || rejected.match(action)
|
|
1629
|
-
});
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
// packages/database/dbSlice.ts
|
|
1633
|
-
function stubSnapshot(root) {
|
|
1634
|
-
const { db } = root ?? {};
|
|
1635
|
-
return db;
|
|
1636
|
-
}
|
|
1637
|
-
function selectSnapshot(root) {
|
|
1638
|
-
return getDbEntityStore(root)?.getSnapshot() ?? stubSnapshot(root);
|
|
1639
|
-
}
|
|
1640
|
-
function selectById(root, dbKey) {
|
|
1641
|
-
const owner = getDbEntityStore(root);
|
|
1642
|
-
return owner ? owner.getById(dbKey) : stubSnapshot(root).entities[dbKey];
|
|
1643
|
-
}
|
|
1644
|
-
function selectEntities(root) {
|
|
1645
|
-
return getDbEntityStore(root)?.getEntities() ?? stubSnapshot(root).entities;
|
|
1646
|
-
}
|
|
1647
|
-
function selectOptionalEntities(root) {
|
|
1648
|
-
return getDbEntityStore(root)?.getEntities() ?? stubSnapshot(root)?.entities;
|
|
1649
|
-
}
|
|
1650
|
-
var selectIds = (root) => selectSnapshot(root).ids;
|
|
1651
|
-
var selectTotal = (root) => selectIds(root).length;
|
|
1652
|
-
var allBySnapshot = /* @__PURE__ */ new WeakMap();
|
|
1653
|
-
function selectAll(root) {
|
|
1654
|
-
const snapshot = selectSnapshot(root);
|
|
1655
|
-
let all = allBySnapshot.get(snapshot);
|
|
1656
|
-
if (!all) {
|
|
1657
|
-
all = snapshot.ids.map((id) => snapshot.entities[id]);
|
|
1658
|
-
allBySnapshot.set(snapshot, all);
|
|
1659
|
-
}
|
|
1660
|
-
return all;
|
|
1661
|
-
}
|
|
1662
|
-
var read = dbOperation("read", (payload, context) => dbDataAccess.read(payload, context));
|
|
1663
|
-
var readLocalRecord = dbOperation("readLocalRecord", async (key, { extra }) => {
|
|
1664
|
-
if (!extra.db) throw new Error("Client database unavailable");
|
|
1665
|
-
return extra.db.get(key);
|
|
1666
|
-
});
|
|
1667
|
-
var readAndWait = dbOperation("readAndWait", dbDataAccess.readAndWait);
|
|
1668
|
-
var remove = dbOperation("remove", dbDataAccess.remove);
|
|
1669
|
-
var purge = dbOperation("purge", dbDataAccess.purge);
|
|
1670
|
-
var write = dbOperation("write", dbDataAccess.write);
|
|
1671
|
-
var patch = dbOperation("patch", dbDataAccess.patch);
|
|
1672
|
-
var upsert = dbOperation("upsert", dbDataAccess.upsert);
|
|
1673
|
-
var upload = dbOperation("upload", dbDataAccess.upload);
|
|
1674
|
-
var readFileContent = dbOperation("readFileContent", dbDataAccess.readFileContent);
|
|
1675
|
-
var share = dbOperation("share", dbDataAccess.share);
|
|
1676
|
-
var upsertSSREntity = dbAction("db/upsertSSREntity", (payload) => ({ payload }));
|
|
1677
|
-
var removeCachedEntity = dbAction("db/removeCachedEntity", (payload) => ({ payload }));
|
|
1678
|
-
function cacheWrite(action) {
|
|
1679
|
-
const payload = action.payload;
|
|
1680
|
-
switch (action.type) {
|
|
1681
|
-
case read.fulfilled.type:
|
|
1682
|
-
case readAndWait.fulfilled.type:
|
|
1683
|
-
if (payload && Object.keys(payload).length > 0) return (owner) => owner.upsertOne(payload);
|
|
1684
|
-
break;
|
|
1685
|
-
case write.fulfilled.type:
|
|
1686
|
-
case patch.fulfilled.type:
|
|
1687
|
-
case upsert.fulfilled.type:
|
|
1688
|
-
case upload.fulfilled.type:
|
|
1689
|
-
if (payload?.dbKey && Object.keys(payload).length > 0) return (owner) => owner.upsertOne(payload);
|
|
1690
|
-
break;
|
|
1691
|
-
case upsertSSREntity.type:
|
|
1692
|
-
if (payload?.dbKey) return (owner) => owner.upsertOne(payload);
|
|
1693
|
-
break;
|
|
1694
|
-
case remove.fulfilled.type:
|
|
1695
|
-
case purge.fulfilled.type: {
|
|
1696
|
-
const { dbKey } = payload;
|
|
1697
|
-
if (dbKey) return (owner) => owner.removeOne(dbKey);
|
|
1698
|
-
break;
|
|
1699
|
-
}
|
|
1700
|
-
case removeCachedEntity.type:
|
|
1701
|
-
if (payload) return (owner) => owner.removeOne(payload);
|
|
1702
|
-
break;
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
function applyDbCacheAction(owner, action) {
|
|
1706
|
-
if (action && typeof action === "object") cacheWrite(action)?.(owner);
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
export {
|
|
1710
|
-
protectedSyncStateKey,
|
|
1711
|
-
readAndWaitAction,
|
|
1712
|
-
toTimestampMs,
|
|
1713
|
-
upsertAction,
|
|
1714
|
-
uploadFileAction,
|
|
1715
|
-
readFileContentAction,
|
|
1716
|
-
unwrapDbResult,
|
|
1717
|
-
selectById,
|
|
1718
|
-
selectEntities,
|
|
1719
|
-
selectOptionalEntities,
|
|
1720
|
-
selectIds,
|
|
1721
|
-
selectTotal,
|
|
1722
|
-
selectAll,
|
|
1723
|
-
read,
|
|
1724
|
-
readLocalRecord,
|
|
1725
|
-
readAndWait,
|
|
1726
|
-
remove,
|
|
1727
|
-
purge,
|
|
1728
|
-
write,
|
|
1729
|
-
patch,
|
|
1730
|
-
upsert,
|
|
1731
|
-
upload,
|
|
1732
|
-
readFileContent,
|
|
1733
|
-
share,
|
|
1734
|
-
upsertSSREntity,
|
|
1735
|
-
removeCachedEntity,
|
|
1736
|
-
applyDbCacheAction
|
|
1737
|
-
};
|