sandforge 1.83.0 → 1.84.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/README.md +1 -1
- package/lib/chunk-23SEDORH.mjs +11 -0
- package/lib/{chunk-I5C4O3VA.mjs → chunk-24RFOFYT.mjs} +1 -1
- package/lib/chunk-26POJDIT.mjs +7 -0
- package/lib/{chunk-WJAZ5LHL.mjs → chunk-2AZQHBEF.mjs} +1 -1
- package/lib/{chunk-IHGYJZZ2.mjs → chunk-2HVOZUM4.mjs} +1 -1
- package/lib/{chunk-3V4YH5KO.mjs → chunk-2JDAOWUW.mjs} +1 -1
- package/lib/{chunk-BNKT3R3F.mjs → chunk-2METQHGG.mjs} +1 -1
- package/lib/chunk-2WFIVO4F.mjs +13 -0
- package/lib/chunk-2YHZBUZE.mjs +7 -0
- package/lib/{chunk-7DPHZWA4.mjs → chunk-326AJTIU.mjs} +14 -14
- package/lib/{chunk-UIR77ZJD.mjs → chunk-36JOHEJL.mjs} +1 -1
- package/lib/chunk-3PVRGTVK.mjs +7 -0
- package/lib/{chunk-2WMKJVD2.mjs → chunk-3Q353S2R.mjs} +1 -1
- package/lib/chunk-3TZSBHEY.mjs +7 -0
- package/lib/{chunk-T36DZJPH.mjs → chunk-43TOMFV4.mjs} +1 -1
- package/lib/{chunk-XAMMIPZ4.mjs → chunk-4CVUUVGJ.mjs} +1 -1
- package/lib/{chunk-6YC2ELCU.mjs → chunk-4EOHEDFP.mjs} +1 -1
- package/lib/{chunk-ZB5E7NHU.mjs → chunk-4JE4BYXK.mjs} +1 -1
- package/lib/{chunk-JREKJO3D.mjs → chunk-54WZUS7J.mjs} +1 -1
- package/lib/{chunk-CGZGL6VT.mjs → chunk-5CRLRHOJ.mjs} +1 -1
- package/lib/{chunk-UOHZW2L4.mjs → chunk-5IZTFMJM.mjs} +1 -1
- package/lib/{chunk-6VOQFISN.mjs → chunk-5M5FQ7RP.mjs} +1 -1
- package/lib/{chunk-U4YFYSF3.mjs → chunk-5SMWFNE7.mjs} +1 -1
- package/lib/{chunk-HQZUQXDC.mjs → chunk-5XTUSN72.mjs} +1 -1
- package/lib/chunk-6I6TWNV5.mjs +7 -0
- package/lib/{chunk-QLRWU3MB.mjs → chunk-6JWWSDM6.mjs} +1 -1
- package/lib/chunk-6O222PW6.mjs +7 -0
- package/lib/{chunk-J3TIHLWG.mjs → chunk-6PD6K7LP.mjs} +1 -1
- package/lib/{chunk-ISAUCWYK.mjs → chunk-6QE6R6RL.mjs} +1 -1
- package/lib/{chunk-2KTGDYUH.mjs → chunk-6WX5ZU7Q.mjs} +1 -1
- package/lib/{chunk-XAUQXYPW.mjs → chunk-6YL7BNYD.mjs} +1 -1
- package/lib/chunk-6ZLKIT3H.mjs +7 -0
- package/lib/{chunk-XKFHTBAB.mjs → chunk-7QYHEHMA.mjs} +1 -1
- package/lib/chunk-7SQSWVAU.mjs +9 -0
- package/lib/{chunk-NNV7IGM7.mjs → chunk-7UVKIWKV.mjs} +1 -1
- package/lib/{chunk-RZKJQOOC.mjs → chunk-7WATA4SB.mjs} +1 -1
- package/lib/{chunk-DMT5SCO3.mjs → chunk-7YNM6KFZ.mjs} +1 -1
- package/lib/{chunk-TMIESDE5.mjs → chunk-A3MYSOOC.mjs} +1 -1
- package/lib/chunk-AL4C3GFT.mjs +7 -0
- package/lib/chunk-B3FBHVNN.mjs +21 -0
- package/lib/{chunk-CDWZGQAJ.mjs → chunk-B63POIPQ.mjs} +1 -1
- package/lib/{chunk-YEVB7LVK.mjs → chunk-BAWCOKRW.mjs} +1 -1
- package/lib/{chunk-FVLFO2S6.mjs → chunk-BBRWFKS5.mjs} +1 -1
- package/lib/chunk-BEA27DLS.mjs +7 -0
- package/lib/chunk-BRY3PLIZ.mjs +7 -0
- package/lib/chunk-CBH3TOWK.mjs +341 -0
- package/lib/{chunk-7V2UYZ6S.mjs → chunk-CPQIZGG5.mjs} +1 -1
- package/lib/chunk-CVHNXJH3.mjs +7 -0
- package/lib/{chunk-ZOSESZ22.mjs → chunk-D4GF4FAB.mjs} +1 -1
- package/lib/chunk-DGDRQRCW.mjs +7 -0
- package/lib/{chunk-2N73W63D.mjs → chunk-DPMRIMUC.mjs} +1 -1
- package/lib/chunk-DUN2EPRC.mjs +7 -0
- package/lib/chunk-E3A3LOCY.mjs +7 -0
- package/lib/{chunk-KWAVSZ2B.mjs → chunk-EAC5QCE3.mjs} +1 -1
- package/lib/{chunk-JUOQUG7U.mjs → chunk-EC72TIEG.mjs} +1 -1
- package/lib/chunk-EPFCERGL.mjs +7 -0
- package/lib/{chunk-6KOUYHEY.mjs → chunk-ETDCBLGU.mjs} +1 -1
- package/lib/{chunk-2R6GFNKF.mjs → chunk-F3AQW6IU.mjs} +1 -1
- package/lib/{chunk-AHUGG3WU.mjs → chunk-FITPY3L4.mjs} +1 -1
- package/lib/chunk-FNJ4SGWO.mjs +7 -0
- package/lib/{chunk-EOQON3E5.mjs → chunk-FP7CYB2F.mjs} +1 -1
- package/lib/{chunk-262TP6UU.mjs → chunk-GKY2JMHY.mjs} +1 -1
- package/lib/{chunk-JBWJ6UEZ.mjs → chunk-GMIGWR6U.mjs} +1 -1
- package/lib/{chunk-OS5GE52G.mjs → chunk-GNRSF65U.mjs} +1 -1
- package/lib/chunk-GOOVPVWX.mjs +7 -0
- package/lib/{chunk-DB5RVDC5.mjs → chunk-GWZRR3MM.mjs} +1 -1
- package/lib/{chunk-SX6QWYCQ.mjs → chunk-H2BHESDA.mjs} +2 -2
- package/lib/chunk-H4CGM6YO.mjs +7 -0
- package/lib/{chunk-NFEBX75O.mjs → chunk-HCGXK7G7.mjs} +1 -1
- package/lib/{chunk-4X5D3MSV.mjs → chunk-HIDW7FNV.mjs} +1 -1
- package/lib/chunk-HSBXRQTI.mjs +7 -0
- package/lib/chunk-HUZPBE47.mjs +7 -0
- package/lib/{chunk-F5SBGJWW.mjs → chunk-HV7VPEXP.mjs} +1 -1
- package/lib/chunk-I6E6T6YY.mjs +7 -0
- package/lib/chunk-IUM4NFKI.mjs +10 -0
- package/lib/chunk-IVFVNNGB.mjs +37 -0
- package/lib/{chunk-L4MSL4U7.mjs → chunk-IZGCEOYO.mjs} +1 -1
- package/lib/{chunk-E3RQ575Y.mjs → chunk-J3DND3BC.mjs} +1 -1
- package/lib/{chunk-MJD6CPZZ.mjs → chunk-JAEDM4SI.mjs} +1 -1
- package/lib/chunk-JCFBFF4Y.mjs +7 -0
- package/lib/{chunk-U2CTKIPE.mjs → chunk-JE6SCT6R.mjs} +1 -1
- package/lib/{chunk-XJICAOAQ.mjs → chunk-JGZPD4IM.mjs} +1 -1
- package/lib/{chunk-XCJUNX63.mjs → chunk-JKJ74BX5.mjs} +1 -1
- package/lib/{chunk-WAYQLQAD.mjs → chunk-JLSIWO4Z.mjs} +1 -1
- package/lib/{chunk-D7XUNWWU.mjs → chunk-JSAJS3MY.mjs} +1 -1
- package/lib/chunk-JTJK2D36.mjs +7 -0
- package/lib/{chunk-OTJH6AEA.mjs → chunk-KAZS5Z6W.mjs} +1 -1
- package/lib/chunk-KB4ZHM4Q.mjs +10 -0
- package/lib/{chunk-N2HYG3BL.mjs → chunk-KGU4SVIT.mjs} +1 -1
- package/lib/{chunk-FKCIGJOI.mjs → chunk-KJWFYBMU.mjs} +2 -2
- package/lib/{chunk-KXUOHACP.mjs → chunk-KZTZDC7H.mjs} +1 -1
- package/lib/{chunk-S4PRKKGC.mjs → chunk-L2E5WBGD.mjs} +1 -1
- package/lib/{chunk-X2XZQ434.mjs → chunk-L53JWJ3S.mjs} +1 -1
- package/lib/{chunk-CQAFVEKP.mjs → chunk-LA4KIATH.mjs} +6 -6
- package/lib/chunk-LC3NDW4N.mjs +7 -0
- package/lib/{chunk-4V3QO7HF.mjs → chunk-LKTNQEBS.mjs} +1 -1
- package/lib/chunk-M2ABR4JM.mjs +7 -0
- package/lib/{chunk-3CM7LAPE.mjs → chunk-M4BLK6HJ.mjs} +1 -1
- package/lib/{chunk-Z3MGN42K.mjs → chunk-M6K34KGF.mjs} +1 -1
- package/lib/{chunk-TUPZY2QJ.mjs → chunk-MDMPJEV3.mjs} +1 -1
- package/lib/{chunk-BVZ5H3N4.mjs → chunk-MJZU3U5O.mjs} +68 -63
- package/lib/{chunk-OUU47Y7A.mjs → chunk-MSIEU5MR.mjs} +1 -1
- package/lib/{chunk-QQDZQCO2.mjs → chunk-N4WPCWJO.mjs} +1 -1
- package/lib/{chunk-MTM4KG3T.mjs → chunk-NCZKWSC7.mjs} +1 -1
- package/lib/{chunk-Y7YUNRKK.mjs → chunk-NED4MBIM.mjs} +1 -1
- package/lib/{chunk-QKJXIY6L.mjs → chunk-NOBQTEQD.mjs} +1 -1
- package/lib/{chunk-WBELLGNE.mjs → chunk-NSQWI7ZY.mjs} +1 -1
- package/lib/{chunk-BPHTA6KP.mjs → chunk-O677VOGO.mjs} +1 -1
- package/lib/chunk-OFTT7J2M.mjs +7 -0
- package/lib/{chunk-JH4ZTVQN.mjs → chunk-OLCVHL7I.mjs} +1 -1
- package/lib/chunk-OM5NORJG.mjs +7 -0
- package/lib/{chunk-QP3JLFIO.mjs → chunk-OMNMLKDT.mjs} +1 -1
- package/lib/{chunk-WABXKL4N.mjs → chunk-OPMO6I45.mjs} +1 -1
- package/lib/{chunk-7ZBDACVG.mjs → chunk-OUZQPYT3.mjs} +1 -1
- package/lib/chunk-OVNMB6Q2.mjs +7 -0
- package/lib/{chunk-DKDKCGXV.mjs → chunk-PAXNWTYK.mjs} +1 -1
- package/lib/{chunk-GLN4PI5P.mjs → chunk-PBY2O6OF.mjs} +1 -1
- package/lib/chunk-PEDQPM2P.mjs +926 -0
- package/lib/chunk-PH7SP4YK.mjs +21 -0
- package/lib/{chunk-BT43WSOS.mjs → chunk-PMN4PAC3.mjs} +1 -1
- package/lib/chunk-PMWAFDUB.mjs +48 -0
- package/lib/chunk-PPLVFX6N.mjs +7 -0
- package/lib/{chunk-L3I6DAHX.mjs → chunk-PR3XCSPO.mjs} +1 -1
- package/lib/{chunk-WZN36ACK.mjs → chunk-PR42EZSR.mjs} +1 -1
- package/lib/{chunk-NDFFIJL5.mjs → chunk-PWRJRL5U.mjs} +1 -1
- package/lib/{chunk-NS6ONPWL.mjs → chunk-Q7GIJBCD.mjs} +1 -1
- package/lib/chunk-Q7TLC3I2.mjs +7 -0
- package/lib/{chunk-ALBY5SOH.mjs → chunk-QAFPQ3YB.mjs} +1 -1
- package/lib/{chunk-KKS2KFBT.mjs → chunk-QKEKG2LD.mjs} +1 -1
- package/lib/{chunk-OOIDCHBQ.mjs → chunk-QO53K5W2.mjs} +2 -2
- package/lib/{chunk-HVX2AFYW.mjs → chunk-QTG6LUZT.mjs} +1 -1
- package/lib/{chunk-K7G3W7XH.mjs → chunk-RE7RYF3B.mjs} +1 -1
- package/lib/{chunk-JIPT5FUD.mjs → chunk-RGBGUCJA.mjs} +1 -1
- package/lib/{chunk-GT5ZKU6V.mjs → chunk-RGUQOSBU.mjs} +1 -1
- package/lib/{chunk-VXZ5PTOM.mjs → chunk-RHNTHGNU.mjs} +1 -1
- package/lib/chunk-RKTFFCNS.mjs +7 -0
- package/lib/chunk-RMFU4BAL.mjs +28 -0
- package/lib/{chunk-DNQKVCUV.mjs → chunk-ROV3QXEF.mjs} +11 -11
- package/lib/chunk-RT47RKLY.mjs +7 -0
- package/lib/{chunk-ISOSTAJR.mjs → chunk-S42RBRH2.mjs} +1 -1
- package/lib/{chunk-27BBEGUD.mjs → chunk-SI267LYR.mjs} +1 -1
- package/lib/chunk-T3G6VZNS.mjs +7 -0
- package/lib/chunk-TNT27RBG.mjs +7 -0
- package/lib/chunk-UBIKR5VO.mjs +7 -0
- package/lib/chunk-UI3JQVRU.mjs +8 -0
- package/lib/{chunk-RVCPQVKM.mjs → chunk-UIOMAX56.mjs} +1 -1
- package/lib/chunk-UX3BVH2Y.mjs +7 -0
- package/lib/{chunk-L4RJX7DG.mjs → chunk-VCUXCK36.mjs} +1 -1
- package/lib/chunk-VINGECAJ.mjs +10 -0
- package/lib/chunk-VOXJHJIE.mjs +7 -0
- package/lib/chunk-W6PN6TJG.mjs +7 -0
- package/lib/{chunk-D6JT4PAB.mjs → chunk-WAPSSYMT.mjs} +1 -1
- package/lib/{chunk-7BQMBXKX.mjs → chunk-WUUKFE2U.mjs} +1 -1
- package/lib/chunk-WWTCWWZI.mjs +7 -0
- package/lib/chunk-WXDLQT2O.mjs +10 -0
- package/lib/{chunk-TCEXCHXR.mjs → chunk-WY5V5PR3.mjs} +1 -1
- package/lib/chunk-X4BXESMQ.mjs +7 -0
- package/lib/chunk-XBQGZGWR.mjs +7 -0
- package/lib/{chunk-AXFD2OH6.mjs → chunk-XGGOUNPP.mjs} +1 -1
- package/lib/chunk-XKWW3GKF.mjs +7 -0
- package/lib/{chunk-PDRXM5WN.mjs → chunk-Y2DRK37K.mjs} +1 -1
- package/lib/{chunk-ZXOUWHYE.mjs → chunk-YA6ATMTB.mjs} +1 -1
- package/lib/{chunk-54HYHHVL.mjs → chunk-YDXMTWAT.mjs} +1 -1
- package/lib/chunk-YHR4WQPR.mjs +7 -0
- package/lib/{chunk-LWES2KZE.mjs → chunk-YTLUYSMF.mjs} +1 -1
- package/lib/{chunk-2K5BYZQM.mjs → chunk-YWEQQL3C.mjs} +1 -1
- package/lib/{chunk-C6RKM4BB.mjs → chunk-Z4LKKOFY.mjs} +1 -1
- package/lib/chunk-ZBAWJUG2.mjs +7 -0
- package/lib/{chunk-446GBKAC.mjs → chunk-ZJW6YOMV.mjs} +1 -1
- package/lib/chunk-ZQQXSCVI.mjs +7 -0
- package/lib/{chunk-L6CLN664.mjs → chunk-ZQWIVYVM.mjs} +1 -1
- package/lib/{chunk-CXKZ6TYV.mjs → chunk-ZV7ZFQQC.mjs} +1 -1
- package/lib/sandforge-autopilot.mjs +25 -25
- package/lib/sandforge-backup.mjs +1 -1
- package/lib/sandforge-checkpoint.mjs +1 -1
- package/lib/sandforge-cleanup.mjs +1 -1
- package/lib/sandforge-clone.mjs +1 -1
- package/lib/sandforge-compare.mjs +52 -21
- package/lib/sandforge-dataops.mjs +1 -1
- package/lib/sandforge-empty.mjs +1 -1
- package/lib/sandforge-env.mjs +95 -95
- package/lib/sandforge-frozen.mjs +1 -1
- package/lib/sandforge-mcp.mjs +12 -12
- package/lib/sandforge-monitor.mjs +1 -1
- package/lib/sandforge-pipeline.mjs +1 -1
- package/lib/sandforge-seed.mjs +1 -1
- package/lib/sandforge-sync.mjs +1 -1
- package/lib/sandforge-users.mjs +1 -1
- package/lib/sandforge.mjs +1 -1
- package/lib/sf/sandforge/compare.mjs +2 -2
- package/lib/sfPlugin.mjs +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/lib/chunk-2ADSD5WK.mjs +0 -7
- package/lib/chunk-2GSMHGIV.mjs +0 -7
- package/lib/chunk-36Y225OM.mjs +0 -7
- package/lib/chunk-3OVTKRS4.mjs +0 -7
- package/lib/chunk-4GCYGQXD.mjs +0 -7
- package/lib/chunk-4JKR4PTZ.mjs +0 -8
- package/lib/chunk-5OGNK3JP.mjs +0 -37
- package/lib/chunk-6QSHWIZI.mjs +0 -48
- package/lib/chunk-77IVKH7R.mjs +0 -7
- package/lib/chunk-77MZRBWX.mjs +0 -7
- package/lib/chunk-7WSQ65WG.mjs +0 -9
- package/lib/chunk-A32ISQ6M.mjs +0 -28
- package/lib/chunk-AG24QMSY.mjs +0 -7
- package/lib/chunk-BH76USTQ.mjs +0 -11
- package/lib/chunk-BZ24IAP5.mjs +0 -7
- package/lib/chunk-CN5HGFG4.mjs +0 -7
- package/lib/chunk-CTPLYUXA.mjs +0 -7
- package/lib/chunk-DIGUC7S4.mjs +0 -341
- package/lib/chunk-DSR2MSBH.mjs +0 -7
- package/lib/chunk-ETNQHIDI.mjs +0 -9
- package/lib/chunk-FBXH4VRQ.mjs +0 -7
- package/lib/chunk-FYWNSMOZ.mjs +0 -10
- package/lib/chunk-GEEWPTV5.mjs +0 -7
- package/lib/chunk-GTRU5AV5.mjs +0 -7
- package/lib/chunk-I3ZO76LL.mjs +0 -21
- package/lib/chunk-ISA2NYJV.mjs +0 -7
- package/lib/chunk-IXIY6Q4M.mjs +0 -7
- package/lib/chunk-JAV6F6OA.mjs +0 -7
- package/lib/chunk-JYUMD357.mjs +0 -7
- package/lib/chunk-L47JCNP3.mjs +0 -7
- package/lib/chunk-LI2XNV7F.mjs +0 -7
- package/lib/chunk-LP2D3JJP.mjs +0 -7
- package/lib/chunk-LYOGCIYD.mjs +0 -925
- package/lib/chunk-N5UIE4IR.mjs +0 -7
- package/lib/chunk-O7GCCRPW.mjs +0 -7
- package/lib/chunk-OO24ZYYJ.mjs +0 -7
- package/lib/chunk-OS6HFJ7L.mjs +0 -7
- package/lib/chunk-P6WRYJN3.mjs +0 -7
- package/lib/chunk-PGRY365W.mjs +0 -7
- package/lib/chunk-PPGDAUEQ.mjs +0 -7
- package/lib/chunk-Q4PPI3KG.mjs +0 -7
- package/lib/chunk-QFTF2PGS.mjs +0 -21
- package/lib/chunk-QO4MPHZD.mjs +0 -7
- package/lib/chunk-QXB6U3ZP.mjs +0 -7
- package/lib/chunk-R3OM3X4L.mjs +0 -8
- package/lib/chunk-R7GKMAT4.mjs +0 -7
- package/lib/chunk-SCKUIE3R.mjs +0 -7
- package/lib/chunk-SU65Z2BA.mjs +0 -7
- package/lib/chunk-T7DDS4UQ.mjs +0 -7
- package/lib/chunk-TQJ5NPRC.mjs +0 -7
- package/lib/chunk-VZLJZEV2.mjs +0 -7
- package/lib/chunk-W3BQGMTR.mjs +0 -7
- package/lib/chunk-WXU6ZJIV.mjs +0 -7
- package/lib/chunk-X4HZD5U2.mjs +0 -7
- package/lib/chunk-X6XNTOGO.mjs +0 -7
- package/lib/chunk-XMQ5R6TC.mjs +0 -10
- package/lib/chunk-XPXEQKLR.mjs +0 -7
- package/lib/chunk-YBZIDW6W.mjs +0 -7
- package/lib/chunk-ZCOSME6P.mjs +0 -7
- package/lib/chunk-ZTHC42X6.mjs +0 -7
package/lib/chunk-FYWNSMOZ.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{c as Pt,d as It}from"./chunk-U2CTKIPE.mjs";import{a as Je,c as Rn,d as Re,e as Rt,f as Ot,g as At,h as St,j as Ct,l as Fn,m as En}from"./chunk-NDFFIJL5.mjs";import{d as tn,f as an,g as ut,h as gt,i as ht,k as wt,l as bn,m as vn}from"./chunk-RVCPQVKM.mjs";import{a as Nn}from"./chunk-X2XZQ434.mjs";import{B as ot}from"./chunk-IXIY6Q4M.mjs";import{A as Bn,B as se,C as yt,E as xe,F as cn,G as bt,e as it,i as te,l as Ve,p as jn,q as ft,r as $e,s as lt,t as pt,x as mt,y as kt,z as ve}from"./chunk-EOQON3E5.mjs";import{b as Z,e as We,g as Ln}from"./chunk-Y7YUNRKK.mjs";import{J as dt,a as st,b as rt,d as nn,o as at,x as ct,z as yn}from"./chunk-N2HYG3BL.mjs";import{b as rn,d as Le,e as tt}from"./chunk-MJD6CPZZ.mjs";import{i as nt}from"./chunk-INIT2UKJ.mjs";import{E as en}from"./chunk-ZXOUWHYE.mjs";import{f as Yn,g as le,h as me,i as et,p as kn}from"./chunk-Z3MGN42K.mjs";import{q as mn,r as je}from"./chunk-2GSMHGIV.mjs";import{h as pn}from"./chunk-TZE3Y7IQ.mjs";import{b as Pe}from"./chunk-CA5NAXSU.mjs";import{Uc as pe}from"./chunk-6QSHWIZI.mjs";import{b as Xn,k as hn,l as wn}from"./chunk-WZQEK4WT.mjs";import{randomBytes as yi}from"node:crypto";import{appendFile as bi,readdir as Ri,rm as Oi}from"node:fs/promises";import{join as Jn}from"node:path";import{appendFile as No,rm as qn}from"node:fs/promises";import{join as jo}from"node:path";import{appendFile as ho}from"node:fs/promises";import{join as wo}from"node:path";var In=it*10,po=2e3,mo="005",ko=["Id","IsDeleted","CreatedDate","LastModifiedById","LastModifiedDate","LatestPublishedVersionId","ContentSize"],Mt=1,Tt=2,_t=4,Dt=8,_n=16,An=32,Sn=64,Nt=1,jt=2,Lt=4,On=32768,Cn={toDelete:["createdSince","broughtBackSince"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","toRecreate"]},Mn={toDelete:["createdSince","broughtBackSince","comesBackWithParent"],comesBack:["inBin","withParent","deletedWhileTaken"],lost:["goneForGood","deletedWithCreatedParent","deletedWithParentOutside"]};function Be(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function $n(e){return`${e.ContentDocumentId.slice(0,15)}${e.LinkedEntityId.slice(0,15)}`}function $t(e){return`${e.ShareType}/${e.Visibility}`}async function*dn(e){try{for await(let n of se(e))yield n}catch(n){if(n.code==="ENOENT")return;throw n}}function vt(e){return typeof e=="string"&&/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/.test(e)?e:null}function Tn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function yo(e){let n=en(e);return n===null?Number.NaN:Date.parse(n)}var Ge=class{constructor(n){this.file=n}file;lines=[];count=0;async add(n){this.lines.push(`${JSON.stringify(n)}
|
|
8
|
-
`),this.count++,this.lines.length>=po&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await ho(this.file,n,{encoding:"utf8",mode:nn,flag:"a"})}};function Bt(e,n,t){let o=pe(n);return wo(e,`${o}.links${t===void 0?"":`.${t}`}.ndjson`)}function*Wt(e,n){let t=[];for(let o of e)t.push(o),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}var bo=wn({sobjects:hn(Yn)}).loose(),Wn=class{files=new Z;held=new Map;sharings=[];prefixes;now;constructor(n,t){this.prefixes=n,this.now=t}anchoredNow(n){return(this.files.flagsOf(n)&_t)!==0}anchoredThen(n){return(this.files.flagsOf(n)&Tt)!==0}sharingAt(n){let t=this.sharings.indexOf(n);return t>=0?t:(this.sharings.push(n),this.sharings.length-1)}};function Ro(e,n){let t=n.fields.find(s=>s.name.toLowerCase()==="linkedentityid"),o=new Set((t?.referenceTo??[]).map(s=>s.toLowerCase()));if(o.size===0)throw new Error(`The describe of ${me} names no record a link ties a file to.`);return e.objects.map(({objectApiName:s})=>s).filter(s=>{if(s.toLowerCase()===le.toLowerCase()||!o.has(s.toLowerCase()))return!1;let i=e.changes.get(s);return i!==void 0&&!("unread"in i)&&(i.count??0)>0})}async function*Oo(e,n){let t=await $e.read(e.folder,e.snapshotId,n);for(let s=0;s<t.size;s++)yield t.idAt(s);let o=e.changes.get(n);if(!(o===void 0||"unread"in o||!o.live))for await(let s of se(o.live.file))typeof s.Id=="string"&&!t.has(s.Id)&&(yield s.Id)}async function Ao(e,n){let{reader:t,previewDir:o,signal:s}=e,i=n.map(l=>({...St(l),file:Bt(o,l)})),r=await Bn(t,i,s),a=[];for(let[l,w]of r.entries()){let p=n[l];if(w.read){a.push({objectApiName:p,file:i[l].file});continue}let c=0,g=Oo(e,p);for await(let d of So(g,Je*In)){let h=[...Wt(d,Je)].map(j=>({...Ct(p,j),file:Bt(o,p,c++)})),R=(await Bn(t,h,s)).find(j=>!j.read);if(R&&!R.read)throw new Error(`The links of the files of ${p} could not be read whole: ${w.reason}; read by the ids of its records, ${R.reason}`);for(let j of h)a.push({objectApiName:p,file:j.file})}}return a}async function*So(e,n){let t=[];for await(let o of e)t.push(o),t.length>=n&&(yield t,t=[]);t.length>0&&(yield t)}async function xt(e){let n=bo.safeParse(await e.describeGlobal());if(!n.success)throw new Error("The org\u2019s global describe does not read as one.");let t=Ot(n.data.sobjects,e.objects.map(({objectApiName:a})=>a)),o=Ro(e,await e.linkDescribe),s=await Ao(e,o),i=new Wn(t,s);for await(let a of En(e.folder))i.files.add(a.Id,Mt|(a.anchored?Tt:0));let r=await jn.read(e.folder);for await(let a of Fn(e.folder))i.held.set($n(Gt(a,r)),i.sharingAt($t(a)));for(let{file:a}of s)for await(let l of se(a))typeof l.ContentDocumentId=="string"&&i.files.add(l.ContentDocumentId,_t);return i}function Gt(e,n){let t=Be(e.LinkedEntityId),o=t===void 0?void 0:n.currentOf(t);return o===void 0?e:{...e,LinkedEntityId:o}}async function Pn(e,n,t,o,s){for(let i of o)for await(let r of dn(n(t,i)))typeof r.Id=="string"&&e.add(r.Id,s)}async function Ft(e){let n=0;for await(let t of dn(e))typeof t.Id=="string"&&n++;return n}async function Et(e,n,t){let o=new Map;if(n.length===0)return o;let s=Le([...n],Je).map(a=>({objectApiName:le,soql:`SELECT ${ko.join(", ")} FROM ${le} WHERE Id IN (${a})`,scanAll:!0})),r=(await ve(e,s,(a,l)=>{for(let w of l){let p=Be(w.Id);p!==void 0&&o.set(p,w)}},t)).find(a=>!a.read);if(r&&!r.read)throw new Error(`The files the checkpoint names could not be read by their ids: ${r.reason}`);return o}function Co(e,n){return n===void 0||n.version===null||e.LatestPublishedVersionId===null?!1:Be(n.version)!==Be(e.LatestPublishedVersionId)}async function Ut(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=n.files,r=le;await Pn(i,o,r,Cn.toDelete,_n),await Pn(i,o,r,Cn.comesBack,An),await Pn(i,o,r,Cn.lost,Sn);let a=new Map,l=e.fileChanges;if(!("unread"in l)){for(let D of[l.live,l.deleted])if(D!==void 0)for await(let L of se(D.file)){let N=Be(L.Id);N!==void 0&&(i.add(String(L.Id),Dt),a.set(N,{version:vt(L.LatestPublishedVersionId),size:Tn(L.ContentSize)}))}}let w=await $e.read(e.folder,e.snapshotId,r),p=D=>(i.flagsOf(D)&Dt)===0&&!w.has(D),c=new Ge(o(r,"createdSince")),g=new Ge(o(r,"deletedWhileTaken")),d=new Ge(o(r,"goneForGood")),f=new Ge(o(r,"newFileVersion")),h=0,b=0,R=async D=>{let L=await Et(t,D.filter(N=>N.anchored&&p(N.Id)).map(N=>N.Id),s);for(let N of D){if(!N.anchored)continue;let V=Be(N.Id)??"",J=a.get(V);if(p(N.Id)){let x=L.get(V);if(x===void 0){i.add(N.Id,Sn),await d.add({Id:N.Id});continue}J={version:vt(x.LatestPublishedVersionId),size:Tn(x.ContentSize)},x.IsDeleted===!0&&(i.add(N.Id,An),await g.add({Id:N.Id}))}let Y=i.flagsOf(N.Id);(Y&Sn)===0&&((Y&An)!==0&&(h+=J?.size??N.ContentSize??0),Co(N,J)&&await f.add({Id:N.Id}))}},j=[];for await(let D of En(e.folder))j.push(D),j.length>=Je*In&&(await R(j),j=[]);await R(j);let C=new Z,v=[],O=async D=>{let L=await Et(t,D,s);for(let N of D){let V=L.get(Be(N)??"");V===void 0||V.IsDeleted===!0||yo(V.CreatedDate)>=e.t0s&&(i.add(N,_n),await c.add({Id:N}),v.push(V))}},B=[];for(let{file:D}of n.now)for await(let L of se(D)){let N=L.ContentDocumentId;typeof N!="string"||(i.flagsOf(N)&Mt)!==0||!p(N)||C.add(N)&&(B.push(N),B.length>=Je*In&&(await O(B),B=[]))}await O(B);for await(let D of dn(o(r,"createdSince"))){let L=Be(D.Id);L!==void 0&&(b+=a.get(L)?.size??0)}for await(let D of dn(o(r,"broughtBackSince")))b+=a.get(Be(D.Id)??"")?.size??0;for(let D of v)b+=Tn(D.ContentSize)??0;for(let D of[c,g,d,f])await D.flush();return{files:{...await Po(e),outsideAdded:await Ft(o(r,"outsideAdded")),outsideDeleted:await Ft(o(r,"outsideDeleted")),storage:{bringBack:h,undo:b},...e.queryAllFiles?{}:{blindSpot:!0}},createdSince:c.count,deletedWhileTaken:g.count,goneForGood:d.count,newFileVersion:f.count,changedBy:v}}async function Po(e){let{anchors:n,classFileOf:t}=e,o=new Z,s=new Set;for(let{objectApiName:c}of e.objects){if(c.toLowerCase()===le.toLowerCase())continue;if(!e.told.has(c)){for(let[d,f]of n.prefixes)f.toLowerCase()===c.toLowerCase()&&s.add(d);continue}let g=(d,f)=>Pn(o,t,c,d,f);await g(Mn.toDelete,Nt),await g(Mn.comesBack,jt),await g(Mn.lost,Lt)}let i=c=>s.has(c.LinkedEntityId.slice(0,3)),r=c=>new Ge(Re(e.previewDir,c)),a=r("linkAdded"),l=r("linkRemoved"),w=r("linkChanged");for(let{file:c}of n.now)for await(let g of se(c)){let d=Rn.safeParse(g);if(!d.success)throw new Error(`The org answered a link that does not read as one: ${d.error.message}`);let f=d.data,h=$n(f),b=n.held.get(h);if(b!==void 0){if(n.held.set(h,b|On),i(f)||n.sharings[b&~On]===$t(f))continue;let[R,j]=(n.sharings[b&~On]??"").split("/"),C={...f,ShareType:R,Visibility:j,now:{ShareType:f.ShareType,Visibility:f.Visibility}};await w.add(C);continue}i(f)||(n.files.flagsOf(f.ContentDocumentId)&_n)===0&&(o.flagsOf(f.LinkedEntityId)&Nt)===0&&await a.add(f)}let p=await jn.read(e.folder);for await(let c of Fn(e.folder)){let g=Gt(c,p);((n.held.get($n(g))??0)&On)!==0||i(g)||(n.files.flagsOf(g.ContentDocumentId)&(An|Sn))===0&&(o.flagsOf(g.LinkedEntityId)&(jt|Lt))===0&&await l.add(g)}for(let c of[a,l,w])await c.flush();return{unlink:a.count,relink:l.count,updateLinks:w.count}}async function zt(e){let{anchors:n,reader:t,classFileOf:o,signal:s}=e,i=[];for(let l of Cn.toDelete)for await(let w of dn(o(le,l)))typeof w.Id=="string"&&i.push(w.Id);if(i.length===0)return{links:0,files:0};let r=new Map,a=0;for(let l of Wt(Le(i,Je),In)){let w=l.map(g=>({objectApiName:me,soql:`SELECT Id, ContentDocumentId, LinkedEntityId FROM ${me} WHERE ContentDocumentId IN (${g})`,scanAll:!1})),c=(await ve(t,w,(g,d)=>{for(let f of d){let h=f.LinkedEntityId,b=f.ContentDocumentId;typeof h!="string"||typeof b!="string"||h.startsWith(mo)||At({LinkedEntityId:h},n.prefixes)===void 0&&(a++,r.set(b.slice(0,15),b))}},s)).find(g=>!g.read);if(c&&!c.read)throw new Error(`The links of the files to delete to what the checkpoint does not hold could not be read: ${c.reason}`)}if(r.size>0){let l=new Ge(o(le,"outsideParents"));for(let w of r.values())await l.add({Id:w});await l.flush()}return{links:a,files:r.size}}var Gn=Object.freeze({kind:"org",notHeld:new Map,heldAs:()=>"org",unseenOf:()=>Promise.resolve([]),requests:()=>0,diffAccess:()=>({kind:"org"})});function xn(e){return e.slice(0,15)}function Io(e,n,t,o){let s=n.detail!==void 0?` (${n.detail})`:"";switch(n.reason){case"noViewAll":case"noModifyAll":return`${t} ${o} View All and Modify All on ${e}`;case"parentNotSeen":return`${t} ${o} View All and Modify All on every record ${e} hangs from`+s;case"activities":return`${t} doesn't have View All Data and Modify All Data, which tasks and events need: Salesforce has no View All for activities`;case"catalog":return`${t} doesn't have View All Data and Modify All Data, which products and price books need: Salesforce has no View All or Modify All for them`;case"filesNotProven":return`${t} doesn't have View All Data and Modify All Data, which files need: nothing else proves who sees every file`;case"settingNotProven":return`${t} doesn't have View All Data and Modify All Data, which custom settings need: no permission on an object proves who sees and writes every row`}}async function ss(e){let{grants:n,reader:t}=e;if(n.kind==="org"||e.userId===void 0)return Gn;let o=e.checkpoint.objects,s=o.filter(f=>f.customSetting!==void 0).map(f=>f.objectApiName),i=new Map,r=n.requests,a=async f=>{let h=[...new Set(f)].filter(j=>!i.has(j.toLowerCase()));if(h.length===0)return;let b=t.calls(),R=await Promise.allSettled(h.map(j=>t.describe(j)));r+=t.calls()-b,R.forEach((j,C)=>{if(j.status==="rejected"&&j.reason instanceof te)throw j.reason;let v=j.status==="fulfilled"&&"body"in j.value?j.value.body:void 0,O=tn.safeParse(v);i.set(h[C].toLowerCase(),O.success?O.data:void 0)})},l=()=>[...i.values()].filter(f=>f!==void 0),w=async f=>{let h=f.filter(R=>!n.objects.has(R.toLowerCase()));await a(h);let b={grants:n.objects,describes:l(),customSettings:s};return await a(Pt(f,b)),It(f,{...b,describes:l()})},p=await w(o.map(f=>f.objectApiName)),c=xn(e.userId)===xn(e.checkpoint.takenBy.userId)?"no longer has":"doesn't have",g=new Map,d=new Map;for(let[f,h]of p)"access"in h?g.set(f,h.access):d.set(f,Io(f,h,e.username,c));return{kind:"perObject",userKey:xn(e.userId),notHeld:d,heldAs:f=>g.get(f),unseenOf:async f=>{let h=await w(f);return f.filter(b=>{let R=h.get(b);return R===void 0||!("access"in R)})},requests:()=>r,diffAccess:()=>({kind:"perObject",requests:r})}}var Lo=["giveBack","touched","createdSince","broughtBackSince","comesBackWithParent","unexplained","inBin","withParent","deletedWhileTaken","toRecreate","goneForGood","convertedLead","activatedContract","carrier","deletedWithCreatedParent","deletedWithParentOutside","deletedByOther","outOfReach","undoCannot","outsideParents","outsideAdded","outsideDeleted","newFileVersion"],vo="Lead",Bo="IsConverted",Fo="Contract",Eo="Status",qt="StatusCode",Mo="Activated",To=["createdSince","broughtBackSince"];function X(e,n,t){return jo(e,`${pe(n)}.${t}.ndjson`)}var Dn=1e3,_o=1440*6e4,$o=60*6e4,Wo=100,xo=2e3,Jt=["LastModifiedById","LastModifiedDate"];function ee(e){return typeof e=="string"&&e.length>=15?e.slice(0,15):void 0}function ke(e){let n=en(e);return n===null?Number.NaN:Date.parse(n)}function Hn(e){return e.toLowerCase()===le.toLowerCase()}function Go(e){return e==null||e===""}function Ie(e,n){let t=n.toLowerCase();return e.find(o=>o.toLowerCase()===t)}function Uo(e){return!e.leftOutFields.some(n=>n.reason==="base64")}var fn=class{constructor(n){this.file=n}file;lines=[];written=!1;count=0;async add(n){this.lines.push(`${JSON.stringify(n)}
|
|
9
|
-
`),this.count++,this.lines.length>=xo&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await No(this.file,n,{encoding:"utf8",mode:nn,flag:this.written?"a":"w"}),this.written=!0}async discard(){this.lines=[],this.written&&await qn(this.file,{force:!0})}};async function Kn(e,n){await Promise.all(Lo.map(t=>qn(X(e,n,t),{force:!0})))}var Un=class{constructor(n){this.activeFrom=n}activeFrom;counts=new Map;active=new Set;add(n){let t=n.LastModifiedById;typeof t!="string"||t===""||(this.counts.set(t,(this.counts.get(t)??0)+1),ke(n.LastModifiedDate)>=this.activeFrom&&this.active.add(t))}byUser(){return Object.fromEntries([...this.counts].sort(([n],[t])=>n<t?-1:n>t?1:0))}};function Qt(e,n){let t,o=async()=>{let s=new Set;try{for await(let i of se(at(e,n))){let r=ee(i.Id);r!==void 0&&s.add(r)}}catch(i){throw i.code!=="ENOENT"?i:new Error(`The checkpoint\u2019s list of what ${n} held in the recycle bin is not on this machine.`)}return s};return async s=>(await(t??=o())).has(s)}async function zo(e,n,t,o){let s=pe(n.objectApiName),i=n.readMode==="scanAllLive",r=i?" AND IsDeleted = false":"",a=async p=>{let c=e.lane(),g=[];try{let d=await kt(c,{objectApiName:s,soql:p,scanAll:i},f=>{g.push(...f)});if(!d.read)throw new Error(d.reason);return g}finally{c.close()}},l=t.length>Wo?rn/4:rn,w=new Map;for(let p of Le(o,l)){let c=await nt(`SELECT ${t.join(", ")} FROM ${s} WHERE Id IN (${p})${r}`,a,{stamp:"SystemModstamp",...i?{idsWhere:"IsDeleted = false"}:{}});for(let g of c){let d=ee(g.Id);d!==void 0&&w.set(d,g)}}return w}var qo=/__(?:c|pc|s)$/i,Ho=/^(.+)__[A-Za-z]+__s$/i,Ko=/^(.+)__pc$/i,Vo=/^[A-Za-z][A-Za-z0-9_]*$/,Jo=200;function Qo(e,n){if(!qo.test(n)||!Vo.test(n))return;let t=Ko.exec(n);if(t)return{entity:je,name:`${t[1]}__c`};let o=Ho.exec(n);return o?{entity:e,name:`${o[1]}__c`}:{entity:e,name:n}}var Zo=hn(wn({QualifiedApiName:Xn()}).loose());function Xo(e,n){let t=`SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = '${pe(e)}' AND QualifiedApiName IN (`,o=r=>`${t}${r.map(a=>`'${a}'`).join(", ")})`,s=[],i=[];for(let r of n){let a=[...i,r],l=a.length>Jo||encodeURIComponent(o(a)).length>14e3;i.length>0&&l?(s.push({soql:o(i),names:i}),i=[r]):i=a}return i.length>0&&s.push({soql:o(i),names:i}),s}async function Yo(e,n){let t=new Map,o=new Map;for(let[r,a]of n){let l={removed:[],hidden:[]};t.set(r,l);for(let w of a){let p=Qo(r,w);if(p===void 0){l.hidden.push(w);continue}let c=o.get(p.entity)??new Map;o.set(p.entity,c);let g=p.name.toLowerCase(),d=c.get(g)??{name:p.name,fields:[]};c.set(g,d),d.fields.push({objectApiName:r,field:w})}}let s=0,i=new Map;for(let[r,a]of o){let l=new Set,w=new Map,p=Xo(r,[...a.values()].map(({name:c})=>c));for(let c of p){s++;try{let g=await e.tooling(c.soql);if(!g.done)throw new Error("FieldDefinition answered more than one page");let d=Zo.safeParse(g.records);if(!d.success)throw new Error("FieldDefinition answered rows with no field name");for(let f of d.data)l.add(f.QualifiedApiName.toLowerCase())}catch(g){if(g instanceof te)throw g;let d=Pe(g);for(let f of c.names)w.set(f.toLowerCase(),d)}}for(let[c,{fields:g}]of a){let d=w.get(c);for(let{objectApiName:f,field:h}of g){let b=t.get(f);if(b!==void 0)if(d!==void 0){let R=i.get(f)??{fields:[],reasons:[]};i.set(f,R),R.fields.push(h),R.reasons.includes(d)||R.reasons.push(d)}else l.has(c)?b.hidden.push(h):b.removed.push(h)}}}for(let[r,a]of t){a.removed.sort(),a.hidden.sort();let l=i.get(r);l!==void 0&&(a.uncertain={fields:l.fields.sort(),...l.reasons.length>0?{reason:l.reasons.join("; ")}:{}})}return{gone:t,requests:s}}async function Ht(e,n,t){let{checkpoint:o,folder:s,reader:i}=e,r=new Date(Date.parse(o.readFrom)-_o).toISOString(),a=await Promise.allSettled(n.map(({objectApiName:h})=>i.describe(h,r))),l,w=new Map,p=new Map;for(let[h,b]of a.entries()){let R=n[h].objectApiName;if(b.status==="rejected"){if(b.reason instanceof te)throw b.reason;w.set(R,{unread:`The org did not answer the describe of ${R}: ${Pe(b.reason)}`});continue}if("notModified"in b.value){w.set(R,{gone:new Set});continue}let j=tn.safeParse(b.value.body);if(!j.success){w.set(R,{unread:`The describe of ${R} does not read as one.`});continue}t.set(R,j.data);try{let C=(await(l??=dt(s,o.objects))).get(R);if(C===void 0)throw new Error(`The checkpoint holds no field prints of ${R}.`);p.set(R,rt(C,st(j.data.fields)))}catch(C){w.set(R,{unread:Pe(C)})}}let c=new Map(n.map(h=>[h.objectApiName,new Set(bn(h.objectApiName,h.fields,o.ignoredFields).map(b=>b.toLowerCase()))])),g=(h,b)=>b.filter(R=>c.get(h)?.has(R.toLowerCase())===!0),d=new Map([...p].map(([h,b])=>[h,g(h,b.removed)]).filter(([,h])=>h.length>0)),f=d.size>0?await Yo(i,d):{gone:new Map,requests:0};for(let[h,{removed:b,added:R,changed:j}]of p){let C=f.gone.get(h);w.set(h,{...g(h,b).length+R.length+j.length>0?{drift:{removed:C?.removed??[],added:R,changed:j,...C!==void 0&&C.hidden.length>0?{hidden:C.hidden}:{},...C?.uncertain!==void 0?{uncertain:C.uncertain}:{}}}:{},gone:new Set(b.map(v=>v.toLowerCase()))})}return{now:w,requests:f.requests}}function ei(e,n){let t=i=>{let r=n.get(i);return r!==void 0&&!("unread"in r)&&r.moved},o=e.find(({objectApiName:i})=>i===je),s=o!==void 0&&Ie(o.fields,an)!==void 0&&t(je);return e.filter(({objectApiName:i})=>t(i)||s&&i===mn)}function ni(e,n){let t=[...e.cascadeParents,...e.restrictParents??[]].filter(s=>!n.has(s.toLowerCase()));if(e.customSetting!==void 0){let s=Ie(e.fields,kn(e.customSetting));s!==void 0&&!n.has(s.toLowerCase())&&!t.includes(s)&&t.push(s)}if(Hn(e.objectApiName))for(let s of ut){let i=Ie(e.fields,s);i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}let o=Ie(e.fields,an);if(e.objectApiName===je&&o!==void 0){let s=Ie(e.fields,"AccountId");for(let i of[o,s])i!==void 0&&!n.has(i.toLowerCase())&&t.push(i)}return[...t,...Jt]}async function ti(e,n,t){let{folder:o,checkpoint:s}=e.input,i=new Map,r=new Map;for(let{objectApiName:a,cascadeParents:l,restrictParents:w=[]}of n){let p=t.get(a);if(!p||"unread"in p||!p.deleted||p.deleted.rows===0)continue;let c=new Map,g=new Map;try{let d=await $e.read(o,s.snapshotId,a),f=Qt(o,a);for await(let h of se(p.deleted.file)){let b=ee(h.Id);if(b===void 0)continue;let R=v=>v.map(O=>ee(h[O])).filter(O=>O!==void 0&&O!==b),j=ee(h.LastModifiedById),C=()=>({objectApiName:a,id:String(h.Id),stamp:ke(h.SystemModstamp),parents:R(l),restricts:R(w),...j!==void 0?{by:j}:{}});if(!d.retired(h.Id)){if(!d.has(h.Id)){if(await f(b)){g.set(b,C());continue}if(ke(h.CreatedDate)>=e.t0s&&g.set(b,C()),!(ke(h.CreatedDate)<e.t0s))continue}c.set(b,C())}}}catch(d){if(d instanceof te)throw d;continue}for(let[d,f]of c)i.set(d,f);for(let[d,f]of g)r.set(d,f)}return{back:i,gone:r}}function oi(e,n){let t=s=>e.get(s)?.stamp??n.get(s)?.stamp,o=new Set;for(let s of[e,n])for(let[i,r]of s)[...r.parents,...r.restricts].some(l=>(t(l)??0)>r.stamp)&&o.add(i);return zn(o,e,n),o}function zn(e,n,t){let o=s=>n.get(s)?.stamp??t.get(s)?.stamp;for(let s=e.size>0;s;){s=!1;for(let i of[n,t])for(let[r,a]of i){if(e.has(r))continue;a.parents.some(w=>e.has(w)&&o(w)===a.stamp)&&(e.add(r),s=!0)}}for(let s of e)n.delete(s)}function ii(e,n){if(n===void 0)return new Set;let t=[...e].filter(([,o])=>o.by!==n).map(([o])=>o);return Zt(t,e)}function Zt(e,n){let t=new Set(e);for(let o=t.size>0;o;){o=!1;for(let[s,i]of n){if(t.has(s))continue;i.parents.some(a=>t.has(a)&&n.get(a)?.stamp===i.stamp)&&(t.add(s),o=!0)}}return t}function si(e,n,t){let o=new Map(e.map(l=>[l.objectApiName,l.undeletable])),s=new Set,i=new Set,r=(l,w)=>l.parents.find(p=>!w.has(p)&&t.get(p)?.stamp===l.stamp),a=l=>l.parents.some(w=>n.get(w)?.stamp===l.stamp);for(let l of[...n.values()]){if(a(l))continue;let w=new Set,p=[],c=r(l,w),g=!1;for(;c!==void 0;){w.add(c),p.push(c);let h=t.get(c);if(!h)break;if(a(h)){g=!0;break}c=r(h,w)}let d=p[p.length-1];if(d===void 0||g)continue;let f=t.get(d);if(!(!f||o.get(f.objectApiName)!==!0)){s.add(d);for(let h of p.slice(0,-1))i.add(h)}}for(let l of[...s,...i]){let w=t.get(l);w&&n.set(l,w)}return s}function ri(e,n,t){let o=new Map;for(let[s,i]of e){if(t.has(s)){o.set(s,"deletedWithParentOutside");continue}if(n.has(s))continue;i.parents.some(a=>!e.has(a)&&n.get(a)?.stamp===i.stamp)&&o.set(s,"deletedWithCreatedParent")}for(let s=o.size>0;s;){s=!1;for(let[i,r]of e){if(o.has(i))continue;let a=r.parents.find(w=>o.has(w)&&e.get(w)?.stamp===r.stamp),l=a===void 0?void 0:o.get(a);l!==void 0&&(o.set(i,l),s=!0)}}for(let s of o.keys())e.delete(s);return o}async function ai(e,n,t,o,s,i){let r=new Set,a=new Set,l=new Set(n.map(({objectApiName:d})=>d.toLowerCase())),w=new Map(n.map(d=>[d.objectApiName,d])),p=new Map;for(let[d,f]of t)o.has(d)||s.has(d)||f.parents.some(b=>(t.get(b)??o.get(b))?.stamp===f.stamp)||p.set(f.objectApiName,[...p.get(f.objectApiName)??[],f]);if(p.size===0)return{outside:r,stuck:a,requests:0};let c=e.reader.calls(),g=async d=>{try{return await i(d)}catch(f){if(f instanceof te)throw f;return}};for(let[d,f]of p){let h=w.get(d),b=await g(d);if(!h||!b)continue;let R=new Set([...h.cascadeParents,...h.restrictParents??[]].map(P=>P.toLowerCase())),j=b.fields.filter(P=>P.type==="reference"&&!R.has(P.name.toLowerCase())&&(P.referenceTo??[]).some(H=>!l.has(H.toLowerCase())));if(j.length===0)continue;let C=[...new Set(j.flatMap(P=>(P.referenceTo??[]).filter(H=>!l.has(H.toLowerCase()))))],v=await Promise.all(C.map(g)),O=new Map;if(v.forEach((P,H)=>{if(!P)return;let Q=P.keyPrefix;for(let z of P.childRelationships??[]){if(z.cascadeDelete!==!0||z.childSObject.toLowerCase()!==d.toLowerCase())continue;let fe=j.find(oe=>oe.name.toLowerCase()===z.field.toLowerCase());fe&&O.set(fe.name,[...O.get(fe.name)??[],{object:C[H],...typeof Q=="string"?{prefix:Q}:{}}])}}),O.size===0)continue;let B=[...O.keys()].map(pn),W=pe(d),D=f.map(P=>P.id),L=new Map,N=Le(D).map(P=>({objectApiName:W,soql:`SELECT Id, ${B.join(", ")} FROM ${W} WHERE Id IN (${P}) AND IsDeleted = true`,scanAll:!0}));if((await ve(e.reader,N,(P,H)=>{for(let Q of H){let z=ee(Q.Id);if(z!==void 0)for(let[fe,oe]of O){let ue=Q[fe];if(typeof ue!="string"||ee(ue)===void 0)continue;let Ae=oe.length===1?oe[0]:oe.find(he=>he.prefix!==void 0&&ue.startsWith(he.prefix));Ae&&L.set(z,[...L.get(z)??[],{object:Ae.object,id:ue}])}}},e.signal)).some(P=>!P.read))continue;let J=new Map;for(let P of L.values())for(let{object:H,id:Q}of P)J.set(H,[...J.get(H)??[],Q]);let Y=[];for(let[P,H]of J){let Q=pe(P);for(let z of Le([...new Set(H)]))Y.push({object:P,read:{objectApiName:Q,soql:`SELECT Id, IsDeleted, SystemModstamp FROM ${Q} WHERE Id IN (${z})`,scanAll:!0}})}let x=new Map;await ve(e.reader,Y.map(({read:P})=>P),(P,H)=>{for(let Q of H){let z=ee(Q.Id);z!==void 0&&Q.IsDeleted===!0&&x.set(z,ke(Q.SystemModstamp))}},e.signal);for(let P of f){let H=ee(P.id);if(H!==void 0)for(let{id:Q}of L.get(H)??[]){let z=x.get(ee(Q)??"");z!==void 0&&(z===P.stamp?r.add(H):z>P.stamp&&a.add(H))}}}return{outside:r,stuck:a,requests:e.reader.calls()-c}}async function ci(e,n,t,o){let s=[...new Set([...e.values()].map(({objectApiName:l})=>l))],i=await Promise.allSettled(s.map(t)),r=new Map([...n.keys()].map(l=>[l.toLowerCase(),l])),a=new Map;for(let[l,w]of i.entries()){if(w.status==="rejected"){if(w.reason instanceof te)throw w.reason;let p=s[l];o.set(p,Pe(w.reason));for(let[c,g]of e)g.objectApiName===p&&e.delete(c);continue}for(let p of w.value.childRelationships??[]){let c=r.get(p.childSObject.toLowerCase());if(c===void 0)continue;let g=Ie(n.get(c)??[],p.field);if(g===void 0)continue;let d=a.get(c);d||(d=new Set,a.set(c,d)),d.add(g)}}return new Map([...a].map(([l,w])=>[l,[...w]]))}async function di(e,n){let t=new Set,o=e.find(({objectApiName:i})=>i===je);if(!o||Ie(o.fields,an)===void 0)return t;let s=n.get(je);if(!s||"unread"in s||!s.live)return t;try{for await(let i of se(s.live.file)){let r=ee(i.AccountId);r!==void 0&&vn(je,i)&&t.add(r)}}catch{return new Set}return t}async function fi(e,n,t,o){if("unread"in t)return{unread:t.unread};let{input:s,previewDir:i,t0s:r,back:a,carriers:l,stranded:w,stuck:p,others:c,personAccounts:g}=e,{folder:d,reader:f,checkpoint:h,signal:b}=s,R=n.objectApiName,j=Hn(R)?e.files:void 0,C=L=>j===void 0||j.anchoredThen(L),v=new Map,O=L=>{let N=v.get(L);return N||(N=new fn(X(i,R,L)),v.set(L,N)),N},B=L=>v.get(L)?.count??0,W=new Un(e.activeFrom),D=[];try{let L=await $e.read(d,h.snapshotId,R),N=Qt(d,R),{gone:V}=o,J=wt(R,h.ignoredFields),Y=bn(R,n.fields,[]),x=m=>J.has(m.toLowerCase())||V.has(m.toLowerCase()),P=Y.filter(m=>!x(m)).map(pn),H=Y.filter(x),Q=R===vo?Ie(n.fields,Bo):void 0,z=Q!==void 0&&!V.has(Q.toLowerCase())?Q:void 0,fe=R===Fo?Ie(n.fields,Eo):void 0,oe=fe!==void 0&&P.includes(fe)?fe:void 0,ue=["Id","SystemModstamp",...Jt,...P,...z!==void 0&&!P.includes(z)?[z]:[],...oe!==void 0?[qt]:[]],Ae=n.cascadeParents.filter(m=>!V.has(m.toLowerCase())),he=(n.restrictParents??[]).filter(m=>!V.has(m.toLowerCase())),Se=R===je&&Ie(n.fields,an)!==void 0,De=m=>Se&&vn(R,m),ye=Uo(n)?"toRecreate":"goneForGood",ze=e.access.heldAs(R)==="parent"?"outOfReach":ye,be=r-Dn,ne={fields:0,cleared:0,liveNotHeld:0,deletedHeld:0},Fe=m=>{let A=ee(m.Id);if(A===void 0)throw new Error(`${R} answered a record without its Id.`);return{id:String(m.Id),key:A}},ge=(m,A,I)=>m.map($=>ee(A[$])).filter($=>$!==void 0&&$!==I),we=(m,A)=>ge(Ae,m,A),Ee=(m,A)=>{let I=ke(m.SystemModstamp);return we(m,A).some($=>a.get($)?.stamp===I)},sn=Date.parse(h.takenAt),Ze=Date.parse(s.readAt)-Dn,Me=(m,A,I,$)=>{W.add(m);let S=we(m,I),F=ge(he,m,I),U=$&&ke(m.CreatedDate)>=sn&&ke(m.LastModifiedDate)<=Ze;n.undeletable&&S.length+F.length===0||D.push({id:A,parents:S,restricts:F,goesAlong:U,undeletable:n.undeletable})},ae=new Map,qe=e.lookups.get(R)??[];if(qe.length>0&&L.size>0)for await(let m of L.records()){if(De(m))continue;let A=ee(m.Id);if(A===void 0)continue;let I=qe.filter($=>{let S=ee(m[$]);return S!==void 0&&a.has(S)});I.length>0&&ae.set(A,{id:String(m.Id),fields:I})}let Te=async m=>{if(m.length===0)return;if(P.length===0){for(let F of m)F.stamp!==F.held&&await O("touched").add({Id:F.id});return}let A=m.map(F=>F.id),I=new Map,$=await L.chunk(A).batches(h.snapshotId,R,rn);for await(let F of $??[])for(let U of F){let G=ee(U.Id);G!==void 0&&I.set(G,U)}if(b?.aborted)throw new te;let S=await zo(f,n,ue,A);for(let F of m){let U=S.get(F.key);if(!U)continue;let G=I.get(F.key);if(!G)throw new Error(`The checkpoint\u2019s snapshot of ${R} does not hold record ${F.id}, which its index names.`);if(z!==void 0&&G[z]!==!0&&U[z]===!0){await O("convertedLead").add({Id:F.id});continue}if(oe!==void 0&&U[qt]===Mo&&!Nn(G[oe],U[oe])){await O("activatedContract").add({Id:F.id});continue}let ie=P.filter(ce=>!Nn(G[ce],U[ce]));if(ie.length>0){ne.fields+=ie.length;let ce=(F.cleared??[]).filter(un=>ie.includes(un)&&Go(U[un]));ce.length>0&&ne.cleared++,await O("giveBack").add({Id:F.id,fields:ie,...ce.length>0?{cleared:ce}:{}}),W.add(U)}else ke(U.SystemModstamp)!==F.held&&await O("touched").add({Id:F.id})}},Ce=[],Ne=async m=>{Ce.push(m),Ce.length>=Ve&&(await Te(Ce),Ce=[])};if(t.live)for await(let m of se(t.live.file)){let{id:A,key:I}=Fe(m),$=De(m),S=L.stampOf(A);if(S!==void 0){if($||!C(A))continue;let U=ae.get(I)?.fields;U&&ae.delete(I);let G=R===mn&&g.delete(I),ie=ke(m.SystemModstamp);(U||G||ie!==S||S>=be)&&await Ne({id:A,key:I,held:S,stamp:ie,...U?{cleared:U}:{}});continue}if(ne.liveNotHeld++,$)continue;let F=await N(I)?"broughtBackSince":ke(m.CreatedDate)>=r?"createdSince":void 0;F===void 0?await O("unexplained").add({Id:A}):j!==void 0&&!j.anchoredNow(A)?await O("outsideAdded").add({Id:A}):(await O(F).add({Id:A}),Me(m,A,I,!0))}for(let[m,A]of ae){let I=L.stampOf(A.id);I!==void 0&&await Ne({id:A.id,key:m,held:I,stamp:I,cleared:A.fields})}if(R===mn)for(let m of g){let A=L.rowOf(m);if(A<0||(g.delete(m),ae.has(m)))continue;let I=L.idAt(A),$=L.stampOf(I);$!==void 0&&await Ne({id:I,key:m,held:$,stamp:$})}if(await Te(Ce),t.deleted)for await(let m of se(t.deleted.file)){let{id:A,key:I}=Fe(m);if(L.retired(A))continue;let $=De(m);if(L.has(A)){if(ne.deletedHeld++,$)continue;if(!C(A)){await O("outsideDeleted").add({Id:A});continue}let S=w.get(I);c.has(I)?await O("deletedByOther").add({Id:A}):p.has(I)?await O(e.answeredGone.has(I)?ze:ye).add({Id:A}):S!==void 0?await O(S).add({Id:A}):Ee(m,I)?await O("withParent").add({Id:A}):n.undeletable?await O("inBin").add({Id:A}):await O(ye).add({Id:A});continue}if(l.has(I)&&!$){await O("carrier").add({Id:A});continue}if(!($||await N(I)))if(ke(m.CreatedDate)<r){let S=w.get(I),F=C(A)?c.has(I)?"deletedByOther":p.has(I)?"goneForGood":S??"deletedWhileTaken":"outsideDeleted";await O(F).add({Id:A})}else Ee(m,I)&&(await O("comesBackWithParent").add({Id:A}),Me(m,A,I,!1))}let He=t.count;if(L.size>0&&He===void 0)throw new Error(`The org gave no count of the ${R} records it holds.`);if(L.size-((He??0)-ne.liveNotHeld)-ne.deletedHeld>0){let m=new lt(L);if(t.deleted)for await(let S of se(t.deleted.file))m.mark(S.Id);let[A]=await ve(f,[mt(R,n.readMode)],(S,F)=>{for(let U of F)m.mark(U.Id)},b);if(!A.read)throw new Error(A.reason);let I=[],$=async()=>{let S=new Set;if(Se){let F=await L.chunk(I).batches(h.snapshotId,R,rn);for await(let U of F??[])for(let G of U){let ie=ee(G.Id);ie!==void 0&&De(G)&&S.add(ie)}}for(let F of I)S.has(F.slice(0,15))||await O(C(F)?ze:"outsideDeleted").add({Id:F});I=[]};for(let S of m.ids())I.push(S),I.length>=Ve&&await $();await $()}for(let m of v.values())await m.flush();let Ye=B("toRecreate"),_e=B("goneForGood"),k=B("convertedLead"),E=B("activatedContract"),K=B("deletedWithCreatedParent"),u=B("deletedWithParentOutside"),y=B("deletedByOther"),T=B("outOfReach"),M=B("carrier");return{told:{diff:{objectApiName:R,toDelete:{createdSince:B("createdSince"),broughtBackSince:B("broughtBackSince"),comesBackWithParent:B("comesBackWithParent")},toGiveBack:{records:B("giveBack"),fields:ne.fields,clearedLookups:ne.cleared},toBringBack:{inBin:B("inBin"),withParent:B("withParent"),deletedWhileTaken:B("deletedWhileTaken"),...M>0?{carriers:M}:{}},...Ye>0?{toRecreate:Ye}:{},cannotUndo:[..._e>0?[{reason:"goneForGood",count:_e}]:[],...k>0?[{reason:"convertedLead",count:k}]:[],...E>0?[{reason:"activatedContract",count:E}]:[],...K>0?[{reason:"deletedWithCreatedParent",count:K}]:[],...u>0?[{reason:"deletedWithParentOutside",count:u}]:[],...y>0?[{reason:"deletedByOther",count:y}]:[],...T>0?[{reason:"outOfReach",count:T}]:[]],outside:[],touched:B("touched"),unexplained:B("unexplained"),lastChangedBy:W.byUser(),...o.drift?{schemaDrift:o.drift}:{},notCompared:H},people:W,pending:D}}}catch(L){for(let N of v.values())await N.discard();if(L instanceof te)throw L;return{unread:Pe(L)}}}async function*Xt(e,n){let t=[];for(let o of To)if(n.diff.toDelete[o]!==0)for await(let s of se(X(e,n.diff.objectApiName,o)))typeof s.Id=="string"&&(t.push(s.Id),t.length>=Ve&&(yield t,t=[]));t.length>0&&(yield t)}async function li(e,n,t,o,s){let{input:i,previewDir:r}=e,a=n.diff.objectApiName,w=((await t(a)).childRelationships??[]).filter(C=>C.cascadeDelete===!0&&!s.has(C.childSObject.toLowerCase()));if(w.length===0)return[];let p=await o(),c=w.filter(C=>p.has(C.childSObject));if(c.length===0)return[];let g=new Set(await e.access.unseenOf([...new Set(c.map(({childSObject:C})=>C))])),d=c.filter(({childSObject:C})=>!g.has(C));if(d.length===0)return[];let f=Date.parse(i.checkpoint.takenAt);if(!Number.isFinite(f))throw new Error(`Not a date: ${i.checkpoint.takenAt}`);let h=pt(Math.ceil(f/Dn)*Dn),b=new Map,R=new Map,j=new Map;for await(let C of Xt(r,n)){let v=d;for(;v.length>0;){let O=[];for(let D of v){let L=pe(D.childSObject),N=pn(D.field),V=gt(L)==="scanAllLive",J=j.get(L)??"CreatedDate";for(let Y of Le(C))O.push({child:L,field:N,read:{objectApiName:L,soql:`SELECT Id, ${N} FROM ${L} WHERE ${N} IN (${Y}) AND ${J} >= ${h}${V?" AND IsDeleted = false":""}`,scanAll:V}})}let B=await ve(i.reader,O.map(({read:D})=>D),(D,L)=>{let{child:N,field:V}=O[D],J=b.get(N);J||(J={records:new Set,parents:new Set},b.set(N,J));for(let Y of L){let x=ee(Y.Id),P=ee(Y[V]);x!==void 0&&J.records.add(x),P!==void 0&&(J.parents.add(P),R.set(P,String(Y[V])))}},i.signal),W=new Set;B.forEach((D,L)=>{if(D.read)return;let{child:N}=O[L];if(!j.has(N)&&/No such column 'CreatedDate'/.test(D.reason)){W.add(N);return}throw new Error(`The ${D.objectApiName} records its deletion would take along could not be read: `+D.reason)});for(let D of W)j.set(D,"SystemModstamp");v=v.filter(D=>W.has(pe(D.childSObject)))}}if(R.size>0){let C=new fn(X(r,a,"outsideParents"));for(let v of R.values())await C.add({Id:v});await C.flush()}return[...b].filter(([,{records:C}])=>C.size>0).sort(([C],[v])=>C<v?-1:C>v?1:0).map(([C,{records:v,parents:O}])=>({objectApiName:C,count:v.size,parents:O.size}))}async function ui(e,n,t,o){if(e.kind==="org")return;let{objectApiName:s,toDelete:i}=n.diff,r=i.createdSince+i.broughtBackSince;if(r===0)return;let l=((await t(s)).childRelationships??[]).filter(d=>d.cascadeDelete===!0).map(d=>d.childSObject);if(l.length===0)return;let w=await o(),p=[...new Set(l.filter(d=>w.has(d)))].sort(),g=[...p.length>0?await e.unseenOf(p):[]].sort((d,f)=>+!Kt.has(d)-+!Kt.has(f));return g.length>0?{objectApiName:s,children:g,records:r}:void 0}var Kt=new Set(["Event","Task"]);async function gi(e,n){let t=new Set(n.flatMap(({pending:c})=>c.flatMap(({parents:g,restricts:d})=>[...g,...d]))),o=new Set;if(t.size>0)for(let c of n)for await(let g of Xt(e,c))for(let d of g){let f=d.slice(0,15);t.has(f)&&o.add(f)}let s=new Map(n.flatMap(({pending:c})=>c.map(g=>[g.id.slice(0,15),g]))),i=c=>c.goesAlong?c.parents.find(g=>o.has(g)):void 0,r=(c,g=new Set)=>{let d=s.get(c),f=d&&!g.has(c)?i(d):void 0;return f===void 0?c:r(f,new Set([...g,c]))},a=new Map,l=(c,g)=>{let d=a.get(c);if(d!==void 0)return d;a.set(c,!1);let f=r(c),h=g.restricts.some(b=>o.has(b)&&r(b)!==f)||g.parents.some(b=>{let R=s.get(b);return R!==void 0&&i(R)!==void 0&&l(b,R)});return a.set(c,h),h},w=[],p=[];for(let{diff:c,pending:g}of n){let d=c.objectApiName,f=O=>i(O)!==void 0&&!l(O.id.slice(0,15),O),h=g.filter(f).length;h>0&&p.push({objectApiName:d,count:h});let b=g.filter(O=>!f(O)),R=b.filter(O=>[...O.parents,...O.restricts].some(B=>o.has(B))),j=new Set(R.map(({id:O})=>O)),C=b.filter(O=>!O.undeletable&&!j.has(O.id));if(C.length+R.length===0)continue;let v=new fn(X(e,d,"undoCannot"));for(let{id:O}of C)await v.add({Id:O});for(let{id:O}of R)await v.add({Id:O,reason:"deletedBeforeParent"});await v.flush(),C.length>0&&w.push({objectApiName:d,count:C.length}),R.length>0&&w.push({objectApiName:d,count:R.length,reason:"deletedBeforeParent"})}return{undoCannot:w,withParentDeleted:p}}async function hi(e,n,t){let o={};if(n.length===0)return o;let s=Le([...n].sort()).map(i=>({objectApiName:"User",soql:`SELECT Id, Name FROM User WHERE Id IN (${i})`,scanAll:!1}));return await ve(e,s,(i,r)=>{for(let a of r)typeof a.Id=="string"&&typeof a.Name=="string"&&(o[a.Id]=a.Name)},t),o}function Vt(e){let{toDelete:n,toGiveBack:t,toBringBack:o}=e;return n.createdSince+n.broughtBackSince+n.comesBackWithParent+t.records+o.inBin+o.withParent+o.deletedWhileTaken+(o.carriers??0)+(e.toRecreate??0)+e.touched+e.unexplained+e.cannotUndo.reduce((s,i)=>s+i.count,0)>0||e.schemaDrift!==void 0}async function wi(e){let n=await e.describe(me),t=tn.safeParse("body"in n?n.body:null);if(!t.success)throw new Error(`The org gave no describe of ${me}.`);return t.data}function Yt(e){return(n,t)=>X(e,n,t)}async function pi(e,n){let t=n.fileObject.objectApiName,o=n.changes.get(t);if(!(n.unread.has(t)||o===void 0||"unread"in o))try{return{anchors:await xt({reader:e.reader,folder:e.folder,previewDir:n.previewDir,snapshotId:e.checkpoint.snapshotId,objects:n.ordered,changes:n.changes,linkDescribe:n.linkDescribe,describeGlobal:e.describeGlobal,...e.signal?{signal:e.signal}:{}})}}catch(s){if(s instanceof te)throw s;return{unread:"The links of its files to the records of the checkpoint could not be read: "+Pe(s)}}}async function eo(e){await Promise.all(["linkAdded","linkRemoved","linkChanged"].map(n=>qn(Re(e,n),{force:!0})))}async function mi(e,n){let t=n.fileObject.objectApiName,o=n.outcomes.get(t),s=n.changes.get(t);if(o===void 0||!("told"in o)||s===void 0)return;let i=new Set([...n.outcomes].filter(([,r])=>"told"in r).map(([r])=>r));try{let r=await Ut({anchors:n.anchors,reader:e.reader,folder:e.folder,snapshotId:e.checkpoint.snapshotId,t0s:n.t0s,objects:n.ordered,fileChanges:s,told:i,classFileOf:Yt(n.previewDir),previewDir:n.previewDir,queryAllFiles:e.checkpoint.takenBy?.queryAllFiles===!0&&e.queryAllFiles!==!1,...e.signal?{signal:e.signal}:{}}),{diff:a,people:l}=o.told;a.toDelete.createdSince+=r.createdSince,a.toBringBack.deletedWhileTaken+=r.deletedWhileTaken;for(let g of r.changedBy)l.add(g);a.lastChangedBy=l.byUser();let w=r.goneForGood,p=r.newFileVersion,c=a.cannotUndo.find(g=>g.reason==="goneForGood");return c!==void 0?c.count+=w:w>0&&a.cannotUndo.unshift({reason:"goneForGood",count:w}),a.cannotUndo.push(...p>0?[{reason:"newFileVersion",count:p}]:[]),r.files}catch(r){if(r instanceof te)throw r;await Kn(n.previewDir,t),await eo(n.previewDir),n.outcomes.set(t,{unread:Pe(r)});return}}async function ki(e,n){let t=n.fileObject.objectApiName,o=n.outcomes.get(t);if(o===void 0||!("told"in o))return;let{diff:s}=o.told;if(s.toDelete.createdSince+s.toDelete.broughtBackSince!==0)try{let{links:i,files:r}=await zt({anchors:n.anchors,reader:e.reader,classFileOf:Yt(n.previewDir),...e.signal?{signal:e.signal}:{}});if(i===0)return;s.outside=[...s.outside.filter(({objectApiName:a})=>a!==me),{objectApiName:me,count:i,parents:r}].sort((a,l)=>a.objectApiName<l.objectApiName?-1:a.objectApiName>l.objectApiName?1:0)}catch(i){if(i instanceof te)throw i;await Kn(n.previewDir,t),await eo(n.previewDir),n.outcomes.set(t,{unread:Pe(i)})}}async function Is(e){let{checkpoint:n,folder:t,reader:o,previewId:s,readAt:i,signal:r}=e,a=Date.parse(n.readFrom);if(!Number.isFinite(a))throw new Error(`Not a date: ${n.readFrom}`);let l=Date.parse(i);if(!Number.isFinite(l))throw new Error(`Not a date: ${i}`);if(r?.aborted)throw new te;let w=a-(a%1e3+1e3)%1e3,p=ct(t,s);await yn(p);let c=[...n.objects].sort((k,E)=>k.readOrder-E.readOrder),g=e.access??Gn,d=c.filter(({objectApiName:k})=>!g.notHeld.has(k)),f=new Map,h=n.files!==void 0?d.find(({objectApiName:k})=>Hn(k)):void 0,b=await yt(o,d.map(({objectApiName:k})=>k),n.readFrom,r),R=new Map(d.map(({objectApiName:k},E)=>[k,b[E]])),j=ei(d,R),C=h!==void 0?wi(o):void 0;C?.catch(()=>{});let v=await Ht(e,j,f),O=v.requests,B=new Map,W=new Set,D=[];for(let k of c){let E=k.objectApiName,K=g.notHeld.get(E);if(K!==void 0){B.set(E,K);continue}let u=R.get(E);if(u===void 0||"unread"in u){B.set(E,u?.unread??"Its newest record was not read.");continue}let y=v.now.get(E);y===void 0?(W.add(E),D.push({object:k,fields:{gone:new Set},check:u})):"unread"in y?B.set(E,y.unread):D.push({object:k,fields:y,check:u})}let L=await bt(o,D.map(({object:k,fields:E})=>({objectApiName:k.objectApiName,readMode:k.readMode,held:k.records>0,fields:ni(k,E.gone)})),n.readFrom,p,r,D.map(({check:k})=>k)),N=new Map(D.map(({object:k},E)=>[k.objectApiName,L[E]])),V=D.filter(({object:k})=>{if(!W.has(k.objectApiName))return!1;let E=N.get(k.objectApiName);return E!==void 0&&!("unread"in E)&&E.count!==void 0&&E.count<k.records});if(V.length>0){let k=await Ht(e,V.map(({object:E})=>E),f);O+=k.requests;for(let E of V){let K=E.object.objectApiName;W.delete(K);let u=k.now.get(K);u===void 0||"unread"in u?B.set(K,u?.unread??"Its describe was not read."):E.fields=u}}let J=new Map,Y=k=>{let E=f.get(k);if(E)return Promise.resolve(E);let K=J.get(k);return K||(K=(async()=>{let u=await o.describe(k),y=tn.safeParse("body"in u?u.body:null);if(!y.success)throw new Error(`The org gave no describe of ${k}.`);return y.data})(),J.set(k,K)),K},{back:x,gone:P}=await ti({input:e,t0s:w},c,N),H=ii(x,g.userKey),Q=new Map([...P,...x]),z=oi(x,P),fe=await ft.read(t);for(let k of fe.keys())(x.has(k)||P.has(k))&&z.add(k);let oe=Zt([...fe.keys()].filter(k=>Q.has(k)),Q);zn(z,x,P);for(let k of H)x.delete(k),z.delete(k);let ue=si(c,x,P),Ae=new Map(D.map(({object:k,fields:E})=>[k.objectApiName,bn(k.objectApiName,k.fields,n.ignoredFields).filter(K=>!E.gone.has(K.toLowerCase()))])),he=await ci(x,Ae,Y,B),Se=await ai(e,D.map(({object:k})=>k),x,P,ue,Y);for(let k of Se.stuck)z.add(k);zn(z,x,P);for(let k of[...ue])x.has(k)||ue.delete(k);let De=ri(x,P,Se.outside),ye=0,ze=o.calls(),be=h!==void 0&&C!==void 0?await pi(e,{previewDir:p,ordered:c,changes:N,linkDescribe:C,fileObject:h,unread:B}):void 0;ye+=o.calls()-ze;let ne=be!==void 0&&"anchors"in be?be.anchors:void 0,Fe={input:e,previewDir:p,t0s:w,activeFrom:l-$o,back:x,carriers:ue,stranded:De,stuck:z,answeredGone:oe,others:H,access:g,lookups:he,personAccounts:await di(c,N),...ne!==void 0?{files:ne}:{}},ge=new Map;for(let{object:k,fields:E}of D){if(r?.aborted)throw new te;let K=B.get(k.objectApiName)??(be!==void 0&&"unread"in be&&k===h?be.unread:void 0),u=N.get(k.objectApiName);ge.set(k.objectApiName,K!==void 0||u===void 0?{unread:K??"Its changes were not read."}:await fi(Fe,k,u,E))}let we;if(ne!==void 0&&h!==void 0){let k=o.calls();we=await mi(e,{anchors:ne,fileObject:h,changes:N,outcomes:ge,ordered:c,previewDir:p,t0s:w}),ye+=o.calls()-k}let Ee=new Set(c.map(({objectApiName:k})=>k.toLowerCase()));if(n.files!==void 0&&h!==void 0)for(let k of[me,et])Ee.add(k.toLowerCase());let sn,Ze=()=>sn??=tt({describeGlobal:e.describeGlobal}),Me=[];for(let[k,E]of ge){if(!("told"in E))continue;let{toDelete:K}=E.told.diff;if(K.createdSince+K.broughtBackSince!==0)try{E.told.diff.outside=await li(Fe,E.told,Y,Ze,Ee);let u=await ui(g,E.told,Y,Ze);u!==void 0&&Me.push(u)}catch(u){if(u instanceof te)throw u;await Kn(p,k),ge.set(k,{unread:Pe(u)})}}if(ne!==void 0&&h!==void 0){let k=o.calls();await ki(e,{anchors:ne,fileObject:h,outcomes:ge,previewDir:p}),ye+=o.calls()-k,"told"in(ge.get(h.objectApiName)??{unread:""})||(we=void 0)}let ae=c.flatMap(({objectApiName:k})=>{let E=ge.get(k);return E&&"told"in E?[E.told]:[]}),{undoCannot:qe,withParentDeleted:Te}=await gi(p,ae),Ce=new Set(ae.map(({diff:k})=>k.objectApiName)),Ne=Me.filter(({objectApiName:k})=>Ce.has(k)),He=[...new Set(ae.flatMap(({diff:k})=>Object.keys(k.lastChangedBy)))],Xe=await hi(o,He,r),Ye=new Set(ae.flatMap(({people:k})=>[...k.active])),_e=ae.filter(({diff:k})=>W.has(k.objectApiName)&&!Vt(k)).length;return{checkpointId:n.checkpointId,previewId:s,readAt:i,objects:ae.map(({diff:k})=>k).filter(Vt),undoCannot:qe,...Te.length>0?{withParentDeleted:Te}:{},...Se.requests>0?{parentsOutsideRequests:Se.requests}:{},...O>0?{fieldsRequests:O}:{},described:{first:j.length,later:V.length},..._e>0?{fieldsNotChecked:_e}:{},...we!==void 0?{files:we}:{},...h!==void 0?{filesRequests:ye}:{},access:g.diffAccess(),...Ne.length>0?{unseen:Ne}:{},unread:c.flatMap(({objectApiName:k})=>{let E=ge.get(k),K=E&&"unread"in E?E.unread:E?void 0:B.get(k);return K===void 0?[]:[{objectApiName:k,reason:K}]}),userNames:Xe,activeLastHour:[...Ye].sort()}}var Ai=1e3,Si=25,Ci=2e3,Oe=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/,no=["createdSince","broughtBackSince","comesBackWithParent","giveBack","inBin","withParent","deletedWhileTaken","toRecreate","carrier"],de={createdSince:1,broughtBackSince:2,comesBackWithParent:4,giveBack:8,inBin:16,withParent:32,deletedWhileTaken:64,toRecreate:128,carrier:256},to=32768,Pi={createdSince:de.createdSince|de.comesBackWithParent|de.carrier,broughtBackSince:de.broughtBackSince|de.carrier,comesBackWithParent:de.comesBackWithParent,giveBack:de.giveBack|de.inBin|de.withParent,inBin:de.inBin,withParent:de.withParent,deletedWhileTaken:de.deletedWhileTaken,toRecreate:de.toRecreate,carrier:de.carrier},ln=new Set(["createdSince","broughtBackSince"]),Ue={changedSincePreview:1,changedDuringRewind:2,outsideNotAccepted:4,holdsLeft:8,noUndoNotAccepted:16,beforeParentNotAccepted:32,recreateNotAccepted:64,keyTaken:128,needsUnpickedParent:256,heldByUnpicked:512},Ii=[{cls:"linkAdded",as:"unlink"},{cls:"linkRemoved",as:"relink"},{cls:"linkChanged",as:"share"}];function zs(e,n){return[n,e.automatedProcessUserId].filter(t=>typeof t=="string"&&t!=="")}function qs(e,n){let t=n.length>0?n.join(", "):"child";return`${e}: given back once the ${t} records hanging from it that the rewind deletes were gone, as those records held some of its values in place`}function Qe(e){let n=en(e);return n===null?Number.NaN:Date.parse(n)}function re(e,n){let t=e.Id;if(typeof t!="string"||!Oe.test(t))throw new Error(`A line of ${n} names no record: the diff it was read from is not whole.`);return t}async function*q(e){try{for await(let n of se(e))yield n}catch(n){if(n.code!=="ENOENT")throw n}}function Di(e,n){return Jn(e,`${pe(n)}.beforeParent.ndjson`)}var on=class{constructor(n){this.file=n}file;lines=[];written=!1;async add(n){this.lines.push(`${JSON.stringify(n)}
|
|
10
|
-
`),this.lines.length>=Ci&&await this.flush()}async flush(){if(this.lines.length===0)return;let n=this.lines.join("");this.lines=[],await bi(this.file,n,{encoding:"utf8",mode:nn,flag:this.written?"a":"w"}),this.written=!0}},Vn=class{entries=new Map;add(n,t,o,s,i){let r=`${n}\0${t}\0${s??""}\0${i??""}`,a=this.entries.get(r);a||(a={objectApiName:n,reason:t,...s!==void 0?{by:s}:{},...i!==void 0?{needs:i}:{},count:0,ids:[]},this.entries.set(r,a)),a.count++,a.ids.length<Si&&a.ids.push(o)}all(n){let t=(o,s)=>(o??"")<(s??"")?-1:(o??"")>(s??"")?1:0;return[...this.entries.values()].sort((o,s)=>(n.get(o.objectApiName)??0)-(n.get(s.objectApiName)??0)||t(o.reason,s.reason)||t(o.by,s.by)||t(o.needs,s.needs))}};function oo(e,n){if(!(typeof n!="string"||n===""))return e==="SetupOwnerId"&&Oe.test(n)?n.slice(0,15):n}async function Ni(e,n,t,o){let s=new Z;if(e.customSetting===void 0)return s;let i=kn(e.customSetting).toLowerCase(),r=e.fields.find(w=>w.toLowerCase()===i);if(r===void 0)return s;let a=new Z;for(let w of o){let p=X(t,e.objectApiName,w);for await(let c of q(p))a.add(re(c,p))}if(a.size===0)return s;let l=new Set;for await(let w of q(xe(n,e.objectApiName))){let p=oo(r,w[r]);p!==void 0&&l.add(p)}if(l.size===0)return s;for await(let w of q(cn(n,e.objectApiName))){if(typeof w.Id!="string"||!a.has(w.Id))continue;let p=oo(r,w[r]);p!==void 0&&l.has(p)&&s.add(w.Id)}return s}function io(e){return{objectApiName:e,deleted:0,withParentDeleted:0,undoCannot:0,nextPassDeleted:0,broughtBack:0,backWithParent:0,recreated:0,givenBackFirst:0,givenBackAfter:0,givenBackNextPass:0,skipped:0}}function ji(e){return Object.entries(e).some(([n,t])=>n!=="objectApiName"&&t!==0)}function so(e){return`${e.ContentDocumentId.slice(0,15)}:${e.LinkedEntityId.slice(0,15)}`}function ro(e,n,t){let s=(n==="linkChanged"?Rt:Rn).safeParse(e);if(!s.success)throw new Error(`A line of ${t} names no link: the diff it was read from is not whole.`);return s.data}function co(e){return{unlink:{file:Re(e,"linkAdded"),count:0},relink:{file:Re(e,"linkRemoved"),count:0},share:{file:Re(e,"linkChanged"),count:0}}}async function Li(e){let n={};for(let{cls:o,as:s}of Ii){let i=new Set,r=Re(e.confirmedDir,o);for await(let p of q(r))i.add(so(ro(p,o,r)));let a=Re(e.freshDir,o),l=new on(Re(e.dir,o)),w=0;for await(let p of q(a)){let c=ro(p,o,a);if(e.deleted(c.ContentDocumentId)||e.deleted(c.LinkedEntityId))continue;let g=e.pass===2&&o==="linkRemoved"&&(e.earlier(c.ContentDocumentId)||e.earlier(c.LinkedEntityId));if(!i.has(so(c))&&!g){e.left.add(me,"changedSincePreview",c.Id);continue}await l.add(p),w++}await l.flush(),n[s]={file:l.file,count:w}}let t=co(e.dir);return{unlink:n.unlink??t.unlink,relink:n.relink??t.relink,share:n.share??t.share}}var vi=["inBin","withParent","deletedWhileTaken","carrier"],Bi=new Set(["id","createdbyid","lastmodifiedbyid","systemmodstamp","createddate","lastmodifieddate"]);function Fi(e,n){return e.flatMap(t=>{let o=n[t];return typeof o=="string"&&Oe.test(o)?[o.slice(0,15)]:[]})}function ao(e,n,t){let o=t===void 0?void 0:new Set(t.map(s=>s.toLowerCase()));return Object.entries(e).flatMap(([s,i])=>{let r=s.toLowerCase();if(Bi.has(r)||o!==void 0&&!o.has(r))return[];if(typeof i!="string"||!Oe.test(i))return[];let a=i.slice(0,15);return n.has(a)?[{field:s,needs:n.get(a)}]:[]})}async function Ei(e,n,t){let{freshDir:o,heldRows:s}=e,i=new Map,r=new Map;for(let d of n)for(let f of[...vi,"toRecreate","comesBackWithParent"]){let h=X(o,d.objectApiName,f);for await(let b of q(h)){let R=re(b,h).slice(0,15);i.set(R,d.objectApiName),r.set(R,f)}}let a=new Map;for(let d of n)if(d.cascadeParents.length!==0)for await(let f of q(cn(o,d.objectApiName))){if(typeof f.Id!="string"||!Oe.test(f.Id))continue;let h=f.Id.slice(0,15),b=r.get(h);(b==="withParent"||b==="comesBackWithParent")&&a.set(h,Fi(d.cascadeParents,f))}let l=new Set;for(let[d,f]of r)(f==="inBin"||f==="deletedWhileTaken"||f==="carrier")&&t(i.get(d)??"")&&l.add(d);for(let d=l.size>0;d;){d=!1;for(let[f,h]of a)l.has(f)||!h.some(b=>l.has(b))||(l.add(f),d=!0)}let w=(d,f=new Set)=>{let h=i.get(d);if(!(h===void 0||f.has(d))){if(!t(h))return h;f.add(d);for(let b of a.get(d)??[]){if(l.has(b))continue;let R=w(b,f);if(R!==void 0)return R}}},p=new Map,c=new Map;for(let[d,f]of r){if(l.has(d)||f==="comesBackWithParent")continue;let h=i.get(d)??"";if(!t(h))p.set(d,h);else if(f==="withParent"){let b=w(d);c.set(d,b),p.set(d,b)}}let g=new Map;if(s===void 0)return{comes:l,left:c,fields:g};for(let d of[...n].reverse()){let f=d.objectApiName;if(!t(f))continue;let h=new Set(d.cascadeParents.map(v=>v.toLowerCase())),b=[],R=X(o,f,"toRecreate");for await(let v of q(R))b.push(re(v,R));if(b.length>0)for await(let v of s(f,b)){if(typeof v.Id!="string"||!Oe.test(v.Id))continue;let O=v.Id.slice(0,15),B=ao(v,p,void 0);if(B.length===0)continue;let W=B.find(({field:D})=>h.has(D.toLowerCase()));W!==void 0?(c.set(O,W.needs),p.set(O,W.needs)):g.set(O,{fields:B.map(({field:D})=>D),needs:B[0].needs})}let j=new Map,C=X(o,f,"giveBack");for await(let v of q(C)){let O=re(v,C),B=Array.isArray(v.fields)?v.fields.filter(W=>typeof W=="string"):void 0;j.set(O.slice(0,15),{id:O,differ:B})}for(let v of["inBin","withParent"]){let O=X(o,f,v);for await(let B of q(O)){let W=re(B,O);l.has(W.slice(0,15))&&j.set(W.slice(0,15),{id:W,differ:void 0})}}if(j.size!==0)for await(let v of s(f,[...j.values()].map(({id:O})=>O))){if(typeof v.Id!="string"||!Oe.test(v.Id))continue;let O=v.Id.slice(0,15),B=j.get(O);if(B===void 0)continue;let W=ao(v,p,B.differ);W.length>0&&g.set(O,{fields:W.map(({field:D})=>D),needs:W[0].needs})}}return{comes:l,left:c,fields:g}}function Mi(e,n){let t=n!==void 0?` Rewind ${n} with it to put it back.`:"",o=n??"an object this rewind was not limited to";switch(e){case"needsUnpickedParent":return`Left: it comes back only with a parent this rewind leaves deleted, or a lookup of it names a record this rewind leaves deleted (${o}), which the org refuses to point at.${t}`;case"heldByUnpicked":return`Given back but for the values records of ${o} created since hold in place: this rewind leaves them, so the org refuses to change those values.${t}`;case"outsideNotAccepted":return`Kept: records of ${o} created since hang from it, which its deletion would take along, and deleting them was not accepted.${t}`;default:return`Kept: records of ${o} this rewind leaves as they are hang from it, and its deletion would take them along.${t}`}}async function Ti(e){let{checkpoint:n,pass:t,confirmedDir:o,freshDir:s,dir:i,signal:r}=e,a=Date.parse(n.takenAt);if(!Number.isFinite(a))throw new Error(`Not a date: ${n.takenAt}`);let l=Date.parse(e.readAt);if(!Number.isFinite(l))throw new Error(`Not a date: ${e.readAt}`);let w=l-Ai;if(await yn(i),(await Ri(i)).length>0)throw new Error(`A rewind's plan is written to a folder of its own: ${i} is not empty.`);let p=()=>{if(r?.aborted)throw new te},c=[...n.objects].map(ht).sort((u,y)=>u.readOrder-y.readOrder),g=new Map(c.map(({objectApiName:u},y)=>[u,y])),d=new Map(c.map(({objectApiName:u})=>[u,io(u)])),f=u=>d.get(u)??io(u),h=new Set(e.ownWriters.map(u=>u.slice(0,15))),b=new Map(Object.entries(e.removalStamps??{}).map(([u,y])=>[u.slice(0,15),Qe(y)])),R=u=>fo(u,w,h,b),j=(u,y)=>u.flatMap(T=>{let M=y[T];return typeof M=="string"&&Oe.test(M)?[M]:[]}),C=(u,y)=>j(u.cascadeParents,y),v=(u,y)=>j(u.restrictParents??[],y),O=new Vn,B=u=>e.objects===void 0||e.objects.has(u),W=e.objects!==void 0?await Ei(e,c,B):void 0,D=new Map,L=new Map,N=new on(Jn(i,"leftFields.ndjson")),V=0,J=(u,y,T,M)=>{if(O.add(u,y,T,void 0,M),D.set(T.slice(0,15),Mi(y,M)),M===void 0)return;let _=L.get(M);_||(_=new Z,L.set(M,_)),_.add(T)},Y=new Z,x=new Z,P=new Z,H=new Z,Q=new Z,z=new Z,fe=[];for(let u of c){p();let y=u.objectApiName,T=B(y),M=(g.get(y)??0)+1,_=f(y),m=new Z;for(let S of no){let F=X(o,y,S);for await(let U of q(F))m.add(re(U,F),de[S])}let A=t===2?await Gi(s,y,w,h,b,fe):void 0,I=new Map,$=S=>{let F=I.get(S);return F||(F=new on(X(i,y,S)),I.set(S,F)),F};for(let S of no){if(!T&&S!=="comesBackWithParent"&&S!=="createdSince")continue;let F=X(s,y,S);for await(let U of q(F)){let G=re(U,F),ie=(m.flagsOf(G)&Pi[S])!==0;if(!T&&!(t===2?ie:S==="comesBackWithParent"&&ie&&W?.comes.has(G.slice(0,15))))continue;ie&&m.add(G,to),ie&&ln.has(S)&&(m.flagsOf(G)&de.carrier)!==0&&z.add(G);let ce=A?.other.flagsOf(G)??0,un=T&&A?.own.has(G)===!0;if(ce>0||!(ie||un)){let Ke=ce>0?"changedDuringRewind":"changedSincePreview";O.add(y,Ke,G,ce>0?fe[ce-1]:void 0),ln.has(S)&&P.add(G,Ue[Ke]);continue}if(W!==void 0&&T){let Ke=G.slice(0,15);if(S==="comesBackWithParent"&&!W.comes.has(Ke))continue;if((S==="withParent"||S==="toRecreate")&&W.left.has(Ke)){J(y,"needsUnpickedParent",G,W.left.get(Ke));continue}let gn=W.fields.get(Ke);if(gn!==void 0&&(S==="giveBack"||S==="toRecreate"||S==="inBin"||S==="withParent")){J(y,"needsUnpickedParent",G,gn.needs),await N.add({Id:G,fields:gn.fields}),V++;let Qn=Array.isArray(U.fields)?U.fields:[],lo=Qn.filter(Zn=>typeof Zn=="string"&&!gn.fields.some(uo=>uo.toLowerCase()===Zn.toLowerCase()));if(S==="giveBack"&&Qn.length>0&&lo.length===0)continue}}if(S==="toRecreate"&&!e.acceptRecreate){O.add(y,"recreateNotAccepted",G);continue}await $(S).add(S==="giveBack"?U:{Id:G}),S==="giveBack"&&W!==void 0&&Y.add(G,M),ln.has(S)?x.add(G,M):S==="comesBackWithParent"?(H.add(G),_.nextPassDeleted++):S==="carrier"?(H.add(G),Q.add(G),_.carriers=(_.carriers??0)+1,_.nextPassDeleted++):S==="inBin"||S==="deletedWhileTaken"?_.broughtBack++:S==="withParent"?_.backWithParent++:S==="toRecreate"&&_.recreated++,(S==="inBin"||S==="withParent")&&await $("giveBack").add({Id:G})}}for(let S of I.values())await S.flush();_.skipped=T?m.count(S=>(S&to)===0):0}await N.flush();let oe=new Map;if(W!==void 0){let u=new Z;for(let y of c){let T=y.objectApiName;if(B(T)||y.cascadeParents.length===0)continue;let M=new Z;for(let _ of ln){let m=X(s,T,_);for await(let A of q(m))M.add(re(A,m))}for await(let _ of q(xe(s,T))){if(typeof _.Id!="string"||!Oe.test(_.Id)||x.has(_.Id))continue;let m=M.has(_.Id),A=m&&Qe(_.CreatedDate)>=a&&Qe(_.LastModifiedDate)<=w;for(let I of C(y,_)){let $=x.flagsOf(I);if($>0){if(P.has(I)||A&&e.acceptOutside)continue;let F=c[$-1].objectApiName;oe.set(I.slice(0,15),T),A?(P.add(I,Ue.outsideNotAccepted),J(F,"outsideNotAccepted",I,T)):P.add(I,Ue.holdsLeft);continue}let S=Y.flagsOf(I);m&&S>0&&u.add(I)&&J(c[S-1].objectApiName,"heldByUnpicked",I,T)}}}}if(n.scope.mode==="picked"&&!e.acceptOutside)for(let u of c){let y=X(s,u.objectApiName,"outsideParents");for await(let T of q(y)){let M=re(T,y);!x.has(M)||P.has(M)||z.has(M)||(P.add(M,Ue.outsideNotAccepted),O.add(u.objectApiName,"outsideNotAccepted",M))}}let ue=c.map(u=>({object:u,file:xe(s,u.objectApiName)}));for(let u=P.size>0;u;){p(),u=!1;for(let{object:y,file:T}of ue)for await(let M of q(T)){if(!P.has(M.Id))continue;let _=oe.get(String(M.Id).slice(0,15));for(let m of C(y,M))!x.has(m)||P.has(m)||(P.add(m,Ue.holdsLeft),_!==void 0&&oe.set(m.slice(0,15),_),u=!0)}}for(let{object:u,file:y}of ue)for await(let T of q(y))if(x.has(T.Id)&&P.flagsOf(T.Id)===Ue.holdsLeft){let M=re(T,y),_=oe.get(M.slice(0,15));_!==void 0?J(u.objectApiName,"holdsLeft",M,_):O.add(u.objectApiName,"holdsLeft",M)}let Ae=new Z,he=u=>x.has(u)&&!P.has(u),Se=new Map,De=u=>{let y=u.slice(0,15);return Se.get(y)??y},ye=new Z,ze=[...c].reverse(),be=[];for(let u of ze){p();let y=u.objectApiName,T=xe(s,y),M=new on(Di(i,y)),_=0;for await(let m of q(T)){let A=typeof m.Id=="string"?m.Id:"";if(!he(A))continue;let I=Qe(m.LastModifiedDate),$=C(u,m).filter(he);if($.length>0&&Qe(m.CreatedDate)>=a&&(I<=w||I<=(b.get(A.slice(0,15))??Number.NaN))){let G=De($[0]);if(!($.some(ce=>ye.has(ce))||v(u,m).some(ce=>he(ce)&&De(ce)!==G))){Ae.add(A),Se.set(A.slice(0,15),G),f(y).withParentDeleted++;continue}ye.add(A)}let F=[...C(u,m),...v(u,m)].filter(he);if(u.undeletable&&F.length===0)continue;let U=F.length>0?"beforeParentNotAccepted":"noUndoNotAccepted";e.acceptNoUndo?(f(y).undoCannot++,F.length>0&&(await M.add({Id:A,parents:F}),_++)):(P.add(A,Ue[U]),O.add(y,U,A))}await M.flush(),_>0&&be.push({objectApiName:y,count:_,file:M.file})}let ne=new We(`${i}/deletes`),Fe=new We(`${i}/along-to-draft`),ge={},we=new Z,Ee=0;for(let u of c){p();let y=u.objectApiName,T=xe(s,y),M=0;for await(let _ of q(T)){let m=typeof _.Id=="string"?_.Id:"";if(x.has(m)&&(Ee++,!P.has(m))){for(let A of C(u,_))we.has(A)||we.add(A,(g.get(y)??0)+1);if(Ae.has(m)){ot([y]).length>0&&await Fe.add(y,m);continue}await ne.add(y,m),M++,t===2&&R(_)&&typeof _.LastModifiedDate=="string"&&(ge[m]=_.LastModifiedDate)}}f(y).deleted=M}if(Ee!==x.size)throw new Error("The fresh diff's reads do not hold every record its classes name to delete.");let sn=await Ln.of(ne),Ze=await Ln.of(Fe),Me=new Z;if(t===1&&H.size>0){for(let u of c)for await(let y of q(cn(s,u.objectApiName)))if(H.has(y.Id))for(let T of C(u,y))Me.add(T)}let ae=new Map;for(let u of c){let y=await Ni(u,s,i,["inBin","deletedWhileTaken"]);if(y.size===0)continue;ae.set(u.objectApiName,y);let T=f(u.objectApiName);T.broughtBack-=y.size,T.keyTaken=y.size;for(let M of["inBin","deletedWhileTaken"]){let _=X(i,u.objectApiName,M);for await(let m of q(_)){let A=re(m,_);y.has(A)&&O.add(u.objectApiName,"keyTaken",A)}}}let qe=new We(`${i}/giveBackFirst`),Te=new We(`${i}/giveBackAfter`),Ce=[];for(let u of c){p();let y=u.objectApiName,T=X(i,y,"giveBack"),M=!1;for await(let $ of q(T))if(we.has($.Id)){M=!0;break}let _=new Z;if(M)for await(let $ of q(xe(s,y)))we.has($.Id)&&C(u,$).some(he)&&_.add(String($.Id));let m=f(y),A=new Set,I=ae.get(y);for await(let $ of q(T)){let S=re($,T);if(I?.has(S)===!0)continue;let F=we.flagsOf(S),U=_.has(S);if(F>0){if(await Te.add(y,S),m.givenBackAfter++,A.add(c[F-1].objectApiName),!U)continue}else if(!U&&Me.has(S)){m.givenBackNextPass++;continue}await qe.add(y,S),m.givenBackFirst++}A.size>0&&Ce.push({objectApiName:y,by:[...A]})}let Ne=new We(`${i}/bringBack`),He=new We(`${i}/recreate`);for(let u of ze){let y=ae.get(u.objectApiName);for(let M of["carrier","inBin","deletedWhileTaken"]){let _=X(i,u.objectApiName,M);for await(let m of q(_)){let A=re(m,_);y?.has(A)!==!0&&await Ne.add(u.objectApiName,A)}}let T=X(i,u.objectApiName,"toRecreate");for await(let M of q(T))await He.add(u.objectApiName,re(M,T))}let Xe=new Z;if(t===2)for(let u of c)for(let y of["inBin","withParent","deletedWhileTaken","carrier","toRecreate"]){let T=X(o,u.objectApiName,y);for await(let M of q(T))Xe.add(re(M,T))}let Ye=n.files===void 0||!B(le)?co(i):await Li({confirmedDir:o,freshDir:s,dir:i,pass:t,deleted:u=>Oe.test(u)&&he(u),earlier:u=>Oe.test(u)&&(Xe.has(u)||Xe.has(e.recreated?.originalOf(u.slice(0,15))??u)),left:O}),_e=new We(`${i}/unlinkFrom`);for(let u of ln){let y=X(i,le,u);for await(let T of q(y)){let M=re(T,y);(P.flagsOf(M)&Ue.outsideNotAccepted)!==0&&await _e.add(le,M)}}let k={...e.removalStamps,...ge},E=Object.keys(k).length>0,K=c.map(({objectApiName:u})=>f(u)).filter(ji);return{pass:t,dir:i,deletes:sn,removal:{runStartedAt:new Date(a),runEndedAt:new Date(w),includeChanged:!1,...E?{removalStamps:k}:{},...e.removalSpans&&e.removalSpans.length>0?{removalSpans:[...e.removalSpans]}:{}},bringBack:await Ne.finish(),carriers:Q,goesAlong:Ae,alongToDraft:Ze,recreate:await He.finish(),giveBack:{beforeDeletes:await qe.finish(),afterDeletes:await Te.finish(),heldBy:Ce},restore:{changedAfter:e.readAt,ownWriters:[...e.ownWriters],includeChanged:!1,...E?{stamps:k}:{}},objects:K,undoCannot:K.filter(u=>u.undoCannot>0).map(({objectApiName:u,undoCannot:y})=>({objectApiName:u,count:y})),beforeParent:be.reverse(),left:O.all(g),links:{...Ye,unlinkFrom:await _e.finish()},...W!==void 0?{limited:{objects:c.map(({objectApiName:u})=>u).filter(B),needs:[...L].sort(([u],[y])=>(g.get(u)??0)-(g.get(y)??0)).map(([u,y])=>({objectApiName:u,records:y.size})),why:D,leftFields:{file:N.file,count:V}}}:{}}}function Hs(e,n){if(n===void 0)return e;let t=i=>i.filter(r=>n.has(r.objectApiName)),{files:o,...s}=e;return{...s,objects:t(e.objects),undoCannot:t(e.undoCannot),unread:t(e.unread),...e.withParentDeleted?{withParentDeleted:t(e.withParentDeleted)}:{},...e.unseen?{unseen:t(e.unseen)}:{},...o!==void 0&&n.has(le)?{files:o}:{}}}var _i=200;function Ks(e,n){return async function*(t,o){if(o.length===0)return;let s=await $e.read(n,e.snapshotId,t);for(let i=0;i<o.length;i+=Ve){let r=await s.chunk(o.slice(i,i+Ve)).batches(e.snapshotId,t,_i);for await(let a of r??[])yield*a}}}var $i=new Set(["needsUnpickedParent","heldByUnpicked","outsideNotAccepted","holdsLeft","keyTaken"]);async function Wi(e,n){let t=0;for await(let o of q(X(e,n,"giveBack")))Array.isArray(o.fields)&&t++;return t}async function xi(e){let n=new Set(e.limited?.objects??e.objects.map(i=>i.objectApiName)),t=[];for(let i of e.objects){let r={objectApiName:i.objectApiName,picked:n.has(i.objectApiName),toDelete:i.deleted+i.withParentDeleted+i.nextPassDeleted-(i.carriers??0),toGiveBack:await Wi(e.dir,i.objectApiName),toBringBack:i.broughtBack+i.backWithParent,toRecreate:i.recreated};r.toDelete+r.toGiveBack+r.toBringBack+r.toRecreate>0&&t.push(r)}let o=new Map;for(let i of e.left){if(!n.has(i.objectApiName)||!$i.has(i.reason))continue;let r=`${i.objectApiName}\0${i.reason}`,a=o.get(r);a?a.count+=i.count:o.set(r,{objectApiName:i.objectApiName,reason:i.reason,count:i.count})}let s=e.undoCannot.flatMap(({objectApiName:i,count:r})=>{let a=e.beforeParent.find(w=>w.objectApiName===i),l=r-(a?.count??0);return[...l>0?[{objectApiName:i,count:l}]:[],...a!==void 0&&a.count>0?[{objectApiName:i,count:a.count,reason:"deletedBeforeParent"}]:[]]});return{objects:[...n],acts:t,left:[...o.values()],needs:e.limited?.needs??[],undoCannot:s}}async function Vs(e){let n=Jn(e.previewDir,`selection-${yi(4).toString("hex")}`);try{let t=await Ti({checkpoint:e.checkpoint,pass:1,confirmedDir:e.previewDir,freshDir:e.previewDir,readAt:e.readAt,ownWriters:[],acceptOutside:e.acceptOutside,acceptNoUndo:!0,acceptRecreate:!0,...e.objects?{objects:e.objects}:{},...e.heldRows?{heldRows:e.heldRows}:{},dir:n,...e.signal?{signal:e.signal}:{}});return await xi(t)}finally{await Oi(n,{recursive:!0,force:!0})}}function fo(e,n,t,o){let s=Qe(e.LastModifiedDate);if(!(s>n))return!1;let i=typeof e.Id=="string"?e.Id:"",r=typeof e.LastModifiedById=="string"?e.LastModifiedById:"";return s<=(o.get(i.slice(0,15))??Number.NaN)||t.has(r.slice(0,15))}async function Gi(e,n,t,o,s,i){let r={own:new Z,other:new Z};for(let a of[xe(e,n),cn(e,n)])for await(let l of q(a)){if(!(Qe(l.LastModifiedDate)>t))continue;let p=re(l,a);if(fo(l,t,o,s)){r.own.add(p);continue}let c=typeof l.LastModifiedById=="string"?l.LastModifiedById:"",g=i.indexOf(c);g<0&&(i.push(c),g=i.length-1),r.other.add(p,g+1)}return r}export{Gn as a,ss as b,X as c,Uo as d,Is as e,zs as f,qs as g,Ti as h,Hs as i,Ks as j,xi as k,Vs as l};
|
package/lib/chunk-GEEWPTV5.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a as Ce}from"./chunk-GMY5427L.mjs";import{h as Re,i as be,j as Se,k as ke,n as Te,o as Fe}from"./chunk-TEIBWMJM.mjs";import{c as Oe}from"./chunk-BWWQXU2B.mjs";import{f as he,i as me,o as we}from"./chunk-YBZIDW6W.mjs";import{b as fe,c as q,m as pe}from"./chunk-HFSBDM7B.mjs";import{d as K}from"./chunk-OHEOJISY.mjs";import{G as se,q as te,s as ne,t as re,u as oe}from"./chunk-2GSMHGIV.mjs";import{b as ee}from"./chunk-CA5NAXSU.mjs";import{a as z,l as ie,o as ae,q as de,t as ce,u as ue,v as le}from"./chunk-ICIYL45C.mjs";import{b as ye,e as ge}from"./chunk-7BQMBXKX.mjs";import{Sc as X,id as B}from"./chunk-6QSHWIZI.mjs";var H=/^[A-Za-z0-9]{15}(?:[A-Za-z0-9]{3})?$/;function b(t){return t.slice(0,15)}var We=class{constructor(e=new Map){this.earlier=e}earlier;written=new Map;refused=new Map;deleted=new Set;ownersRefused=new Set;contactsSentWith=new Map;noteSentWithContact(e,n){this.contactsSentWith.set(b(e),n)}contactSentWith(e){return this.contactsSentWith.get(b(e))}roleLinkedFor(e){this.contactsSentWith.delete(b(e))}get sentWithAContact(){return this.contactsSentWith.size>0}noteOwnerRefused(e){this.ownersRefused.add(b(e))}isOwnerRefused(e){return this.ownersRefused.has(b(e))}noteDeleted(e){for(let n of e)this.deleted.add(b(n))}standing(e){return e!==void 0&&this.deleted.has(b(e))?void 0:e}noteMatched(e,n){this.noteWritten(e,n)}noteWritten(e,n){this.written.set(b(e),n),this.refused.delete(b(e))}noteRefused(e,n){this.written.has(b(e))||this.refused.set(b(e),n)}targetOf(e){return this.standing(this.written.get(b(e)))??this.standing(this.earlier.get(b(e)))}refusedObjectOf(e){if(this.standing(this.earlier.get(b(e)))===void 0)return this.refused.get(b(e))}};function Ae(t,e,n){if(e.length===0||!n.some(o=>!o.master))return;let r={};for(let o of e)r[o]=(r[o]??0)+1;let s=Se(be(n));return{objectApiName:t,rows:e.length,why:r,...s?{predicted:s}:{}}}function Ie(t,e){return q(t,e?.target??[])}function Y(t){switch(t.operation){case"insert":return null;case"upsert":return t.externalIdField??"Id";case"update":case"delete":return"Id"}}function ze(t,e,n,r,s){let o=ge(t,e);for(let i of n)(!(i.fieldApiName in o)||i.overwriteExisting)&&(o[i.fieldApiName]=i.value);if(!r)return o;let a={};for(let i of Object.keys(o))i!=="attributes"&&(r.has(i)||i===s)&&(a[i]=o[i]);return a}function ve(t,e){return`${t} ${e} record${t===1?"":"s"}`}function Ue(t,e,n){let r=a=>e.find(i=>b(i.recordTypeId)===b(a)),s=t;if(!r(t)&&n){let a=n.mappings.find(i=>b(i.sourceId)===b(t));if(!a){let i=n.source.find(c=>b(c.id)===b(t)),y=i?(n.target??[]).filter(c=>c.sobjectType===i.sobjectType&&c.developerName===i.developerName):[];return{unmapped:i?K(i):"",namesakes:y.map(K)}}s=a.targetId}let o=q(e.filter(a=>b(a.recordTypeId)===b(s)),n?.target??[])[0];return o&&!o.available&&!o.master?{unavailable:o}:o?{sent:s,info:o}:{sent:s}}function Ge(t,e,n){if(t?.personAccounts===!1)return!0;if(!n)return!1;let r=e??Te(t?.recordTypes);return r!==void 0&&!n.has(b(r))}function Le(t,e,n){return{group:`parent:${e}:${n}`,reason:`PARENT_REFUSED: the ${n} record its ${e} names was refused in this run.`,say:r=>`PARENT_REFUSED: ${ve(r,t)} held back, not sent: the ${n} record their ${e} names was refused in this run, and written without it they would stand without their ${n}.`}}function Ee(t){let{config:e,records:n,target:r,run:s}=t,o=e.objectApiName,a=Y(e),i=r?.recordTypes??[],y=r?.references??new Set,c={payloads:[],sentAt:[],settled:[],held:[],deferred:[],deferredAcross:[],notes:[],currencies:[],withoutRecordType:new Map},h=new Map,m=new Map,T=(d,l,g,k)=>{c.held.push({index:d,reason:g}),h.delete(d);let I=m.get(l);I?I.count++:m.set(l,{count:1,say:k})},w=e.operation==="insert"||e.operation==="upsert",W=w&&i.some(d=>!d.master),f=new Map;s&&w&&s.sources.forEach((d,l)=>{let g=d?.Id;typeof g=="string"&&H.test(g)&&f.set(b(g),l)});let v=new Set([...s&&w?s.later??[]:[]].map(d=>d.toLowerCase())),R=new Set(v.size===0?[]:(r?.fields??[]).flatMap(d=>d.isReference&&(d.referenceTo??[]).some(l=>v.has(l.toLowerCase()))&&!(d.nillable===!1&&d.defaultedOnCreate!==!0)?[d.name]:[]));n.forEach((d,l)=>{let g=ze(d,e.fieldMappings,e.addOnFields,r?.creatable??null,a);if(e.operation==="delete"){h.set(l,{payload:g,settled:new Set});return}let k=new Set;if(s)for(let p of Object.keys(g)){let C=g[p];if(p==="RecordTypeId"||!y.has(p)||typeof C!="string"||!H.test(C))continue;if(f.has(b(C))){delete g[p],c.deferred.push({index:l,field:p,parent:C});continue}let _=s.links.targetOf(C);if(_){g[p]=_,k.add(p);continue}let M=s.links.refusedObjectOf(C);if(M===void 0){R.has(p)&&(delete g[p],c.deferredAcross.push({index:l,field:p,parent:C}));continue}let G=Le(o,p,M);T(l,G.group,G.reason,G.say);return}let I=g.RecordTypeId,E,j=Oe(I);if(j)delete g.RecordTypeId;else if(typeof I=="string"&&H.test(I)){let p=Ue(I,i,s?.recordTypes);if("unmapped"in p){let C=p.unmapped,_=p.namesakes.length>0?` The target org's ${p.namesakes.join(" and ")} carries its DeveloperName under another namespace, and a record type is mapped to one of the same namespace only.`:"";T(l,`unmapped:${C}`,"RECORD_TYPE_UNMAPPED: its record type has no counterpart in the target org.",M=>`RECORD_TYPE_UNMAPPED: ${ve(M,o)} held back, not sent: `+(C?`their record type ${C} has no active ${o} record type of that API name in the target org.${_} Create or activate record type ${C} on ${o} in the target org.`:"their record type is inactive in the source org, and has no counterpart in the target org."));return}if("unavailable"in p){let C=p.unavailable;T(l,`unavailable:${C.recordTypeId}`,`RECORD_TYPE_UNAVAILABLE: record type ${C.developerName} is closed to the running user in the target org.`,_=>`${pe({objectApiName:o,recordTypeId:C.recordTypeId,developerName:C.developerName,name:C.name,inactive:!C.active,recordCount:_})} Held back, not sent.`);return}g.RecordTypeId=p.sent,E=p.sent,p.info&&k.add("RecordTypeId")}let $=s?.sources[l]??d;if(re($)){let p=oe($,Ge(r,E,s?.recordTypes?.personTypes));for(let C of Object.keys(g))B(o,C,p)&&delete g[C]}else for(let p of Object.keys(g))B(o,p,"business")&&delete g[p];W&&!("RecordTypeId"in g)&&c.withoutRecordType.set(l,j?"masterInSource":"notRead"),h.set(l,{payload:g,settled:k})});let L=!0;for(;L;){L=!1;for(let{index:d,field:l,parent:g}of c.deferred){let k=f.get(b(g));if(!h.has(d)||k===void 0||h.has(k)||s?.links.targetOf(g)!==void 0)continue;let I=Le(o,l,o);T(d,I.group,I.reason,I.say),L=!0}}c.deferred=c.deferred.filter(({index:d})=>h.has(d)),c.deferredAcross=c.deferredAcross.filter(({index:d})=>h.has(d));for(let d of[...c.withoutRecordType.keys()])h.has(d)||c.withoutRecordType.delete(d);c.held.sort((d,l)=>d.index-l.index);let S=e.operation==="delete"?void 0:s?.currencies,O=r?.creatable.has(z)===!0,u=!O&&(s?.currencyChangesById?.size??0)>0&&r?.fields?.some(d=>d.name===z)===!0,F=S&&(O||u)?ae(r?.fields??[]):void 0,P=[...r?.references??[]],A=new le;for(let[d,{payload:l,settled:g}]of[...h].sort(([k],[I])=>k-I)){for(let k of X(o,l))delete l[k];if(S&&F){let k=s?.sources[d]??n[d],I=k?.[z],E=O?de(l,{read:I,currencyFields:F,ratesOn:ie(o,k)},S):ue(l,{read:I,parent:k?ce(o,k,P,$=>s?.currencyChangesById?.get($)):void 0,currencyFields:F},S);A.add(o,E);let j=k?.Id;E&&typeof j=="string"&&s?.currencyChangesById?.set(j,E)}c.payloads.push(l),c.sentAt.push(d),c.settled.push(g)}return c.notes=[...m.values()].map(({count:d,say:l})=>l(d)),c.currencies=A.list(),c}function V(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:void 0}function Be(t){let e=V(t.length),n=V(t.precision),r=V(t.digits);return{name:t.name,queryable:t.queryable!==!1,createable:t.createable===!0,isReference:t.type==="reference",...t.type!==void 0?{type:t.type}:{},...e!==void 0?{length:e}:{},...t.nillable!==void 0?{nillable:t.nillable}:{},...t.defaultedOnCreate!==void 0?{defaultedOnCreate:t.defaultedOnCreate}:{},...t.calculated===!0?{calculated:!0}:{},...n!==void 0?{precision:n}:{},...n!==void 0&&typeof t.scale=="number"&&t.scale>=0?{scale:t.scale}:{},...r!==void 0?{digits:r}:{},...t.unique===!0?{unique:!0}:{},...t.referenceTo?{referenceTo:[...t.referenceTo]}:{}}}function yt(t){let e=t.fields.filter(r=>r.createable===!0),n=t.fields.some(r=>typeof r.idLookup=="boolean");return{creatable:new Set(e.map(r=>r.name)),references:new Set(e.filter(r=>r.type==="reference").map(r=>r.name)),...typeof t.createable=="boolean"?{objectCreateable:t.createable}:{},...typeof t.updateable=="boolean"?{objectUpdateable:t.updateable}:{},recordTypes:fe(t.recordTypeInfos),...t.name===te?{personAccounts:t.fields.some(r=>r.name===ne)}:{},fields:t.fields.map(Be),...n?{upsertKeys:new Set(t.fields.filter(r=>r.externalId===!0||r.idLookup===!0).map(r=>r.name.toLowerCase()))}:{}}}function Z(t,e,n){switch(e){case"notInTarget":return`Object is not in the target org, or the user the run writes as cannot see it: ${t}. None of its records were sent.`;case"notCreateable":return`Object is not createable on target org: the user the run writes as may not create ${t} records there. None of its records were sent.`;case"notUpdateable":return`Object is not updateable on target org: the user the run writes as may not edit ${t} records there. None of its records were sent.`;case"unread":return`The target org did not describe ${t}${n?` (${n})`:""}, so what it takes could not be told and none of its records were sent.`;case"notAKey":return`The upsert of ${t} matches on ${n??"a field"}, which the target org does not match an upsert on: it takes an External ID field, the Id, or a field its describe marks idLookup. None of its records were sent.`}}function gt(t,e){let n=t.externalIdField?.trim().toLowerCase();if(t.operation!=="upsert"||!n)return t;let r=e.fields?.find(s=>s.name.toLowerCase()===n)?.name;return r===void 0?t:{...t,externalIdField:r}}function ht(t,e){if(t.operation==="delete"||t.query===void 0)return t;let n=Ce(t.query);if(!("list"in n))return t;let r=new Set([...n.list,t.externalIdField??"",...t.fieldMappings.filter(o=>ye.has(o.type)).map(o=>o.sourceField)].map(o=>o.toLowerCase())),s=[...e.creatable].filter(o=>!r.has(o.toLowerCase()));return s.length===0?t:{...t,excludedFields:[...new Set([...t.excludedFields??[],...s])]}}async function Pe(t,e,n,r){let s;try{s=await t(e)}catch(c){if(n==="delete")return{notAsked:!0};let h=Fe(c)?"notInTarget":"unread";return{refused:{why:h,message:Z(e,h,ee(c))}}}let o=n==="insert"||n==="upsert",a=n==="update"||n==="upsert",i=o&&s.objectCreateable===!1?"notCreateable":a&&s.objectUpdateable===!1?"notUpdateable":void 0;if(i)return{refused:{why:i,message:Z(e,i)},target:s};let y=r?.trim()||"Id";return n==="upsert"&&s.upsertKeys&&!s.upsertKeys.has(y.toLowerCase())?{refused:{why:"notAKey",message:Z(e,"notAKey",y),key:y},target:s}:{target:s}}function Rt(t){return t.keepContactPoints===!0?void 0:new Re}function Ot(t,e){if(!t)return e?{neutralized:!1,fields:[],values:0}:void 0;let n=t.report();return n.values>0?n:void 0}function xe(t,e,n,r,s){let o=s?n.filter(i=>i.name!==s):n,a=t.forObject(e,o);if(a)for(let i of r)a(i)}var x=class extends Error{constructor(n,r=[],s=[],o=[],a){super(r.length===0?`The write of ${n} was cancelled before any of its records was written.`:`The write of ${n} was cancelled after ${r.length} of its records were sent.`);this.objectApiName=n;this.written=r;this.notes=s;this.lookupsLeftOut=o;this.writtenWithoutFields=a;this.name="WriteCancelledError"}objectApiName;written;notes;lookupsLeftOut;writtenWithoutFields};var Ne=class{deps;constructor(e){this.deps=e}async sync(e,n,r){let{outcomes:s,notes:o,currencies:a,lookupsLeftOut:i,writtenWithoutFields:y}=await this.write(e,n,r);return Je(Qe(e.objectApiName,e.operation,s,o,i,y),a)}updateRecords(e,n,r){return this.executeOperation(e,"update",n,r)}async write(e,n,r){let s=null;if(this.deps.describeTargetFields){let u=await Pe(this.deps.describeTargetFields,e.objectApiName,e.operation,e.externalIdField);if("refused"in u){let F=n.map(()=>({success:!1,errors:[u.refused.message]}));return r&&$e(e,F,r),{outcomes:F,notes:[],currencies:[],lookupsLeftOut:[]}}"target"in u&&u.target.creatable.size>0&&(s=u.target)}let o=Ee({config:e,records:n,target:s,run:r}),a=r?r.contactPoints:this.deps.contactPoints;a&&s?.fields&&xe(a,e.objectApiName,s.fields,o.payloads,e.externalIdField);let i=He(o.payloads,o.settled,r),y=new Map(o.held.map(({index:u,reason:F})=>[u,F])),c=u=>{let F=[],P=0;for(let A=0;A<n.length;A++){let d=y.get(A);if(d!==void 0){F.push({success:!1,errors:[d],heldBack:!0});continue}if(P>=u.length)break;F.push(u[P++])}return F},h,m=o.sentAt.filter(u=>u<(r?.standardFirst??0)).length,T=u=>this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField);try{h=o.payloads.length===0&&n.length>0?[]:m>0&&m<o.payloads.length?await Ve(e.objectApiName,T,o.payloads.slice(0,m),o.payloads.slice(m)):await T(o.payloads)}catch(u){if(!(u instanceof x))throw u;let F=je(i,u.written),P=c(u.written);throw De(e,o.withoutRecordType,P,s,r),new x(e.objectApiName,P,[...o.notes,...u.notes],[...F?[F]:[],...u.lookupsLeftOut,...Q(U([...o.deferred,...o.deferredAcross],P))],u.writtenWithoutFields)}let w=await this.retryRefused(e,o.payloads,h,s?.references??null,o.settled);if(r)for(let u of w.ownersRefused)r.links.noteOwnerRefused(u);let W=c(w.outcomes);De(e,o.withoutRecordType,W,s,r);let f=je(i,w.outcomes),v=[...o.notes,...w.notes],R=[...f?[f]:[],...w.lookupsLeftOut],{writtenWithoutFields:L}=w,S=U(o.deferredAcross,W),O=0;if(w.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q([...U(o.deferred,W),...S])],L);if(r){$e(e,W,r),Ze(e,o.payloads,w.outcomes,r.links);let u=await this.setLookups(e,U(o.deferred,W),r.links,!1);if(R.push(...u.leftOut),O=u.unset,u.cancelled)throw new x(e.objectApiName,W,v,[...R,...Q(S)],L)}return{outcomes:W,notes:v,currencies:o.currencies,lookupsLeftOut:R,...L?{writtenWithoutFields:L}:{},...S.length>0?{lookupsToSet:S}:{},...O>0?{lookupsUnset:O}:{}}}async setLookups(e,n,r,s){let o=e.objectApiName,a=new Map,i=new Map,y=new D;for(let{id:f,field:v,parent:R}of n){let L=r.targetOf(R),S=L!==void 0?a:s&&r.refusedObjectOf(R)===void 0?i:void 0;if(!S){y.add(f,v);continue}let O=S.get(f)??{Id:f};O[v]=L??R,S.set(f,O)}let c=new D,h=new D,m=new D,T=new D,w=!1;for(let f of[[...a.values()],[...i.values()]]){if(f.length===0)continue;if(w){for(let R of f)T.addRow(R);continue}let v;try{v=await this.executeOperation(o,"update",f,e.batchSize)}catch(R){if(!(R instanceof x)){let L=R instanceof Error?R.message:String(R);for(let S of f)m.addRow(S,L);continue}v=R.written,w=!0}f.forEach((R,L)=>{let S=v[L];S===void 0?T.addRow(R):S.success?c.addRow(R):S.errors.some(O=>J(O))?h.addRow(R):m.addRow(R,S.errors[0])})}let W=[y,h,m,T];return{...c.records>0?{set:{records:c.records,fields:c.fields()}}:{},leftOut:[y.leftOut("parentRefused"),h.leftOut("notInTarget"),m.leftOut("notSet"),T.leftOut("notReached")].flatMap(f=>f?[f]:[]),unset:new Set(W.flatMap(f=>[...f.recordIds])).size,cancelled:w}}async retryRefused(e,n,r,s,o){let a=Y(e)??void 0,i=[...r],y=[...n],c=n.map(()=>new Set),h=n.map(()=>[]),m=n.map(()=>[]),T=[],w,W=new Set;for(let S=0;S<2&&!w;S++){let O=[],u=[],F=[];if(i.forEach((A,d)=>{if(A.success)return;let l=y[d],g=o[d]??new Set;if(A.errors.some(E=>J(E))){let E=n[d]?.[N];if(typeof E=="string"&&!g.has(N)&&(A.errorDetails??[]).some(p=>J(p.statusCode)&&p.fields.includes(N))&&W.add(E),c[d].has("lookup")||!s||s.size===0)return;let j={},$=!1;for(let p of Object.keys(l)){if(s.has(p)&&!g.has(p)&&l[p]!==null&&l[p]!==void 0){$=!0;continue}j[p]=l[p]}if(!$)return;O.push(d),u.push(j),F.push(null);return}if(c[d].has("fields"))return;let k=he(A.errorDetails,l,a);if(!k||k.some(({field:E})=>g.has(E)))return;let I=new Set(k.map(({field:E})=>E));O.push(d),u.push(Object.fromEntries(Object.entries(l).filter(([E])=>!I.has(E)))),F.push(k)}),O.length===0)break;let P;try{P=await this.executeOperation(e.objectApiName,e.operation,u,e.batchSize,e.externalIdField)}catch(A){if(!(A instanceof x)){T.push(...Ye(O,y,u,F,A));break}P=A.written,w=A}P.forEach((A,d)=>{let l=O[d],g=F[d];c[l].add(g===null?"lookup":"fields"),g===null?h[l].push(...Object.keys(y[l]).filter(k=>!(k in u[d]))):m[l].push(...g),y[l]=u[d],i[l]=A})}let f=new Set,v=0,R,L=new Set(W);return i.forEach((S,O)=>{if(!(!S.success||c[O].size===0)){if(h[O].length>0){v++;for(let F of h[O])f.add(F);let u=n[O]?.[N];typeof u=="string"&&h[O].length===1&&h[O][0]===N&&L.add(u)}m[O].length>0&&(R=me(R,{rows:1,fields:m[O].map(u=>({...u,rows:1}))}))}}),{outcomes:i,notes:[...T,...w?.notes??[]],...R?{writtenWithoutFields:R}:{},cancelled:w!==void 0,ownersRefused:[...L],lookupsLeftOut:[...v>0?[{records:v,fields:[...f].sort(),reason:"notInTarget"}]:[],...w?.lookupsLeftOut??[]]}}async executeOperation(e,n,r,s,o){if(this.deps.crudFlsGuard){let a=r.length>0?Object.keys(r[0]):[],i=await this.deps.crudFlsGuard.checkCrudAndFls(e,n,a);if(!i.allowed)throw new Error(`CRUD/FLS check failed for ${n} on ${e}: ${i.reason}`)}switch(n){case"insert":return this.deps.insert(e,r,s);case"update":return this.deps.update(e,r,s);case"upsert":return this.deps.upsert(e,o??"Id",r,s);case"delete":{let a=r.map(i=>i.Id).filter(i=>typeof i=="string");return this.deps.delete(e,a,s)}}}},Ke=["INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY","INVALID_CROSS_REFERENCE_KEY"],qe=/cross[- ]reference id|r[ée]f[ée]rence crois[ée]e/i;function J(t){return Ke.some(e=>t.includes(e))||qe.test(t)}var N="OwnerId";function He(t,e,n){let r=new Set;return n&&t.forEach((s,o)=>{let a=s[N];typeof a!="string"||e[o]?.has(N)||n.links.isOwnerRefused(a)&&(delete s[N],r.add(o))}),r}function je(t,e){let n=0;for(let r of t)e[r]?.success&&n++;if(n!==0)return{records:n,fields:[N],reason:"ownerRefusedEarlier"}}function Ye(t,e,n,r,s){let o=s instanceof Error?s.message:String(s),a=new Set,i=new Set,y=0;return r.forEach((c,h)=>{if(c===null){y++;let m=n[h];for(let T of Object.keys(e[t[h]]))T in m||a.add(T)}else for(let{field:m}of c)i.add(m)}),[...y>0?[`${y} record(s) the target refused for a lookup it does not have could not be written again without ${[...a].sort().join(", ")}: ${o}`]:[],...i.size>0?[`${t.length-y} record(s) the target refused on fields it named could not be written again without ${[...i].sort().join(", ")}: ${o}`]:[]]}var D=class{ids=new Set;named=new Set;said;add(e,n){this.ids.add(e),this.named.add(n)}addRow(e,n){let r=String(e.Id);for(let s of Object.keys(e))s!=="Id"&&this.add(r,s);n!==void 0&&n!==""&&(this.said??=n)}get records(){return this.ids.size}get recordIds(){return this.ids}fields(){return[...this.named].sort()}leftOut(e){if(this.ids.size!==0)return{records:this.ids.size,fields:this.fields(),reason:e,...this.said!==void 0?{refusal:this.said}:{}}}};function U(t,e){return t.flatMap(({index:n,field:r,parent:s})=>{let o=e[n];return o?.success&&typeof o.id=="string"&&o.id!==""?[{id:o.id,field:r,parent:s}]:[]})}function vt(t){return new Set(t.map(({id:e})=>e)).size}function Q(t){let e=new D;for(let{id:r,field:s}of t)e.add(r,s);let n=e.leftOut("notReached");return n?[n]:[]}function Me(t,e){if(!(e.success||t!=="insert"&&t!=="upsert"))return e.existingId!==void 0&&e.existingId!==""?e.existingId:void 0}async function Ve(t,e,n,r){let s=await e(n);try{return[...s,...await e(r)]}catch(o){throw o instanceof x?new x(t,[...s,...o.written],o.notes,o.lookupsLeftOut,o.writtenWithoutFields):o}}function De(t,e,n,r,s){if(!s?.createdWithoutRecordType||e.size===0)return;let o=[],a=[];for(let[c,h]of e){let m=n[c];!m?.success||typeof m.id!="string"||m.id===""||t.operation!=="insert"&&m.created!==!0||(o.push(h),a.length<ke&&a.push(m.id))}let i=Ie(s.recordTypesUnderTheLease??r?.recordTypes??[],s.recordTypes),y=Ae(t.objectApiName,o,i);y&&s.createdWithoutRecordType.set(t.objectApiName,{given:y,types:i,ids:a})}function Ze(t,e,n,r){t.objectApiName==="Opportunity"&&(t.operation!=="insert"&&t.operation!=="upsert"||e.forEach((s,o)=>{let a=n[o],i=s[se];!a?.success||typeof a.id!="string"||a.id===""||t.operation!=="insert"&&a.created!==!0||typeof i=="string"&&i!==""&&r.noteSentWithContact(a.id,i)}))}function $e(t,e,n){if(t.operation==="delete")return;let r=t.operation==="insert"||t.operation==="upsert";e.forEach((s,o)=>{let a=n.sources[o]?.Id;if(typeof a!="string"||a==="")return;let i=Me(t.operation,s);s.success&&typeof s.id=="string"&&s.id!==""?n.links.noteWritten(a,s.id):i!==void 0?n.links.noteWritten(a,i):!s.success&&r&&n.links.noteRefused(a,t.objectApiName)})}function Je(t,e){return e.length>0?{...t,currenciesReplaced:[...e]}:t}var _e=1e3;function Qe(t,e,n,r=[],s=[],o){let a=0,i=0,y=0,c,h=[],m=0,T={created:0,updated:0},w={rows:0,written:0,stillLocked:0};for(let f of n)f.lockResends!==void 0&&(w.rows++,f.success?w.written++:we(f.errors,f.errorDetails)&&w.stillLocked++),f.success?(a++,f.created===!0?T.created++:f.created===!1&&T.updated++):Me(e,f)!==void 0?(y++,c??=f.errors[0]):(i++,!f.heldBack&&m++<_e&&h.push(...f.errors));let W=Math.max(0,m-_e);return{objectApiName:t,operation:e,processed:n.length,success:a,failed:i,skipped:y,conflictCount:0,errors:[...h,...r],...y>0?{linkedToExisting:{records:y,...c?{refusal:c}:{}}}:{},...s.length>0?{lookupsLeftOut:[...s]}:{},...o?{writtenWithoutFields:o}:{},...w.rows>0?{sentAgainForALock:w}:{},...W>0?{refusalsDropped:W}:{},...e==="upsert"?{upsertSplit:T}:{}}}export{We as a,Ae as b,Ie as c,Ee as d,yt as e,gt as f,ht as g,Pe as h,Rt as i,Ot as j,xe as k,x as l,Ne as m,vt as n,Q as o,Me as p,Je as q,_e as r,Qe as s};
|
package/lib/chunk-GTRU5AV5.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __sandforgeRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __sandforgePath } from 'node:url';
|
|
3
|
-
import { dirname as __sandforgeDirname } from 'node:path';
|
|
4
|
-
const require = __sandforgeRequire(import.meta.url);
|
|
5
|
-
const __filename = __sandforgePath(import.meta.url);
|
|
6
|
-
const __dirname = __sandforgeDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-OS5GE52G.mjs";import"./chunk-BPHTA6KP.mjs";import"./chunk-U2CTKIPE.mjs";import"./chunk-NDFFIJL5.mjs";import"./chunk-I5C4O3VA.mjs";import"./chunk-RVCPQVKM.mjs";import"./chunk-FKCIGJOI.mjs";import"./chunk-C6RKM4BB.mjs";import"./chunk-IHGYJZZ2.mjs";import"./chunk-XCA5AONB.mjs";import"./chunk-66NMFCWX.mjs";import"./chunk-WB2RIVO3.mjs";import"./chunk-AXFD2OH6.mjs";import"./chunk-X2XZQ434.mjs";import"./chunk-CE6ZDGBB.mjs";import"./chunk-O7GCCRPW.mjs";import"./chunk-4X5D3MSV.mjs";import"./chunk-BOGNK4LV.mjs";import"./chunk-XMQ5R6TC.mjs";import"./chunk-IXIY6Q4M.mjs";import"./chunk-T63U4OZJ.mjs";import"./chunk-YYZL7UGV.mjs";import"./chunk-54HYHHVL.mjs";import"./chunk-QIRO4HTE.mjs";import"./chunk-BT43WSOS.mjs";import"./chunk-QSRAEUGZ.mjs";import"./chunk-EOQON3E5.mjs";import"./chunk-Y7YUNRKK.mjs";import"./chunk-4JKR4PTZ.mjs";import"./chunk-N2HYG3BL.mjs";import"./chunk-7WSQ65WG.mjs";import"./chunk-MJD6CPZZ.mjs";import"./chunk-5LFSFYFJ.mjs";import"./chunk-OUU47Y7A.mjs";import"./chunk-4GCYGQXD.mjs";import"./chunk-WXU6ZJIV.mjs";import"./chunk-R3OM3X4L.mjs";import"./chunk-77IVKH7R.mjs";import"./chunk-2WMKJVD2.mjs";import"./chunk-PPGDAUEQ.mjs";import"./chunk-VV3B6IC3.mjs";import"./chunk-4TLYUZD5.mjs";import"./chunk-VXZ5PTOM.mjs";import"./chunk-INIT2UKJ.mjs";import"./chunk-SU65Z2BA.mjs";import"./chunk-HF6LAK3G.mjs";import"./chunk-ZOSESZ22.mjs";import"./chunk-ZXOUWHYE.mjs";import"./chunk-TQ2TQHTT.mjs";import"./chunk-HFSBDM7B.mjs";import"./chunk-OHEOJISY.mjs";import"./chunk-PC247GKX.mjs";import"./chunk-EADHKH3A.mjs";import"./chunk-Z3MGN42K.mjs";import"./chunk-2GSMHGIV.mjs";import"./chunk-TZE3Y7IQ.mjs";import"./chunk-CA5NAXSU.mjs";import"./chunk-ISOSTAJR.mjs";import"./chunk-UNDIBZWG.mjs";import"./chunk-ICIYL45C.mjs";import"./chunk-7BQMBXKX.mjs";import"./chunk-KWAVSZ2B.mjs";import"./chunk-TUACWKIH.mjs";import"./chunk-6QSHWIZI.mjs";import"./chunk-WZQEK4WT.mjs";import"./chunk-NTOVCTRS.mjs";export{d as CheckpointTakeStopped,a as DEFAULT_MAX_TOTAL,b as OBJECT_ROWS_MAX,f as holdingLimit,e as pastTheLimit,g as scopeCheckpoint,h as takeCheckpoint,c as takeOrgOf};
|